Buggy python submission (verdict: Time Limit Exceeded):
N= int(input())
A = list(map(int, input().split()))
C=0
for i in range(N):
    k=int(A.count(i+1))
    C += k * (k - 1) // 2
for i in range(N):
    print(int(C-(A.count(A[i]))+1))

Fixed submission:
import math
import collections

def cmb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
    
N = int(input())
M = input().split()

total = 0
count = collections.Counter(M)

for i in count.values():
    if i >= 2:
        total += cmb(i, 2)
    
for j in M:
    print(total - (count[j]-1))

Buggy python submission (verdict: Time Limit Exceeded):
N= int(input())
A = list(map(int, input().split()))
C=0
for i in range(N):
    k=A.count(i+1)
    C += k * (k - 1) / 2
for i in range(N):
    print(int(C-(A.count(A[i]))+1))

Fixed submission:
import math
import collections

def cmb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
    
N = int(input())
M = input().split()

total = 0
count = collections.Counter(M)

for i in count.values():
    if i >= 2:
        total += cmb(i, 2)
    
for j in M:
    print(total - (count[j]-1))

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

Fixed submission:
import math
import collections

def cmb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
    
N = int(input())
M = input().split()

total = 0
count = collections.Counter(M)

for i in count.values():
    if i >= 2:
        total += cmb(i, 2)
    
for j in M:
    print(total - (count[j]-1))

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

Fixed submission:
import math
import collections

def cmb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
    
N = int(input())
M = input().split()

total = 0
count = collections.Counter(M)

for i in count.values():
    if i >= 2:
        total += cmb(i, 2)
    
for j in M:
    print(total - (count[j]-1))

Buggy python submission (verdict: Time Limit Exceeded):
N= int(input())
A = list(map(int, input().split()))
C=0
for i in range(N):
    C += A.count(i+1) * (A.count(i+1) - 1) / 2
for i in range(N):
    print(int(C-(A.count(A[i]))+1))

Fixed submission:
import math
import collections

def cmb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
    
N = int(input())
M = input().split()

total = 0
count = collections.Counter(M)

for i in count.values():
    if i >= 2:
        total += cmb(i, 2)
    
for j in M:
    print(total - (count[j]-1))

Buggy python submission (verdict: Time Limit Exceeded):
N= int(input())
A = list(map(int, input().split()))
B=[0]*N
C=0
for i in range(N):
    B[i]=A.count(i+1)
    C = C + B[i] * (B[i] - 1) / 2
for i in range(N):
    print(int(C-(B[A[i]-1])+1))

Fixed submission:
import math
import collections

def cmb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
    
N = int(input())
M = input().split()

total = 0
count = collections.Counter(M)

for i in count.values():
    if i >= 2:
        total += cmb(i, 2)
    
for j in M:
    print(total - (count[j]-1))

Buggy python submission (verdict: Time Limit Exceeded):
N= int(input())
A = list(map(int, input().split()))
B=[0]*N
C=0
for i in range(N):
    B[i]=A.count(i+1)
for i in range(N):
    C=C+B[i] * (B[i] - 1) / 2

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

Fixed submission:
import math
import collections

def cmb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
    
N = int(input())
M = input().split()

total = 0
count = collections.Counter(M)

for i in count.values():
    if i >= 2:
        total += cmb(i, 2)
    
for j in M:
    print(total - (count[j]-1))

Buggy python submission (verdict: Time Limit Exceeded):
N= int(input())
A = list(map(int, input().split()))
B=[0]*N
C=[0]*N
for i in range(N):
    B[i]=A.count(i+1)
for i in range(N):
    B[i] = B[i] - 1
    for j in range(N):
        if B[j] > 1:
            C[i] = C[i] + B[j] * (B[j] - 1) / 2
    B[i] = B[i] + 1

for i in range(N):
    print(int(C[A[i]-1]))


Fixed submission:
import math
import collections

def cmb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
    
N = int(input())
M = input().split()

total = 0
count = collections.Counter(M)

for i in count.values():
    if i >= 2:
        total += cmb(i, 2)
    
for j in M:
    print(total - (count[j]-1))

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

        if B[j]>1:
            C=C+B[j]*(B[j]-1)/2
    print(int(C))
    B[A[i] - 1] = B[A[i] - 1] +1


Fixed submission:
import math
import collections

def cmb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
    
N = int(input())
M = input().split()

total = 0
count = collections.Counter(M)

for i in count.values():
    if i >= 2:
        total += cmb(i, 2)
    
for j in M:
    print(total - (count[j]-1))