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

def Get_nC2(n):
    return int(n*(n-1) / 2)


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

c = Counter(A_i)
cnt_dict = {}

total = sum(list(map(Get_nC2, tmp.values())))

for a_i in A_i:
    result =  total - Get_nC2(c[a_i]) + Get_nC2(c[a_i-1])
    print(result)


Fixed submission:
from collections import Counter

def Get_nC2(n):
    return int(n*(n-1) / 2)


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

c = Counter(A_i)


total = sum(list(map(Get_nC2, c.values())))

for a_i in A_i:
    result =  total - Get_nC2(c[a_i]) + Get_nC2(c[a_i]-1)
    print(result)

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

def Get_nC2(n):
    return int(n*(n-1) / 2)


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

c = Counter(A_i)
cnt_dict = {}

for a_i in A_i:
    if a_i in cnt_dict:
        print(cnt_dict[a_i])
        continue
        
    tmp = c.copy()
    tmp[a_i] = tmp[a_i] - 1
    total = sum(list(map(Get_nC2, tmp.values())))
    cnt_dict[a_i] = total
    print(total)


Fixed submission:
from collections import Counter

def Get_nC2(n):
    return int(n*(n-1) / 2)


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

c = Counter(A_i)


total = sum(list(map(Get_nC2, c.values())))

for a_i in A_i:
    result =  total - Get_nC2(c[a_i]) + Get_nC2(c[a_i]-1)
    print(result)

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

def Get_nC2(n):
    return int(n*(n-1) / 2)


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

c = Counter(A_i)

for a_i in A_i:
    tmp = c.copy()
    tmp[a_i] = tmp[a_i] - 1
    total = sum(list(map(Get_nC2, tmp.values())))
    print(total)


Fixed submission:
from collections import Counter

def Get_nC2(n):
    return int(n*(n-1) / 2)


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

c = Counter(A_i)


total = sum(list(map(Get_nC2, c.values())))

for a_i in A_i:
    result =  total - Get_nC2(c[a_i]) + Get_nC2(c[a_i]-1)
    print(result)

Buggy python submission (verdict: Time Limit Exceeded):
def Get_nC2(n):
    return int(n*(n-1) / 2);


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

all_cnt = 0
num_cnt_dict = {}
comb_cnt_dict = {}
for i in range(min(A_i), max(A_i)+1):
    if i in A_i and A_i.count(i) > 1:
        num_cnt_dict[i] = A_i.count(i)
        all_cnt += Get_nC2(num_cnt_dict[i])

for a_i in A_i:
    if a_i in comb_cnt_dict:
        print(comb_cnt_dict[a_i])
    elif a_i in num_cnt_dict:
        comb_cnt_dict[a_i] = all_cnt - Get_nC2(num_cnt_dict[a_i]) + Get_nC2(num_cnt_dict[a_i]-1)
        print(comb_cnt_dict[a_i])
    else:
        print(0)


Fixed submission:
from collections import Counter

def Get_nC2(n):
    return int(n*(n-1) / 2)


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

c = Counter(A_i)


total = sum(list(map(Get_nC2, c.values())))

for a_i in A_i:
    result =  total - Get_nC2(c[a_i]) + Get_nC2(c[a_i]-1)
    print(result)

Buggy python submission (verdict: Time Limit Exceeded):
def Get_nC2(n):
    return int(n*(n-1) / 2);


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

all_cnt = 0
num_cnt_dict = {}
comb_cnt_dict = {}
for i in range(1, N+1):
    if i in A_i and A_i.count(i) > 1:
        num_cnt_dict[i] = A_i.count(i)
        all_cnt += Get_nC2(num_cnt_dict[i])

for a_i in A_i:
    if a_i in comb_cnt_dict:
        print(comb_cnt_dict[a_i])
    elif a_i in num_cnt_dict:
        comb_cnt_dict[a_i] = all_cnt - Get_nC2(num_cnt_dict[a_i]) + Get_nC2(num_cnt_dict[a_i]-1)
        print(comb_cnt_dict[a_i])
    else:
        print(0)


Fixed submission:
from collections import Counter

def Get_nC2(n):
    return int(n*(n-1) / 2)


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

c = Counter(A_i)


total = sum(list(map(Get_nC2, c.values())))

for a_i in A_i:
    result =  total - Get_nC2(c[a_i]) + Get_nC2(c[a_i]-1)
    print(result)

Buggy python submission (verdict: Runtime Error):

def Get_nC2(n):
    return int(n*(n-1) / 2);


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

cnt_dict = {}
for a_i in A_i:
    cnt = 0
    if a_i in cnt_dict:
        print(cnt_dict[a_i])
        continue
    else:
    for j in range(min(A_i), max(A_i)+1):
        j_cnt = A_i.count(j)
        if a_i == j:
            j_cnt -= 1

        cnt += Get_nC2(j_cnt)

        cnt_dict[a_i] = cnt

        print(cnt)


Fixed submission:
from collections import Counter

def Get_nC2(n):
    return int(n*(n-1) / 2)


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

c = Counter(A_i)


total = sum(list(map(Get_nC2, c.values())))

for a_i in A_i:
    result =  total - Get_nC2(c[a_i]) + Get_nC2(c[a_i]-1)
    print(result)

Buggy python submission (verdict: Time Limit Exceeded):

def Get_nC2(n):
    return int(n*(n-1) / 2);


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

for a_i in A_i:
    cnt = 0
    for j in range(min(A_i), max(A_i)+1):
        j_cnt = A_i.count(j)
        if a_i == j:
            j_cnt -= 1

        cnt += Get_nC2(j_cnt)

    print(cnt)


Fixed submission:
from collections import Counter

def Get_nC2(n):
    return int(n*(n-1) / 2)


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

c = Counter(A_i)


total = sum(list(map(Get_nC2, c.values())))

for a_i in A_i:
    result =  total - Get_nC2(c[a_i]) + Get_nC2(c[a_i]-1)
    print(result)

Buggy python submission (verdict: Time Limit Exceeded):

def Get_nC2(n):
    return int(n*(n-1) / 2);


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

for a_i in A_i:
    cnt = 0
    for j in range(1, N+1):
        j_cnt = A_i.count(j)
        if a_i == j:
            j_cnt -= 1

        cnt += Get_nC2(j_cnt)

    print(cnt)


Fixed submission:
from collections import Counter

def Get_nC2(n):
    return int(n*(n-1) / 2)


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

c = Counter(A_i)


total = sum(list(map(Get_nC2, c.values())))

for a_i in A_i:
    result =  total - Get_nC2(c[a_i]) + Get_nC2(c[a_i]-1)
    print(result)