Buggy python submission (verdict: Runtime Error):
from collections import Counter

n = int(input())
A = list(map(int, input().split()))
counter = Counter(A)
counter_comb = list(map(lambda y: int(y*(y-1)/2), counter.values()))
sum_counter = sum(counter_comb)
for i in range(n):
    z = counter[A[i]-1]
    if z>0:
        print(ssum_counter-(z-1))
    else:
        print(sum_counter)
    

Fixed submission:
from collections import Counter

n = int(input())
A = list(map(int, input().split()))
counter = Counter(A)
counter_comb = list(map(lambda y: int(y*(y-1)/2), counter.values()))
sum_counter = sum(counter_comb)
for i in range(n):
    z = counter[A[i]]
    if z>0:
        print(sum_counter-(z-1))
    else:
        print(sum_counter)

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

n = int(input())
A = list(map(int, input().split()))
counter = Counter(A)
counter_comb = list(map(lambda y: int(y*(y-1)/2), counter.values()))

for i in range(n):
    z = counter[A[i]]
    if z>0:
        print(sum(counter_comb)-(z-1))
    else:
        print(sum(counter_comb))
    

Fixed submission:
from collections import Counter

n = int(input())
A = list(map(int, input().split()))
counter = Counter(A)
counter_comb = list(map(lambda y: int(y*(y-1)/2), counter.values()))
sum_counter = sum(counter_comb)
for i in range(n):
    z = counter[A[i]]
    if z>0:
        print(sum_counter-(z-1))
    else:
        print(sum_counter)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = list(map(int, input().split()))
counter = [0]*n
for i in range(n):
    counter[A[i]-1] += 1
 
counter_comb = list(map(lambda y: int(y*(y-1)/2), counter))
 
for i in range(n):
    z = counter[A[i]-1]
    if z>0:
        print(sum(counter_comb)-(z-1))
    else:
        print(sum(counter_comb))

Fixed submission:
from collections import Counter

n = int(input())
A = list(map(int, input().split()))
counter = Counter(A)
counter_comb = list(map(lambda y: int(y*(y-1)/2), counter.values()))
sum_counter = sum(counter_comb)
for i in range(n):
    z = counter[A[i]]
    if z>0:
        print(sum_counter-(z-1))
    else:
        print(sum_counter)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = list(map(int, input().split()))
counter = [0]*n
for i in range(n):
    counter[A[i]-1] += 1

counter_comb = list(map(lambda y: int(y*(y-1)/2), counter))

for i in range(n):
    z = counter[A[i]-1]
    counter_copy = counter_comb.copy()
    if z>0:
        counter_copy[A[i]-1] -= z-1
    print(sum(counter_copy))
    

Fixed submission:
from collections import Counter

n = int(input())
A = list(map(int, input().split()))
counter = Counter(A)
counter_comb = list(map(lambda y: int(y*(y-1)/2), counter.values()))
sum_counter = sum(counter_comb)
for i in range(n):
    z = counter[A[i]]
    if z>0:
        print(sum_counter-(z-1))
    else:
        print(sum_counter)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = list(map(int, input().split()))
counter = [0]*n
for i in range(n):
    counter[A[i]-1] += 1

for i in range(n):
    counter_copy = counter.copy()
    if counter_copy[A[i]-1]>1:
        counter_copy[A[i]-1] -= 1
    x = list(map(lambda y: int(y*(y-1)/2), counter_copy))
    print(sum(x))
    

Fixed submission:
from collections import Counter

n = int(input())
A = list(map(int, input().split()))
counter = Counter(A)
counter_comb = list(map(lambda y: int(y*(y-1)/2), counter.values()))
sum_counter = sum(counter_comb)
for i in range(n):
    z = counter[A[i]]
    if z>0:
        print(sum_counter-(z-1))
    else:
        print(sum_counter)