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

Fixed submission:
N,K=map(int, input().split())
sushi=sorted([tuple(map(int, input().split())) for _ in range(N)], key=lambda x: x[1], reverse=True)

typ = set()
ans = 0
cur = 0
rem = []

for t,d in sushi:
	if t in typ:
		if K > 0:
			K -= 1
			cur += d
			rem.append(d)
	else:
		typ.add(t)
		cur += d
		if K > 0:
			K -= 1
		elif len(rem):
			cur -= rem.pop()
		else:
			break

	ans = max(ans, cur + len(typ)**2)

print(ans)

Buggy submission (verdict: Runtime Error):
N,K=map(int, input().split())
sushi=sorted([tuple(map(int, input().split())) for _ in range(N)], key=lambda x: x[1], reverse=True)

ty = set()
im = []
mu = []
an = []

for t,d in sushi:
	if t in ty:
		if K > 0:
			mu.append(d)
			K -= 1
	else:
		ty.add(t)
		im.append(d)
		if K > 0:
			K -= 1
		else:
			mu.pop()

	an.append(len(ty)**2 + sum(im) + sum(mu))

print(max(an))
Problem p03240 (python)

Fixed submission:
N=int(input())
xyh=sorted([list(map(int, input().split())) for _ in range(N)], key=lambda x: x[2], reverse=True)

def find(cx, cy, H):
	for x,y,h in xyh:
		if h != max(H-abs(x-cx)-abs(y-cy), 0):
			return False
	return True

def solve():
	for cx in range(101):
		for cy in range(101):
			x,y,h = xyh[0]
			H = h + abs(x-cx) + abs(y-cy)
			if find(cx, cy, H):
				return "%d %d %d" % (cx, cy, H)
	raise Exception

print(solve())

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

def find(cx, cy, H):
	for x,y,h in xyh:
		if h != max(H-abs(x-cx)-abs(y-cy), 0):
			return False
	return True

def solve():
	for cx in range(101):
		for cy in range(101):
			x,y,h = xyh[0]
			H = h + abs(x-cx) + abs(y-cy)
			if find(cx, cy, H):
				return "%d %d %d" % (cx, cy, H)
	raise Exception

print(solve())
Problem p03274 (python)

Fixed submission:
n,k=map(int, input().split())
x,neg,pos=[],[],[]
for i in input().split():
	i = int(i)
	x.append(i)
	if i < 0:
		neg.append(i)
	else:
		pos.append(i)
neg.reverse()

ans=[]

if len(neg) >= k:
	ans.append(-neg[k-1])
if len(pos) >= k:
	ans.append(pos[k-1])

for i in range(1, k):
	j = k - i
	if i > len(neg) or j > len(pos):
		continue
	ans.append(pos[j-1] - neg[i-1] + min(pos[j-1], -neg[i-1]))

print(min(ans))

Buggy submission (verdict: Runtime Error):
n,k=map(int, input().split())
x,neg,pos=[],[],[]
for i in input().split():
	i = int(i)
	x.append(i)
	if i < 0:
		neg.append(i)
	else:
		pos.append(i)
neg.reverse()

ans=[]

if len(neg) >= k:
	ans.append(-neg[k-1])
if len(pos) >= k:
	ans.append(pos[k-1])

for i in range(1, k):
	j = k - i
	if i >= len(neg) or j >= len(pos):
		continue
	ans.append(pos[j-1] - neg[i-1] + min(pos[j-1], -neg[i-1]))

print(min(ans))
Problem p03352 (python)

Fixed submission:
x=int(input())

exp=set([1])
for i in range(2, 32):
	v = i*i
	while v <= x:
		exp.add(v)
		v *= i
print(max(exp))

Buggy submission (verdict: Runtime Error):
from sympy import factorint

ans=1
for i in range(int(input()), 1, -1):
	f=factorint(i)
	if len(f) == 1 and sum(f.values()) > 1:
		ans=i
		break

print(ans)
Problem p03450 (python)

Fixed submission:
import sys
sys.setrecursionlimit(1145141919)

N,M=map(int, input().split())

path=[[] for _ in range(N+1)]

for _ in range(M):
	l,r,d=map(int, input().split())
	path[l].append((r,+d))
	path[r].append((l,-d))

cost=[None for _ in range(N+1)]

