ZhenlongDai/ACPR huggingface dataset:
Problem: p02732
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
a=list(map(int,input().split()))
dic={}
for i in range(n):
  if a[i] in dic:
    dic[a[i]]+=1
  else:
    dic[a[i]]=1
ans=0
for i in dic.values():
  if i>1:
    ans+=i*(i-1)/2
for i in range(n):
  bk=dic[a[i]]
  print(int(ans-bk+1) if bk>1 else ans)

Failing test case input:
8
1 3 1 6 2 1 4 1

Expected output:
3
6
3
6
6
3
6
3


Actual output:
3
6.0
3
6.0
6.0
3
6.0
3


Fixed submission (verdict: Accepted):
n=int(input())
a=list(map(int,input().split()))
dic={}
for i in range(n):
  if a[i] in dic:
    dic[a[i]]+=1
  else:
    dic[a[i]]=1
ans=0
for i in dic.values():
  ans+=i*(i-1)/2
for i in range(n):
  bk=dic[a[i]]
  print(int(ans-bk+1 if bk>1 else ans))

Problem: p02732
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import Counter
n = int(input())
s = [int(i) for i in input().split()]

s_set = set(s)

counted = Counter(s)
ans = sum(i*(i-1)/2 for i in counted.values())
print(ans)

for i in s:
    x = counted[i]
    print(int(ans - x + 1))

Failing test case input:
8
2 2 0 5 1 0 4 1

Expected output:
2
2
2
3
2
2
3
2


Actual output:
3.0
2
2
2
3
2
2
3
2


Fixed submission (verdict: Accepted):
from collections import Counter
n = int(input())
s = [int(i) for i in input().split()]

s_set = set(s)

counted = Counter(s)
ans = sum(i*(i-1)/2 for i in counted.values())

for i in s:
    x = counted[i]
    print(int(ans - x + 1))

Problem: p02732
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
a=list(map(int,input().split()))
c=[0]*n

all=0
for i in range(n):
  c[a[i]-1]+=1
for i in range(n):
  if c[i]>=2:
    d=c[i]*(c[i]-1)/2
    all+=d
for i in range(n):
  print(all-(c[a[i]-1]-1))

Failing test case input:
8
0 3 0 3 0 0 4 1

Expected output:
4
6
4
6
4
4
7
7


Actual output:
4.0
6.0
4.0
6.0
4.0
4.0
7.0
7.0


Fixed submission (verdict: Accepted):
n=int(input())
a=list(map(int,input().split()))
c=[0]*n

all=0
for i in range(n):
  c[a[i]-1]+=1
for i in range(n):
  if c[i]>=2:
    d=c[i]*(c[i]-1)/2
    all+=d
for i in range(n):
  print(int(all-(c[a[i]-1]-1)))

Problem: p02732
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import Counter

n = int(input())

a_list = list(map(int, input().split()))

c = Counter(a_list)

all_count = 0
for value in c.values():
    if value == 1:
        continue
    else:
        tmp = int((value * (value - 1))/2)
        all_count += tmp

for i in range(n):
    print(all_count - c[i])


Failing test case input:
8
2 2 0 1 1 0 0 1

Expected output:
6
6
5
5
5
5
5
5


Actual output:
4
4
5
7
7
7
7
7


Fixed submission (verdict: Accepted):
from collections import Counter

n = int(input())

a_list = list(map(int, input().split()))

c = Counter(a_list)

all_count = 0
for value in c.values():
    if value == 1:
        continue
    else:
        tmp = int((value * (value - 1))/2)
        all_count += tmp

for i in a_list:
    print(all_count - c[i] + 1)
Problem: p02732
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import itertools

N=int(input())
A=list(map(int,input().split(' ')))

gr=itertools.groupby(sorted(A))
s=0
dic={}
for x,group in gr:
  l=len(list(group))
  if l >= 2:
    s+=l*(l-1)/2
  dic[x]=l

for k in range(N):
  l=dic[A[k]]
  if l >= 2:
    print(int(s-l*(l-1)/2+(l-1)*(l-2)/2))
  else:
    print(0)
    

Failing test case input:
8
1 3 1 6 2 1 4 1

Expected output:
3
6
3
6
6
3
6
3


Actual output:
3
0
3
0
0
3
0
3


Fixed submission (verdict: Accepted):
import itertools

N=int(input())
A=list(map(int,input().split(' ')))

gr=itertools.groupby(sorted(A))
s=0
dic={}
for x,group in gr:
  l=len(list(group))
  if l >= 2:
    s+=l*(l-1)/2
  dic[x]=l

for k in range(N):
  l=dic[A[k]]
  if l >= 2:
    print(int(s-l*(l-1)/2+(l-1)*(l-2)/2))
  else:
    print(int(s))

Problem: p02732
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import Counter

n = int(input())

a_list = list(map(int, input().split()))

c = Counter(a_list)

all_count = 0
for value in c.values():
    if value == 1:
        continue
    else:
        tmp = int((value * (value - 1))/2)
        all_count += tmp

if all_count == 0:
    all_count = 1

for i in range(n):
    print(all_count - c[i])


Failing test case input:
5
2 1 2 4 5

Expected output:
0
1
0
1
1


Actual output:
1
0
-1
1
0


Fixed submission (verdict: Accepted):
from collections import Counter

n = int(input())

a_list = list(map(int, input().split()))

c = Counter(a_list)

all_count = 0
for value in c.values():
    if value == 1:
        continue
    else:
        tmp = int((value * (value - 1))/2)
        all_count += tmp

for i in a_list:
    print(all_count - c[i] + 1)

Problem: p02732
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import Counter

n = int(input())

a_list = list(map(int, input().split()))

c = Counter(a_list)

all_count = 0
for value in c.values():
    if value == 1:
        continue
    else:
        tmp = int((value * (value - 1))/2)
        all_count += tmp

if all_count == 0:
    all_count = 1

for i in a_list:
    print(all_count - c[i])


Failing test case input:
8
1 2 1 7 3 1 3 1

Expected output:
4
7
4
7
6
4
6
4


Actual output:
3
6
3
6
5
3
5
3


Fixed submission (verdict: Accepted):
from collections import Counter

n = int(input())

a_list = list(map(int, input().split()))

c = Counter(a_list)

all_count = 0
for value in c.values():
    if value == 1:
        continue
    else:
        tmp = int((value * (value - 1))/2)
        all_count += tmp

for i in a_list:
    print(all_count - c[i] + 1)
Problem: p02732
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import Counter
N = int(input())
A = list(map(int,input().split()))

def ch_2(n):
	return n*(n-1)

count=Counter(A)
ans=0
for i in range(len(count)):
	ans+=ch_2(count[A[i]])
print(ans)
for j in range(N):
	ttl=ans
	ttl-=ch_2(count[A[j]])
	ttl+=ch_2(count[A[j]]-1)
	print(int(ttl))







Failing test case input:
8
1 2 1 6 2 0 4 1

Expected output:
2
3
2
4
3
4
4
2


Actual output:
16
12
14
12
16
14
16
16
12


