Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
N = int(input())
A = list(map(int, input().split()))

dict = {}
for i in range(N):
  if A[i] in dict.keys():
    dict[A[i]] += 1
  else:
    dict[A[i]] = 1

fact = []

fact.append(1)
for i in range(1, N+1):
  fact.append(fact[i-1] * i)

def comb(n,k):
  if n<k:
    return 0
  return int(fact[n] / fact[k] / fact[n-k])

# all
ret = 0
for key in dict.keys():
  val = dict[key]
  ret += comb(val, 2)

# i >= 0
for i in range(N):
  val_n = dict[A[i]]
  next_ret = ret - comb(val_n, 2) + comb(val_n - 1, 2)
  print(next_ret)

Fixed submission:
# coding: utf-8
N = int(input())
A = list(map(int, input().split()))

dict = {}
for i in range(N):
  if A[i] in dict.keys():
    dict[A[i]] += 1
  else:
    dict[A[i]] = 1

def comb(n):
  if n<2:
    return 0
  return int(n * (n - 1) / 2)

# all
ret = 0
for key in dict.keys():
  val = dict[key]
  ret += comb(val)

# i >= 0
for i in range(N):
  val_n = dict[A[i]]
  next_ret = ret - comb(val_n) + comb(val_n - 1)
  print(next_ret)

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
N = int(input())
A = list(map(int, input().split()))

dict = {}
for i in range(N):
  if A[i] in dict.keys():
    dict[A[i]] += 1
  else:
    dict[A[i]] = 1

fact = []

fact.append(1)
for i in range(1, N):
  fact.append(fact[i-1] * i)
  
for i in range(N):
  ret = 0
  for key in dict.keys():
    val = dict[key]
    if key == A[i]:
      val -= 1
    if val < 2:
      continue
    ret += int(fact[val]/fact[val-2]/fact[2])
  print(ret)

Fixed submission:
# coding: utf-8
N = int(input())
A = list(map(int, input().split()))

dict = {}
for i in range(N):
  if A[i] in dict.keys():
    dict[A[i]] += 1
  else:
    dict[A[i]] = 1

def comb(n):
  if n<2:
    return 0
  return int(n * (n - 1) / 2)

# all
ret = 0
for key in dict.keys():
  val = dict[key]
  ret += comb(val)

# i >= 0
for i in range(N):
  val_n = dict[A[i]]
  next_ret = ret - comb(val_n) + comb(val_n - 1)
  print(next_ret)

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
N = int(input())
A = input().split()

# total count
dict = set(A)
total_count = 0
for val in dict:
  tmp = A.count(val)
  tmp = int(tmp*(tmp-1)/2)
  total_count += tmp

# substracted count
for k in range(N):
  sub_count = A.count(A[k]) - 1
  print('{}'.format(total_count - sub_count))

Fixed submission:
# coding: utf-8
N = int(input())
A = list(map(int, input().split()))

dict = {}
for i in range(N):
  if A[i] in dict.keys():
    dict[A[i]] += 1
  else:
    dict[A[i]] = 1

def comb(n):
  if n<2:
    return 0
  return int(n * (n - 1) / 2)

# all
ret = 0
for key in dict.keys():
  val = dict[key]
  ret += comb(val)

# i >= 0
for i in range(N):
  val_n = dict[A[i]]
  next_ret = ret - comb(val_n) + comb(val_n - 1)
  print(next_ret)

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
N = int(input())
A = input().split()
for k in range(N):
  A_ = A.copy()
  del A_[k]
  ans = 0
  while len(A_) > 0:
    val = A_[0]
    counts = A_.count(val)
    ans += int(counts * (counts - 1) / 2)
    while True:
      try:
        A_.remove(val)
      except:
        break

  print('{}'.format(ans))

Fixed submission:
# coding: utf-8
N = int(input())
A = list(map(int, input().split()))

dict = {}
for i in range(N):
  if A[i] in dict.keys():
    dict[A[i]] += 1
  else:
    dict[A[i]] = 1

def comb(n):
  if n<2:
    return 0
  return int(n * (n - 1) / 2)

# all
ret = 0
for key in dict.keys():
  val = dict[key]
  ret += comb(val)

# i >= 0
for i in range(N):
  val_n = dict[A[i]]
  next_ret = ret - comb(val_n) + comb(val_n - 1)
  print(next_ret)

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
N = int(input())
A = input().split()
for k in range(N):
  A_ = A.copy()
  del A_[k]
  dic = set(A_)
  ans = 0
  for i in dic:
    tmp = A_.count(i)
    if tmp == 1:
      continue
    ans += int(tmp * (tmp - 1) / 2)

  print('{}'.format(ans))

Fixed submission:
# coding: utf-8
N = int(input())
A = list(map(int, input().split()))

dict = {}
for i in range(N):
  if A[i] in dict.keys():
    dict[A[i]] += 1
  else:
    dict[A[i]] = 1

def comb(n):
  if n<2:
    return 0
  return int(n * (n - 1) / 2)

# all
ret = 0
for key in dict.keys():
  val = dict[key]
  ret += comb(val)

# i >= 0
for i in range(N):
  val_n = dict[A[i]]
  next_ret = ret - comb(val_n) + comb(val_n - 1)
  print(next_ret)

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
N = int(input())
A = input().split()
for k in range(N):
  A_ = A.copy()
  del A_[k]
  dic = set(A_)
  ans = 0
  for i in dic:
    tmp = A_.count(i)
    ans += int(tmp * (tmp - 1) / 2)

  print('{}'.format(ans))

Fixed submission:
# coding: utf-8
N = int(input())
A = list(map(int, input().split()))

dict = {}
for i in range(N):
  if A[i] in dict.keys():
    dict[A[i]] += 1
  else:
    dict[A[i]] = 1

def comb(n):
  if n<2:
    return 0
  return int(n * (n - 1) / 2)

# all
ret = 0
for key in dict.keys():
  val = dict[key]
  ret += comb(val)

# i >= 0
for i in range(N):
  val_n = dict[A[i]]
  next_ret = ret - comb(val_n) + comb(val_n - 1)
  print(next_ret)

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
N = int(input())
A = input().split()
for k in range(N):
  A_ = A.copy()
  del A_[k]
  dict = {}
  for i in range(N-1):
    if A_[i] in dict.keys():
      dict[A_[i]] += 1
    else:
      dict[A_[i]] = 1

  ans = 0
  for key in dict.keys():
    ans += int(dict[key] * (dict[key] - 1) / 2)
  print('{}'.format(ans))

Fixed submission:
# coding: utf-8
N = int(input())
A = list(map(int, input().split()))

dict = {}
for i in range(N):
  if A[i] in dict.keys():
    dict[A[i]] += 1
  else:
    dict[A[i]] = 1

def comb(n):
  if n<2:
    return 0
  return int(n * (n - 1) / 2)

# all
ret = 0
for key in dict.keys():
  val = dict[key]
  ret += comb(val)

# i >= 0
for i in range(N):
  val_n = dict[A[i]]
  next_ret = ret - comb(val_n) + comb(val_n - 1)
  print(next_ret)