Buggy python submission (verdict: Time Limit Exceeded):
n = input()
n = int(n)
lin = input().split()
# 要素の個数を求める
dic_s = {}
for c in lin:
  dic_s.setdefault(c, 0)
  dic_s[c] += 1
# 1つしかない要素は計算対象外
dic_cp = dic_s.copy()
for key, value in dic_cp.items():
  if value == 1:
    del dic_s[key]
dic_tot = {}
for c in lin:
  # 1度求めたら再計算しない
  # 同じ数字が多いと時間短縮
  if dic_tot.get(c):
    print(int(dic_tot[c]))
  else:
    # 指定数値を除いた2つを選ぶ
    tot = 0
    for key,value in dic_s.items():
      v = value
      if key == c:
        v -= 1
      tot += v * (v - 1) / 2
    dic_tot.setdefault(c,tot)
    print(int(tot))

Fixed submission:
n = input()
n = int(n)
lin = input().split()
# 要素の個数を求める
dic_s = {}
for c in lin:
  dic_s.setdefault(c, 0)
  dic_s[c] += 1
# ペアの総数
tot = 0
for key,value in dic_s.items():
  v = value
  tot += v * (v - 1) / 2
# print(int(tot))
# 指定位置のペアを除く
for c in lin:
  if tot > 0:
    v = dic_s[c]
    print(int(tot-(v-1)))
  else:
    print(0)

Buggy python submission (verdict: Runtime Error):
n = input()
n = int(n)
lin = input().split()
# 要素の個数を求める
dic_s = {}
for c in lin:
  dic_s.setdefault(c, 0)
  dic_s[c] += 1
# 1つしかない要素は計算対象外
for key, value in dic_s.items():
  if value == 1:
    del dic_s[key]
dic_tot = {}
for c in lin:
  # 1度求めたら再計算しない
  # 同じ数字が多いと時間短縮
  if dic_tot.get(c):
    print(int(dic_tot[c]))
  else:
    # 指定数値を除いた2つを選ぶ
    tot = 0
    for key,value in dic_s.items():
      v = value
      if key == c:
        v -= 1
      if v > 1:
        tot += v * (v - 1) / 2
    dic_tot.setdefault(c,tot)
    print(int(tot))

Fixed submission:
n = input()
n = int(n)
lin = input().split()
# 要素の個数を求める
dic_s = {}
for c in lin:
  dic_s.setdefault(c, 0)
  dic_s[c] += 1
# ペアの総数
tot = 0
for key,value in dic_s.items():
  v = value
  tot += v * (v - 1) / 2
# print(int(tot))
# 指定位置のペアを除く
for c in lin:
  if tot > 0:
    v = dic_s[c]
    print(int(tot-(v-1)))
  else:
    print(0)

Buggy python submission (verdict: Time Limit Exceeded):
n = input()
n = int(n)
lin = input().split()
# 要素の個数を求める
dic_s = {}
for c in lin:
  dic_s.setdefault(c, 0)
  dic_s[c] += 1
dic_tot = {}
for c in lin:
  if dic_tot.get(c):
    print(int(dic_tot[c]))
  else:
    tot = 0
    for key,value in dic_s.items():
      v = value
      if key == c:
        v -= 1
      if v > 1:
        tot += v * (v - 1) / 2
    dic_tot.setdefault(c,tot)
    print(int(tot))

Fixed submission:
n = input()
n = int(n)
lin = input().split()
# 要素の個数を求める
dic_s = {}
for c in lin:
  dic_s.setdefault(c, 0)
  dic_s[c] += 1
# ペアの総数
tot = 0
for key,value in dic_s.items():
  v = value
  tot += v * (v - 1) / 2
# print(int(tot))
# 指定位置のペアを除く
for c in lin:
  if tot > 0:
    v = dic_s[c]
    print(int(tot-(v-1)))
  else:
    print(0)

Buggy python submission (verdict: Time Limit Exceeded):
n = input()
n = int(n)
lin = input().split()
# 要素の個数を求める
dic_s = {}
for c in lin:
  dic_s.setdefault(c, 0)
  dic_s[c] += 1
for c in lin:
  tot = 0
  for key,value in dic_s.items():
    v = value
    if key == c:
      v -= 1
    if v > 1:
      tot += v * (v - 1) / 2
  print(int(tot))

Fixed submission:
n = input()
n = int(n)
lin = input().split()
# 要素の個数を求める
dic_s = {}
for c in lin:
  dic_s.setdefault(c, 0)
  dic_s[c] += 1
# ペアの総数
tot = 0
for key,value in dic_s.items():
  v = value
  tot += v * (v - 1) / 2
# print(int(tot))
# 指定位置のペアを除く
for c in lin:
  if tot > 0:
    v = dic_s[c]
    print(int(tot-(v-1)))
  else:
    print(0)

Buggy python submission (verdict: Time Limit Exceeded):
n = input()
n = int(n)
lin = input().split()
i = 0
while i < len(lin):
  sl = []
  sr = []
  if i > 0:
    sl = lin[0:i]
  if i < len(lin)-1:
    sr = lin[i+1:]
  # print("sl,sr=",sl,sr)
  sl.extend(sr)
  s = sl
  i+=1
  # 要素の個数を求める
  dic_s = {}
  for c in s:
    dic_s.setdefault(c, 0)
    dic_s[c] += 1
  tot = 0
  for key,value in dic_s.items():
    if value > 1:
      tot += value * (value - 1) / 2
  print(int(tot))

Fixed submission:
n = input()
n = int(n)
lin = input().split()
# 要素の個数を求める
dic_s = {}
for c in lin:
  dic_s.setdefault(c, 0)
  dic_s[c] += 1
# ペアの総数
tot = 0
for key,value in dic_s.items():
  v = value
  tot += v * (v - 1) / 2
# print(int(tot))
# 指定位置のペアを除く
for c in lin:
  if tot > 0:
    v = dic_s[c]
    print(int(tot-(v-1)))
  else:
    print(0)