Buggy python submission (verdict: Time Limit Exceeded):
import collections
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
n = int(input())
a = list(map(int, input().split()))
c = collections.Counter(a)
val = list(c.values())
key = list(c.keys())
cosum = 0
for i in val:
    cosum += (i*(i-1))//2
for i in range(n):
    ind = key.index(a[i])
    count = cosum
    count -= val[ind]-1
    print(count)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
b = [0]*n
for i in range(n):
    b[a[i]-1] += 1
c = sum([(i*(i-1))//2 for i in b])
for i in a:
    print(c-(b[i-1]-1))

Buggy python submission (verdict: Time Limit Exceeded):
import collections
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
n = int(input())
a = list(map(int, input().split()))
c = collections.Counter(a)
val = list(c.values())
key = list(c.keys())
comb = [combinations_count(i,2) if not i < 2 else 0 for i in val]
cosum = sum(comb)
for i in range(n):
    ind = key.index(a[i])
    count = sum(comb)
    count -= val[ind]-1
    print(count)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
b = [0]*n
for i in range(n):
    b[a[i]-1] += 1
c = sum([(i*(i-1))//2 for i in b])
for i in a:
    print(c-(b[i-1]-1))

Buggy python submission (verdict: Time Limit Exceeded):
import collections
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
n = int(input())
a = list(map(int, input().split()))
c = collections.Counter(a)
val = list(c.values())
key = list(c.keys())
comb = [combinations_count(i,2) if not i < 2 else 0 for i in val]
for i in range(n):
    ind = key.index(a[i])
    count = sum(comb)
    count -= comb[ind]
    hoge = val[ind] -1 
    if hoge < 2:
        pass
    else:
        count += combinations_count(hoge,2)
    print(count)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
b = [0]*n
for i in range(n):
    b[a[i]-1] += 1
c = sum([(i*(i-1))//2 for i in b])
for i in a:
    print(c-(b[i-1]-1))

Buggy python submission (verdict: Time Limit Exceeded):
import collections
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
n = int(input())
a = list(map(int, input().split()))
c = collections.Counter(a)
val = list(c.values())
key = list(c.keys())
for i in range(n):
    ind = key.index(a[i])
    val[ind] -= 1
    count = 0
    for j in val:
        if j < 2:
            pass
        else:   
            count += combinations_count(j,2)
    print(count)
    val[ind] += 1

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
b = [0]*n
for i in range(n):
    b[a[i]-1] += 1
c = sum([(i*(i-1))//2 for i in b])
for i in a:
    print(c-(b[i-1]-1))

Buggy python submission (verdict: Time Limit Exceeded):
import collections
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
n = int(input())
a = list(map(int, input().split()))
for i in range(n):
    l = [a[t] for t in range(n) if t != i]
    x = collections.Counter(l).values()
    count = 0
    for j in x:
        if j < 2:
            pass
        else:

            count += combinations_count(j,2)
    print(count)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
b = [0]*n
for i in range(n):
    b[a[i]-1] += 1
c = sum([(i*(i-1))//2 for i in b])
for i in a:
    print(c-(b[i-1]-1))