Buggy python submission (verdict: Runtime Error):
def combi(count):
  if n==1:return 0
  elif n==2:return 1
  else:return int(count*(count-1)/2)


n=int(input())
alis=list(map(int,input().split()))
dick=dict()
for i in range(n):
  p=alis[i]
  dick[p]+=1

point=0
for k,v in dick:
  point+=combi(v)


for i in range(n):
  idx=alis[i]
  minus=dick[idx]-1
  print(point-minus)
  
  
  
  

Fixed submission:
def combi(count):
  if n==1:return 0
  elif n==2:return 1
  else:return int(count*(count-1)/2)
 
 
n=int(input())
alis=list(map(int,input().split()))
dick={st:0 for st in set(alis)}
for i in range(n):
  p=alis[i]
  dick[p]+=1
#print(dick)
point=0
for v in dick.values():
  point+=combi(v)
 
 
for i in range(n):
  idx=alis[i]
  minus=dick[idx]-1
  print(point-minus)

Buggy python submission (verdict: Runtime Error):
"""from operator import mul
from functools import reduce
 
def cmb(n,r):
  if n<2: return 0
  r = min(n-r,r)
  over = reduce(mul, range(n, n - r, -1))
  under = reduce(mul, range(1,r + 1))
  return over // under
"""
from math import factorial
def cmb(n,r=2):
  
  return factorial(n) / factorial(r) / factorial(n - r)
 
 
N=int(input())
a_lis=list(map(int,input().split()))
 
olt={i:0 for i in set(a_lis)}
for i in a_lis:
  olt[i]+=1
#print(olt)
for j in range(N):
  index=a_lis[j]
  olt[index]-=1
  #print(olt)
  san=0
  for i in set(a_lis):
    if olt[i] <2:
      continue
    #print(i,olt[i])
    san+=cmb(olt[i])
  
  print(int(san))
  olt[index]+=1

Fixed submission:
def combi(count):
  if n==1:return 0
  elif n==2:return 1
  else:return int(count*(count-1)/2)
 
 
n=int(input())
alis=list(map(int,input().split()))
dick={st:0 for st in set(alis)}
for i in range(n):
  p=alis[i]
  dick[p]+=1
#print(dick)
point=0
for v in dick.values():
  point+=combi(v)
 
 
for i in range(n):
  idx=alis[i]
  minus=dick[idx]-1
  print(point-minus)

Buggy python submission (verdict: Runtime Error):
"""from operator import mul
from functools import reduce

def cmb(n,r):
  if n<2: return 0
  r = min(n-r,r)
  over = reduce(mul, range(n, n - r, -1))
  under = reduce(mul, range(1,r + 1))
  return over // under
"""
from math import factorial
def cmb(n,r=2):
  
  return factorial(n) / factorial(r) / factorial(n - r)


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

olt={i:0 for i in set(a_lis)}
for i in a_lis:
  olt[i]+=1
#print(olt)
for j in range(N):
  index=a_lis[j]
  olt[index]-=1
  #print(olt)
  san=0
  for i in set(a_lis):
    if olt[i] <2:
      continue
    #print(i,olt[i])
    san+=cmb(olt[i])
  
  print(int(san))
  olt[index]+=1

Fixed submission:
def combi(count):
  if n==1:return 0
  elif n==2:return 1
  else:return int(count*(count-1)/2)
 
 
n=int(input())
alis=list(map(int,input().split()))
dick={st:0 for st in set(alis)}
for i in range(n):
  p=alis[i]
  dick[p]+=1
#print(dick)
point=0
for v in dick.values():
  point+=combi(v)
 
 
for i in range(n):
  idx=alis[i]
  minus=dick[idx]-1
  print(point-minus)

Buggy python submission (verdict: Runtime Error):
from operator import mul
from functools import reduce

def cmb(n,r):
  	if n == 1 or n == 0: return 0
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

n=int(input())
a_lis=list(map(int,input().split()))

olt={i:0 for i in set(a_lis)}
for i in a_lis:
  olt[i]+=1
for j in range(n):
  index=a_lis[j]
  olt[index]-=1
  
  z=sum([cmb(k,2) for key,k in olt])
  print(z)
  olt[index]+=1

Fixed submission:
def combi(count):
  if n==1:return 0
  elif n==2:return 1
  else:return int(count*(count-1)/2)
 
 
n=int(input())
alis=list(map(int,input().split()))
dick={st:0 for st in set(alis)}
for i in range(n):
  p=alis[i]
  dick[p]+=1
#print(dick)
point=0
for v in dick.values():
  point+=combi(v)
 
 
for i in range(n):
  idx=alis[i]
  minus=dick[idx]-1
  print(point-minus)