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

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

d = defaultdict(int)

all = 0
for i, a in enumerate(A):
    # i=1;val=A[i]
    cnt = Counter(A[i + 1:])
    all += cnt[a]

val_cnt = Counter(A)
for a in A:
    # a=1
    print(all - (val_cnt[a] - 1))


Fixed submission:
from collections import defaultdict, Counter

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

d = defaultdict(int)
for a in A:
    d[a] += 1

all = 0
for val in d.values():
    all += val * (val - 1) / 2

all = int(all)
val_cnt = Counter(A)
for a in A:
    print(all - (val_cnt[a] - 1))

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

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

# N = 5
# A = [1, 1, 2, 1, 2]

c = collections.Counter(A)
d = {}
for i in c:
    # val = uni_vals[0]
    ans = 0
    for j in c:
        n = c[j]
        if j == i:
            n -= 1
        ans += (n*(n-1))/2
    d[i] = ans

for i in range(N):
    print(int(d[A[i]]))


Fixed submission:
from collections import defaultdict, Counter

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

d = defaultdict(int)
for a in A:
    d[a] += 1

all = 0
for val in d.values():
    all += val * (val - 1) / 2

all = int(all)
val_cnt = Counter(A)
for a in A:
    print(all - (val_cnt[a] - 1))

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

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

# N = 5
# A = [1, 1, 2, 1, 2]

c = collections.Counter(A)
d = {}
for i in c:
    # val = uni_vals[0]
    ans = 0
    for j in c:
        n = c[j]
        if j == A[i]:
            n -= 1
        ans += (n*(n-1))/2
    d[i] = ans

for i in range(N):
    print(int(d[A[i]]))


Fixed submission:
from collections import defaultdict, Counter

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

d = defaultdict(int)
for a in A:
    d[a] += 1

all = 0
for val in d.values():
    all += val * (val - 1) / 2

all = int(all)
val_cnt = Counter(A)
for a in A:
    print(all - (val_cnt[a] - 1))

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

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

# N = 5
# A = [1, 1, 2, 1, 2]

for i in range(N):
    # i = 2
    A_sub = A.copy()
    # A_sub.pop(i)

    # A_sub = np.array(A_sub)

    ans = 0
    # u, counts = np.unique(A_sub, return_counts=True)
    c = collections.Counter(A_sub)
    for j in c:
        # val = uni_vals[0]
        n = c[j]
        if j == A[i]:
            n -= 1
        ans += (n*(n-1))/2

    print(int(ans))


Fixed submission:
from collections import defaultdict, Counter

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

d = defaultdict(int)
for a in A:
    d[a] += 1

all = 0
for val in d.values():
    all += val * (val - 1) / 2

all = int(all)
val_cnt = Counter(A)
for a in A:
    print(all - (val_cnt[a] - 1))

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

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

# N = 5
# A = [1, 1, 2, 1, 2]

for i in range(N):
    # i = 2
    A_sub = A.copy()
    A_sub.pop(i)

    A_sub = np.array(A_sub)

    ans = 0
    # u, counts = np.unique(A_sub, return_counts=True)
    c = collections.Counter(A_sub)
    for j in c:
        # val = uni_vals[0]
        n = c[j]
        ans += (n*(n-1))/2
    # dic = {}
    # for val in A_sub:
    #     if val in dic.keys():
    #         dic[val] += 1
    #     else:
    #         dic[val] = 1
    # ans = 0
    # for val in dic.values():
    #     ans += (val*(val-1)/2)

    print(int(ans))


Fixed submission:
from collections import defaultdict, Counter

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

d = defaultdict(int)
for a in A:
    d[a] += 1

all = 0
for val in d.values():
    all += val * (val - 1) / 2

all = int(all)
val_cnt = Counter(A)
for a in A:
    print(all - (val_cnt[a] - 1))

Buggy python submission (verdict: Runtime Error):
import numpy as np

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

# N = 5
# A = [1, 1, 2, 1, 2]

for i in range(N):
    # i = 2
    A_sub = A.copy()
    A_sub.pop(i)

    A_sub = np.array(A_sub)

    ans = 0
    u, counts = np.unique(A_sub, return_counts=True)
    for n in counts:
        # val = uni_vals[0]
        ans += (n*(n-1))/2
    # dic = {}
    # for val in A_sub:
    #     if val in dic.keys():
    #         dic[val] += 1
    #     else:
    #         dic[val] = 1
    # ans = 0
    # for val in dic.values():
    #     ans += (val*(val-1)/2)

    print(int(ans))

Fixed submission:
from collections import defaultdict, Counter

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

d = defaultdict(int)
for a in A:
    d[a] += 1

all = 0
for val in d.values():
    all += val * (val - 1) / 2

all = int(all)
val_cnt = Counter(A)
for a in A:
    print(all - (val_cnt[a] - 1))

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

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

# N = 5
# A = [1, 1, 2, 1, 2]

for i in range(N):
    # i = 2
    A_sub = A.copy()
    A_sub.pop(i)

    A_sub = np.array(A_sub)

    # ans = 0
    # uni_vals = np.unique(A_sub)
    # for val in uni_vals:
    #     # val = uni_vals[0]
    #     n = np.where(A_sub == val)[0].shape[0]
    #     ans += (n*(n-1))/2
    dic = {}
    for val in A_sub:
        if val in dic.keys():
            dic[val] += 1
        else:
            dic[val] = 1
    ans = 0
    for val in dic.values():
        ans += (val*(val-1)/2)

    print(int(ans))


Fixed submission:
from collections import defaultdict, Counter

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

d = defaultdict(int)
for a in A:
    d[a] += 1

all = 0
for val in d.values():
    all += val * (val - 1) / 2

all = int(all)
val_cnt = Counter(A)
for a in A:
    print(all - (val_cnt[a] - 1))

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

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

# N = 5
# A = [1, 1, 2, 1, 2]

for i in range(N):
    # i = 2
    A_sub = A.copy()
    A_sub.pop(i)

    A_sub = np.array(A_sub)
    uni_vals = np.unique(A_sub)

    ans = 0
    for val in uni_vals:
        # val = uni_vals[0]
        n = np.where(A_sub == val)[0].shape[0]
        ans += (n*(n-1))/2

    print(int(ans))

Fixed submission:
from collections import defaultdict, Counter

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

d = defaultdict(int)
for a in A:
    d[a] += 1

all = 0
for val in d.values():
    all += val * (val - 1) / 2

all = int(all)
val_cnt = Counter(A)
for a in A:
    print(all - (val_cnt[a] - 1))