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

N=int(input())
A=deque(map(int,input().split()))
setA=set(A)
number1={}#-1
number2={}
ans={}
if(len(setA)==1):
    answer= len(A) - 1
    q=(answer - 1) * answer //2
    for _ in range(len(A)):
        print(q)
    sys.exit()


if(len(setA)==len(A)):
    for _ in range(len(A)):
        print(0)
    sys.exit()


for i in setA:
    tmp=A.count(i) - 1
    souwa=(tmp - 1)*(tmp)//2
    number1[i]=souwa
    souwa=tmp*(tmp+1)//2
    number2[i]=souwa
    total=number1[i]
    total-=number2[i]
    ans[i]=total
t=sum(number2.values())

for a in A:
    print(ans[a]+t)




Fixed submission:
from collections import Counter
N = int(input())
A = list(map(int,input().split()))
d=Counter(A)
dic={}
total=0
for item in d.items():
    counter=item[1]
    s1=(counter - 1)*(counter - 2)/2 #1個少ない
    s2=(counter)*(counter - 1)/2
    dic[item[0]]=int(s1 - s2)
    total+=int(s2)

for a in A:
    print(total + dic[a])

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

N=int(input())
A=deque(map(int,input().split()))
setA=set(A)
number1={}#-1
number2={}
ans={}
if(len(setA)==1):
    answer= len(A) - 1
    q=(answer - 1) * answer //2
    for _ in range(len(A)):
        print(q)
    sys.exit()


if(len(setA)==len(A)):
    for _ in range(len(A)):
        print(0)
    sys.exit()


for i in setA:
    tmp=A.count(i) - 1
    souwa=(tmp - 1)*(tmp)//2
    number1[i]=souwa
    souwa=tmp*(tmp+1)//2
    number2[i]=souwa

t=sum(number2.values())

for a in setA:
    total=number1[a]
    total+=t
    total-=number2[a]
    ans[a]=total

for a in A:
    print(ans[a])




Fixed submission:
from collections import Counter
N = int(input())
A = list(map(int,input().split()))
d=Counter(A)
dic={}
total=0
for item in d.items():
    counter=item[1]
    s1=(counter - 1)*(counter - 2)/2 #1個少ない
    s2=(counter)*(counter - 1)/2
    dic[item[0]]=int(s1 - s2)
    total+=int(s2)

for a in A:
    print(total + dic[a])

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))
setA=set(A)
number1={}#-1
number2={}
ans={}
for i in setA:
    tmp=A.count(i) - 1
    souwa=(tmp - 1)*(tmp)//2
    number1[i]=souwa
    souwa=tmp*(tmp+1)//2
    number2[i]=souwa
t=sum(number2.values())
for a in setA:
    total=number1[a]
    total+=t
    total-=number2[a]
    ans[a]=total

for a in A:
    print(ans[a])






Fixed submission:
from collections import Counter
N = int(input())
A = list(map(int,input().split()))
d=Counter(A)
dic={}
total=0
for item in d.items():
    counter=item[1]
    s1=(counter - 1)*(counter - 2)/2 #1個少ない
    s2=(counter)*(counter - 1)/2
    dic[item[0]]=int(s1 - s2)
    total+=int(s2)

for a in A:
    print(total + dic[a])

Buggy python submission (verdict: Time Limit Exceeded):

N=int(input())
A=list(map(int,input().split()))
setA=set(A)
number1={}#-1
number2={}
ans={}
for i in setA:
    tmp=A.count(i) - 1
    souwa=(tmp - 1)*(tmp)//2
    number1[i]=souwa
    souwa=tmp*(tmp+1)//2
    number2[i]=souwa
t=sum(number2.values())
for a in setA:
    total=number1[a]
    total+=t
    total-=number2[a]
    ans[a]=total

for a in A:
    print(ans[a])






Fixed submission:
from collections import Counter
N = int(input())
A = list(map(int,input().split()))
d=Counter(A)
dic={}
total=0
for item in d.items():
    counter=item[1]
    s1=(counter - 1)*(counter - 2)/2 #1個少ない
    s2=(counter)*(counter - 1)/2
    dic[item[0]]=int(s1 - s2)
    total+=int(s2)

for a in A:
    print(total + dic[a])

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))
setA=set(A)
number1={}#-1
number2={}
for i in setA:
    tmp=A.count(i) - 1
    souwa=(tmp - 1)*(tmp)//2
    number1[i]=souwa
    souwa=tmp*(tmp+1)//2
    number2[i]=souwa

t=sum(number2.values())

for a in A:
    total=number1[a]
    total+=t
    total-=number2[a]
    print(total)

Fixed submission:
from collections import Counter
N = int(input())
A = list(map(int,input().split()))
d=Counter(A)
dic={}
total=0
for item in d.items():
    counter=item[1]
    s1=(counter - 1)*(counter - 2)/2 #1個少ない
    s2=(counter)*(counter - 1)/2
    dic[item[0]]=int(s1 - s2)
    total+=int(s2)

for a in A:
    print(total + dic[a])