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

N = int(input())
A = list(map(int, input().split()))
ans = 0

C = list(set(A))
M = len(C)
t = []
anst = 0
jisyo = {}
for i in range(M):
  temp = A.count(C[i])
  jisyo[C[i]] = temp
  #t.append(A.count(C[i]))
  if temp >=2:
    anst += temp*(temp-1)/2

#jisyo = dict(zip(C, t))
#print(jisyo)   
for i in range(N):
  #print(t[C.index(A[i])])
  print(int(anst-jisyo[A[i]]+1))

Fixed submission:
import math

N = int(input())
A = list(map(int, input().split()))
ans = 0

C = list(set(A))
M = len(C)
t = []
anst = 0
dic = {}
for i in A:
  if not i in dic:
    dic[i] = 0
  dic[i] += 1

jisyo = {}
for i in range(M):
  temp = dic[C[i]]
  jisyo[C[i]] = temp
  #t.append(A.count(C[i]))
  if temp >=2:
    anst += temp*(temp-1)/2

#jisyo = dict(zip(C, t))
#print(jisyo)   
for i in range(N):
  #print(t[C.index(A[i])])
  print(int(anst-jisyo[A[i]]+1))

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

N = int(input())
A = list(map(int, input().split()))
ans = 0

C = list(set(A))
M = len(C)
t = []
anst = 0
for i in range(M):
  t.append(A.count(C[i]))
  temp = A.count(C[i])
  if temp >=2:
    anst += temp*(temp-1)/2

jisyo = dict(zip(C, t))
    
for i in range(N):
  #print(t[C.index(A[i])])
  print(int(anst-jisyo[A[i]]+1))

Fixed submission:
import math

N = int(input())
A = list(map(int, input().split()))
ans = 0

C = list(set(A))
M = len(C)
t = []
anst = 0
dic = {}
for i in A:
  if not i in dic:
    dic[i] = 0
  dic[i] += 1

jisyo = {}
for i in range(M):
  temp = dic[C[i]]
  jisyo[C[i]] = temp
  #t.append(A.count(C[i]))
  if temp >=2:
    anst += temp*(temp-1)/2

#jisyo = dict(zip(C, t))
#print(jisyo)   
for i in range(N):
  #print(t[C.index(A[i])])
  print(int(anst-jisyo[A[i]]+1))

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

N = int(input())
A = list(map(int, input().split()))
ans = 0

C = list(set(A))
M = len(C)
t = []
anst = 0
for i in range(M):
  t.append(A.count(C[i]))
  temp = A.count(C[i])
  if temp >=2:
    anst += temp*(temp-1)/2

#print(t)
#print(anst)
#print(jisyo[1])
for i in range(N):
  #print(t[C.index(A[i])])
  print(int(anst-t[C.index(A[i])]+1))

Fixed submission:
import math

N = int(input())
A = list(map(int, input().split()))
ans = 0

C = list(set(A))
M = len(C)
t = []
anst = 0
dic = {}
for i in A:
  if not i in dic:
    dic[i] = 0
  dic[i] += 1

jisyo = {}
for i in range(M):
  temp = dic[C[i]]
  jisyo[C[i]] = temp
  #t.append(A.count(C[i]))
  if temp >=2:
    anst += temp*(temp-1)/2

#jisyo = dict(zip(C, t))
#print(jisyo)   
for i in range(N):
  #print(t[C.index(A[i])])
  print(int(anst-jisyo[A[i]]+1))

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

N = int(input())
A = list(map(int, input().split()))
ans = 0

C = list(set(A))
M = len(C)
t = []
anst = 0
for i in range(M):
  t.append(A.count(C[i]))
  temp = A.count(C[i])
  if temp >=2:
    anst += math.factorial(temp)/(math.factorial(temp-2)*2)

#print(t)
#print(anst)
#print(jisyo[1])
for i in range(N):
  #print(t[C.index(A[i])])
  print(int(anst-t[C.index(A[i])]+1))


Fixed submission:
import math

N = int(input())
A = list(map(int, input().split()))
ans = 0

C = list(set(A))
M = len(C)
t = []
anst = 0
dic = {}
for i in A:
  if not i in dic:
    dic[i] = 0
  dic[i] += 1

