Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p02732 (python)

Fixed submission:
from collections import defaultdict
N = int(input())
A = list(map(int, input().split()))
d = defaultdict(lambda: 0)
for i in range(len(A)):
    d[A[i]] += 1
total = 0
for k,v in d.items():
    total += v*(v-1)//2
for a in A:
    print(total - (d[a]-1))

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
d = defaultdict(lambda: 0)
for i in range(len(A)):
    d[A[i]] += 1

ans1 = 0
ans2 = 0
r = 2
calc_dict1 = {}
calc_dict2 = {}
for k, v in zip(d.keys(), d.values()):
    if v > 1:
        ans1 = math.factorial(v) // (math.factorial(v - r) * math.factorial(r))
    else:
        ans1 = 0
    if v > 2:
        ans2 = math.factorial(v - 1) // (math.factorial(v - 1 - r) * math.factorial(r))
    else:
        ans2 = 0
    calc_dict1[k] = ans1
    calc_dict2[k] = ans1 - ans2
total = sum(calc_dict1.values())
for i in range(N):
    print(total - calc_dict2[A[i]])
Problem p02741 (python)

Fixed submission:
ls = 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
K = int(input())
print(ls[K-1])

Buggy submission (verdict: Runtime Error):
ls = 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
K = int(input())
print(ls[K]+1)
Problem p02747 (python)

Fixed submission:
S = input()
is_hitachi = True
if len(S) %2 == 0:
    for i in range(0, len(S), 2):
        if not (S[i] == 'h' and S[i + 1] == 'i'):
            is_hitachi = False
    print('YNeos'[not is_hitachi::2])
else:
    print('No')

Buggy submission (verdict: Runtime Error):
S = input()
is_hitachi = True
if len(S) >= 2:
    for i in range(0, len(S), 2):
        if not (S[i] == 'h' and S[i + 1] == 'i'):
            is_hitachi = False
    print('YNeos'[not is_hitachi::2])
else:
    print('No')

Buggy submission (verdict: Runtime Error):
S = input()
is_hitachi = True
for i in range(0, len(S), 2):
    if not (S[i] == 'h' and S[i + 1] == 'i'):
        is_hitachi = False
print('YNeos'[not is_hitachi::2])
Problem p02812 (python)

Fixed submission:
_ = int(input())
s = str(input())

ans = 0
for i in range(len(s)-2):
    ans += "ABC" == '{}'.format(s[i:i+3])

print(ans)

Buggy submission (verdict: Runtime Error):
_ = int(input())
s = list(input())

ans = 0
for i in range(len(s)-2):
    ans += "ABC" == f"{s[i]}{s[i+1]}{s[i+2]}"

print(ans)
Problem p02995 (python)

Fixed submission:
import fractions

A,B,C,D = map(int,input().split())
l = C*D // fractions.gcd(C,D)
x = (A-1) -(A-1)//C - (A-1)//D + (A-1)//l
y = B - B//C - B//D + B//l
print(y-x)

Buggy submission (verdict: Runtime Error):
import math

A,B,C,D = map(int,input().split())
A -= 1
g = math.gcd(C, D)
l = C * D / g

sA = A // C
eA = A // D
lA = A - (eA + sA) + A // l

sB = B // C
eB = B // D
lB = B - (eB + sB) + B // l
print(int(lB - lA))

Buggy submission (verdict: Runtime Error):
import math

A = int(input())
B = int(input())
C = int(input())
D = int(input())

