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

N = int(input())
nums = list(map(int, input().split()))
numsB = nums[:]
d = dict()

for num in nums:
    if num not in d:
        d[num] = 1
    else:
        d[num] += 1

total = 0
for i in d:
    n = d[i]
    if n == 2:
        total += 1
    elif n > 2:
        total += factorial(n) / factorial(2) / factorial(n - 2)

for num in numsB:
    tmp = d[num] - 1
#    if tmp >= 2:
#        hoge = factorial(tmp) / factorial(2) / factorial(tmp - 2)
    print(int(total - tmp))


Fixed submission:
import math

N = int(input())
nums = list(map(int, input().split()))
numsB = nums[:]
d = dict()

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

for num in nums:
    if num not in d:
        d[num] = 1
    else:
        d[num] += 1

total = 0
for i in d:
    n = d[i]
    if n == 2:
        total += 1
    elif n > 2:
        total += combinations_count(n, 2)

for num in numsB:
    tmp = d[num] - 1
#    if tmp >= 2:
#        hoge = factorial(tmp) / factorial(2) / factorial(tmp - 2)
    print(int(total - tmp))

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

N = int(input())
nums = list(map(int, input().split()))
d = dict()

for num in nums:
    if num not in d:
        d[num] = 1
    else:
        d[num] += 1

total = 0
for i in d:
    n = d[i]
    if n == 2:
        total += 1
    elif n > 2:
        total += factorial(n) / factorial(2) / factorial(n - 2)

for num in nums:
    tmp = d[num] - 1
#    if tmp >= 2:
#        hoge = factorial(tmp) / factorial(2) / factorial(tmp - 2)
    print(total - tmp)


Fixed submission:
import math

N = int(input())
nums = list(map(int, input().split()))
numsB = nums[:]
d = dict()

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

for num in nums:
    if num not in d:
        d[num] = 1
    else:
        d[num] += 1

total = 0
for i in d:
    n = d[i]
    if n == 2:
        total += 1
    elif n > 2:
        total += combinations_count(n, 2)

for num in numsB:
    tmp = d[num] - 1
#    if tmp >= 2:
#        hoge = factorial(tmp) / factorial(2) / factorial(tmp - 2)
    print(int(total - tmp))

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

N = int(input())
nums = list(map(int, input().split()))
d = dict()

for num in nums:
    if num not in d:
        d[num] = 1
    else:
        d[num] += 1

total = 0
for i in d:
    n = d[i]
    if n == 2:
        total += 1
    elif n > 2:
        total += factorial(n) / factorial(2) / factorial(n - 2)

for num in nums:
    tmp = d[num] - 1
#    if tmp >= 2:
#        hoge = factorial(tmp) / factorial(2) / factorial(tmp - 2)
    print(int(total - tmp))


Fixed submission:
import math

N = int(input())
nums = list(map(int, input().split()))
numsB = nums[:]
d = dict()

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

for num in nums:
    if num not in d:
        d[num] = 1
    else:
        d[num] += 1

total = 0
for i in d:
    n = d[i]
    if n == 2:
        total += 1
    elif n > 2:
        total += combinations_count(n, 2)

for num in numsB:
    tmp = d[num] - 1
#    if tmp >= 2:
#        hoge = factorial(tmp) / factorial(2) / factorial(tmp - 2)
    print(int(total - tmp))

Buggy python submission (verdict: Runtime Error):
from collections import defaultdict

from math import factorial

N = int(input())
nums = list(map(int, input().split()))
d = defaultdict(int)

for num in nums:
    d[num] += 1

total = 0
for i in d:
    n = d[i]
    if n == 2:
        total += 1
    elif n > 2:
        total += factorial(n) / factorial(2) / factorial(n - 2)

for num in nums:
    tmp = d[num] - 1
#    if tmp >= 2:
#        hoge = factorial(tmp) / factorial(2) / factorial(tmp - 2)
    print(int(total - tmp))


Fixed submission:
import math

N = int(input())
nums = list(map(int, input().split()))
numsB = nums[:]
d = dict()

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

for num in nums:
    if num not in d:
        d[num] = 1
    else:
        d[num] += 1

total = 0
for i in d:
    n = d[i]
    if n == 2:
        total += 1
    elif n > 2:
        total += combinations_count(n, 2)

for num in numsB:
    tmp = d[num] - 1
#    if tmp >= 2:
#        hoge = factorial(tmp) / factorial(2) / factorial(tmp - 2)
    print(int(total - tmp))

Buggy python submission (verdict: Runtime Error):
from collections import defaultdict

from math import factorial

N = int(input())
nums = list(map(int, input().split()))
d = defaultdict(int)

for num in nums:
    d[num] += 1

#print(d)

total = 0
for i in d:
    n = d[i]
    if n >= 2:
        total += factorial(n) / factorial(2) / factorial(n - 2)

for num in nums:
    tmp = d[num] - 1
    if tmp >= 2:
        hoge = factorial(tmp) / factorial(2) / factorial(tmp - 2)
    print(int(total - tmp))

Fixed submission:
import math

N = int(input())
nums = list(map(int, input().split()))
numsB = nums[:]
d = dict()

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

for num in nums:
    if num not in d:
        d[num] = 1
    else:
        d[num] += 1

total = 0
for i in d:
    n = d[i]
    if n == 2:
        total += 1
    elif n > 2:
        total += combinations_count(n, 2)

for num in numsB:
    tmp = d[num] - 1
#    if tmp >= 2:
#        hoge = factorial(tmp) / factorial(2) / factorial(tmp - 2)
    print(int(total - tmp))