Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
n = int(input())
res = list(map(int,input().split()))
res2 = [0] * len(res)
a = Counter(res)

for i in a.keys():
    a[i] -= 1
    sums = 0
    for j in a.values():
        sums += j * (j - 1) // 2
    a[i] += 1
    for x in range(len(res)):
        if res[x] == i:
            res2[x] = sums
        else:
            res2[x] = res2[x]
for k in res2:
    print(k)

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

sums = 0

for i in a.values():
    sums +=  i * (i - 1) // 2

for j in res:
    print(sums - a[j] * (a[j] -1) //2 + (a[j]-1) * (a[j] -2 ) // 2)

Buggy python submission (verdict: Runtime Error):
from collections import Counter
n = int(input())
res = list(map(int,input().split()))
res2 = res.copy()
a = Counter(res)
b = set()
for i in range(len(res)):
    if res[i] not in b:
        b.add(res[i])
        a[res[i]] -= 1
        sums = 0
        for j in a.values():
            sums += j * (j - 1) // 2
        a[res[i]] += 1
        res2 = [sums if x == res[i] else x for x in res2]
for k in res2:
    print(k)

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

sums = 0

for i in a.values():
    sums +=  i * (i - 1) // 2

for j in res:
    print(sums - a[j] * (a[j] -1) //2 + (a[j]-1) * (a[j] -2 ) // 2)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
n = int(input())
res = list(map(int,input().split()))
a = Counter(res)
for i in range(len(res)):
    a[res[i]] -= 1
    sums = 0
    for j in a.values():
        sums += j * (j - 1) // 2
    a[res[i]] += 1
    res[i] = sums
for k in res:
    print(k)

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

sums = 0

for i in a.values():
    sums +=  i * (i - 1) // 2

for j in res:
    print(sums - a[j] * (a[j] -1) //2 + (a[j]-1) * (a[j] -2 ) // 2)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
n = int(input())
res = list(map(int,input().split()))
a = Counter(res)
for i in range(len(res)):
    a[res[i]] -= 1
    sums = 0
    for j in a.values():
        sums += j * (j - 1) // 2
    a[res[i]] += 1
    res[i] = sums
for k in res:
    print(k)

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

sums = 0

for i in a.values():
    sums +=  i * (i - 1) // 2

for j in res:
    print(sums - a[j] * (a[j] -1) //2 + (a[j]-1) * (a[j] -2 ) // 2)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
n = int(input())
res = list(map(int,input().split()))
sums = 0
ans = []
a = Counter(res)
for i in range(len(res)):
    a[res[i]] -= 1
    sums = 0
    for j in a.values():
        sums += j * (j - 1) // 2
    ans.append(sums)
    a[res[i]] += 1
for k in ans:
    print(k)

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

sums = 0

for i in a.values():
    sums +=  i * (i - 1) // 2

for j in res:
    print(sums - a[j] * (a[j] -1) //2 + (a[j]-1) * (a[j] -2 ) // 2)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
n = int(input())
res = list(map(int,input().split()))
sums = 0
ans = []
for i in range(len(res)):
    popl = res.pop(i)
    a = Counter(res)
    sums = 0
    for j in a.values():
        sums += j * (j - 1) // 2
    ans.append(sums)
    res.insert(i,popl)
for k in ans:
    print(k)

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

sums = 0

for i in a.values():
    sums +=  i * (i - 1) // 2

for j in res:
    print(sums - a[j] * (a[j] -1) //2 + (a[j]-1) * (a[j] -2 ) // 2)