multi = C * D
multiGcd = int((C * D) // math.gcd(C, D))

nC = int((A - 1) // C)
nD = int((A - 1) // D)
mC = int(B // C)
mD = int(B // D)

nM = int((A - 1) // multi)
mM = int(B // multi)

wC = mC - nC
wD = mD - nD
wM = mM - nM
wCD = wC + wD - wM

nGcd = int((A - 1) // multiGcd)
mGcd = int(B // multiGcd)
wGcD = mGcd - nGcd

ans = B - (A - 1) - wCD
if multiGcd != multi:
    ans += wGcD
print(ans)

Buggy submission (verdict: Runtime Error):
A = int(input())
B = int(input())
C = int(input())
D = int(input())

multi = C * D
multiGcd = int((C * D) // math.gcd(C, D))

nC = int((A - 1) // C)
nD = int((A - 1) // D)
mC = int(B // C)
mD = int(B // D)

nM = int((A - 1) // multi)
mM = int(B // multi)

wC = mC - nC
wD = mD - nD
wM = mM - nM
wCD = wC + wD - wM

nGcd = int((A - 1) // multiGcd)
mGcd = int(B // multiGcd)
wGcD = mGcd - nGcd

ans = B - (A - 1) - wCD
if multiGcd != multi:
    ans += wGcD
print(ans)

Buggy submission (verdict: Runtime Error):
import math

A, B, C, D = map(int, input().split())
multi = C * D
multiGcd = int(math.floor((C * D) / math.gcd(C, D)))

nC = int(math.floor((A - 1) / C))
nD = int(math.floor((A - 1) / D))
mC = int(math.floor(B / C))
mD = int(math.floor(B / D))

nM = int(math.floor((A - 1) / multi))
mM = int(math.floor(B / multi))

wC = mC - nC
wD = mD - nD
wM = mM - nM
wCD = wC + wD - wM

nGcd = int(math.floor((A - 1) / multiGcd))
mGcd = int(math.floor(B / multiGcd))
wGcD = mGcd - nGcd

ans = B - (A - 1) - wCD
if multiGcd != multi:
    ans += wGcD
print(ans)

Buggy submission (verdict: Runtime Error):
import math

A, B, C, D = map(int, input().split())
multi = C * D
multiGcd = int((C * D) // math.gcd(C, D))

nC = int(math.floor((A - 1) / C))
nD = int(math.floor((A - 1) / D))
mC = int(math.floor(B / C))
mD = int(math.floor(B / D))

nM = int(math.floor((A - 1) / multi))
mM = int(math.floor(B / multi))

wC = mC - nC
wD = mD - nD
wM = mM - nM
wCD = wC + wD - wM

nGcd = int(math.floor((A - 1) / multiGcd))
mGcd = int(math.floor(B / multiGcd))
wGcD = mGcd - nGcd

ans = B - (A - 1) - wCD
if multiGcd != multi:
    ans += wGcD
print(ans)
Problem p02996 (python)

Fixed submission:
N = int(input())
works = []
for i in range(N):
    works.append(list(map(int, input().split())))
works = sorted(works, key=lambda x: (x[1], x[0]))
time = 0
isFail = False
for i in range(N):
    time += works[i][0]
    if time > works[i][1]:
        isFail = True
        break
print("YNeos"[isFail::2])

Buggy submission (verdict: Runtime Error):
import sys

N = int(input())
ABList = []
for i in range(N):
    ABList.append(sys.stdin.readline().split())
sABList = sorted(ABList, key=[1])
temp = 0
isYes = True
for i in reversed(range(0, len(sABList))):
    temp += int(sABList[i][0])
    if temp > int(sABList[i][1]):
        isYes = False
print(sABList)
print(["No", "Yes"][isYes])
Problem p03106 (python)

Fixed submission:
def main():
    from builtins import int, map, list, print
    import sys
    sys.setrecursionlimit(10 ** 6)

    input = sys.stdin.readline
    input_list = (lambda: input().rstrip().split())
    input_number = (lambda: int(input()))
    input_number_list = (lambda: list(map(int, input_list())))

    A, B, K = input_number_list()
    t = 0
    i = max(A,B)+1
    while t < K:
        i -= 1
        t += 1 if A % i == 0 and B % i == 0 else 0
    print(i)


main()

Buggy submission (verdict: Runtime Error):
def main():
    from builtins import int, map, list, print
    import sys
    sys.setrecursionlimit(10 ** 6)

    input = sys.stdin.readline
    input_list = (lambda: input().rstrip().split())
    input_number = (lambda: int(input()))
    input_number_list = (lambda: list(map(int, input_list())))

    A, B, K = input_number_list()
    t = 0
    i = max(A,B)
    while t < K:
        i -= 1
        t += 1 if A % i == 0 and B % i == 0 else 0
    print(i)


main()
Problem p03150 (python)

Fixed submission:
S = input()
ls = ['k', 'e', 'y', 'e', 'n', 'c', 'e']
is_ng = True
idx = 0
tmp = 0
for i in range(len(ls)):
    l = S[:i]
    r = S[-len(ls)+i:]
    if l+r == 'keyence':
        is_ng=False

print('YNEOS'[is_ng::2])

Buggy submission (verdict: Runtime Error):
S = input()
ls = ['k', 'e', 'y', 'e', 'n', 'c', 'e']
is_ng = True
for i in range(len(S)-len(ls)+1):
    if S[i] == 'k':
        idx = 0
        tmp = 0
        for j in range(i, len(S)):
            if S[j] == ls[idx]:
                if tmp == 1:
                    tmp = 2
                idx += 1
            else:
                if tmp == 0:
                    tmp = 1
                elif tmp==2:
                    break
                continue
            if idx == len(ls):
                is_ng = False
print('YNEOS'[is_ng::2])
Problem p03844 (python)

Fixed submission:
A, op, B = input().split()
A = int(A)
B = int(B)
if op == "+":
    print(A + B)
else:
    print(A - B)

Buggy submission (verdict: Runtime Error):
A, op, B = input().split()
if op == "+":
    print(A + B)
else:
    print(A - B)
Problem p03845 (python)

Fixed submission:
N = input()
T = list(map(int, input().split()))
M = input()
sum = sum(T)
PX = []
ansList = list()
for i in range(int(M)):
    PX.append(list(map(int, input().split())))
for i in range(int(M)):
    ansList.append(sum - (T[PX[i][0]-1] - PX[i][1]))
    print(ansList[i])

Buggy submission (verdict: Runtime Error):
import sys
N = sys.stdin.readline()
T = map(int,sys.stdin.readline().split())
M = sys.stdin.readline()
sum = sum(T)
PX = []
ansList = list(list())
for i in range(M):
    PX.append(map(int,sys.stdin.readline().split()))
for i in range(T):
    ansList[i] = sum[i] + (T[PX[i][0]] - PX[i][1])
    print(ansList[i])
Problem p03852 (python)

Fixed submission:
if input() in "aiueo":
    print("vowel")
else:
    print("consonant")

Buggy submission (verdict: Runtime Error):
import sys
 
H, W = sys.stdin.readline().split()
C =  sys.stdin
for i in C:
    print(i)
    print(i)
Problem p03853 (python)

Fixed submission:
import sys

H, W = sys.stdin.readline().split()
C = map(str, sys.stdin)
for i in C:
    print(i)
    print(i)

Buggy submission (verdict: Runtime Error):
C = open(0)
for i in C[1:]:
    print(i)
    print(i)

Buggy submission (verdict: Runtime Error):
import sys
H,W = map(int,sys.stdin.readline())
C = open(0)
for i in C:
    print(i)
    print(i)

Buggy submission (verdict: Runtime Error):
import sys

H, W = sys.stdin.readline().split()
C = set(map(int, sys.stdin))
for i in C:
    print(i)
    print(i)

Buggy submission (verdict: Runtime Error):
import sys
H,W = map(int,input().split())
C = list()
C = set(map(int, sys.stdin))
for i in C:
    print(i)
    print(i)

Buggy submission (verdict: Runtime Error):
import sys
H,W = map(int,input().split())
C = list()
C = set(map(int, sys.stdin))
for i in C:
    print(C[i])
    print(C[i])

Buggy submission (verdict: Runtime Error):
import sys
H,W = map(int,input().split())
C = set(map(int, sys.stdin))
for i in C:
    print(C[i])
    print(C[i])

Buggy submission (verdict: Runtime Error):
import sys
H,W = map(int,input().split())
C = list(map(int,sys.stdin))
for i in C:
    print(C[i])
    print(C[i])
Problem p03944 (python)

Fixed submission:
import sys

W, H, N = map(int, input().split())
l = d = 0
u = H
r = W
for i in range(N):
    x, y, a = list(map(int, input().split()))
    if a == 1:
        l = max(x, l)
    if a == 2:
        r = min(x, r)
    if a == 3:
        d = max(y, d)
    if a == 4:
        u = min(y, u)

ans = (r - l) * (u - d)
if r - l < 0 or u - d < 0:
    ans = 0
print(max(ans, 0))

Buggy submission (verdict: Runtime Error):
import sys

W, H, N = map(int, input().split())
l = d = 0
u = H
r = W
for i in range(N):
    x, y, a = list(map(int, input().split()))
    if a == 1:
        l = max(x, l)
    if a == 2:
        r = min(x, r)
    if a == 3:
        d = max(y, d)
    if a == 4:
        u = min(y, u)

ans = (r - l) * (u - d)
if r - l < 0 or u - d < 0
    ans = 0 
print(max(ans, 0))
Problem p03998 (python)

Fixed submission:
s = {}
s['a'] = list(input())
s['b'] = list(input())
s['c'] = list(input())

now = 'a'
while s[now]:
    now = s[now].pop(0)
print(now.upper())

Buggy submission (verdict: Runtime Error):
import sys

arr = list(map(int,sys.stdin))
a, b, c = 0
tmp = 0
while True:
    x = [a, b, c][tmp]
    s = arr[tmp][x]
    [a,b,c][tmp] += 1
    tmp = [0, 1, 2]["abc".find(s)]
    if arr[tmp][x]:
        [a,b,c][tmp]
        break
Problem p02720 (python)

Fixed submission:
def lower(upper):
    if upper==9:
        return [8,9]
    elif upper==0:
        return [0,1]
    else:
        return [upper-1,upper,upper+1]

def numerize(a):
    return sum([a[i]*(10**i) for i in range(len(a))])

def getRunruns(digit):
    if digit==1:
        return [(i,) for i in range(10)]
    elif digit==2:
        return [(k,i) for i in range(1,10) for k in lower(i)]
    else:
        runruns=getRunruns(2)
        for i in range(digit-2):
            runruns=[(k,)+i for i in runruns for k in lower(i[0])]
        return runruns

A1=[(i,) for i in range(10)]
A2=[(k,i) for i in range(1,10) for k in lower(i)]
A=A1+A2
Aprev=A2
K=int(input())
while len(A)<K+1:
    Aprev=[(k,)+i for i in Aprev for k in lower(i[0])]
    A+=Aprev
print(numerize(A[K]))

Buggy submission (verdict: Runtime Error):
def lower(upper):
    if upper==9:
        return [8,9]
    elif upper==0:
        return [0,1]
    else:
        return [upper-1,upper,upper+1]

def numerize(a):
    return sum([a[i]*(10**i) for i in range(len(a))])

def getRunruns(digit):
    if digit==1:
        return [(i,) for i in range(10)]
    elif digit==2:
        return [(k,i) for i in range(1,10) for k in lower(i)]
    else:
        runruns=getRunruns(2)
        for i in range(digit-2):
            runruns=[(k,)+i for i in runruns for k in lower(i[0])]
        return runruns

A1=[(i,) for i in range(10)]
A2=[(k,i) for i in range(1,10) for k in lower(i)]
A=A1+A2
Aprev=A2
K=int(input())
while len(A)<K:
    Aprev=[(k,)+i for i in Aprev for k in lower(i[0])]
    A+=Aprev
print(numerize(A[K]))
Problem p02761 (python)

Fixed submission:
N,M=[int(i) for i in input().split(" ")]
number=[-1 for i in range(N)]
for i in range(M):
    s,c=[int(i) for i in input().split(" ")]
    if(number[s-1]==-1):
        number[s-1]=c
    elif(number[s-1]!=c):
        print(-1)
        break
else:
    n=0
    for i in range(N):
        if number[i]==-1:
            if i==0 and N>=2:
                number[i]=1
            else:
                number[i]=0
        n=n*10 + number[i]
    if(len(str(n))==N):
        print(n)
    else:
        print("-1")

Buggy submission (verdict: Runtime Error):
N,M=[int(i) for i in input().split(" ")]
number=[-1 for i in range(N)]
for i in range(M):
    s,c=[int(i) for i in input().split(" ")]
    if(number[s-1]==-1):
        number[s-1]=c
    elif(number[s-1]!=c):
        print(-1)
        break
else:
    for i in range(len(number)):
        if number[i]==-1:
            if i==3-N:
                number[i]=1
            else:
                number[i]=0
    n=number[0]*100+number[1]*10+number[2]
    if(len(str(n))!=N):
        print("-1")
    else:
        print(n)

Buggy submission (verdict: Runtime Error):
N,M=[int(i) for i in input().split(" ")]
number=[-1 for i in range(N)]
for s,c in [[int(i) for i in input().split(" ")] for n in range(M)]:
    if(number[s-1]==-1):
        number[s-1]=c
    elif(number[s-1]!=c):
        print(-1)
        break
else:
    for i in range(len(number)):
        if number[i]==-1:
            if i==0:
                number[i]=1
            else:
                number[i]=0
    n=number[0]*100+number[1]*10+number[2]
    if(len(str(n))!=N):
        print("-1")
    else:
        print(n)
Problem p02767 (python)

Fixed submission:
N=int(input())
X=[int(i) for i in input().split(" ")]
sp=lambda P:sum([(Xi-P)**2 for Xi in X])
print(min([sp(p) for p in range(0,102)]))

Buggy submission (verdict: Runtime Error):
N=int(input())
if N==1:
    print(0)
else:
    X=[int(x) for x in input().split(" ")]
    cons=lambda P:sum([(x-P)**2 for x in X])
    print(min([cons(P) for P in range(min(X),max(X))]))

Buggy submission (verdict: Runtime Error):
N=int(input())
X=[int(x) for x in input().split(" ")]
cons=lambda P:sum([(x-P)**2 for x in X])
print(min([cons(P) for P in range(min(X),max(X))]))
Problem p02690 (python)

Fixed submission:
x = int(input())

def func():
    for a in range(-10**2 - 200, 10**2 + 200):
        for b in range(-10**2 - 200, 10**2 + 200):
            if a**5 - b**5 == x:
                k = [a, b]
                return k
    

k = func()
for i in range(2):
    print(k[i], end=" ")

Buggy submission (verdict: Runtime Error):
x = int(input())

def func():
    for a in range(-10**2 - 100, 10**2 + 100):
        for b in range(-10**2, 10**2):
            if a**5 - b**5 == x:
                k = [a, b]
                return k
    

k = func()
for i in range(2):
    print(k[i], end=" ")

Buggy submission (verdict: Runtime Error):
x = int(input())

for a in range(-10**3, 10**3):
    for b in range(-10**2, 10**2):
        if a**5 - b**5 == x:
            k = [a, b]

for i in range(2):
    print(k[i], end=" ")

Buggy submission (verdict: Runtime Error):
x = int(input())

for a in range(-10**2, 10**2):
    for b in range(-10**2, 10**2):
        if a**5 - b**5 == x:
            k = [a, b]

for i in range(2):
    print(k[i], end=" ")
Problem p02696 (python)

Fixed submission:
a, b, n = map(int, input().split())

cnt = 1
buf = []
if n < b:
    buf.append(int(a * n / b) - a * (int(n / b)))
else:
    buf.append(int(a * (b - 1) / b) - a * (int((b - 1) / b)))
    

while True:
    if n / b > 10 ** 6:
        break
    x = cnt * b - 1
    if n < x :
        break
    calc = int(a * x / b) - a * (int(x / b))
    if calc > max(buf):
        buf.append(calc)
    cnt += 1
    
if n / b > 10 ** 6 and n >= b:
    buf.append(int(a * (b - 1) / b) - a * (int((b - 1) / b)))

ans = max(buf)
print(ans)

Buggy submission (verdict: Runtime Error):
a, b, n = map(int, input().split())

cnt = 1
buf = []
if n < b:
    buf.append(int(a * n / b) - a * (int(n / b)))

while True:
    if n / b > 10 ** 6:
        break
    x = cnt * b - 1
    if n < x :
        break
    calc = int(a * x / b) - a * (int(x / b))
    if calc > max(buf):
        buf.append(calc)
    cnt += 1
    
if n / b > 10 ** 6 and n >= b:
    buf.append(int(a * (b - 1) / b) - a * (int((b - 1) / b)))

ans = max(buf)
print(ans)
Problem p02811 (python)

Fixed submission:
k, x = map(int, input().split())

if 500*k >= x:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = list(map(int, input().split()))

import math
from functools import reduce

# for i, j in enumerate(a):

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

kouyakusuu = gcd_list(a)
koubaisuu = lcm_list(a)

buf = 1
for i, j in enumerate(a):
    buf *= j / kouyakusuu

ans = (m - buf) // koubaisuu + 1

print(int(ans))
Problem p02971 (python)

Fixed submission:
N = int(input()) #1行目のNを取得する
s = []
s = [int(input()) for i in range(N)] #複数行の数値の入力を取得

max_num = max(s)
max_ind = s.index(max_num)
s.remove(max_num)
max2_num = max(s)
 
for i in range(N):
    if i == max_ind:
        print(max2_num)
    else:
        print(max_num)

Buggy submission (verdict: Runtime Error):
N = int(input()) #1行目のNを取得する
s = []
s = [input() for i in range(N)] #複数行の数値の入力を取得

max_num = max(s)
max_ind = s.index(mux_num)
s.remove(max_num)
max2_num = max(s)
 
for i in range(N):
    if i == max_ind:
        print(max2_num)
    else:
        print(max_num)

Buggy submission (verdict: Runtime Error):
import numpy as np
N = int(input()) #1行目のNを取得する
s = [input() for i in range(N)] #複数行の数値の入力を取得


# for i in range(N):
#     buf = s.copy()
#     buf.pop(i)
#     ans = max(buf)
#     print(ans)


max_ind = [i for i, a in enumerate(s) if a == max(s)]
max_num = max(s)
max2_num = sorted(set(s))[-2]

for i in range(N):
    if (np.array(max_ind) == i).any():
        print(max2_num)
    else:
        print(max_num)
Problem p02713 (python)

Fixed submission:
import math

K = int(input())
total = 0
for a in range(1, K+1):
  for b in range(1, K+1):
    ab = math.gcd(a, b)
    for c in range(1, K+1):
      total += math.gcd(ab, c)
print(total)

Buggy submission (verdict: Runtime Error):
import math
total = 0
for a in range(K):
  for b in range(K):
    for c in range(K):
      total += math.gcd(a, b)
print(total)
Problem p02761 (python)

Fixed submission:
N, M = map(int, input().split())
SC = [list(map(int, input().split())) for _ in range(M)]

A = [-1 for _ in range(N)]

for s, c in SC:
  if s == 1 and c == 0 and N != 1:
    print(-1)
    exit()
  if A[s-1] == -1:
    A[s-1] = c
  else:
    if A[s-1] == c:
      pass
    else:
      print(-1)
      exit()

for i in range(N):
  if A[i] == -1:
    A[i] = 0

if A[0] == 0:
  if N == 1:
    pass
  else:
    A[0] = 1

print(''.join(map(str, A)))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
SC = [list(map(int, input().split())) for _ in range(M)]

A = [-1 for _ in range(N)]

for s, c in SC:
  if A[s-1] == -1:
    A[s-1] = c
  else:
    if A[s-1] == c:
      pass
    else:
      print(-1)
      exit()

for i in range(M):
  if A[i] == -1:
    A[i] = 0

if A[0] == 0 and N != 1:
  print(-1)
  exit()

print(''.join(map(str, A)))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
SC = [list(map(int, input().split())) for _ in range(M)]

A = [-1 for _ in range(N)]

for s, c in SC:
  if A[s-1] == -1:
    A[s-1] = c
  else:
    if A[s-1] == c:
      pass
    else:
      print(-1)
      exit()

for i in range(M):
  if A[i] == -1:
    A[i] = 0

if A[0] == 0:
  print(-1)
  exit()

print(''.join(map(str, A)))
Problem p02732 (python)

Fixed submission:
import numpy as np
from collections import Counter


N = int(input())
A = list(map(int, input().split()))
c = Counter(A)
np_A = np.array(A)

# 全体を求める
tmp_all = np.array(A)
unique = np.unique(tmp_all)
# print("unique:", unique)
ans_all = 0
for u in unique:
    count_u = c[u]
    # print(f"u:{u}, count_u:{count_u}")
    if count_u < 2:
        continue
    # (count_u) C 2
    tmp = int(count_u*(count_u-1)/2)
    ans_all += tmp
# print("all", ans_all)


# kごとのケースを求めて、全体から引く
for i in A:
    print(ans_all - c[i] + 1)

Buggy submission (verdict: Runtime Error):
import numpy as np
import math
def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


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

# kごとに、
# 異なる数がいくつあるかを調べる
# (2以上要素が存在する)異なる数ごとに、
# (要素数)C2を解く。

np_A = np.array(A)

# 辞書作成
dic = {}

for k in range(N):
    before = A[:k]
    after = A[k+1:]

    before.extend(after)
    tmp_k = np.array(before)
    # print("tmp_k", tmp_k)   # k以上
    # print(np.unique(np_A))

    # 同じ組み合わせのケースを排除する。
    # (num, 要素数)の組み合わせを辞書かで作る

    k_unique = np.unique(tmp_k)
    ans = 0

    # k_uniqueをstr化
    # str_unique = [str(i) for i in k_unique]
    maped_num = map(str, k_unique) #格納される数値を文字列にする
    str_unique = "".join(maped_num.tolist())
    # print("str_unique", str_unique)

    # 要素数リストを作成
    count_u_list = []
    for u in k_unique:
        count_u = np.count_nonzero(tmp_k==u)
        count_u_list.append(count_u)
    # 要素数リストをstr化
    maped_num = map(str, count_u_list) #格納される数値を文字列にする
    str_count = "".join(maped_num.tolist())
    # str_count = "".join(count_u_list)
    # print("str_count", str_count)

    key = str_unique+str_count

    if key in dic.keys():
        print(dic[key])
        continue
    else:
        for count_u in count_u_list:
            if count_u < 2:
                continue
            # (count_u) C 2
            tmp = comb(count_u,2)
            ans += tmp

    # 値の更新
    dic[key] = ans
    print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
import math
def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


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

# kごとに、
# 異なる数がいくつあるかを調べる
# (2以上要素が存在する)異なる数ごとに、
# (要素数)C2を解く。

np_A = np.array(A)

# 辞書作成
dic = {}

for k in range(N):
    before = A[:k]
    after = A[k+1:]

    before.extend(after)
    tmp_k = np.array(before)
    # print("tmp_k", tmp_k)   # k以上
    # print(np.unique(np_A))

    # 同じ組み合わせのケースを排除する。
    # (num, 要素数)の組み合わせを辞書かで作る
    # →単純にnCrなら(n, r)で保存する

    k_unique = np.unique(tmp_k)
    ans = 0

    for u in k_unique:
        count_u = np.count_nonzero(tmp_k==u)
        if count_u < 2:
            continue
        if f"{count_u}"+"2" in dic.keys():
            ans += dic[f"{count_u}"+"2"]
            continue

        # (count_u) C 2
        tmp = comb(count_u,2)
        ans += tmp
        # 値の更新
        dic[f"{count_u}"+"2"] = tmp
    
    print(ans)