jisyo = {}
for i in range(M):
  temp = dic[C[i]]
  jisyo[C[i]] = temp
  #t.append(A.count(C[i]))
  if temp >=2:
    anst += temp*(temp-1)/2

#jisyo = dict(zip(C, t))
#print(jisyo)   
for i in range(N):
  #print(t[C.index(A[i])])
  print(int(anst-jisyo[A[i]]+1))

Buggy python submission (verdict: Runtime Error):
import math

N = int(input())
A = list(map(int, input().split()))
ans = 0

C = list(set(A))
M = len(C)
t = []
anst = 0
for i in range(M):
  t.append(A.count(C[i]))
  temp = A.count(C[i])
  anst += math.factorial(temp)/(math.factorial(temp-2)*2)

#print(t)
#print(anst)
#print(jisyo[1])
for i in range(N):
  #print(t[C.index(A[i])])
  print(int(anst-t[C.index(A[i])]+1))

Fixed submission:
import math

N = int(input())
A = list(map(int, input().split()))
ans = 0

C = list(set(A))
M = len(C)
t = []
anst = 0
dic = {}
for i in A:
  if not i in dic:
    dic[i] = 0
  dic[i] += 1

jisyo = {}
for i in range(M):
  temp = dic[C[i]]
  jisyo[C[i]] = temp
  #t.append(A.count(C[i]))
  if temp >=2:
    anst += temp*(temp-1)/2

#jisyo = dict(zip(C, t))
#print(jisyo)   
for i in range(N):
  #print(t[C.index(A[i])])
  print(int(anst-jisyo[A[i]]+1))

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

N = int(input())
A = list(map(int, input().split()))
ans = 0

C = list(set(A))
M = len(C)
t = []
t1 = []
t2 = []
for i in range(M):
  #t.append(A.count(C[i]))
  temp = A.count(C[i])
  if temp >=3:
    t1.append(math.factorial(temp-1)/(math.factorial(temp-3)*2))
    t2.append(math.factorial(temp)/(math.factorial(temp-2)*2))    
  elif temp == 2:
    t1.append(0)
    t2.append(math.factorial(temp)/(math.factorial(temp-2)*2))
  else:
    t1.append(0)
    t2.append(0)

#print(t,t1,t2)


s = []  
for i in range(M):
  ans = 0
  for j in range(M):
    if i == j:
      ans += t1[j]
    else:
      ans += t2[j]
  s.append(int(ans))

jisyo = dict(zip(C,s))
#print(jisyo[1])
for i in range(N):
  print(jisyo[A[i]])

Fixed submission:
import math

N = int(input())
A = list(map(int, input().split()))
ans = 0

C = list(set(A))
M = len(C)
t = []
anst = 0
dic = {}
for i in A:
  if not i in dic:
    dic[i] = 0
  dic[i] += 1

jisyo = {}
for i in range(M):
  temp = dic[C[i]]
  jisyo[C[i]] = temp
  #t.append(A.count(C[i]))
  if temp >=2:
    anst += temp*(temp-1)/2

#jisyo = dict(zip(C, t))
#print(jisyo)   
for i in range(N):
  #print(t[C.index(A[i])])
  print(int(anst-jisyo[A[i]]+1))

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

N = int(input())
A = list(map(int, input().split()))
ans = 0

C = list(set(A))
M = len(C)
t = []
t1 = []
t2 = []
for i in range(M):
  t.append(A.count(C[i]))
  temp = A.count(C[i])
  if temp >=3:
    t1.append(math.factorial(temp-1)/(math.factorial(temp-3)*2))
    t2.append(math.factorial(temp)/(math.factorial(temp-2)*2))    
  elif temp == 2:
    t1.append(0)
    t2.append(math.factorial(temp)/(math.factorial(temp-2)*2))
  else:
    t1.append(0)
    t2.append(0)

#print(t,t1,t2)


s = []  
for i in range(M):
  ans = 0
  for j in range(M):
    if i == j:
      ans += t1[j]
    else:
      ans += t2[j]
  s.append(int(ans))

jisyo = dict(zip(C,s))
#print(jisyo[1])
for i in range(N):
  print(jisyo[A[i]])

