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

N = int(input())
A = list(map(int, input().split()))


for i in range(N):
    kosu = Counter(A)

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


def C(N):
    if N <= 0:
        return 0
    else:
        return N*(N-1)//2


for a in A:
    print(tempSum - kosu[a]+1)




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

cnt = Counter(A)

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

for k in A:
    # n*(n-1)//2 - (n-1)*(n-2)//2 = n - 1
    print(ans - (cnt[k] - 1))

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

N = int(input())
A = list(map(int, input().split()))


for i in range(N):
    kosu = Counter(A)

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


def C(N):
    if N <= 0:
        return 0
    else:
        return N*(N-1)//2


for a in A:
    print(tempSum - C(kosu[a]) + C(kosu[a] - 1))




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

cnt = Counter(A)

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

for k in A:
    # n*(n-1)//2 - (n-1)*(n-2)//2 = n - 1
    print(ans - (cnt[k] - 1))

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

N = int(input())
A = list(map(int, input().split()))

kosu = [0] * N

for i in range(N):
    kosu = Counter(A)

tempSum = 0
for i in range(N):
    tempSum += kosu[i+1] * (kosu[i+1] - 1) // 2


def C(N):
    if N <= 0:
        return 0
    else:
        return N*(N-1)//2


for a in A:
    print(tempSum - C(kosu[a]) + C(kosu[a] - 1))




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

cnt = Counter(A)

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

for k in A:
    # n*(n-1)//2 - (n-1)*(n-2)//2 = n - 1
    print(ans - (cnt[k] - 1))

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

N = int(input())
A = list(map(int, input().split()))

kosu = [0] * N

for i in range(N):
    kosu = Counter(A)

tempSum = 0
for i in range(N):
    tempSum += kosu[i+1] * (kosu[i+1] - 1) // 2


def C(N):
    if N <= 0:
        return 0
    else:
        return N*(N-1)//2


for i in range(N):
    print(tempSum - C(kosu[A[i]]) + C(kosu[A[i]] - 1))




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

cnt = Counter(A)

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

for k in A:
    # n*(n-1)//2 - (n-1)*(n-2)//2 = n - 1
    print(ans - (cnt[k] - 1))

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

kosu = [0] * N

for i in range(N):
    kosu[i] = (A.count(i+1))

tempSum = 0
for i in range(N):
    tempSum += kosu[i] * (kosu[i] - 1) // 2

def C(N):
    if N <= 0:
        return 0
    else:
        return N*(N-1)//2


for i in range(N):
    print(tempSum - C(kosu[A[i]-1]) + C(kosu[A[i]-1] - 1))




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

cnt = Counter(A)

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

for k in A:
    # n*(n-1)//2 - (n-1)*(n-2)//2 = n - 1
    print(ans - (cnt[k] - 1))