Fixed submission (verdict: Accepted):
from collections import Counter
N = int(input())
A = list(map(int,input().split()))

def ch_2(n):
	
	return n*(n-1)/2

count=Counter(A)

ans=0
for i in count.values():
	ans+=ch_2(i)

for j in range(N):
	ttl=ans
	ttl-=ch_2(count[A[j]])
	ttl+=ch_2(count[A[j]]-1)
	print(int(ttl))

Problem: p02732
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def main():
    import math
    import collections
    N = int(input())
    A = list(map(int, input().split()))
    tt = 0
    
    ann = 0

    def comb(m, n):
        
        return ((m - 1 + 1) / 1) * (m - 2 + 1) / 2

    

    C = collections.Counter(A)
    for i in C.values():
        if i>=2:
            tt = tt + comb(i, 2)

    for i in A:
        f = C[i] 
        if f>=3:
            ann = (tt - comb(f, 2) + comb(f-1, 2))
        elif f==2:
            ann = tt - comb(f, 2)
        else:
            ann = tt
        print(ann)

    
    


if __name__ == '__main__':
    main()

Failing test case input:
5
3 3 3 3 3

Expected output:
6
6
6
6
6

Actual output:
6.0
6.0
6.0
6.0
6.0


Fixed submission (verdict: Accepted):
def main():
    import math
    import collections
    N = int(input())
    A = list(map(int, input().split()))
    tt = 0
    
    ann = 0

    def comb(m, n):
        
        return ((m - 1 + 1) / 1) * (m - 2 + 1) / 2

    

    C = collections.Counter(A)
    for i in C.values():
        if i>=2:
            tt = tt + comb(i, 2)

    for i in A:
        f = C[i] 
        if f>=3:
            ann = (tt - comb(f, 2) + comb(f-1, 2))
        elif f==2:
            ann = tt - comb(f, 2)
        else:
            ann = tt
        print(int(ann))

    
    


if __name__ == '__main__':
    main()

Problem: p02732
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
from collections import Counter

N = int(input())
A = list(map(int, input().split()))

cA = Counter(A)

allS = 0
for key in cA:
    allS += cA[key] * (cA[key] - 1) / 2

for i in range(N):
    if i in cA.keys():
        print(int(allS - (cA[i] - 1)))
    else:
        print(int(allS))

Failing test case input:
8
2 1 1 2 4 1 6 1

Expected output:
6
4
4
6
7
4
7
4


Actual output:
7
4
6
7
7
7
7
7


Fixed submission (verdict: Accepted):
from collections import Counter

N = int(input())
A = list(map(int, input().split()))

cA = Counter(A)

allS = 0
for key in cA:
    allS += cA[key] * (cA[key] - 1) / 2

for i in range(N):
    if A[i] in cA.keys():
        print(int(allS - (cA[A[i]] - 1)))
    else:
        print(int(allS))
Problem: p02732
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
an = list(map(int, input().split()))
n_list = [0]*n

for i in range(n):
  n_list[an[i]-1] += 1

for j in range(n):
  n_list1 = n_list[:]
  n_list1[an[j]-1] -= 1
  answer = 0
  for k in n_list1:
    answer += k*(k-1)/2
  print(answer)
  

Failing test case input:
8
1 1 1 3 1 0 3 1

Expected output:
7
7
7
10
7
11
10
7


Actual output:
7.0
7.0
7.0
10.0
7.0
11.0
10.0
7.0


Fixed submission (verdict: Accepted):
n = int(input())
an = list(map(int, input().split()))
n_list = [0]*n

for i in range(n):
  n_list[an[i]-1] += 1
n_sum = int(sum([x*(x-1)/2 for x in n_list]))

for j in range(n):
  n_remove = n_list[an[j]-1] - 1
  print(n_sum - n_remove)

Problem: p02732
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import itertools

N=int(input())
A=list(map(int,input().split(' ')))

gr=itertools.groupby(sorted(A))
s=0
dic={}
for x,group in gr:
  l=len(list(group))
  if l >= 2:
    s+=l*(l-1)/2
  dic[x]=l

for k in range(N):
  l=dic[A[k]]
  if l >= 2:
    print(int(s-l*(l-1)/2+(l-1)*(l-2)/2))
  else:
    print(s)
    

Failing test case input:
5
1 1 0 -1 0

Expected output:
1
1
1
2
1


Actual output:
1
1
1
2.0
1


Fixed submission (verdict: Accepted):
import itertools

N=int(input())
A=list(map(int,input().split(' ')))

gr=itertools.groupby(sorted(A))
s=0
dic={}
for x,group in gr:
  l=len(list(group))
  if l >= 2:
    s+=l*(l-1)/2
  dic[x]=l

for k in range(N):
  l=dic[A[k]]
  if l >= 2:
    print(int(s-l*(l-1)/2+(l-1)*(l-2)/2))
  else:
    print(int(s))

Problem: p02732
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import collections

x=int(input())
a=list(map(int,input().split()))

c=collections.Counter(a)
num=0
for i in c.values():
    num+=i*(i-1)/2
    
for i in range(x):
    print(num-c[a[i]]+1)

Failing test case input:
8
2 0 2 6 0 0 1 1

Expected output:
4
3
4
5
3
3
4
4


Actual output:
4.0
3.0
4.0
5.0
3.0
3.0
4.0
4.0


Fixed submission (verdict: Accepted):
import collections

x=int(input())
a=list(map(int,input().split()))

c=collections.Counter(a)
num=0
for i in c.values():
    num+=i*(i-1)/2
    
for i in range(x):
    print(int(num-c[a[i]]+1))

Problem: p02732
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
A = list(map(int, input().split()))
B = [[] for i in range(N)]
ans = [0]*N
for k, a in enumerate(A):
    a = a - 1
    B[a].append(k)


S = 0
for b in B:
    lenb = len(b)
    if lenb >= 1:
        S += lenb * (lenb-1) / 2

for i, b in enumerate(B):
    for j, k in enumerate(b):
        ans[k] = int(S - (len(b) - 1))
print(ans)

Failing test case input:
8
2 2 0 5 1 0 4 1

Expected output:
2
2
2
3
2
2
3
2


Actual output:
[2, 2, 2, 3, 2, 2, 3, 2]


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int, input().split()))
B = [[] for i in range(N)]
ans = [0]*N
for k, a in enumerate(A):
    a = a - 1
    B[a].append(k)


S = 0
for b in B:
    lenb = len(b)
    if lenb >= 1:
        S += lenb * (lenb-1) / 2

for i, b in enumerate(B):
    for j, k in enumerate(b):
        ans[k] = int(S - (len(b) - 1))
for i in ans:
    print(i)
Problem: p02732
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):

import sys
def II(): return int(sys.stdin.readline())

def LI(): return list(map(int, sys.stdin.readline().split()))

N = II()
A = LI()

def comb(k):
	if k == 1:
		return 1
	else:
		return int(k*(k-1)/2)

result = 0
kind = list(set(A))
for k in kind:
	result += comb(A.count(k))

for a in A:
	n = A.count(a)
	print(result-n+1)


Failing test case input:
5
0 0 2 1 0

Expected output:
1
1
3
3
1


