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
p02732
u478719560
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
['import collections\nfrom sys import stdin\nn = int(stdin.readline().rstrip())\nass = list(map(int, stdin.readline().rstrip().split()))\n\nc = collections.Counter(ass)\n\ncnum =[0]*len(c)\nkeys = c.keys()\n\ncs = {}\nfor i in keys:\n key = c[i]\n combi = key *(key-1) / 2\n cs[i] = combi\n\nsum = sum(cs.values())\n\nfor i in range(n):\n add = c[ass[i]]-1\n adds = add *(add-1) / 2\n ans = sum - cs[ass[i]] + adds\n print(ans)\n', 'import collections\nfrom sys import stdin\nn = int(stdin.readline().rstrip())\nass = list(map(int, stdin.readline().rstrip().split()))\n\nc = collections.Counter(ass)\n\ncnum =[0]*len(c)\nkeys = c.keys()\n\ncs = {}\nfor i in keys:\n key = c[i]\n combi = key *(key-1) / 2\n cs[i] = combi\n\nsum = sum(cs.values())\n\nfor i in range(n):\n add = c[ass[i]]-1\n adds = add *(add-1) / 2\n ans = sum - cs[ass[i]] + adds\n print(int(ans))\n']
['Wrong Answer', 'Accepted']
['s594292986', 's822253592']
[35484.0, 35272.0]
[568.0, 524.0]
[425, 430]
p02732
u482157295
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
['from collections import Counter\nn = int(input())\nnum_list = list(map(int,input().split()))\na = Counter(num_list)\ncount = 0\nfor i in a.values():\n count += (i*(i-1))//2\nfor j in num_list:\n', 'from collections import Counter\nn = int(input())\nnum_list = list(map(int,input().split()))\na = Counter(num_list)\ncount = 0\nfor i in a.values():\n count += (i*(i-1))//2\nfor j in num_list:\n print(count-(a[j]-1))']
['Runtime Error', 'Accepted']
['s163856407', 's172486714']
[2940.0, 26780.0]
[17.0, 314.0]
[187, 210]
p02732
u485566817
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
['import collections\n\nn = int(input())\na = list(map(int, input().split()))\n\nnum_count = collections.Counter(a)\ntotal = sum([num*(num-1)//2 for num in num_count.values()])\n\nfor i in range(n):\n print(total-a.count(a[i]+1))', 'import collections\n\nn = int(input())\na = list(map(int, input().split()))\n\nnum_count = collections.Counter(a)\ntotal = sum([num*(num-1)//2 for num in num_count.values()])\n\nfor i in range(n):\n print(total-num_count[a[i]]+1)']
['Wrong Answer', 'Accepted']
['s301014128', 's586005183']
[26780.0, 26780.0]
[2104.0, 322.0]
[221, 223]
p02732
u489959379
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
['from collections import Counter\nfrom math import factorial\n\n\nn = int(input())\na = list(map(int, input().split()))\nd = Counter(a)\nc = [0 for _ in range(max(a))]\nfor k, v in d.items():\n if v > 2:\n c[k - 1] = factorial(v) / factorial(2) / factorial(v - 2)\n else:\n c[k - 1] = 0\n \nfor i in range(n):\n ans = sum(c)\n p = a[i]\n res = c[p - 1] * (d[p] - 2) / d[p]\n ans -= c[p - 1] - res\n print(int(ans))\n', 'from collections import Counter\n\nn = int(input())\na = list(map(int, input().split()))\nd = Counter(a)\nc = [0 for _ in range(max(a))]\nfor k, v in d.items():\n c[k - 1] = v * (v - 1) / 2\n\nans = sum(c)\nfor i in range(n):\n p = a[i]\n res = c[p - 1] * (d[p] - 2) / d[p]\n ans -= c[p - 1] - res\n print(int(ans))\n ans += c[p - 1] - res\n']
['Runtime Error', 'Accepted']
['s620312909', 's835324544']
[26772.0, 26908.0]
[2104.0, 651.0]
[437, 343]
p02732
u490489966
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
['\nfrom collections import Counter\nn = int(input())\na = list(map(int, input().split()))\nc = Counter(a)\nval=0\nfor i in c.values():\n print(i) \n val += i * (i - 1) // 2 \n # val+=sum(range(i-1))\nfor i in range(n):\n b = c[a[i]] \n print(val - b + 1) ', '#D AC\nfrom collections import Counter\nn = int(input())\na = list(map(int, input().split()))\nc = Counter(a)\nval=0\nfor i in c.values():\n \n val += i * (i - 1) // 2 \n # val+=sum(range(i-1))\nfor i in range(n):\n b = c[a[i]] \n print(val - b + 1) ']
['Wrong Answer', 'Accepted']
['s943920220', 's367400221']
[25900.0, 25900.0]
[440.0, 352.0]
[540, 527]
p02732
u502731482
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
['from collections import defaultdict\n\nn = int(input())\na = list(map(int, input().split()))\n\ndic = defaultdict(int)\nans1 = defaultdict(int)\nans2 = defaultdict(int)\n\ndef calc_patern1(n, ans, dic):\n for k, v in dic.items():\n ans[k] = v * (v - 1) / 2\n\n\ndef calc_patern2(n, ans, dic):\n for k, v in dic.items():\n ans[k] = (v - 1) * (v - 2) / 2\n\nfor i in range(n):\n dic[a[i]] += 1\nfor v in dic.values():\n calc_patern1(a[i], ans1, dic)\n calc_patern2(a[i] - 1, ans2, dic)\nprint(ans1, ans2)\nfor i in range(n):\n ans = 0\n for k, v in dic.items():\n #print(ans)\n if k == a[i]:\n ans += ans2[k]\n else:\n ans += ans1[k]\n print(int(ans))', 'from collections import defaultdict, Counter\n\nn = int(input())\na = list(map(int, input().split()))\nans = [0] * n\ndic = defaultdict(int)\nfor i in range(n):\n dic[a[i]] += 1\n\nsum = 0\nfor v in dic.values():\n sum += v * (v - 1) / 2\n \nfor i in range(n):\n print(int(sum - (dic[a[i]] - 1)))']
['Wrong Answer', 'Accepted']
['s286923630', 's121089851']
[41884.0, 26908.0]
[2105.0, 412.0]
[698, 294]
p02732
u503111914
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
['from collections import Counter\nN = int(input())\nA = list(map(int,input().split()))\nB = Counter(A)\nC = {key:(B[key]*(B[key]-1)//2) for key in B}\nans = sum(B.values())\nfor i in A:\n if C[i] < 2:\n print(ans)\n else:\n ans = ans - C[i] +(B[key-1]*(B[key]-2)//2)\n print(ans)', 'from collections import Counter\nN = int(input())\nA = list(map(int,input().split()))\nB = Counter(A)\nC = {key:(B[key]*(B[key]-1)//2) for key in B}\nans = sum(C.values())\n#print(C,ans)\n#print(C[3])\nfor i in A:\n if C[i] < 1:\n print(ans)\n else:\n print(ans - C[i] + (B[i]-1)*(B[i]-2)//2)']
['Runtime Error', 'Accepted']
['s152519800', 's689481386']
[30780.0, 32020.0]
[153.0, 444.0]
[294, 300]
p02732
u514401521
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
['import sys\nsys.setrecursionlimit(10**6)\nfrom collections import defaultdict\n\nN = int(input())\nA = list(map(int, input().split()))\n\nd = defaultdict(int)\n\nfor i in range(N):\n d[A[i]] += 1\n\nprint(d)\na = defaultdict(int)\nb = defaultdict(int)\nfor key, value in d.items():\n a[key] = value * (value - 1) //2\n b[key] = value * (value - 1) //2 - (value - 1) * (value - 2) // 2\n#print(a)\n#print(b)\ntotal = 0\nfor key, value in a.items():\n total += value\n#print(total)\nfor i in range(N):\n ans = total - b[A[i]]\n print(ans)', 'import sys\nsys.setrecursionlimit(10**6)\nfrom collections import defaultdict\n\nN = int(input())\nA = list(map(int, input().split()))\n\nd = defaultdict(int)\n\nfor i in range(N):\n d[A[i]] += 1\n\n#print(d)\na = defaultdict(int)\nb = defaultdict(int)\nfor key, value in d.items():\n a[key] = value * (value - 1) //2\n b[key] = value * (value - 1) //2 - (value - 1) * (value - 2) // 2\n#print(a)\n#print(b)\ntotal = 0\nfor key, value in a.items():\n total += value\n#print(total)\nfor i in range(N):\n ans = total - b[A[i]]\n print(ans)']
['Wrong Answer', 'Accepted']
['s372417661', 's088802979']
[40244.0, 38964.0]
[556.0, 470.0]
[528, 529]
p02732
u517447467
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
['N = int(input())\nK = list(map(int, input().split()))\ncounter = dict()\nfor i in range(N):\n if K[i] not in counter:\n \tcounter[K[i]] = 1\n else:\n \tcounter[K[i]] += 1\n\nresults = 0\nremove_counter = dict()\nfor key, value in counter.items():\n remove_counter[key] = (value * (value - 1) / 2) - ((value - 1) * (value - 2) / 2)\n results += value * (value - 1) / 2\nfor i in range(N):\n print(results - remove_counter[K[i]])', 'N = int(input())\nK = list(map(int, input().split()))\ncounter = dict()\nfor i in range(N):\n if K[i] not in counter:\n \tcounter[K[i]] = 1\n else:\n \tcounter[K[i]] += 1\n\nresults = 0\nremove_counter = dict()\nfor key, value in counter.items():\n remove_counter[key] = (value * (value - 1) / 2) - ((value - 1) * (value - 2) / 2)\n results += value * (value - 1) / 2\nfor i in range(N):\n print(int(results - remove_counter[K[i]]))\n']
['Wrong Answer', 'Accepted']
['s654106237', 's348825289']
[35232.0, 34848.0]
[432.0, 471.0]
[418, 424]
p02732
u517797706
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
["\nif __name__ == '__main__':\n\n n = int(input())\n A = list(map(int,input().split()))\n\n \n d = Counter(A)\n \n d2 = dict()\n \n for k,v in d.items():\n d2[k] = (v*(v-1)) // 2\n ans_sum = sum(d2.values())\n\n \n for i in A:\n ans = 0\n if i in d2:\n \n tmp = d[i] - 1\n before= d2[i]\n after = (tmp*(tmp-1)) //2\n ans = ans_sum - (before-after)\n print(ans)\n else:\n \n print(ans_sum)\n", "from collections import Counter\n\nif __name__ == '__main__':\n\n n = int(input())\n A = list(map(int,input().split()))\n\n \n d = Counter(A)\n \n d2 = dict()\n \n for k,v in d.items():\n d2[k] = (v*(v-1)) // 2\n ans_sum = sum(d2.values())\n\n \n for i in A:\n ans = 0\n if i in d2:\n \n tmp = d[i] - 1\n before= d2[i]\n after = (tmp*(tmp-1)) //2\n ans = ans_sum - (before-after)\n print(ans)\n else:\n \n print(ans_sum)\n"]
['Runtime Error', 'Accepted']
['s678913857', 's591340897']
[32348.0, 34236.0]
[70.0, 309.0]
[605, 637]
p02732
u526094365
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
['import collections\nimport math\n\nN = int(input())\nA = list(map(int, input().split()))\nc = collections.Counter(A)\ncnt = 0\nansx = []\nansy = []\nansy2 = []\n\nfor x, y in c.items():\n sumall += (y*(y-1)//2)\n ansy2.append(y-1)\n ansx.append(x)\n\nfor i in A:\n print(sumall - ansy2[ansx.index(i)])\n', 'import collections\nimport math\n\nN = int(input())\nA = list(map(int, input().split()))\nc = collections.Counter(A)\ncnt = 0\nansx = []\nansy = []\nansy2 = []\n\nfor x, y in c.items():\n sumall += (y*(y-1)//2))\n ansy2.append(y-1)\n ansx.append(x)\n\nfor i in A:\n print(sumall - ansy2[ansx.index(i)])\n', 'import collections\nimport math\n\nN = int(input())\nA = list(map(int, input().split()))\nc = collections.Counter(A)\ncnt = 0\n\n\nsumall = 0\nfor x, y in c.items():\n sumall += (y*(y-1)//2)\n\nfor i in range(N):\n print(sumall - c[A[i]] + 1)\n']
['Runtime Error', 'Runtime Error', 'Accepted']
['s111251894', 's876009264', 's025268467']
[26772.0, 2940.0, 26772.0]
[94.0, 18.0, 365.0]
[297, 298, 235]
p02732
u530786533
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
['n = int(input())\na = list(map(int, input().split()))\n\nfrom collections import Counter\nc = Counter(a)\n\nprint(c)\nfor i in range(n):\n c[a[i]] -= 1\n tmp = [x*(x-1)//2 for x in c.values()]\n print(sum(tmp))\n c[a[i]] += 1\n', 'n = int(input())\na = list(map(int, input().split()))\n\nfrom collections import Counter\nc = Counter(a)\ncombi = {}\nfor k, v in c.items():\n combi[k] = v*(v-1)//2\nsumc = sum(list(combi.values()))\n\nfor i in range(n):\n x = c[a[i]] - 1\n ans = sumc - combi[a[i]] + x*(x-1)//2\n print(ans)\n']
['Wrong Answer', 'Accepted']
['s113185833', 's888368532']
[37024.0, 32212.0]
[2105.0, 439.0]
[223, 287]
p02732
u531603069
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
['import copy\nN = int(input())\nA = list(map(int, input().split()))\n\na_types = set(A)\nfor each in a_types:\n count_dict[each - 1] += A.count(each)\n\ncount_dict = [0] * N\nfor each in A:\n count_dict[each - 1] += 1\n\nall_types = 0\nfor value in count_dict:\n all_types += value * (value - 1) // 2\n\n# result_dict = {}\n# for each in a_types:\n# result_dict[each] = all_types - count_dict[each] + 1\n\nfor a in A:\n print(all_types - count_dict[a - 1] + 1)', 'import copy\nN = int(input())\nA = list(map(int, input().split()))\n\na_types = set(A)\ncount_dict = [0] * N\nfor each in a_types:\n count_dict[each - 1] = A.count(each)\n\nfor each in A:\n count_dict[each - 1] += 1\n\nall_types = 0\nfor value in count_dict:\n all_types += value * (value - 1) // 2\n\n# result_dict = {}\n# for each in a_types:\n# result_dict[each] = all_types - count_dict[each] + 1\n\nfor a in A:\n print(all_types - count_dict[a - 1] + 1)', 'import copy\nN = int(input())\nA = list(map(int, input().split()))\n\na_types = set(A)\n\ncount_dict = {}\nfor each in a_types:\n count_dict[each] = A.count(each)\nprint(count_dict)\n\nall_types = 0\nfor value in count_dict.values():\n all_types += value * (value - 1) / 2\n\nfor a in A:\n print(int(all_types - count_dict[a] + 1))\n# no_execlusion_results = {}\n# for each in a_types:\n# no_execlusion_results[each] = \n# result_dict = {}\n# for each in a_types:\n# tmp_dict = copy.deepcopy(count_dict)\n# tmp_dict[each] = count_dict[each] - 1\n# combinations = 0\n# for value in tmp_dict.values():\n# combinations += int(value * (value - 1) / 2)\n# result_dict[each] = combinations\n# \n# print(result_dict)\n# for a in A:\n# print(result_dict[a])', 'import copy\nN = int(input())\nA = list(map(int, input().split()))\n\na_types = set(A)\n\ncount_dict = [0] * N\nfor each in A:\n count_dict[each - 1] += 1\n\nall_types = 0\nfor value in count_dict:\n all_types += value * (value - 1) // 2\n\n# result_dict = {}\n# for each in a_types:\n# result_dict[each] = all_types - count_dict[each] + 1\n\nfor a in A:\n print(all_types - count_dict[a - 1] + 1)']
['Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s161477503', 's578432179', 's903229811', 's628830366']
[26908.0, 26780.0, 26908.0, 26908.0]
[89.0, 2104.0, 2104.0, 321.0]
[454, 453, 763, 391]
p02732
u534338602
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
['n= int(input())\na=list(map(int, input().split()))\nb = [0]*(n+1)\nc = [0]*(n+1)\nsu = 0\n\nfor x in range(n):\n b[a[x]] += 1\n\nfor y in range(len(b)):\n if b[y] >=2:\n c[y]=combinations_count(b[y], 2)\n else:\n c[y]=0\n su += c[y]\n\nfor z in range(n):\n if c[a[z]] > 0:\n ans = su - (b[a[z]] - 1)\n else:\n ans = su\n\n print(str(ans))', 'import math\n\ndef combinations_count(n, r):\n return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))\n\nn= int(input())\na=list(map(int, input().split()))\nb = [0]*(n+1)\nc = [0]*(n+1)\nsu = 0\n\nfor x in range(n):\n b[a[x]] += 1\n\nfor y in range(len(b)):\n if b[y] >=2:\n c[y]=combinations_count(b[y], 2)\n else:\n c[y]=0\n su += c[y]\n\nfor z in range(n):\n if c[a[z]] > 0:\n ans = su - (b[a[z]] - 1)\n else:\n ans = su\n\n print(str(ans))']
['Runtime Error', 'Accepted']
['s518789606', 's393489352']
[26140.0, 25644.0]
[142.0, 1779.0]
[365, 485]
p02732
u535171899
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
['from collections import Counter\nn = int(input())\na_input = list(map(int,input().split()))\n\na_count = Counter(a_input)\n\nscore_dic={}\nexclude_dic={}\n\nfor k,v in enumerate(a_count.items()):\n score_dic[k]=v*(v-1)//2\n exclude_dic[k]=(v-1)*(v-2)//2\n\nscore_sum = sum(score_dic.values())\n\nfor i in range(n):\n print(score_sum-score_dic[a_input[i]]+exclude_dic[a_input[i]])', 'from collections import Counter\nn = int(input())\na_input = list(map(int,input().split()))\n\na_count = Counter(a_input)\n\nscore_dic={}\nexclude_dic={}\n\nfor k,v in a_count.items():\n score_dic[k]=v*(v-1)//2\n exclude_dic[k]=(v-1)*(v-2)//2\n\nscore_sum = sum(score_dic.values())\n\nfor i in range(n):\n print(score_sum-score_dic[a_input[i]]+exclude_dic[a_input[i]])\n\n']
['Runtime Error', 'Accepted']
['s372033621', 's819668573']
[26780.0, 38964.0]
[102.0, 397.0]
[372, 363]
p02732
u537892680
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
['N = int(input())\nA = [int(a) for a in input().split()]\ncnt = {}\ntotal = 0\n\nfor a in A:\n if a not in cnt:\n cnt[a] = 0\n cnt[a] += 1\n\nfor i in cnt.values():\n total += i * (i - 1) // 2\n\nfor i in range(N):\n print(total - (cnt[i] - 1))\n', '# D - Banned K\n\nfrom collections import Counter\n\nN = int(input())\nA = [int(a) for a in input().split()]\n\ncounter = Counter(A)\ntotal = 0\nfor v in counter.values():\n total += v * (v - 1) // 2\n\nfor i in range(N):\n print(total - (counter[A[i]] - 1))\n']
['Runtime Error', 'Accepted']
['s071344434', 's627533312']
[25768.0, 26780.0]
[166.0, 359.0]
[249, 252]
p02732
u538361257
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
['\ndef Get_nC2(n):\n return int(n*(n-1) / 2);\n\n\nN = int(input())\nA_i = list(map(int, input().split()))\n\nfor a_i in A_i:\n cnt = 0\n for j in range(min(A_i), max(A_i)):\n j_cnt = A_i.count(j)\n if a_i == j:\n j_cnt -= 1\n\n cnt += Get_nC2(j_cnt)\n\n print(cnt)\n', '\ndef Get_nC2(n):\n return int(n*(n-1) / 2);\n\n\nN = int(input())\nA_i = list(map(int, input().split()))\n\ncnt_dict = {}\nfor a_i in A_i:\n cnt = 0\n if a_i in cnt_dict:\n print(cnt_dict[a_i])\n continue\n else:\n for j in range(min(A_i), max(A_i)+1):\n j_cnt = A_i.count(j)\n if a_i == j:\n j_cnt -= 1\n\n cnt += Get_nC2(j_cnt)\n\n cnt_dict[a_i] = cnt\n\n print(cnt)\n', '\ndef Get_nC2(n):\n return int(n*(n-1) / 2);\n\n\nN = int(input())\nA_i = list(map(int, input().split()))\n\ncnt_dict = {}\nfor a_i in A_i:\n cnt = 0\n if a_i in cnt_dict:\n print(cnt_dict[a_i])\n continue\n else:\n for j in range(min(A_i), max(A_i)+1):\n j_cnt = A_i.count(j)\n if a_i == j:\n j_cnt -= 1\n\n cnt += Get_nC2(j_cnt)\n\n cnt_dict[a_i] = cnt\n\n print(cnt)\n', 'from collections import Counter\n\ndef Get_nC2(n):\n return int(n*(n-1) / 2)\n\n\nN = int(input())\nA_i = list(map(int, input().split()))\n\nc = Counter(A_i)\ncnt_dict = {}\n\ntotal = sum(list(map(Get_nC2, tmp.values())))\n\nfor a_i in A_i:\n result = total - Get_nC2(c[a_i]) + Get_nC2(c[a_i-1])\n print(result)\n', 'from collections import Counter\n\ndef Get_nC2(n):\n return int(n*(n-1) / 2)\n\n\nN = int(input())\nA_i = list(map(int, input().split()))\n\nc = Counter(A_i)\n\n\ntotal = sum(list(map(Get_nC2, c.values())))\n\nfor a_i in A_i:\n result = total - Get_nC2(c[a_i]) + Get_nC2(c[a_i]-1)\n print(result)\n']
['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Accepted']
['s229111282', 's230279103', 's385782741', 's471199353', 's015538419']
[26140.0, 25716.0, 2940.0, 26780.0, 26780.0]
[2104.0, 2104.0, 17.0, 98.0, 547.0]
[292, 437, 421, 306, 291]
p02732
u541017633
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
['import math\nN, *A = map(int,inp.split())\n\nfor e in A:\n d = dict((i, A.count(i)) for i in set(A))\n d[e]-=1\n \n ans = 0\n for i in list(d):\n if d[i] < 2:\n continue\n ans += d[i]*(d[i]-1)/2\n print(int(ans))\n ', 'import math\nN, *A = map(int,input().split())\n\nfor e in A:\n d = dict((i, A.count(i)) for i in set(A))\n d[e]-=1\n \n ans = 0\n for i in list(d):\n if d[i] < 2:\n continue\n ans += d[i]*(d[i]-1)/2\n print(int(ans))\n ', 'n = int(input())\na = list(map(int,input().split()))\n\nad = dict((i, a.count(i)) for i in set(a))\n\nfor i in range(n):\n ans = 0\n for v in list(ad):\n ans += ad[v]*(ad[v]-1)//2 if a[v] != v else (ad[v]-1)*(ad[v]-2)//2\n \n print(ans)', 'import math\nN = input()\nA = map(int,inp.split())\n\nfor e in A:\n d = dict((i, A.count(i)) for i in set(A))\n d[e]-=1\n \n ans = 0\n for i in list(d):\n if d[i] < 2:\n continue\n ans += d[i]*(d[i]-1)/2\n print(int(ans))\n ', 'import math\nN = input()\nA = map(int,input().split())\n\nfor e in A:\n d = dict((i, A.count(i)) for i in set(A))\n d[e]-=1\n \n ans = 0\n for i in list(d):\n if d[i] < 2:\n continue\n ans += d[i]*(d[i]-1)/2\n print(int(ans))\n ', 'n = int(input())\na = list(map(int,input().split()))\n\nad = {}\nfor i in range(n) :\n if a[i] in ad :\n ad[a[i]] += 1\n else :\n ad[a[i]] = 1\n\nans = 0\nfor v in ad.values():\n ans += v*(v-1)//2\n\nfor i in range(n):\n v = ad[a[i]]\n print(ans-v*(v-1)//2+(v-1)*(v-2)//2)']
['Runtime Error', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s144302541', 's160267036', 's209352827', 's492522634', 's512759244', 's683458426']
[3060.0, 3060.0, 26268.0, 3060.0, 25256.0, 24748.0]
[17.0, 18.0, 2104.0, 17.0, 79.0, 403.0]
[248, 252, 234, 256, 260, 285]
p02732
u547608423
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
['N=int(input())\nA=list(map(int,input().split()))\n\n\ndict_A={}\nB=list(set(A))\nsum=0\n\n\nfor b in B:\n a=A.count(b)\n sum+=a*(a-1)//2\n\nfor a in A:\n print(sum-a+1)\n\n ', 'N=int(input())\nA=list(map(int,input().split()))\n\n\ndict_A={}\nB=list(set(A))\nsum=0\n\n\nfor a in A:\n if a not in dict_A.keys():\n dict_A[a]=1\n else:\n dict_A[a]+=1\nfor b in B:\n sum+=dict_A[b]*(dict_A[b]-1)//2\n\nfor a in A:\n print(sum-dict_A[a]+1)\n\n ']
['Wrong Answer', 'Accepted']
['s445018518', 's688715425']
[24872.0, 28604.0]
[2104.0, 366.0]
[173, 274]
p02732
u549383771
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
['\nn = int(input())\nnum_list = list(map(int,input().split()))\nnum_list2 = [0]*n\nnum_list3 = [0]*n\nfor i in num_list:\n num_list2[i-1] += 1\nfor i in range(n):\n num_list3[i-1] = n*(n-1) // 2\n\nfor i in num_list:\n ans = n*(n-1) // 2\n print(ans-num_list3[i-1]+sum(num_list3))\n # elif size == 1:\n \n # else :\n # ans = 0 \n #num_list5[num_list2[i]-1] = ans\n', 'import math\nimport numpy as np\ndef comb(n, r):\n if n == -1:\n n = 0\n return n*(n-1) // 2\nn = int(input())\nnum_list = map(int,input().split())\nnum_list2 = [0]*n\nnum_list3 = [0]*n\nfor i in num_list:\n num_list2[i-1] += 1\nfor i in range(n):\n # size = max(0 , num_list3[num_list2[i]-1])\n# if size >= 2:\n ans = comb(num_list2[i-1],2)\n # elif size == 1:\n # ans = 0\n # else :\n # ans = 0 \n num_list3[i-1] = ans\n\nfor i in num_list:\n # size = max(0 , num_list3[num_list2[i]-1]-1)\n # if size >= 2:\n ans = comb(num_list2[i-1]-1,2)\n print(ans-num_list3[i-1]+np.sum(num_list3))\n # elif size == 1:\n \n # else :\n # ans = 0 \n #num_list5[num_list2[i]-1] = ans\n', "%%time\nimport math\nimport numpy as np\ndef comb(n, r):\n return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))\nn = int(input())\nnum_list = input().split(' ')\nnum_list2 = [int(n) for n in num_list]\nnum_list3 = [0]*n\nnum_list4 = [0]*n\nnum_list5 = [0]*n\nfor i in range(len(num_list2)):\n num_list3[num_list2[i]-1] += 1\nfor i in range(len(num_list2)):\n if num_list4[num_list2[i]-1] == 0:\n size = max(0 , num_list3[num_list2[i]-1])\n if size >= 2:\n ans = comb(size,2)\n elif size == 1:\n ans = 0\n else :\n ans = 0 \n num_list4[num_list2[i]-1] = ans\n\n if num_list5[num_list2[i]-1] == 0:\n size = max(0 , num_list3[num_list2[i]-1]-1)\n if size >= 2:\n ans = comb(size,2)\n elif size == 1:\n ans = 0\n else :\n ans = 0 \n num_list5[num_list2[i]-1] = ans\nfor i in range(n):\n print(num_list5[num_list2[i]-1]-num_list4[num_list2[i]-1]+np.sum(num_list4))", 'n = int(input())\nnum_list = list(map(int,input().split()))\nnum_list2 = [0]*n\nnum_list3 = [0]*n\nfor i in num_list:\n num_list2[i-1] += 1\nfor i in range(n):\n ans = num_list2[i]*(num_list2[i]-1)//2\n num_list3[i] = ans\nsum_V = sum(num_list3)\nfor i in num_list:\n ans = (num_list2[i-1]-1)*(num_list2[i-1]-2)//2\n print(ans-num_list3[i-1]+sum_V)']
['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s264792927', 's905669996', 's977949418', 's299075722']
[26140.0, 29088.0, 2940.0, 25716.0]
[2105.0, 318.0, 17.0, 420.0]
[386, 721, 996, 352]
p02732
u552176911
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
['import math\n\n\ndef kumiawase(n):\n if n == 0 or n == 1:\n return 0\n return 5 * n + 5\n\n\nn = int(input())\naL = list(map(int, input().split(" ")))\n\nd = {}\n\nfor ai in aL:\n if ai in d:\n d[ai] += 1\n else:\n d[ai] = 1\n\nfor ai in aL:\n sm = 0\n for dk, di in d.items():\n if dk == ai:\n sm += kumiawase(di - 1)\n else:\n sm += kumiawase(di)\n print(sm)', 'import math\nimport collections\n\n\ndef kumiawase(n):\n if n == 0 or n == 1:\n return 0\n return (n**2 - n) // 2\n\n\nn = int(input())\naL = list(map(int, input().split(" ")))\n\nd = collections.Counter(aL)\n\ns = 0\nfor i in d.values():\n s += kumiawase(i)\n\nfor a in aL:\n print(s - kumiawase(d[a]) + kumiawase(d[a] - 1))\n']
['Wrong Answer', 'Accepted']
['s489407953', 's612714891']
[26140.0, 26780.0]
[2104.0, 529.0]
[411, 325]
p02732
u553070631
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
["import collections\nn=int(input())\na=list(map(int,input().split()))\nc = collections.Counter(a)\n\na1=len(list(set(a)))\n\ntotal=0\nfor j in range(a1):\n x=c.most_common()[j][1]\n total+=x*(x-1)/2\n print('total',total)\n\nfor i in range(n):\n ans=total-a.count(a[i])+1\n print(int(ans))", 'import collections \nfrom collections import defaultdict\nn=int(input())\na=list(map(int,input().split()))\nc=defaultdict(int)\nfor s in a:\n c[s]+=1\n\na1=list(set(a))\n\ntotal=0\nfor j in range(len(a1)):\n x=c[a1[j]]\n total+=x*(x-1)/2\n\nfor i in range(n):\n ans=total-c[a[i]]+1\n print(int(ans))']
['Wrong Answer', 'Accepted']
['s624749465', 's838772733']
[29080.0, 26780.0]
[2105.0, 443.0]
[288, 297]
p02732
u553600587
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
['from functools import lru_cache\n\nN = int(input().strip())\nA = [int(v) for v in input().strip().split()]\nC = {}\nS = {}\n\n\n@lru_cache\ndef calc(C, a):\n C[a] -= 1\n sum_ = sum([S[n] for n in C.values() if n > 1])\n C[a] += 1\n return sum_\n\nfor a in A:\n C.setdefault(a, 0)\n C[a] += 1\n\n\nfor i, a in enumerate(A):\n print(calc(C, a))\n', 'N = int(input().strip())\nA = [int(v) for v in input().strip().split()]\nC = {}\nS = {}\n\nfor a in A:\n C.setdefault(a, 0)\n C[a] += 1\n\nfor c in C.values():\n if c < 1:\n continue\n S.setdefault(c, c * (c - 1) // 2)\n if c < 2:\n continue\n S.setdefault(c - 1, c - 1 * (c - 2) // 2)\n\nfor i, a in enumerate(A):\n C[a] -= 1\n sum_ = sum([S[n] for n in C.values() if n > 1])\n C[a] += 1\n print(sum_)', 'N = int(input().strip())\nA = [int(v) for v in input().strip().split()]\nC = {}\nS = {}\n\nfor a in A:\n C.setdefault(a, 0)\n C[a] += 1\n\nfor c in C.values():\n if c < 1:\n continue\n C.setdefault(c, c * (c - 1) // 2)\n if c < 2:\n continue\n C.setdefault(c - 1, c * (c - 1) // 2)\n\nfor i, a in enumerate(A):\n C[a] -= 1\n sum_ = sum([S[n] for n in C.values() if n > 1])\n C[a] += 1\n print(sum_)', 'from functools import lru_cache\n\nN = int(input().strip())\nA = [int(v) for v in input().strip().split()]\nC = {}\n\n\n@lru_cache(maxsize=None)\ndef pair(k):\n return k * (k - 1) // 2\n\n@lru_cache(maxsize=None)\ndef calc(s, a):\n return s - pair(C[a]) + pair(C[a] - 1)\n\nfor a in A:\n C.setdefault(a, 0)\n C[a] += 1\n\nS = sum([pair(v) for v in C.values()])\n\nfor a in A:\n print(calc(S, a))\n']
['Runtime Error', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s040321682', 's292143978', 's808714369', 's845152161']
[26892.0, 26140.0, 26268.0, 52344.0]
[80.0, 2105.0, 153.0, 1454.0]
[343, 425, 421, 389]
p02732
u555458045
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
['n = int(input())\na = list(map(int, input().split()))\nfor i in range(n):\n acopy = a.copy()\n del acopy[i]\n c = collections.Counter(acopy)\n itm = c.values()\n ans = 0\n for j in itm:\n ans += j*(j-1)//2\n print(ans)\n', 'import collections\n\nsys.stdin = io.StringIO(_INPUT)\nn = int(input())\na = list(map(int, input().split()))\nfor i in range(n):\n acopy = a.copy()\n del acopy[i]\n c = collections.Counter(acopy)\n itm = c.values()\n ans = 0\n for j in itm:\n ans += j*(j-1)//2\n print(ans)', 'import collections\nn = int(input())\na = list(map(int, input().split()))\nc = collections.Counter(a)\nv = c.values()\ns = 0\nfor i in v:\n s += (i*(i-1))//2\n\nfor i in range(n):\n d = c[a[i]]\n x = (d*(d-1))//2 if d > 1 else 0\n y = ((d-1)*(d-2))//2 if d > 2 else 0\n print(s-x+y)\n']
['Runtime Error', 'Runtime Error', 'Accepted']
['s222061630', 's847421658', 's820696343']
[32232.0, 9228.0, 34180.0]
[74.0, 29.0, 259.0]
[237, 288, 285]
p02732
u555688810
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
['from collections import Counter,defaultdict\nimport sys\ninput = sys.stdin.readline\n\ndef cmb(n, r, mod):\n if ( r<0 or r>n ):\n return 0\n r = min(r, n-r)\n return g1[n] * g2[r] * g2[n-r] % mod\n\nmod = 10**9+7 \nN = 2*(10**5)\ng1 = [1, 1] \ng2 = [1, 1] \ninverse = [0, 1] 計算用テーブル\n\nfor i in range( 2, N + 1 ):\n g1.append( ( g1[-1] * i ) % mod )\n inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )\n g2.append( (g2[-1] * inverse[-1]) % mod )\n\n\nl = int(input())\nA=list(map(int, input().split()))\nS = Counter(A)\n\ndd=defaultdict(int)\nfor j in S.keys():\n S[j] -= 1\n tmp = []\n for k in S.keys():\n tmp.append(cmb(S[k],2,mod))\n dd[j] += sum(tmp)\n S[j] += 1\n\nfor i in A:\n print(dd[i])\n', 'from collections import Counter\n\ndef cmb(n, r, mod):\n if ( r<0 or r>n ):\n return 0\n r = min(r, n-r)\n return g1[n] * g2[r] * g2[n-r] % mod\n\nmod = 10**9+7 \nN = 10**4\ng1 = [1, 1] \ng2 = [1, 1] \ninverse = [0, 1] 計算用テーブル\n\nfor i in range( 2, N + 1 ):\n g1.append( ( g1[-1] * i ) % mod )\n inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )\n g2.append( (g2[-1] * inverse[-1]) % mod )\n\n\nl = int(input())\nA=list(map(int, input().split()))\n\nS = Counter(A)\n\nfor i in range(l):\n ans = 0\n S[A[i]] -= 1\n for j in S.keys():\n ans += cmb(S[j],2,mod)\n S[A[i]] += 1\n print(ans)\n', 'from collections import Counter\nimport sys\ninput = sys.stdin.readline\n\ndef cmb(n, r, mod):\n if ( r<0 or r>n ):\n return 0\n r = min(r, n-r)\n return g1[n] * g2[r] * g2[n-r] % mod\n\nmod = 10**9+7 \nN = 10**4\ng1 = [1, 1] \ng2 = [1, 1] \ninverse = [0, 1] 計算用テーブル\n\nfor i in range( 2, N + 1 ):\n g1.append( ( g1[-1] * i ) % mod )\n inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )\n g2.append( (g2[-1] * inverse[-1]) % mod )\n\n\nl = int(input())\n#A=list(map(int, input().split()))\nA=[int(i) for i in input().split()]\n\nS = Counter(A)\n\nfor i in range(l):\n ans = 0\n S[A[i]] -= 1\n for j in S.keys():\n ans += cmb(S[j],2,mod)\n S[A[i]] += 1\n print(ans)\n', 'from collections import Counter\nfrom operator import mul\nfrom functools import reduce\n\ndef combo(n):\n if n<1:\n return 0\n r = min(n-2,2)\n if r == 0: return 1\n over = reduce(mul, range(n, n - 2, -1))\n under = reduce(mul, range(1,2 + 1))\n return over // under\n\nN=int(input())\nA=list(map(int,input().split()))\ncount=Counter(A)\ncom={}\n\nfor k,v in count.items():\n com[k]=combo(v)\n s=sum(com.values())\n for i in range(N):\n su=s-combo(count[A[i]])+combo(count[A[i]]-1)\n print(su)', 'from collections import Counter\nimport sys\ninput = sys.stdin.readline\n\ndef cmb(n, r, mod):\n if ( r<0 or r>n ):\n return 0\n r = min(r, n-r)\n return g1[n] * g2[r] * g2[n-r] % mod\n\nmod = 10**9+7 \nN = 10**4\ng1 = [1, 1] \ng2 = [1, 1] \ninverse = [0, 1] 計算用テーブル\n\nfor i in range( 2, N + 1 ):\n g1.append( ( g1[-1] * i ) % mod )\n inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )\n g2.append( (g2[-1] * inverse[-1]) % mod )\n\n\nl = int(input())\n#A=list(map(int, input().split()))\nA=[int(i) for i in input().split()]\n\nS = Counter(A)\n\nfor i in range(l):\n tmp = []\n S[A[i]] -= 1\n for j in S.keys():\n tmp.append(cmb(S[j],2,mod))\n S[A[i]] += 1\n print(sum(tmp))\n', 'from collections import Counter\n\ndef cmb(n, r, mod):\n if ( r<0 or r>n ):\n return 0\n r = min(r, n-r)\n return g1[n] * g2[r] * g2[n-r] % mod\n\nmod = 10**9+7 \nN = 10**4\ng1 = [1, 1] \ng2 = [1, 1] \ninverse = [0, 1] 計算用テーブル\n\nfor i in range( 2, N + 1 ):\n g1.append( ( g1[-1] * i ) % mod )\n inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )\n g2.append( (g2[-1] * inverse[-1]) % mod )\n\n\nl = int(input())\nA=list(map(int, input().split()))\n\nS = Counter(A)\n\nfor i in range(l):\n ans = 0\n S[A[i]] -= 1\n for j in S.keys():\n ans += cmb(S[j],2,mod)\n S[A[i]] += 1\n print(ans)\n ', 'from collections import Counter\nimport sys\ninput = sys.stdin.readline\n\ndef cmb(n, r, mod):\n if ( r<0 or r>n ):\n return 0\n r = min(r, n-r)\n return g1[n] * g2[r] * g2[n-r] % mod\n\nmod = 10**9+7 \nN = 2*10**5\ng1 = [1, 1] \ng2 = [1, 1] \ninverse = [0, 1] 計算用テーブル\n\nfor i in range( 2, N + 1 ):\n g1.append( ( g1[-1] * i ) % mod )\n inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )\n g2.append( (g2[-1] * inverse[-1]) % mod )\n\n\nl = int(input())\nA=list(map(int, input().split()))\nS = Counter(A)\n\nfor i in A:\n tmp = []\n S[i] -= 1\n for j in S.keys():\n tmp.append(cmb(S[j],2,mod))\n S[i] += 1\n print(sum(tmp))\n', 'from collections import Counter\nimport sys\ninput = sys.stdin.readline\n\ndef cmb(n, r, mod):\n if ( r<0 or r>n ):\n return 0\n r = min(r, n-r)\n return g1[n] * g2[r] * g2[n-r] % mod\n\nmod = 10**9+7 \nN = 10**4\ng1 = [1, 1] \ng2 = [1, 1] \ninverse = [0, 1] 計算用テーブル\n\nfor i in range( 2, N + 1 ):\n g1.append( ( g1[-1] * i ) % mod )\n inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )\n g2.append( (g2[-1] * inverse[-1]) % mod )\n\n\nl = int(input())\n#A=list(map(int, input().split()))\nA=[int(i) for i in input().split()]\n\nS = Counter(A)\n\nfor i in A:\n tmp = []\n S[i] -= 1\n for j in S.keys():\n tmp.append(cmb(S[j],2,mod))\n S[i] += 1\n print(sum(tmp))\n', 'from collections import defaultdict,Counter\nimport sys\n\nn = int(input())\na = list(map(int, sys.stdin.readline().split()))\n\nd = Counter(a)\ne = defaultdict(int)\n\nbase = sum(v * (v - 1) // 2 for v in d.values())\ne = {k: base - (v >= 2) * (v - 1) for k, v in d.items()}\n\nfor x in a:\n print(e[x])']
['Wrong Answer', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s069308646', 's111706600', 's191621510', 's485737069', 's496492560', 's566846230', 's656329672', 's785119196', 's392401462']
[50244.0, 26552.0, 27784.0, 26644.0, 27792.0, 26660.0, 50272.0, 26672.0, 32488.0]
[2106.0, 2105.0, 2105.0, 2105.0, 2105.0, 2105.0, 2107.0, 2104.0, 320.0]
[788, 680, 755, 489, 766, 682, 717, 753, 292]
p02732
u556610039
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
['import collections\n\nnum = int(input())\na_i = list(map(int, input().split()))\nanslist = collections.Counter(a_i)\nans = sum(anslist.values())\nfor x in range(num):\n val = a_i[x]\n cnt = a_i.count(val)\n sa = (cnt - 1)\n print(ans - sa)', 'import collections\n\nnum = int(input())\na_i = list(map(int, input().split()))\nanslist = collections.Counter(a_i)\n\nans = 0\nfor x in anslist.values():\n ans += x * (x - 1) // 2\nfor x in range(num):\n val = a_i[x]\n cnt = anslist[val]\n print(ans - (cnt - 1))']
['Wrong Answer', 'Accepted']
['s925950930', 's853146845']
[26780.0, 26780.0]
[2104.0, 349.0]
[241, 263]
p02732
u563838154
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
['n = int(input())\na = list(map(int,input().split()))\nx = [0]*max(a)\nfor i in a:\n x[i-1]+=1\n\n\nfor i in range(1,n+1):\n x[a[i-1]-1]-=1\n count = 0\n x_ = [(k*k-1)/2 for k in x if k>=2]\n count = sum(x_)\n # for j in x:\n # if j>=2:\n # count += int((j*(j-1)/2))\n x[a[i-1]-1]+=1\n print(count)', 'n = int(input())\na = list(map(int,input().split()))\nx = [0]*max(a)\nfor i in a:\n x[i-1]+=1\n\n\nfor i in range(1,n+1):\n x[a[i-1]-1]-=1\n count = 0\n x_ = [(k*k-1)/2 in x if k>=2]\n count = sum(x_)\n # for j in x:\n # if j>=2:\n # count += int((j*(j-1)/2))\n x[a[i-1]-1]+=1\n print(count)', 'n = int(input())\na = list(map(int,input().split()))\nx = [0]*max(a)\nfor i in a:\n x[i-1]+=1\n\n\nfor i in range(1,n+1):\n x[a[i-1]-1]-=1\n count = 0\n x_ = [(k*(k-1))/2 for k in x if k>=2]\n count = sum(x_)\n # for j in x:\n # if j>=2:\n # count += int((j*(j-1)/2))\n x[a[i-1]-1]+=1\n print(count)', 'n = int(input())\na = list(map(int,input().split()))\nx = [0]*max(a)\nfor i in a:\n x[i-1]+=1\n# print(x)\ncount = 0\n# x_ = [(k*(k-1))/2 for k in x if k>=2]\n# count = sum(x_)\nfor j in x:\n if j>=2:\n count += int((j*(j-1)/2))\nfor i in range(n):\n if x[a[i]-1]>=2:\n print(count-x[a[i]-1]+1)\n else:\n print(count)']
['Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s013620150', 's107562405', 's566335794', 's841490850']
[24748.0, 2940.0, 26268.0, 24744.0]
[2104.0, 18.0, 2104.0, 330.0]
[323, 317, 325, 334]
p02732
u563992898
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
['n = int(input())\nl = [int(i) for i in input().split()]\n\n\nans = 0\nfor i in range(n):\n j = l.count(i)\n ans += int(j * (j - 1) / 2)\n', 'from collections import Counter\n\nn = int(input())\nl = [int(i) for i in input().split()]\n\nS = Counter(l)\n\nans = 0\nfor i in S.values():\n ans += int(i * (i - 1) / 2)\n\nfor i in range(n):\n val = S[l[i]]\n print(ans - val + 1)\n']
['Wrong Answer', 'Accepted']
['s721505270', 's552691293']
[26268.0, 26780.0]
[2104.0, 398.0]
[135, 229]
p02732
u569322757
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
['import collections\nimport math\n\n\ndef comb(n, r):\n if n < r:\n return 0\n return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))\n\n\nn = int(input())\na = list(map(int, input().split()))\nc = collections.Counter(a)\n\npre = 0\nfor i in range(n):\n if i == 0:\n c[a[i]] -= 1\n else:\n c[pre] += 1\n c[a[i]] -= 1\n print(sum(comb(v, 2) for v in c.values()))\n pre = a[i]', 'import collections\nimport math\n\n\ndef comb(n, r):\n if n < r:\n return 0\n return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))\n\n\ninput()\na = list(map(int, input().split()))\nc = collections.Counter(a)\n\nsumm = sum([comb(v, 2) for v in c.values()])\nfor ai in a:\n print(summ - c[ai] + 1)']
['Wrong Answer', 'Accepted']
['s474419664', 's740769948']
[26780.0, 25896.0]
[2104.0, 1686.0]
[418, 315]
p02732
u571867512
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
['import collections\n\nN = int(input())\nA = list(map(int,input().split()))\nAS = set(A)\nprint(AS)\ndef comb(n):\n return n*(n-1)//2\n\nL = collections.Counter(A)\n\nfor i in range(N):\n ans = 0\n for a in AS:\n if A[i] == a:\n ans += comb(L[a]-1)\n else:\n ans += comb(L[a])\n print(ans)\n', 'import collections\n\nN = int(input())\nA = list(map(int,input().split()))\nAS = set(A)\n\ndef comb(n):\n return n*(n-1)//2\n\nL = collections.Counter(A)\n\nans_tmp = 0\nfor a in AS:\n ans_tmp += comb(L[a])\n\nfor i in range(N):\n ans = ans_tmp\n ans += (comb(L[A[i]]-1) - comb(L[A[i]]))\n\n print(ans)\n']
['Wrong Answer', 'Accepted']
['s083268276', 's580974634']
[29856.0, 28732.0]
[2105.0, 535.0]
[319, 299]
p02732
u576927476
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
['import sys\n\nfrom scipy.misc import comb \n\n#import numpy as np\n\nn = int(input())\n\na = [int(i) for i in input().split()]\n\nnum = [[-1,0,0]]*(200000)\n\nasort = sorted(a)\n\n#print(asort)\n\nsum = 0\ni = 0\nwhile i < n-1:\n counter = 1\n index = asort[i]\n while i < n-1 and asort[i] == asort[i+1]:\n #print("yes")\n counter +=1\n i+=1\n #print("no")\n i+=1\n num[index] = [counter,comb(counter,2),comb(counter-1,2)]\n sum+=num[index][1]\n\n\n\n\nfor i in a:\n print(int(sum-num[i][1]+num[i][2]))\n', 'import sys\n\nfrom scipy.misc import comb \n\n#import numpy as np\n\nn = int(input())\n\na = [int(i) for i in input().split()]\n\ndict = {}\n\nasort = sorted(a)\n\n#print(asort)\n\nsum = 0\ni = 0\nwhile i < n-1:\n counter = 1\n index = asort[i]\n while i < n-1 and asort[i] == asort[i+1]:\n #print("yes")\n counter +=1\n i+=1\n #print("no")\n i+=1\n dict[(index)] = [counter,comb(counter,2),comb(counter-1,2)]\n sum+=dict[(index)][1]\n\n\n\n\nfor i in a:\n print(int(sum-dict[(i)][1]+dict[(i)][2]))\n', 'import sys\n\nfrom scipy.misc import comb\n\n#import numpy as np\n\nn = int(input())\n\na = [int(i) for i in input().split()]\n\nnum = [[-1,0,0]]*(200000)\n\nasort = sorted(a)\n\n#print(asort)\n\ni = 0\nwhile i < n-1:\n counter = 1\n index = asort[i]\n while i < n-1 and asort[i] == asort[i+1]:\n #print("yes")\n counter +=1\n i+=1\n #print("no")\n i+=1\n num[index] = [counter,comb(counter,2),comb(counter-1,2)]\n\nsum=0\nfor i in range(200000):\n sum +=num[i][1]\n\nfor i in a:\n print(int(sum-num[i][1]+num[i][2]))\n', 'import sys\n\n#from scipy.misc import comb #scipy.special\n\n#import numpy as np\n\ndef choose(n):\n return n*(n-1)/2\n\nn = int(input())\n\na = [int(i) for i in input().split()]\n\nbunpu = [0]*(n+1)\n\nfor i in range(len(a)):\n bunpu[a[i]]+=1\n\n\nsum = 0\nfor i in bunpu:\n sum+=choose(i)\ni = 0\nfor i in a:\n print(int(sum-choose(bunpu[i])+choose(bunpu[i]-1)))\n']
['Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s576283369', 's602532595', 's705721653', 's375329284']
[44820.0, 36468.0, 35820.0, 25716.0]
[2113.0, 2110.0, 2110.0, 424.0]
[529, 525, 531, 353]
p02732
u579699847
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
['import collections\ndef I(): return int(input())\ndef LI(): return list(map(int,input().split()))\n##################################################\nN = I()\nA = LI()\ncount = collections.Counter(A)\nnC2 = {}\nfor x in count.values():\n nC2[x] = x*(x-1)//2\nsum = sum(nC2.values())\nfor x in A:\n if x-1 in nC2:\n minus = nC2[x-1]\n else:\n minus = (x-1)*(x-2)//2\n nC2[x-1] = minus\n print(sum-x+minus)', 'import collections\ndef I(): return int(input())\ndef LI(): return list(map(int,input().split()))\n##################################################\nN = I()\nA = LI()\ncount = collections.Counter(A)\nsum = 0\nfor x in count.values():\n sum += x*(x-1)//2\nfor x in A:\n temp = count[x]\n minus = temp*(temp-1)//2\n plus = (temp-1)*(temp-2)//2\n print(sum-minus+plus)']
['Wrong Answer', 'Accepted']
['s623035779', 's121994038']
[39984.0, 26780.0]
[391.0, 426.0]
[421, 368]
p02732
u586639900
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
['N = int(input())\nA = list(map(int, input().split()))\n\ncounts = [0] * (N+1)\n\nfor i in range(1, N+1):\n counts[A[i-1]] += 1\n\nsum_ = 0\nfor k in range(1, N+1):\n sum_ += counts[k] * (counts[k]-1) // 2\n\nres = []\nfor k in range(1, N+1):\n \n res.append(sum_ - (counts[A[k-1]] - 1))\n\nprint(res)', 'N = int(input())\nA = list(map(int, input().split()))\n\ncounts = [0] * (N+1)\n\nfor i in range(1, N+1):\n counts[A[i-1]] += 1\n\nsum_ = 0\nfor k in range(1, N+1):\n sum_ += counts[k] * (counts[k]-1) // 2\n\nfor k in range(1, N+1):\n \n print(sum_ - (counts[A[k-1]] - 1))\n\n ']
['Wrong Answer', 'Accepted']
['s396888396', 's421307138']
[30844.0, 26408.0]
[226.0, 341.0]
[349, 326]
p02732
u586662847
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
['import collections\n\n\ndef resolve():\n N = int(input())\n A = sorted(map(int, input().split()))\n\n counter = collections.Counter(A)\n ans = 0\n\n for i in counter.values():\n ans += i * (i - 1) // 2\n\n for a in A:\n count = counter[a]\n print(ans - (count * (count - 1) // 2) +\n ((count - 1) * (count - 2) // 2))\n\nresolve()', 'def resolve():\n N = int(input())\n A = sorted(map(int, input().split()))\n\n counter = collections.Counter(A)\n ans = 0\n\n for i in counter.values():\n ans += i * (i - 1) // 2\n\n for a in A:\n count = counter[a]\n print(ans - (count * (count - 1) // 2) +\n ((count - 1) * (count - 2) // 2))\n\nresolve()', 'import collections\n\n\ndef resolve():\n N = int(input())\n A = map(int, input().split())\n\n counter = collections.Counter(A)\n ans = 0\n\n for i in counter.values():\n ans += i * (i - 1) // 2\n\n for a in A:\n count = counter[a]\n print(ans - (count * (count - 1) // 2) +\n ((count - 1) * (count - 2) // 2))\n\n\nresolve()', 'import collections\n\n\ndef resolve():\n N = int(input())\n A = list(map(int, input().split()))\n\n counter = collections.Counter(A)\n ans = 0\n\n for i in counter.values():\n ans += i * (i - 1) // 2\n\n for a in A:\n count = counter[a]\n print(ans - (count * (count - 1) // 2) +\n ((count - 1) * (count - 2) // 2))\n\n\nresolve()']
['Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s645822930', 's756737436', 's797622309', 's534686673']
[26780.0, 26268.0, 29476.0, 26780.0]
[432.0, 148.0, 111.0, 370.0]
[364, 343, 357, 363]
p02732
u587589241
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
['def comb(n,k):\n nCk = 1\n MOD = 10**9+7\n\n for i in range(n-k+1, n+1):\n nCk *= i\n nCk %= MOD\n\n for i in range(1,k+1):\n nCk *= pow(i,MOD-2,MOD)\n nCk %= MOD\n return nCk\nn=int(input())\nans=[0 for i in range(n)]\na=list(map(int,input().split()))\n\nfor i in range(n):\n ans[a[i]-1]+=1\nl=[0 for i in range(n)]\ntmp=0\nfor i in range(n):\n if ans[i]>1:\n c=comb(ans[i],2)\n tmp+=c\n l[i]=c\nfor i in range(n):\n tt=tmp\n t=ans[a[i]-1]\n if t<2:\n print(tt)\n elif 2<=t<3:\n print(tt-l[a[i]-1])\n elif t>3:\n print(tt-l[a[i]-1]+comb(t-1,2))', 'import math\nimport collections\n\nN = input()\nnums = list(map(int, input().split()))\ncounter = collections.Counter(nums)\npatterns = {}\nfor k, v in counter.items():\n patterns[k] = math.comb(v, 2)\n\nbaseline = sum(v for v in patterns.values())\n\ncache = {}\nfor n in nums:\n if n in cache:\n print(cache[n])\n else:\n val = baseline - patterns[n] + math.comb(counter[n] - 1, 2)\n cache[n] = val\n print(val)\n']
['Wrong Answer', 'Accepted']
['s711120943', 's144840629']
[35388.0, 41580.0]
[1074.0, 334.0]
[618, 432]
p02732
u592035627
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
['N = int(input())\nA = list(map(int,input().split()))\nimport copy\n\n\ns = [0 for i in range(N)]\nfor i in range(N):\n s[A[i]-1] += 1\n \ns1 = copy.copy(s)\nfor i in range(N):\n if s[i] == 0:\n s1[i] = 0\n else:\n s1[i] -= 1\n\namount = sum(s)\n\nfor i in range(N):\n print(amount-s1[A[i]-1])\n ', 'N = int(input())\nA = list(map(int,input().split()))\nimport copy\nfrom operator import mul\nfrom functools import reduce\n\ndef cmb(n,r):\n if n >= r:\n r = min(n-r,r)\n if r == 0: return 1\n over = reduce(mul, range(n, n - r, -1))\n under = reduce(mul, range(1,r + 1))\n return over // under\n else:\n return 0\n\n\ns = [0 for i in range(N)]\nfor i in range(N):\n s[A[i]-1] += 1\n \ns1 = copy.copy(s)\nfor i in range(N):\n if s[i] == 0:\n s1[i] = 0\n else:\n s1[i] -= 1\n\namount = 0\nfor i in range(N):\n a = cmb(s[i],2)\n amount += a\n\nfor i in range(N):\n print(amount-s1[A[i]-1])']
['Wrong Answer', 'Accepted']
['s346841768', 's466592918']
[25644.0, 26140.0]
[328.0, 425.0]
[307, 635]
p02732
u595905528
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
['N = int(input())\nAlist=list(map(int, input().split()))\nnumdic = {}\nfor i in Alist:\n if i in numdic:\n numdic[i] += 1\n else:\n numdic[i] = 1\nApple = 0\nfor i in numdic.values():\n Apple += i*(i-1)//2\nfor i in Alist:\n tmp = Apple\n tmp -= numdic[i]+1\n print(tmp)', 'N = int(input())\nAlist=list(map(int, input().split()))\nnumdic = {}\nfor i in Alist:\n if i in numdic:\n numdic[i] += 1\n else:\n numdic[i] = 1\nApple = 0\nfor i in numdic.values():\n Apple += i*(i-1)//2\nfor i in Alist:\n tmp = Apple\n tmp -= (numdic[i]-1)\n print(tmp)']
['Wrong Answer', 'Accepted']
['s088053854', 's248570570']
[26268.0, 24748.0]
[328.0, 351.0]
[287, 289]
p02732
u595952233
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
['from collections import Counter\nn = int(input())\na = list(map(int, input().split()))\n\nc = dict(Counter(a))\ndp_on = {}\ndp_off = {}\nfor k, v in c.items():\nif v < 2:\n dp_on[k] = 0\n dp_off[k] = 0\nelif v < 3:\n dp_on[k] = 1\n dp_off[k] = 0\nelse:\n dp_on[k] = int(v*(v-1)/2)\n dp_off[k] = int((v-1)*(v-2)/2)\ncomb_sum = sum([v for v in dp_on.values()])\nfor i in range(n):\nprint(comb_sum - dp_on[a[i]] + dp_off[a[i]])', 'from collections import Counter\nn = int(input())\na = list(map(int, input().split()))\n\nc = dict(Counter(a))\ndp_on = {}\ndp_off = {}\nfor k, v in c.items():\n if v == 1:\n dp_on[k] = 0\n dp_off[k] = 0\n elif v == 2:\n dp_on[k] = 1\n dp_off[k] = 0\n else:\n dp_on[k] = int(v*(v-1)/2)\n dp_off[k] = int((v-1)*(v-2)/2)\n comb_sum = sum([v for v in dp_on.values()])\n for i in range(n):\n print(comb_sum - dp_on[a[i]] + dp_off[a[i]])', 'from collections import Counter\nn = int(input())\na = list(map(int, input().split()))\n\nc = dict(Counter(a))\ndp_on = {}\ndp_off = {}\nfor k, v in c.items():\n if v == 1:\n dp_on[k] = 0\n dp_off[k] = 0\n elif v == 2:\n dp_on[k] = 1\n dp_off[k] = 0\n else:\n dp_on[k] = int(v*(v-1)/2)\n dp_off[k] = int((v-1)*(v-2)/2)\ncomb_sum = sum([v for v in dp_on.values()])\nfor i in range(n):\n print(comb_sum - dp_on[a[i]] + dp_off[a[i]])\n']
['Runtime Error', 'Runtime Error', 'Accepted']
['s120470142', 's669148897', 's816583249']
[2940.0, 26780.0, 40112.0]
[17.0, 106.0, 379.0]
[447, 477, 466]
p02732
u602773379
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
['from collections import Counter\nN = int(input())\nA = list(map(int,input().split()))\n\ndef ch_2(n):\n\treturn n*(n-1)/2\n\ncount=Counter(A)\nans=0\nfor i in range(len(count)):\n\tans+=ch_2(count[i])\nfor j in range(N):\n\tprint(ans-ch_2(count[A[j]]-1))\n\n\n\n\n\n', 'from collections import Counter\nN = int(input())\nA = list(map(int,input().split()))\n\ndef ch_2(n):\n\treturn n*(n-1)//2\n\ncount=Counter(A)\nans=0\nfor i in range(len(count)):\n\tans+=ch_2(count[A[i]])\nprint(ans)\nfor j in range(N):\n\tttl=ans\n\tttl-=ch_2(count[A[j]])\n\tttl+=ch_2(count[A[j]]-1)\n\tprint(int(ttl))\n\n\n\n\n\n', 'from collections import Counter\nN = int(input())\nA = list(map(int,input().split()))\n\ndef ch_2(n):\n\t# print(n)\n\treturn n*(n-1)/2\n\ncount=Counter(A)\n\nans=0\nfor i in count.values():\n\tans+=ch_2(i)\n\nfor j in range(N):\n\tttl=ans\n\tttl-=ch_2(count[A[j]])\n\tttl+=ch_2(count[A[j]]-1)\n\tprint(int(ttl))\n\n\n\n\n\n']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s331500009', 's891071424', 's216306363']
[26780.0, 26780.0, 26780.0]
[475.0, 591.0, 552.0]
[245, 304, 293]
p02732
u607075479
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
['N = int(input())\nA = list(map(int, input().split()))\nB = [[] for i in range(N)]\nans = [0]*N\nfor k, a in enumerate(A):\n a = a - 1\n B[a].append(k)\n\n\nS = 0\nfor b in B:\n lenb = len(b)\n if lenb >= 1:\n S += lenb * (lenb-1) / 2\n\nfor i, b in enumerate(B):\n for j, k in enumerate(b):\n ans[k] = int(S - (len(b) - 1))\nprint(ans)', 'N = int(input())\nA = list(map(int, input().split()))\nB = [[] for i in range(N)]\nans = [0]*N\nfor k, a in enumerate(A):\n a = a - 1\n B[a].append(k)\n\n\nS = 0\nfor b in B:\n lenb = len(b)\n if lenb >= 1:\n S += lenb * (lenb-1) / 2\n\nfor i, b in enumerate(B):\n for j, k in enumerate(b):\n ans[k] = int(S - (len(b) - 1))\nfor i in ans:\n print(i)']
['Wrong Answer', 'Accepted']
['s589751836', 's564587373']
[51492.0, 47064.0]
[536.0, 644.0]
[346, 362]
p02732
u608579392
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
['import copy\nimport numpy as np\nfrom math import factorial\n\ndef num_choice_2(N):\n if N > 1:\n return factorial(N) // (factorial(N - 2)* 2)\n else:\n return 0\n\nN = int(input())\nA = [int(x) for x in input().split()]\n\nnums = np.zeros(N, dtype=int)\nfor a_i in A:\n nums[a_i - 1] += 1\n\nfor i in range(N):\n nums[A[i] - 1] -= 1\n ans = np.sum([num_choice_2(x) for x in tmp_nums])\n nums[A[i] - 1] += 1\n print(ans)', 'def n_c_2(n):\n if n < 1:\n return 0\n else:\n return n * (n - 1) // 2\n\nN = int(input())\nA = [int(x) for x in input().split()]\n\nn_balls = [0 for _ in A]\nfor a_i in A:\n n_balls[a_i - 1] += 1\n\nn_combinations = [n_c_2(n) for n in n_balls]\ntotal_combinations = sum(n_combinations)\n\nfor i, a_i in enumerate(A):\n diff = n_c_2(n_balls[a_i - 1]) - n_c_2(n_balls[a_i - 1] - 1)\n print(total_combinations - diff)\n']
['Runtime Error', 'Accepted']
['s695811691', 's700268351']
[34040.0, 25764.0]
[483.0, 437.0]
[434, 427]
p02732
u614314290
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
['from collections import deque, Counter as cnt\nfrom collections import defaultdict as dd\nfrom operator import itemgetter as ig\nfrom bisect import bisect_right as bsr\nfrom math import factorial, ceil, floor\nimport sys\nsys.setrecursionlimit(1000000)\n\n\nargs = None\nINF = float("inf")\nMOD = int(1e9 + 7)\n\n\ndef input(*ps):\n if type(ps[0]) is list:\n return [input(*ps[0][:-1]) for _ in range(ps[0][-1])]\n elif len(ps) == 1:\n return ps[0](next(args))\n else:\n return [p(next(args)) for p in ps]\n\n\ndef nlist(n, v):\n if not n:\n return [] if type(v) is list else v\n return [nlist(n[1:], v) for _ in range(n[0])]\n\n\ndef yesno(v):\n print(["Yes", "No"][not v])\n\n\nif not __name__ == \'__main__\':\n def debug(*v):\n print(*v)\n\n\n\ndef main():\n N = input(int)\n A = input([int, N])\n\n count = dd(int)\n for a in A:\n count[a] += 1\n debug(count)\n for a in A:\n ans = 0\n for k, v in count.items():\n temp = v if not k == a else v - 1\n ans += (temp * (temp - 1)) // 2\n print(ans)\n\n\nif __name__ == \'__main__\':\n args = iter(sys.stdin.read().split())\n main()\n', 'from collections import deque, Counter as cnt\nfrom collections import defaultdict as dd\nfrom operator import itemgetter as ig\nfrom bisect import bisect_right as bsr\nfrom math import factorial, ceil, floor\nimport sys\nsys.setrecursionlimit(1000000)\n\n\nargs = None\nINF = float("inf")\nMOD = int(1e9 + 7)\n\n\ndef input(*ps):\n if type(ps[0]) is list:\n return [input(*ps[0][:-1]) for _ in range(ps[0][-1])]\n elif len(ps) == 1:\n return ps[0](next(args))\n else:\n return [p(next(args)) for p in ps]\n\n\ndef nlist(n, v):\n if not n:\n return [] if type(v) is list else v\n return [nlist(n[1:], v) for _ in range(n[0])]\n\n\ndef yesno(v):\n print(["Yes", "No"][not v])\n\n\n\ndef main():\n N = input(int)\n A = input([int, N])\n\n count = dd(int)\n for a in A:\n count[a] += 1\n sum_ = 0\n for k, v in count.items():\n sum_ += (v * (v - 1)) // 2\n for a in A:\n print(sum_ - count[a] + 1)\n\n\nif __name__ == \'__main__\':\n args = iter(sys.stdin.read().split())\n main()\n']
['Runtime Error', 'Accepted']
['s118153786', 's322559401']
[35344.0, 35344.0]
[274.0, 461.0]
[1193, 1060]
p02732
u617228707
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
['N = int(input())\nlist = list(map(int,input().split()))\nlist.append(-1)\nkosuu = [0] * N\ntotal = 0\nlisted = sorted(list)\ni = 0\ncount = 1\nwhile i < N:\n a = listed[i]\n if a == listed[i+1]:\n count += 1\n else:\n kosuu[a-1] = count\n total += ( count * (count-1) ) //2\n count = 1\n i += 1\nfor i in range(N):\n a = kosuu[list[i]-1]\n print(total-a*(a-1)//2 + (a-1)*(a-2)//2)', 'N = int(input())\nlist = list(map(int,input().split()))\nkosuu = [0] * N\nkosuuu = [0] * N\ntotal = 0\nlisted = sorted(list)\nlisted.append(-1)\ni = 0\ncount = 1\nwhile i < N:\n a = listed[i]\n if a == listed[i+1]:\n count += 1\n else:\n kosuu[a-1] = count\n total += ( count * (count-1) ) //2\n count = 1\n i += 1\nfor i in range(N):\n a = kosuu[list[i]-1]\n print(total-a*(a-1)//2 + (a-1)*(a-2)//2)']
['Wrong Answer', 'Accepted']
['s087113610', 's226570872']
[26140.0, 26140.0]
[497.0, 502.0]
[407, 426]
p02732
u622847899
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
['N,A = [input() for i in range(2)]\nA=A.split()\nN=int(N)\nA=[int(i) for i in A]\n\na=0\nfor i in range(N):\n for j in A[i+1:]:\n if A[i]==j:\n a+=1\nprint(a)\n\nans=[]\nb=[]\nfor k in range(N):\n b_k=0\n for i in range(N-1):\n if A[k]==A[i]:\n b_k+=1\n ans.append(a-b_k)\n\nfor i in range(len(ans)):\n print(ans[i])\n', 'n = int(input())\na = list(map(int,input().split()))\n\ncount={}\nfor ak in a:\n if ak not in count:\n count[ak] = 0\n count[ak] += 1\n\nsum=0\nfor key in count:\n sum += count[key]*(count[key]-1) // 2\n\nfor ak in a:\n print(sum-(count[ak]-1))\n']
['Wrong Answer', 'Accepted']
['s680065994', 's220496934']
[26140.0, 24748.0]
[2104.0, 341.0]
[345, 250]
p02732
u634079249
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
['import sys\nimport os\nimport collections\n\n\ndef main():\n if os.getenv("LOCAL"):\n sys.stdin = open("input.txt", "r")\n\n L = int(sys.stdin.buffer.readline().decode().rstrip())\n print(L ** 3 / 27)\n\n\nif __name__ == \'__main__\':\n main()\n', 'import sys\nimport os\nimport collections\n\ndef main():\n if os.getenv("LOCAL"):\n sys.stdin = open("input.txt", "r")\n\n N = int(sys.stdin.buffer.readline().rstrip())\n A = list(map(int, sys.stdin.buffer.readline().split()))\n\n obj = collections.Counter(A)\n\n p = 0\n for v in obj.values():\n if v > 1:\n p += v * (v - 1) // 2\n\n for a in A:\n print(p - (obj[a] - 1))\n\n\nif __name__ == \'__main__\':\n main()\n']
['Wrong Answer', 'Accepted']
['s366349634', 's249217857']
[3316.0, 25568.0]
[20.0, 294.0]
[247, 447]
p02732
u640922335
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
['from collections import Counter\nN=int(input())\nA = list(map(int,input().split()))\nans = [0] * N\nB = Counter(A)\nfor i in range(N):\n ans[i] = B[A[i]]-1\n\ntotal=sum(ans)\nC=[]\nfor i in range(N):\n c = (total-ans[i])//2\n C.append(c)\n\nfor num in C:\n print(num)', 'from collections import Counter\nN=int(input())\nA = list(map(int,input().split()))\nans = [0] * N\nB = Counter(A)\nfor i in range(N):\n ans[i] = B[A[i]]-1\n\ntotal=sum(ans)\nC=[]\nfor i in range(N):\n c = (total-2*ans[i])//2\n C.append(c)\n\nfor num in C:\n print(num)']
['Wrong Answer', 'Accepted']
['s941402094', 's484455096']
[34020.0, 34404.0]
[268.0, 249.0]
[264, 266]
p02732
u644224332
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
['import math\n\n\ndef combinations_count(n, r):\n return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))\n\n\nif __name__ == \'__main__\':\n n = int(input())\n a = list(map(int, input().split(" ")))\n\n total = 0\n c_list = []\n a_count_list = []\n for i in range(n):\n count = a.count(i + 1)\n a_count_list.append(count)\n # print(count)\n if count > 1: \n c = combinations_count(count, 2)\n else:\n c = 0\n\n c_list.append(c)\n total = total + c\n\n print(a, c_list, total, a_count_list)\n for k in range(n):\n if c_list[a[k] - 1] == 1:\n q = 1\n elif c_list[a[k] - 1] == 0:\n q = 0\n else:\n \n q = c_list[a[k] - 1] - c_list[a[k] - 1] * (a_count_list[a[k] - 1] - 2) // a_count_list[a[k] - 1]\n print(total - q)', 'from collections import defaultdict\n\nif __name__ == \'__main__\':\n n = int(input())\n a = list(map(int, input().split(" ")))\n\n variation = set(a)\n a_count_dict = defaultdict(int)\n for j in a:\n a_count_dict[j] += 1\n\n total = 0\n c_dict = {}\n for i in variation:\n count = a_count_dict[i]\n if count > 1: \n # c = combinations_count(count, 2)\n c = count * (count - 1) // 2\n else:\n c = 0\n c_dict[i] = c\n total = total + c\n\n \n # c_list = []\n # a_count_list = []\n \n # count = a.count(i + 1)\n # a_count_list.append(count)\n # # print(count)\n # if count > 1: \n # # c = combinations_count(count, 2)\n # c = count * (count - 1) // 2\n # else:\n # c = 0\n #\n # c_list.append(c)\n \n\n \n for k in range(n):\n ck = c_dict[a[k]]\n ca = a_count_dict[a[k]]\n if ck == 1 or ck == 0:\n q = ck\n else:\n \n q = ck - ck * (ca - 2) // ca\n\n\n # if c_list[a[k] - 1] == 1:\n \n # elif c_list[a[k] - 1] == 0:\n \n # else:\n # \n \n print(total - q)']
['Wrong Answer', 'Accepted']
['s439526574', 's049353526']
[26140.0, 36124.0]
[2104.0, 452.0]
[900, 1506]
p02732
u652081898
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
['from collections import Counter\nfrom copy import deepcopy\n\nn = int(input())\na = list(map(int, input().split()))\nc = Counter(a)\nall_comb = 0\nfor v in c.values():\n all_comb += v*(v-1)/2\n\nfor i in range(n):\n tmp = c[a[i]]\n print(all_comb-tmp+1)\n', 'from collections import Counter\nfrom copy import deepcopy\n\nn = int(input())\na = list(map(int, input().split()))\nc = Counter(a)\n\nfor i in range(n):\n tmp_c = deepcopy(c)\n ans = 0\n tmp_c[a[i]] -= 1\n for v in tmp_c.values():\n ans += v*(v-1)/2\n print(ans)\n', 'from collections import Counter\nfrom copy import deepcopy\n\nn = int(input())\na = list(map(int, input().split()))\nc = Counter(a)\nfor v in c.values():\n all_comb += v*(v-1)/2\n\nfor i in range(n):\n tmp = c[a[i]]\n print(all_comb - 2*(tmp-1))\n', 'from collections import Counter\n\nn = int(input())\na = list(map(int, input().split()))\nc = Counter(a)\nall_comb = 0\nfor v in c.values():\n all_comb += v*(v-1)/2\n\nfor i in range(n):\n tmp = c[a[i]]\n print(int(all_comb-tmp+1))\n']
['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s106258753', 's857438192', 's879370973', 's969261556']
[26780.0, 49880.0, 26780.0, 25896.0]
[456.0, 2106.0, 97.0, 424.0]
[251, 273, 244, 230]
p02732
u667024514
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
['n = int(input())\nlis = list(map(int,input().split()))\nnum = [0 for i in range(n)]\nfor nn in lis:\n num[nn-1] += 1\nans = 0\nfor nnn in num:\n ans += (nnn*(nnn-1))//2\nfor i in range(n):\n print(ans-(num[lis[i]]*(num[lis[i]]-1))//2+((num[lis[i]]-1)*(num[lis[i]]-2))//2)', 'n = int(input())\nlis = list(map(int,input().split()))\nnum = [0 for i in range(n+1)]\nfor nn in lis:\n num[nn] += 1\nans = 0\nfor nnn in num:\n ans += (nnn*(nnn-1))//2\nfor i in range(n):\n print(ans-(num[lis[i]]*(num[lis[i]]-1))//2+((num[lis[i]]-1)*(num[lis[i]]-2))//2)\n']
['Runtime Error', 'Accepted']
['s190172775', 's405216556']
[26140.0, 26140.0]
[410.0, 410.0]
[265, 266]
p02732
u671446913
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
['import collections as cl\nfrom math import factorial\n\ndef comb(n, r):\n if n >= r:\n return int(factorial(n) / factorial(r) / factorial(n - r))\n elif n == 1:\n return 1:\n else:\n return 0\n \nn = int(input())\na = list(map(int, input().split()))\n\nclc = cl.Counter(a)\n\n\nnpair = 0\nfor (k, v) in clc.items():\n npair += comb(v, 2)\n\n\nfor a_ in a:\n print(npair - (clc[a_] - 1))', '#!/usr/bin/env python3\nimport collections\nimport copy\nimport itertools as it\nimport math\nimport numpy as np\n\n# A = input()\nN = int(input())\n# A = map(int, input().split())\nA = list(map(int, input().split()))\n\n#\nc = collections.Counter(A)\n\ncache = {}\n\nA_ = copy.deepcopy(A)\n\ncount = len(A)\nfor (k, v) in c.most_common():\n if v == 1:\n count -= 1\n\nfor a in A:\n if c[a] == 2:\n print(count - 2)\n if c[a] == 1:\n print(count)\n else:\n print(count)\n\nprint()', 'import collections as cl\nfrom math import factorial\n\ndef comb(n, r):\n if n >= r:\n return int(factorial(n) / factorial(r) / factorial(n - r))\n elif:\n n == 1:\n return 1:\n else:\n return 0\n \nn = int(input())\na = list(map(int, input().split()))\n\nclc = cl.Counter(a)\n\n\nnpair = 0\nfor (k, v) in clc.items():\n npair += comb(v, 2)\n\n\nfor a_ in a:\n print(npair - (clc[a_] - 1))', '#!/usr/bin/env python3\nimport collections as cl\nfrom math import factorial\n\ndef comb(n, r):\n if n >= r:\n return factorial(n) // (factorial(n - r) * factorial(r))\n else:\n return 0\n \nn = int(input())\na = list(map(int, input().split()))\n\nclc = cl.Counter(a)\n\n\nnpair = 0\nfor (k, v) in clc.items():\n npair += comb(v, 2)\n\n\nfor a_ in a:\n print(npair - (clc[a_] - 1))\n']
['Runtime Error', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s646984932', 's835332261', 's997508655', 's376769798']
[2940.0, 38284.0, 2940.0, 25900.0]
[17.0, 751.0, 17.0, 1681.0]
[488, 526, 493, 495]
p02732
u673101577
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
["import collections\n\nN = int(input())\nA = list(map(int, input().split(' ')))\n\n\ndef main(n: int, a: list):\n counter = collections.Counter(a)\n pairs = {k: v * (v - 1) / 2 for k, v in counter.items()}\n pairs_all = sum(pairs.values())\n\n print(pairs)\n\n counted = {}\n\n for i in range(N):\n\n k = a[i]\n v = counter[k] - 1\n \n pair_cnt = pairs_all - pairs[k] + (v*(v-1)/2)\n\n # if target not in counted.keys():\n \n #\n \n \n #\n \n # counted.update({target: pair_cnt})\n # else:\n # pair_cnt = counted[target]\n print(int(pair_cnt))\n\n\nmain(N, A)\n", "import collections\n\nN = int(input())\nA = list(map(int, input().split(' ')))\n\n\ndef main(n: int, a: list):\n counter = collections.Counter(a)\n pairs = {k: v * (v - 1) / 2 for k, v in counter.items()}\n pairs_all = sum(pairs.values())\n\n for i in range(N):\n k = a[i]\n v = counter[k] - 1\n pair_cnt = pairs_all - pairs[k] + (v * (v - 1) / 2)\n\n print(int(pair_cnt))\n\n\nmain(N, A)\n"]
['Wrong Answer', 'Accepted']
['s775462597', 's518139115']
[35484.0, 33948.0]
[502.0, 464.0]
[811, 410]
p02732
u674588203
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
['import numpy as np\n\nN=int(input())\nA=np.array(list(map(int,input().split())))\n\n\nunique_num, counts =np.unique(A,return_counts=True) \n\n\n# print(counts)\ndic0={} \ndic1={} \ndic2={} \n\nCombination_pattern\u3000= []\nfor i in range(len(counts)):\n Combination = counts[i] * (counts[i]-1) // 2 \n dic0[unique_num[i]]=counts[i]\n dic1[unique_num[i]]=Combination\n dic2.setdefault(unique_num[i])\n Combination_pattern.append(Combination)\n\ntotalcombination=sum(Combination_pattern)\n\n# print(dic0)\n# print(dic1)\n# print(dic2)\n# print(Combination_pattern)\n\n\n\nfor j in range (N):\n n=A[j] \n if dic2[n]==None:\n reduced_pattern = (dic0[n]-1) * (dic0[n]-2) // 2 \n ans=totalcombination-dic1[n]+reduced_pattern \n dic2[n] = ans \n print(ans)\n else:\n print(dic2[n]) ', 'import numpy as np\n\nN=int(input())\nA=np.array(list(map(int,input().split())))\n\n\nunique_num, counts =np.unique(A,return_counts=True) \n\n\n# print(counts)\ndic0={} \ndic1={} \ndic2={} \n\nCombination_pattern = []\nfor i in range(len(counts)):\n Combination = counts[i] * (counts[i]-1) // 2 \n dic0[unique_num[i]]=counts[i]\n dic1[unique_num[i]]=Combination\n dic2.setdefault(unique_num[i])\n Combination_pattern.append(Combination)\n\ntotalcombination=sum(Combination_pattern)\n\n# print(dic0)\n# print(dic1)\n# print(dic2)\n# print(Combination_pattern)\n\n\n\nfor j in range (N):\n n=A[j] \n if dic2[n]==None:\n reduced_pattern = (dic0[n]-1) * (dic0[n]-2) // 2 \n ans=totalcombination-dic1[n]+reduced_pattern \n dic2[n] = ans \n print(ans)\n else:\n print(dic2[n]) ']
['Runtime Error', 'Accepted']
['s225944523', 's698970192']
[8928.0, 76536.0]
[26.0, 897.0]
[2017, 2015]
p02732
u676933207
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
['import copy\n\n#N = int(input())\n#A = list(map(int,input().split()))\nN = 5\nA = [3,3,3,3,3]\n\n\nnCr = {}\ndef cmb(n,r):\n if r > n:\n return 0\n if r == 0 or r == n:\n return 1\n if r == 1:\n return n\n if (n,r) not in nCr:\n return nCr[(n,r)]\n nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)\n return nCr[(n,r)]\n\nmem_cnt = [0] * N\nset_a = set(A)\nfor c in list(set_a):\n mem_cnt[c] = A.count(c)\n\nfor k in A:\n ret = 0\n for v in mem_cnt:\n x = v\n ret += cmb(x,2)\n print(ret)\n', 'N = int(input())\nA = list(map(int,input().split()))\n\nnCr = {}\ndef cmb(n,r):\n if r > n:\n return 0\n if r == 0 or r == n:\n return 1\n if r == 1:\n return n\n if (n,r) in nCr.keys():\n return nCr[(n,r)]\n nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)\n return nCr[(n,r)]\n\nmem_cnt = [0] * N\nset_a = set(A)\nfor c in list(set_a):\n mem_cnt[c] = A.count(c)\n\nfor k in A:\n ret = 0\n for v in mem_cnt:\n x = v\n ret += cmb(x,2)\n print(ret)\n', 'from collections import Counter\n\nN = int(input())\nA = list(map(int,input().split()))\n\ncnt = Counter(A)\ns = 0\nfor v in cnt.values():\n s += v*(v-1)//2\n\nfor a in A:\n print(s - (cnt[a]-1))\n']
['Runtime Error', 'Runtime Error', 'Accepted']
['s230396377', 's411826219', 's111229488']
[3444.0, 26140.0, 26780.0]
[22.0, 2104.0, 331.0]
[519, 484, 191]
p02732
u678505520
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
['import collections\nn = int(input())\nA = list(map(int,input().split()))\nB = collections.Counter(A)\nC = B.copy()\ntotal = 0\nfor i in B.values():\n total += i*(i-1)//2\nfor i in A:\n print(total - i)', 'import collections\nn = int(input())\nA = list(map(int,input().split()))\nB = collections.Counter(A)\nC = B.copy()\ntotal = 0\nfor i in B.values():\n total += i*(i-1)//2\nfor i in A:\n print(total - B[i]+1)']
['Wrong Answer', 'Accepted']
['s140522374', 's351094351']
[27448.0, 28216.0]
[268.0, 359.0]
[198, 203]
p02732
u679439110
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
['import heapdict\n\nn = int(input())\nla = list(map(int, input().split()))\n\nct = [0] * (2*10**5+1)\nans = [0] * (n+1)\nld = [0] * (n+1)\n\nfor i in range(len(la)):\n ct[la[i]] += 1\n\nsa = set(la)\n\nfor j in sa:\n ans[j] = ct[j] * (ct[j]-1) // 2\n ld[j] = ans[j] - ((ct[j]-2) * (ct[j]-1) // 2)\n\ntotal = sum(ans)\n\n# print(ct[0:10])\n# print(ans)\n\nfor k in range(n):\n knum = la[k]\n print(total - ld[knum])\n', 'n = int(input())\nla = list(map(int, input().split()))\n\nct = [0] * (2*10**5+1)\nans = [0] * (n+1)\nld = [0] * (n+1)\n\nfor i in range(len(la)):\n ct[la[i]] += 1\n\nsa = set(la)\n\nfor j in sa:\n ans[j] = ct[j] * (ct[j]-1) // 2\n ld[j] = ans[j] - ((ct[j]-2) * (ct[j]-1) // 2)\n\ntotal = sum(ans)\n\n# print(ct[0:10])\n# print(ans)\n\nfor k in range(n):\n knum = la[k]\n print(total - ld[knum])\n']
['Runtime Error', 'Accepted']
['s573053052', 's105781053']
[3188.0, 26140.0]
[20.0, 388.0]
[404, 387]
p02732
u686174642
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
['def nc2(n):\n if n==0:\n return 0\n return n*(n-1)/2\n\n\nn=int(input())\narr=[int(i) for i in input().strip().split(" ")]\nans=0\ndic={}\nfor i in arr:\n dic[i]=dic.get(i,0)+1\nfor i in dic:\n if dic[i]==1 :\n continue\n ans+=nc2(dic[i])\n \nprint(dic)\n\nfor i in range(n):\n curr_nc2=nc2(dic[arr[i]])\n # print(curr_nc2)\n print(int(ans-curr_nc2+nc2(dic[arr[i]]-1)))\n ', 'def nc2(n):\n if n==0:\n return 0\n return n*(n-1)/2\n\n\nn=int(input())\narr=[int(i) for i in input().strip().split(" ")]\nans=0\ndic={}\nfor i in arr:\n dic[i]=dic.get(i,0)+1\nfor i in dic:\n if dic[i]==1 :\n continue\n ans+=nc2(dic[i])\n \n#print(dic)\n\nfor i in range(n):\n curr_nc2=nc2(dic[arr[i]])\n # print(curr_nc2)\n print(int(ans-curr_nc2+nc2(dic[arr[i]]-1)))\n ']
['Wrong Answer', 'Accepted']
['s398621367', 's642062632']
[32164.0, 32268.0]
[344.0, 337.0]
[393, 394]
p02732
u688219499
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
['N=int(input())\nA=list(map(int,input().split()))\nA_new=sorted(A)\nn=0\nsum_number=0\nindex=[]\nnumber=[]\nfor i in range(N-1):\n if A_new[i]==A_new[i+1]:\n n=n+1\n else:\n sum_number=n*(n+1)/2+sum_number\n index.append(i)\n number.append(n+1)\n n=0\nif n!=0:\n sum_number=n*(n+1)/2+sum_number\nif all(number):\n number.append(n+1)\n index.append(N-1)\nI=len(index)\nprint(index)\nprint(number)\nprint(A)\nprint(A_new)\nfor i in range(N):\n for s,S in enumerate(index):\n if A[i]==A_new[S]:\n L=s\n break\n print(int(sum_number+1-number[L]))\n', 'N=int(input())\nA=list(map(int,input().split()))\nnumber=[0]*(N+1)\nall_sum=0\nfor i in A:\n number[i]+=1\nfor i in number:\n all_sum+=i*(i-1)/2\nfor i in range(N):\n print(int(all_sum-(number[A[i]]-1)))\n\n']
['Wrong Answer', 'Accepted']
['s398588676', 's493197475']
[28856.0, 26268.0]
[2105.0, 365.0]
[597, 205]
p02732
u690184681
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
['from collections import Counter\n\nN = int(input())\nA = list(map(int,input().split()))\n\na = list(set(A))\ncc = Counter(A)\ndup = [x for x in a if cc[x] > 1]\nm = len(a)\nl = len(A) \nal = sum(cc.values())\n\nfor k in A:\n if k in dup:\n print(int(al-cc[k]+1))\n else :\n print(int(al))', 'from collections import Counter\n\nN = int(input())\nA = list(map(int,input().split()))\na = list(set(A))\ncc = Counter(A)\ndup = set([x for x in a if cc[x] > 1])\nc_l = [(cc[i]-1)*(cc[i])/2 for i in a]\nal = sum(c_l)\n\nfor k in A:\n if k in dup:\n print(int(al-cc[k]+1))\n else :\n print(int(al))']
['Wrong Answer', 'Accepted']
['s770035689', 's443824186']
[27820.0, 28852.0]
[2105.0, 492.0]
[292, 304]
p02732
u692054751
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
['import collections\n\ndef LI():\n\treturn [ int(s) for s in input().split() ]\n\nN = int(input())\nA = LI()\n\nc_counter = [0]*(2*(10**5))\n\nfor a in A:\n c_counter[a]+=1\n\ntotal = 0\ntotal_dict = [0]*(2*(10**5))\n\nfor a in A:\n v = c_counter[a]\n if v >= 2:\n comb = v*(v-1)//2\n total_dict[a] = comb\n total += comb\n\nfor a in A:\n if total == 0:\n print(0)\n else:\n print(total - total_dict[a] + (c_counter[a]-1)*(c_counter[a]-2)//2)\n', 'import collections\n \ndef LI():\n\treturn [ int(s) for s in input().split() ]\n \nN = int(input())\nA = LI()\n \nc_counter = [0]*(2*(10**5))\n \nfor a in A:\n c_counter[a]+=1\n \ntotal = 0\ntotal_dict = [0]*(2*(10**5))\n \nfor a in range(len(c_counter)):\n v = c_counter[a]\n if v >= 2:\n comb = v*(v-1)//2\n total_dict[a] = comb\n total += comb\n \nfor a in A:\n if total == 0:\n print(0)\n else:\n print(total - total_dict[a] + (c_counter[a]-1)*(c_counter[a]-2)//2)']
['Wrong Answer', 'Accepted']
['s421519369', 's916424718']
[26780.0, 26780.0]
[441.0, 378.0]
[434, 460]
p02732
u693391925
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
['N=int(input())\nA = list(map(int, input().split()))\n\ndic={}\nfor i in A:\n if i in dic.keys():\n dic[i]+=1\n else:\n dic.setdefault(i,1)\n\nhoge=0\nfor i in dic.values():\n hoge+=i*(i-1)\nhoge =hoge/2\n\nfor k in A:\n print(hoge-(dic[k]-1))', 'N=int(input())\nA = list(map(int, input().split()))\n\ndic={}\nfor i in A:\n if i in dic.keys():\n dic[i]+=1\n else:\n dic.setdefault(i,1)\n\nhoge=0\nfor i in dic.values():\n hoge+=i*(i-1)\nhoge =int(hoge/2)\n\nfor k in A:\n print(hoge-(dic[k]-1))']
['Wrong Answer', 'Accepted']
['s707384392', 's936827924']
[26268.0, 25644.0]
[426.0, 346.0]
[252, 257]
p02732
u693945629
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
['import sys\nfrom operator import mul\nfrom functools import reduce\n\ndef combinations_count(n, r):\n r = min(r, n - r)\n numer = reduce(mul, range(n, n - r, -1), 1)\n denom = reduce(mul, range(1, r + 1), 1)\n return numer // denom\n\nn = int(input())\nl = [int(x) for x in input().split()]\n\n\ncl = []\nll = [x for x in set(l) if l.count(x) > 1]\n\n# print(ll)\n\nif not ll:\n for i in range(n):\n print(0)\n sys.exit()\n\nsum = 0\nfor i in ll:\n m = l.count(i)\n nc = combinations_count(m, 2)\n sum += nc\n # print(nc)\n \n cl.append(nc - int(nc * (m - 2) / m))\n\n# print(sum)\n# print(cl)\nfor i in l:\n \n idx = ll.index(i)\n if idx:\n print(0)\n else:\n print(sum - cl[ll.index(i)])\n', 'import sys\nimport collections\nfrom operator import mul\nfrom functools import reduce\n \ndef combinations_count(n, r):\n r = min(r, n - r)\n numer = reduce(mul, range(n, n - r, -1), 1)\n denom = reduce(mul, range(1, r + 1), 1)\n return numer // denom\n \nn = int(input())\nl = [int(x) for x in input().split()]\nc = collections.Counter(l)\n \n\ncl = []\n \n# print(ll)\n \nif not ll:\n for i in range(n):\n print(0)\n sys.exit()\n \nsum = 0\nfor a, v in c:\n nc = combinations_count(v, 2)\n sum += nc\n # print(nc)\n \n cl.append(nc - int(nc * (v - 2) / v))\n \n# print(sum)\n# print(cl)\n \ndef my_index(l, x, default=n):\n if x in l:\n return l.index(x)\n else:\n return default\n \nfor i in l:\n \n idx = my_index(ll, i)\n if idx == n:\n print(sum)\n else:\n print(sum - cl[idx])', 'import sys\nimport collections\nfrom operator import mul\nfrom functools import reduce\n \ndef combinations_count(n, r):\n r = min(r, n - r)\n numer = reduce(mul, range(n, n - r, -1), 1)\n denom = reduce(mul, range(1, r + 1), 1)\n return numer // denom\n \nn = int(input())\nl = [int(x) for x in input().split()]\nc = collections.Counter(l)\n \n\ncl = []\nll = [x for x in set(l) if l.count(x) > 1]\n \n# print(ll)\n \nif not ll:\n for i in range(n):\n print(0)\n sys.exit()\n \nsum = 0\nfor i in ll:\n nc = combinations_count(c[i], 2)\n sum += nc\n # print(nc)\n \n cl.append(nc - int(nc * (m - 2) / m))\n \n# print(sum)\n# print(cl)\n \ndef my_index(l, x, default=n):\n if x in l:\n return l.index(x)\n else:\n return default\n \nfor i in l:\n \n idx = my_index(ll, i)\n if idx == n:\n print(sum)\n else:\n print(sum - cl[idx])', 'import collections\n\ndef combinations_count(n, r):\n return n * (n-1) // r\n\n\nn = int(input())\nl = [int(x) for x in input().split()]\n\nl1 = []\nl2 = []\nc = collections.Counter(l)\n\ntotal = sum([combinations_count(i, 2) for i in c.values()])\n\nfor a in l:\n l1.append(combinations_count(c[a], 2))\n l2.append(combinations_count(c[a]-1, 2))\nprint(l1, l2)\nfor i in range(len(l)):\n print(total-l1[i]+l2[i])\n', 'import sys\nimport collections\nfrom operator import mul\nfrom functools import reduce\n\n\ndef combinations_count(n, r):\n if n < r:\n return 0\n r = min(r, n - r)\n numer = reduce(mul, range(n, n - r, -1), 1)\n denom = reduce(mul, range(1, r + 1), 1)\n return numer // denom\n\n\nn = int(input())\nl = [int(x) for x in input().split()]\nc = collections.Counter(l)\n\n\ncd = {}\n\n# print(ll)\n\nif not c:\n for _ in range(len(l)):\n print(0)\n sys.exit()\n\nsum = 0\nfor a in c:\n nc = combinations_count(c[a], 2)\n sum += nc\n # print(nc)\n \n cd[a] = (nc - int(nc * (c[a] - 2) / c[a]))\n\n"""\ndef my_index(lv):\n if lv not in c.keys():\n return sum\n else:\n return cd[lv]\n"""\n\nfor lv in l:\n print(sum-cd[lv])\n']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s120043455', 's489654267', 's623350698', 's738896579', 's182026606']
[27024.0, 26636.0, 26636.0, 41484.0, 31892.0]
[2105.0, 116.0, 2105.0, 517.0, 474.0]
[800, 904, 948, 406, 806]
p02732
u694422786
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
['import collections\nfrom collections import defaultdict\n\nn = int(input())\nl = list(map(int, input().split()))\n\ndict = defaultdict(int)\nfor i in l:\n dict[i]+=1\nprint(dict)\n\nans = 0\nfor v in dict.values():\n ans += int((v*(v-1)) // 2)\n\nfor k in l:\n print(ans - (dict[k] - 1))\n', 'from math import factorial\nn = int(input())\nl = list(map(int, input().split()))\n\ndict = defaultdict(int)\nfor i in l:\n dict[i]+=1\n\n\n\nfor j in l:\n ans = 0\n k = dict.copy()\n k[j] -= 1\n # print(k)\n for v in k.values():\n if v > 1:\n ans += int(factorial(v) / factorial(2) / factorial(v - 2))\n print(ans)\n', 'import collections\nfrom collections import defaultdict\n\nn = int(input())\nl = list(map(int, input().split()))\n\ndict = defaultdict(int)\nfor i in l:\n dict[i]+=1\n\nans = 0\nfor v in dict.values():\n ans += int((v*(v-1)) // 2)\n\nfor k in l:\n print(ans - (dict[k] - 1))\n']
['Wrong Answer', 'Runtime Error', 'Accepted']
['s657092754', 's869099787', 's662796714']
[26780.0, 26140.0, 26780.0]
[378.0, 66.0, 339.0]
[281, 337, 269]
p02732
u695261159
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
['n,a = [input().split() for i in range(2)]\n\nfor index, item in enumerate(a):\n count = 0\n for chk_index, chk_item in enumerate(a):\n if index == chk_index:\n continue\n for cnt_index, cnt_item in enumerate(a[chk_index+1:]):\n if index == cnt_index:\n continue\n if chk_item == cnt_item:\n count += 1\n print(count)\n', 'from collections import Counter\nimport math\ndef combinations_count(n, r):\n return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))\n\nn = int(input())\na = list(map(int, input().split()))\n\ncntA = Counter(a)\nall = 0\nfor i in cntA:\n if cntA[i] > 1:\n all += combinations_count(cntA[i], 2)\nfor i in range(len(a)):\n if cntA[a[i]] > 1:\n print(all - (cntA[a[i]] -1))\n else:\n print(all)']
['Wrong Answer', 'Accepted']
['s404801397', 's624480057']
[19996.0, 26780.0]
[2105.0, 1761.0]
[391, 424]
p02732
u696684809
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
['n = int(input())\na =list(map(int,input().split()))\nd = [0]*(n+1)\nanswer = 0\nfor i in range(n):\n d[a[i]]+=1\nfor j in range(n):\n answer+= (d[j]*(d[j]-1))//2\nfor k in range(n) \n print(answer+1-(d[a[k]]))', 'n = int(input())\na =list(map(int,input().split()))\nd = [0]*(n+1)\nanswer = 0\nfor i in range(n):\n d[a[i]]+=1\nfor j in range(n+1):\n answer+= (d[j]*(d[j]-1))//2\nfor k in range(n):\n print(answer+1-(d[a[k]]))']
['Runtime Error', 'Accepted']
['s504691487', 's712774457']
[9016.0, 32324.0]
[29.0, 226.0]
[204, 205]
p02732
u697696097
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
['n=int(input())\narr=list(map(int,input().split()))\ntt=[0]*(n+7)\n\ntotal=0\n\nfor a in range(n):\n tt[a]+=1\n\nfor t in tt:\n total += (t*(t-1)//2)\n\nfor i in range(n):\n n = tt[arr[0]]\n d = (n*(n-1)//2) - ((n-1)*(n-2)//2)\n print(total-d)\n# x * x-1 // 2', 'n=int(input())\narr=list(map(int,input().split()))\ntt=[0]*(n+7)\n\ntotal=0\n\nfor a in arr:\n tt[a]+=1\n\nfor t in tt:\n total += (t*(t-1)//2)\n\nfor i in range(n):\n n = tt[arr[i]]\n d = (n*(n-1)//2) - ((n-1)*(n-2)//2)\n print(total-d)\n# x * x-1 // 2\n']
['Wrong Answer', 'Accepted']
['s291330765', 's284230478']
[32176.0, 32160.0]
[215.0, 255.0]
[247, 243]
p02732
u698849142
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
['import collections\nn=int(input())\na=list(map(int,input().split()))\nd=collections.Counter(a)\ntotal=sum([(v-1)*v//2, for v in d.values()])\nfor x in a:\n print(total-d[x]+1)', 'n=int(input())\na=list(map(int,input().split()))\nd={}\nfor x in a:\n if d.get(x):\n d[x]+=1\n continue\n d[x]=1\ntotal=sum(d.values())\nfor x in a:\n print(total-d[x]+1)', "n=int(input())\na=list(map(int,input().split()))\nd={}\nua=list(set(a))\ntotal=0\nprint('hoge')\nfor x in ua:\n y=a.count(x)\n d[x]=y\n total+=(y-1)*y//2\nfor x in a:\n print(total-d[x]+1)\n", 'n=int(input())\na=list(map(int,input().split()))\nua=list(set(a))\ntotal=sum([sum(range(a.count(x))) for x in ua])\nd={}\ntotal=0\nfor x in ua:\n c=a.count(x)\n d[x]=c\n total+=sum(range(c))\nfor i in range(n):\n print(total-d[i]+1)', 'n=int(input())\na=list(map(int,input().split()))\nd={}\nfor x in a:\n if d.get(x) is None:\n d[x]=1\n continue\n d[x]+=1\ntotal=0\nfor v in d.values():\n total+=(y-1)*y//2\nfor x in a:\n print(total-d[x]+1)', 'import collections\nn=int(input())\na=list(map(int,input().split()))\nd=collections.Counter(a)\ntotal=sum([(v-1)*v//2 for v in d.values()])\nfor x in a:\n print(total-d[x]+1)']
['Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Accepted']
['s023071124', 's085572397', 's631202113', 's777546133', 's989752967', 's373089297']
[2940.0, 26140.0, 26140.0, 24748.0, 24748.0, 26780.0]
[17.0, 310.0, 2104.0, 2105.0, 133.0, 329.0]
[172, 183, 190, 233, 220, 171]
p02732
u698919163
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
['N = int(input())\nA = list(map(int,input().split()))\nimport collections as col\n \nnum _list= set(A)\nca = col.Counter(A)\n\nnum = 0\n\nfor i in num_list:\n if ca[i] == 1:\n continue\n else:\n num += (ca[i]*(ca[i]-1))//2\n \nfor i in A:\n ans = num - (ca[i]-1)\n print(ans)', 'N = int(input())\nA = list(map(int,input().split()))\nimport collections as col\n \nnum_list = set(A)\nca = col.Counter(A)\n\nnum = 0\n\nfor i in num_list:\n if ca[i] == 1:\n continue\n else:\n num += (ca[i]*(ca[i]-1))//2\n \nfor i in A:\n ans = num - (ca[i]-1)\n print(ans)']
['Runtime Error', 'Accepted']
['s605802000', 's557992738']
[2940.0, 29312.0]
[18.0, 379.0]
[290, 290]
p02732
u699547221
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
['N = int(input())\nA = list(map(int, input().split()))\n\nANSWER = []\nfor i in range(N):\n A_ = A.copy()\n del A_[i]\n unique_i = list(set(A_))\n\n answer_i = 0\n for j in unique_i:\n answer_i += (A_.count(j) * (A_.count(j)-1)/2)\n \n ANSWER.append(int(answer_i))\n \nprint(ANSWER)', 'N = int(input())\nA = list(map(int, input().split()))\n\nANSWER = []\nfor i in range(N):\n A_ = A.copy()\n del A_[i]\n unique_i = list(set(A_))\n\n answer_i = 0\n for j in unique_i:\n answer_i += (A_.count(j) * (A_.count(j)-1)/2)\n \n ANSWER.append(int(answer_i))', 'N = int(input())\nA = list(map(int, input().split()))\n\ncounter = np.bincount(A)\n\nans = []\nfor i in range(len(A)):\n counter_i = counter.copy()\n counter_i[A[i]] -=1\n sum_i = sum(counter_i * (counter_i -1) //2)\n ans.append(sum_i)\n \nfor i in range(len(ans)):\n print(ans[i])', 'import numpy as np\n\nN = int(input())\nA = list(map(int, input().split()))\n\ncounter = np.bincount(A)\n\ndiff = (counter * (counter-1)//2 - (counter-1) * (counter-2)//2)\nans = total - diff[A]\n\nprint(*ans, sep="\\n")', 'N = int(input())\nA = list(map(int, input().split()))\n\nA_ = A.copy()\n\nANSWER = []\nfor i in range(N):\n del A_[i]\n unique_i = list(set(A_))\n\n answer_i = 0\n for j in unique_i:\n answer_i += (A_.count(j) * (A_.count(j)-1)/2)\n \n ANSWER.append(int(answer_i)\n \n A_ = A.copy()', 'import numpy as np\n\nN = int(input())\nA = list(map(int, input().split()))\n\ncounter = np.bincount(A)\n\ntotal = (counter * (counter - 1)).sum() // 2\ndiff = counter -1\nans = total - diff[A]\n\nprint(*ans, sep="\\n")']
['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s051103532', 's580300132', 's821049080', 's894009528', 's938555839', 's179306160']
[26268.0, 26140.0, 26140.0, 34136.0, 3064.0, 36080.0]
[2104.0, 2104.0, 65.0, 229.0, 19.0, 898.0]
[297, 278, 286, 209, 297, 207]
p02732
u699944218
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
['import collections as cl\nN = int(input())\nA = list(map(int,inpput().split()))\ncn = cl.Counter(A)\nsumC = sum([n*(n-1)//2 for n in cl.values()])\nfor k in range(N):\n print(sumC - cn[A[k]] +1)', 'import collections as cl\nn = int(input())\nA = list(map(int,input().split()))\ncn = cl.Counter(A)\nsumC = sum([(n-2)*(n-1)/2 for n in cn.values()])\nfor k in range(n):\n print(sumC - cn[A[k]] +1)', 'import collections as cl\nN = int(input())\nA = list(map(int,input().split()))\ncn = cl.Counter(A)\nsumC = sum([N*(N-1)//2 for N in cn.values()])\nfor k in range(N):\n sum = sumC - cn[A[k]] +1\nprint(sum)', 'import collections as cl\nn = int(input())\nA = list(map(int,input().split()))\ncn = cl.Counter(A)\nsumC = sum([(n-2)*(n-1)/2 for n in cn.values()])\nfor k in range(n):\n print(sumC - cn[k] +1)', 'import collections as cl\nN = int(input())\nA = list(map(int,inpput().split()))\ncn = cl.Counter(A)\nsumC = sum([n*(n-1)//2 for n in cl.values()])\nfor k in range(N):\n print(sumC - cn[k] +1)', 'N = int(input())\nA = list(map(int,input().split()))\ncount = 0\nfor i in range(N):\n for j in range(N):\n if A[i] == A[j]:\n count += 1\n else:\n count += 0\n print(count-i-1)', 'import collections as cl\nN = int(input())\nA = list(map(int,input().split()))\ncn = cl.Counter(A)\nsumC = sum([N*(N-1)//2 for N in cn.values()])\nfor k in range(N):\n sum = sumC - cn[A[k]] +1\n print(sum)']
['Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s144729415', 's371166371', 's381025388', 's458255813', 's814894889', 's967216419', 's572801220']
[3316.0, 26780.0, 26780.0, 26780.0, 3316.0, 25644.0, 25900.0]
[20.0, 427.0, 174.0, 437.0, 20.0, 2104.0, 348.0]
[189, 191, 198, 188, 186, 185, 200]
p02732
u705007443
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
["import numpy as np\nn=int(input())\na=list(np.fromstring(input(),int,sep=' '))\na_=list(set(a))\ndic={}\nans={}\nfor i in a_:\n dic[i]=a.count(i)\n \ndef check(x):\n lst_=lst\n count=0\n ans=0\n dic_=dic\n for i in a_:\n if x==i:\n dic_[x]-=1\n break\n for i in dic_.values():\n ans+=i*(i-1)//2\n dic_[x]+=1\n return ans\n\nfor i in a_:\n ans[i]=check(i)\n\nfor i in a:\n print(ans[i])", "import numpy as np\nimport collections\nn=int(input())\na=list(np.fromstring(input(),int,sep=' '))\ndic=collections.Counter(a)\nans=0\n\nfor i in dic.values():\n ans+=i*(i-1)//2\n \nfor i in range(n):\n print(ans-(dic[a[i]]-1))"]
['Runtime Error', 'Accepted']
['s593509734', 's348718506']
[27848.0, 30808.0]
[2109.0, 468.0]
[430, 225]
p02732
u709304134
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
['import collections\ndef C(n):\n return n * (n-1) // 2\nN = int(input())\nA = list(map(int,input().split()))\nc = collections.Counter(A)\nd = {}\nsm = 0\nfor k,v in c.most_common():\n d[k] = v\n sm += C(v)\nfor a in A:\n print (sm - 1 + d[a])', 'import collections\ndef C(n):\n return n * (n-1) // 2\nN = int(input())\nA = list(map(int,input().split()))\nc = collections.Counter(A)\nd = {}\nsm = 0\nfor k,v in c.most_common():\n d[k] = v\n sm += C(v)\nfor a in A:\n print (sm - d[a] + 1)']
['Wrong Answer', 'Accepted']
['s788110720', 's451394522']
[38836.0, 38840.0]
[397.0, 415.0]
[241, 241]
p02732
u713914478
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
['import collections \nfrom collections import Counter\n*l, = map(int, input().split())\nc = Counter(l)\n\nA = [int(i*(i-1)/2) for i in c.values()]\nA_sum = sum(A)\n\nfor j in l:\n\tprint(A_sum - c[j] + 1)', 'import collections \nfrom collections import Counter\n*l, = map(int, input().split())\nc = Counter(l)\n\nA = [int(i*(i-1)/2) for i in c.values()]\nA_sum = sum(A)\n\nfor j in l:\n\tprint(A_sum - c[j] + 1)', 'import collections \nfrom collections import Counter\n\nn = input()\n*l, = map(int, input().split())\nc = Counter(l)\n\nA = [int(i*(i-1)/2) for i in c.values()]\nA_sum = sum(A)\n\nfor j in l:\n\tprint(A_sum - c[j] + 1)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s039918045', 's939835224', 's037878970']
[3316.0, 3444.0, 26780.0]
[21.0, 21.0, 326.0]
[193, 193, 206]
p02732
u725133562
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
["def main():\n n = int(input())\n a = tuple(map(int, input().split()))\n ans = 0\n lim = max(a)\n amount = [0]*lim\n for i in range(lim):\n amount[0] = a.count(i+1)\n ans += amount[i]*(amount[i]-1)//2\n #print(ans)\n for j in range(n):\n ansout = ans\n #print(amount[a[j]-1])\n ansout -= amount[a[j]-1] -1\n print(ansout)\n\nif __name__ == '__main__':\n main()", "import numpy as np\ndef main():\n from collections import Counter\n n = int(input())\n a = tuple(map(int, input().split()))\n ans = 0\n c = Counter(a)\n for i in range(n):\n ans += c[i+1]*(c[i+1]-1)//2\n for j in range(n):\n print(ans - c[a[j]] + 1)\nif __name__ == '__main__':\n main()"]
['Wrong Answer', 'Accepted']
['s461547890', 's158560375']
[26396.0, 34168.0]
[2104.0, 546.0]
[411, 312]
p02732
u726285999
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
['import itertools\n\n\nN = int(input())\nAn = [int(x) for x in input().split()]\n\n\nL = []\nfor i in range(0,N+1):\n l = [0] * i\n L.append(len(list(itertools.combinations(l,2))))\n \n\nCn = [An.count(i) for i in range(1,N+1)]\n\n\nDn = [L[Cn[i-1]] for i in range(1,N+1)]\ns = sum(Dn)', 'import copy\n\nN = int(input())\nAn = [int(x) for x in input().split()]\n\nfor i in range(N):\n tmp = copy.copy(An)\n tmp.pop(i)\n \n c = 0\n for i in range(N):\n k = tmp.count(i)\n if k>1:\n c += int(math.factorial(k) / (math.factorial(k-2) * 2))\n print(c)', 'import math\n\nN = int(input())\nAn = [int(x) for x in input().split()]\n \nL = [0,0]\nfor i in range(N):\n if i > 1:\n L.append(int(math.factorial(i) / (math.factorial(i-2) * 2)))\n\nCn = [An.count(i) for i in range(1,N+1)]\ns = sum([L[Cn[i]] for i in range(N)])\n\nfor k in range(N):\n print(sum(Dn) - (Cn[An[k]-1]-1))', 'N = int(input())\nAn = [int(x) for x in input().split()]\n\nL = [0,0]\nfor i in range(N):\n if i > 1:\n L.append(int(math.factorial(i) / (math.factorial(i-2) * 2)))\n\nfor k in range(N):\n Bn = [An[i] for i in range(N) if not i == k]\n Cn = [Bn.count(i) for i in range(N)]\n Dn = [Cn.count(i)*L[i] for i in range(N)] \n \n print(sum(Dn))', 'N = int(input())\nAn = [int(x) for x in input().split()] \n \n\ns = 0\nfor i in range(1,N+1):\n b = An.count(i)\n if b > 1:\n s += b*(b-1) / 2\n\nfor k in range(N):\n print(s - (An.count(An[k])-1))', 'N = int(input())\nAn = [int(x) for x in input().split()]\n \nL = [0,0]\nfor i in range(N):\n if i > 1:\n L.append(int(math.factorial(i) / (math.factorial(i-2) * 2)))\n\nCn = [An.count(i) for i in range(1,N+1)]\ns = sum([L[Cn[i]] for i in range(N)])\n\nfor k in range(N):\n print(sum(Dn) - (Cn[An[k]-1]-1))', 'import collections as c\n\n\nN = int(input())\nAn = [int(x) for x in input().split()]\n \n\nCn = c.Counter(An)\n \n\ns = 0\nfor v in Cn.values():\n s += int(v*(v-1) / 2)\n\nfor i in range(0,N):\n print(s - (Cn[An[i]] - 1))']
['Wrong Answer', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s037992727', 's607474161', 's647658552', 's804616543', 's828355914', 's926553895', 's292775558']
[26140.0, 26908.0, 26140.0, 25768.0, 26012.0, 25716.0, 26780.0]
[2105.0, 2104.0, 2104.0, 72.0, 2108.0, 78.0, 370.0]
[359, 287, 319, 349, 259, 306, 279]
p02732
u729790965
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
['n=(int)(nput())\na=input().split()\nfor i in range(n):\n a[i]=(int)(a[i])\n \ndic={}\nsum=0\nfor i in range(n):\n if not a[i] in dic:\n dic[a[i]]=1\n else:\n dic[a[i]]+=1\n sum+=dic[a[i]]-1\n\nfor i in a:\n print(sum-dic[i]+1)\n\n', 'n=(int)(input())\na=input().split()\nfor i in range(n):\n a[i]=(int)(a[i])\n \ndic={}\nsum=0\nfor i in range(n):\n if not a[i] in dic:\n dic[a[i]]=1\n else:\n dic[a[i]]+=1\n sum+=dic[a[i]]-1\n\nfor i in a:\n print(sum-dic[i]+1)\n\n']
['Runtime Error', 'Accepted']
['s055203205', 's072346097']
[8992.0, 31860.0]
[25.0, 257.0]
[227, 228]
p02732
u731322489
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
['n = int(input())\nA = list(map(int, input().split()))\n\nC = list(itertools.combinations(A, 2))\nC = list(c for c in C if c[0] == c[1])\nequal = len(C)\n\nfor i in range(n):\n A_tmp = A[: i] + A[i + 1: ]\n equal_i = A_tmp.count(A[i])\n print(equal - equal_i)', 'import math\nimport collections\n\nn = int(input())\nA = list(map(int, input().split()))\n\nequal = 0\nelements = collections.Counter(A)\nequal = sum([v * (v - 1) // 2 for v in elements.values()])\n\nfor i in range(n):\n equal_i = elements[A[i]] - 1\n print(equal - equal_i)']
['Runtime Error', 'Accepted']
['s349957948', 's588133637']
[26268.0, 26780.0]
[65.0, 338.0]
[257, 268]
p02732
u731368968
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
['N = int(input())\nA = list(map(int, input().split()))\ncount = [0] * 200005\nfor a in A:\n count[a] += 1\n\ns = 0\nfor c in count:\n s += c * (c - 1) // 2\nprint(s)\n\nfor a in A:\n c = count[a]\n x = c * (c - 1) // 2\n c -= 1\n y = c * (c - 1) // 2\n\n print(s - x + y)\n', 'N = int(input())\nA = list(map(int, input().split()))\ncount = [0] * 200005\nfor a in A:\n count[a] += 1\n\ns = 0\nfor c in count:\n s += c * (c - 1) // 2\n\nfor a in A:\n c = count[a]\n x = c * (c - 1) // 2\n c -= 1\n y = c * (c - 1) // 2\n\n print(s - x + y)\n']
['Wrong Answer', 'Accepted']
['s281156960', 's805093285']
[24748.0, 26268.0]
[392.0, 385.0]
[275, 266]
p02732
u736470924
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
['n = int(input())\ndA = {}\nfor a in input().split():\n if a in dA:\n dA[a] += 1\n else:\n dA[a] = 1\n\ncA = {}\nfor a in dA:\n cA[a] = dA[a] * (dA[a] - 1) // 2\n\nfor a in A:\n print(sum(cA.values()) - dA[a] + 1)\n', 'n = int(input())\ndA = {}\nA = []\nfor a in input().split():\n A.append(a)\n if a in dA:\n dA[a] += 1\n else:\n dA[a] = 1\n\ncA = {}\nfor a in dA:\n cA[a] = dA[a] * (dA[a] - 1) // 2\n\ns = sum(cA.values())\nfor a in A:\n print(s - dA[a] + 1)\n']
['Runtime Error', 'Accepted']
['s429487389', 's444411377']
[32636.0, 36508.0]
[150.0, 359.0]
[226, 255]
p02732
u736641785
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
['from sys import stdin\ninput = stdin.readline\n\nN = int(input())\nA = list(map(int,input().split()))\nimport collections\nc = collections.Counter(A)\n\nfor i in A:\n temp = c.copy()\n temp[i] = temp[i]-1\n counter = 0\n for j in c.keys():\n n = temp[j]\n if n >= 2:\n counter += n*(n-1)/2\n print(counter)', 'N = int(input())\nA = list(map(int,input().split()))\nimport collections\nc = collections.Counter(A)\n\nfor i in A:\n temp = c.copy()\n temp[i] = temp[i]-1\n counter = 0\n for j in c.keys():\n n = temp[j]\n if n >= 2:\n counter += n*(n-1)/2\n print(counter)', 'N = int(input())\nA = list(map(int,input().split()))\nimport collections\nc = collections.Counter(A)\ncounter = 0\nfor j in c.keys():\n if c[j]>=2:\n counter+=c[j]*(c[j]-1)/2\n\n\n\nfor i in A:\n print(int(counter-c[i]+1))']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s845176823', 's902754120', 's013598588']
[33784.0, 32692.0, 24748.0]
[2105.0, 2105.0, 420.0]
[330, 284, 223]
p02732
u741612283
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
['n = int(input())\na_list = [int(x) for x in input().split()]\na_dict = {}\n\nfor a in a_list:\n if a in a_dict.keys():\n a_dict[a] += 1\n else:\n a_dict[a] = 0\n\nfor a in a_list:\n print(a_dict[a])', 'n = int(input())\na_list = [int(x) for x in input().split()]\na_dict = {}\n\nfor a in a_list:\n if a in a_dict.keys():\n a_dict[a] += 1\n else:\n a_dict[a] = 1\n\n\nsum_value = sum([int((v*(v-1))/2)for v in a_dict.values()])\n\nfor a in a_list:\n print(sum_value-a_dict[a]+1)']
['Wrong Answer', 'Accepted']
['s201958091', 's977474949']
[24744.0, 24748.0]
[279.0, 351.0]
[196, 270]
p02732
u742899538
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
['N = int(input())\nA = list(map(int, input().split()))\n\nnumber = defaultdict(int)\nfor a in A:\n number[a] += 1\n\ndef combination(n, r):\n denominator = 1\n for i in range(n, n - r, -1):\n denominator *= i\n numerator = factorial(r)\n return denominator // numerator\n\ncombi = {}\ncombi2 = {}\nfor k, v in number.items():\n combi[k] = combination(v, 2)\n combi2[k] = combination(v - 1, 2)\ncombination_all = sum(combi.values())\n# print(f"number:{number} combi:{combi} combi2:{combi2} combination_all:{combination_all}", file=sys.stderr)\n\nfor a in A:\n # print(f"a:{a} n:{n}", file=sys.stderr)\n print(combination_all - (combi[a] - combi2[a]))', 'from collections import defaultdict\nfrom math import factorial N = int(input())\nA = list(map(int, input().split()))\n\nnumber = defaultdict(int)\nfor a in A:\n number[a] += 1\n\ndef combination(n, r):\n denominator = 1\n for i in range(n, n - r, -1):\n denominator *= i\n numerator = factorial(r)\n return denominator // numerator\n\ncombi = {}\ncombi2 = {}\nfor k, v in number.items():\n combi[k] = combination(v, 2)\n combi2[k] = combination(v - 1, 2)\ncombination_all = sum(combi.values())\n# print(f"number:{number} combi:{combi} combi2:{combi2} combination_all:{combination_all}", file=sys.stderr)\n\nfor a in A:\n print(combination_all - (combi[a] - combi2[a]))\n', 'N = int(input())\nA = list(map(int, input().split()))\n\nnumber = defaultdict(int)\nfor a in A:\n number[a] += 1\n\ndef combination(n, r):\n denominator = 1\n for i in range(n, n - r, -1):\n denominator *= i\n numerator = factorial(r)\n return denominator // numerator\n\ncombi = {}\ncombi2 = {}\nfor k, v in number.items():\n combi[k] = combination(v, 2)\n combi2[k] = combination(v - 1, 2)\ncombination_all = sum(combi.values())\n# print(f"number:{number} combi:{combi} combi2:{combi2} combination_all:{combination_all}", file=sys.stderr)\n\nfor a in A:\n print(combination_all - (combi[a] - combi2[a]))', 'from collections import defaultdict\nfrom math import factorial\n\nN = int(input())\nA = list(map(int, input().split()))\n\nnumber = defaultdict(int)\nfor a in A:\n number[a] += 1\n\ndef combination(n, r):\n denominator = 1\n for i in range(n, n - r, -1):\n denominator *= i\n numerator = factorial(r)\n return denominator // numerator\n\ncombi = {}\ncombi2 = {}\nfor k, v in number.items():\n combi[k] = combination(v, 2)\n combi2[k] = combination(v - 1, 2)\ncombination_all = sum(combi.values())\n# print(f"number:{number} combi:{combi} combi2:{combi2} combination_all:{combination_all}", file=sys.stderr)\n\nfor a in A:\n print(combination_all - (combi[a] - combi2[a]))']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s467338579', 's498320156', 's572946189', 's541248012']
[26140.0, 2940.0, 26268.0, 38972.0]
[65.0, 17.0, 67.0, 518.0]
[658, 680, 613, 677]
p02732
u745687363
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
['n = int(input())\nA = list(map(int, input().split())\nfrom collections import Counter\nL = list(Counter(A))\nLV = L.values()\n\nans = 0\nfor x in LV:\n ans += x*(x-1)//2\n\nfor k in range(n):\n print(ans-(A[k]-1)) ', 'n = int(input())\nA = list(map(int, input().split()))\nfrom collections import Counter\nD = Counter(A)\nL = list(D.values())\n\nans = 0\nfor x in L:\n ans += x*(x-1)//2\n\nfor k in range(n):\n print(ans-(D[A[k]]-1)) ']
['Runtime Error', 'Accepted']
['s693446752', 's988373611']
[2940.0, 25644.0]
[17.0, 358.0]
[209, 211]
p02732
u746206084
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
['n=int(input())\nli=list(map(int,input().split()))\nd={}\ndif={-1}\nans={}\nfor i in range(n):\n if li[i] not in dif:\n dif|={li[i]}\n if d.get(li[i])!=None:\n d[li[i]]+=1\n else:\n d[li[i]]=1\ndif.remove(-1)\nfor i in dif:\n g=0\n for j in dif:\n if i!=j:\n g+=d[j]*(d[j]-1)//2\n else:\n g+=(d[j]-2)*(d[j]-1)//2\n ans[i]=g\nfor i in li:\n print(ans[i])\n', 'n=int(input())\nli=list(map(int,input().split()))\nd={}\ndif={-1}\nans={}\nfor i in range(n):\n if li[i] not in dif:\n dif|={li[i]}\n if d.get(li[i])!=None:\n d[li[i]]+=1\n else:\n d[li[i]]=1\ndif.remove(-1)\ng=0\nfor i in dif:\n g+=d[i]*(d[i]-1)//2\nfor i in dif:\n ans[i]=g-(d[i]-1)*d[i]//2+(d[i]-2)*(d[i]-1)//2\nfor i in li:\n print(ans[i])']
['Wrong Answer', 'Accepted']
['s375730977', 's522363596']
[28956.0, 38992.0]
[2105.0, 558.0]
[425, 363]
p02732
u751057101
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
["def cmb(n):\n return n * (n-1) / 2\n\ndef main():\n\n N = int(input())\n\n a_l = [0] * N\n\n nums = list(map(int, input().split()))\n\n for i in nums:\n a_l[i-1] += 1\n\n for i in nums:\n a_l[i-1] -= 1\n total = 0\n for j in a_l:\n if j > 1:\n total += cmb(j)\n print(total)\n a_l[i-1] += 1\n\n\nif __name__ == '__main__':\n main()", "def cmb(n):\n return int(n * (n-1) / 2)\n\ndef main():\n\n N = int(input())\n\n a_l = [0] * N\n\n nums = list(map(int, input().split()))\n for i in nums:\n a_l[i-1] += 1\n\n total = 0\n for j in a_l:\n if j > 1:\n total += cmb(j)\n\n for k in nums:\n if a_l[k-1] > 1:\n print(total - cmb(a_l[k-1]) + cmb(a_l[k-1] - 1))\n else:\n print(total)\n\n\nif __name__ == '__main__':\n main()"]
['Wrong Answer', 'Accepted']
['s592007905', 's106986999']
[27676.0, 27252.0]
[2104.0, 423.0]
[395, 444]
p02732
u751277549
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
['# from collections import deque\nfrom collections import Counter\nfrom scipy.misc import comb\nfrom copy import deepcopy\n\nn = int(input())\na = list(map(int, input().split()))\ncnt_n = 0\na_n = deepcopy(a)\nc = Counter(a_n)\nfor key in c:\n cnt_n += comb(c[key], 2, exact=True)\n\nfor k in range(len(a)):\n a_n = deepcopy(a)\n a_k = deepcopy(a[k])\n a_n.pop(k)\n cnt_k = a_n.count(a_k)\n print(cnt_n - cnt_k)\n', '# from collections import deque\nfrom collections import Counter\nfrom scipy.misc import comb\n# from scipy.special import comb\nfrom copy import deepcopy\n\nn = int(input())\nk = list(map(int, input().split()))\nfor i in range(len(k)):\n ans = 0\n k_n = deepcopy(k)\n k_n.pop(i)\n c = Counter(k_n)\n for key in c:\n ans += comb(c[key], 2, exact=True)\n print(ans)', '# from collections import deque\nfrom collections import Counter\nfrom scipy.misc import comb\n# from scipy.special import comb\n\nn = int(input())\nk = list(map(int, input().split()))\nfor i in range(len(k)):\n ans = 0\n k_n = k.copy()\n k_n.pop(i)\n c = Counter(k_n)\n for key in c:\n ans += comb(c[key], 2, exact=True)\n print(ans)', '# from collections import deque\nfrom collections import Counter\n# from scipy.misc import comb\n# from copy import deepcopy\n\nn = int(input())\na = list(map(int, input().split()))\nC = Counter(a)\nS = 0\n"""\nfor key in C:\n S += comb(C[key], 2, exact=True)\n"""\nfor i in C.keys():\n S += C[i]*(C[i]-1)//2\n\nfor k in range(n):\n A = a[k]\n print(S - C[A] + 1)']
['Time Limit Exceeded', 'Time Limit Exceeded', 'Time Limit Exceeded', 'Accepted']
['s148741529', 's363859280', 's753808051', 's731388407']
[35224.0, 46500.0, 46408.0, 26780.0]
[2109.0, 2114.0, 2110.0, 381.0]
[411, 374, 345, 357]
p02732
u751843916
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
['import collections\nimport copy\n\ndef f(l):\n return l*(l-1)\n\n\nn=int(input())\na=list(map(int,input().split()))\nb=collections.Counter(a)\nprint(b)\n\nfor x in a:\n c=copy.deepcopy(b)\n c[x]-=1\n d=c.values()\n e=0\n for y in d:\n e+=f(y)\n print(e//2)', 'import collections\nn=int(input())\na=list(map(int,input().split()))\nb=collections.Counter(a)\ne=0\nfor x in b.values():\n e+=x*(x-1)\nfor x in a:\n t=b[x]\n p=e-t*(t-1)+(t-1)*(t-2)\n print(p//2)']
['Wrong Answer', 'Accepted']
['s704298942', 's718237864']
[53484.0, 26780.0]
[2106.0, 379.0]
[265, 198]
p02732
u760961723
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
['from collections import Counter\nimport numpy as np\n\nN = int(input()) \nli = list(map(int, input().split())) \n\n#print(N)\n#print(li)\n\n\nfor k in range(N):\n ans = 0\n LI = li.copy()\n LI_k = LI.pop(k)\n #print(LI)\n counter = Counter(LI)\n #print(counter)\n #print(len(counter))\n #print(counter.values())\n counter_value_array = np.array(list(counter.values()))\n for i in range(len(counter_value_array)):\n ans = ans + counter_value_array[i] * (counter_value_array[i]-1)/2\n print(ans)\n ', 'N = int(input())\nA = list(map(int,input().split()))\n\nimport collections\nimport math\n\ndicA = collections.Counter(A)\n\ntotal = 0\nfor x in list(dicA.values()):\n if x != 1:\n total += math.factorial(x) // (math.factorial(x - 2)*2)\n\nfor i in range(N):\n print(total - dicA[A[i]] +1)\n ']
['Wrong Answer', 'Accepted']
['s774092120', 's333518776']
[48740.0, 25644.0]
[2112.0, 1712.0]
[585, 282]
p02732
u762325798
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
["def check_block(comb, K):\n block = 0\n pre = (comb & 1) > 0\n mapping = {0: 0}\n cut_num = 0\n for i in range(1, K):\n cur = ((1 << i) & comb) > 0\n if pre != cur:\n block += 1\n pre = cur\n cut_num += 1\n mapping[i] = block\n return mapping, cut_num\n\nH, W, K = map(int, input().split())\ngraph = [input() for ele in range(H)]\n#\nans = 1319203291031903\nfor comb in range(1<<(H-1)):\n mapping, cut_num = check_block(comb, K)\n pre = [0] * (cut_num + 1)\n gg = False\n # preprocess \n for j in range(H):\n pre[mapping[j]] += (graph[j][0] == '1')\n for ele in pre:\n if ele > K:\n gg = True\n break\n if gg: continue\n\n for i in range(1, W):\n cum = pre[:]\n for j in range(H):\n cum[mapping[j]] += (graph[j][i] == '1')\n for ii in range(len(cum)):\n if cum[ii] - pre[ii] > K:\n gg = True\n break\n if cum[ii] > K:\n cut_num += 1\n for idx in range(len(cum)):\n cum[idx] -= pre[idx]\n break\n pre = cum\n if gg: break\n\n if not gg:\n ans = min(ans, cut_num)\nprint(ans)\n", 'n = int(input())\nnums = list(map(int, input().split()))\n\nnum_count = {}\nfor num in nums:\n num_count[num] = num_count.get(num, 0) + 1\n\ntotal = 0\nfor num, ele in num_count.items():\n total += (ele * (ele - 1)) // 2\n\nans = []\n\nfor num in nums:\n ans.append(total - num_count[num] + 1)\nprint("\\n".join(list(map(str, ans))))\n']
['Runtime Error', 'Accepted']
['s857995708', 's883537900']
[3064.0, 38972.0]
[18.0, 307.0]
[1229, 327]
p02732
u767664985
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
['from collections import Counter\n\nN = int(input())\nA = list(map(int, input().split()))\nc = Counter(A)\n\n\nans = 0\nfor n in c.values():\n ans += n*(n-1)//2\n\n\nfor k in range(N):\n m = c[A[k]]\n ans -= m-1 # -m*(m-1)//2 + (m-1)*(m-2)//2\n print(ans)\n', 'from collections import Counter\n\nN = int(input())\nA = list(map(int, input().split()))\nc = Counter(A)\n\n\nans = 0\nfor n in c.values():\n ans += n*(n-1)//2\n\n\nfor k in range(N):\n m = c[A[k]]\n print(ans - (m-1)) # -m*(m-1)//2 + (m-1)*(m-2)//2\n']
['Wrong Answer', 'Accepted']
['s077938241', 's291069470']
[26780.0, 26780.0]
[356.0, 351.0]
[352, 345]
p02732
u768496010
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
["n = int(input())\nalist = list(map(int,input().split(' ')))\n\nfrom collections import defaultdict\n\nresdict = {}\n\nfrom collections import Counter\n\nc = Counter(alist)\n\nold_cdict = dict(c)\n\ncdict = dict((key, value) for (key, value) in old_cdict.items() if value >= 2)\n\n# print(cdict)\n\nmaxi = 0\n\nfor k, v in cdict.items():\n maxi += v * (v - 1) // 2\n\nfor a in alist:\n num = 0\n if num in cdict:\n num = cdict[a]\n if num in resdict:\n # print('used')\n print(resdict[num])\n continue\n # print('not used')\n if a in cdict:\n cdict[a] -= 1\n temp = 0\n for k,v in cdict.items():\n temp += v*(v-1)//2\n print(temp)\n resdict[num] = temp\n cdict[a] += 1\n else:\n print(maxi)", "n = int(input())\nalist = list(map(int,input().split(' ')))\n\nfrom collections import defaultdict\n\nresdict = {}\n\nfrom collections import Counter\n\nc = Counter(alist)\n\ncdict = dict(c)\n\n# cdict = dict((key, value) for (key, value) in old_cdict.items() if value >= 2)\n\n# print(cdict)\n\nmaxi = 0\n\nfor k, v in cdict.items():\n maxi += v * (v - 1) // 2\n\nfor a in alist:\n num = cdict[a]\n if num in resdict:\n # print('used')\n print(resdict[num])\n continue\n # print('not used')\n if a in cdict:\n cdict[a] -= 1\n temp = 0\n for k,v in cdict.items():\n temp += v*(v-1)//2\n print(temp)\n resdict[num] = temp\n cdict[a] += 1\n else:\n print(maxi)"]
['Wrong Answer', 'Accepted']
['s709512989', 's494652014']
[32928.0, 29140.0]
[353.0, 645.0]
[758, 719]
p02732
u768896740
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
['import numpy as np\nimport math\n\ndef combinations_count(n, r):\n return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))\n\n\nn = int(input())\na = np.array(list(map(int, input().split())))\n\narray = np.zeros(n+1)\n\nfor i in a:\n array[i] += 1\n\nsum = 0\nfor i in array:\n if i > 1:\n sum += combinations_count(i, 2)\n\nfor i in a:\n tmp = sum\n if array[i] > 2:\n tmp -= (combinations_count(array[i],2) - combinations_count(array[i]-1, 2))\n elif array[i] == 2:\n tmp -= combinations_count(array[i], 2)\n elif array[i] == 1:\n tmp = tmp\n print(tmp)\n\n', 'from collections import Counter\n\nn = int(input())\na = list(map(int, input().split()))\n\nc = Counter(a)\n\ntotal = 0\nfor i in c.items():\n x = i[1]\n total += x*(x-1)//2\n\nfor i in a:\n ans = total\n ans -= (c[i] - 1)\n print(ans)\n']
['Time Limit Exceeded', 'Accepted']
['s513721736', 's743113106']
[35764.0, 26780.0]
[2109.0, 374.0]
[597, 236]
p02732
u769095634
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
['N = int(input())\nA = [int(i) for i in input().split()]\nC = [0 for i in range(N)]\nfor value in A:\n C[value - 1] += 1\nprint(C)\nways_all = 0\nfor i in range(N):\n ways_all += (C[i] * (C[i] - 1)) // 2\nprint(ways_all)\nfor value in A:\n print(ways_all - C[value - 1] + 1)', 'N = int(input())\nA = [int(i) for i in input().split()]\nC = [0 for i in range(N)]\nfor value in A:\n C[value - 1] += 1\nways_all = 0\nfor i in range(N):\n ways_all += (C[i] * (C[i] - 1)) // 2\nfor value in A:\n print(ways_all - C[value - 1] + 1)']
['Wrong Answer', 'Accepted']
['s443402788', 's233960921']
[25772.0, 25900.0]
[341.0, 332.0]
[271, 246]
p02732
u771007149
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
['import collections\nn = int(input())\na = list(map(int,input().split()))\ntmp = {}\nfor i in range(n):\n if a[i] in tmp:\n print(tmp[a[i]])\n else:\n a_copy = a[:]\n a_copy.remove(a[i])\n c = collections.Counter(a_copy)\n cnt = 0\n for i in c.values():\n cnt += i * (i-1) // 2\n \n tmp[a[i]] = cnt\n \n print(cnt)', 'from collections import Counter\nn = int(input())\na = list(map(int,input().split()))\n\nc = Counter(a)\n#print(c)\n\ns = 0\nfor i in c.values():\n s += i * (i-1) // 2\n\nfor i in range(n):\n print(s - c[a[i]] + 1)']
['Wrong Answer', 'Accepted']
['s579505478', 's873465827']
[35348.0, 34220.0]
[2105.0, 224.0]
[375, 208]
p02732
u779728630
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
['N = int(input())\nA = list(map(int, input.split()))\nL = [0 for i in range(N)]\n\ntotal = 0\n\nfor i in range(N):\n r = 0\n for j in range(N):\n if i != j and A[i] == A[j]:\n r += 1\n L[i] = r\n total += r\n\ntotal = total // 2\n\nfor i in L:\n print(total - L[i])', 'N = int(input())\nA = list(map(int, input().split()))\n\ndict = {}\n\nfor i in A:\n if i in dict:\n dict[i] = dict[i] + 1\n else:\n dict[i] = 1\n\nprint(dict)\ntotal = 0;\nfor i in dict:\n# print("i:" + str(i) + " " + str(dict[i]))\n total += dict[i]*(dict[i]-1) // 2\n\n#print("T:" + str(total))\n\nfor i in A:\n print(total - dict[i] + 1)', 'N = int(input())\nA = list(map(int, input().split()))\n\ndict = {}\n\nfor i in A:\n if i in dict:\n dict[i] = dict[i] + 1\n else:\n dict[i] = 1\n\n#print(dict)\ntotal = 0;\nfor i in dict:\n# print("i:" + str(i) + " " + str(dict[i]))\n total += dict[i]*(dict[i]-1) // 2\n\n#print("T:" + str(total))\n\nfor i in A:\n print(total - dict[i] + 1)\n']
['Runtime Error', 'Wrong Answer', 'Accepted']
['s212862320', 's537375342', 's554707956']
[3064.0, 26012.0, 25644.0]
[17.0, 411.0, 405.0]
[260, 357, 359]
p02732
u785578220
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
['n = int(input())\nA = list(map(int,input().split()))\nfrom collections import Counter\n\nc = Counter(A)\nprint(c)\ncou = 0\nfor x in c:\n if c[x]>1:\n y = c[x]\n cou+=y*(y-1)//2\n else:\n break\n\n\nfor i in A:\n X = c[i]\n ans = cou - X*(X-1)//2 + (X-1)*(X-2)//2\n print(ans)\n', 'n = int(input())\nA = list(map(int,input().split()))\nfrom collections import Counter\n\nc = Counter(A)\n# print(c)\ncou = 0\nfor x in c:\n # print(x,c[x])\n if c[x]>1:\n y = c[x]\n cou+=y*(y-1)//2\n\n\n\nfor i in A:\n X = c[i]\n ans = cou - X*(X-1)//2 + (X-1)*(X-2)//2\n print(ans)\n']
['Wrong Answer', 'Accepted']
['s666374289', 's970048359']
[36896.0, 25644.0]
[454.0, 444.0]
[295, 294]
p02732
u787131053
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
['import collections\n\ndef check(A):\n count = 0\n for j in A:\n n = A[j]\n if n > 1:\n count += n * (n - 1) / 2\n \n return int(count)\n\n\nN = int(input())\nA = list(map(int, input().split(" ")))\nA2 = collections.Counter(A)\nprint(A2)\nNsum = check(A2)\n# print(Nsum)\nfor i in range(0,N):\n num = A[i]\n count = A2[num]\n out = Nsum - ( count - 1 )\n print(out)', 'import collections\n\ndef check(A):\n count = 0\n for j in A:\n n = A[j]\n if n > 1:\n count += n * (n - 1) / 2\n \n return int(count)\n\n\nN = int(input())\nA = list(map(int, input().split(" ")))\nA2 = collections.Counter(A)\n# print(A2)\nNsum = check(A2)\n# print(Nsum)\nfor i in range(0,N):\n num = A[i]\n count = A2[num]\n out = Nsum - ( count - 1 )\n print(out)']
['Wrong Answer', 'Accepted']
['s855067964', 's362977813']
[35996.0, 26780.0]
[479.0, 347.0]
[399, 401]
p02732
u798675549
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
['def com(n):\n return n*(n-1)//2\nans=0\nn=int(input())\na=list(map(int,input().split()))\ncoun=[0]*n\nfor i in range(n):\n coun[a[i]]+=1\nfoi i in range(n):\n ans+=com(coun[i])\nfor i in range(n):\n m=com(coun[a[i]]-1)\n o=com(coun[a[i]])\n print(ans-o+m)\n ', 'import collections\nN=int(input())\nlst=input().split()\ns=0\ndic=collections.Counter(lst)\nfor i in dic.values():\n s+=(i*i-i)//2\nfor i in lst:\n print(s+1-dict[i])', 'import collections\nN=int(input())\nlst=input().split()\ns=0\ndic=collections.Counter(lst)\nfor i in dic.values():\n s+=(i*i-i)//2\nfor i in lst:\n print(s+1-dic[i])']
['Runtime Error', 'Runtime Error', 'Accepted']
['s095373137', 's974730622', 's599686368']
[2940.0, 26788.0, 26928.0]
[17.0, 103.0, 344.0]
[262, 164, 163]
p02732
u800058906
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
['import collections\n\nn=int(input())\na=list(map(int,input().split()))\n\nc=collections.Counter(a)\n\nprint(c)\n\nfor i in c.values():\n s+=i*(i-1)//2 \n\nfor j in a:\n f=c[j]\n print(s-(f-1)) \n\n\n', 'import collections\n\nn=int(input())\na=list(map(int,input().split()))\n\nc=collections.Counter(a)\n\nprint(c)\n\ns=0\n\nfor i in c.values():\n s+=i*(i-1)//2 \n\nfor j in a:\n f=c[j]\n print(s-(f-1)) \n\n', 'import collections\n\nn=int(input())\na=list(map(int,input().split()))\n\nc=collections.Counter(a)\ns=0\n\nfor i in c.values():\n s+=i*(i-1)//2 \n\nfor j in a:\n f=c[j]\n print(s-(f-1)) \n\n']
['Runtime Error', 'Wrong Answer', 'Accepted']
['s455228437', 's494947842', 's881182493']
[40896.0, 40732.0, 34108.0]
[160.0, 294.0, 227.0]
[489, 491, 482]
p02732
u801049006
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
["import math\nfrom collections import Counter\n\ndef cmb(n,r):\n if n < r:\n return 0\n else:\n math.factorial(n,r)\n\ndef main():\n N = int(input())\n A = list(map(int, input().split()))\n count = Counter(A)\n sum_ = sum([cmb(i,2) for i in count.values()])\n\n for i in range(len(A)):\n remain = A[:i] + A[i+1:]\n took_count = count[A[i]]\n sub = took_count - 1\n print(int(sum_ - sub))\n\nif __name__ == '__main__':\n main()", "import math\nfrom collections import Counter\n\ndef cmb(n,r):\n if n < r:\n return 0\n return math.factorial(n)\n\ndef main():\n N = int(input())\n A = list(map(int, input().split()))\n count = Counter(A)\n sum_ = sum([cmb(v,2) for v in count.values()])\n\n for i in range(len(A)):\n remain = A[:i] + A[i+1:]\n took_count = count[A[i]]\n sub = took_count - 1\n print(int(sum_ - sub))\n\nif __name__ == '__main__':\n main()", "import math\nfrom collections import Counter\n\ndef main():\n N = int(input())\n A = list(map(int, input().split()))\n count = Counter(A)\n sum_ = sum([math.factorial(i,2) for i in count.values()])\n\n for i in range(len(A)):\n remain = A[:i] + A[i+1:]\n took_count = count[A[i]]\n sub = took_count - 1\n print(int(sum_ - sub))\n\nif __name__ == '__main__':\n main()", "from collections import Counter\n\ndef main():\n N = int(input())\n A = list(map(int, input().split()))\n count = Counter(A)\n sum_ = sum([v*(v-1)/2 for v in count.values()])\n\n for i in range(len(A)):\n took_count = count[A[i]]\n sub = took_count - 1\n print(int(sum_ - sub))\n\nif __name__ == '__main__':\n main()"]
['Runtime Error', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s372233223', 's889050259', 's994816956', 's031485016']
[26776.0, 27120.0, 25900.0, 26780.0]
[96.0, 2105.0, 97.0, 386.0]
[469, 460, 396, 341]
p02732
u803989191
2,000
1,048,576
We have N balls. The i-th ball has an integer A_i written on it. For each k=1, 2, ..., N, solve the following problem and print the answer. * Find the number of ways to choose two distinct balls (disregarding order) from the N-1 balls other than the k-th ball so that the integers written on them are equal.
['# -*- coding: utf-8 -*-\nn = int(input())\nnumlist = list(map(int, input().split()))\ndic = {}\nfor num in numlist:\n if num not in dic:\n dic[num] = 1\n else:\n dic[num] += 1\n \nansdic = {}\nfor key in dic.keys():\n n = dic[key]\n ansdic[key] = [int(n*(n-1)/2),int((n-1)*(n-2)/2)]\n \nansdic2 = {}\nfor key in ansdic.keys():\n sum = 0\n for key2 in ansdic.keys():\n if key == key2:\n sum += ansdic[key][1]\n else:\n sum += ansdic[key][0]\n ansdic2[key] = sum \n \nfor num in numlist:\n print(ansdic2[num])', '# -*- coding: utf-8 -*-\nn = int(input())\nnumlist = list(map(int, input().split()))\ndic = {}\nfor num in numlist:\n if num not in dic:\n dic[num] = 1\n else:\n dic[num] += 1\n \ntmpsum = 0\nfor value in dic.values():\n tmpsum += int(value*(value-1)/2)\nansdic = {}\nfor key in dic.keys():\n n = dic[key]\n ansdic[key] = tmpsum - n + 1 \n \nfor num in numlist:\n print(ansdic[num])']
['Wrong Answer', 'Accepted']
['s151365368', 's451440602']
[40908.0, 34720.0]
[2105.0, 369.0]
[525, 386]