Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations_with_replacement
from collections import Counter

n = int(input())
a = list(map(int, input().split())) #1-index

#n個のボールから書かれている整数が等しい異なる２つを選ぶ方法
n_l = list(Counter(a).values())
all_p = 0
for i in n_l:
    if i > 1:
        #all_p += len((list(combinations_with_replacement(range(1,i), 2))))
        all_p += (i-1)*i//2
#k番目のボールを覗いたn-1個から、k番目のボールと同じ整数を選ぶ方法
for k in range(n):
    print(all_p - (a.count(a[k])-1))


Fixed submission:
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
s=Counter(a)
sums=0
for k in s.keys():
    sums+=(s[k]-1)*s[k]//2

for i in a:
    print(sums-s[i]+1)

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations_with_replacement
from collections import Counter
import sys
input = sys.stdin.readline


n = int(input())
a = list(map(int, input().split())) #1-index

#n個のボールから書かれている整数が等しい異なる２つを選ぶ方法
n_l = list(Counter(a).values())
all_p = 0
for i in n_l:
    if i > 1:
        all_p += len((list(combinations_with_replacement(range(1,i), 2))))

#k番目のボールを覗いたn-1個から、k番目のボールと同じ整数を選ぶ方法
for k in range(n):
    print(all_p - (a.count(a[k])-1))


Fixed submission:
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
s=Counter(a)
sums=0
for k in s.keys():
    sums+=(s[k]-1)*s[k]//2

for i in a:
    print(sums-s[i]+1)

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations_with_replacement
from collections import Counter

n = int(input())
a = list(map(int, input().split())) #1-index

#n個のボールから書かれている整数が等しい異なる２つを選ぶ方法
n_l = list(Counter(a).values())
all_p = 0
for i in n_l:
    if i > 1:
        all_p += len((list(combinations_with_replacement(range(1,i), 2))))

#k番目のボールを覗いたn-1個から、k番目のボールと同じ整数を選ぶ方法
for k in range(n):
    print(all_p - (a.count(a[k])-1))


Fixed submission:
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
s=Counter(a)
sums=0
for k in s.keys():
    sums+=(s[k]-1)*s[k]//2

for i in a:
    print(sums-s[i]+1)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

from itertools import combinations_with_replacement
from collections import Counter

n = int(input())
a = list(map(int, input().split())) #1-index

ans_l = []
for k in range(n):
    ans = 0
    temp = a[k]
    a.remove(a[k]) #k番目を取り除いた
    c_v = list(Counter(a).values())
    for i in c_v:
        if i > 1:
            ans += len((list(combinations_with_replacement(range(1,i), 2))))
    a.insert(k,temp)
    ans_l.append(ans)

for i in ans_l:
    print(i)


Fixed submission:
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
s=Counter(a)
sums=0
for k in s.keys():
    sums+=(s[k]-1)*s[k]//2

for i in a:
    print(sums-s[i]+1)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

from itertools import combinations_with_replacement
from collections import Counter

n = int(input())
a = list(map(int, input().split())) #1-index

ans_l = []
for k in range(n):
    ans = 0
    temp = a[k]
    a.remove(a[k]) #k番目を取り除いた
    c_v = list(Counter(a).values())
    for i in c_v:
        if i > 1:
            ans += len((list(combinations_with_replacement(range(1,i), 2))))
    a.insert(k,temp)
    ans_l.append(ans)

for i in ans_l:
    print(i)


Fixed submission:
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
s=Counter(a)
sums=0
for k in s.keys():
    sums+=(s[k]-1)*s[k]//2

for i in a:
    print(sums-s[i]+1)

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations_with_replacement
from collections import Counter

n = int(input())
a = list(map(int, input().split())) #1-index

ans_l = []
for k in range(n):
    ans = 0
    temp = a[k]
    a.remove(a[k]) #k番目を取り除いた
    c_v = list(Counter(a).values())
    for i in c_v:
        if i > 1:
            ans += len((list(combinations_with_replacement(range(1,i), 2))))
    a.insert(k,temp)
    ans_l.append(ans)

for i in ans_l:
    print(i)


Fixed submission:
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
s=Counter(a)
sums=0
for k in s.keys():
    sums+=(s[k]-1)*s[k]//2

for i in a:
    print(sums-s[i]+1)