Actual output:
3
3
5
5
3


Fixed submission (verdict: Accepted):

import sys
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))

N = II()
A = LI()

from collections import Counter
S = Counter(A)
result = sum(list(map(lambda x: int(x*(x-1)/2), S.values())))

for a in A:
	n = S[a]
	print(result-n+1)

Problem: p02732
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import collections 
from collections import Counter
*l, = map(int, input().split())
c = Counter(l)

A = [int(i*(i-1)/2) for i in c.values()]
A_sum = sum(A)

for j in l:
	print(A_sum - c[j] + 1)

Failing test case input:
8
1 6 1 6 2 1 4 1

Expected output:
4
6
4
6
7
4
7
4


Actual output:
0


Fixed submission (verdict: Accepted):
import collections 
from collections import Counter

n = input()
*l, = map(int, input().split())
c = Counter(l)

A = [int(i*(i-1)/2) for i in c.values()]
A_sum = sum(A)

for j in l:
	print(A_sum - c[j] + 1)

Problem: p02732
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import collections

N = int(input())
A = list(map(int, input().split(' ')))


def main(n: int, a: list):
    counter = collections.Counter(a)
    pairs = {k: v * (v - 1) / 2 for k, v in counter.items()}
    pairs_all = sum(pairs.values())

    print(pairs)

    counted = {}

    for i in range(N):

        k = a[i]
        v = counter[k] - 1
        
        pair_cnt = pairs_all - pairs[k] + (v*(v-1)/2)

        
        
        
        
        
        
        
        
        
        
        print(int(pair_cnt))


main(N, A)


Failing test case input:
8
2 1 1 1 4 1 6 1

Expected output:
10
6
6
6
10
6
10
6


Actual output:
{2: 0.0, 1: 10.0, 4: 0.0, 6: 0.0}
10
6
6
6
10
6
10
6


Fixed submission (verdict: Accepted):
import collections

N = int(input())
A = list(map(int, input().split(' ')))


def main(n: int, a: list):
    counter = collections.Counter(a)
    pairs = {k: v * (v - 1) / 2 for k, v in counter.items()}
    pairs_all = sum(pairs.values())

    for i in range(N):
        k = a[i]
        v = counter[k] - 1
        pair_cnt = pairs_all - pairs[k] + (v * (v - 1) / 2)

        print(int(pair_cnt))


main(N, A)
Problem: p02732
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
arr= list(map(int,input().split(' ')))

count={}
for i in range(len(arr)):
    val=arr[i]
    if val not in count.keys():
        count[val]=1
    else:
        count[val]+=1

big_sum=0
for d in count.keys():
    big_sum+= count[d]*(count[d]-1)/2

for a in arr:
    if a in count.keys():
        if count[a]==1:
            print(0)
        else:
            print(int(big_sum-(count[a]-1)))

Failing test case input:
8
2 1 0 5 0 0 4 1

Expected output:
4
3
2
4
2
2
4
3


Actual output:
0
3
2
0
2
2
0
3


Fixed submission (verdict: Accepted):
n=int(input())
arr= list(map(int,input().split(' ')))

count={}
for i in range(len(arr)):
    val=arr[i]
    if val not in count.keys():
        count[val]=1
    else:
        count[val]+=1

big_sum=0
for d in count.keys():
    big_sum+= count[d]*(count[d]-1)/2

for a in arr:
    if a in count.keys():
        if count[a]==1:
            print(int(big_sum))
        else:
            print(int(big_sum-(count[a]-1)))

Problem: p02732
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import defaultdict
n, *D  = [list(map(int, s.split())) for s in open(0)]
D = D[0]
dic = defaultdict(int)
for d1 in D:
    dic[d1] += 1

total_comb = 0
for k in dic:
    if dic[k] >= 2:
        total_comb += dic[k] * (dic[k] - 1) / 2

for d2 in D:
    comb = 0
    if dic[d2] >= 2:
        print(int(total_comb - dic[d2] + 1))
    else:
        print(total_comb)

Failing test case input:
8
1 1 0 3 1 -1 3 1

Expected output:
4
4
7
6
4
7
6
4


Actual output:
4
4
7.0
6
4
7.0
6
4


Fixed submission (verdict: Accepted):
from collections import defaultdict
n, *D  = [list(map(int, s.split())) for s in open(0)]
D = D[0]
dic = defaultdict(int)
for i in D:
    dic[i] += 1

total_comb = 0
for j in dic:
    if dic[j] >= 2:
        total_comb += dic[j] * (dic[j] - 1) / 2
for k in D:
    if dic[k] >= 2:
        print(int(total_comb - dic[k] + 1))
    else:
        print(int(total_comb))

Problem: p02732
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
N = II()
A = list(MI())
ans = 0
cum = {}
def couple_combination(n):
    if n >= 2:
        return int(n * (n - 1) / 2)
    else:
        return 0
for unique in list(set(A)):
    cum_count = A.count(unique)
    cum[unique] = cum_count
    ans += couple_combination(cum_count)
for i in A:
    print(ans - cum[i])


Failing test case input:
8
3 0 0 5 0 1 0 1

Expected output:
7
4
4
7
4
6
4
6


Actual output:
6
3
3
6
3
5
3
5


Fixed submission (verdict: Accepted):
import sys
from collections import defaultdict
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
N = II()
A = list(MI())
ans = 0
cum = defaultdict(int)
def couple_combination(n):
    if n >= 2:
        return int(n * (n - 1) / 2)
    else:
        return 0
for v in A:
    cum[v] += 1
for v in cum.values():
    ans += couple_combination(v)
for v in A:
    print(max(0,ans - cum[v] + 1))
Problem: p02732
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import Counter

N = int(input())
al = list(map(int, input().split()))
C = Counter(al)


ans = 0
for i in C.values():
    ans += i * (i - 1) / 2

for a in al:
    k = C[a]
    print(ans - (k * (k - 1) / 2) + (k - 1) * (k - 2) / 2)


Failing test case input:
5
1 0 2 1 1

Expected output:
1
3
3
1
1


Actual output:
1.0
3.0
3.0
1.0
1.0


Fixed submission (verdict: Accepted):
from collections import Counter

N = int(input())
al = list(map(int, input().split()))
C = Counter(al)


ans = 0
for i in C.values():
    ans += i * (i - 1) / 2

for a in al:
    k = C[a]
    print(int(ans - (k * (k - 1) / 2) + (k - 1) * (k - 2) / 2))

Problem: p02732
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
from collections import Counter
n = input()
res = list(map(int,input().split()))
a = Counter(res)
for i in a.keys():
    a[i] -= 1
    sums = 0
    for j in a.values():
        sums += j * (j - 1) 
    a[i] += 1
    res = [sums if x == i else x for x in res]
for k in res:
    print(k)

Failing test case input:
5
3 3 2 3 3

Expected output:
3
3
6
3
3


Actual output:
6
6
12
6
6


Fixed submission (verdict: Accepted):
from collections import Counter
n = int(input())
res = list(map(int,input().split()))
a = Counter(res)

sums = 0

for i in a.values():
    sums +=  i * (i - 1) 

