Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import numpy as np 
import math

# 入力
N = int(input())
A = input()

A = np.array(A.split()).astype('int')
ones = np.ones([N, N])
B = (A*ones)
for i in range(N):
    B[i, i] = 0
B = B[np.where(B != 0, True, False)].reshape(N, N-1)
B.sort()

def comb(n, r):
    if n < r:
        return 0
    else:
        return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
      
def uniq_2_comb(N, ar):
    u = np.unique(ar, return_index=True)[1]
    u = np.concatenate([u, np.array([N-1])])
    ans = 0
    for i in range(len(u)-1):
        n = u[i+1] - u[i]
        ans += comb(n, 2)
    return ans

#ans_ar = np.apply_along_axis(lambda x : uniq_2_comb(N, x), 1, B)
for i in range(len(B)):
    print(uniq_2_comb(N, B[i]))
  

#for a in ans_ar:
#    print(a)

Fixed submission:
# -*- coding: utf-8 -*-
import collections
import math

# 入力
N = int(input())
A = list(input().split())

c = collections.Counter(A)

def comb(n, r):
    if n < r:
        return 0
    else:
        return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

comb_sum = 0
for i in c:
    comb_sum += comb(c[i], 2)
     
for a in A:
    ans = comb_sum
    if c[a] >= 2:
        ans -= (c[a] - 1)
    print(ans)

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import numpy as np 
import math

# 入力
N = int(input())
A = input()

A = np.array(A.split()).astype('int')
ones = np.ones([N, N])
B = (A*ones)
for i in range(N):
    B[i, i] = 0
B = B[np.where(B != 0, True, False)].reshape(N, N-1)
B.sort()

def comb(n, r):
    if n < r:
        return 0
    else:
        return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
      
def uniq_2_comb(N, ar):
    u = np.unique(ar, return_index=True)[1]
    u = np.concatenate([u, np.array([N-1])])
    ans = 0
    for i in range(len(u)-1):
        n = u[i+1] - u[i]
        ans += comb(n, 2)
    return ans

ans_ar = np.apply_along_axis(lambda x : uniq_2_comb(N, x), 1, B)

for a in ans_ar:
    print(a)

Fixed submission:
# -*- coding: utf-8 -*-
import collections
import math

# 入力
N = int(input())
A = list(input().split())

c = collections.Counter(A)

def comb(n, r):
    if n < r:
        return 0
    else:
        return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

comb_sum = 0
for i in c:
    comb_sum += comb(c[i], 2)
     
for a in A:
    ans = comb_sum
    if c[a] >= 2:
        ans -= (c[a] - 1)
    print(ans)

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import numpy as np 
import math

# 入力
N = int(input())
A = input()

A = np.array(A.split()).astype('int')
ones = np.ones([N, N])
B = (A*ones)
for i in range(N):
    B[i, i] = 0
B = B[np.where(B != 0, True, False)].reshape(N, N-1)
B.sort()

def comb(n, r):
    if n < r:
        return 0
    else:
        return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
      
def uniq_2_comb(N, ar):
    u = np.unique(ar, return_index=True)[1]
    u = np.concatenate([u, np.array([N-1])])
    ans = 0
    for i in range(len(u)-1):
        n = u[i+1] - u[i]
        ans += comb(n, 2)
    return ans

ans_ar = np.apply_along_axis(lambda x : uniq_2_comb(N, x), 1, B)

for ans in ans_ar:
    print(ans)


Fixed submission:
# -*- coding: utf-8 -*-
import collections
import math

# 入力
N = int(input())
A = list(input().split())

c = collections.Counter(A)

def comb(n, r):
    if n < r:
        return 0
    else:
        return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

comb_sum = 0
for i in c:
    comb_sum += comb(c[i], 2)
     
for a in A:
    ans = comb_sum
    if c[a] >= 2:
        ans -= (c[a] - 1)
    print(ans)

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import numpy as np 
import math

# 入力
N = int(input())
A = input()

A = np.array(A.split()).astype('int')
ones = np.ones([N, N])
B = (A*ones)
for i in range(N):
  B[i, i] = 0
B = B[np.where(B != 0, True, False)].reshape(N, N-1)
B.sort()

def comb(n, r):
  if n < r:
    return 0
  else:
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
      
def uniq_2_comb(N, ar):
  u = np.unique(ar, return_index=True)[1]
  u = np.concatenate([u, np.array([N-1])])
  ans = 0
  for i in range(len(u)-1):
    n = u[i+1] - u[i]
    ans += comb(n, 2)
  return ans