def walk(i, c):
	if cost[i] is None:
		cost[i] = c
		for j,d in path[i]:
			if not walk(j, c+d):
				return False
	return cost[i] == c

ans = "Yes"

for i in range(1, N+1):
	if cost[i] is None and not walk(i, 0):
		ans = "No"
		break

print(ans)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(65536)

N,M=map(int, input().split())

path=[[] for _ in range(N+1)]

for _ in range(M):
	l,r,d=map(int, input().split())
	path[l].append((r,+d))
	path[r].append((l,-d))

cost=[None for _ in range(N+1)]

def walk(i, c):
	if cost[i] is None:
		cost[i] = c
		for j,d in path[i]:
			if not walk(j, c+d):
				return False
	return cost[i] == c

ans = "Yes"

for i in range(1, N+1):
	if cost[i] is None and not walk(i, 0):
		ans = "No"
		break

print(ans)

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

fi=True
inl=[[] for _ in range(N+1)]
inr=[[] for _ in range(N+1)]
pos=[None for _ in range(N+1)]
det=set()

for _ in range(M):
	l,r,d=map(int, input().split())
	inl[l].append((l,r,d))
	inl[r].append((l,r,d))

	if fi:
		fi=False
		det.add(l)
		det.add(r)
		pos[l]=0
		pos[r]=d

ans = "Yes"

while len(det) > 0 and ans == "Yes":
	p = det.pop()

	for l,r,d in inl[p]:
		if pos[r] is not None:
			if pos[r] != pos[l] + d:
				ans = "No"
				break
		else:
			pos[r] = pos[l] + d
			det.add(r)

	for l,r,d in inr[p]:
		if pos[l] is not None:
			if pos[l] != pos[r] - d:
				ans = "No"
				break
		else:
			pos[l] = pos[r] - d
			det.add(l)

print(ans)
Problem p03504 (python)

Fixed submission:
MAX = 114514

N,C=map(int, input().split())

Z=[[] for _ in range(C+1)]
for _ in range(N):
	s,t,c = map(int, input().split())
	Z[c].append([s,t])

Y=[]
for z in [sorted(z) for z in Z if len(z) > 0]:
	for i in range(len(z)-1):
		if z[i][1] == z[i+1][0]:
			z[i+1][0] = z[i][0]
		else:
			Y.append(z[i])
	Y.append(z.pop())

X=[0 for _ in range(MAX)]
for s,t in Y:
	X[s] += 1
	X[t+1] -= 1

for i in range(1, MAX):
	X[i] += X[i-1]

print(max(X))

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

Z=[[] for _ in range(C+1)]
for _ in range(N):
	s,t,c = map(int, input().split())
	Z[c].append([s,t])

Y=[]
for z in [sorted(z) for z in Z if len(z) > 0]:
	for i in range(len(z)-1):
		if z[i][1] == z[i+1][0]:
			z[i+1][0] = z[i][0]
		else:
			Y.append(z[i])
	Y.append(z.pop())

X=[0 for _ in range(10**5+1)]
for s,t in Y:
	X[s] += 1
	X[t+1] -= 1

for i in range(1, 10**5+1):
	X[i] += X[i-1]

print(max(X))
Problem p02681 (python)

Fixed submission:
S = input()
T = input()
X = int(len(T)) - 1
Y = T[:-1]

if S == Y and X == int(len(S)):
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
S = input()
T = input()
X = len(T) - 1

if S in T and (len(X) == len(S)):
    print('Yes')
else:
    print('No')
Problem p02760 (python)

Fixed submission:
grid = list(list(map(int,input().split())) for _ in range(3))

N = int(input())

S = set(int(input()) for _ in range(N))

def check():
    for i in range(3):
        if all(grid[i][j] in S for j in range(3)):
            return True
        if all(grid[j][i] in S for j in range(3)):
            return True
    return all(grid[i][i] in S for i in range(3)) or all(grid[2-i][i] in S for i in range(3))

print('Yes' if check() else 'No')

Buggy submission (verdict: Runtime Error):
a = list(list(map(int,input().split())) for _ in range(3))
n = int(input())

b = set(int(input() for i in range(n)))

def check():
    for i in range(3):
        if all(a[i][j] in b for j in range(3)):
            return True
        if all(a[j][i] in b for j in range(3)):
            return True
    return all(a[i][i] in b for i in range(3)) or all(a[2-i][i] in b for i in range(3))

print('Yes' if check() else 'No')