for j in res:
    print(sums - a[j] * (a[j] -1)

Problem: p02732
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int(input())
A = list(map(int, input().split()))

dic={}
for i in A:
    if i in dic.keys():
        dic[i]+=1
    else:
        dic.setdefault(i,1)

hoge=0
for i in dic.values():
    hoge+=i*(i-1)
hoge =hoge/2

for k in A:
    print(hoge-(dic[k]-1))

Failing test case input:
8
1 0 2 1 2 0 4 1

Expected output:
3
4
4
3
4
4
5
3


Actual output:
3.0
4.0
4.0
3.0
4.0
4.0
5.0
3.0


Fixed submission (verdict: Accepted):
N=int(input())
A = list(map(int, input().split()))

dic={}
for i in A:
    if i in dic.keys():
        dic[i]+=1
    else:
        dic.setdefault(i,1)

hoge=0
for i in dic.values():
    hoge+=i*(i-1)
hoge =int(hoge/2)

for k in A:
    print(hoge-(dic[k]-1))

Problem: p02732
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import Counter

n = int(input())

a_list = list(map(int, input().split()))

c = Counter(a_list)

all_count = 0
for value in c.values():
    if value == 1:
        continue
    else:
        tmp = int((value * (value - 1))/2)
        all_count += tmp

if all_count == 0:
    all_count = 1

for i in a_list:
    print(all_count - c[i] + 1)


Failing test case input:
5
1 4 0 3 2

Expected output:
0
0
0
0
0


Actual output:
1
1
1
1
1


Fixed submission (verdict: Accepted):
from collections import Counter

n = int(input())

a_list = list(map(int, input().split()))

c = Counter(a_list)

all_count = 0
for value in c.values():
    if value == 1:
        continue
    else:
        tmp = int((value * (value - 1))/2)
        all_count += tmp

for i in a_list:
    print(all_count - c[i] + 1)
Problem: p02732
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import itertools

N=int(input())
A=list(map(int,input().split(' ')))

A.sort()
for k in range(N):
  a=A[:k]+A[k+1:]
  gr=itertools.groupby(a)
  s=0
  for _,group in gr:
    l=len(list(group))
    if l>=2:
      s+=int(l*(l-1)/2)
  print(s)

Failing test case input:
5
1 -1 2 0 0

Expected output:
1
1
1
0
0


Actual output:
1
0
0
1
1


Fixed submission (verdict: Accepted):
import itertools

N=int(input())
A=list(map(int,input().split(' ')))

gr=itertools.groupby(sorted(A))
s=0
dic={}
for x,group in gr:
  l=len(list(group))
  if l >= 2:
    s+=l*(l-1)/2
  dic[x]=l

for k in range(N):
  l=dic[A[k]]
  if l >= 2:
    print(int(s-l*(l-1)/2+(l-1)*(l-2)/2))
  else:
    print(int(s))

Problem: p02732
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import math

N = int(input())
A = list(map(int, input().split()))
ans = 0

C = list(set(A))
M = len(C)
t = []
anst = 0
for i in range(M):
  t.append(A.count(C[i]))
  temp = A.count(C[i])
  if temp >=2:
    anst += math.factorial(temp)/(math.factorial(temp-2)*2)




for i in range(N):
  print(t[C.index(A[i])])
  print(int(anst-t[C.index(A[i])]+1))

Failing test case input:
8
2 1 1 2 4 1 6 1

Expected output:
6
4
4
6
7
4
7
4


Actual output:
2
6
4
4
4
4
2
6
1
7
4
4
1
7
4
4


Fixed submission (verdict: Accepted):
import math

N = int(input())
A = list(map(int, input().split()))
ans = 0

C = list(set(A))
M = len(C)
t = []
anst = 0
dic = {}
for i in A:
  if not i in dic:
    dic[i] = 0
  dic[i] += 1

jisyo = {}
for i in range(M):
  temp = dic[C[i]]
  jisyo[C[i]] = temp
  
  if temp >=2:
    anst += temp*(temp-1)/2



for i in range(N):
  
  print(int(anst-jisyo[A[i]]+1))

Problem: p02732
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import Counter
from copy import deepcopy

n = int(input())
a = list(map(int, input().split()))
c = Counter(a)

for i in range(n):
    tmp_c = deepcopy(c)
    ans = 0
    tmp_c[a[i]] -= 1
    for v in tmp_c.values():
        ans += v*(v-1)/2
    print(ans)


Failing test case input:
8
1 2 0 3 1 -1 3 1

Expected output:
2
4
4
3
2
4
3
2


Actual output:
2.0
4.0
4.0
3.0
2.0
4.0
3.0
2.0


Fixed submission (verdict: Accepted):
from collections import Counter

n = int(input())
a = list(map(int, input().split()))
c = Counter(a)
all_comb = 0
for v in c.values():
    all_comb += v*(v-1)/2

for i in range(n):
    tmp = c[a[i]]
    print(int(all_comb-tmp+1))
Problem: p02732
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import math
import collections
def calc_combi2(n):
    if n<=1:
        return 0
    return math.factorial(n)/(math.factorial(n-2)*math.factorial(2))
n=int(input())
data=list(map(int,input().split()))
data_cnt=collections.Counter(data)
count=0
for i in data_cnt.values():
    if 2<=i:
        count+=calc_combi2(i)
for i in data:
    if i<=1:
        print(count)
    else:
        ans=count+(calc_combi2(data_cnt[i]-1)-calc_combi2(data_cnt[i]))
        print(int(ans))

Failing test case input:
8
2 2 0 1 1 0 0 0

Expected output:
7
7
5
7
7
5
5
5


Actual output:
7
7
8.0
8.0
8.0
8.0
8.0
8.0


Fixed submission (verdict: Accepted):
import math
import collections
def calc_combi2(n):
    if n<=1:
        return 0
    return math.factorial(n)/(math.factorial(n-2)*math.factorial(2))
n=int(input())
data=list(map(int,input().split()))
data_cnt=collections.Counter(data)
count=0
for i in data_cnt.values():
    count+=calc_combi2(i)
for i in data:
    ans=count-data_cnt[i]+1
    print(int(ans))

Problem: p02732
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
l = list(map(int, input().split()))

ans = 0

k = [0 for _ in range(n+1)]

for i in range(n):
    k[l[i]] += 1
    
ll = len(k)
for i in range(ll):
    a = k[i]
    if a <= 1:
        pass
    else:
        ans += (a * (a - 1))/2
        
for i in range(n):
    a = k[l[i]]
    b = (a * (a - 1))/2
    c = a - 1
    if c <= 1:
        print(int(ans))
    else:
        pans = ans - b
        c = (c * (c - 1))/2
        pans = pans + c
        print(int(pans))

Failing test case input:
8
2 2 0 1 1 0 4 1

Expected output:
4
4
4
3
3
4
5
3


Actual output:
5
5
5
3
3
5
5
3


Fixed submission (verdict: Accepted):
n = int(input())
l = list(map(int, input().split()))

ans = 0

k = [0 for _ in range(n+1)]

for i in range(n):
    k[l[i]] += 1
    
ll = len(k)
for i in range(ll):
    a = k[i]
    if a <= 1:
        pass
    else:
        ans += (a * (a - 1))/2
        
for i in range(n):
    a = k[l[i]]
    b = (a * (a - 1))/2
    c = a - 1
    if a < 1:
        print(int(ans))
    else:
        pans = ans - b
        c = (c * (c - 1))/2
        pans = pans + c
        print(int(pans))

Problem: p02732
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import sys
N=int(sys.stdin.readline())
L=list(map(int,sys.stdin.readline().split()))
count=[0]*N
C=list(set(L))
x=0
for i in range(len(C)):
  x += int((L.count(C[i]))*(L.count(C[i])-1)/2)  
for K in range(N):
  print(x-L.count(L[K])-1)


Failing test case input:
8
2 0 0 1 1 -1 0 1

Expected output:
6
4
4
4
4
6
4
4


Actual output:
4
2
2
2
2
4
2
2


Fixed submission (verdict: Accepted):
import sys
from collections import Counter
N=int(sys.stdin.readline())
L=list(map(int,sys.stdin.readline().split()))
C=Counter(L)
x=0
for a in C.values():
  x += int(a*(a-1)/2)  
for K in range(N):
  print(x-C[L[K]]+1)
Problem: p02732
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int(input())
A=list(map(int,input().split()))
dic={}
for a in A:
  if a in dic:
    dic[a]+=1
  else:
    dic[a]=1
   
print(dic)
c=0
for i in dic.values():
  c+=i*(i-1)/2
for j in range(1,N+1):
  d=c-dic[A[j-1]]+1
  print(int(d))
  

Failing test case input:
8
1 3 1 6 2 0 4 1

Expected output:
1
3
1
3
3
3
3
1


Actual output:
{1: 3, 3: 1, 6: 1, 2: 1, 0: 1, 4: 1}
1
3
1
3
3
3
3
1


Fixed submission (verdict: Accepted):
N=int(input())
A=list(map(int,input().split()))
dic={}
for a in A:
  if a in dic:
    dic[a]+=1
  else:
    dic[a]=1
   

c=0
for i in dic.values():
  c+=i*(i-1)/2
for j in range(1,N+1):
  d=c-dic[A[j-1]]+1
  print(int(d))

Problem: p02732
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
a=list(map(int, input().split()))
import collections
import math
def combinations_count2(n):
    if(n<=1):
        answer=0
    else:
        answer=n*(n-1)/2
    return answer

table=collections.Counter(a)
keytable=table.keys()
c=[]

for key in keytable:
    c.append(table[key])

ca=[]
for j in range(len(c)):
    ca.append(c[j]*(c[j])/2)

sums=sum(ca)



for i in range(len(a)):
    keynum=list(keytable).index(a[i])
    answer=sums-ca[keynum]+(c[keynum]-1)*(c[keynum]-2)/2
    print(int(answer))

Failing test case input:
8
1 2 1 4 2 1 4 1

Expected output:
5
7
5
7
7
5
7
5

Actual output:
7
10
7
10
10
7
10
7


Fixed submission (verdict: Accepted):
n=int(input())
a=list(map(int, input().split()))
import collections
import math
def combinations_count2(n):
    if(n<=1):
        answer=0
    else:
        answer=n*(n-1)/2
    return answer

table=collections.Counter(a)
keytable=table.keys()
sums=0
for value in table.values():
    sums+=combinations_count2(value)




for i in range(len(a)):
    answer=sums-table[a[i]]+1
    print(int(answer))

Problem: p02732
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
An = [int(x) for x in input().split()]  
 

s = 0
for i in range(1,N+1):
    b = An.count(i)
    if b > 1:
        s += b*(b-1) / 2

for k in range(N):
    print(s - (An.count(An[k])-1))

Failing test case input:
5
3 3 2 3 3

Expected output:
3
3
6
3
3


Actual output:
3.0
3.0
6.0
3.0
3.0


Fixed submission (verdict: Accepted):
import collections as c


N = int(input())
An = [int(x) for x in input().split()]
 

Cn = c.Counter(An)
 

s = 0
for v in Cn.values():
    s += int(v*(v-1) / 2)

for i in range(0,N):
    print(s - (Cn[An[i]] - 1))
Problem: p02732
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
K = list(map(int, input().split()))
counter = dict()
for i in range(N):
  if K[i] not in counter:
  	counter[K[i]] = 1
  else:
   	counter[K[i]] += 1

results = 0
remove_counter = dict()
for key, value in counter.items():
  remove_counter[key] = (value * (value - 1) / 2) - ((value - 1) * (value - 2) / 2)
  results += value * (value - 1) / 2
for i in range(N):
  print(results - remove_counter[K[i]])

Failing test case input:
8
2 4 1 6 2 0 4 0

Expected output:
2
2
3
3
2
2
2
2


Actual output:
2.0
2.0
3.0
3.0
2.0
2.0
2.0
2.0


Fixed submission (verdict: Accepted):
N = int(input())
K = list(map(int, input().split()))
counter = dict()
for i in range(N):
  if K[i] not in counter:
  	counter[K[i]] = 1
  else:
   	counter[K[i]] += 1

results = 0
remove_counter = dict()
for key, value in counter.items():
  remove_counter[key] = (value * (value - 1) / 2) - ((value - 1) * (value - 2) / 2)
  results += value * (value - 1) / 2
for i in range(N):
  print(int(results - remove_counter[K[i]]))

Problem: p02732
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
m = int(input())
q_list = list(map(int, input().strip().split()))
n = [0] * m
k = [0] * m

for i in q_list:
    n[i - 1] += 1
for j, l in zip(range(m), n):
    k[j] = int(l * (l - 1)/2)
sum_n = sum(k)

for j in q_list:
    print(sum_n - n[j - 1]-1)


Failing test case input:
8
1 0 1 0 2 0 4 1

Expected output:
4
4
4
4
6
4
6
4


Actual output:
2
2
2
2
4
2
4
2


Fixed submission (verdict: Accepted):
m = int(input())
q_list = list(map(int, input().strip().split()))
n = [0] * m
k = [0] * m

for i in q_list:
    n[i - 1] += 1
for j, l in zip(range(m), n):
    k[j] = int(l * (l - 1)/2)
sum_n = sum(k)

for j in q_list:
    print(sum_n - n[j - 1] + 1)

Problem: p02732
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N = int(input())
A = list(map(int,input().split()))
num = [0 for i in range(N)]
ans = []
for i in A:
    num[i-1]+=1
sums = 0
print(num)
for i in A:
    num[i-1]-=1
    for j in range(N):
        if num[j] > 1:
            sums += 1/2*num[j]*(num[j]-1)
    ans.append(int(sums))
    sums = 0
    num[i-1]+=1

print(ans)

Failing test case input:
8
1 0 1 0 1 0 4 1

Expected output:
6
7
6
7
6
7
9
6


Actual output:
[4, 0, 0, 1, 0, 0, 0, 3]
[6, 7, 6, 7, 6, 7, 9, 6]


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int,input().split()))
num = [0 for i in range(N)]
zu = 0
ans = []
for i in A:
    num[i-1]+=1
