Buggy python submission (verdict: Time Limit Exceeded):
# from sys import stdin
# import math
from functools import lru_cache


@lru_cache(maxsize=1000)
def combinations_count(n, r):
    if n < 2:
        return 0
    return n*(n-1)//2


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

d = {}
cnt = 0
for i in range(N):
    d[A[i]] = d.get(A[i], 0)+1
# print(d)
for l in range(N):
    d[A[cnt]] = d.get(A[cnt], 0)-1
    # print(d)
    # print(len(d))
    sum = 0
    for key, value in enumerate(d):
        # print(key,value)
        sum = sum+combinations_count(d.get(value, 0), 2)
    print(sum)
    d[A[cnt]] = d.get(A[cnt], 0)+1
    # d = {}
    cnt += 1


Fixed submission:
# from sys import stdin
# import math
from functools import lru_cache


@lru_cache(maxsize=1000)
def combinations_count(n, r):
    if n < 2:
        return 0
    return n*(n-1)//2


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

d = {}
cnt = 0
for i in range(N):
    d[A[i]] = d.get(A[i], 0)+1
# print(d)
sum1 = 0
for key, value in enumerate(d):
    # print(key,value)
    sum1 = sum1+combinations_count(d.get(value, 0), 2)

for l in range(N):

    # print(d)
    # print(len(d))
    sum = 0
    sum = sum1-combinations_count(d.get(A[cnt], 0), 2)
    d[A[cnt]] = d.get(A[cnt], 0)-1
    sum = sum+combinations_count(d.get(A[cnt], 0), 2)
    # for key, value in enumerate(d):
    #     # print(key,value)
    #     sum = sum+combinations_count(d.get(value, 0), 2)
    print(sum)
    d[A[cnt]] = d.get(A[cnt], 0)+1
    # d = {}
    cnt += 1

Buggy python submission (verdict: Time Limit Exceeded):
# from sys import stdin
import math


def combinations_count(n, r):
    if n < 2:
        return 0
    return n*(n-1)//2


N = int(input())
A = list(map(int, input().split()))
# print(A)
d = {}
cnt = 0
for i in range(N):
    d[A[i]] = d.get(A[i], 0)+1
# print(d)
for l in range(N):
    d[A[cnt]] = d.get(A[cnt], 0)-1
    # print(d)
    # print(len(d))
    sum = 0
    for key, value in enumerate(d):
        # print(key,value)
        sum = sum+combinations_count(d.get(value, 0), 2)
    print(sum)
    d[A[cnt]] = d.get(A[cnt], 0)+1
    # d = {}
    cnt += 1

Fixed submission:
# from sys import stdin
# import math
from functools import lru_cache


@lru_cache(maxsize=1000)
def combinations_count(n, r):
    if n < 2:
        return 0
    return n*(n-1)//2


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

d = {}
cnt = 0
for i in range(N):
    d[A[i]] = d.get(A[i], 0)+1
# print(d)
sum1 = 0
for key, value in enumerate(d):
    # print(key,value)
    sum1 = sum1+combinations_count(d.get(value, 0), 2)

for l in range(N):

    # print(d)
    # print(len(d))
    sum = 0
    sum = sum1-combinations_count(d.get(A[cnt], 0), 2)
    d[A[cnt]] = d.get(A[cnt], 0)-1
    sum = sum+combinations_count(d.get(A[cnt], 0), 2)
    # for key, value in enumerate(d):
    #     # print(key,value)
    #     sum = sum+combinations_count(d.get(value, 0), 2)
    print(sum)
    d[A[cnt]] = d.get(A[cnt], 0)+1
    # d = {}
    cnt += 1

Buggy python submission (verdict: Time Limit Exceeded):
# from sys import stdin
import math


def combinations_count(n, r):
    if n < 2:
        return 0
    return n*(n-1)//2


N = int(input())
A = list(map(int, input().split()))
# print(A)
d = {}
cnt = 0
for l in range(N):
    for i in range(N):
        if i != cnt:
            d[A[i]] = d.get(A[i], 0)+1
    # print(d)
    # print(len(d))
    sum = 0
    for key, value in enumerate(d):
        # print(key,value)
        sum = sum+combinations_count(d.get(value, 0), 2)
    print(sum)
    d = {}
    cnt += 1


