Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
 
num_cnt = {}
sum_cnt = 0
 
for x in a:
    if x not in num_cnt:
        cnt = a.count(x)
        num_cnt[x] = cnt
        sum_cnt += cnt*(cnt-1)//2

res = []
for x in a:
    cnt = num_cnt[x]
    res.append(str( sum_cnt - (cnt-1) ))

print('\n'.join(res))

Fixed submission:
n = int(input())
a = list(map(int, input().split()))

import collections
cnt = collections.Counter(a)

sum_cnt = 0
for v in cnt.values():
    sum_cnt += v*(v-1)//2

res = []
for value in a:
    res.append(str( sum_cnt - (cnt[value]-1) ))
print('\n'.join(res))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
 
num_cnt = [0]*n
sum_cnt = 0
 
for num in range(n):
    cnt = a.count(num+1)
    if cnt > 0:
        num_cnt[num] = cnt
        sum_cnt += cnt*(cnt-1)//2

res = []
for x in a:
    cnt = num_cnt[x-1]
    res.append(str( sum_cnt - (cnt-1) ))

print('\n'.join(res))

Fixed submission:
n = int(input())
a = list(map(int, input().split()))

import collections
cnt = collections.Counter(a)

sum_cnt = 0
for v in cnt.values():
    sum_cnt += v*(v-1)//2

res = []
for value in a:
    res.append(str( sum_cnt - (cnt[value]-1) ))
print('\n'.join(res))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
 
num_cnt = [0]*n
sum_cnt = 0
 
for num in range(n):
    cnt = a.count(num+1)
    if cnt > 0:
        num_cnt[num] = cnt
        sum_cnt += cnt*(cnt-1)//2
res = [0]*n
 
for num in range(n):
    cnt = num_cnt[num]
    res[num] = (sum_cnt - (cnt-1)) if cnt != 0 else 0
 
for a_k in a:
    print(res[a_k-1])

Fixed submission:
n = int(input())
a = list(map(int, input().split()))

import collections
cnt = collections.Counter(a)

sum_cnt = 0
for v in cnt.values():
    sum_cnt += v*(v-1)//2

res = []
for value in a:
    res.append(str( sum_cnt - (cnt[value]-1) ))
print('\n'.join(res))

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

num_cnt = [0]*n
sum_cnt = 0

for num in range(n):
    cnt = a.count(num+1)
    if cnt > 0:
        num_cnt[num] = cnt
        sum_cnt += cnt*(cnt-1)//2
res = [0]*n

for num in range(n):
    cnt = num_cnt[num]
    res[num] = (sum_cnt - (cnt-1)*(cnt - (cnt-2))//2) if cnt != 0 else 0

for a_k in a:
    print(res[a_k-1])

Fixed submission:
n = int(input())
a = list(map(int, input().split()))

import collections
cnt = collections.Counter(a)

sum_cnt = 0
for v in cnt.values():
    sum_cnt += v*(v-1)//2

res = []
for value in a:
    res.append(str( sum_cnt - (cnt[value]-1) ))
print('\n'.join(res))

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

num_cnt = [0]*n
res = 0
for num in range(n):
    cnt = a.count(num+1)
    num_cnt[num] = cnt
    if cnt > 0:
        res += cnt*(cnt-1)//2

for a_k in a:
    cnt = num_cnt[a_k-1]
    print(res - (cnt-1)*(cnt - (cnt-2))//2)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))

import collections
cnt = collections.Counter(a)

sum_cnt = 0
for v in cnt.values():
    sum_cnt += v*(v-1)//2

res = []
for value in a:
    res.append(str( sum_cnt - (cnt[value]-1) ))
print('\n'.join(res))

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

num_cnt = {}
res = 0
for num in range(n):
    cnt = a.count(num+1)
    if cnt > 0:
        num_cnt[num+1] = cnt
        res += cnt*(cnt-1)//2

for a_k in a:
    cnt = num_cnt[a_k]
    print(res - (cnt-1)*(cnt - (cnt-2))//2)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))

import collections
cnt = collections.Counter(a)

sum_cnt = 0
for v in cnt.values():
    sum_cnt += v*(v-1)//2

res = []
for value in a:
    res.append(str( sum_cnt - (cnt[value]-1) ))
print('\n'.join(res))

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

res = 0
for num in range(n):
    if a.count(num+1) > 0:
        res += a.count(num+1)*(a.count(num+1)-1)//2

for a_k in a:
    cnt = a.count(a_k)
    print(res - (cnt-1)*(cnt - (cnt-2))//2)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))

import collections
cnt = collections.Counter(a)

sum_cnt = 0
for v in cnt.values():
    sum_cnt += v*(v-1)//2

res = []
for value in a:
    res.append(str( sum_cnt - (cnt[value]-1) ))
print('\n'.join(res))

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

num_cnt = {}
for a_i in a:
    if a_i in num_cnt:
        num_cnt[a_i] += 1
    else:
        num_cnt[a_i] = 1
for a_i in a:
    res = 0;
    for k,v in num_cnt.items():
        x = v-1 if k == a_i else v
        res += x*(x-1)//2
    print(res)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))

import collections
cnt = collections.Counter(a)

sum_cnt = 0
for v in cnt.values():
    sum_cnt += v*(v-1)//2

res = []
for value in a:
    res.append(str( sum_cnt - (cnt[value]-1) ))
print('\n'.join(res))