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

from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

a_c = Counter(A)
for i in range(n):
    tmp = 0
    for k,v in a_c.items():
        if k==A[i]:
            v-=1
        if v>=2:
            tmp+=cmb(v,2)
    print(tmp)

Fixed submission:
from collections import Counter
n = int(input())
a_input = list(map(int,input().split()))

a_count = Counter(a_input)

score_dic={}
exclude_dic={}

for k,v in a_count.items():
    score_dic[k]=v*(v-1)//2
    exclude_dic[k]=(v-1)*(v-2)//2

score_sum = sum(score_dic.values())

for i in range(n):
    print(score_sum-score_dic[a_input[i]]+exclude_dic[a_input[i]])

Buggy python submission (verdict: Runtime Error):
from collections import Counter
n = int(input())
a_input = list(map(int,input().split()))

a_count = Counter(a_input)

score_dic={}
exclude_dic={}

for k,v in enumerate(a_count.items()):
    score_dic[k]=v*(v-1)//2
    exclude_dic[k]=(v-1)*(v-2)//2

score_sum = sum(score_dic.values())

for i in range(n):
    print(score_sum-score_dic[a_input[i]]+exclude_dic[a_input[i]])

Fixed submission:
from collections import Counter
n = int(input())
a_input = list(map(int,input().split()))

a_count = Counter(a_input)

score_dic={}
exclude_dic={}

for k,v in a_count.items():
    score_dic[k]=v*(v-1)//2
    exclude_dic[k]=(v-1)*(v-2)//2

score_sum = sum(score_dic.values())

for i in range(n):
    print(score_sum-score_dic[a_input[i]]+exclude_dic[a_input[i]])

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
n = int(input())
a_input = list(map(int,input().split()))

a_count = Counter(a_input)

score_li = [0]*len(a_count)
exclude_li = [0]*len(a_count)

for i,(k,v) in enumerate(a_count.items()):
    score_li[i]=v*(v-1)//2
    exclude_li[i]=(v-1)*(v-2)//2

score_sum = sum(score_li)

for i in range(n):
    for j,(k,v) in enumerate(a_count.items()):
        if a_input[i]==k:
            print(score_sum-score_li[j]+exclude_li[j])
            break

Fixed submission:
from collections import Counter
n = int(input())
a_input = list(map(int,input().split()))

a_count = Counter(a_input)

score_dic={}
exclude_dic={}

for k,v in a_count.items():
    score_dic[k]=v*(v-1)//2
    exclude_dic[k]=(v-1)*(v-2)//2

score_sum = sum(score_dic.values())

for i in range(n):
    print(score_sum-score_dic[a_input[i]]+exclude_dic[a_input[i]])

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
n = int(input())
a_input = list(map(int,input().split()))

a_count = Counter(a_input)

score_li = [0]*len(a_count)
exclude_li = [0]*len(a_count)

for i in range(n):
    tmp=0
    for k,v in a_count.items():
        if a_input[i]==k:
            tmp+=(v-1)*(v-2)//2
        else:
            tmp+=v*(v-1)//2
    print(tmp)


Fixed submission:
from collections import Counter
n = int(input())
a_input = list(map(int,input().split()))

a_count = Counter(a_input)

score_dic={}
exclude_dic={}

for k,v in a_count.items():
    score_dic[k]=v*(v-1)//2
    exclude_dic[k]=(v-1)*(v-2)//2

score_sum = sum(score_dic.values())

for i in range(n):
    print(score_sum-score_dic[a_input[i]]+exclude_dic[a_input[i]])

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
n = int(input())
a_input = list(map(int,input().split()))

a_count = Counter(a_input)
for i in range(n):
    li = [(v-1)*(v-2)//2 if k==a_input[i] else v*(v-1)//2 for k,v in a_count.items()]
    print(sum(li))  

Fixed submission:
from collections import Counter
n = int(input())
a_input = list(map(int,input().split()))

a_count = Counter(a_input)

score_dic={}
exclude_dic={}

for k,v in a_count.items():
    score_dic[k]=v*(v-1)//2
    exclude_dic[k]=(v-1)*(v-2)//2

score_sum = sum(score_dic.values())

for i in range(n):
    print(score_sum-score_dic[a_input[i]]+exclude_dic[a_input[i]])

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
n = int(input())
a_input = list(map(int,input().split()))

a_count = Counter(a_input)
for i in range(n):
    li = [v-1 if k==a_input[i] else v for k,v in a_count.items()]
    len_li = len(li)
    tmp=0
    for l in li:
        tmp+=l*(l-1)//2
    print(tmp)  

Fixed submission:
from collections import Counter
n = int(input())
a_input = list(map(int,input().split()))

a_count = Counter(a_input)

score_dic={}
exclude_dic={}

for k,v in a_count.items():
    score_dic[k]=v*(v-1)//2
    exclude_dic[k]=(v-1)*(v-2)//2

score_sum = sum(score_dic.values())

for i in range(n):
    print(score_sum-score_dic[a_input[i]]+exclude_dic[a_input[i]])