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

from scipy.misc import comb #scipy.special

#import numpy as np

n = int(input())

a = [int(i) for i in input().split()]

dict = {}

asort = sorted(a)

#print(asort)

sum = 0
i = 0
while i < n-1:
    counter = 1
    index = asort[i]
    while  i < n-1 and asort[i] == asort[i+1]:
        #print("yes")
        counter +=1
        i+=1
    #print("no")
    i+=1
    dict[(index)] = [counter,comb(counter,2),comb(counter-1,2)]
    sum+=dict[(index)][1]




for i in a:
    print(int(sum-dict[(i)][1]+dict[(i)][2]))


Fixed submission:
import sys

#from scipy.misc import comb #scipy.special

#import numpy as np

def choose(n):
    return n*(n-1)/2

n = int(input())

a = [int(i) for i in input().split()]

bunpu = [0]*(n+1)

for i in range(len(a)):
    bunpu[a[i]]+=1


sum = 0
for i in bunpu:
    sum+=choose(i)
i = 0
for i in a:
    print(int(sum-choose(bunpu[i])+choose(bunpu[i]-1)))

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

from scipy.special import comb #scipy.special

#import numpy as np

n = int(input())

a = [int(i) for i in input().split()]

dict = {}

asort = sorted(a)

#print(asort)

sum = 0
i = 0
while i < n-1:
    counter = 1
    index = asort[i]
    while  i < n-1 and asort[i] == asort[i+1]:
        #print("yes")
        counter +=1
        i+=1
    #print("no")
    i+=1
    dict[(index)] = [counter,comb(counter,2),comb(counter-1,2)]
    sum+=dict[(index)][1]




for i in a:
    print(int(sum-dict[(i)][1]+dict[(i)][2]))


Fixed submission:
import sys

#from scipy.misc import comb #scipy.special

#import numpy as np

def choose(n):
    return n*(n-1)/2

n = int(input())

a = [int(i) for i in input().split()]

bunpu = [0]*(n+1)

for i in range(len(a)):
    bunpu[a[i]]+=1


sum = 0
for i in bunpu:
    sum+=choose(i)
i = 0
for i in a:
    print(int(sum-choose(bunpu[i])+choose(bunpu[i]-1)))

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

from scipy.special import comb

#import numpy as np

n = int(input())

a = [int(i) for i in input().split()]

num = [[-1,0,0]]*(200000)

asort = sorted(a)

#print(asort)

sum = 0
i = 0
while i < n-1:
    counter = 1
    index = asort[i]
    while  i < n-1 and asort[i] == asort[i+1]:
        #print("yes")
        counter +=1
        i+=1
    #print("no")
    i+=1
    num[index] = [counter,comb(counter,2),comb(counter-1,2)]
    sum+=num[index][1]




for i in a:
    print(int(sum-num[i][1]+num[i][2]))


Fixed submission:
import sys

#from scipy.misc import comb #scipy.special

#import numpy as np

def choose(n):
    return n*(n-1)/2

n = int(input())

a = [int(i) for i in input().split()]

bunpu = [0]*(n+1)

for i in range(len(a)):
    bunpu[a[i]]+=1


sum = 0
for i in bunpu:
    sum+=choose(i)
i = 0
for i in a:
    print(int(sum-choose(bunpu[i])+choose(bunpu[i]-1)))

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

from scipy.special import comb

#import numpy as np

n = int(input())

a = [int(i) for i in input().split()]

num = [[-1,0,0]]*(200000)

asort = sorted(a)

#print(asort)

i = 0
while i < n-1:
    counter = 1
    index = asort[i]
    while  i < n-1 and asort[i] == asort[i+1]:
        #print("yes")
        counter +=1
        i+=1
    #print("no")
    i+=1
    num[index] = [counter,comb(counter,2),comb(counter-1,2)]

sum=0
for i in range(200000):
    sum +=num[i][1]

for i in a:
    print(int(sum-num[i][1]+num[i][2]))


Fixed submission:
import sys

#from scipy.misc import comb #scipy.special

#import numpy as np

def choose(n):
    return n*(n-1)/2

n = int(input())

a = [int(i) for i in input().split()]

bunpu = [0]*(n+1)

for i in range(len(a)):
    bunpu[a[i]]+=1


sum = 0
for i in bunpu:
    sum+=choose(i)
i = 0
for i in a:
    print(int(sum-choose(bunpu[i])+choose(bunpu[i]-1)))