ans_ar = np.apply_along_axis(lambda x : uniq_2_comb(N, x), 1, B)

for ans in ans_ar:
  print(ans)


Fixed submission:
# -*- coding: utf-8 -*-
import collections
import math

# 入力
N = int(input())
A = list(input().split())

c = collections.Counter(A)

def comb(n, r):
    if n < r:
        return 0
    else:
        return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

comb_sum = 0
for i in c:
    comb_sum += comb(c[i], 2)
     
for a in A:
    ans = comb_sum
    if c[a] >= 2:
        ans -= (c[a] - 1)
    print(ans)

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import numpy as np 
import math

# 入力
N = int(input())
A = input()

A = np.array(A.split()).astype('int')
ones = np.ones([N, N])
B = (A*ones)
for i in range(N):
  B[i, i] = 0
B = B[np.where(B != 0, True, False)].reshape(N, N-1)
B.sort()

def comb(n, r):
    if n < r:
        return 0
    else:
        return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
      
def uniq_2_comb(N, ar):
  u = np.unique(ar, return_index=True)[1]
  u = np.concatenate([u, np.array([N-1])])
  ans = 0
  for i in range(len(u)-1):
    n = u[i+1] - u[i]
    ans += comb(n, 2)
  return ans

ans_ar = np.apply_along_axis(lambda x : uniq_2_comb(N, x), 1, B)

for ans in ans_ar:
  print(ans)


Fixed submission:
# -*- coding: utf-8 -*-
import collections
import math

# 入力
N = int(input())
A = list(input().split())

c = collections.Counter(A)

def comb(n, r):
    if n < r:
        return 0
    else:
        return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

comb_sum = 0
for i in c:
    comb_sum += comb(c[i], 2)
     
for a in A:
    ans = comb_sum
    if c[a] >= 2:
        ans -= (c[a] - 1)
    print(ans)

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import numpy as np 
import math

# 入力
N = int(input())
A = input()

A = np.array(A.split()).astype('int')
ones = np.ones([N, N])
B = (A*ones)
for i in range(N):
  B[i, i] = 0
B = B[np.where(B != 0, True, False)].reshape(N, N-1)
B.sort()

def comb(n, r):
    if n < r:
        return 0
    else:
        return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
      
def uniq_2_comb(N, ar):
  u = np.unique(ar, return_index=True)[1]
  u = np.concatenate([u, np.array([N])])
  ans = 0
  for i in range(len(u)-1):
    n = u[i+1] - u[i]
    ans += comb(n, 2)
  return ans

ans_ar = np.apply_along_axis(lambda x : uniq_2_comb(N, x), 1, B)

for ans in ans_ar:
  print(ans)


Fixed submission:
# -*- coding: utf-8 -*-
import collections
import math

# 入力
N = int(input())
A = list(input().split())

c = collections.Counter(A)

def comb(n, r):
    if n < r:
        return 0
    else:
        return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

comb_sum = 0
for i in c:
    comb_sum += comb(c[i], 2)
     
for a in A:
    ans = comb_sum
    if c[a] >= 2:
        ans -= (c[a] - 1)
    print(ans)

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import numpy as np 
import math

# 入力
N = int(input())
A = input()

A = np.array(A.split()).astype('int')
ones = np.ones([N, N])
B = (A*ones)
for i in range(N):
  B[i, i] = 0
B = B[np.where(B != 0, True, False)].reshape(N, N-1)
B.sort()

def comb(n, r):
    if n < r:
        return 0
    else:
        return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
      
def uniq_2_comb(N, ar):
  u = np.unique(ar, return_index=True)[1]
  ans = 0
  for i in range(len(u)-1):
    n = u[i+1] - u[i]
    ans += comb(n, 2)
  return ans

ans_ar = np.apply_along_axis(lambda x : uniq_2_comb(N, x), 1, B)

for ans in ans_ar:
  print(ans)

Fixed submission:
# -*- coding: utf-8 -*-
import collections
import math

# 入力
N = int(input())
A = list(input().split())

c = collections.Counter(A)

def comb(n, r):
    if n < r:
        return 0
    else:
        return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

comb_sum = 0
for i in c:
    comb_sum += comb(c[i], 2)
     
for a in A:
    ans = comb_sum
    if c[a] >= 2:
        ans -= (c[a] - 1)
    print(ans)