for i in range(N):
    temp = 1/2*num[i]*(num[i]-1)
    zu += temp
for i in A:
    kawari =zu
    temp1 = 1/2*num[i-1]*(num[i-1]-1)
    num[i-1] -= 1
    temp2 = 1/2*num[i-1]*(num[i-1]-1)
    kawari += -temp1+temp2
    num[i-1] += 1
    print(int(kawari))
Problem: p02732
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def cmb(n):
    return n * (n-1) / 2

def main():

    N = int(input())

    a_l = [0] * N

    nums = list(map(int, input().split()))

    for i in nums:
        a_l[i-1] += 1

    for i in nums:
        a_l[i-1] -= 1
        total = 0
        for j in a_l:
            if j > 1:
                total += cmb(j)
        print(total)
        a_l[i-1] += 1


if __name__ == '__main__':
    main()

Failing test case input:
8
2 0 1 6 0 0 1 1

Expected output:
6
4
4
6
4
4
4
4


Actual output:
6.0
4.0
4.0
6.0
4.0
4.0
4.0
4.0


Fixed submission (verdict: Accepted):
def cmb(n):
    return int(n * (n-1) / 2)

def main():

    N = int(input())

    a_l = [0] * N

    nums = list(map(int, input().split()))
    for i in nums:
        a_l[i-1] += 1

    total = 0
    for j in a_l:
        if j > 1:
            total += cmb(j)

    for k in nums:
        if a_l[k-1] > 1:
            print(total - cmb(a_l[k-1]) + cmb(a_l[k-1] - 1))
        else:
            print(total)


