Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A_list = list(map(int, input().split(' ')))
count_dict = {}
for A in A_list:
  strA = str(A)
  if strA in count_dict.keys():
    pass
  else:
    count_dict[strA] = A_list.count(A)
#print(count_dict)

sum_ = 0
for count in count_dict.values():
  sum_ += (count**2 - count) // 2

for A in A_list:
  print(sum_ - count_dict[str(A)] + 1)

Fixed submission:
import collections

N = int(input())
A_list = list(map(int, input().split(' ')))
count_dict = collections.Counter(A_list)

sum_ = 0
for count in count_dict.values():
  sum_ += (count**2 - count) // 2

for A in A_list:
  print(sum_ - count_dict[A] + 1)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A_list = list(map(int, input().split(' ')))
count_dict = {}
for A in A_list:
  strA = str(A)
  if strA in count_dict.keys():
    count_dict[strA] += 1
  else:
    count_dict[strA] = 1
#print(count_dict)

sum_ = 0
for count in count_dict.values():
  sum_ += (count**2 - count) // 2

for A in A_list:
  num = count_dict[str(A)]
  ans = sum_ - (num**2-num)//2 + (num**2-3*num+2)//2
  print(ans)

Fixed submission:
import collections

N = int(input())
A_list = list(map(int, input().split(' ')))
count_dict = collections.Counter(A_list)

sum_ = 0
for count in count_dict.values():
  sum_ += (count**2 - count) // 2

for A in A_list:
  print(sum_ - count_dict[A] + 1)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A_list = list(map(int, input().split(' ')))
count_list = [A_list.count(i) for i in range(N+1)]

sum_ = 0
for count in count_list:
  sum_ += (count**2 - count) // 2

for i in range(N):
  num = count_list[A_list[i]]
  ans = sum_ - (num**2-num)//2 + (num**2-3*num+2)//2
  print(ans)

Fixed submission:
import collections

N = int(input())
A_list = list(map(int, input().split(' ')))
count_dict = collections.Counter(A_list)

sum_ = 0
for count in count_dict.values():
  sum_ += (count**2 - count) // 2

for A in A_list:
  print(sum_ - count_dict[A] + 1)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A_list = list(map(int, input().split(' ')))
count_list = [A_list.count(i) for i in range(N+1)]

sum_ = 0
for count in count_list:
  sum_ += (count**2 - count) // 2

for i in range(N):
  num = A_list.count(A_list[i])
  ans = sum_ - (num**2-num)//2 + (num**2-3*num+2)//2
  print(ans)

Fixed submission:
import collections

N = int(input())
A_list = list(map(int, input().split(' ')))
count_dict = collections.Counter(A_list)

sum_ = 0
for count in count_dict.values():
  sum_ += (count**2 - count) // 2

for A in A_list:
  print(sum_ - count_dict[A] + 1)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A_list = list(map(int, input().split(' ')))
count_list = [A_list.count(i) for i in range(N+1)]
table = [(count**2-count)//2 for count in count_list]
sum_table = sum(table)

for i in range(N):
  print(sum_table - table[A_list[i]] + (count_list[A_list[i]]-1)*(count_list[A_list[i]]-2)//2)

Fixed submission:
import collections

N = int(input())
A_list = list(map(int, input().split(' ')))
count_dict = collections.Counter(A_list)

sum_ = 0
for count in count_dict.values():
  sum_ += (count**2 - count) // 2

for A in A_list:
  print(sum_ - count_dict[A] + 1)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A_list = list(map(int, input().split(' ')))
count_list = [A_list.count(i) for i in range(N+1)]
table = [(count**2-count)//2 for count in count_list]
sum_table = sum(table)

for i in range(N):
  print(sum_table - table[A_list[i]] + (count_list[A_list[i]]-1)*(count_list[A_list[i]]-2)//2)

Fixed submission:
import collections

N = int(input())
A_list = list(map(int, input().split(' ')))
count_dict = collections.Counter(A_list)

sum_ = 0
for count in count_dict.values():
  sum_ += (count**2 - count) // 2

for A in A_list:
  print(sum_ - count_dict[A] + 1)