Buggy python submission (verdict: Time Limit Exceeded):
def list_counter(num_list,num):
    counter = 0
    for n in num_list:
        if n == num:
            counter +=1
    return counter

n = int(input())
a_list = [int(num) for num in input().split(" ")]
a_set = set(a_list)
total_comb = 0
for i in a_set:
    i_count = list_counter(a_list,i)
    total_comb += i_count*(i_count-1)
total_comb = int(total_comb/2)
for k in range(n):
    except_num = a_list[k]
    print(total_comb - (list_counter(a_list,except_num)-1))


Fixed submission:
import collections

n = int(input())
a_list = [int(num) for num in input().split(" ")]
c_dict = collections.Counter(a_list)

total_comb = 0
for i in c_dict:
    i_count = c_dict[i]
    total_comb += int(i_count*(i_count-1)/2)
for k in range(n):
    except_num = a_list[k]
    print(total_comb - (c_dict[except_num]-1))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a_list = [int(num) for num in input().split(" ")]
a_set = set(a_list)
total_comb = 0
for i in a_set:
    i_count = a_list.count(i)
    total_comb += i_count*(i_count-1)
total_comb = int(total_comb/2)
for k in range(n):
    except_num = a_list[k]
    print(total_comb - (a_list.count(except_num)-1))


Fixed submission:
import collections

n = int(input())
a_list = [int(num) for num in input().split(" ")]
c_dict = collections.Counter(a_list)

total_comb = 0
for i in c_dict:
    i_count = c_dict[i]
    total_comb += int(i_count*(i_count-1)/2)
for k in range(n):
    except_num = a_list[k]
    print(total_comb - (c_dict[except_num]-1))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a_list = [int(num) for num in input().split(" ")]
a_set = set(a_list)
total_comb = 0
for i in a_set:
    i_count = a_list.count(i)
    total_comb += int(i_count*(i_count-1)/2)
for k in range(n):
    except_num = a_list[k]
    print(total_comb - (a_list.count(except_num)-1))


Fixed submission:
import collections

n = int(input())
a_list = [int(num) for num in input().split(" ")]
c_dict = collections.Counter(a_list)

total_comb = 0
for i in c_dict:
    i_count = c_dict[i]
    total_comb += int(i_count*(i_count-1)/2)
for k in range(n):
    except_num = a_list[k]
    print(total_comb - (c_dict[except_num]-1))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a_list = [int(num) for num in input().split(" ")]
a_set = set(a_list)
total_comb = 0
ball_num_count = {}
for i in a_set:
    i_count = a_list.count(i)
    total_comb += int(i_count*(i_count-1)/2)
    ball_num_count[i] = i_count-1
for k in range(n):
    except_num = a_list[k]
    print(total_comb - ball_num_count[except_num])


Fixed submission:
import collections

n = int(input())
a_list = [int(num) for num in input().split(" ")]
c_dict = collections.Counter(a_list)

total_comb = 0
for i in c_dict:
    i_count = c_dict[i]
    total_comb += int(i_count*(i_count-1)/2)
for k in range(n):
    except_num = a_list[k]
    print(total_comb - (c_dict[except_num]-1))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a_list = [int(num) for num in input().split(" ")]

total_comb = 0
ball_num_count = {}
for i in range(1,n+1):
    i_count = a_list.count(i)
    total_comb += int(i_count*(i_count-1)/2)
    ball_num_count[i] = i_count-1
for k in range(n):
    except_num = a_list[k]
    print(total_comb - ball_num_count[except_num])


Fixed submission:
import collections

n = int(input())
a_list = [int(num) for num in input().split(" ")]
c_dict = collections.Counter(a_list)

total_comb = 0
for i in c_dict:
    i_count = c_dict[i]
    total_comb += int(i_count*(i_count-1)/2)
for k in range(n):
    except_num = a_list[k]
    print(total_comb - (c_dict[except_num]-1))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a_list = [int(num) for num in input().split(" ")]

total_comb = 0
ball_num_count = {}
for i in range(1,n+1):
    i_count = a_list.count(i)
    total_comb += int(i_count*(i_count-1)/2)
    ball_num_count[i] = int(i_count*(i_count-1)/2 - (i_count-1)*(i_count-2)/2)
for i in range(n):
    except_num = a_list[i]
    print(total_comb - ball_num_count[except_num])


Fixed submission:
import collections

n = int(input())
a_list = [int(num) for num in input().split(" ")]
c_dict = collections.Counter(a_list)

total_comb = 0
for i in c_dict:
    i_count = c_dict[i]
    total_comb += int(i_count*(i_count-1)/2)
for k in range(n):
    except_num = a_list[k]
    print(total_comb - (c_dict[except_num]-1))