Fixed submission:
# from sys import stdin
# import math
from functools import lru_cache


@lru_cache(maxsize=1000)
def combinations_count(n, r):
    if n < 2:
        return 0
    return n*(n-1)//2


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

d = {}
cnt = 0
for i in range(N):
    d[A[i]] = d.get(A[i], 0)+1
# print(d)
sum1 = 0
for key, value in enumerate(d):
    # print(key,value)
    sum1 = sum1+combinations_count(d.get(value, 0), 2)

for l in range(N):

    # print(d)
    # print(len(d))
    sum = 0
    sum = sum1-combinations_count(d.get(A[cnt], 0), 2)
    d[A[cnt]] = d.get(A[cnt], 0)-1
    sum = sum+combinations_count(d.get(A[cnt], 0), 2)
    # for key, value in enumerate(d):
    #     # print(key,value)
    #     sum = sum+combinations_count(d.get(value, 0), 2)
    print(sum)
    d[A[cnt]] = d.get(A[cnt], 0)+1
    # d = {}
    cnt += 1

Buggy python submission (verdict: Time Limit Exceeded):
# from sys import stdin
import math


def combinations_count(n, r):
    if n < 2:
        return 0
    return n*(n-1)//2


N = int(input())
A = list(map(int, input().split()))
# print(A)
d = {}
cnt = 0
for l in range(N):
    for i in range(N):
        if i != cnt:
            d[A[i]] = d.get(A[i], 0)+1
    # print(d)
    # print(len(d))
    sum = 0
    for key, value in enumerate(d):
        # print(key,value)
        sum = sum+combinations_count(d.get(value, 0), 2)
    print(sum)
    d = {}
    cnt += 1


Fixed submission:
# from sys import stdin
# import math
from functools import lru_cache


@lru_cache(maxsize=1000)
def combinations_count(n, r):
    if n < 2:
        return 0
    return n*(n-1)//2


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

d = {}
cnt = 0
for i in range(N):
    d[A[i]] = d.get(A[i], 0)+1
# print(d)
sum1 = 0
for key, value in enumerate(d):
    # print(key,value)
    sum1 = sum1+combinations_count(d.get(value, 0), 2)

for l in range(N):

    # print(d)
    # print(len(d))
    sum = 0
    sum = sum1-combinations_count(d.get(A[cnt], 0), 2)
    d[A[cnt]] = d.get(A[cnt], 0)-1
    sum = sum+combinations_count(d.get(A[cnt], 0), 2)
    # for key, value in enumerate(d):
    #     # print(key,value)
    #     sum = sum+combinations_count(d.get(value, 0), 2)
    print(sum)
    d[A[cnt]] = d.get(A[cnt], 0)+1
    # d = {}
    cnt += 1

Buggy python submission (verdict: Time Limit Exceeded):
# from sys import stdin
import math


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


N = int(input())
A = list(map(int, input().split()))
# print(A)
d = {}
cnt = 0
for l in range(N):
    for i in range(N):
        if i != cnt:

            # else:
            d[A[i]] = d.get(A[i], 0)+1
    # print(d)
    # print(len(d))
    sum = 0
    for key,value in enumerate(d):
        # print(key,value)
        sum = sum+combinations_count(d.get(value, 0), 2)
    print(sum)
    d = {}
    cnt += 1


Fixed submission:
# from sys import stdin
# import math
from functools import lru_cache


@lru_cache(maxsize=1000)
def combinations_count(n, r):
    if n < 2:
        return 0
    return n*(n-1)//2


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

d = {}
cnt = 0
for i in range(N):
    d[A[i]] = d.get(A[i], 0)+1
# print(d)
sum1 = 0
for key, value in enumerate(d):
    # print(key,value)
    sum1 = sum1+combinations_count(d.get(value, 0), 2)

for l in range(N):

    # print(d)
    # print(len(d))
    sum = 0
    sum = sum1-combinations_count(d.get(A[cnt], 0), 2)
    d[A[cnt]] = d.get(A[cnt], 0)-1
    sum = sum+combinations_count(d.get(A[cnt], 0), 2)
    # for key, value in enumerate(d):
    #     # print(key,value)
    #     sum = sum+combinations_count(d.get(value, 0), 2)
    print(sum)
    d[A[cnt]] = d.get(A[cnt], 0)+1
    # d = {}
    cnt += 1