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

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

equal = 0
elements = collections.Counter(A)
for v in elements.values():
    equal += v * (v - 1) // 2

for i in range(n):
    A_tmp = A[: i] + A[i + 1: ]
    equal_i = A_tmp.count(A[i])
    print(equal - equal_i)


Fixed submission:
import math
import collections

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

equal = 0
elements = collections.Counter(A)
equal = sum([v * (v - 1) // 2 for v in elements.values()])

for i in range(n):
    equal_i = elements[A[i]] - 1
    print(equal - equal_i)

Buggy python submission (verdict: Time Limit Exceeded):
import math

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

equal = 0
elements = set(A)
for e in elements:
    tmp = A.count(e)
    equal += tmp * (tmp - 1) // 2

for i in range(n):
    A_tmp = A[: i] + A[i + 1: ]
    equal_i = A_tmp.count(A[i])
    print(equal - equal_i)

Fixed submission:
import math
import collections

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

equal = 0
elements = collections.Counter(A)
equal = sum([v * (v - 1) // 2 for v in elements.values()])

for i in range(n):
    equal_i = elements[A[i]] - 1
    print(equal - equal_i)

Buggy python submission (verdict: Runtime Error):
import math

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

equal = 0
elements = set(A)
for e in elements:
    tmp = A.count(e)
    equal += math.factorial(tmp) // (2 * math.factorial(tmp - 2))

for i in range(n):
    A_tmp = A[: i] + A[i + 1: ]
    equal_i = A_tmp.count(A[i])
    print(equal - equal_i)

Fixed submission:
import math
import collections

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

equal = 0
elements = collections.Counter(A)
equal = sum([v * (v - 1) // 2 for v in elements.values()])

for i in range(n):
    equal_i = elements[A[i]] - 1
    print(equal - equal_i)

Buggy python submission (verdict: Time Limit Exceeded):
import math
import itertools

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

C = list(itertools.combinations(A, 2))
C = list(c for c in C if c[0] == c[1])
equal = len(C)

for i in range(n):
    A_tmp = A[: i] + A[i + 1: ]
    equal_i = A_tmp.count(A[i])
    print(equal - equal_i)


Fixed submission:
import math
import collections

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

equal = 0
elements = collections.Counter(A)
equal = sum([v * (v - 1) // 2 for v in elements.values()])

for i in range(n):
    equal_i = elements[A[i]] - 1
    print(equal - equal_i)

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

C = list(itertools.combinations(A, 2))
C = list(c for c in C if c[0] == c[1])
equal = len(C)

for i in range(n):
    A_tmp = A[: i] + A[i + 1: ]
    equal_i = A_tmp.count(A[i])
    print(equal - equal_i)

Fixed submission:
import math
import collections

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

equal = 0
elements = collections.Counter(A)
equal = sum([v * (v - 1) // 2 for v in elements.values()])

for i in range(n):
    equal_i = elements[A[i]] - 1
    print(equal - equal_i)

Buggy python submission (verdict: Time Limit Exceeded):
import math

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

for i in range(n):
    ans = 0
    A_tmp = A[: i] + A[i + 1: ]
    D = dict.fromkeys(A_tmp, 0)
    for k in D.keys():
        D[k] = A_tmp.count(k)
    for v in D.values():
        if v >= 2:
            ans += math.factorial(v) // (2 * math.factorial(v - 2))
    print(ans)

Fixed submission:
import math
import collections

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

equal = 0
elements = collections.Counter(A)
equal = sum([v * (v - 1) // 2 for v in elements.values()])

for i in range(n):
    equal_i = elements[A[i]] - 1
    print(equal - equal_i)