Buggy python submission (verdict: Time Limit Exceeded):
import math,collections

def f(c):
  sum=0
  for i in c.values():
    sum+=i*(i-1)//2
  return sum

n=int(input())
k=list(map(int,input().split()))
c=collections.Counter(k)

for i in range(n):
  c[k[i]]-=1
  print(f(c))
  c[k[i]]+=1


Fixed submission:
import collections
n=int(input())
k=list(map(int,input().split()))
c=collections.Counter(k)
ans=0

for i in c.values():
  ans+=i*(i-1)//2

for i in range(n):
  print(ans-c[k[i]]+1)

Buggy python submission (verdict: Time Limit Exceeded):
import math,collections

def f(c):
  sum=0
  for i in c.values():
    sum+=g(i,2)
  return sum

def g(n,r):
  if n==0 or n==1:return 0
  else:return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))

n=int(input())
k=list(map(int,input().split()))
c=collections.Counter(k)

for i in range(n):
  c[k[i]]-=1
  print(f(c))
  c[k[i]]+=1


Fixed submission:
import collections
n=int(input())
k=list(map(int,input().split()))
c=collections.Counter(k)
ans=0

for i in c.values():
  ans+=i*(i-1)//2

for i in range(n):
  print(ans-c[k[i]]+1)

Buggy python submission (verdict: Time Limit Exceeded):
import math,collections

def f(c):
  sum=0
  for i in c.values():
    sum+=g(i,2)
  return sum

def g(n,r):
  if n==0 or n==1:return 0
  else:return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))

n=int(input())
k=list(map(int,input().split()))
c=collections.Counter(k)

for i in range(n):
  c=collections.Counter(k)
  c[k[i]]-=1
  print(f(c))

Fixed submission:
import collections
n=int(input())
k=list(map(int,input().split()))
c=collections.Counter(k)
ans=0

for i in c.values():
  ans+=i*(i-1)//2

for i in range(n):
  print(ans-c[k[i]]+1)

Buggy python submission (verdict: Time Limit Exceeded):
import math,collections

def f(c):
  sum=0
  for i in c:
    sum+=g(i,2)
  return sum

def g(n,r):
  if n==0 or n==1:return 0
  else:return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))

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

for i in range(n):
  l=k[0:i]
  l.extend(k[i+1:])
  c=collections.Counter(l).values()
#  print('l:',l,'c:',c)
  print(f(c))

Fixed submission:
import collections
n=int(input())
k=list(map(int,input().split()))
c=collections.Counter(k)
ans=0

for i in c.values():
  ans+=i*(i-1)//2

for i in range(n):
  print(ans-c[k[i]]+1)

Buggy python submission (verdict: Time Limit Exceeded):
import math,collections

def f(c):
  sum=0
  for i in c.values():
    sum+=g(i,2)
  return sum

def g(n,r):
  if n==0 or n==1:return 0
  else:return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))

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

for i in range(n):
  l=k[0:i]
  l.extend(k[i+1:])
  c=collections.Counter(l)
#  print('l:',l,'c:',c)
  print(f(c))

Fixed submission:
import collections
n=int(input())
k=list(map(int,input().split()))
c=collections.Counter(k)
ans=0

for i in c.values():
  ans+=i*(i-1)//2

for i in range(n):
  print(ans-c[k[i]]+1)

Buggy python submission (verdict: Time Limit Exceeded):
import math, collections

def f(c):
  sum=0
  for i in c.values():
    sum+=g(i,2)
  return sum

def g(n,r):
  if n==0 or n==1:return 0
  else:return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))

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

for i in range(n):
  l=[]
  l.extend(k)
  del l[i]
  c=collections.Counter(l)
  print(f(c))

Fixed submission:
import collections
n=int(input())
k=list(map(int,input().split()))
c=collections.Counter(k)
ans=0

for i in c.values():
  ans+=i*(i-1)//2

for i in range(n):
  print(ans-c[k[i]]+1)