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
u195177386
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 math\nimport sys\n\nN = int(input())\nA = list(map(int, input().split()))\n\nif N == len(set(A)):\n for _ in range(N):\n print(0)\n sys.exit(0)\n\nc2 = math.factorial(2)\numemory = {}\ndmemory = {}\nmemory = {}\n\ncount = Counter(A)\n\nfor k, v in count.items():\n umemory[k] = 0 if v < 2 else math.factorial(v) // (math.factorial(v - 2) * c2)\n dmemory[k] = 0 if v < 3 else math.factorial(v-1) // (math.factorial(v - 3) * c2)\n\nfor k in range(0, N):\n a = A[k]\n print("DEBUG: ", memory)\n if a in memory:\n result = memory[a]\n else:\n memory[a] = sum(map(lambda kv: kv[1], filter(lambda kv: kv[0] != a, umemory.items())))\n memory[a] += dmemory[a]\n result = memory[a]\n print(result)', 'from collections import Collection\nimport math\n\nN = int(input())\nA = list(map(int, input().split()))\n\nc = Collection(A)\n\nall_ans = 0\nfor n in c.values():\n if n <= 1:\n continue\n all_ans += math.factorial(n)//(math.factorial(n-2)*math.factorial(2))\n\nfor n in A:\n print(all_ans - (c[n]-1))', 'from collections import Counter\nimport math\n\nN = int(input())\nA = list(map(int, input().split()))\n\nc = Counter(A)\n\nall_ans = 0\nfor n in c.values():\n if n <= 1:\n continue\n all_ans += math.factorial(n)//(math.factorial(n-2)*math.factorial(2))\n\nfor n in A:\n print(all_ans - (c[n]-1))']
['Wrong Answer', 'Runtime Error', 'Accepted']
['s724169722', 's992892894', 's869824133']
[38972.0, 3316.0, 26780.0]
[2105.0, 20.0, 1698.0]
[758, 302, 296]
p02732
u197457087
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\nN = int(input())\nA = list(map(int, input().split()))\nans = 0\n\nC = list(set(A))\nM = len(C)\nt = []\nanst = 0\nfor i in range(M):\n t.append(A.count(C[i]))\n temp = A.count(C[i])\n if temp >=2:\n anst += math.factorial(temp)/(math.factorial(temp-2)*2)\n\n#print(t)\n#print(anst)\n\nfor i in range(N):\n print(t[C.index(A[i])])\n print(int(anst-t[C.index(A[i])]+1))', 'import math\n\nN = int(input())\nA = list(map(int, input().split()))\nans = 0\n\nC = list(set(A))\nM = len(C)\nt = []\nanst = 0\ndic = {}\nfor i in A:\n if not i in dic:\n dic[i] = 0\n dic[i] += 1\n\njisyo = {}\nfor i in range(M):\n temp = dic[C[i]]\n jisyo[C[i]] = temp\n #t.append(A.count(C[i]))\n if temp >=2:\n anst += temp*(temp-1)/2\n\n\n\nfor i in range(N):\n #print(t[C.index(A[i])])\n print(int(anst-jisyo[A[i]]+1))']
['Wrong Answer', 'Accepted']
['s560275483', 's604441026']
[26140.0, 32956.0]
[2104.0, 469.0]
[385, 450]
p02732
u197922478
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 = 8#int(input())\n#A = list(map(int, input().split()))\nA = [1, 2, 1, 4, 2, 1, 4, 1]\n\nc = collections.Counter(A)\n#print(c)\n\ncount_dic = {}\nfor i in c.keys():\n count = 0\n c_copy = c.copy()\n c_copy[i] = c[i]-1\n #print(c_copy)\n for k in c.keys():\n count += int(c_copy[k]*(c_copy[k]-1)/2)\n count_dic[i] = count\n #print(count)\n #print(count_dic)\n\nfor i in range(N):\n print(count_dic[A[i]])', 'from collections import Counter\nimport numpy as np\n \nN = int(input())\nA = np.array(list(map(int, input().split())))\nA_set = np.unique(A)\ncount_dict= Counter(A)\ncount_sum = np.sum([count_dict[i]*(count_dict[i]-1)/2 for i in A_set])\n \nfor i in A:\n print(int(count_sum-count_dict[i]+1))']
['Wrong Answer', 'Accepted']
['s968185839', 's112761357']
[3316.0, 34148.0]
[21.0, 1171.0]
[446, 289]
p02732
u197968862
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 scipy.misc import comb\n\nn = int(input())\na = list(map(int,input().split()))\nfor i in range(n):\n l = a[i]\n a[i] = ''\n ans = 0\n a_s = set(a)\n for j in a_s:\n c = a.count(j)\n ans += comb(c,2,exact=True)\n print(ans)\n a[i] = l", "from scipy.misc import comb\n\nn = int(input())\na = list(map(int,input().split()))\na_s = set(a)\nfor i in range(n):\n l = a[i]\n a[i] = 'X'\n ans = 0\n for j in a_s:\n ans += comb(a.count(j),2)\n print(int(ans))\n a[i] = l", "from scipy.misc import comb\n\nn = int(input())\na = list(map(int,input().split()))\na_s = set(a)\nfor i in range(n):\n l = a[i]\n a[i] = 'X'\n ans = 0\n for j in a_s:\n ans += comb(a.count(j),2,exact=True)\n print(ans)\n a[i] = l", "from scipy.misc import comb\n\nn = int(input())\na = list(map(int,input().split()))\nfor i in range(n):\n l = a[i]\n a[i] = 'X'\n ans = 0\n a_s = set(a)\n for j in a_s:\n c = a.count(j)\n if c < 2:\n continue\n ans += comb(c,2,exact=True)\n print(ans)\n a[i] = l", "from scipy.misc import comb\n\nn = int(input())\na = list(map(int,input().split()))\nfor i in range(n):\n l = a[i]\n a[i] = 'X'\n ans = 0\n a_s = set(a)\n for j in a_s:\n ans += comb(a.count(j),2,exact=True)\n print(ans)\n a[i] = l\n", 'from collections import Counter\nn = int(input())\na = list(map(int,input().split()))\n\nc = Counter(a)\nkey = c.keys()\ncomb = 0\nfor i in key:\n comb += (c[i]) * (c[i]-1) // 2\n\nfor i in a:\n ans = comb - (c[i]-1)\n print(ans)']
['Time Limit Exceeded', 'Wrong Answer', 'Time Limit Exceeded', 'Time Limit Exceeded', 'Time Limit Exceeded', 'Accepted']
['s081216138', 's157938198', 's559054860', 's772977612', 's892667806', 's738784835']
[36560.0, 36572.0, 36572.0, 36624.0, 36444.0, 25900.0]
[2109.0, 2109.0, 2109.0, 2110.0, 2109.0, 344.0]
[260, 237, 243, 300, 248, 226]
p02732
u199830845
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 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())\nA_list = list(map(int, input().split()))\n\ndivided = []\nfor i in range(N):\n divided.append(A_list.count(i + 1))\n\nans = 0\nfor j in divided:\n ans += combinations_count(j, 2)\n\n# print(divided)\n\nfor k in range(1, N + 1):\n n = divided[A_list[k - 1] - 1]\n # print(n)\n ans_k = ans\n if n > 1:\n ans_k -= n - 1', 'import math\ndef combinations_count(n, r):\n return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))\n\nN = int(input())\nA_list = list(map(int, input().split()))\n\ndivided = []\nfor i in range(N):\n divided.append(A_list.count(i + 1))\n\nans = 0\nfor j in divided:\n ans += combinations_count(j, 2)\n\n# print(divided)\n\nfor k in range(1, N + 1):\n n = divided[A_list[k - 1] - 1]\n # print(n)\n ans_k = ans\n if n > 1:\n ans_k -= n - 1\n\n print(int(ans_k))', 'import collections\n\n\n# return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))\n\nN = int(input())\nA_list = list(map(int, input().split()))\n\ncounts = collections.Counter(A_list)\nans = 0\nfor _, v in counts.items():\n ans += v * (v - 1) / 2\n\nfor k in range(1, N + 1):\n n = counts[A_list[k - 1]]\n ans_k = ans\n if n > 1:\n ans_k -= n - 1\n\n print(int(ans_k))']
['Wrong Answer', 'Runtime Error', 'Accepted']
['s127858712', 's528493090', 's634061243']
[27020.0, 26140.0, 26772.0]
[2104.0, 2104.0, 439.0]
[567, 483, 422]
p02732
u201387466
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\ninput=sys.stdin.readline\nN = int(input())\nA = list(map(int,input().split()))\nnCr = {}\ndef cmb(n):\n if n == 1:\n return 0\n else:\n return n * n-1 /2\nmydict = {}\nfor i in range(N):\n a = A[i]\n if a in mydict.keys():\n mydict[a] += 1\n else:\n mydict[a] = 1\ns = 0\nfor i in range(N):\n a = A[i]\n s += cmb(a)\nfor i in range(N):\n a = A[i]\n x = mydict[a] - 1\n print(s-x)', 'import sys\ninput=sys.stdin.readline\nN = int(input())\nA = list(map(int,input().split()))\nnCr = {}\ndef cmb(n):\n if n == 1:\n return 0\n else:\n return n * n-1 /2\nmydict = {}\nfor i in range(N):\n a = A[i]\n if a in mydict.keys():\n mydict[a] += 1\n else:\n mydict[a] = 1\nfor i in range(N):\n s = 0\n a = A[i]\n mydict[a] -= 1\n for j in mydict.values():\n s += cmb(j)\n print(s)\n mydict[a] += 1', 'import sys\ninput=sys.stdin.readline\nN = int(input())\nA = list(map(int,input().split()))\ndef cmb(n):\n if n == 1:\n return 0\n else:\n return n * (n-1) /2\nmydict = {}\nfor i in range(N):\n a = A[i]\n if a in mydict.keys():\n mydict[a] += 1\n else:\n mydict[a] = 1\ns = 0\nfor i in mydict.values():\n\ts += cmb(i)\nfor i in range(N):\n a = A[i]\n x = mydict[a] - 1\n print(int(s-x))']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s474144042', 's782124550', 's866938754']
[25696.0, 24988.0, 24988.0]
[673.0, 2105.0, 444.0]
[425, 445, 414]
p02732
u207137484
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()))\ndi = {}\nfor i in range(n):\n\tk = list[i]\n\tif k not in di:\n\t\tdi[k]=1\n\telse:\n\t\tdi[k]+=1\nlist_del=[]\nfor key in di.keys():\n\tif di[key]==1:\n\t\tlist_del.append(key)\nfor i in range(len(list_del)):\n\tdi.pop(list_del[i])\n\t\n\t\nsu=0\nfor valu in di.values():\n\tsu += valu*(valu-1)/2\n\t\nfor i in range(n):\n\tk = list[i]\n\tif k in si:\n\t\tl = di[k]\n\t\tsu_ch = su\n\t\tsu_ch -= l*(l-1)/2\n\t\tsu_ch += (l-1)*(l-2)/2\n\t\tprint(int(su_ch))\n\telse:\n\t\tprint(su)\n', 'n = int(input())\nlist = list(map(int,input().split()))\ndi = {}\nfor i in range(n):\n\tk = list[i]\n\tif k not in di:\n\t\tdi[k]=1\n\telse:\n\t\tdi[k]+=1\n"""\nlist_del=[]\nfor key in di.keys():\n\tif di[key]==1:\n\t\tlist_del.append(key)\nfor i in range(len(list_del)):\n\tdi.pop(list_del[i])\n"""\n\t\nsu=0\nfor valu in di.values():\n\tsu += valu*(valu-1)/2\n\t\nfor i in range(n):\n\tk = list[i]\n\tl = di[k]\n\tsu_ch = su\n\tsu_ch -= l*(l-1)/2\n\tsu_ch += (l-1)*(l-2)/2\n\tprint(int(su_ch))\n\t']
['Runtime Error', 'Accepted']
['s151961351', 's022176089']
[26140.0, 26140.0]
[198.0, 481.0]
[479, 449]
p02732
u207326980
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 = input().split()\nfreq = Counter(a)\nprint(freq)\ntotal=0\n \nfor key,val in freq.items():\n total+=(val*(val-1))//2\n\nfor k in range(n): \n\n kth = (freq[a[k]]*(freq[a[k]]-1))//2\n newkth = ((freq[a[k]]-2)*(freq[a[k]]-1))//2 \n\n total -= kth\n total += newkth\n \n print(total)\n \n total -=newkth\n total +=kth', 'from collections import Counter\n\nn = int(input())\na = input().split()\nfreq = Counter(a)\nprint(freq)\ntotal = []\n\n\n\nfor k in range(n): \n freq[a[k]]-=1\n total=0\n \n for key,val in freq.items():\n total+=(val*(val-1))//2\n \n freq[a[k]]+=1\n \n print(total)', 'from collections import Counter\n\nn = int(input())\na = input().split()\nfreq = Counter(a)\n#print(freq)\ntotal=0\n \nfor key,val in freq.items():\n total+=(val*(val-1))//2\n\nfor k in range(n): \n\n kth = (freq[a[k]]*(freq[a[k]]-1))//2\n newkth = ((freq[a[k]]-2)*(freq[a[k]]-1))//2 \n\n total -= kth\n total += newkth\n \n print(total)\n \n total -=newkth\n total +=kth']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s828686117', 's958767750', 's547681645']
[40792.0, 40776.0, 26660.0]
[700.0, 2105.0, 540.0]
[382, 282, 383]
p02732
u209299893
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\nimport math\nimport scipy.special import comb\n\ndef combinations_count(n, r):\n return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))\n\nn = int(input())\nnums = [ int(s) for s in input().split() ]\n\n\nfor i in range(n):\n ans = 0\n\n cpl = copy.copy(nums)\n cpl.pop(i)\n ct = collections.Counter(cpl)\n\n for key, val in ct.items():\n if val > 1:\n ans += comb(val, 2, exact=True)\n \n print(ans)\n', 'import collections\nimport copy\nimport math\nimport scipy.misc import comb\n\ndef combinations_count(n, r):\n return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))\n\nn = int(input())\nnums = [ int(s) for s in input().split() ]\n\n\nfor i in range(n):\n ans = 0\n\n cpl = copy.copy(nums)\n cpl.pop(i)\n ct = collections.Counter(cpl)\n\n for key, val in ct.items():\n if val > 1:\n ans += comb(val, 2, exact=True)\n \n print(ans)\n', 'import collections\nimport copy\nimport math\nfrom scipy.misc import comb\n\ndef combinations_count(n, r):\n return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))\n\nn = int(input())\nnums = [ int(s) for s in input().split() ]\n\n\nfor i in range(n):\n ans = 0\n\n cpl = copy.copy(nums)\n cpl.pop(i)\n ct = collections.Counter(cpl)\n\n for key, val in ct.items():\n if val > 1:\n ans += comb(val, 2, exact=True)\n \n print(ans)\n', '\n\n\nn = int(input())\nlst = list(map(int, input().split()))\n\n# counter\nfrom collections import Counter\ncntr = Counter(lst)\n\n# combination\nimport math\ndef combinations_count(n, r):\n return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))\n\ntotal = 0\n# countSameNames\nfor value in cntr.values():\n if value > 1:\n total += combinations_count( value, 2 )\n\n\nfor l in lst:\n print(total - (cntr[l]-1))']
['Runtime Error', 'Runtime Error', 'Time Limit Exceeded', 'Accepted']
['s295905820', 's623970273', 's937330189', 's702850699']
[2940.0, 2940.0, 43784.0, 26268.0]
[17.0, 19.0, 2110.0, 1680.0]
[470, 467, 465, 422]
p02732
u212328220
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())\nal = list(map(int, input().split()))\nC = Counter(al)\n# print(C)\n# print(C.values())\nans = 0\nfor i in C.values():\n ans += i * (i - 1) / 2\n\nfor a in al:\n k = C[a]\n print(ans - (k * (k - 1) / 2) + (k - 1) * (k - 2) / 2)\n', 'import math\nfrom collections import Counter\nimport itertools\nn = int(input())\nal = list(map(int,input().split()))\nC_al = Counter(al)\n\nall = 0\nfor i in C_al.values():\n all += i*(i-1)/2\n\nfor i in al:\n k = C_al[i]\n print(int(all - (k * (k - 1) / 2) + (k - 1) * (k - 2) / 2))\n \n\n\n']
['Wrong Answer', 'Accepted']
['s030206391', 's925199882']
[26772.0, 33920.0]
[454.0, 278.0]
[276, 288]
p02732
u214344212
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\nx=int(input())\na=list(map(int,input().split()))\n\nc=collections.Counter(a)\nnum=0\nfor i in c.values():\n num+=i*(i-1)/2\n \nfor i in range(x):\n print(num-c[a[i]]+1)', 'import collections\n\nx=int(input())\na=list(map(int,input().split()))\n\nc=collections.Counter(a)\nnum=0\nfor i in c.values():\n num+=i*(i-1)/2\n \nfor i in range(x):\n print(int(num-c[a[i]]+1))']
['Wrong Answer', 'Accepted']
['s784354194', 's955399637']
[25960.0, 26780.0]
[453.0, 406.0]
[188, 193]
p02732
u217627525
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=list(map(int,input().split()))\n cnt=[0]*n\n for i in range(n):\n cnt[a[i]-1]+=1\n res=0\n for i in range(n):\n if cnt[i]>1:\n res+=cnt[i]*(cnt[i]-1)//2\n ans=[0]*n\n for i in range(n):\n if cnt[i]>=1:\n ans[i]=res-(cnt[i]-1)\n print(cnt)\n print(ans)\n for i in range(n):\n print(ans[a[i]-1])\n \nif __name__=="__main__":\n main()', 'def main():\n n=int(input())\n a=list(map(int,input().split()))\n cnt=[0]*n\n for i in range(n):\n cnt[a[i]-1]+=1\n res=0\n for i in range(n):\n if cnt[i]>1:\n res+=cnt[i]*(cnt[i]-1)//2\n ans=[0]*n\n for i in range(n):\n if cnt[i]>=1:\n ans[i]=res-(cnt[i]-1)\n for i in range(n):\n print(ans[a[i]-1])\n \nif __name__=="__main__":\n main()']
['Wrong Answer', 'Accepted']
['s018261888', 's526288057']
[26140.0, 26140.0]
[352.0, 307.0]
[437, 407]
p02732
u221149873
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 = (int(input()))\nitems = list(map(int,input().split()))\nfor i in range(len(items)): \n rest = items[:i] + items[i+1:]\n rest_unique = list(set(rest))\n out = 0\n for j in rest_unique:\n cnt = sum([1 for x in rest if x == j])\n if cnt < 2:\n out = out\n else:\n out = out + math.factorial(cnt)/math.factorial(cnt-2)/2\n print(out)', 'import math\ninput()\nitems = list(map(int,input().split()))\nd = {}\nfor i in items:\n if i in d.keys():\n d[i] = d[i]+1\n else:\n d[i] = 1\n\np = {}\nfor k in d.keys():\n cnt = d[k]\n p[k] = (cnt*(cnt-1))/2\n\ntotal = sum(p.values())\n\nfor item in items:\n print(int(total - d[item] + 1))']
['Wrong Answer', 'Accepted']
['s372801907', 's444946144']
[26140.0, 33664.0]
[2105.0, 433.0]
[394, 302]
p02732
u221272125
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())\nd = {}\nfor i in range(1,N+1):\n d[i] = 0\nA = list(map(int,input().split()))\nfor i in range(N):\n a = A[i]\n d[a] += 1\ns = 0\nfor i in range(1,N+1):\n x = d[a]\n s += (x*(x-1))//2\nfor i in range(N):\n y = A[i]\n z = s + 1 - d[y]\n print(z)', 'N = int(input())\nd = {}\nfor i in range(1,N+1):\n d[i] = 0\nA = list(map(int,input().split()))\nfor i in range(N):\n a = A[i]\n d[a] += 1\ns = 0\nfor i in range(1,N+1):\n x = d[i]\n s += (x*(x-1))//2\nfor i in range(N):\n y = A[i]\n z = s + 1 - d[y]\n print(z)']
['Wrong Answer', 'Accepted']
['s440651808', 's127135510']
[43612.0, 44384.0]
[418.0, 423.0]
[270, 270]
p02732
u222668979
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()))\nnum = [0] * n\ncnt = 0\n\nfor i in a:\n num[i - 1] += 1\n\nfor i in num:\n cnt += i * (i - 1)//2\n\nfor i in range(n):\n tmp = num[a[i]-1]\n ans = cnt - ((tmp-(tmp-2)) * (tmp-1) // 2)\n ans += ((tmp-2) * (tmp-1) // 2)\n print(ans)\n', 'n = int(input())\na = list(map(int, input().split()))\nnum = [0] * n\ncnt = 0\n\nfor i in a:\n num[i - 1] += 1\n\nfor i in num:\n cnt += i * (i - 1)//2\n\nfor i in range(n):\n tmp = num[a[i]-1]\n ans = cnt - (tmp-1)\n print(ans)\n']
['Wrong Answer', 'Accepted']
['s354364679', 's224741691']
[26268.0, 26140.0]
[417.0, 352.0]
[289, 230]
p02732
u225627575
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\n\nc = collections.Counter(A)\nkeys = c.keys()\nans_dict = {}\nans_dict2 = {}\nfor key in keys:\n ans_dict[key] = cmb(c[key]-1,2)\n ans_dict2[key] = cmb(c[key],2)\n\nSUM = sum(ans_dict2.values())\n\n# print(ans_dict)\n# print(ans_dict2)\n\nfor key in A:\n print(SUM-ans_dict2[key]+ans_dict[key])', 'def cmb(n, r):\n if r > n: return 0\n if n - r < r: r = n - r\n if r == 0: return 1\n if r == 1: return n\n\n numerator = [n - r + k + 1 for k in range(r)]\n denominator = [k + 1 for k in range(r)]\n\n for p in range(2,r+1):\n pivot = denominator[p - 1]\n if pivot > 1:\n offset = (n - r) % p\n for k in range(p-1,r,p):\n numerator[k - offset] /= pivot\n denominator[k] /= pivot\n\n result = 1\n for k in range(r):\n if numerator[k] > 1:\n result *= int(numerator[k])\n\n return result\n\nN = int(input())\nA = list(map(int,input().split()))\nimport collections\n\nc = collections.Counter(A)\nkeys = c.keys()\nans_dict = {}\nans_dict2 = {}\nfor key in keys:\n ans_dict[key] = cmb(c[key]-1,2)\n ans_dict2[key] = cmb(c[key],2)\n\nSUM = sum(ans_dict2.values())\n\n# print(ans_dict)\n# print(ans_dict2)\n\nfor key in A:\n print(SUM-ans_dict2[key]+ans_dict[key])']
['Runtime Error', 'Accepted']
['s366000473', 's823853703']
[26268.0, 39508.0]
[97.0, 458.0]
[360, 939]
p02732
u228303592
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())\narr = list(map(int,input().split()))\ncnt = collectioms.Counter(arr)\ntotal = 0\n\nfor key in cnt.keys():\n total += cnt[key] * (cnt[key] - 1)//2\n \nfor i in range(n):\n tmp = total\n tmp -= cnt[arr[i]]*(cnt[arr[i]] - 1)//2\n tmp += (cnt[arr[i]] - 1)*(cnt[arr[i]] - 2)//2\n print(tmp)', 'import collections\n\nn = int(input())\narr = list(map(int,input().split()))\ncnt = collections.Counter(arr)\ntotal = 0\n\nfor key in cnt.keys():\n total += cnt[key] * (cnt[key] - 1)//2\n \nfor i in range(n):\n tmp = total\n tmp -= cnt[arr[i]]*(cnt[arr[i]] - 1)//2\n tmp += (cnt[arr[i]] - 1)*(cnt[arr[i]] - 2)//2\n print(tmp)\n']
['Runtime Error', 'Accepted']
['s526474296', 's749434989']
[34116.0, 34076.0]
[72.0, 323.0]
[317, 318]
p02732
u229429359
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 = input().split()\n\nL = [0 for i in range(N)]\n\nfor i in range(N):\n L[int(A[i])-1] +=1\n\nc = 0\nfor i in range(N):\n n = L[i]\n if n >= 2:\n c += factorial(n) // factorial(2) // factorial(n - 2)\n\nfor i in range(N):\n n = L[A[i]-1]\n if n >= 2:\n print(c - n + 1)\n else:\n print(c)', 'from math import factorial\n\nN = int(input())\nA = input().split()\n\nL = [0 for i in range(N)]\n\nfor i in range(N):\n L[int(A[i])-1] +=1\n\nc = 0\nfor i in range(N):\n n = L[i]\n if n >= 2:\n c += factorial(n) // factorial(2) // factorial(n - 2)\n\nfor i in range(N):\n n = L[int(A[i])-1]\n if n >= 2:\n print(c - n + 1)\n else:\n print(c)']
['Runtime Error', 'Accepted']
['s571290966', 's040048839']
[18724.0, 22444.0]
[129.0, 1799.0]
[305, 338]
p02732
u236885379
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())\n*li,=map(int, input().split())\nfrom collections import Counter\nc = Counter()\nfor i in li:\n c[i] += 1\nans=0\nfrom math import comb\nfor i in c.values():\n ans += comb(i, 2)\nfor i in li:\n print(ans - comb(c[i], 2) + comb(c[i-1], 2))\n ', 'def f():\n n = int(input())\n *li,=map(int, input().split())\n from collections import Counter\n c = Counter()\n for i in li:\n c[i] += 1\n ans=0\n from math import comb\n for i in c.values():\n ans += comb(i, 2)\n for i in li:\n print(ans - comb(c[i], 2) + comb(c[i]-1, 2))\nf()\n ']
['Wrong Answer', 'Accepted']
['s728993036', 's407095322']
[32264.0, 32212.0]
[325.0, 271.0]
[256, 287]
p02732
u239528020
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.
['#!/usr/bin/env python3\n\nimport collections\n\nN = int(input())\nA = list(map(int, input().split()))\n\nc = collections.Counter(A)\nvalues = c.keys()\ncounts = c.values()\n\n\nans = 0\nfor i in range(len(values)):\n tmp = counts[i]\n ans += (tmp * (tmp-1))//2\n\nfor i in range(N):\n num = A[i]\n index = values.index(num)\n print(ans - counts[index] + 1)\n', '#!/usr/bin/env python3\n\nimport collections\n\nN = int(input())\nA = list(map(int, input().split()))\n\nc = collections.Counter(A)\nvalues, counts = c.keys(), c.values()\n\nans = 0\nfor i in range(len(values)):\n tmp = counts[i]\n ans += (tmp * (tmp-1))//2\n\nfor i in range(N):\n num = A[i]\n index = values.index(num)\n print(ans - counts[index] + 1)\n', '#!/usr/bin/env python3\n\nimport collections\n\nN = int(input())\nA = list(map(int, input().split()))\n\nc = collections.Counter(A)\nvalues = c.keys()\ncounts = c.values()\n\nsubs = {}\na_sum = 0\nfor v, c in zip(values, counts):\n subs[v] = c\n a_sum += (c * (c-1)) // 2\n\nfor i in range(N):\n print(a_sum - subs[A[i]] + 1)\n']
['Runtime Error', 'Runtime Error', 'Accepted']
['s275678538', 's933722124', 's301281902']
[26772.0, 26772.0, 32156.0]
[94.0, 98.0, 377.0]
[352, 351, 317]
p02732
u239653493
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 math\nn=int(input())\nA = list(map(int, input().split()))\nres=[0]*n\nimport collections\ndef com(n, r):\n if n<r:\n return 0\n else:\n return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))\nfor i in range(n):\n ac=copy.deepcopy(A)\n del ac[i]\n ak=collections.Counter(ac)\n aj=list( ak.values() )\n s=0\n for j in range(len(aj)):\n s=s+com(aj[j],2)\n res[i]=s\nprint(' '.join(map(str,res)))\n ", 'import math\nn=int(input())\nA = list(map(int, input().split()))\nres=[0]*n\nimport collections\ndef com(n, r):\n if n<r:\n return 0\n else:\n return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))\n\naf=collections.Counter(A)\nres2=list(af.items())\nres3=[0]*n\ns=0\nfor i in range(0,len(res2)):\n s=s+com(res2[i][1],2)\nfor j in range(0,len(res2)):\n res3[res2[j][0]-1]=s+(1/2)*(res2[j][1]-1)*(res2[j][1]-1)-(1/2)*(res2[j][1])*(res2[j][1])\nfor i in range(n):\n res[i]=res3[A[i]-1]\n\nfor j in range(n):\n print(res[j])', 'import math\nn=int(input())\nA = list(map(int, input().split()))\nres=[0]*n\nimport collections\ndef com(n, r):\n if n<r:\n return 0\n else:\n return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))\n\naf=collections.Counter(A)\nres2=list(af.items())\nres3=[0]*n\ns=0\nfor i in range(0,len(res2)):\n s=s+com(res2[i][1],2)\nfor j in range(0,len(res2)):\n res3[res2[j][0]-1]=s-res2[j][1]+1\nfor i in range(n):\n res[i]=res3[A[i]-1]\n\nfor j in range(n):\n print(res[j])\n']
['Time Limit Exceeded', 'Wrong Answer', 'Accepted']
['s081937984', 's734413288', 's871673878']
[40112.0, 34636.0, 35248.0]
[2105.0, 1854.0, 1685.0]
[462, 547, 493]
p02732
u240096083
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\nfrom pprint import pprint\nfrom scipy.misc import comb\n\nn = int(input())\n\na_list = list(map(int,input().split()))\n\na_dict = defaultdict(int)\n\nfor i in a_list:\n a_dict[i] += 1\n\n#pprint(a_dict)\n\n\n\n\n\n\ntotal = 0\n\n\nfor j in a_dict.values():\n total += comb(j,2)\n\nfor k in a_list:\n print(int(total - (a_dict[k]-1) + 1))', 'from collections import defaultdict\nfrom pprint import pprint\nfrom scipy.misc import comb\n\nn = int(input())\n\na_list = list(map(int,input().split()))\n\na_dict = defaultdict(int)\n\nfor i in a_list:\n a_dict[i] += 1\n\n#pprint(a_dict)\n\n\n\n\n\n\ntotal = 0\n\n\nfor j in a_dict.values():\n if j != 1:\n total += comb(j,2)\n\nfor k in a_list:\n print(int(total - (a_dict[k]-1)))', 'from collections import defaultdict\nfrom pprint import pprint\nfrom scipy.misc import comb\n\nn = int(input())\n\na_list = list(map(int,input().split()))\n\na_dict = defaultdict(int)\n\nfor i in a_list:\n a_dict[i] += 1\n\n#pprint(a_dict)\n\n\n\n\n\n\ntotal = 0\n\n\nfor j in a_dict.values():\n total += comb(j,2)\n\nfor k in a_list:\n print(int(total - (a_dict[k]-1)))', 'from collections import defaultdict\nfrom pprint import pprint\n#from scipy.special import comb\n\nn = int(input())\n\na_list = list(map(int,input().split()))\n\na_dict = defaultdict(int)\n\nfor i in a_list:\n a_dict[i] += 1\n\n#pprint(a_dict)\n\n\n\n\n\n\ntotal = 0\n\n\nfor j in a_dict.values():\n total += j*(j-1)/2\n\nfor k in a_list:\n print(int(total - (a_dict[k]-1)))']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s093368136', 's606432246', 's619703169', 's089021027']
[37244.0, 35628.0, 35712.0, 26504.0]
[2109.0, 2109.0, 2112.0, 418.0]
[732, 747, 728, 732]
p02732
u241159583
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, 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\nN = int(input())\nA = list(map(int, input().split()))\n\na = list(set(A))\na_n = []\nc = []\nnew = []\nif len(a) != N:\n for i in range(len(a)):\n x = A.count(a[i])\n a_n.append(x)\n c.append(cmb(x,2, mod))\n if x >= 2: new.append(cmb(x-1,2, mod))\n else: new.append(0)\n\n ans = sum(c)\n for i in range(N):\n n = a.index(A[i])\n print(ans-c[n]+new[n])\nelse:\n for _ in range(N):\n print(0)', 'N = int(input())\nA = list(map(int, input().split()))\n\na = list(set(A))\na_n = []\nc = []\nif len(a) != N:\n for i in range(len(a)):\n x = A.count(a[i])\n a_n.append(x)\n c.append(x*(x-1)//2)\n\n ans = sum(c)\n print(c)\n for i in range(N):\n n = a.index(A[i])\n new = (a_n[n]-1)*(a_n[n]-2)//2\n print(ans-c[n]+new)\nelse:\n for _ in range(N):\n print(0)', 'from collections import Counter\nn = int(input())\nA = list(map(int, input().split()))\na = {}\nANS = 0\nfor x,y in Counter(A).items():\n if y >= 2: \n a[x] = [y, (y*(y-1))//2]\n ANS += (y*(y-1))//2\nfor i in range(n):\n ans = ANS\n if A[i] in a:\n x = a[A[i]][0]-1\n ans -= a[A[i]][1]\n ans += (x*(x-1))//2\n print(ans)']
['Runtime Error', 'Wrong Answer', 'Accepted']
['s124954809', 's593352717', 's845532264']
[26164.0, 26140.0, 34036.0]
[2104.0, 2104.0, 289.0]
[856, 362, 352]
p02732
u242196904
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\n\nc = Counter(a)\n\nfrom scipy.misc import comb\n\ns = set(c.values())\n\ndic = {}\nfor ss in s:\n if ss not in dic.keys():\n dic[ss] = comb(ss, 2)\nfor ss in s:\n ss -= 1\n if ss not in dic.keys():\n dic[ss] = comb(ss, 2)\n\nbase = 0\nfor k in c.keys():\n base += dic[c[k]]\n\nfor k in range(len(a)):\n print(int(base - dic[c[a[k]]] + dic[c[a[k]] - 1]))\n', 'n = int(input())\na = list(map(int, input().split()))\n\nfrom collections import Counter\n\nc = Counter(a)\n\ndef comb(x):\n return x * (x - 1) // 2\n\nbase = 0\nfor aa in c.keys():\n x = c[aa]\n base += comb(x)\n\nfor aa in a:\n ans = base - comb(c[aa]) + comb(c[aa] - 1)\n print(ans)']
['Wrong Answer', 'Accepted']
['s935267153', 's152940936']
[29264.0, 25716.0]
[1001.0, 497.0]
[449, 283]
p02732
u243312682
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\nimport sys\ninput = sys.stdin.readline\n\ndef main():\n n = int(input())\n A = [int(x) for x in input().split()]\n a_c= Counter(A)\n values = a_c.values()\n val_cnt = Counter(values\n for a in A:\n val_cnt_c = deepcopy(val_cnt)\n val_cnt_c[a_c[a]] -= 1\n val_cnt_c[a_c[a]-1] += 1\n cnt = {int(k*(k-1)/2*v) if k > 1 else 0 for k, v in val_cnt_c.items()}\n print(sum(cnt))\n \nif __name__ == '__main__':\n main()", "from collections import Counter\n \ndef main():\n n = int(input())\n A = [int(x) for x in input().split()]\n a_c = Counter(A)\n res = [int(v*(v-1)/2) for v in a_c.values()]\n cnt = sum(res)\n for a in A:\n ans = (cnt - (a_c[a]-1))\n print(ans)\n \nif __name__ == '__main__':\n main()"]
['Runtime Error', 'Accepted']
['s031714281', 's808873473']
[9028.0, 34116.0]
[25.0, 210.0]
[510, 305]
p02732
u244416763
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()))\nc = [0 for _ in range(n)]\nr = []\nfor i in range(n):\n c[a[i-1]-1] += 1\nfor i in range(n):\n r.append(c[i-1])\nkai = []\nv = []\nfor i in range(len(r)):\n kai.append((r[i]*(r[i]-1)//2))\n v.append(kai[i] - max(((r[i]-1)*(r[i]-2)//2),0))\n\nans = sum(kai)\nfor i in range(len(v)):\n for j in range(v[i]+1):\n print(ans - v[i])', 'n = int(input())\na = list(map(int,input().split()))\nc = [0 for _ in range(n+1)]\nr = []\nfor i in range(n):\n c[a[i-1]-1] += 1\nfor i in range(n):\n r.append(c[i])\nkai = []\nv = []\nfor i in range(len(r)):\n kai.append((r[i]*(r[i]-1)//2))\n v.append(kai[i] - max(((r[i]-1)*(r[i]-2)//2),0))\n\nans = sum(kai)\nfor i in range(len(a)):\n print(ans - v[a[i]-1])']
['Wrong Answer', 'Accepted']
['s870571696', 's656229332']
[26140.0, 26140.0]
[545.0, 501.0]
[399, 372]
p02732
u245299791
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()))\nkeys=[]\nvalues=[]\nfor i in A:\n if i in keys:\n pass\n else:\n counts=A.count(i)\n keys.append(i)\n values.append(counts)\nans=0\nfor j in values:\n ans+=j*(j-1)/2\nfor k in A:\n a=keys.index(k)\n print(ans-values[a]+1)', 'N=int(input())\nA=list(map(int,input().split()))\ndic={}\nfor i in A:\n if i not in dic.keys():\n dic.update({i:1})\n else:\n dic[i]+=1\nans=sum([int(j*(j-1)/2) for j in dic.values()])\nfor k in A:\n num=dic[k]\n if num>=1:\n print(int(ans-num+1))\n else:\n print(ans)']
['Wrong Answer', 'Accepted']
['s655856510', 's946332178']
[25644.0, 24748.0]
[2104.0, 415.0]
[272, 271]
p02732
u250583425
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 collections import Counter\ndef input(): return sys.stdin.readline().rstrip()\n\ndef main():\n N = int(input())\n A = tuple(map(int, input().split()))\n c = Counter(A)\n\n sum_count = sum([v * (v - 1) // 2 for v in c.values()])\n for i, v in c.items():\n if v < 2:\n continue\n value = v * (v - 1) // 2\n print(sum_count - value + value * (v - 2) // v)\n\nif __name__ == '__main__':\n main()\n", "import sys\nfrom collections import Counter\ndef input(): return sys.stdin.readline().rstrip()\n\ndef main():\n N = int(input())\n A = tuple(map(int, input().split()))\n c = Counter(A)\n\n data = [0] * (N+1)\n sum_count = 0\n for i, v in c.items():\n if v < 2:\n continue\n value = v * (v - 1) // 2\n data[i] = value - value * (v - 2) // v\n sum_count += value\n\n print('\\n'.join([str(sum_count - data[a]) for a in A]))\n\nif __name__ == '__main__':\n main()\n"]
['Wrong Answer', 'Accepted']
['s343266795', 's986186820']
[27028.0, 32952.0]
[165.0, 178.0]
[442, 502]
p02732
u257265865
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)\ncount=0\nfor i in range(1,N+1):\n a=B["i"]\n count+=(a*(a-1))/2\n\n \nfor i in range(1,N+1):\n a=B["i"]\n print(int(count-(a*(a-1))/2))', 'import collections\nN=int(input())\nA=list(map(int,input().split()))\nB=collections.Counter(A)\ncount=0\nfor i in range(1,N+1):\n a=B[i]\n count+=(a*(a-1))/2\nfor i in A:\n a=B[i]\n print(int((count-(a*(a-1))/2)+(a-1)*(a-2)/2))']
['Wrong Answer', 'Accepted']
['s074472640', 's092866709']
[26780.0, 26780.0]
[473.0, 507.0]
[224, 221]
p02732
u266675845
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())\nA = []\nA = [int(i) for i in input().split()]\n\nnumber_set = list(set(A))\n#print("number set is :", number_set) \n \nfor k in range(n):\n out = 0\n ans = []\n ans += A[0:k]\n ans += A[k+1:n]\n #print(ans)\n for i in range(len(number_set)):\n #print(ans.count(number_set[i]))\n out += ans.count(number_set[i]) * (ans.count(number_set[i]-1)) //2\n \n print(out) ', 'import collections\nN = int(input())\nli = list(map(int, input().split()))\ncn = collections.Counter(li)\nsumC = sum([n*(n-1)//2 for n in cn.values()])\nfor k in range(N):\n print(sumC - (cn[li[k]]-1))']
['Wrong Answer', 'Accepted']
['s243223153', 's674761747']
[25764.0, 26780.0]
[2105.0, 334.0]
[415, 198]
p02732
u268554510
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 H,W,K = map(int,input().split())\n import numpy as np\n from collections import deque\n ans = 10000\n S = np.array([list(map(int,list(input()))) for _ in range(H)])\n cum = [[0]*W for _ in range(H+1)]\n for j in range(W):\n for i in range(1,H+1):\n cum[i][j] = cum[i-1][j]+S[i-1][j]\n\n cum = np.array(cum)\n for i in range(2**(H-1)):\n q = deque([0])\n for h in range(H):\n if (i>>h)&1:\n q.append(h+1)\n q.append(H)\n p = deque()\n judge = False\n for a in range(len(q)-1):\n x = cum[q[a+1]]-cum[q[a]]\n if (x>K).any():\n judge = True\n break\n else:\n p.append(x)\n\n if judge:\n continue\n\n t_a = len(q)-2\n l = [0]*len(p)\n for w in range(W):\n for x,a in enumerate(p):\n l[x]+=a[w]\n if l[x]>K:\n t_a+=1\n l = [0]*len(p)\n for z,b in enumerate(p):\n l[z] = b[w]\n break\n ans = min(ans,t_a)\n\n print(ans)\n \nmain()', 'N = int(input())\nA = list(map(int,input().split()))\nA_set = list(set(A))\nl = [0]*(N+2)\nans = [0]*(N+2)\nfor a in A:\n l[a]+=1\ncomb = [0]*(N+2)\nfor i in range(2,N+1):\n comb[i] = i*(i-1)//2\n \nfor i in range(2,N+1):\n ans[i]=comb[i]-comb[i-1]\n \ntotal = 0\nfor a in A_set:\n total += comb[l[a]]\n\nfor a in A:\n print(int(total-ans[l[a]]))']
['Runtime Error', 'Accepted']
['s607051464', 's197240809']
[3444.0, 32080.0]
[21.0, 436.0]
[962, 334]
p02732
u274841648
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())\ns = [int(i) for i in input().split()]\n\ns_set = set(s)\n\ncounted = Counter(s)\nans = sum(i*(i-1)/2 for i in counted.values())\nprint(ans)\n\nfor i in s:\n x = counted[i]\n print(int(ans - x + 1))', 'from collections import Counter\nn = int(input())\ns = [int(i) for i in input().split()]\n\ns_set = set(s)\n\ncounted = Counter(s)\nans = sum(i*(i-1)/2 for i in counted.values())\n\nfor i in s:\n x = counted[i]\n print(int(ans - x + 1))']
['Wrong Answer', 'Accepted']
['s972711693', 's473904987']
[28704.0, 29388.0]
[440.0, 418.0]
[242, 231]
p02732
u277104886
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())\na = list(map(int, input().split()))\nb = set(a)\n\ndef choose2(x):\n return int(x*(x-1)/2)\n \ntotal = 0\nfor i in b:\n total += choose2(a.count(i))\n\nfor i in a:\n print(total - choose2(s[i]) + choose2(s[i]-1))', '\nn = int(input())\na = list(map(int, input().split()))\n\nfrom collections import Counter\ncount = Counter(a)\n\ndef choose2(x):\n return int(x*(x-1)/2)\n \ntotal = 0\nfor i in list(count.values()):\n total += choose2(i)\n\nfor i in a:\n s = count[i]\n print(total - choose2(s) + choose2(s-1))']
['Runtime Error', 'Accepted']
['s220774709', 's589322605']
[32252.0, 32288.0]
[2206.0, 310.0]
[231, 293]
p02732
u279266699
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()))\ndif = [0] * n\nsum_c = 0\nfor i, v in collections.Counter(a).items():\n if v < 2:\n continue\n val = v * (v - 1) // 2\n dif[i] = 2 * (v - 1) // 2\n sum_c += val\nprint('\\n'.join([int(sum_c - data[i]) for i in a])", "import collections\nn = int(input())\na = list(map(int, input().split()))\ndif = [0] * n\nsum = 0\nfor i, v in collections.Counter(a).items():\n if v < 2:\n continue\n val = v * (v - 1) // 2\n dif[i] = 2 * (v - 1) // 2\n sum += val\nprint('\\n'.join([int(sum - data[i]) for i in a])", "import collections\nn = int(input())\na = list(map(int, input().split()))\ndif = [0] * n\nsum_c = 0\nc = collections.Counter(a)\nfor i, v in c.items():\n if v < 2:\n continue\n val = v * (v - 1) // 2\n dif[i] = 2 * (v - 1) // 2\n sum_c += val\nprint('\\n'.join([int(sum_c - data[i]) for i in a])\n", "import collections\nn = int(input())\na = list(map(int, input().split()))\ndif = [0] * n\nsum = 0\nfor i, v in collections.Counter(a).items():\n if v < 2:\n continue\n val = v * (v - 1) // 2\n dif[i] = 2 * (v - 1) // 2\n sum += val\nprint('\\n'.join([int(sum_count - data[i]) for i in a])", "from collections import Counter\n\nn = int(input())\na = list(map(int, input().split()))\ndif = [0] * n\nsum_c = 0\nc = Counter(a)\nfor i, v in c.items():\n if v < 2:\n continue\n val = v * (v - 1) / 2\n dif[i] = v - 1\n sum_c += val\nprint('\\n'.join([int(sum_c - data[i]) for i in a])", 'from collections import Counter\n\n\ndef main():\n n = int(input())\n A = list(map(int, input().split()))\n a_c = Counter(A)\n a_s = list(set(A))\n tot = 0\n for a in a_s:\n tot += a_c[a] * (a_c[a] - 1) // 2\n ans = list(map(lambda x: tot - (a_c[x] - 1), a_s))\n ans_dic = dict(zip(a_s, ans))\n for a in A:\n print(ans_dic[a])\n\n\nif __name__ == "__main__":\n main()']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s254885830', 's358421717', 's520479268', 's817810767', 's838050639', 's136833647']
[3060.0, 3064.0, 2940.0, 3060.0, 3060.0, 38488.0]
[17.0, 17.0, 17.0, 17.0, 17.0, 304.0]
[295, 289, 302, 295, 291, 393]
p02732
u279292103
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()))\nc = Counter(a)\nvalues, counts = zip(*c.most_common())\nvalues, counts = list(values), list(counts)\nk = 0\nfor i in range(len(counts)):\n k += counts[i]*(counts[i]-1)//2\noutput = [0]*len(a)\nfor i in range(len(a)):\n temp = c[a[i]]\n if temp == 1:\n output[i] = k\n else:\n output[i] = k-temp*(temp-1)//2+(temp-1)*(temp-2)//2\nprint(output)', 'from collections import Counter\nn = int(input())\na = list(map(int, input().split()))\nc = Counter(a)\nvalues, counts = zip(*c.most_common())\nvalues, counts = list(values), list(counts)\nk = 0\nfor i in range(len(counts)):\n k += counts[i]*(counts[i]-1)//2\noutput = [0]*len(a)\nfor i in range(len(a)):\n temp = c[a[i]]\n if temp == 1:\n output[i] = k\n else:\n output[i] = k-temp*(temp-1)//2+(temp-1)*(temp-2)//2\n print(output[i])']
['Wrong Answer', 'Accepted']
['s089742310', 's225305820']
[36892.0, 37024.0]
[381.0, 573.0]
[424, 429]
p02732
u281610856
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, deque, Counter\nimport sys\ninput = sys.stdin.readline\n\n\ndef main():\n n = int(input())\n A = list(map(int, input().split()))\n dd = defaultdict(int)\n ans = []\n for i in A:\n dd[i] += 1\n for i in range(n):\n ng = A[i]\n dd[ng] -= 1\n cnt = 0\n for key, val in dd.items():\n cnt += val * (val-1) // 2\n ans.append(cnt)\n dd[ng] += 1\n print(*ans, sep='\\n')", "from collections import defaultdict, deque, Counter\nimport sys\ninput = sys.stdin.readline\n\n\ndef main():\n n = int(input())\n A = list(map(int, input().split()))\n cnt = Counter(A)\n cnt_common = cnt.most_common()\n ans = 0\n for i in range(len(cnt_common)):\n num, val = cnt_common[i]\n ans += val * (val - 1) // 2\n for i in A:\n c = cnt[i]\n print(ans - c * (c - 1) // 2 + (c-1) * (c-2) // 2 )\n\nif __name__ == '__main__':\n main()"]
['Wrong Answer', 'Accepted']
['s085313924', 's138887377']
[3316.0, 29808.0]
[21.0, 417.0]
[459, 472]
p02732
u281796054
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())\nS=list(map(int,input().split()))\nset_S=list(set(S))\nans_stock={}\nnumber={}\nfor i in set_S:\n number[i] = S.count(i)\ncomb = 0\nfor i in set_S:\n comb += number[i]*(number[i]-1)/2\n\nfor i in S:\n if i in list(ans_stock.keys()):\n print(ans_stock[i])\n else:\n ans = comb - number[i]*(number[i]-1)/2 + (number[i]-1)*(number[i]-2)/2\n print(ans)\n ans_stock[i]=ans', 'n=int(input())\nS=list(map(int,input().split()))\nfor i in S:\n print(len(S)-S.count(i)+1)', 'from collections import Counter\nn=int(input())\nS=list(map(int,input().split()))\nnumber=Counter(S)\ncomb=0\nstock={}\nfor i in list(number.values()):\n comb += i*(i-1)/2\nfor i in S:\n ans = int(comb - number[i]*(number[i]-1)/2 + (number[i]-1)*(number[i]-2)/2)\n print(ans)\n']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s369672688', 's773202334', 's644706116']
[26140.0, 24996.0, 25896.0]
[2104.0, 2108.0, 508.0]
[383, 88, 269]
p02732
u283605799
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\ntable = set(a)\n\ncon = {}\ndic = {}\nans = []\n\ncon = Counter(a)\ndic = {}\n\n# con[i] = a.count(i)\n\n\nfor x in a:\n if dic[x] == None:\n ex = (con[x] - 1) * (con[x] - 2) / 2\n no = (con[x]) * (con[x] - 1) / 2\n dic[x] = (int(no), int(ex))\n\nsu = sum([int(x[0]) for x in dic.values()])\n\nfor i,x in enumerate(a):\n print(su - (dic[x][0] - dic[x][1]))\n', 'from collections import Counter\n\nn = int(input())\na = list(map(int,input().split()))\n\nc = Counter(a)\ndic = {}\n\nfor x in a:\n if x not in dic:\n ex = (c[x] - 1) * (c[x] - 2) / 2\n no = (c[x]) * (c[x] - 1) / 2\n dic[x] = (int(no), int(ex))\n\nsu = sum([int(x[0]) for x in dic.values()])\n\nfor i,x in enumerate(a):\n print(su - (dic[x][0] - dic[x][1]))']
['Runtime Error', 'Accepted']
['s440552026', 's319951107']
[28732.0, 35256.0]
[113.0, 579.0]
[484, 368]
p02732
u289162337
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()]\nt = set(L)\ndn = {}\ndc = {}\nAll = 0\nfor i in L:\n dn[i] += 1\nfor i in t:\n dc[i] = int(dn[i]*(dn[i]-1)/2)\n All += dc[i]\nfor i in range(n):\n print(All-dc[L[i]] + int((dn[L[i]]-1)*(dn[L[i]]-2)/2))', 'n = int(input())\nL = [int(i) for i in input().split()]\nt = set(L)\ndn = {}\ndc = {}\nAll = 0\nfor i in t:\n dn[i] = L.count(i)\n dc[i] = int(dn[i]*(dn[i]-1)/2)\n All += dc[i]\nfor i in range(n):\n print(All-dc[L[i]] + int((dn[L[i]-1]-1)*(dn[L[i]-2])/2))', 'n = int(input())\nL = [int(i) for i in input().split()]\nt = set(L)\ndn = {}\ndc = {}\nAll = 0\nfor i in t:\n dn[i] = 0\nfor i in L:\n dn[i] += 1\nfor i in t:\n dc[i] = int(dn[i]*(dn[i]-1)/2)\n All += dc[i]\nfor i in range(n):\n print(All-dc[L[i]] + int((dn[L[i]]-1)*(dn[L[i]]-2)/2))']
['Runtime Error', 'Runtime Error', 'Accepted']
['s170039205', 's871182105', 's354746712']
[24748.0, 25764.0, 38152.0]
[97.0, 2104.0, 541.0]
[250, 248, 274]
p02732
u289288647
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 math import factorial\n\nN = int(input())\nindex = list(map(int, input().split()))\nval = [0]*max(index)\nfor i in index:\n val[i-1] += 1\ntotal = 0\nfor i in val:\n if i >= 2:\n total += comb(i, 2, exact=True)\nfor i in index:\n if val[i-1] >= 2:\n print(total-(comb(val[i-1], 2, exact=True)-comb(val[i-1]-1, 2, exact=True)))\n else:\n print(total)\n', 'from scipy.special import comb\n\nN = int(input())\nindex = list(map(int, input().split()))\nval = [0]*max(index)\nfor i in index:\n val[i-1] += 1\ntotal = 0\nfor i in val:\n if i >= 2:\n total += comb(i, 2, exact=True)\nfor i in index:\n if val[i-1] >= 2:\n print(total-(comb(val[i-1], 2, exact=True)-comb(val[i-1]-1, 2, exact=True)))\n else:\n print(total)\n']
['Runtime Error', 'Accepted']
['s418251006', 's418685127']
[32324.0, 65988.0]
[99.0, 453.0]
[373, 377]
p02732
u290886932
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()))\nwlists = collections.Counter(A)\nprint(wlists)\nprint(wlists[1])\nprint(wlists[2])\nsum_num = 0\nfor i in wlists:\n sum_num += wlists[i] * (wlists[i] - 1) // 2\nprint("num_sum:{}".format(sum_num))\nfor i in range(N):\n num = sum_num - wlists[A[i]] * (wlists[A[i]] - 1) // 2\n if wlists[A[i]] > 1:\n num += (wlists[A[i]] - 1) * (wlists[A[i]] - 2) // 2\n print(num)', 'import collections\nN = int(input())\nA = list(map(int, input().split()))\nwlists = collections.Counter(A)\nsum_num = 0\nfor i in wlists:\n sum_num += wlists[i] * (wlists[i] - 1) // 2\nfor i in range(N):\n num = sum_num - wlists[A[i]] * (wlists[A[i]] - 1) // 2\n if wlists[A[i]] > 1:\n num += (wlists[A[i]] - 1) * (wlists[A[i]] - 2) // 2\n print(num)']
['Wrong Answer', 'Accepted']
['s888709344', 's120081869']
[35896.0, 26780.0]
[632.0, 549.0]
[430, 346]
p02732
u291988695
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())\nAs=list(map(int,input().split()))\nls=collections.Counter(As)\nsubd={}\nan=ls.values()\nfor k in l:\n ans+=k*(k-1)//2\nsans=ans\n\nfor i in As:\n ans=sans+1-ls[i]\n print(ans)\n', 'import collections\n\nn=int(input())\nAs=list(map(int,input().split()))\nls=collections.Counter(As)\nsubd={}\nan=ls.values()\nans=0\nfor k in an:\n ans+=k*(k-1)//2\nsans=ans\n\nfor i in As:\n ans=sans+1-ls[i]\n print(ans)']
['Runtime Error', 'Accepted']
['s314297412', 's417184652']
[26780.0, 26780.0]
[97.0, 369.0]
[204, 210]
p02732
u303739137
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.
['input()\naa = list(map(int, input().split()))\nuu = list(set(aa))\ncc = uu.copy()\nfor i in range(len(uu)):\n cc[i] = aa.count(uu[i])\n total += cc[i] * (cc[i]-1) / 2\n\ndic = dict(zip(uu,cc))\n\nfor a in aa:\n print(int(total - dic[a] + 1))', 'input()\nfrom collections import Counter\naa = list(map(int, input().split()))\ndic = Counter(aa)\n\ntotal = 0\nfor v in dic.values():\n total += v * (v-1) / 2\n\nfor a in aa:\n print(int(total - dic[a] + 1))']
['Runtime Error', 'Accepted']
['s374044320', 's059565955']
[26012.0, 26780.0]
[94.0, 411.0]
[239, 204]
p02732
u306516971
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\nsetA = set(A)\nan = 0\nfor num in B:\n d = A.count(num)\n an += d*(d-1)//2\n\nfor i in range(n):\n ans = an\n t = A[i]\n e = A.count(A[i])\n ans -= e*(e-1)//2\n ans += (e-1)*(e-2)//2\n print(ans)', 'n = int(input())\n\nli = list(map(int, input().split()))\n\nans = [0]*n\nfor i in range(n):\n li2 = li\n del li2[i]\n for j in range(n-1):\n for k in range(j+1, n-1):\n if li2[j] == li2[k]:\n ans[i] += 1\nfor l in range(len(ans)):\n print(ans[l])\n \n', 'N=int(input())\nK=list(map(int, input().split()))\nfrom collections import Counter\nans = 0\nfor i in range(N):\n ans += i*(i-1)//2\nC = Counter(K)\nfor a in K:\n e = C[a]\n print(ans-a*(a-1)//2+(a-1)*(a-2)//2)', 'N=int(input())\nK=list(map(int, input().split()))\nfrom collections import Counter\nans = 0\nC = Counter(K)\nfor k, v in C.items():\n ans += v*(v-1)//2\n\nfor a in K:\n e = C[a]\n print(ans-e*(e-1)//2+(e-1)*(e-2)//2)']
['Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s129111414', 's791905994', 's863228159', 's880736096']
[26268.0, 26268.0, 24748.0, 26268.0]
[88.0, 2104.0, 470.0, 414.0]
[261, 281, 210, 215]
p02732
u306950978
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())\nc=list(map(int,input().split()))\n\ns = Counter(c)\nt = list(s.items())\n\nnag = len(t)\nx = 0\nrt = [0 for i in range(nag)]\nprint(s)\n\nfor i in range(nag):\n x += (t[i][1]*(t[i][1]-1))//2\nfor f in range(nag):\n rt[f] = x - (t[f][1] -1)\n \nfor j in range(n):\n for k in range(nag):\n if c[j] == t[k][0]:\n print(rt[k])\n break\n', 'from collections import Counter\n\nn = int(input())\nc = list(map(int,input().split()))\ns = Counter(c)\nt = list(s.items())\nnag = len(t)\nx = 0\nans = 0\n\nfor i in range(nag):\n x += (t[i][1]*(t[i][1]-1))//2\n \nfor j in range(n):\n ans = x - s[c[j]] + 1 \n print(ans)']
['Wrong Answer', 'Accepted']
['s045245771', 's704209160']
[46000.0, 28336.0]
[2109.0, 408.0]
[401, 268]
p02732
u312078744
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#from scipy.special import comb\n# a = comb(n, r)\n# >> cannot use in Contest (like AtCoder)\n\n\ndef cmb(n, r):\n if n - r < r:\n r = n - r\n if r == 0:\n return 1\n if r == 1:\n return n\n\n numerator = [n - r + k + 1 for k in range(r)]\n denominator = [k + 1 for k in range(r)]\n\n for p in range(2, r+1):\n pivot = denominator[p - 1]\n if pivot > 1:\n offset = (n - r) % p\n for k in range(p-1, r, p):\n numerator[k - offset] /= pivot\n denominator[k] /= pivot\n\n result = 1\n for k in range(r):\n if numerator[k] > 1:\n result *= int(numerator[k])\n\n return result\n\n\nN = int(input())\ndata = list(map(int, input().split()))\ncount = Counter(data)\n#print(count) > Counter({1: 4, 2: 2, 4: 2})\ncountMost = count.most_common()\n\nlis = [0] * (2 * 10 ** 5)\ntot = 0\nfor i, v in countMost:\n #print(i, v)\n lis[i - 1] = v\n tot += cmb(v, 2)\n\nfor i, v in enumerate(data):\n num = lis[v-1]\n ans = tot - cmb(num - 1, 2)\n\n print(ans)\n'''\ndataSort = data.sort()\nprint(countMost)\nprint(len(countMost))\n'''\n", "from collections import Counter\n#from scipy.special import comb\n# a = comb(n, r)\n# >> cannot use in Contest (like AtCoder)\n\n\ndef cmb(n, r):\n if n - r < r:\n r = n - r\n if r == 0:\n return 1\n if r == 1:\n return n\n if n <= 1:\n return 0\n\n numerator = [n - r + k + 1 for k in range(r)]\n denominator = [k + 1 for k in range(r)]\n\n for p in range(2, r+1):\n pivot = denominator[p - 1]\n if pivot > 1:\n offset = (n - r) % p\n for k in range(p-1, r, p):\n numerator[k - offset] /= pivot\n denominator[k] /= pivot\n\n result = 1\n for k in range(r):\n if numerator[k] > 1:\n result *= int(numerator[k])\n\n return result\n\n\nN = int(input())\ndata = list(map(int, input().split()))\ncount = Counter(data)\n#print(count) > Counter({1: 4, 2: 2, 4: 2})\ncountMost = count.most_common()\n\nlis = [0] * (2 * 10 ** 5)\ncombination = [0] * (2 * 10 ** 5)\ntot = 0\nfor i, v in countMost:\n #print(i, v)\n lis[i - 1] = v\n val = cmb(v, 2)\n tot += val\n combination[i - 1] = val\n\n# print(lis[0])\nfor i, v in enumerate(data):\n num = lis[v - 1]\n if (num == 2):\n # print('a')\n ans = tot - 1\n else:\n ans = tot - combination[v-1] + cmb(num-1, 2)\n\n print(ans)\n'''\ndataSort = data.sort()\nprint(countMost)\nprint(len(countMost))\n'''\n"]
['Wrong Answer', 'Accepted']
['s434539736', 's619641781']
[30124.0, 31516.0]
[1297.0, 1370.0]
[1163, 1386]
p02732
u312237545
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_int():\n\treturn int(input())\n\ndef get_ints():\n\treturn list(map(int, input().split()))\n\n\n\ndef choose2(n):\n return n*(n-1)/2\n \n\nN = get_int()\nAn = get_ints()\n\nuni = [0] * (N+1)\n\nfor i in range(N):\n uni[An[i]] += 1\nsumWay = 0\n\nfor i in range(N):\n sumWay += choose2(uni[i])\n\nfor i in range(N):\n print(sumWay - choose2(uni[An[i]]) + choose2(uni[An[i]]-1)) \n', 'def get_int():\n\treturn int(input())\n\ndef get_ints():\n\treturn list(map(int, input().split()))\n\ndef choose2(n):\n return n*(n-1)/2\n\nN = get_int()\nAn = get_ints()\n\nuni = [0] * (N)\n\nfor i in range(N):\n uni[An[i]] += 1\nsumWay = 0\n\nfor i in range(N):\n sumWay += choose2(uni[i])\n\nfor i in range(N):\n print(sumWay - choose2(uni[An[i]]) + choose2(uni[An[i]]-1)) \n# 4 - 3 + 1\n', '\ndef get_int():\n\treturn int(input())\n\ndef get_ints():\n\treturn list(map(int, input().split()))\n\nimport math\n\ndef choose2(n):\n return math.floor(n*(n-1)/2)\n\n\nN = get_int()\nAn = get_ints()\n\nuni = [0] * (N+1)\n\nfor i in range(N):\n uni[An[i]] += 1\nsumWay = 0\n\nfor i in range(N+1):\n sumWay += choose2(uni[i])\n\nfor i in range(N):\n print(sumWay - choose2(uni[An[i]]) + choose2(uni[An[i]]-1)) ']
['Wrong Answer', 'Runtime Error', 'Accepted']
['s064369476', 's542645556', 's256697253']
[32324.0, 32292.0, 32312.0]
[316.0, 310.0, 338.0]
[760, 684, 814]
p02732
u313370702
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\n\nimport collections\nimport copy\n\n\nN = int(input())\n\n\nA = list(map(str, input().split()))\n\nprint(A)\nfor _N in range(N):\n A2 = copy.copy(A)\n del A2[_N]\n c = collections.Counter(A2)\n ans = 0\n for v in c.values():\n if v >= 2:\n ans += int(((v * (v - 1)) / 2))\n print(ans)\n', '# coding: utf-8\n\nimport collections\nimport copy\n\n\nN = int(input())\n\n\nA = list(map(str, input().split()))\n\nc = collections.Counter(A)\nnodel = 0\n\nfor cv in c.values():\n if cv >= 2:\n nodel += int((cv * (cv-1))/2)\n\nfor a in A:\n ans = copy.copy(nodel)\n if c.get(a) >= 3:\n ans = ans - int((c.get(a)*(c.get(a)-1))/2) + int(((c.get(a)-1)*(c.get(a)-2))/2)\n elif c.get(a) == 2:\n ans -= 1\n print(ans)']
['Wrong Answer', 'Accepted']
['s787595947', 's281181907']
[43688.0, 28896.0]
[2105.0, 594.0]
[344, 450]
p02732
u314089899
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(10000000000000)\n\nfrom operator import mul\nfrom functools import reduce\nfrom functools import lru_cache\n\nN = int(input())\nA_list = [int(e) for e in input().split()]\n\n\nnumber_dict = dict()\n\nfor i in range(N):\n ball_number = A_list[i]\n if ball_number not in number_dict:\n number_dict[ball_number] = 0\n \n number_dict[ball_number] += 1\n\n\ncomb_dict = dict()\n\n@lru_cache(maxsize=10000000000000)\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 \n@lru_cache(maxsize=10000000000000)\ndef two_choice(N):\n if N == 2:\n return 1\n elif N <= 1:\n return 0\n elif N == 3:\n return 3\n else:\n return combinations_count(N,2)*combinations_count(N-2,2)\n\nall = 0\n\nfor in_dict in number_dict.items():\n ball_number = in_dict[0]\n balls = in_dict[1]\n comb_dict[ball_number] = two_choice(balls)\n all += comb_dict[ball_number]\n\n\nfor i in range(1,N+1):\n ball_number = A_list[i-1]\n now_balls = number_dict[ball_number] - 1\n print(int(all-comb_dict[ball_number]+two_choice(now_balls)))', 'import sys\nsys.setrecursionlimit(1000000000)\n\nfrom operator import mul\nfrom functools import reduce\nfrom functools import lru_cache\n\nN = int(input())\nA_list = [int(e) for e in input().split()]\n\n\nnumber_dict = dict()\n\nfor i in range(N):\n ball_number = A_list[i]\n if ball_number not in number_dict:\n number_dict[ball_number] = 0\n \n number_dict[ball_number] += 1\n\n\ncomb_dict = dict()\n\n@lru_cache(maxsize=10000000000000)\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 \n@lru_cache(maxsize=10000000000000)\ndef two_choice(N):\n if N == 2:\n return 1\n elif N <= 1:\n return 0\n elif N == 3:\n return 3\n else:\n return combinations_count(N,2)\n\nall = 0\n\nfor in_dict in number_dict.items():\n ball_number = in_dict[0]\n balls = in_dict[1]\n comb_dict[ball_number] = two_choice(balls)\n all += comb_dict[ball_number]\n\n\nfor i in range(1,N+1):\n ball_number = A_list[i-1]\n now_balls = number_dict[ball_number] - 1\n print(int(all-comb_dict[ball_number]+two_choice(now_balls)))']
['Runtime Error', 'Accepted']
['s375824454', 's177936696']
[3064.0, 31888.0]
[19.0, 1117.0]
[1351, 1321]
p02732
u316733945
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 = []\ntotal = 0\n\nm = max(a)\n\nfor i in range(1, m+1):\n if a.count(i):\n total += (a.count(i)*(a.count(i)-1))/2\n l.append(a.count(i))\n\nprint(l)\nprint(total)\n\nfor k in range(n):\n score = total\n if l[a[k]-1]:\n score -= (l[a[k]-1]-1)\n print(int(score))\n', 'from collections import Counter\n\nn = int(input())\na = list(map(int, input().split()))\ntotal = 0\n\nc = Counter(a)\n\nfor r in list(c.values()):\n total += (r*(r-1))/2\n\n#print(l)\n#print(total)\n\nfor i in a:\n score = total - (c[i]-1)\n print(int(score))\n']
['Wrong Answer', 'Accepted']
['s739795035', 's250523728']
[26140.0, 26780.0]
[2104.0, 380.0]
[330, 254]
p02732
u319311571
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(' ')))\nc = [0] * (n + 1)\nd = [0] * (n + 1)\nfor i in a:\n c[i] += 1\n d[i] = c[i] * (c[i] - 1) // 2\nfor i in a:\n if c[i] > 2:\n r = (((c[i] - 1) * (c[i] - 2)) // 2)\n else:\n r = 0\n print(d[i] + r)", "n = int(input())\na = list(map(int, input().split(' ')))\nc = [0] * (n + 1)\nd = [0] * (n + 1)\nfor i in a:\n c[i] += 1\n d[i] = c[i] * (c[i] - 1) // 2\nt = sum(d)\nfor i in a:\n if c[i] > 2:\n r = (((c[i] - 1) * (c[i] - 2)) // 2)\n else:\n r = 0\n print(t - d[i] + r)"]
['Wrong Answer', 'Accepted']
['s899151406', 's660051074']
[24872.0, 25716.0]
[375.0, 381.0]
[269, 284]
p02732
u323531048
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\ninp = [input() for i in range(2)]\nN = int(inp[0])\nA = list(map(int, inp[1].split()))\n# B = 0\nd = {}\nfor k in A:\n # a = A.count(k)\n # B += (a - 1) / 2\n if k in d.keys():\n d[i] += 1\n\n# for k in range(N):\n# c = A.count(A[k]) - 1\n# counter = B - c\n# print(int(counter))\n\np = {}\nfor k in d.keys():\n cnt = d[k]\n p[k] = cnt * (cnt-1) / 2\n\ntotal = sum(p.values())\n\nfor item in A:\n print(int(total - d[item] + 1))', 'import math\ninp = [input() for i in range(2)]\nN = int(inp[0])\nA = list(map(int, inp[1].split()))\n# B = 0\nd = {}\nfor k in A:\n # a = A.count(k)\n # B += (a - 1) / 2\n if k in d.keys():\n d[k] += 1\n else:\n d[k] = 1\n\n# for k in range(N):\n# c = A.count(A[k]) - 1\n# counter = B - c\n# print(int(counter))\n\np = {}\nfor k in d.keys():\n cnt = d[k]\n p[k] = cnt * (cnt-1) / 2\n\ntotal = sum(p.values())\n\nfor item in A:\n print(int(total - d[item] + 1))']
['Runtime Error', 'Accepted']
['s125973209', 's726055094']
[26816.0, 35084.0]
[89.0, 427.0]
[453, 480]
p02732
u324197506
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.
['\nimport sys\ninput = sys.stdin.readline\n\nn = int(input())\n\nballs = list(map(int, input().split()))\n\ncnt = {}\n\nfor ball in balls:\n if ball not in cnt:\n cnt[ball] = 0\n cnt[ball] += 1\n\ndef combination(nxt, num = 0):\n return (cnt[nxt]-num) * (cnt[nxt]-1- num) // 2\n\ntotal = 0\nfor nxt in cnt:\n total += combination(nxt)\n\nprint(total)\n\nfor ball in balls:\n ans = total - combination(ball) + combination(ball,1)\n print(ans)', '\nimport sys\ninput = sys.stdin.readline\n\nn = int(input())\n\nballs = list(map(int, input().split()))\n\ncnt = {}\n\nfor ball in balls:\n if ball not in cnt:\n cnt[ball] = 0\n cnt[ball] += 1\n\ndef combination(nxt, num = 0):\n return (cnt[nxt]-num) * (cnt[nxt]-1- num) // 2\n\ntotal = 0\nfor nxt in cnt:\n total += combination(nxt)\n\n\nfor ball in balls:\n ans = total - combination(ball) + combination(ball,1)\n print(ans)']
['Wrong Answer', 'Accepted']
['s453683894', 's025802920']
[25916.0, 25912.0]
[545.0, 483.0]
[468, 455]
p02732
u331226975
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_set = list(set(A))\n\nAd = {a_set:A.count(a_set) for a_set in A_set}\n\nscore_sum = sum([x*(x-1)/2 for x in list(Ad.values())]\n\nfor a in A:\n print(int(score_sum - (Ad[a] - 1)))\n', 'import collections\n\nN = int(input())\nA = list(map(int, input().split()))\n\nAd = dict(collections.Counter(A))\n# A_set = list(set(A))\n# Ad = {a_set:A.count(a_set) for a_set in A_set}\n# Ad = {}\n\n# if not i in Ad:\n# Ad[i]=0\n# Ad[i] += 1\n\nscore_sum = sum([x*(x-1)/2 for x in list(Ad.values())])\n\nfor a in A:\n print(int(score_sum - (Ad[a] - 1)))\n']
['Runtime Error', 'Accepted']
['s211491722', 's312716047']
[2940.0, 26780.0]
[17.0, 337.0]
[231, 363]
p02732
u332800105
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(s) for s in input().split()]\nfor i in range(0,n):\n print(a.count(a[i])-1)', 'n=int(input())\na=[int(s) for s in input().split()]\nd={}\nfor i in range(0,n):\n if a[i] not in d:\n d[a[i]]=1\n else:\n d[a[i]]+=1 \nfor i in range(0,n):\n print(d[a[i]]-1)', 'n=int(input())\na=[int(s) for s in input().split()]\nd={}\nfor i in range(0,n):\n if a[i] not in d:\n d[a[i]]=1\n else:\n d[a[i]]+=1 \nd1={}\ns=0\nfor i in range(0,n):\n if a[i] not in d1:\n d1[a[i]]=(d[a[i]]*(d[a[i]]-1))//2\n s+=d1[a[i]]\nfor i in range(0,n):\n print(s-d[a[i]]+1)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s249084131', 's576658897', 's020021417']
[25768.0, 26268.0, 32008.0]
[2104.0, 311.0, 460.0]
[98, 188, 306]
p02732
u336564899
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\nmod = pow(10,9)+7\n\n\nmemo = {}\ndef combination(n, a, mod):\n\n if (n,a) in memo:\n return memo[(n,a)]\n\n x = 1\n y = 1\n for i in range(a):\n x = x * (n-i)%mod\n y = y * (a-i)%mod\n\n ans = x * pow(y, mod-2, mod)%mod\n\n memo[(n, a)] = ans\n return ans\n\nif __name__ == '__main__':\n\n n = int(input())\n a = list(map(int, input().split()))\n\n c = collections.Counter(a)\n\n all_cnt = 0 \n a_cnt = []\n\n\n for i in range(n):\n for item in c.items():\n cnt = combination(item[1],2,mod)\n all_cnt += cnt\n a_cnt.append(cnt - combination(item[1]-1,2,mod))\n\n for i in range(n):\n ans = all_cnt - a_cnt[i]\n print(ans)\n", "import collections\n\nif __name__ == '__main__':\n\n n = int(input())\n a = list(map(int, input().split()))\n\n c = collections.Counter(a)\n\n all = 0\n before = []\n after = []\n\n for i in range(n):\n for item in c.items():\n cnt = item[1]*(item[1]-1)//2\n all += cnt\n before.append(item[1]*(item[1]-1)//2)\n after.append((item[1]-1)*(item[1]-2)//2)\n\n for i in range(n):\n ans = all - before[i] + after[i]\n print(ans)\n", "import collections\n\nif __name__ == '__main__':\n\n n = int(input())\n a = list(map(int, input().split()))\n\n c = collections.Counter(a)\n\n all = 0\n\n for item in c.items():\n all += item[1] * (item[1] - 1) //2\n\n for i in range(n):\n item = c[a[i]]\n after = item * (item-1) // 2\n before = (item-1) * (item-2) // 2\n #print(after, before)\n ans = all - after + before\n print(ans)\n"]
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s098757121', 's835657874', 's197573360']
[39200.0, 66352.0, 26780.0]
[2106.0, 2107.0, 437.0]
[771, 491, 435]
p02732
u337751290
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 main():\n N = int(input())\n A = list(map(int, input().split()))\n\n # print(N)\n # print(A)\n\n for i in range(N):\n result = 0\n for j in range(N):\n if A[i] == A[j]:\n result += 1\n print(result)\n\n\n\n\nif __name__ == '__main__':\n main()", "\ndef main():\n N = int(input())\n A = list(map(int, input().split()))\n\n print(N)\n print(A)\n\n for i in range(N):\n result = 0\n for j in range(N):\n if A[i] == A[j]:\n result += 1\n print(result)\n\n\n\n\nif __name__ == '__main__':\n main()", "\ndef main():\n N = int(input())\n A = list(map(int, input().split()))\n\n # print(N)\n # print(A)\n d = {i:0 for i in range(1,N+1)}\n d2 = {}\n d3 = {}\n # print(d)\n # return\n\n\n for i in A:\n d[i] += 1\n\n # print(d)\n sum = 0\n for i in range(1,N+1):\n d2[i] = int(d[i] * (d[i]-1) / 2)\n sum += d2[i]\n\n # print(d2)\n\n for i in range(1, N+1):\n if d[i] == 0: d3[i] = 0\n else: d3[i] = int((d[i]-1) * (d[i]-2) / 2)\n\n # print(d3)\n\n\n for i in A:\n print(sum - d2[i] + d3[i])\n\nif __name__ == '__main__':\n main()"]
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s716497234', 's892564128', 's682799882']
[24748.0, 26268.0, 82040.0]
[2104.0, 2104.0, 494.0]
[295, 291, 583]
p02732
u339503988
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] * 100000\nfor i in A:\n l[i] += 1\nc = 0\nnums = [0] * N\nfor i in range(N):\n nums[i] = l[i] * (l[i] - 1) / 2\ns = sum(nums)\nfor i in range(N):\n a = A[i]\n print(int(s - nums[a - 1] + (l[a] - 1) * (l[a] - 2) / 2))\n', 'N = int(input())\nA = list(map(int, input().split()))\nl = [0] * 10000001\nfor i in A:\n l[i] += 1\ns = 0\nfor i in l:\n s += i * (i - 1) // 2\nfor a in A:\n a = l[a]\n print(s - (a * (a - 1) // 2) + ((a - 1) * (a - 2) // 2))\n', 'N = int(input())\nA = list(map(int, input().split()))\nl = [0] * 10000001\nfor i in A:\n l[i] += 1\ns = 0\nfor i in range(N + 1):\n i = l[i]\n s += i * (i - 1) // 2\nfor a in A:\n a = l[a]\n print(s - (a * (a - 1) // 2) + ((a - 1) * (a - 2) // 2))\n']
['Runtime Error', 'Time Limit Exceeded', 'Accepted']
['s313211991', 's825991993', 's637999746']
[26140.0, 94464.0, 94304.0]
[97.0, 2104.0, 485.0]
[280, 228, 252]
p02732
u343523553
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 = [a.count(i+1) for i in range(n)]\nd = []\nfor j in b:\n if j >= 2:\n d.append(factorial(j)//factorial(2)//factorial(j-2))\n else:\n d.append(0)\n\nfor k in a:\n if b[k-1] >= 3:\n u = b[k-1] \n p = factorial(u-1)//factorial(2)//factorial(u-3)\n print(sum(d)-d[k-1]+p)\n else:\n print(sum(d)-d[k-1])', 'n = int(input())\na = list(map(int,input().split()))\nnum = [0]*(n+1)\ns = 0\nfor i in a:\n num[i] += 1\nfor i in num:\n s += i*(i-1)//2\nfor i in range(n):\n print(s-num[a[i]]+1)\n\n ']
['Runtime Error', 'Accepted']
['s984463996', 's436355017']
[26140.0, 26140.0]
[2104.0, 304.0]
[393, 185]
p02732
u348868667
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\ndef main():\n N = int(input())\n A = list(map(int, input().split()))\n c = Counter(A)\n comb = 0\n for i in c.values():\n if i >= 2:\n comb += i*(i-1)/2\n for i in range(N):\n print(comb - (c[A[i]] - 1))\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 c = Counter(A)\n comb = 0\n for i in c.values():\n if i >= 2:\n comb += i*(i-1)//2\n for i in range(N):\n print(comb - (c[A[i]] - 1))\n\nif __name__ == '__main__':\n main()"]
['Wrong Answer', 'Accepted']
['s731175258', 's450577113']
[26780.0, 26780.0]
[407.0, 298.0]
[309, 310]
p02732
u349444371
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()))\nC=Counter(a)\n#print(C)\ntotal=0\nfor k,v in C.items():\n if v>=2:\n total+=v*(v-1)//2\nprint(total)\nfor i in range(n):\n V=C[a[i]]\n ans=total-(V*(V-1))//2+((V-1)*(V-2))//2\n print(ans)', 'from collections import Counter\nn=int(input())\na=list(map(int,input().split()))\nC=Counter(a)\n#print(C)\ntotal=0\nfor k,v in C.items():\n if v>=2:\n total+=v*(v-1)//2\n#print(total)\nfor i in range(n):\n V=C[a[i]]\n ans=total-(V*(V-1))//2+((V-1)*(V-2))//2\n print(ans)']
['Wrong Answer', 'Accepted']
['s853817482', 's273812705']
[25896.0, 26772.0]
[410.0, 400.0]
[276, 277]
p02732
u353895424
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 return n*(n-1)/2\n\nn = int(input())\na = list(map(int, input().split()))\n\ncnt = [0]*(n+1)\ntotal = 0\nans = 0\n\nfor i in range(n):\n cnt[a[i]] += 1\n\nfor i in range(n):\n total += nC2(cnt[i])\n\nfor i in range(n):\n print(total - nC2(cnt[a[i]]) + nC2(cnt[a[i]] - 1))', 'def nC2(n):\n return n*(n-1)//2\n\nn = int(input())\na = list(map(int, input().split()))\n\ncnt = [0]*(n+1)\ntotal = 0\nans = 0\n\nfor i in range(n):\n cnt[a[i]] += 1\n\nfor i in range(1, n+1):\n total += nC2(cnt[i])\n\nfor i in range(n):\n print(total - nC2(cnt[a[i]]) + nC2(cnt[a[i]] - 1))']
['Wrong Answer', 'Accepted']
['s728851196', 's342944230']
[24748.0, 24744.0]
[505.0, 429.0]
[280, 286]
p02732
u357230322
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=int(input())\na=list(map(int,input().split()))\nt=0\nu=0\nfor i in range(n):\n if u!=n-1:\n m=a[i]\n del a[i]\n s=sorted(a)\n x=s.count(s[u])\n t+=math.factorial(x)//2\n u+=x\n a.insert(i,m)\n print(t)', 'from collections import Counter\n\nn=int(input())\na=list(map(int,input().split()))\n\nc=Counter(a)\nans=0\nfor i in c.keys():\n ans+=(c[i]*(c[i]-1))//2\n\nfor i in a:\n print(ans-c[i]+1)\n']
['Wrong Answer', 'Accepted']
['s170629747', 's617894629']
[26140.0, 26780.0]
[2105.0, 375.0]
[225, 179]
p02732
u360061665
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\nN = int(input())\nA = list(map(int, input().split(' ')))\nc = collections.Counter(A)\nd1 = {}\nd2 = {}\nfor i in c:\n d1[str(i)] = (c[i]*(c[i]-1))/2\n d2[str(i)] = ((c[i]-1)*(c[i]-2))/2\n\ns = sum(d1.values())\n\nprint(c)\nfor i in range(N):\n ans = s - d1[str(A[i])]+d2[str(A[i])]\n print(int(ans))\n", "import collections\nimport math\nN = int(input())\nA = list(map(int, input().split(' ')))\nc = collections.Counter(A)\nd1 = {}\nd2 = {}\nfor i in c:\n d1[str(i)] = (c[i]*(c[i]-1))/2\n d2[str(i)] = ((c[i]-1)*(c[i]-2))/2\n\ns = sum(d1.values())\n\nfor i in range(N):\n ans = s - d1[str(A[i])]+d2[str(A[i])]\n print(int(ans))\n"]
['Wrong Answer', 'Accepted']
['s831879127', 's838555003']
[71324.0, 56604.0]
[835.0, 790.0]
[329, 320]
p02732
u362563655
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 = []\nC = []\n\nfor i in range(1,N+1):\n n = A.count(i)\n B.append(n*(n-1)//2)\n C.append((n-1)*(n-2)//2 if n >1 else 0)\n\nB_sum = sum(B)\nprint(B)\nprint(C)\n\nfor i in range(N):\n a = A[i]-1\n print(B_sum-B[a]+C[a])', 'N= int(input())\nA = list(map(int,input().split()))\nB = [0] * N\n\nfor i in A:\n B[i-1] +=1\n\nB_sum = 0\nfor i in B:\n B_sum += i * (i-1) //2\n\nprint(A,B,B_sum)\nfor i in range(N):\n print(B_sum-B[A[i]-1]+1)', 'N= int(input())\nA = list(map(int,input().split()))\nB = [0] * N\n\nfor i in A:\n B[i-1] +=1\n\nB_sum = 0\nfor i in B:\n B_sum += i * (i-1) //2\n\nfor i in range(N):\n print(B_sum-B[A[i]-1]+1)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s426739555', 's796473001', 's425965428']
[24748.0, 24748.0, 26140.0]
[2105.0, 364.0, 320.0]
[272, 206, 189]
p02732
u365838886
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 = []\nS = 0\n\nfor i in range(1, N+1):\n B[i] = A.count(i)\n S += B[i]*(B[i]-1)/2\n\nfor i in range(N):\n if B[A[i]] < 2:\n print(S)\n else:\n print(S-B[A[i]]+1)', 'N = int(input())\nA = list(map(int, input().split()))\nB = []\nS = 0\n\nfor i in range(1, N+1):\n\tB[i] = A.count(i)\n\tS += B[i]*(B[i]-1)/2\n\nfor i in range(N):\n\tif B[A[i]] < 2:\n\t\tprint(S)\n\telse:\n\t\tprint(S-B[A[i]]+1)', 'N = int(input())\nA = list(map(int, input().split()))\nB = [0]*(N+1)\nS = 0\n\nfor i in range(N):\n B[A[i]] += 1\n\nfor i in range(1, N+1):\n S += B[i]*(B[i]-1)//2\n\nfor k in range(N):\n print(S-B[A[k]]+1)']
['Runtime Error', 'Runtime Error', 'Accepted']
['s328819793', 's501750708', 's663283234']
[32132.0, 32140.0, 32216.0]
[76.0, 76.0, 221.0]
[231, 207, 203]
p02732
u367130284
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*\nd={}\nn,*a=map(int,open(0).read().split())\nb=Counter(a)\nfor i in range(n):\n c=(b-Counter([a[i]]))\n if a[i]not in d:\n ans=sum([v*(v-1)//2 for k,v in c.items()if v>=2])\n d[a[i]]=ans\n else:\n print(d[a[i]])', 'from collections import*\nn,*a=map(int,open(0).read().split())\n\nb=Counter(a)\n\nans=sum(v*(v-1)//2 for k,v in b.items())\n\nfor i in range(n):\n x=b[a[i]]\n print(ans-x*(x-1)//2+(x-1)*(x-2)//2)']
['Wrong Answer', 'Accepted']
['s807318046', 's349987590']
[39948.0, 25932.0]
[2105.0, 414.0]
[256, 192]
p02732
u369502636
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())\nnumber = list(map(int,input().split()))\nnum = sorted(number)\nnum.append(0)\np = num[0]\ncombi = dict()\nu = 0\n\nfor i in range (n+1) :\n q = num[i]\n if p != q :\n combi[p] = u\n u = 0\n u += 1\n p = q\n\nt = 0\n\nfor j in combi.values() :\n t += j*(j-1)//2\n\nfor k in range (n) :\n x = combi[j]\n print(t + (combi[x]-1)*(combi[x]-2)//2 - combi[x]*(combi[x]-1)//2)', 'n = int(input())\nnumber = list(map(int,input().split()))\nnum = sorted(number)\nnum.append(0)\np = num[0]\ncombi = dict()\nu = 0\n\nfor i in range (n+1) :\n q = num[i]\n if p != q :\n combi[p] = u\n u = 0\n u += 1\n p = q\n\nt = 0\n\nfor j in combi.values() :\n t += j*(j-1)//2\n\nfor k in range (n) :\n x = number[k]\n print(t + (combi[x]-1)*(combi[x]-2)//2 - combi[x]*(combi[x]-1)//2)']
['Runtime Error', 'Accepted']
['s582353740', 's967167594']
[26140.0, 26524.0]
[498.0, 529.0]
[398, 399]
p02732
u370217787
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\nfrom math import factorial\n\nN = int(input())\nA = np.array(list(map(int, input().split())))\n\ndic = {}\nafter = {}\n\nnewdata = np.unique(A)\nfor i in range(len(newdata)):\n\tx = np.sum(A == newdata[i])\n\tif x <= 1:\n\t\tdic[newdata[i]] = 0\n\telse:\n\t\tdic[newdata[i]] = factorial(x) / factorial(2) / factorial(x - 2)\n\n\tif x - 1 <= 1:\n\t\tafter[newdata[i]] = 0\n\telse:\n\t\tafter[newdata[i]] = factorial(x - 1) / factorial(2) / factorial(x - 1 - 2)\n\n\tprint(dic, after)\n\nnumsum = 0\nfor dicv in dic.values():\n\tnumsum += dicv \n\n\nfor i in range(N):\n\tprint(int(numsum - dic[A[i]] + after[A[i]]))\n', 'import numpy as np\nfrom math import factorial\n\nN = int(input())\nA = np.array(list(map(int, input().split())))\n\namount = np.array([])\nfor i in range(N):\n\tamount = np.append(amount, np.sum(A == i + 1))\n\nfor i in range(N):\n\tamount[A[i] - 1] -= 1\n\tans = 0\n\tfor j in range(N):\n\t\tif amount[j] <= 1:\n\t\t\tpass\n\t\telse:\n\t\t\tans += factorial(amount[j]) / factorial(2) / factorial(amount[j] - 2)\n\tprint(int(ans))\n\tamount[A[i] - 1] += 1\n', 'import numpy as np\nimport collections\n\nN = int(input())\nA = list(map(int, input().split()))\n\ndic = {}\nafter = {}\n\nl = collections.Counter(A)\n\nfor key, val in l.items():\n\tdic[key] = val * (val - 1) // 2\n\tafter[key] = (val - 1) * (val - 2) // 2\n\nnumsum = sum(dic.values())\n\nans = {}\nfor key in dic.keys():\n\tans[key] = numsum - dic[key] + after[key]\n\nfor i in range(N):\n\tprint(ans[A[i]])\n\n']
['Runtime Error', 'Time Limit Exceeded', 'Accepted']
['s815548418', 's845200179', 's170094262']
[34156.0, 34080.0, 53384.0]
[2109.0, 2109.0, 592.0]
[589, 422, 386]
p02732
u370721525
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\nN = int(input())\nA = list(map(int, input().split()))\nans = 0\n\nfor i in range(N):\n li = A[:i] + A[i+1]\n c = collections.Counter(li)\n l = [i for i in C.items() if i > 1]\n for num in l:\n ans += math.factorial(num) // (math.factorial(num-2) * 2)\n \nprint(ans)', 'import collections\nN = int(input())\nA = list(map(int, input().split()))\nc = collections.Counter(A)\ntotal = 0\n\nfor n in c.items():\n if n[1] > 1:\n total += n*(n-1)//2\n\nfor i in range(N):\n ans = total\n ans -= A.count(A[i])-1\n print(ans)', 'import collections\nN = int(input())\nA = list(map(int, input().split()))\nc = collections.Counter(A)\ntotal = 1\n\nfor n in c.items():\n total += n[1]*(n[1]-1)//2\n\nfor i in range(N):\n print(total-c[A[i]])']
['Runtime Error', 'Runtime Error', 'Accepted']
['s129350506', 's386222118', 's734595832']
[26900.0, 26780.0, 25896.0]
[70.0, 97.0, 345.0]
[295, 240, 200]
p02732
u378153116
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 scipy.misc import comb\n# from scipy.special import comb\n\ndef banned(al):\n d = {}\n for a in al:\n if a in d.keys():\n d[a] += 1\n else:\n d[a] = 1\n # print(d)\n for k, v in d.items():\n if v > 1:\n d[k] = [v, comb(v, 2)]\n else:\n d[k] = [v, 0]\n for a in al:\n ans = 0\n for k, v in d.items():\n if k == a:\n if v[0] > 2:\n ans += comb(v[0]-1, 2)\n else:\n ans += v[1]\n print(int(ans))\n\nn = int(input())\nal = [int(i) for i in input().split()]\n\nbanned(al)', 'from scipy.misc import comb\n\ndef banned(al):\n d = {}\n for a in al:\n if a in d.keys():\n d[a] += 1\n else:\n d[a] = 1\n # print(d)\n for a in al:\n d[a] -= 1\n ans = 0\n for v in d.values():\n if v > 1:\n ans += comb(v, 2)\n d[a] += 1\n print(int(ans))\n\nn = int(input())\nal = [int(i) for i in input().split()]\n\nbanned(al)', '# from scipy.misc import comb\n# from scipy.special import comb\nimport math\n\ndef comb(n, r):\n return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))\n\ndef banned(al):\n d = {}\n for a in al:\n if a in d.keys():\n d[a] += 1\n else:\n d[a] = 1\n # print(d)\n ans = 0\n for k, v in d.items():\n if v > 1:\n ans += comb(v, 2)\n # d[k] = [v, comb(v, 2)]\n # else:\n # d[k] = [v, 0]\n # print(ans)\n for a in al:\n # for k, v in d.items():\n \n # if v[0] > 2:\n # ans += comb(v[0]-1, 2)\n # else:\n # ans += v[1]\n print(int(ans-(d[a]-1)))\n\nn = int(input())\nal = [int(i) for i in input().split()]\n\nbanned(al)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s303232421', 's447887772', 's702984428']
[43148.0, 35252.0, 26268.0]
[2110.0, 2109.0, 1708.0]
[621, 417, 798]
p02732
u379142263
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 bisect\nn = int(input())\na = list(map(int,input().split()))\nA = collections.Counter(a)\nKey = []\nVal = []\nfor key,val in A.items():\n Key.append(key)\n Val.append(val)\nans = 0\nans1 = 0\nfor i in range(len(Val)):\n ans+= ((Val[i])*(Val[i]-1))//2\nfor i in range(n):\n s = bisect.bisect_left(Key,a[i])\n d1 = (Val[s]*(Val[s]-1))//2\n Val[s]-=1\n d2 = (Val[s]*(Val[s]-1))//2\n ans1 = ans - (d1-d2)\n print(ans1)\n Val[s]+=1\nprint(ans1)', 'import sys\nimport itertools\nsys.setrecursionlimit(1000000000)\nfrom heapq import heapify,heappop,heappush,heappushpop\nimport math\nimport collections\nMOD = 10**9 + 7\n\nn = int(input())\na = list(map(int,input().split()))\n\n\nc = collections.Counter(a)\nmaxa = 0\nitem = [0 for i in range(max(a))]\nfor key,value in c.items():\n item[key-1] = value\n maxa += (value)*(value-1)//2\nfor i in range(len(a)):\n d = (item[a[i]-1])*(item[a[i]-1]-1)//2-(item[a[i]-1]-1)*(item[a[i]-1]-2)//2\n print(maxa-d)\n']
['Runtime Error', 'Accepted']
['s723362407', 's297894938']
[26780.0, 26004.0]
[707.0, 449.0]
[474, 563]
p02732
u384124931
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 - d[a] + 1)', '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)']
['Runtime Error', 'Accepted']
['s309822946', 's369433689']
[27960.0, 38840.0]
[161.0, 413.0]
[241, 241]
p02732
u386944085
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=0\nlist1 = list(map(int, input().split()))\nc = collections.Counter(list1)\nfor i in range(N):\n a+=int(c[i+1]*(c[i+1]-1)/2)\nfor i in range(N):\n print(a-c[list1[i]]*2+3)', 'import collections\nN=int(input())\na=0\nlist1 = list(map(int, input().split()))\nc = collections.Counter(list1)\nfor i in range(N):\n a+=int(c[i+1]*(c[i+1]-1)/2)\nfor i in range(N):\n if c[list1[i]]!=0:\n print(a-c[list1[i]]+1)\n else:\n print(a)']
['Wrong Answer', 'Accepted']
['s038728579', 's663257035']
[26772.0, 26780.0]
[508.0, 525.0]
[207, 259]
p02732
u399155892
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.
["#!/usr/bin/env python\n\ndef main():\n n = int(input())\n a = list(map(int, input().split()))\n a_sort = sorted(a)\n\n ball_dict = {}\n count = 1\n for i in range(1, n):\n if a_sort[i] == a_sort[i - 1]:\n count += 1\n else:\n ball_dict.setdefault(a_sort[i - 1], count)\n count = 1\n ball_dict.setdefault(a_sort[n - 1], count)\n\n ans = 0\n for v in ball_dict.values():\n ans += v * (v - 1) // 2\n\n ans_dict = {}\n for v in ball_dict.values():\n if v not in ans_dict.values():\n ans_dict.setdefault(v, ans - (v - 1))\n\n for i in range(n):\n print(ans_dict[ball_dict[a[i]]])\n\nif __name__ == '__main__':\n main()\n", "#!/usr/bin/env python\n\ndef main():\n n = int(input())\n a = list(map(int, input().split()))\n a_sort = sorted(a)\n\n ball_dict = {}\n count = 1\n for i in range(1, n):\n if a_sort[i] == a_sort[i - 1]:\n count += 1\n else:\n ball_dict.setdefault(a_sort[i - 1], count)\n count = 1\n ball_dict.setdefault(a_sort[n - 1], count)\n\n ans = 0\n for v in ball_dict.values():\n ans += v * (v - 1) // 2\n\n ans_dict = {}\n for v in ball_dict.values():\n if v not in ans_dict:\n ans_dict.setdefault(v, ans - (v - 1))\n\n for i in range(n):\n print(ans_dict[ball_dict[a[i]]])\n\nif __name__ == '__main__':\n main()\n"]
['Runtime Error', 'Accepted']
['s993478399', 's072867725']
[25380.0, 26200.0]
[456.0, 373.0]
[702, 693]
p02732
u401452016
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 math\nfrom collections import Counter\nn = int(sys.stdin.readline())\nA = map(int, sys.stdin.readline().split())\ndef comb(n):\n return int(math.factrial(n)/(math.factrial(n-2)*2))\nfor k in range(n):\n ans =0\n L=A[:k]+A[k+1:]\n for v in Counter(L).values():\n if v>=2:\n ans +=comb(v)\n print(ans)\n', 'import sys\nimport math\nfrom collections import Counter\nn = int(sys.stdin.readline())\nA = map(int, sys.stdin.readline().split())\ndef comb(n):\n return math.factrial(n)/(math.factrial(n-2)*2)\nfor k in range(n):\n ans =0\n L=A[:k]+A[k+1:]\n for v in Counter(L).values():\n if v>=2:\n ans +=comb(v)\n print(ans)', 'import sys\nimport math\nfrom collections import Counter\nn = int(sys.stdin.readline())\nA = list(map(int, sys.stdin.readline().split()))\ndef comb(n):\n return int(math.factrial(n)/(math.factrial(n-2)*2))\nfor k in range(n):\n ans =0\n L=A[:k]+A[k+1:]\n for v in Counter(L).values():\n if v>=2:\n ans +=comb(v)\n print(ans)\n', '#ABC159D\nimport sys, math\nfrom collections import Counter\n\nN = int(sys.stdin.readline())\nA = list(map(int, sys.stdin.readline().split()))\n\ndef comb(n):\n return int(math.factorial(n)/(2*math.factorial(n-2)))\n\ntotal = 0\nL = Counter(A)\nfor v in L.values():\n if v>=2:\n total += comb(v)\n\nfor k in range(N):\n print(total - (L[A[k]]-1))\n']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s410852382', 's437160250', 's799438762', 's343877728']
[18668.0, 18668.0, 26224.0, 25920.0]
[39.0, 40.0, 95.0, 1712.0]
[319, 313, 325, 346]
p02732
u403331159
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 comb_ans=1\n for i in range(1,k+1):\n comb_ans*=(n-i+1)/i\n comb_ans=int(comb_ans)\n return comb_ans\n\nN=int(input())\nA=list(map(int,input().split()))\nans=0\nL=[0]*N\nfor i in range(N):\n L[A[i]-1]+=1\nfor i in range(len(C)):\n ans+=Comb(L[A[i]-1],2)\nfor i in range(N):\n pri=ans\n pri=ans-Comb(L[A[i]-1],2)+Comb(L[A[i]-1]-1,2)\n print(pri)', 'def Comb(n,k):\n comb_ans=1\n for i in range(1,k+1):\n comb_ans*=(n-i+1)/i\n comb_ans=int(comb_ans)\n return comb_ans\n\nN=int(input())\nA=list(map(int,input().split()))\nans=0\nB=set(A)\nL=[0]*N\nfor i in range(N):\n L[A[i]-1]+=1\nfor i in B:\n ans+=Comb(L[i-1],2)\nfor i in range(N):\n pri=ans\n pri=ans-L[A[i]-1]+1\n print(pri)']
['Runtime Error', 'Accepted']
['s798927853', 's991226313']
[26140.0, 26140.0]
[109.0, 442.0]
[377, 345]
p02732
u405733072
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 resolve():\n n = int(input())\n a = tuple(map(int,input().split()))\n A = collections.Counter(a)\n cnt_0 = 0\n for i in A.values():\n cnt_0 += int(i*(i-1)/2)\n for i in a:\n cnt_1 = A[i]-1\n print(cnt_0-cnt_1)\nresolve()', 'import collections\ndef resolve():\n n = int(input())\n a = tuple(map(int,input().split()))\n A = collections.Counter(a)\n cnt_0 = 0\n for i in A.values():\n cnt_0 += int(i*(i-1)/2)\n for i in a:\n cnt_1 = A[i]-1\n print(cnt_0-cnt_1)\nresolve()']
['Runtime Error', 'Accepted']
['s148677311', 's029531447']
[33172.0, 34340.0]
[70.0, 199.0]
[253, 272]
p02732
u408375121
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()))\ndic1 = {}\ndic2 = {}\nfor i in range(N):\n if A[i] in dic1:\n dic1[A[i]] += 1\n dic2[A[i]].append(i)\n else:\n dic1[A[i]] = 1\n dic2[A[i]].append(i)\n\nfor j in range(N):\n ans = 0\n for k, v in dic1.items():\n if j in dic2[k]:\n ans += ((v-1)*(v-2))//2\n else:\n ans += (v*(v-1))//2\n print(ans)', 'N = int(input())\nA = list(map(int, input().split()))\ndic1 = {}\ndic2 = {}\nfor i in range(N):\n if A[i] in dic1:\n dic1[A[i]] += 1\n else:\n dic1[A[i]] = 1\nans = 0\nfor v in dic1.values():\n ans += (v*(v-1))//2\nfor j in range(N):\n w = dic1[A[j]]\n v = w-1\n comb = ans -(w*(w-1))//2 + (v*(v-1))//2\n print(comb)\n']
['Runtime Error', 'Accepted']
['s002903765', 's949204356']
[26268.0, 25716.0]
[66.0, 431.0]
[365, 314]
p02732
u411858517
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\ndef P(n, r):\n return math.factorial(n)//math.factorial(n-r)\ndef C(n, r):\n return P(n, r)//math.factorial(r)\n\nN = int(input())\nA = list(map(int, input().split()))\n\ndic = {}\nfor i in range(N):\n if A[i] in dic:\n dic[A[i]] += 1\n else:\n dic[A[i]] = 1\n\nmemo = \nans = 0\nfor k in dic:\n tmp =dic[k]\n if tmp >= 2:\n memo[k] = C(tmp, 2)\n ans += memo[k]\n\nfor i in range(N):\n tmp = dic[A[i]]\n if tmp == 1:\n print(ans)\n elif tmp == 2:\n print(ans - 1)\n else\n print(ans - (memo[A[i]] - C(tmp-1, 2)))\n', 'import math\n\ndef P(n, r):\n return math.factorial(n)//math.factorial(n-r)\ndef C(n, r):\n return P(n, r)//math.factorial(r)\n\nN = int(input())\nA = list(map(int, input().split()))\n\ndic = {}\nfor i in range(N):\n if A[i] in dic:\n dic[A[i]] += 1\n else:\n dic[A[i]] = 1\n\nmemo = [0 for i in range(10 ** 6)]\nans = 0\nfor k in dic:\n tmp =dic[k]\n if tmp >= 2:\n if memo[tmp] == 0:\n memo[tmp] = C(tmp, 2)\n ans += memo[tmp]\n else:\n ans += memo[tmp]\n\nfor i in range(N):\n tmp = dic[A[i]]\n if tmp == 1:\n print(ans)\n elif tmp == 2:\n print(ans - 1)\n else:\n print(ans)\n', 'import math\n\nN = int(input())\nA = list(map(int, input().split()))\n\ndic = {}\nfor i in range(N):\n if A[i] in dic:\n dic[A[i]] += 1\n else:\n dic[A[i]] = 1\n\nmemo = [0 for i in range(10 ** 6)]\nans = 0\nfor k in dic:\n tmp =dic[k]\n if tmp >= 2:\n if memo[tmp] == 0:\n memo[tmp] = tmp * (tmp - 1) // 2\n ans += memo[tmp]\n else:\n ans += memo[tmp]\n\nfor i in range(N):\n tmp = dic[A[i]]\n if tmp == 1:\n print(ans)\n elif tmp == 2:\n print(ans - 1)\n else:\n print(ans - tmp * (tmp - 1) // 2 + (tmp - 1) * (tmp - 2) // 2)\n\n\n']
['Runtime Error', 'Wrong Answer', 'Accepted']
['s435961984', 's669691376', 's209825365']
[2940.0, 32544.0, 32544.0]
[17.0, 1788.0, 436.0]
[532, 595, 545]
p02732
u412139296
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\nans = [-1] * N\n\nfor A_ in range(len(A)):\n K = A[A_]\n for B_ in range(len(A)):\n if K == A[B_]:\n ans[A_] += 1\n print(ans[A_])\n', 'N = int(input())\nA = list(map(int, input().split()))\nCNT = [0] * (N+1)\n\nfor i in A:\n CNT[i] += 1\n\nCONB = [CNT[j]*(CNT[j]-1)//2 for j in range(len(CNT))]\n\nSUM = sum(CONB)\nfor i in A:\n ans = SUM - CNT[i] + 1\n print(ans)\n']
['Wrong Answer', 'Accepted']
['s457594361', 's837384944']
[24996.0, 26140.0]
[2104.0, 300.0]
[204, 227]
p02732
u424467986
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 scipy.misc import comb\n\nN = int(input())\nA = list(map(int, input().split(' ')))\n\nK = {}\nfor row in A:\n if row in K:\n K[row] += 1\n else:\n K[row] = 1\n\n\nD = {}\nfor row in A:\n ans = 0\n if row not in D:\n for i in K:\n if i == row:\n ans += comb(K[i]-1, 2, exact=True)\n else:\n ans += comb(K[i], 2, exact=True)\n D[row] = int(ans)\n print(D[row])\n else:\n print(D[row])", "from scipy.misc import comb\n\nN = int(input())\nA = list(map(int, input().split(' ')))\n\nK = {}\nfor row in A:\n if row in K:\n K[row] += 1\n else:\n K[row] = 1\n\n\nD = {}\nC = {}\nfor row in A:\n ans = 0\n if row not in D:\n for i in K:\n tmp = 0\n if i == row:\n tmp = K[i]-1\n else:\n tmp = K[i]\n if tmp not in C:\n ans += comb(tmp, 2, exact=True)\n else:\n ans += C[tmp]\n D[row] = int(ans)\n print(D[row])\n else:\n print(D[row])\n", "from scipy.misc import comb\n\nN = int(input())\nA = list(map(int, input().split(' ')))\n\nK = {}\nfor row in A:\n if row in K:\n K[row] += 1\n else:\n K[row] = 1\n\n\nfor row in A:\n ans = 0\n for i in K:\n if i == row:\n ans += comb(K[i]-1,2,exact=True)\n else:\n ans += comb(K[i],2,exact=True)\n print(int(ans))\n", "N = int(input())\nA = list(map(int, input().split(' ')))\n\nK = {}\nfor row in A:\n if row in K:\n K[row] += 1\n else:\n K[row] = 1\n \n\nmax = 0\nfor i in K:\n max += int(K[i]*(K[i]-1)/2)\n\n\nfor i in A:\n print(max - int(K[i]*(K[i]-1)/2) + int((K[i]-1)*(K[i]-2)/2) )"]
['Time Limit Exceeded', 'Time Limit Exceeded', 'Time Limit Exceeded', 'Accepted']
['s021331440', 's577416243', 's995316573', 's173821362']
[45348.0, 43792.0, 36568.0, 24748.0]
[2109.0, 2110.0, 2110.0, 488.0]
[501, 610, 386, 319]
p02732
u428199834
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()))\ndic={}\nfor i in set(A):\n dic[i]=A.count(i) \ndef ans(k,dic):\n dic[A[k-1]]+=-1\n c=0\n for i in dic.values():\n c+=i*(i-1)/2\n dic[A[k-1]]+=1 \n return int(c)\nfor k in range(1,N+1):', 'N=int(input())\nA=list(map(int,input().split()))\ndic={}\nfor a in A:\n if a in dic:\n dic[a]+=1\n else:\n dic[a]=1\n \nprint(dic)\nc=0\nfor i in dic.values():\n c+=i*(i-1)/2\nfor j in range(1,N+1):\n d=c-dic[A[j-1]]+1\n print(int(d))\n ', 'n=int(input())\ncnt=[0]*(n+1)\na=list(map(int,input().split()))\nfor i in range(n):\n cnt[a[i]]+=1 \nans=0 \nfor i in range(1,n+1):\n if cnt[i]>=1:\n ans+=cnt[i]*(cnt[i]-1)//2\nfor i in range(n):\n print(ans-cnt[a[i]]+1)\n ']
['Runtime Error', 'Wrong Answer', 'Accepted']
['s535560891', 's812048410', 's670867495']
[3060.0, 25716.0, 33876.0]
[17.0, 462.0, 221.0]
[232, 235, 220]
p02732
u436982376
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\ndef combinations_count(n, memo_fact):\n return memo_fact[n] // (memo_fact[n - 2] * 2)\n\nn = int(input())\na = list(map(int,input().split()))\nprint(len(a))\nn_list = [0 for i in range(n)]\nlen_list = [0 for i in range(n)]\n\nmemo_fact = [1]\n\nfor i in range(1, n+1):\n memo_fact.append(memo_fact[i-1]*i)\n\nfor i in range(n):\n n_list[a[i]-1] += 1\n\nsum_len = 0\n\nfor i in range(n):\n if n_list[i] == 0:\n len_list[i] == 0\n elif n_list[i] == 1:\n len_list[i] == 1\n else:\n len_list[i] = combinations_count(n_list[i], memo_fact)\n sum_len += len_list[i]\n\nfor i in range(n):\n if len_list[a[i]-1] == 0:\n print(sum_len)\n elif len_list[a[i]-1] == 1 or len_list[a[i]-1] == 2:\n print(sum_len - 1)\n else:\n print(sum_len - len_list[a[i]-1] + combinations_count(n_list[a[i]-1] - 1, memo_fact))\n', 'import math\n\ndef combinations_count(n):\n return math.factorial(n) / (math.factorial(n - 2) * math.factorial(2))\n\nn = int(input())\na = list(map(int,input().split()))\nn_list = [[] for i in range(n)]\nlen_list = [0 for i in range(n)]\n\nfor i in range(n):\n n_list[a[i]-1].append(i)\n\nfor i in range(n):\n if len(n_list[i]) == 0:\n len_list[i] == 0\n elif len(n_list[i]) == 1:\n len_list[i] == 1\n else:\n len_list[i] = combinations_count(len(n_list[i]))\n\nsum_len = sum(len_list)\nans_list = [sum_len for i in range(n)]\n\nfor i in range(n):\n if len_list[a[i]-1] == 0:\n continue\n elif len_list[a[i]-1] == 1:\n ans_list[i] = ans_list[i] - 1\n elif len_list[a[i]-1] == 2:\n ans_list[i] = ans_list[i] - 1\n else:\n ans_list[i] = ans_list[i] - len_list[a[i]-1] + combinations_count(len(n_list[a[i]-1]) - 1)\n\nfor i in range(n):\n print(ans_list[i])\n', 'import math\n\ndef combinations_count(n):\n return math.factorial(n) // (math.factorial(n - 2) * math.factorial(2))\n\nn = int(input())\na = list(map(int,input().split()))\nn_list = [0 for i in range(n)]\nlen_list = [0 for i in range(n)]\n\nfor i in range(n):\n n_list[a[i]-1] += 1\n\nsum_len = 0\n\nfor i in range(n):\n if n_list[i] == 0:\n len_list[i] == 0\n elif n_list[i] == 1:\n len_list[i] == 1\n else:\n len_list[i] = combinations_count(n_list[i])\n sum_len += len_list[i]\n\nfor i in range(n):\n if len_list[a[i]-1] == 0:\n print(sum_len)\n elif len_list[a[i]-1] == 1 or len_list[a[i]-1] == 2:\n print(sum_len - 1)\n else:\n print(sum_len - (n_list[a[i]-1] - 1))\n']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s691212242', 's853357839', 's021792663']
[3436.0, 46816.0, 26140.0]
[2286.0, 2106.0, 1865.0]
[849, 900, 710]
p02732
u440129511
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]*(n)\nl1=[0]*(n)\nfor i in range(n):\n l[a[i]-1]+=1\n \nfor i in range(n):\n if l[i]>=2:\n l1[i]+=(l[i]*(l[i]-1))//2\n\nl1sum=sum(l1)\nfor i in range(n):\n if l[a[i]-1]-1>=2:print(l1sum-l1[a[i]-1]+(l[a[i]-1]-1 * l[a[i]-1]-2)//2)\n else:print(l1sum-l1[a[i]-1])', 'n=int(input())\na=list(map(int,input().split()))\nl=[0]*(n)\nl1=[0]*(n)\nfor i in range(n):\n l[a[i]-1]+=1\n \nfor i in range(n):\n if l[i]>=2:\n l1[i]+=(l[i]*(l[i]-1))//2\n\nl1sum=sum(l1)\nfor i in range(n):\n if l[a[i]-1]-1>=2:print(l1sum-l1[a[i]-1]+(l[i]*(l[i]-1))//2)\n else:print(l1sum-l1[a[i]-1])', 'n=int(input())\na=list(map(int,input().split()))\nl=[0]*(n)\nl1=[0]*(n)\nfor i in range(n):\n l[a[i]-1]+=1\n \ndef combinations_count(n,r):\n return math.factorial(n) // (math.factorial(n-r) * math.factorial(r))\n\nfor i in range(n):\n if l[i]>=2:\n l1[i]+=combinations_count(l[i],2)\n\nl1sum=sum(l1)\nfor i in range(n):\n if l[a[i]-1]-1>=2:print(l1sum-l1[a[i]-1]+combinations_count(l[a[i]-1]-1,2))\n else:print(l1sum-l1[a[i]-1])', 'n=int(input())\na=list(map(int,input().split()))\nl=[0]*(n)\nl1=[0]*(n)\nfor i in range(n):\n l[a[i]-1]+=1\n \nfor i in range(n):\n if l[i]>=2:\n l1[i]+=l[i]*(l[i]-1)//2\n\nl1sum=sum(l1)\nfor i in range(n):\n if l[a[i]-1]-1>=2:print(l1sum-l1[a[i]-1]+ (l[a[i]-1]-1)*(l[a[i]-1]-2)//2)\n else:print(l1sum-l1[a[i]-1])']
['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s018361761', 's022429724', 's381442052', 's722207055']
[26140.0, 26140.0, 26140.0, 26140.0]
[390.0, 376.0, 117.0, 409.0]
[322, 310, 437, 321]
p02732
u440161695
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 f(n):\n return (n*(n-1))//2\nN=int(input())\nA=list(map(int,input().split()))\nd=dict()\nans=0\n\nfor i in range(len(A)):\n if A[i] not in d:\n d[i]=0\n d[i]+=1\nfor i in d:\n ans+=f(d[i])\nfor i in range(len(A)):\n print(ans-d[A[i]]-1)', 'def f(n):\n return (n*(n-1))//2\nN=int(input())\nA=list(map(int,input().split()))\nd=dict()\nans=0\n\nfor i in range(len(A)):\n if A[i] not in d:\n d[A[i]]=0\n d[A[i]]+=1\nfor i in d:\n ans+=f(d[i])\nfor i in range(len(A)):\n print(ans-d[A[i]]+1)']
['Runtime Error', 'Accepted']
['s522401057', 's023997932']
[25716.0, 25716.0]
[71.0, 382.0]
[283, 289]
p02732
u443569380
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 = int(input())\na = list(map(int, input().split()))\n\n\nfor i in range(len(a)):\n rem_k = a[:i] + a[i + 1:]\n \n cho = []\n for j in rem_k:\n if rem_k.count(j) >= 2:\n cho.append(j)\n # print(rem_k)\n for i in cho:\n if rem_k.count(i) - 2 < 0:\n ans = 0\n else:\n ans = math.factorial(rem_k.count(i)) // (math.factorial(rem_k.count(i) - 2) * math.factorial(2))\n\n print(ans)\n', 'from collections import Counter\n\nn = int(input())\nl = list(map(int, input().split()))\ncl = Counter(l)\n\n\ncnt = 0\nfor v in cl.values():\n cnt += v * (v - 1) // 2 \n\nfor i in l:\n v = cl[i]\n ans = cnt - (v * (v - 1) // 2) + (v - 1) * (v - 2) // 2\n print(ans)\n']
['Runtime Error', 'Accepted']
['s596802136', 's712030714']
[26140.0, 26772.0]
[2104.0, 413.0]
[522, 265]
p02732
u451017206
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.
['A = [int(i) for i in input().split()]\nfrom collections import Counter\na = Counter(A)\n\nfor i in A:\n t = 0\n for k in a.keys():\n c = a[k]\n if k == i:\n c -= 1\n t += (c * (c-1)) // 2\n print(t) ', 'N = int(input())\nA = [int(i) for i in input().split()]\nfrom collections import Counter\na = Counter(A)\n\nT = 0\nfor k in a.keys():\n c = a[k]\n T += (c * (c-1)) // 2\n\nfor i in A:\n t = 0\n c = a[i]\n t = T\n t -= (c * (c-1)) // 2\n c -= 1\n t += (c * (c-1)) // 2\n print(t)']
['Wrong Answer', 'Accepted']
['s116354754', 's517854386']
[3316.0, 26268.0]
[21.0, 465.0]
[232, 288]
p02732
u452512115
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 choose2(n):\n return n * (n - 1) // 2\n\na = int(input())\nA = list(map(int, input().split())) \nd = {}\nfor k in A:\n if k in d:\n d[k] += 1\n else:\n d[k] = 1\n \nres = 0\nfor k in d.values():\n res += choose2(k, 2)\n\nfor k in A:\n temp = res\n m = d[k]\n temp -= choose2(m, 2, mod)\n\n d[k] -= 1\n temp += choose2(d[k], 2, mod)\n print(temp)\n d[k] += 1\n', 'def choose2(n):\n return n * (n - 1) // 2\n\na = int(input())\nA = list(map(int, input().split())) \nd = {}\nfor k in A:\n if k in d:\n d[k] += 1\n else:\n d[k] = 1\n \nres = 0\nfor k in d.values():\n res += choose2(k)\n\nfor k in A:\n temp = res\n m = d[k]\n temp -= choose2(m)\n\n d[k] -= 1\n temp += choose2(d[k])\n print(temp)\n d[k] += 1\n']
['Runtime Error', 'Accepted']
['s454359673', 's228993235']
[26268.0, 25716.0]
[116.0, 534.0]
[358, 339]
p02732
u454524105
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()))\ncnt = Counter(a)\nans = {}\nfor k in cnt.keys():\n ans[k] = (cnt[k] * cnt[k]-1) // 2\ns = sum(list(ans.values()))\nfor ai in a:\n if ai == 1:\n print(s)\n else:\n print(s - ans[ai] + (ans[ai] / cnt[ai]) * (cnt[ai] - 2))', 'from collections import Counter\nn = int(input())\na = list(map(int, input().split()))\ncnt = Counter(a)\nans = {}\nfor k in cnt.keys():\n ans[k] = (cnt[k] * cnt[k]-1) // 2\ns = sum(list(ans.values()))\nfor ai in a:\n if cnt[ai] == 1:\n print(s)\n else:\n print(s - ans[ai] + (ans[ai] / cnt[ai]) * (cnt[ai] - 2))', 'from collections import Counter\nn = int(input())\na = list(map(int, input().split()))\ncnt = Counter(a)\nans = {}\nfor k in cnt.keys():\n ans[k] = (cnt[k] * (cnt[k]-1)) // 2\ns = sum(list(ans.values()))\nfor ai in a:\n if cnt[ai] == 1:\n print(s)\n else:\n print(s - ans[ai] + int((ans[ai] / cnt[ai]) * (cnt[ai] - 2)))']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s065512292', 's581406267', 's041316976']
[32924.0, 32924.0, 32028.0]
[655.0, 658.0, 525.0]
[318, 323, 330]
p02732
u458834822
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 -*-\nimport numpy as np \nimport math\n\n\nN = int(input())\nA = input()\n\nA = np.array(A.split()).astype('int')\nones = np.ones([N, N])\nB = (A*ones)\nfor i in range(N):\n B[i, i] = 0\nB = B[np.where(B != 0, True, False)].reshape(N, N-1)\nB.sort()\n\ndef comb(n, r):\n if n < r:\n return 0\n else:\n return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))\n \ndef uniq_2_comb(N, ar):\n u = np.unique(ar, return_index=True)[1]\n ans = 0\n for i in range(len(u)-1):\n n = u[i+1] - u[i]\n ans += comb(n, 2)\n return ans\n\nans_ar = np.apply_along_axis(lambda x : uniq_2_comb(N, x), 1, B)\n\nfor ans in ans_ar:\n print(ans)", "# -*- coding: utf-8 -*-\nimport numpy as np \nimport math\n\n\nN = int(input())\nA = input()\n\nA = np.array(A.split()).astype('int')\nones = np.ones([N, N])\nB = (A*ones)\nfor i in range(N):\n B[i, i] = 0\nB = B[np.where(B != 0, True, False)].reshape(N, N-1)\nB.sort()\n\ndef comb(n, r):\n if n < r:\n return 0\n else:\n return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))\n \ndef uniq_2_comb(N, ar):\n u = np.unique(ar, return_index=True)[1]\n u = np.concatenate([u, np.array([N])])\n ans = 0\n for i in range(len(u)-1):\n n = u[i+1] - u[i]\n ans += comb(n, 2)\n return ans\n\nans_ar = np.apply_along_axis(lambda x : uniq_2_comb(N, x), 1, B)\n\nfor ans in ans_ar:\n print(ans)\n", '# -*- coding: utf-8 -*-\nimport collections\nimport math\n\n\nN = int(input())\nA = list(input().split())\n\nc = collections.Counter(A)\n\ndef comb(n, r):\n if n < r:\n return 0\n else:\n return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))\n\ncomb_sum = 0\nfor i in c:\n comb_sum += comb(c[i], 2)\n \nfor a in A:\n ans = comb_sum\n if c[a] >= 2:\n ans -= (c[a] - 1)\n print(ans)\n']
['Runtime Error', 'Runtime Error', 'Accepted']
['s261991113', 's980130020', 's761644273']
[38412.0, 38412.0, 26780.0]
[240.0, 248.0, 1711.0]
[669, 711, 426]
p02732
u459150945
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())\nAn = list(map(int, input().split()))\ncounter = Counter(An)\ncnt = 0\nfor c in counter.values():\n cnt += c * c-1 // 2\nfor a in An:\n print(int(cnt - (counter[a] - 1)))\n', 'from collections import Counter\nfrom scipy.misc import comb\nN = int(input())\nAn = list(map(int, input().split()))\ncounter = Counter(An)\ncnt = 0\nfor c in counter.values():\n cnt += comb(c, 2)\nfor a in An:\n print(int(cnt - comb(counter[a], 2) + comb(counter[a]-1, 2)))\n', 'from collections import Counter\nN = int(input())\nAn = list(map(int, input().split()))\ncounter = Counter(An)\ncnt = 0\nfor c in counter.values():\n cnt += c * c-1 // 2\nfor a in An:\n print(cnt - (counter[a] - 1))\n', 'from collections import Counter\nN = int(input())\nAn = list(map(int, input().split()))\ncounter = Counter(An)\ncnt = 0\nfor c in counter.values():\n cnt += c * (c-1) // 2\nfor a in An:\n print(cnt - (counter[a] - 1))\n']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s292301052', 's652926158', 's715777098', 's440544599']
[26780.0, 37048.0, 26780.0, 26780.0]
[364.0, 2109.0, 302.0, 332.0]
[219, 272, 214, 216]
p02732
u460375306
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 OrderedDict\nN = int(input())\nA = list(map(int, input().split()))\n\nball_values = OrderedDict()\nfor val in A:\n if val not in ball_values:\n ball_values[val] = 1\n else:\n ball_values[val] += 1\n# get total pairs of all balls\ntotal_possible_combos = sum(item[1]*(item[1]-1)//2 for item in ball_values.items())\n# for each k, take away the loss of pairs due to removing it\nk_outputs = [total_possible_combos-(ball_values[val]-1) for val in A]\nprint(k_outputs)', 'from collections import OrderedDict\nN = int(input())\nA = list(map(int, input().split()))\n\nball_values = OrderedDict()\nfor val in A:\n if val not in ball_values:\n ball_values[val] = 1\n else:\n ball_values[val] += 1\n# get total pairs of all balls\ntotal_possible_combos = sum(item[1]*(item[1]-1)//2 for item in ball_values.items())\n# for each k, take away the loss of pairs due to removing it\nk_outputs = [total_possible_combos-(ball_values[val]-1) for val in A]\n[print(value) for value in k_outputs]']
['Wrong Answer', 'Accepted']
['s100131083', 's995147199']
[56752.0, 55308.0]
[590.0, 678.0]
[506, 527]
p02732
u470618774
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 = list()\nfor i in range(1,n+1):\n c.append(int((b[i]*(b[i]-1))/2))\nprint(c)\nfor i in range(n):\n d = int(a[i]-1)\n if c[d]>2:\n e = sum(c) - c[d] + int( (c[d])*(b[d+1]-2) /(b[d+1]) )\n else:\n e = sum(c) - c[d]\n print(e)', 'import collections\nn=int(input())\na = list(map(int,input().split()))\nb = collections.Counter(a)\nc = list()\nfor i in range(1,n+1):\n c.append(int((b[i]*(b[i]-1))/2))\n\nsum = sum(c)\nfor i in range(n):\n d = int(a[i]-1)\n if c[d]>2:\n e = sum - c[d] + int( (c[d])*(b[d+1]-2) /(b[d+1]) )\n else:\n e = sum - c[d]\n print(e)']
['Wrong Answer', 'Accepted']
['s882430612', 's925742389']
[26780.0, 26780.0]
[2105.0, 681.0]
[341, 340]
p02732
u471214054
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 scipy.misc import comb\n\nN, M = map(int, input().split())\n\nprint(int(comb(N, 2) + comb(M, 2)))\n', 'from scipy.misc import comb\n\nN = int(input())\nA = list(map(int, input().split()))\n\nfor k, val in enumerate(A):\n count = 0\n nums = [0] * N\n for i, v in enumerate(A):\n if k == i:\n continue\n nums[v] += 1\n combs = list(map(lambda n: int(comb(n, 2)), nums))\n print(sum(combs))', 'N = int(input())\nA = list(map(int, input().split()))\n\n\ndef comb2(n):\n return n * (n - 1) // 2\n\n\ncounts = [0] * (N + 1)\nfor a in A:\n counts[a] += 1\ntotal = sum(map(comb2, filter(lambda n: n > 1, counts)))\n\nfor a in A:\n print(total - (counts[a] - 1))\n']
['Runtime Error', 'Runtime Error', 'Accepted']
['s178651076', 's629965911', 's355677315']
[13964.0, 35212.0, 26012.0]
[173.0, 2109.0, 284.0]
[99, 311, 258]
p02732
u471539833
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\nsum=0\nfor i in range(N):\n b[a[i]]+=1\n\nfor i in range(N):\n sum+=b[i]*(b[i]-1)//2\nfor i in range(N):\n print(sum-b[a[i]]-1)', 'N=int(input())\na=list(map(int,input().split()))\nb=[0]*N\nsum=0\nfor i in range(N):\n b[a[i]-1]+=1\n\nfor i in range(N):\n sum+=b[i]*(b[i]-1)//2\nfor i in range(N):\n print(sum-b[a[i]-1]+1)']
['Runtime Error', 'Accepted']
['s681130384', 's407320900']
[24748.0, 26140.0]
[335.0, 362.0]
[179, 183]
p02732
u471593927
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.
["#!/usr/bin/python\n# -*- coding: utf-8 -*-\n\n\n\n\n\n\n\nN = int(input())\nA = list(map(int, input().split()))\n\nNumber = []\nTotal = 0\n\nNumber = [A.count(i+1) for i in range(N)]\nTotal = sum([Number[i]*(Number[i]-1)/2 for i in range(N)])\n\n#for Ak in A:\n# print(int(Total - Number[Ak-1]+1))\n\nprint('\\n'.join([str(Total-Number[Ak-1]+1) for Ak in A]))", '\nimport collections\n\n\n\nN = int(input())\nA = list(map(int, input().split()))\n\nC = collections.Counter(A)\n\nTotal = sum([i*(i-1)/2 for i in C.values()])\n\nfor Ak in A:\n print(int(Total - C[Ak]+1))\n\n']
['Wrong Answer', 'Accepted']
['s455623717', 's422996647']
[24744.0, 26780.0]
[2104.0, 396.0]
[482, 232]
p02732
u471641802
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_uni = list(set(a))\n\na_ol = {}\ndef_count = 0\nfor i in a_uni:\n a_co = a.count(i)\n a_ol[i] = a_co\n def_count += a_co * (a_co - 1)\n\ndef_count *= 0.5\n\nfor k in range(n):\n print(def_count - a_ol[a[k]] + 1)\n\n', 'from collections import Counter\nn = int(input())\na = list(map(int, input().split()))\n\n\na_ol = Counter(a)\ndef_count = 0\nfor item in a_ol.items():\n a_co = item[1]\n def_count += a_co * (a_co - 1)\n\ndef_count //= 2\n\nfor k in a:\n print(def_count - a_ol[k] + 1)\n\n']
['Wrong Answer', 'Accepted']
['s053442611', 's626015841']
[26140.0, 26780.0]
[2105.0, 342.0]
[268, 265]
p02732
u476124554
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()))\ndic = {}\nfor i in a:\n s.add(i)\n if i in dic:\n dic[i] +=1\n else:\n dic[i] = 1\n\nans = 0\nfor i in dic.values():\n ans += i * (i - 1) // 2\n\nfor i in a:\n sa = dic[i] * (dic[i] - 1) // 2 - ((dic[i] - 1) * (dic[i] - 2) // 2)\n print(ans - sa)', 'n = int(input())\na = list(map(int,input().split()))\ndic = {}\nfor i in a:\n if i in dic:\n dic[i] +=1\n else:\n dic[i] = 1\n\nans = 0\nfor i in dic.values():\n ans += i * (i - 1) // 2\n\nfor i in a:\n sa = dic[i] * (dic[i] - 1) // 2 - ((dic[i] - 1) * (dic[i] - 2) // 2)\n print(ans - sa)']
['Runtime Error', 'Accepted']
['s483494077', 's996827229']
[24996.0, 25644.0]
[65.0, 391.0]
[316, 303]
p02732
u478266845
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 CountFrequency_mod(my_list): \n \n # Creating an empty dictionary \n freq = {} \n for item in my_list: \n if (item in freq): \n freq[item] += 1\n else: \n freq[item] = 1\n \n freq_mod = freq\n freq_val = list(freq.values())\n all_sum=0\n \n for i in freq_val:\n all_sum+=i*(i-1)/2\n \n for i in freq:\n freq_mod = all_sum - freq[i]*(freq[i]-1)/2 + (freq[i]-1)*(freq[i]-2)/2\n return freq_mod\n\n\nN = int(input())\n\nA = [int(i) for i in input().split()]\n\ndic = CountFrequency_mod(A)\n\nfor i in A:\n print(int(dic[i]))\n ', 'def CountFrequency_mod(my_list): \n \n # Creating an empty dictionary \n freq = {} \n for item in my_list: \n if (item in freq): \n freq[item] += 1\n else: \n freq[item] = 1\n \n freq_mod = freq\n freq_val = list(freq.values())\n all_sum=0\n \n for i in freq_val:\n all_sum+=i*(i-1)/2\n \n for i in freq:\n freq_mod[i] = all_sum - freq[i]*(freq[i]-1)/2 + (freq[i]-1)*(freq[i]-2)/2\n return freq_mod\n\n\nN = int(input())\n\nA = [int(i) for i in input().split()]\n\ndic = CountFrequency_mod(A)\n\nfor i in A:\n print(int(dic[int(i)]))\n ']
['Runtime Error', 'Accepted']
['s542897015', 's981244907']
[26140.0, 26268.0]
[175.0, 413.0]
[596, 604]