Buggy python submission (verdict: Runtime Error):
from scipy.misc import comb
from collections import defaultdict, deque
d = defaultdict(lambda: -1)
d_ = defaultdict(lambda: -1)
n = int(input())
a = deque([int(x) for x in input().split()])
for i in a:
  a_ = a.copy()
  a_.remove(i)
  b = i
  if d[str(b)] != -1:
    print(d[str(b)])
    continue
  A = list(set(a_))
  ans = 0
  for j in A:
    c = a_.count(j)
    if d_[str(c)] != -1:
      ans += d_[str(c)]
    else:
      e = comb(c, 2, exact=True)
      ans += e
      d_[str(c)] = e

  d[str(b)] = ans
  print(ans)




Fixed submission:
n = int(input())
a = [int(x) for x in input().split()]
from collections import defaultdict
d = defaultdict(int)
for i in a:
  d[i] += 1

total = 0
for i in set(a):
  x = d[i]
  total += x*(x-1)/2

for i in a:
  x = d[i]
  print(int(total-((x*(x-1)/2))+((x-1)*(x-2)/2)))

Buggy python submission (verdict: Runtime Error):
from scipy.misc import comb
from collections import defaultdict
from collections import deque
d = defaultdict(lambda: -1)
d_ = defaultdict(lambda: -1)
n = int(input())
a = deque([int(x) for x in input().split()])

for i in a:
  a_ = a.copy()
  b = a_.remove(i)
  if d[str(b)] != -1:
    print(d[str(b)])
    continue
  A = list(set(a_))
  ans = 0
  for j in A:
    c = a_.count(j)
    if d_[str(c)] != -1:
      ans += d_[str(c)]
    else:
      e = comb(c, 2, exact=True)
      ans += e
      d_[str(c)] = e

  d[str(b)] = ans
  print(ans)




Fixed submission:
n = int(input())
a = [int(x) for x in input().split()]
from collections import defaultdict
d = defaultdict(int)
for i in a:
  d[i] += 1

total = 0
for i in set(a):
  x = d[i]
  total += x*(x-1)/2

for i in a:
  x = d[i]
  print(int(total-((x*(x-1)/2))+((x-1)*(x-2)/2)))

Buggy python submission (verdict: Runtime Error):
from scipy.misc import comb
from collections import defaultdict
from collections import deque
d = defaultdict(lambda: -1)
d_ = defaultdict(lambda: -1)
n = int(input())
a = deque([int(x) for x in input().split()])

for i in a:
  a_ = a.copy()
  b = a_.remove(i)
  if d[str(b)] != -1:
    print(d[str(b)])
    continue
  A = list(set(a_))
  ans = 0
  for j in A:
    c = a_.count(j)
    if d_[str(c)] != -1:
      ans += d_[str(c)]
    else:
      e = comb(c, 2, exact=True)
      ans += e
      d_[str(c)] = e

  d[str(b)] = ans
  print(ans)




Fixed submission:
n = int(input())
a = [int(x) for x in input().split()]
from collections import defaultdict
d = defaultdict(int)
for i in a:
  d[i] += 1

total = 0
for i in set(a):
  x = d[i]
  total += x*(x-1)/2

for i in a:
  x = d[i]
  print(int(total-((x*(x-1)/2))+((x-1)*(x-2)/2)))

Buggy python submission (verdict: Time Limit Exceeded):
from scipy.misc import comb
from collections import defaultdict
d = defaultdict(lambda: -1)
d_ = defaultdict(lambda: -1)
n = int(input())
a = [int(x) for x in input().split()]

for i in range(len(a)):
  a_ = a.copy()
  b = a_.pop(i)
  if d[str(b)] != -1:
    print(d[str(b)])
    continue
  A = list(set(a_))
  ans = 0
  for j in A:
    c = a_.count(j)
    if d_[str(c)] != -1:
      ans += d_[str(c)]
    else:
      e = comb(c, 2, exact=True)
      ans += e
      d_[str(c)] = e

  d[str(b)] = ans
  print(ans)




Fixed submission:
n = int(input())
a = [int(x) for x in input().split()]
from collections import defaultdict
d = defaultdict(int)
for i in a:
  d[i] += 1

total = 0
for i in set(a):
  x = d[i]
  total += x*(x-1)/2

for i in a:
  x = d[i]
  print(int(total-((x*(x-1)/2))+((x-1)*(x-2)/2)))

Buggy python submission (verdict: Time Limit Exceeded):
from scipy.misc import comb
from collections import defaultdict
d = defaultdict(lambda: -1)
n = int(input())
a = [int(x) for x in input().split()]
ans = 0
for i in range(len(a)):
  a_ = a.copy()
  b = a_.pop(i)
  if d[str(b)] != -1:
    print(d[str(b)])
    continue
  A = list(set(a_))
  ans = 0
  for j in A:
    ans += comb(a_.count(j), 2, exact=True)

  d[str(b)] = ans
  print(ans)


Fixed submission:
n = int(input())
a = [int(x) for x in input().split()]
from collections import defaultdict
d = defaultdict(int)
for i in a:
  d[i] += 1

total = 0
for i in set(a):
  x = d[i]
  total += x*(x-1)/2

for i in a:
  x = d[i]
  print(int(total-((x*(x-1)/2))+((x-1)*(x-2)/2)))

Buggy python submission (verdict: Time Limit Exceeded):
from scipy.misc import comb
n = int(input())
a = [int(x) for x in input().split()]
ans = 0
for i in range(len(a)):
  a_ = a.copy()
  a_.pop(i)
  A = list(set(a_))
  ans = 0
  for j in A:
    ans += comb(a_.count(j), 2, exact=True)

  print(ans)




Fixed submission:
n = int(input())
a = [int(x) for x in input().split()]
from collections import defaultdict
d = defaultdict(int)
for i in a:
  d[i] += 1

total = 0
for i in set(a):
  x = d[i]
  total += x*(x-1)/2

for i in a:
  x = d[i]
  print(int(total-((x*(x-1)/2))+((x-1)*(x-2)/2)))