if __name__ == '__main__':
    main()

Problem: p02732
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
def nc2(n):
    if n==0:
        return 0
    return n*(n-1)/2


n=int(input())
arr=[int(i) for i in input().strip().split(" ")]
ans=0
dic={}
for i in arr:
    dic[i]=dic.get(i,0)+1
for i in dic:
    if dic[i]==1 :
        continue
    ans+=nc2(dic[i])
    
print(dic)

for i in range(n):
    curr_nc2=nc2(dic[arr[i]])
    
    print(int(ans-curr_nc2+nc2(dic[arr[i]]-1)))
    

Failing test case input:
5
1 -1 2 0 0

Expected output:
1
1
1
0
0


Actual output:
{1: 1, -1: 1, 2: 1, 0: 2}
1
1
1
0
0


Fixed submission (verdict: Accepted):
def nc2(n):
    if n==0:
        return 0
    return n*(n-1)/2


n=int(input())
arr=[int(i) for i in input().strip().split(" ")]
ans=0
dic={}
for i in arr:
    dic[i]=dic.get(i,0)+1
for i in dic:
    if dic[i]==1 :
        continue
    ans+=nc2(dic[i])
    


for i in range(n):
    curr_nc2=nc2(dic[arr[i]])
    
    print(int(ans-curr_nc2+nc2(dic[arr[i]]-1)))

Problem: p02732
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import Counter
from copy import deepcopy

n = int(input())
a = list(map(int, input().split()))
c = Counter(a)
all_comb = 0
for v in c.values():
    all_comb += v*(v-1)/2

for i in range(n):
    tmp = c[a[i]]
    print(all_comb-tmp+1)


Failing test case input:
8
2 2 1 6 2 0 4 1

Expected output:
2
2
3
4
2
4
4
3


Actual output:
2.0
2.0
3.0
4.0
2.0
4.0
4.0
3.0


Fixed submission (verdict: Accepted):
from collections import Counter

n = int(input())
a = list(map(int, input().split()))
c = Counter(a)
all_comb = 0
for v in c.values():
    all_comb += v*(v-1)/2

for i in range(n):
    tmp = c[a[i]]
    print(int(all_comb-tmp+1))
Problem: p02732
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
input=sys.stdin.readline
N = int(input())
A = list(map(int,input().split()))
nCr = {}
def cmb(n):
    if n == 1:
        return 0
    else:
        return n * n-1 /2
mydict = {}
for i in range(N):
    a = A[i]
    if a in mydict.keys():
        mydict[a] += 1
    else:
        mydict[a] = 1
for i in range(N):
    s = 0
    a = A[i]
    mydict[a] -= 1
    for j in mydict.values():
        s += cmb(j)
    print(s)
    mydict[a] += 1

Failing test case input:
8
2 0 0 1 1 -1 0 0

Expected output:
7
4
4
6
6
7
4
4


Actual output:
18.5
12.0
12.0
15.5
15.5
18.5
12.0
12.0


Fixed submission (verdict: Accepted):
import sys
input=sys.stdin.readline
N = int(input())
A = list(map(int,input().split()))
def cmb(n):
    if n == 1:
        return 0
    else:
        return n * (n-1) /2
mydict = {}
for i in range(N):
    a = A[i]
    if a in mydict.keys():
        mydict[a] += 1
    else:
        mydict[a] = 1
s = 0
for i in mydict.values():
	s += cmb(i)
for i in range(N):
    a = A[i]
    x = mydict[a] - 1
    print(int(s-x))

Problem: p02732
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
A = [int(i) for i in input().split()]

c = []
sum = 0

for j in A:
    _ = A.count(j)
    c.append(_)
    sum += int(_ * (_ - 1) / 2)

s = ""
for k in range(N):
    s += str(sum - c[k] + 1) + "\n"
print(s)

Failing test case input:
8
2 1 1 5 0 0 4 1

Expected output:
4
2
2
4
3
3
4
2


Actual output:
11
9
9
11
10
10
11
9



Fixed submission (verdict: Accepted):
import collections

N = int(input())
A = [int(i) for i in input().split()]

u = collections.Counter(A)
sum = 0
for j, c in u.items():
    sum += int(c * (c - 1) / 2)

s = ""
for k in A:
    s += str(sum - u[k] + 1) + "\n"
print(s)

Problem: p02732
Buggy submission (Python (3.8.2), verdict: Wrong Answer):

def get_int():
	return int(input())

def get_ints():
	return list(map(int, input().split()))



def choose2(n):
    return n*(n-1)/2
  

N = get_int()
An = get_ints()

uni = [0] * (N+1)

for i in range(N):
    uni[An[i]] += 1
sumWay = 0

for i in range(N):
    sumWay += choose2(uni[i])

for i in range(N):
    print(sumWay - choose2(uni[An[i]]) + choose2(uni[An[i]]-1)) 


Failing test case input:
5
0 0 2 1 0

Expected output:
1
1
3
3
1


Actual output:
1.0
1.0
3.0
3.0
1.0


Fixed submission (verdict: Accepted):

def get_int():
	return int(input())

def get_ints():
	return list(map(int, input().split()))

import math

def choose2(n):
    return math.floor(n*(n-1)/2)


N = get_int()
An = get_ints()

uni = [0] * (N+1)

for i in range(N):
    uni[An[i]] += 1
sumWay = 0

for i in range(N+1):
    sumWay += choose2(uni[i])

for i in range(N):
    print(sumWay - choose2(uni[An[i]]) + choose2(uni[An[i]]-1))
