Buggy python submission (verdict: Time Limit Exceeded):
import collections

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

ans=0
B=collections.Counter(A)

keys=list(B.keys())
values=list(B.values())

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


for j in A:
    ANS=ans
    num=values[keys.index(j)]
    ANS=ANS-(num-1)
    print(ANS)

Fixed submission:
import collections

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

ans=0
dic=collections.Counter(A)
keys=list(dic.keys())
values=list(dic.values())


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

for j in A:
    ANS=ans
    num=dic[j]
    ANS=ANS-(num-1)
    print(ANS)

Buggy python submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))

shim0=[-1 for i in range(N)]
real_ans=0
ans1=list(set(A))
for k in range(len(ans1)):
    num_k=A.count(ans1[k])
    real_ans+=(num_k*(num_k-1))//2
    
    
for i in range(N):
    if shim0[A[i]]!=-1:
        print(shim0[A[i]])
    else:
        num=A.count(A[i])
        re_ans=real_ans-(num-1)
        shim0[A[i]]=re_ans
        print(shim0[A[i]])
        

Fixed submission:
import collections

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

ans=0
dic=collections.Counter(A)
keys=list(dic.keys())
values=list(dic.values())


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

for j in A:
    ANS=ans
    num=dic[j]
    ANS=ANS-(num-1)
    print(ANS)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))

real_ans=0
ans1=list(set(A))
for k in range(len(ans1)):
    num_k=A.count(ans1[k])
    real_ans+=(num_k*(num_k-1))//2

for i in range(N):
    num=A.count(A[i])
    re_ans=real_ans-(num-1)
    print(re_ans)

Fixed submission:
import collections

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

ans=0
dic=collections.Counter(A)
keys=list(dic.keys())
values=list(dic.values())


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

for j in A:
    ANS=ans
    num=dic[j]
    ANS=ANS-(num-1)
    print(ANS)

Buggy python submission (verdict: Time Limit Exceeded):
import collections
N=int(input())
A=list(map(int,input().split()))

real_ans=0
ans1=len(set(A))
ans2=collections.Counter(A)
ANS=list(ans2.values())

for j in range(ans1):
    real_ans+=(ANS[j]*(ANS[j]-1))//2
    
for i in range(N):
    num=A.count(A[i])
    re_ans=real_ans-(num-1)
    print(re_ans)

Fixed submission:
import collections

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

ans=0
dic=collections.Counter(A)
keys=list(dic.keys())
values=list(dic.values())


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

for j in A:
    ANS=ans
    num=dic[j]
    ANS=ANS-(num-1)
    print(ANS)

Buggy python submission (verdict: Time Limit Exceeded):
import collections
N=int(input())
A=list(map(int,input().split()))


for i in range(N):
    B=A[0:i]+A[i+1:N]
    ans1=len(set(B))
    ans2=collections.Counter(B)
    ANS=list(ans2.values())
    real_ans=0
    for j in range(ans1):
        real_ans+=(ANS[j]*(ANS[j]-1))//2
    print(real_ans)

Fixed submission:
import collections

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

ans=0
dic=collections.Counter(A)
keys=list(dic.keys())
values=list(dic.values())


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

for j in A:
    ANS=ans
    num=dic[j]
    ANS=ANS-(num-1)
    print(ANS)