Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
l = list(map(int, input().split()))
set_l = set(l)

dictionary = {ll: l.count(ll) for ll in set_l}
ll_dict = {}

cnt = 0
for k, v in dictionary.items():
  cnt += v*(v-1)//2

for n in range(N):
  print(cnt-(dictionary[l[n]]-1))

Fixed submission:
from collections import Counter

N = int(input())
l = list(map(int, input().split()))
set_l = set(l)

dictionary = Counter(l)
ll_dict = {}

cnt = 0
for k, v in dictionary.items():
  cnt += v*(v-1)//2

for n in range(N):
  print(cnt-(dictionary[l[n]]-1))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
l = list(map(int, input().split()))
set_l = set(l)

dictionary = {ll: l.count(ll) for ll in set_l}
ll_dict = {}
for ll in set_l:
  cnt = 0
  for k, v in dictionary.items():
    if k==ll:
      v -=1
    cnt += v*(v-1)/2
  ll_dict[ll] = cnt

for n in range(N):
  print(int(ll_dict[l[n]]))

Fixed submission:
from collections import Counter

N = int(input())
l = list(map(int, input().split()))
set_l = set(l)

dictionary = Counter(l)
ll_dict = {}

cnt = 0
for k, v in dictionary.items():
  cnt += v*(v-1)//2

for n in range(N):
  print(cnt-(dictionary[l[n]]-1))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
l = list(map(int, input().split()))
set_l = set(l)

dictionary = {ll: l.count(ll)for ll in set_l}

for n in range(N):
  cnt = 0
  for k, v in dictionary.items():
    if k==l[n]:
      v -=1
    cnt += v*(v-1)/2
  print(int(cnt))

Fixed submission:
from collections import Counter

N = int(input())
l = list(map(int, input().split()))
set_l = set(l)

dictionary = Counter(l)
ll_dict = {}

cnt = 0
for k, v in dictionary.items():
  cnt += v*(v-1)//2

for n in range(N):
  print(cnt-(dictionary[l[n]]-1))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
l = list(map(int, input().split()))
set_N = set(l)

for i in range(N):
  cnt = 0
  for sn in set_N:
    num = l.count(sn)
    if l[i]==sn:
      num -= 1
    cnt += num*(num-1)/2
  print(int(cnt))


Fixed submission:
from collections import Counter

N = int(input())
l = list(map(int, input().split()))
set_l = set(l)

dictionary = Counter(l)
ll_dict = {}

cnt = 0
for k, v in dictionary.items():
  cnt += v*(v-1)//2

for n in range(N):
  print(cnt-(dictionary[l[n]]-1))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
l = list(map(int, input().split()))

for i in range(N):
  cnt = 0
  for j in range(N):
    for k in range(j+1, N):
      if i!=j and i!=k and l[j]==l[k]:
        cnt += 1
  print(int(cnt))

Fixed submission:
from collections import Counter

N = int(input())
l = list(map(int, input().split()))
set_l = set(l)

dictionary = Counter(l)
ll_dict = {}

cnt = 0
for k, v in dictionary.items():
  cnt += v*(v-1)//2

for n in range(N):
  print(cnt-(dictionary[l[n]]-1))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
l = list(map(int, input().split()))

for i in range(N):
  cnt = 0
  for j in range(N):
    for k in range(N):
      if i!=j and i!=k and j!=k and l[j]==l[k]:
        cnt += 1
  print(int(cnt/2))

Fixed submission:
from collections import Counter

N = int(input())
l = list(map(int, input().split()))
set_l = set(l)

dictionary = Counter(l)
ll_dict = {}

cnt = 0
for k, v in dictionary.items():
  cnt += v*(v-1)//2

for n in range(N):
  print(cnt-(dictionary[l[n]]-1))