Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))
se_ = set(A)
 
 
all = 0
for i in se_:
    all += A.count(i)*(A.count(i)-1)//2
    
 
for i in A:
    final=0
    final = all - A.count(i)+1
    print(final)

Fixed submission:
from collections import Counter
N = int(input())
A = list(map(int,input().split()))
se_ = Counter(A)
key = se_.keys()
 
 
all = 0
for i in key:
    all += se_[i]*(se_[i]-1)//2
    
 
for i in A:
    final=0
    final = all -se_[i]+1
    print(final)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
def com(n,r):
    return n*(n-1)//2

N = int(input())
A = list(map(int,input().split()))
se_ = Counter(A)
key = se_.keys()


all = 0
for i in key:
    all += com(se_[i],2)
    

for i in A:
    final=0
    final = all - com(A.count(i),2) + com(A.count(i)-1,2)
    print(final)

Fixed submission:
from collections import Counter
N = int(input())
A = list(map(int,input().split()))
se_ = Counter(A)
key = se_.keys()
 
 
all = 0
for i in key:
    all += se_[i]*(se_[i]-1)//2
    
 
for i in A:
    final=0
    final = all -se_[i]+1
    print(final)

Buggy python submission (verdict: Time Limit Exceeded):
from math import factorial
def com(n,r):
    return n*(n-1)//2

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


all = 0
for i in se_:
    all += com(A.count(i),2)
    

for i in A:
    final=0
    final = all - com(A.count(i),2) + com(A.count(i)-1,2)
    print(final)

Fixed submission:
from collections import Counter
N = int(input())
A = list(map(int,input().split()))
se_ = Counter(A)
key = se_.keys()
 
 
all = 0
for i in key:
    all += se_[i]*(se_[i]-1)//2
    
 
for i in A:
    final=0
    final = all -se_[i]+1
    print(final)

Buggy python submission (verdict: Time Limit Exceeded):
from math import factorial
def com(n,r):
    if n-r<0:
        return 0
    return factorial(n) // factorial(r) // factorial(n - r)

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


all = 0
for i in se_:
    all += com(A.count(i),2)
    

for i in A:
    final=0
    final = all - com(A.count(i),2) + com(A.count(i)-1,2)
    print(final)

Fixed submission:
from collections import Counter
N = int(input())
A = list(map(int,input().split()))
se_ = Counter(A)
key = se_.keys()
 
 
all = 0
for i in key:
    all += se_[i]*(se_[i]-1)//2
    
 
for i in A:
    final=0
    final = all -se_[i]+1
    print(final)

Buggy python submission (verdict: Time Limit Exceeded):
from math import factorial
def com(n,r):
    if n-r<0:
        return 0
    return factorial(n) // factorial(r) // factorial(n - r)

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


all = 0
for i in se_:
    all += com(A.count(i),2)
    

for i in A:
    final=0
    final = all - com(A.count(i),2) + com(A.count(i)-1,2)
    print(final)

Fixed submission:
from collections import Counter
N = int(input())
A = list(map(int,input().split()))
se_ = Counter(A)
key = se_.keys()
 
 
all = 0
for i in key:
    all += se_[i]*(se_[i]-1)//2
    
 
for i in A:
    final=0
    final = all -se_[i]+1
    print(final)

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

li_ = [0]*(N+1)
li_[2]=1
for i in range(2,N):
    li_[i+1]=li_[i]*(i+1)//(i-1)


for i in A:
    counter = 0
    for kind in se_:
        if kind == i:
            counter += li_[A.count(kind)-1]
        else:
            counter += li_[A.count(kind)]
    print(counter)


Fixed submission:
from collections import Counter
N = int(input())
A = list(map(int,input().split()))
se_ = Counter(A)
key = se_.keys()
 
 
all = 0
for i in key:
    all += se_[i]*(se_[i]-1)//2
    
 
for i in A:
    final=0
    final = all -se_[i]+1
    print(final)

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


def count(x):
    return x*(x-1)//2


for i in A:
    counter = 0
    for kind in se_:
        if kind == i:
            counter += count(A.count(kind)-1)
        else:
            counter += count(A.count(kind))  
    print(counter)


Fixed submission:
from collections import Counter
N = int(input())
A = list(map(int,input().split()))
se_ = Counter(A)
key = se_.keys()
 
 
all = 0
for i in key:
    all += se_[i]*(se_[i]-1)//2
    
 
for i in A:
    final=0
    final = all -se_[i]+1
    print(final)