Problem: p02732
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import collections
import math
N = int(input())
A = list(map(int, input().split(' ')))
c = collections.Counter(A)
d1 = {}
d2 = {}
for i in c:
    d1[str(i)] = (c[i]*(c[i]-1))/2
    d2[str(i)] = ((c[i]-1)*(c[i]-2))/2

s = sum(d1.values())

print(c)
for i in range(N):
    ans = s - d1[str(A[i])]+d2[str(A[i])]
    print(int(ans))


Failing test case input:
8
2 0 2 6 0 0 1 1

Expected output:
4
3
4
5
3
3
4
4


Actual output:
Counter({0: 3, 2: 2, 1: 2, 6: 1})
4
3
4
5
3
3
4
4


Fixed submission (verdict: Accepted):
import collections
import math
N = int(input())
A = list(map(int, input().split(' ')))
c = collections.Counter(A)
d1 = {}
d2 = {}
for i in c:
    d1[str(i)] = (c[i]*(c[i]-1))/2
    d2[str(i)] = ((c[i]-1)*(c[i]-2))/2

s = sum(d1.values())

for i in range(N):
    ans = s - d1[str(A[i])]+d2[str(A[i])]
    print(int(ans))

Problem: p02732
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import math

def comb(n, r):
  return math.factorial(n) 

n = (int)(input())
a = list(map(int, input().split(" ")))
temp = [0 for i in range(n + 1)]
aaa = sorted(a)
count = 0
for i in range(n - 1):
  if aaa[i] == aaa[i + 1]:
    count+= 1
  else:
    temp[aaa[i]] = count + 1
    count = 0
else:
  if len(a) == 1:
    temp[aaa[0]] = 1
  else:
    temp[aaa[-1]] = count + 1
ans = 0

for i in range(n + 1):
  if temp[i] >= 2:
    ans += comb(temp[i], 2)

Failing test case input:
8
1 2 1 4 1 1 7 2

Expected output:
4
6
4
7
4
4
7
6


Actual output:

Fixed submission (verdict: Accepted):
n = (int)(input())
a = list(map(int, input().split(" ")))
temp = [0 for i in range(n + 1)]
aaa = sorted(a)
count = 0
for i in range(n - 1):
  if aaa[i] == aaa[i + 1]:
    count+= 1
  else:
    temp[aaa[i]] = count + 1
    count = 0
else:
  if len(a) == 1:
    temp[aaa[0]] = 1
  else:
    temp[aaa[-1]] = count + 1
ans = 0




for i in range(n + 1):
  if temp[i] >= 2:
    ans += temp[i] * (temp[i] - 1) / 2
    




for i in range(n):
  kotae = ans
  if temp[a[i]] >= 3:
    
    
    kotae = ans - (temp[a[i]] * (temp[a[i]] - 1) / 2) + ((temp[a[i]] - 1) * (temp[a[i]] - 2) / 2)
  elif temp[a[i]] == 2:
    kotae = ans -1
  print((int)(kotae))

Problem: p02732
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
*li,=map(int, input().split())
from collections import Counter
c = Counter()
for i in li:
    c[i] += 1
ans=0
from math import comb
for i in c.values():
    ans += comb(i, 2)
for i in li:
    print(ans - comb(c[i], 2) + comb(c[i-1], 2))
  

Failing test case input:
4
2 2 2 4

Expected output:
1
1
1
3


Actual output:
0
0
0
3


Fixed submission (verdict: Accepted):
n = int(input())
*li,=map(int, input().split())
from collections import Counter
c = Counter()
for i in li:
    c[i] += 1
ans=0
from math import comb
for i in c.values():
    ans += comb(i, 2)
for i in li:
    print(ans - comb(c[i], 2) + comb(c[i]-1, 2))
Problem: p02732
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = list(map(int,input().split()))
d = {}
aa = [0]
for i in range(1,n):
	aa.append(aa[-1]+i)
for i in a:
	if i not in d:
		d[i] = 1
	else:
		d[i]+=1
s = 0
for i in d:
	s+=aa[d[i]-1]
dd = {}
for i in d:
	if i not in dd:
		if d[i]!=1:
			dd[i] = (s-aa[d[i]-1]+aa[d[i]-2])
		else:
			dd[i] = 0
print(dd)
for i in a:
	print(dd[i])

Failing test case input:
8
1 2 1 6 2 1 4 1

Expected output:
4
6
4
7
6
4
7
4


Actual output:
{1: 4, 2: 6, 6: 0, 4: 0}
4
6
4
0
6
4
0
4


Fixed submission (verdict: Accepted):
n = int(input())
a = list(map(int,input().split()))
d = {}
aa = [0,0]
for i in range(1,n):
	aa.append(aa[-1]+i)
for i in a:
	if i not in d:
		d[i] = 1
	else:
		d[i]+=1
s = 0
for i in d:
	s+=aa[d[i]]
dd = {}
for i in d:
	if i not in dd:
		dd[i] = (s-aa[d[i]]+aa[d[i]-1])
for i in a:
	print(dd[i])

Problem: p02732
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import Counter
N = int(input())
A = list(map(int,input().split()))

def ch_2(n):
	return n*(n-1)/2

count=Counter(A)
ans=0
for i in range(len(count)):
	ans+=ch_2(count[i])
for j in range(N):
	print(ans-ch_2(count[A[j]]-1))







Failing test case input:
8
2 0 0 1 1 0 0 0

Expected output:
11
7
7
10
10
7
7
7


Actual output:
11.0
5.0
5.0
11.0
11.0
5.0
5.0
5.0


Fixed submission (verdict: Accepted):
from collections import Counter
N = int(input())
A = list(map(int,input().split()))

def ch_2(n):
	
	return n*(n-1)/2

count=Counter(A)

ans=0
for i in count.values():
	ans+=ch_2(i)

for j in range(N):
	ttl=ans
	ttl-=ch_2(count[A[j]])
	ttl+=ch_2(count[A[j]]-1)
	print(int(ttl))

Problem: p02732
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import math
 
def permutations_count(n, r):
    if r == 2:
        return int( (n*(n-1) ) / r )
    if r == 1:
        return n
 
 
N = int(input())
A = list(map(int,input().split()))
 
data = [0] * (N+1)
 
for i in range(N):
    data[A[i]] += 1
 
total = 0
 
for i in range(N+1):
    if data[i] >= 2:
        total += permutations_count(data[i],2)
 
 
 
for i in range(N):
    if data[A[i]] - 1 > 0 :
        print( total - permutations_count(data[A[i]]-1,1) )
    else:
        print(total)

print(permutations_count(3,1))

Failing test case input:
8
1 3 1 6 2 0 4 1

Expected output:
1
3
1
3
3
3
3
1


Actual output:
1
3
1
3
3
3
3
1
3


Fixed submission (verdict: Accepted):
import math
 
def permutations_count(n, r):
    if r == 2:
        return int( (n*(n-1) ) / r )
    if r == 1:
        return n
 
 
N = int(input())
A = list(map(int,input().split()))
 
data = [0] * (N+1)
 