Fixed submission:
import math

N = int(input())
A = list(map(int, input().split()))
ans = 0

C = list(set(A))
M = len(C)
t = []
anst = 0
dic = {}
for i in A:
  if not i in dic:
    dic[i] = 0
  dic[i] += 1

jisyo = {}
for i in range(M):
  temp = dic[C[i]]
  jisyo[C[i]] = temp
  #t.append(A.count(C[i]))
  if temp >=2:
    anst += temp*(temp-1)/2

#jisyo = dict(zip(C, t))
#print(jisyo)   
for i in range(N):
  #print(t[C.index(A[i])])
  print(int(anst-jisyo[A[i]]+1))

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

N = int(input())
A = list(map(int, input().split()))
ans = 0

C = list(set(A))
M = len(C)
t = []
for i in range(M):
  t.append(A.count(C[i]))


s = []  
for i in range(M):
  ans = 0
  for j in range(M):
    if i == j:
      p = t[j]-1
    else:
      p = t[j]
    if p >=2:
      ans += math.factorial(p)/(math.factorial(p-2)*2)
  s.append(int(ans))

jisyo = dict(zip(C,s))
#print(jisyo[1])
for i in range(N):
  print(jisyo[A[i]])

Fixed submission:
import math

N = int(input())
A = list(map(int, input().split()))
ans = 0

C = list(set(A))
M = len(C)
t = []
anst = 0
dic = {}
for i in A:
  if not i in dic:
    dic[i] = 0
  dic[i] += 1

jisyo = {}
for i in range(M):
  temp = dic[C[i]]
  jisyo[C[i]] = temp
  #t.append(A.count(C[i]))
  if temp >=2:
    anst += temp*(temp-1)/2

#jisyo = dict(zip(C, t))
#print(jisyo)   
for i in range(N):
  #print(t[C.index(A[i])])
  print(int(anst-jisyo[A[i]]+1))

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

N = int(input())
A = list(map(int, input().split()))
ans = 0

C = list(set(A))
M = len(C)
t = []
for i in range(M):
  t.append(A.count(C[i]))


s = []  
for i in range(M):
  ans = 0
  for j in range(M):
    if i == j:
      p = t[j]-1
    else:
      p = t[j]
    if p >=2:
      ans += math.factorial(p)/(math.factorial(p-2)*2)
  s.append(int(ans))

for i in range(N):
  print(s[C.index(A[i])])

Fixed submission:
import math

N = int(input())
A = list(map(int, input().split()))
ans = 0

C = list(set(A))
M = len(C)
t = []
anst = 0
dic = {}
for i in A:
  if not i in dic:
    dic[i] = 0
  dic[i] += 1

jisyo = {}
for i in range(M):
  temp = dic[C[i]]
  jisyo[C[i]] = temp
  #t.append(A.count(C[i]))
  if temp >=2:
    anst += temp*(temp-1)/2

#jisyo = dict(zip(C, t))
#print(jisyo)   
for i in range(N):
  #print(t[C.index(A[i])])
  print(int(anst-jisyo[A[i]]+1))

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

N = int(input())
A = list(map(int, input().split()))
ans = 0

for k in range(N):
  ans = 0
  B = A.copy()
  del B[k] #ここでBはk番目が削除されたものとなっている。
  C = list(set(B)) 
  M = len(C)
  for i in range(M):
    if B.count(C[i]) >=2:
      t = B.count(C[i])
      ans += math.factorial(t)/((math.factorial(t-2))*(math.factorial(2)))
  print(int(ans))

Fixed submission:
import math

N = int(input())
A = list(map(int, input().split()))
ans = 0

C = list(set(A))
M = len(C)
t = []
anst = 0
dic = {}
for i in A:
  if not i in dic:
    dic[i] = 0
  dic[i] += 1

jisyo = {}
for i in range(M):
  temp = dic[C[i]]
  jisyo[C[i]] = temp
  #t.append(A.count(C[i]))
  if temp >=2:
    anst += temp*(temp-1)/2

#jisyo = dict(zip(C, t))
#print(jisyo)   
for i in range(N):
  #print(t[C.index(A[i])])
  print(int(anst-jisyo[A[i]]+1))