Buggy python submission (verdict: Runtime Error):
import copy
import collections

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

nCr = {}
def cmb(n,r):
    if (n,r) in nCr:
        return nCr[(n,r)]
    if r > n:
        return 0
    if r == 0 or r == n:
        return 1
    if r == 1:
        return n
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]

col = collections.Counter(A)
for a in A:
    s = 0
    if a in col.keys():
        col[a] = col[a] - 1
        for i in col:
            s += cmb(col[i],2)
        col[a] = col[a] + 1         
    print(s)


Fixed submission:
from collections import Counter

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

cnt = Counter(A)
s = 0
for v in cnt.values():
    s += v*(v-1)//2

for a in A:
    print(s - (cnt[a]-1))

Buggy python submission (verdict: Runtime Error):
import copy
import collections

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

nCr = {}
def cmb(n,r):
    if (n,r) in nCr:
        return nCr[(n,r)]
    if r > n:
        return 0
    if r == 0 or r == n:
        return 1
    if r == 1:
        return n
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]

col = collections.Counter(A)
for a in A:
    c = col.copy()
    c[a] = c[a] - 1
    s = 0
    for i in c:
        s += cmb(c[i],2)
    print(s)


Fixed submission:
from collections import Counter

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

cnt = Counter(A)
s = 0
for v in cnt.values():
    s += v*(v-1)//2

for a in A:
    print(s - (cnt[a]-1))

Buggy python submission (verdict: Runtime Error):
import copy
import collections

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

nCr = {}
def cmb(n,r):
    if r > n:
        return 0
    if r == 0 or r == n:
        return 1
    if r == 1:
        return n
    if (n,r) in nCr:
        return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]

col = collections.Counter(A)
for a in A:
    c = col.copy()
    c[a] = c[a] - 1
    s = 0
    for i in c:
        s += cmb(c[i],2)
    print(s)


Fixed submission:
from collections import Counter

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

cnt = Counter(A)
s = 0
for v in cnt.values():
    s += v*(v-1)//2

for a in A:
    print(s - (cnt[a]-1))

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))

nCr = {}
def cmb(n,r):
    if r > n:
        return 0
    if r == 0 or r == n:
        return 1
    if r == 1:
        return n
    if (n,r) in nCr.keys():
        return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]

mem_cnt = [0] * N
set_a = set(A)
for c in list(set_a):
    mem_cnt[c] = A.count(c)

for k in A:
    ret = 0
    for v in mem_cnt:
        x = v
        ret += cmb(x,2)
    print(ret)


Fixed submission:
from collections import Counter

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

cnt = Counter(A)
s = 0
for v in cnt.values():
    s += v*(v-1)//2

for a in A:
    print(s - (cnt[a]-1))

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

#N = int(input())
#A = list(map(int,input().split()))
N = 5
A = [3,3,3,3,3]


nCr = {}
def cmb(n,r):
    if r > n:
        return 0
    if r == 0 or r == n:
        return 1
    if r == 1:
        return n
    if (n,r) not in nCr:
        return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]

mem_cnt = [0] * N
set_a = set(A)
for c in list(set_a):
    mem_cnt[c] = A.count(c)

for k in A:
    ret = 0
    for v in mem_cnt:
        x = v
        ret += cmb(x,2)
    print(ret)


Fixed submission:
from collections import Counter

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

cnt = Counter(A)
s = 0
for v in cnt.values():
    s += v*(v-1)//2

for a in A:
    print(s - (cnt[a]-1))

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))

nCr = {}
def cmb(n,r):
    if r > n:
        return 0
    if r == 0 or r == n:
        return 1
    if r == 1:
        return n
    if (n,r) in nCr.keys():
        return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]

mem_cnt = {}
set_a = set(A)
for c in list(set_a):
    if str(c) not in mem_cnt.keys():
        mem_cnt[str(c)] = A.count(c)

for k in A:
    ret = 0
    for key,v in mem_cnt.items():
        x = v
        if str(key) == str(k):
            x = v-1
        ret += cmb(x,2)
    print(ret)


Fixed submission:
from collections import Counter

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

cnt = Counter(A)
s = 0
for v in cnt.values():
    s += v*(v-1)//2

for a in A:
    print(s - (cnt[a]-1))

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))

def cmb(n,r):
    if r > n:
        return 0
    if r == 0 or r == n:
        return 1
    if r == 1:
        return n
    return cmb(n-1,r) + cmb(n-1,r-1)

mem_cnt = {}
set_a = set(A)
for c in list(set_a):
    mem_cnt[str(c)] = A.count(c)

for k in A:
    ret = 0
    for key,v in mem_cnt.items():
        x = v
        if str(key) == str(k):
            x = v-1
        ret += cmb(x,2)
    print(ret)


Fixed submission:
from collections import Counter

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

cnt = Counter(A)
s = 0
for v in cnt.values():
    s += v*(v-1)//2

for a in A:
    print(s - (cnt[a]-1))