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

def combinations_count(n, r):
    if n <= 1:
        return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

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

c = collections.Counter(A)
ans = 0
for v in c.values():
    if v > 1:
        ans = ans + combinations_count(v, 2)

for i in range(N):
    print(ans + combinations_count(c[A[i]]-1, 2) - combinations_count(c[A[i]], 2))

Fixed submission:
import math
import collections
import numpy as np

def combinations_count(n, r):
    if n <= 1:
        return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

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

c = collections.Counter(A)
ans = 0
for v in c.values():
    if v > 1:
        ans += v*(v-1)//2

for i in range(N):
    v = c[A[i]]
    print(ans + (v-1)*(v-2)//2 - v*(v-1)//2)

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

def combinations_count(n, r):
    if n <= 1:
        return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

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

c = collections.Counter(A)
ans = 0
for k, v in c.items():
    if v > 1:
        ans = ans + combinations_count(v, 2)

for i in range(N):
    hoge = c[A[i]] - 1
    print(ans + combinations_count(hoge, 2) - combinations_count(hoge+1, 2))

Fixed submission:
import math
import collections
import numpy as np

def combinations_count(n, r):
    if n <= 1:
        return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

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

c = collections.Counter(A)
ans = 0
for v in c.values():
    if v > 1:
        ans += v*(v-1)//2

for i in range(N):
    v = c[A[i]]
    print(ans + (v-1)*(v-2)//2 - v*(v-1)//2)

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

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()))
A = np.array(A)

for i in range(N):
    result = 0
    ind = np.ones(N, dtype=bool)
    ind[i] = False
    # pop = A.pop(i)
    c = collections.Counter(A[ind])
    values, counts = zip(*c.most_common())
    for v in counts:
        if v > 1:
            result = result + combinations_count(v, 2)
        else:
            break
        
    # A.insert(i, pop)
    print(result)

Fixed submission:
import math
import collections
import numpy as np

def combinations_count(n, r):
    if n <= 1:
        return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

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

c = collections.Counter(A)
ans = 0
for v in c.values():
    if v > 1:
        ans += v*(v-1)//2

for i in range(N):
    v = c[A[i]]
    print(ans + (v-1)*(v-2)//2 - v*(v-1)//2)

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

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):
    flag = True
    result = 0
    pop = A.pop(i)
    c = collections.Counter(A)
    values, counts = zip(*c.most_common())
    for v in counts:
        if v > 1:
            result = result + combinations_count(v, 2)
        else:
            break
        
    A.insert(i, pop)
    print(result)

Fixed submission:
import math
import collections
import numpy as np

def combinations_count(n, r):
    if n <= 1:
        return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

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

c = collections.Counter(A)
ans = 0
for v in c.values():
    if v > 1:
        ans += v*(v-1)//2

for i in range(N):
    v = c[A[i]]
    print(ans + (v-1)*(v-2)//2 - v*(v-1)//2)

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

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):
    result = 0
    pop = A.pop(i)
    c = collections.Counter(A)
    for k, v in c.items():
        if v > 1:
            result = result + combinations_count(v, 2)
    A.insert(i, pop)
    print(result)

Fixed submission:
import math
import collections
import numpy as np

def combinations_count(n, r):
    if n <= 1:
        return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

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

c = collections.Counter(A)
ans = 0
for v in c.values():
    if v > 1:
        ans += v*(v-1)//2

for i in range(N):
    v = c[A[i]]
    print(ans + (v-1)*(v-2)//2 - v*(v-1)//2)