Buggy submission (verdict: Runtime Error):
a = [list(map(int, input().split())) for _ in range(3)]
n = int(input())

b = set(int(input() for _ in range(n)))

def check():
    for i in range(3):
        if all(a[i][j] in b for j in range(3)):
            return True
        if all(a[j][i] in b for j in range(3)):
            return True
    return all(a[i][i] in b for i in range(3)) or all(a[2-i][i] in b for i in range(3))

print('Yes' if check() else 'No')

Buggy submission (verdict: Runtime Error):
a = [list(map(int, input().split())) for i in range(3)]
n = int(input())

b = set(int(input() for i in range(n)))

def check():
    for i in range(3):
        if all(a[i][j] in b for j in range(3)):
            return True
        if all(a[j][i] in b for j in range(3)):
            return True
    return all(a[i][i] in b for i in range(3)) or all(a[2-i][i] in b for i in range(3))

print('Yes' if check() else 'No')
Problem p02767 (python)

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

ans = 10**20 #答えになるので初期化
for i in range(1,101): #1<=P<=100の範囲について消費する体力の総和を計算
    dis = 0
    for j in x:
        dis += (i-j)**2
    ans = min(ans,dis)

print(ans)

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

ans = 10**20 #答えになるので初期化
for i in range(1,101): #1<=P<=100の範囲について消費する体力の総和を計算
    dis = 0
    for j in x:
        dis += (i-j)**2
    ans = min(dis)

print(ans)
Problem p02791 (python)

Fixed submission:
N=int(input())
P=list(map(int,input().split()))
MIN=10**9#Nの制約よりも十分に大きい数
ans=0
for i in range(N):
    if P[i]<=MIN:
        ans+=1
        MIN=P[i]#累積最小値で左から順に値を更新していく
print(ans)

Buggy submission (verdict: Runtime Error):
#入力
##1*1行列
import itertools
N=int(input())#1*1の整数を格納
P=[int(i) for i in input().split()]

itertools.accumulate(P, min)

mi=10000000
x=[0]*N
for i in range(N):
    if mi>P[i]:
        x[i]=1
        mi=P[i]
print(sum(x))
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):
k=int(input())
x=int(input())

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

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

if 500*k <= x:
    print("yes")
else:
    print("no")

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

if 500*k <= x:
    print("yes")
else:
    print("no")

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

if 500*k =< x:
    print("yes")
else:
    print("no")
Problem p02841 (python)

Fixed submission:
M1, D1 = map(int, input().split())
M2, D2 = map(int, input().split())

if M2 - M1 ==0:
    print(0)
else:
    print(1)

Buggy submission (verdict: Runtime Error):
M1, M2, D1, D2 = map(int, input().split())

if M2 - M1 == 0:
    print(0)
else:
    print(1)
Problem p02842 (python)

Fixed submission:
# Input the amount of money Takahashi paid
N = int(input())

# Check if the price before tax is X, for X = 1, 2, 3, ..., N
ans = -1
for i in range(1, N + 1):
	if int(i * 1.08) == N:
		ans = i

# Print answer
if ans != -1:
	print(ans)
else:
	print(":(")

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

ans = -1
for i in range(1, N+1)
	if int(i * 1.08)==N:
    	ans = i

if ans != -1:
	print(ans)
else:
	print(":(")

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

N//1.08 = X
M = X * 1.08

if M == N:
    print(X)
else:
    print(":(")
Problem p03102 (python)

Fixed submission:
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
cou=0
for i in range(n):
    a=list(map(int,input().split()))
    x=c
    for j in range(m):
        x+=a[j]*b[j]
    if x>0:
        cou+=1
print(cou)

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

ans = 0

for i in range(n):
    a = list(map(int,input().split()))
    x = c
    for j in range():
        x += a[j]*b[j]
    if x > 0:
        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
a=[list(map(int,input().split())) for i in range(n)]
ans = 0

for k in range(m):
    if a*b+c>0:
        ans += 1
    else:
        pas
print(ans)
Problem p03455 (python)

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

if (a*b)%2==1:
    print('Odd')
else:
    print('Even')

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

if (a*b)%2=0:
    print('Even')
else:
    print('Odd')
Problem p03997 (python)

