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

N = int(input())
listA = list(map(int,input().split()))
listA_hozon = listA

S = Counter(listA)
#print(S)

##key##
key = S.keys()
#for i in key:
#  print(i)

for i in listA:
  out = 0
  listA = listA_hozon
  for a in key:
    if a == i:
      num = S[a]-1
      add = (S[a]-1) * (S[a]-2) /2
      out = out + add
    else:
      num = S[a]
      add = S[a] * (S[a]-1) /2
      out = out +add
  print(int(out))


Fixed submission:
from collections import Counter

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

S = Counter(listA)

##key##
key = S.keys()
out = 0
for i in key:
  out = out + S[i] * (S[i]-1) /2

for i in listA:
  test = out - S[i] * (S[i]-1) /2 + (S[i] -1) * (S[i]-2) /2
  print(int(test))

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

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

S = Counter(listA)

##key##
key = S.keys()

##dict##
#my_dict = {}  

list_low = {}
list_high = {}

for i in key:
  num_low = (S[i]-1) * (S[i]-2) /2
  num_high =S[i] * (S[i]-1) /2
  list_low[i] = num_low
  list_high[i] = num_high

for i in listA:
  out =0
  for a in key:
    if i ==a:
      out = out + list_low[a]
    else:
      out = out + list_high[a]
  print(int(out))    


Fixed submission:
from collections import Counter

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

S = Counter(listA)

##key##
key = S.keys()
out = 0
for i in key:
  out = out + S[i] * (S[i]-1) /2

for i in listA:
  test = out - S[i] * (S[i]-1) /2 + (S[i] -1) * (S[i]-2) /2
  print(int(test))

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

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

S = Counter(listA)

##key##
key = S.keys()

##dict##
my_dict = {}  

for i in key:
  out = 0
  for a in key:
    if a == i:
      num = S[a]-1
      add = (S[a]-1) * (S[a]-2) /2
      out = out + add      
    else:
      num = S[a]
      add = S[a] * (S[a]-1) /2
      out = out +add
  my_dict[i] = int(out) 

for i in listA:
  print(my_dict[i])


Fixed submission:
from collections import Counter

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

S = Counter(listA)

##key##
key = S.keys()
out = 0
for i in key:
  out = out + S[i] * (S[i]-1) /2

for i in listA:
  test = out - S[i] * (S[i]-1) /2 + (S[i] -1) * (S[i]-2) /2
  print(int(test))

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

N = int(input())
listA = list(map(int,input().split()))
listA_hozon = listA

S = Counter(listA)
#print(S)

##key##
key = S.keys()
#for i in key:
#  print(i)

for i in listA:
  out = 0
  listA = listA_hozon
  for a in key:
    if a == i:
      num = S[a]-1
      add = (S[a]-1) * (S[a]-2) /2
      out = out + add
    else:
      num = S[a]
      add = S[a] * (S[a]-1) /2
      out = out +add
  print(int(out))

Fixed submission:
from collections import Counter

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

S = Counter(listA)

##key##
key = S.keys()
out = 0
for i in key:
  out = out + S[i] * (S[i]-1) /2

for i in listA:
  test = out - S[i] * (S[i]-1) /2 + (S[i] -1) * (S[i]-2) /2
  print(int(test))