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

setA = set(A)
an = 0
for num in setA:
    d = A.count(num)
    an += d*(d-1)//2

for i in range(n):
    ans = an
    t = A[i]
    e = A.count(A[i])
    ans -= e*(e-1)//2
    ans += (e-1)*(e-2)//2
    print(ans)

Fixed submission:
N=int(input())
K=list(map(int, input().split()))
from collections import Counter
ans = 0
C = Counter(K)
for k, v in C.items():
    ans += v*(v-1)//2

for a in K:
    e = C[a]
    print(ans-e*(e-1)//2+(e-1)*(e-2)//2)

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

setA = set(A)
an = 0
for num in setA:
    d = A.count(num)
    an += d*(d-1)//2

for i in range(n):
    ans = an
    t = A[i]
    e = A.count(A[i])
    ans -= e*(e-1)//2
    ans += (e-1)*(e-2)//2
    print(ans)

Fixed submission:
N=int(input())
K=list(map(int, input().split()))
from collections import Counter
ans = 0
C = Counter(K)
for k, v in C.items():
    ans += v*(v-1)//2

for a in K:
    e = C[a]
    print(ans-e*(e-1)//2+(e-1)*(e-2)//2)

Buggy python submission (verdict: Runtime Error):
n = int(input())
A = list(map(int, input().split()))

setA = set(A)
an = 0
for num in B:
    d = A.count(num)
    an += d*(d-1)//2

for i in range(n):
    ans = an
    t = A[i]
    e = A.count(A[i])
    ans -= e*(e-1)//2
    ans += (e-1)*(e-2)//2
    print(ans)

Fixed submission:
N=int(input())
K=list(map(int, input().split()))
from collections import Counter
ans = 0
C = Counter(K)
for k, v in C.items():
    ans += v*(v-1)//2

for a in K:
    e = C[a]
    print(ans-e*(e-1)//2+(e-1)*(e-2)//2)

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

for i in range(n):
    AA = A.copy()
    AA.remove(AA[i])
    B = set(AA)
    cnt = 0
    for num in B:
        d = AA.count(num)
        cnt += d*(d-1)//2
    print(cnt)

Fixed submission:
N=int(input())
K=list(map(int, input().split()))
from collections import Counter
ans = 0
C = Counter(K)
for k, v in C.items():
    ans += v*(v-1)//2

for a in K:
    e = C[a]
    print(ans-e*(e-1)//2+(e-1)*(e-2)//2)

Buggy python submission (verdict: Runtime Error):
import sys
 
n = int(sys.stdin.readline())
 
li = list(map(int, sys.stdin.readline().split()))
 
ans = [0]*n
for i in range(n):
    li2 = li.copy()
    del li2[i]
    for j in range(n-1):
        for k in range(j+1, n-1):
            if li2[j] == li2[k]:
                ans[i] += 1
for l in range(len(ans)):

Fixed submission:
N=int(input())
K=list(map(int, input().split()))
from collections import Counter
ans = 0
C = Counter(K)
for k, v in C.items():
    ans += v*(v-1)//2

for a in K:
    e = C[a]
    print(ans-e*(e-1)//2+(e-1)*(e-2)//2)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
 
n = int(sys.stdin.readline())
 
li = list(map(int, sys.stdin.readline().split()))
 
ans = [0]*n
for i in range(n):
    li2 = li.copy()
    del li2[i]
    for j in range(n-1):
        for k in range(j+1, n-1):
            if li2[j] == li2[k]:
                ans[i] += 1
for l in range(len(ans)):
    print(ans[l])

Fixed submission:
N=int(input())
K=list(map(int, input().split()))
from collections import Counter
ans = 0
C = Counter(K)
for k, v in C.items():
    ans += v*(v-1)//2

for a in K:
    e = C[a]
    print(ans-e*(e-1)//2+(e-1)*(e-2)//2)

Buggy python submission (verdict: Runtime Error):
n = int(input())
 
li = list(map(int, input().split()))
 
ans = [0]*n
for i in range(n):
    li2 = li.copy()
    del li2[i]
    li3 = list(set(li2))
    for j in range(len(li3)):
        m = li2.count(li3[j])*(li2.count(li3[j])-1)/2
        ans[i] += m
for l in range(len(ans)):
    print(int(ans[l]))

Fixed submission:
N=int(input())
K=list(map(int, input().split()))
from collections import Counter
ans = 0
C = Counter(K)
for k, v in C.items():
    ans += v*(v-1)//2

for a in K:
    e = C[a]
    print(ans-e*(e-1)//2+(e-1)*(e-2)//2)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

li = list(map(int, input().split()))

ans = [0]*n
for i in range(n):
    li2 = li.copy()
    del li2[i]
    li3 = list(set(li2))
    for j in range(len(li3)):
        m = li2.count(li3[j])*(li2.count(li3[j])-1)/2
        ans[i] += m
for l in range(len(ans)):
    print(int(ans[l]))
 

Fixed submission:
N=int(input())
K=list(map(int, input().split()))
from collections import Counter
ans = 0
C = Counter(K)
for k, v in C.items():
    ans += v*(v-1)//2

for a in K:
    e = C[a]
    print(ans-e*(e-1)//2+(e-1)*(e-2)//2)

Buggy python submission (verdict: Runtime Error):
n = int(input())

li = list(map(int, input().split()))

ans = [0]*n
for i in range(n):
    li2 = li
    del li2[i]
    for j in range(n-1):
        for k in range(j+1, n-1):
            if li2[j] == li2[k]:
                ans[i] += 1
for l in range(len(ans)):
    print(ans[l])
 


Fixed submission:
N=int(input())
K=list(map(int, input().split()))
from collections import Counter
ans = 0
C = Counter(K)
for k, v in C.items():
    ans += v*(v-1)//2

for a in K:
    e = C[a]
    print(ans-e*(e-1)//2+(e-1)*(e-2)//2)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

li = list(map(int, input().split()))

ans = [0]*n
for i in range(n):
    li2 = li.copy()
    del li2[i]
    for j in range(n-1):
        for k in range(j+1, n-1):
            if li2[j] == li2[k]:
                ans[i] += 1
for l in range(len(ans)):
    print(ans[l])
 

Fixed submission:
N=int(input())
K=list(map(int, input().split()))
from collections import Counter
ans = 0
C = Counter(K)
for k, v in C.items():
    ans += v*(v-1)//2

for a in K:
    e = C[a]
    print(ans-e*(e-1)//2+(e-1)*(e-2)//2)