Buggy python submission (verdict: Runtime Error):
import collections
import copy
import math
from scipy.special import comb
from functools import lru_cache


n = int(input())
nums = [ int(s) for s in input().split() ]


@lru_cache(maxsize=1000)
def comb_count2(val):
    return comb(val, 2, exact=True)

for i in range(n):
    ans = 0

    cpl = copy.copy(nums)
    cpl.pop(i)
    ct = collections.Counter(cpl)

    for key, val in ct.items():
        if val > 1:
            ans += comb_count2(val)
    
    print(ans)


Fixed submission:



n = int(input())
lst = list(map(int, input().split()))

# counter
from collections import Counter
cntr = Counter(lst)

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

total = 0
# countSameNames
for value in cntr.values():
    if value > 1:
        total += combinations_count( value, 2 )


for l in lst:
    print(total - (cntr[l]-1))

Buggy python submission (verdict: Time Limit Exceeded):
import collections
import copy
import math
from scipy.misc import comb

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

n = int(input())
nums = [ int(s) for s in input().split() ]


for i in range(n):
    ans = 0

    cpl = copy.copy(nums)
    cpl.pop(i)
    ct = collections.Counter(cpl)

    for key, val in ct.items():
        if val > 1:
            ans += comb(val, 2, exact=True)
    
    print(ans)


Fixed submission:



n = int(input())
lst = list(map(int, input().split()))

# counter
from collections import Counter
cntr = Counter(lst)

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

total = 0
# countSameNames
for value in cntr.values():
    if value > 1:
        total += combinations_count( value, 2 )


for l in lst:
    print(total - (cntr[l]-1))

Buggy python submission (verdict: Runtime Error):
import collections
import copy
import math
from scipy.special import comb

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

n = int(input())
nums = [ int(s) for s in input().split() ]


for i in range(n):
    ans = 0

    cpl = copy.copy(nums)
    cpl.pop(i)
    ct = collections.Counter(cpl)

    for key, val in ct.items():
        if val > 1:
            ans += comb(val, 2, exact=True)
    
    print(ans)


Fixed submission:



n = int(input())
lst = list(map(int, input().split()))

# counter
from collections import Counter
cntr = Counter(lst)

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

total = 0
# countSameNames
for value in cntr.values():
    if value > 1:
        total += combinations_count( value, 2 )


for l in lst:
    print(total - (cntr[l]-1))

Buggy python submission (verdict: Runtime Error):
import collections
import copy
import math
import scipy.misc import comb

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

n = int(input())
nums = [ int(s) for s in input().split() ]


for i in range(n):
    ans = 0

    cpl = copy.copy(nums)
    cpl.pop(i)
    ct = collections.Counter(cpl)

    for key, val in ct.items():
        if val > 1:
            ans += comb(val, 2, exact=True)
    
    print(ans)


Fixed submission:



n = int(input())
lst = list(map(int, input().split()))

# counter
from collections import Counter
cntr = Counter(lst)

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

total = 0
# countSameNames
for value in cntr.values():
    if value > 1:
        total += combinations_count( value, 2 )


for l in lst:
    print(total - (cntr[l]-1))

Buggy python submission (verdict: Runtime Error):
import collections
import copy
import math
import scipy.special import comb

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

n = int(input())
nums = [ int(s) for s in input().split() ]


for i in range(n):
    ans = 0

    cpl = copy.copy(nums)
    cpl.pop(i)
    ct = collections.Counter(cpl)

    for key, val in ct.items():
        if val > 1:
            ans += comb(val, 2, exact=True)
    
    print(ans)


Fixed submission:



n = int(input())
lst = list(map(int, input().split()))

# counter
from collections import Counter
cntr = Counter(lst)

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

total = 0
# countSameNames
for value in cntr.values():
    if value > 1:
        total += combinations_count( value, 2 )


for l in lst:
    print(total - (cntr[l]-1))

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

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

n = int(input())
nums = [ int(s) for s in input().split() ]


for i in range(n):
    ans = 0

    cpl = copy.copy(nums)
    cpl.pop(i)
    ct = collections.Counter(cpl)

    for key, val in ct.items():
        if val > 1:
            ans += combinations_count(val, 2)
    
    print(ans)


Fixed submission:



n = int(input())
lst = list(map(int, input().split()))

# counter
from collections import Counter
cntr = Counter(lst)

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

total = 0
# countSameNames
for value in cntr.values():
    if value > 1:
        total += combinations_count( value, 2 )


for l in lst:
    print(total - (cntr[l]-1))