for i in range(N):
    data[A[i]] += 1
 
total = 0
 
for i in range(N+1):
    if data[i] >= 2:
        total += permutations_count(data[i],2)
 
 
 
for i in range(N):
    if data[A[i]] - 1 > 0 :
        print( total - permutations_count(data[A[i]]-1,1) )
    else:
        print(total)
Problem: p02732
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
B = Counter(A)

tmp = 0
for i in range(N):
    tmp += B[i]*(B[i]-1)

for k in range(N):
    print(tmp-B[A[k]]+1)

Failing test case input:
8
1 1 2 1 2 0 4 1

Expected output:
4
4
6
4
6
7
7
4


Actual output:
11
11
13
11
13
14
14
11


Fixed submission (verdict: Accepted):
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
B = Counter(A)

ans = 0
for i in B.values():
    ans += i*(i-1)

for a in A:
    k = B[a]
    print(ans - (k*(k-1)

Problem: p02732
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import Counter

n = int(input())

a_list = list(map(int, input().split()))

c = Counter(a_list)

all_count = 0
for value in c.values():
    if value == 1:
        continue
    else:
        tmp = int((value * (value - 1))/2)
        all_count += tmp

print(all_count)

for i in range(n):
    print(all_count - c[i])


Failing test case input:
8
2 1 1 5 0 0 4 1

Expected output:
4
2
2
4
3
3
4
2


Actual output:
4
2
1
3
4
3
3
4
4


Fixed submission (verdict: Accepted):
from collections import Counter

n = int(input())

a_list = list(map(int, input().split()))

c = Counter(a_list)

all_count = 0
for value in c.values():
    if value == 1:
        continue
    else:
        tmp = int((value * (value - 1))/2)
        all_count += tmp

for i in a_list:
    print(all_count - c[i] + 1)

Problem: p02732
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import collections

n = int(input())
a = [int(i) for i in input().split(' ')]
c = collections.Counter(a)
counts = {}
all_sum = 0
for k, v in c.items():
    val = v * (v-1) / 2
    counts[k] = val
    all_sum += val

for i in range(n):
    k = a[i]
    count = c[k] - 1
    val = counts[k]
    print(all_sum - val + count * (count - 1) / 2)


Failing test case input:
8
2 4 1 6 2 0 4 -1

Expected output:
1
1
2
2
1
2
1
2


Actual output:
1.0
1.0
2.0
2.0
1.0
2.0
1.0
2.0


Fixed submission (verdict: Accepted):
import collections

n = int(input())
a = [int(i) for i in input().split(' ')]
c = collections.Counter(a)
counts = {}
all_sum = 0
for k, v in c.items():
    val = v * (v-1) / 2
    counts[k] = val
    all_sum += val

for i in range(n):
    k = a[i]
    count = c[k] - 1
    val = counts[k]
    print(int(all_sum - val + count * (count - 1) / 2))

Problem: p02732
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = [int(x) for x in input().split()]
from collections import defaultdict
d = defaultdict(int)
for i in a:
  d[i] += 1

total = 0
for i in set(a):
  x = d[i]
  total += x*(x-1)/2

for i in a:
  x = d[i]
  print(int(total-(x*(x-1)/2)))

Failing test case input:
8
2 0 1 6 0 0 3 1

Expected output:
4
2
3
4
2
2
4
3


Actual output:
4
1
3
4
1
1
4
3


Fixed submission (verdict: Accepted):
n = int(input())
a = [int(x) for x in input().split()]
from collections import defaultdict
d = defaultdict(int)
for i in a:
  d[i] += 1

total = 0
for i in set(a):
  x = d[i]
  total += x*(x-1)/2

for i in a:
  x = d[i]
  print(int(total-((x*(x-1)/2))+((x-1)*(x-2)/2)))
Problem: p02732
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
nums = list(map(int, input().split()))

print(nums)

values = {}
for i in nums:
  if i in values: values[i] += 1
  else: values[i] = 1

sums={} 
subsums={} 
allsum = 0
for k,v in values.items():
  sums[k] = v * (v - 1) / 2
  undersum = (v - 2) * (v - 1) / 2 if v > 1 else 0
  subsums[k] = sums[k] - undersum
  allsum += sums[k]




for i in nums:
  print(int(allsum - subsums[i]))


Failing test case input:
5
0 0 2 1 0

Expected output:
1
1
3
3
1


Actual output:
[0, 0, 2, 1, 0]
1
1
3
3
1


Fixed submission (verdict: Accepted):
n = int(input())
nums = list(map(int, input().split()))

values = {}
for i in nums:
  if i in values: values[i] += 1
  else: values[i] = 1

sums={} 
subsums={} 
allsum = 0
for k,v in values.items():
  sums[k] = v * (v - 1) / 2
  undersum = (v - 2) * (v - 1) / 2 if v > 1 else 0
  subsums[k] = sums[k] - undersum
  allsum += sums[k]




for i in nums:
  print(int(allsum - subsums[i]))

Problem: p02732
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import Counter

N = int(input())
A_array = map(int, input().split())
Ai_dict = Counter(A_array)


def calc_comb(Ai, dictionary):
    num = 0
    for k,v in dictionary.items():
        if k == Ai:
            N_Ai = v -1 
        else:
            N_Ai = v
        num += N_Ai*(N_Ai-1)/2
    return int(num)

for n in A_array:
    print(calc_comb(n, Ai_dict))


Failing test case input:
5
3 3 3 0 3

Expected output:
3
3
3
6
3


Actual output:

Fixed submission (verdict: Accepted):
from collections import Counter

N = int(input())
A_array = list(map(int, input().split()))
Ai_dict = Counter(A_array)


def calc_comb(dct):
    num = 0
    for k,v in dct.items():
        num += v*(v-1)/2
    return int(num)


res_dict = dict([])
TotalComb = calc_comb(Ai_dict)

for n in A_array:
    if not n in res_dict.keys():
        res_dict[n] = TotalComb - Ai_dict[n]+1
    print(res_dict[n])

Problem: p02732
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import collections

def check(A):
    count = 0
    for j in A:
        n = A[j]
        if n > 1:
            count += n * (n - 1) / 2
            
    return int(count)


N = int(input())
A = list(map(int, input().split(" ")))
A2 = collections.Counter(A)
print(A2)
Nsum = check(A2)

for i in range(0,N):
    num = A[i]
    count = A2[num]
    out = Nsum - ( count - 1 )
    print(out)

Failing test case input:
8
0 6 1 6 2 1 4 1

Expected output:
4
3
2
3
4
2
4
2


Actual output:
Counter({1: 3, 6: 2, 0: 1, 2: 1, 4: 1})
4
3
2
3
4
2
4
2


Fixed submission (verdict: Accepted):
import collections

def check(A):
    count = 0
    for j in A:
        n = A[j]
        if n > 1:
            count += n * (n - 1) / 2
            
    return int(count)


N = int(input())
A = list(map(int, input().split(" ")))
A2 = collections.Counter(A)

Nsum = check(A2)

for i in range(0,N):
    num = A[i]
    count = A2[num]
    out = Nsum - ( count - 1 )
    print(out)