Fixed submission:
a = int(input())
b = int(input())
h = int(input())
print((a+b)*h//2)

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

print((a+b)*h//2)

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

print((a+b)*h/2)

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

print((a+b)*h/2)

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

N = (a+b)*h/2

print(int(N))

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

N = int((a+b)*h/2)

print(N)

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

N = ((a+b)*h)/2

print(N)

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

N = (a+b)*h/2

print(N)
Problem p04012 (python)

Fixed submission:
w = input()

ans = "No"
for i in w:
    if w.count(i)%2!= 0:
        break
else:
    ans = "Yes"
print(ans)

Buggy submission (verdict: Runtime Error):
w = input()

ans = "No"
for i in w:
    if w.count(i)%2! = 0:
        break
else:
    ans = "Yes"

print(ans)

Buggy submission (verdict: Runtime Error):
w = input()

for i in w:
    if w.count(i)%2! = 0:
        ans = "No"
        break
else:
    ans = "Yes"

print(ans)

Buggy submission (verdict: Runtime Error):
w = input()

for i in w:
    if w.count(i)%2! = 0:
        ans = "No"
            break
else:
    ans = "Yes"

print(ans)

Buggy submission (verdict: Runtime Error):
w = input()

for i in w:
    if w.count(i)%2! = 0:
        print("No")
            break
else:
    print("Yes")

Buggy submission (verdict: Runtime Error):
w = input()

for i in w:
    if w.count(i)%2! = 0:
        print("No")
        	break
    else:
        print("Yes")

Buggy submission (verdict: Runtime Error):
w = input()

for i in w:
    if w.count(i)%2! = 0:
        print("No")
        break
    else:
        print("Yes")
Problem p04029 (python)

Fixed submission:
N = int(input())

print(int(N*(N+1)/2))

Buggy submission (verdict: Runtime Error):
import sympy as sym
(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z) = sym.symbols('a b c d e f g h i j k l m n o p q r s t u v w x y z')

N = int(input())
A = sym.sequence((N*(N+1))/2,(n, 1, 100))
print([type(N), N for in A])

Buggy submission (verdict: Runtime Error):

import sympy as sym
(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z) = sym.symbols('a b c d e f g h i j k l m n o p q r s t u v w x y z')

N = int(input())
A = sym.sequence((N*(N+1))/2,(n, 1, 100))
print([int(N) for in A])

Buggy submission (verdict: Runtime Error):
import sympy as sym
(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z) = sym.symbols('a b c d e f g h i j k l m n o p q r s t u v w x y z')

A = sym.sequence((N*(N+1))/2,(n, 1, 100))
print([int(N) for in A])

Buggy submission (verdict: Runtime Error):
import sympy as sym
(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z) = sym.symbols('a b c d e f g h i j k l m n o p q r s t u v w x y z')

A = sym.sequence(N*(N+1)/2,(n, 1, 100))
print([int(N) for in A])

Buggy submission (verdict: Runtime Error):
import sympy as sym

A = sym.sequence(N*(N+1)/2,(n, 1, 100))
print([int(N) for in A])

Buggy submission (verdict: Runtime Error):
import sympy as sym

A = sym.sequence(N*(N+1)/2,(n, 1, 100))
print([int(N) for in A])
print(A[3])

Buggy submission (verdict: Runtime Error):
asum = 1
1<N<100

for x in range(2,N):
    asum += x

print(asum)

Buggy submission (verdict: Runtime Error):
asum = 1

for x in range(2,100)
    asum += x

print(asum)

Buggy submission (verdict: Runtime Error):
import numpy as np 

np.arange(1, 100, N)

Buggy submission (verdict: Runtime Error):
import numpy as np 

np.arange(1, 100, 1)
Problem p02675 (python)

Fixed submission:
n = int(input())
c = n % 10
 
if c in [3]:
  print("bon")
elif c in [0,1,6,8]:
  print("pon")
else:
  print("hon")

Buggy submission (verdict: Runtime Error):
 a = int(input())
 c = a % 10
 
if c in ［ 3］:
  print("bon")
elif c in ［ 0,1,6,8］:
  print("pon")
else:
  print("hon")


input()

Buggy submission (verdict: Runtime Error):
 a = int(input())
 c = a % 10
 
if c in ［ 3］:
  print("bon")
elif c in ［ 0,1,6,8］:
  print("pon")
else:
  print("hon")

Buggy submission (verdict: Runtime Error):
a=int(input())
a= a % 10
 
if a in ［ 3］:
  print("bon")
elif a in ［ 0,1,6,8］:
  print("pon")
else:
  print("hon")

Buggy submission (verdict: Runtime Error):
a=int(input())
a=a%10

if a in ［3］:
  print("bon")
elif a in ［0,1,6,8］:
  print("pon")
else:
  print("hon")
Problem p02675 (python)

Fixed submission:
N = int(input())
hon = [2,4,5,7,9]
pon = [0,1,6,8]
 
if N % 10 in hon :
  print("hon")
 
elif N % 10 in pon :
  print("pon")
 
elif N % 10 == 3 :
  print("bon")

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

if N % 10 == 2,4,5,7,9 :
  print("hon")

elif N % 10 == 0,1,6,8 :
  print("pon")

elif N % 10 == 3 :
  print("bon")
Problem p02675 (python)

Fixed submission:
n = int(input())%10
if n in {2, 4, 5, 7, 9}:
    print("hon") 
elif(n == 3):
    print("bon") 
else:
    print("pon")

Buggy submission (verdict: Runtime Error):
import math
chou, tan, ji, hun = map(int,input().split())

kakudo = abs(((ji*30 + hun*.5) - (hun*6)))

if kakudo > 180:
    kakudo = abs(360 - kakudo)
print(kakudo)
kakudo = abs(math.cos((math.radians(kakudo))))
ans =( chou**2 + tan**2 - 2*chou*tan*kakudo)**.5
print(ans)

Buggy submission (verdict: Runtime Error):
import math
chou, tan, ji, hun = map(int,input().split())

kakudo = abs(((ji*30 + hun*.5) - (hun*6)))

if kakudo > 180:
    kakudo = abs(kakudo - 360)

kakudo = abs(math.cos(math.radians(kakudo)))
ans =( chou**2 + tan**2 - 2*chou*tan*kakudo)**.5
print(ans)

Buggy submission (verdict: Runtime Error):
import math
chou, tan, ji, hun = map(int,input().split())

kakudo = abs(((ji*30 + hun*.5) - (hun*6)))

if kakudo > 180:
    kakudo = 360 - kakudo

kakudo = abs(math.cos(math.radians(kakudo)))
ans =( chou**2 + tan**2 - 2*chou*tan*kakudo)**.5
print(ans)

Buggy submission (verdict: Runtime Error):
import math
chou, tan, ji, hun = map(int,input().split())

kakudo = abs(((ji*30 + hun*.5) - (hun*6)))

if kakudo > 180:
    kakudo = kakudo-360
kakudo = abs(math.cos(math.radians(kakudo)))
ans =( chou**2 + tan**2 - 2*chou*tan*kakudo)**.5
print(ans)

Buggy submission (verdict: Runtime Error):
k = int(input())
s = str(input())
if k<len(s):
    s = s[:k:1] + "..."
else:
    pass

print(s)

Buggy submission (verdict: Runtime Error):
m = 0
m = input () 
m = m % 10
if(m == 2,4,5,7,9):
    print("hon") 
elif(m == 0,1,6,8):
    print("pon") 
else:
    print("bon")
Problem p03485 (python)

Fixed submission:
A=input()
B=A.split(" ")
a=int(B[0])
b=int(B[1])
c=a+b
avg=c/2
iavg=int(c/2)
if avg==iavg:
 print(iavg)
else:
 import math
 print(math.floor(avg)+1)

Buggy submission (verdict: Runtime Error):
A=list(input())
B=list(input())
minm=min(A)
maxi=max(B)

while min(len(A),len(B))!=0:
 if minm<maxi:
  print("Yes")
  break
 if minm==maxi:
  A.remove(minm)
  B.remove(maxi)
 if minm>maxi:
  print("No") 
  break
 if min(len(A),len(B))==0:
  print("No")
  break
Problem p03493 (python)

Fixed submission:
I=input()
I2=map(int, I)
X=sum(I2)
print(X)

Buggy submission (verdict: Runtime Error):
N=int(input())
suji=input()
I1=suji.split(" ")
I=list(map(int,I1))
wari=2
n=0
kazu=0

while n<N:
    if n!=N-1:
        if I[n]%2==0:
            n+=1
    if  n==N-1:
        if I[N-1]%2==0:
            wari=wari*2
            kazu=kazu+1
            n=0
    else:
        X=0
        break
print(kazu)
Problem p02982 (python)

Fixed submission:
N, D = [int(elem) for elem in input().split()]
coords = [[int(elem) for elem in input().split()] for _ in range(N)]
assert len(coords[0]) == D

def is_squared(num):
    i = 1
    while i * i <= num:
        if i * i == num:
            return True
        i += 1
    return False


num_pairs = 0
for i in range(N):
    c1 = coords[i]
    for j in range(i + 1, N):
        c2 = coords[j]
        sqaured_dist = sum((p1 - p2) ** 2 for p1, p2 in zip(c1, c2))
        if is_squared(sqaured_dist):
            num_pairs += 1
print(num_pairs)

Buggy submission (verdict: Runtime Error):
from math import sqrt, isclose, floor
N, D = [int(elem) for elem in input().split()]
coords = [[int(elem) for elem in input().split()] for _ in range(N)]
assert len(coords[0]) == D

num_pairs = 0
for i in range(N):
    c1 = coords[i]
    for j in range(i + 1, N):
        c2 = coords[j]
        sqaured_dist = sum((p1 - p2) ** 2 for p1, p2 in zip(c1, c2))
        dist = floor(sqrt(sqaured_dist))
        if sqaured_dist // dist == dist:
            num_pairs += 1
print(num_pairs)
Problem p03047 (python)

Fixed submission:
N, K = [int(elem) for elem in input().split()]

print(N - K + 1)

Buggy submission (verdict: Runtime Error):
import sys


fin = sys.stdin.readline
N = int(fin())
s_list = [fin().rstrip("\n") for _ in range(N)]
num_AB_in_between = 0
s_Bhoge = 0
s_hogeA = 0
s_BA = 0
for s in s_list:
    if s[0] == "B" and s[-1] == "A":
        s_BA += 1
    elif s[0] == "B":
        s_Bhoge += 1
    elif s[-1] == "A":
        s_hogeA += 1

    for i, char in enumerate(s[:-1]):
        next_char = s[i + 1]
        if char == "A" and next_char == "B":
            num_AB_in_between += 1

# print(s_Bhoge, s_hogeA, s_BA)
if s_BA:
    num_AB_bound = 2 * s_BA - 2 + int(s_Bhoge > 0) + int(s_hogeA > 0)
    num_AB_bound += max(0, min(s_Bhoge - 1, s_hogeA - 1))
    # num_AB_bound += min(s_Bhoge - 1, s_hogeA - 1)
else:
    num_AB_bound = min(s_Bhoge, s_hogeA)
print(num_AB_in_between + num_AB_bound)
Problem p03128 (python)

Fixed submission:
import sys
from functools import lru_cache


sys.setrecursionlimit(200000)
fin = sys.stdin.readline
num_matches_required = {n: nmatches for n, nmatches 
    in zip(range(1, 10), (2, 5, 5, 4, 5, 6, 3, 7, 6))}

N, M = map(int, fin().split())
nums = sorted(map(int, fin().split()), reverse=True)

@lru_cache(None)
def rec(i):
    if i < 0: 
        return float('-inf')
    elif i == 0: 
        return 0
    else:
        return max(
            rec(i - num_matches_required[num]) for num in nums
        ) + 1


num_digits = rec(N)
cur_num_matches = N
result = []
while cur_num_matches:
    for num in nums:
        if rec(cur_num_matches - num_matches_required[num]) == num_digits - len(result) - 1:
            result.append(str(num))
            cur_num_matches -= num_matches_required[num]
            break

print("".join(result))

Buggy submission (verdict: Runtime Error):
import sys
from functools import lru_cache


fin = sys.stdin.readline
num_matches_required = {n: nmatches for n, nmatches 
    in zip(range(1, 10), (2, 5, 5, 4, 5, 6, 3, 7, 6))}

N, M = map(int, fin().split())
nums = sorted(map(int, fin().split()), reverse=True)

@lru_cache(None)
def rec(i):
    if i < 0: 
        return float('-inf')
    elif i == 0: 
        return 0
    else:
        return max(
            rec(i - num_matches_required[num]) for num in nums
        ) + 1


num_digits = rec(N)
cur_num_matches = N
result = []
while cur_num_matches:
    for num in nums:
        if rec(cur_num_matches - num_matches_required[num]) == num_digits - len(result) - 1:
            result.append(str(num))
            cur_num_matches -= num_matches_required[num]
            break

print("".join(result))