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

Fixed submission:
def check(string2):
	N = len(string2)
	rev = string2[::-1]
	for i in range((N//2)+1):
		if(rev[i]!=string2[i]):
			return False
	return True


string = input()
n = len(string)
n-=1
str1 = string[0:int((n)/2)]
# print(str1)
str2 = string[int((n)/2)+1:n+1]
# print(str2)
if check(str1) and check(str2) and check(string):
	print("Yes")
else:
	print("No")

Buggy submission (verdict: Runtime Error):
def check(string):
	N = len(string)
	rev = string[::-1]
	for i in range(N//2+1):
		if(rev[i]!=string[i]):
			break
			return False
	return True


string = input()
n = len(string)
n-=1
str1 = string[0:((n-1)//2)]
str2 = string[((n+3)//2):n]
if check(str1) and check(str2):
	print("Yes")
else:
	print("No")

Buggy submission (verdict: Runtime Error):
def check(string):
	N = len(string):
	rev = string[::-1]
	for i in range(N//2+1):
		if(rev[i]!=string[i]):
			break
			return False
	return True


string = input()
n = len(string)
n-=1
str1 = string[0:((n-1)/2)]
str2 = string[((n+3)/2):n]
if check(str1) and check(str2):
	print("Yes")
else:
	print("No")
Problem p02760 (python)

Fixed submission:
'''
INPUT SHORTCUTS
N, K = map(int,input().split())
N ,A,B = map(int,input().split())
string = str(input())
arr = list(map(int,input().split()))
N = int(input())
'''
grid = []
for _ in range(3):
	temp = []
	temp = list(map(int,input().split()))
	grid.append(temp)
N = int(input())
b = []
for _ in range(N):
	b.append(int(input()))
for x in b:
	for i in range(3):
		for j in range(3):
			if grid[i][j]==x:
				grid[i][j]= -(grid[i][j])
ans = -1
# if not (grid[0][0]<0 and grid[1][1]<0 and grid[2][2]<0):	
for i in range(3):
	if grid[i][0]<0 and grid[i][1]<0 and grid[i][2]<0:
		ans  = 1
		break
	elif(grid[0][i]<0 and grid[1][i]<0 and grid[2][i]<0):
		ans = 1
		break
if ans!=1:
	if (grid[0][0]<0 and grid[1][1]<0 and grid[2][2]<0):
		ans = 1
	if( grid[0][2]<0 and grid[1][1]<0 and grid[2][0]<0):
		ans =1  
if(ans ==1):
	print("Yes")
else:
	print("No")

Buggy submission (verdict: Runtime Error):
'''
INPUT SHORTCUTS
N, K = map(int,input().split())
N ,A,B = map(int,input().split())
string = str(input())
arr = list(map(int,input().split()))
N = int(input())
'''
n , m = map(int,input().split())
dp = [-1 for _ in range(n)]
flag = True 
for _ in range(m):
	i , val =  map(int,input().split())
	if dp[i-1] == -1:
		dp[i-1]=val
	elif dp[i-1]!=val:
		flag = False
		# print(dp[i-1])
		break
if dp[0]==0:
	flag = False
if flag:
	for i in range(n):
		if dp[i]==-1:
			dp[i]=0
	if dp[0]==0:
		dp[0]=1
	for x in dp:
		print(str(x),end="")
else:
	print("-1")
Problem p02830 (python)

Fixed submission:
N = int(input())
string1 , string2 = map(str,input().split())
res = ''
j = 0
k = 0
for i in range((2*N)):
	if(i%2==0):
		res+=string1[j]
		j+=1
	else:
		res+=string2[k]
		k+=1
print(res)

Buggy submission (verdict: Runtime Error):
N = int(input())
string1 = str(input())
string2 = str(input())
res = ''
j = 0
k = 0
for i in range((2*N)):
	if(i%2!=0):
		res+=string1[j]
		j+=1
	else:
		res+=string2[k]
		k+=1
print(res)
Problem p02952 (python)

Fixed submission:
def main():
	n = int(input())
	cnt = 0
	for i in range(1,n+1):
		string = str(i)
		if len(string)%2==1:
			cnt+=1
	print(cnt)




main()

Buggy submission (verdict: Runtime Error):
def main():
	n = int(input())
	arr = list(map(int,input().split()))
	for i in range(len(arr)-1):
		if arr[i]-1>(arr[i-1]-1):
			# print(i)
			print("No")
			return
	print("Yes")
	return


main()
Problem p02971 (python)

Fixed submission:
def main():
	n  = int(input())
	arr = []
	for _ in range(n):
		arr.append(int(input()))
	arr2 = arr.copy()
	arr2.sort()
	mx = arr2[-1]
	mx2 = arr2[-2]
	for i in range(len(arr)):
		if arr[i]==mx:
			print(mx2)
		else:
			print(mx)

main()

Buggy submission (verdict: Runtime Error):
def main():
	n  = int(input())
	arr = []
	for _ in range(n):
		arr.append(int(input()))
	arr2 = arr.copy()
	arr2.sort()
	mx = arr2[-1]
	mx2 = arr2[-2]
	for i in range(len(arr)):
		if arr[i]==mx:
			print(mx2)
		else:
			print(mx)

main()

Buggy submission (verdict: Runtime Error):
def main():
	n  = int(input())
	arr = []
	for _ in range(n):
		arr.append(int(input()))
	arr2 = arr.copy()
	arr2.sort()
	mx = arr2[-1]
	mx2 = arr2[-2]
	for i in range(len(arr)):
		if arr[i]==mx:
			print(mx2)
		else:
			print(mx)

main()
Problem p02576 (python)

Fixed submission:
from math import ceil
N,X,T = list(map(int,input().split(' ')))
p = ceil(N/X)
print(p*T)

Buggy submission (verdict: Runtime Error):
def sol(x,y):
    row = {}
    col = {}
    for i in x:
        if i not in row:
            row[i] = 1
        else:
            row[i] += 1
    for i in y:
        if i not in col:
            col[i] = 1
        else:
            col[i] += 1
    maxRow = 0
    maxCol = 0
    mR = 0
    mC = 0
    for i in row:
        if row[i]>mR:
            mR = row[i]
            maxRow = i
    for i in col:
        if col[i]>mC:
            mC = col[i]
            maxCol = i
    rd = {}
    cd = {}
    for i in row:
        if row[i] == mR:
            rd.add(i)
    for i in col:
        if row[i] == mC:
            cd.add(i)
    diff = rd.difference(cd)
    s = mR+mC
    if len(diff) == 0:
        s-=1
        print(s)
        return
    print(s)
    return

x,y,z = list(map(int,input().split(' ')))
row = []
col = []
for i in range(z):
    p = list(map(int,input().split(' ')))
    row.append(p[0])
    col.append(p[1])
sol(row,col)

Buggy submission (verdict: Runtime Error):
def sol(x,y):
    row = {}
    col = {}
    for i in x:
        if i not in row:
            row[i] = 1
        else:
            row[i] += 1
    for i in y:
        if i not in col:
            col[i] = 1
        else:
            col[i] += 1
    a = max(row.values())
    b = max(col.values())
    print(a+b-1)


x,y,z = list(map(int,input().split(' ')))
row = []
col = []
for i in range(z):
    p = list(map(int,input().split(' ')))
    row.append(p[0])
    col.append(p[1])
sol(row,col)
Problem p03160 (python)

Fixed submission:
def sol(lis):
    if len(lis)<=2:
        return abs(lis[0]-lis[1])
    costs = [0,abs(lis[0]-lis[1])]
    for i in range(2,len(lis)):
        x = abs(lis[i]-lis[i-1])
        y = abs(lis[i]-lis[i-2])
        costs.append(min(x+costs[-1],y+costs[-2]))
    return costs[-1]
input()
lis = list(map(int,input().split(' ')))
print(sol(lis))

Buggy submission (verdict: Runtime Error):
def sol(lis):
    if len(lis)<=2:
        return abs(lis[0]-lis[1])
    costs = [0,abs(lis[0]-lis[1])]
    for i in range(2,len(lis)):
        x = abs(lis[i]-lis[i-1])
        y = abs(lis[i]-lis[i-2])
        costs.append(min(x+costs[-1]),min(x+costs[-2]))
    print(costs)
    return costs[-1]
input()
lis = list(map(int,input().split(' ')))
print(sol(lis))
Problem p02678 (python)

Fixed submission:
from collections import deque

n, m = map(int, input().split())
G = [[]for i in range(n+1)]

# グラフ生成
for i in range(m):
    a, b = map(int, input().split())
    G[a].append(b)
    G[b].append(a)
 
ans = [0]*(n+1)
 
stk = deque([1])
 
# BFS 幅優先探索
while stk:
    v = stk.pop()
    for s in G[v]:
        # 未到達ノードであれば、キューに追加
        if ans[s] == 0:
            ans[s] = v
            stk.appendleft(s)
ans = ans[2:]
 
if 0 in ans:
    print("No")
else:
    print("Yes")
    for i in ans:
        print(i)

Buggy submission (verdict: Runtime Error):
from collections import deque

n, m = map(int, input().split())

nodes = [ [] for i in range(m+1)]

# グラフ生成
for i in range(1, m + 1):
    a, b = map(int, input().split())
    nodes[a].append(b)
    nodes[b].append(a)

ans = [0] * (n+1)

# キュー作成
stk = deque([1])

# BFS 幅優先探索
while stk:
    v = stk.pop()
    for s in nodes[v]:
        # 未到達ノードであれば、キューに追加
        if ans[s] == 0:
            # ひとつ前のノードを記録
            ans[s] = v
            # キューに要素を追加
            stk.appendleft(s)

ans = ans[2:]
 
if 0 in ans:
    print("No")
else:
    print("Yes")
    for i in ans:
        print(i)

Buggy submission (verdict: Runtime Error):
from collections import deque

n, m = map(int, input().split())

nodes = [ [] for i in range(m+1)]

# グラフ生成
for i in range(1, m + 1):
    a, b = map(int, input().split())
    nodes[a].append(b)
    nodes[b].append(a)

ans = [0] * (n+1)

# キュー作成
stk = deque([1])

# BFS 幅優先探索
while stk:
    v = stk.pop()
    for s in nodes[v]:
        # 未到達ノードであれば、キューに追加
        if ans[s] == 0:
            # ひとつ前のノードを記録
            ans[s] = v
            # キューに要素を追加
            stk.appendleft(s)

ans = ans[2:]
 
if 0 in ans:
    print("No")
else:
    print("Yes")
    for i in ans:
        print(i)
Problem p02683 (python)

Fixed submission:
import itertools
import numpy as np

n, m, x = map(int, input().split())
san = []
for i in range(n):
    san.append(list(map(int, input().split())))

result = []
adds = []
for j in range(1,n+1):
     for conb in itertools.combinations(san, j):
        result.append(list(conb)) #タプルをリスト型に変換

for i in result:
    t = np.zeros([m+1], dtype=int)
    for j in i:
        t = t + np.array(j)

    adds.append(t)

price = -1
ans = 0
for num, i in enumerate(adds):
    use = True
    for j in range(1,m+1):
        if i[j] < x:
            # print(i)
            use = False
            break

    if use:
        # print(i)
        # print(result[num])
        if price == -1 or price > i[0]:
        # if price > i[0]:
            price = i[0]
            ans = num

print(price)

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

n, m, x = map(int, input().split())
san = []
for i in range(n):
    san.append(list(map(int, input().split())))

result = []
adds = []
for j in range(1,n+1):
     for conb in itertools.combinations(san, j):
        result.append(list(conb)) #タプルをリスト型に変換

for i in result:
    t = np.zeros([m+1], dtype=int)
    for j in i:
        t = t + np.array(j)

    adds.append(t)

price = -1
ans = 0
for num, i in enumerate(adds):
    use = True
    for j in range(1,m+1):
        if i[j] < 10:
            # print(i)
            use = False
            break

    if use:
        # print(i)
        # print(result[num])
        if price == -1 or price > i[0]:
        # if price > i[0]:
            price = i[0]
            ans = num

print(price)
Problem p02630 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
BC = []
for b in range(Q):
  BC.append(list(map(int, input().split())))

T = [0]*200000
#T[i] = A中の数値iの数

for i in A:
  T[i]+=1
S = sum(A)
for i in BC:
  b,c = i
  n = int(T[b])
  sa = c*n - b*n
  S = S + c*n - b*n
  print(S)
  T[b]=0
  T[c]+=n
  #print(S, [b,T[b], 0],[c,T[c],T[c]+T[b]], sa, S+sa)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
BC = []
for b in range(Q):
  BC.append(list(map(int, input().split())))

T = [0]*100000
#T[i] = A中の数値iの数

for i in A:
  T[i]+=1
S = sum(A)
for i in BC:
  b,c = i
  n = int(T[b])
  sa = c*n - b*n
  S = S + c*n - b*n
  print(S)
  T[b]=0
  T[c]+=n
  #print(S, [b,T[b], 0],[c,T[c],T[c]+T[b]], sa, S+sa)
Problem p02641 (python)

Fixed submission:
list1= input().split(" ")
list2= input().split(" ")
X=int(list1[0])
N=int(list1[1])
plus_abs =1000
minus_abs=1000
result=0

for i in range(100):
    plus_abs=X+i
    minus_abs=X-i

    for j in range(N):
        if plus_abs == int(list2[j]):
           plus_abs=1000


    for k in range(N):
        if minus_abs == int(list2[k]):
            minus_abs=1000

    if plus_abs !=1000 or minus_abs!=1000:
        if plus_abs >= minus_abs:
            result = minus_abs
        else:
            result = plus_abs

        print(result)
        break

Buggy submission (verdict: Runtime Error):
for i in range(100):
    plus_abs=X+i
    minus_abs=X-i

    for j in range(N):
        if plus_abs == int(list2[j]):
           plus_abs=1000


    for k in range(N):
        if minus_abs == int(list2[k]):
            minus_abs=1000

    if plus_abs !=1000 or minus_abs!=1000:
        if plus_abs >= minus_abs:
            result = minus_abs
        else:
            result = plus_abs

        print(result)
        break
Problem p02658 (python)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
MAX = 1e18

A.sort()

ans = 1
for i in A:
    ans *= i
    if ans > MAX:
        ans = -1
        break

print(ans)

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

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

ans = int(0)
if(A[0] == 0):
    ans = 0
else:
    ans = np.prod(A)

if ans >= 1e18:
    print('-1')
else:
    print(f'{ans}')

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

N = int(input())
A = [map(int, input().split())]
A.sort()

ans = 0
if(A[0] == 0):
    ans = 0
else:
    ans = np.prod(x)

if ans >= 1e18:
    print('-1')
else:
    print(f'{ans}')

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [map(int, input().split())]
ans = int(0)
for i in A:
  ans *= i
  if ans >= 1e18:
    ans = -1
    break
Problem p02675 (python)

Fixed submission:
from sys import stdin

N = int(input()) 
hon = {2,4,5,7,9}
pon = {0,1,6,8}
bon = {3}

N = N % 10

if N in hon:
    print('hon')
elif N in pon:
    print('pon')
else:
    print('bon')

Buggy submission (verdict: Runtime Error):
from sys import stdin

N = map(int, stdin.readline().rstrip().split())
hon = {2,4,5,7,9}
pon = {0,1,6,8}
bon = {3}

N = N % 10

if N in hon:
    print('hon')
elif N in pon:
    print('pon')
else:
    print('bon')
Problem p02641 (python)

Fixed submission:
X, N = map(int, input().split())
try:
  p = list(map(int, input().split()))
except:
  p = []


l = [0]*200

for i in range(N):
  l[abs(p[i] - X)] += 1

#print(p.index(9))

if N == 0:
  print(X)
else:
  for i in range(N+1):
    if i == 0:
      if l[0] == 1:
        continue
      else:
        print(X)
        break
    else:
      if l[i] == 0:
        print(X-i)
        break
      elif l[i] == 1:
        try:
          p_index = p.index(X-i)
          print(X+i)
        except:
          print(X-i)
        break

Buggy submission (verdict: Runtime Error):
try:
  p = list(map(int, input().split()))
except:
  p = []


l = [0]*100

for i in range(N):
  l[abs(p[i] - X)] += 1

#print(p.index(9))
if N == 0:
  print(X)
else:
  for i in range(N):
    if i == 0:
      if l[0] == 1:
        continue
      else:
        print(X)
        break
    else:
      if l[i] == 0:
        print(X-i)
        break
      elif l[i] == 1:
        try:
          p_index = p.index(X-i)
          print(X+i)
        except:
          print(X-i)
        break

Buggy submission (verdict: Runtime Error):
X, N = map(int, input().split())
try:
  p = list(map(int, input().split()))
except:
  p = []


l = [0]*X

for i in range(N):
  l[abs(p[i] - X)] += 1

#print(p.index(9))
if N == 0:
  print(X)
else:
  for i in range(N):
    if i == 0:
      if l[0] == 1:
        continue
      else:
        print(X)
        break
    else:
      if l[i] == 0:
        print(X-i)
        break
      elif l[i] == 1:
        try:
          p_index = p.index(X-i)
          print(X+i)
        except:
          print(X-i)
        break

Buggy submission (verdict: Runtime Error):
X, N = map(int, input().split())
try:
  p = list(map(int, input().split()))
except:
  p = []


l = [0]*X

for i in range(N):
  l[abs(p[i] - X)] += 1

if N == 0:
  print(X)
else:
  for i in range(N):
    if i == 0:
      if l[0] == 1:
        continue
      else:
        print(X)
        break
    else:
      if l[i] == 0:
        print(X-i)
        break
      elif l[i] == 1:
        try:
          p_index = p.index(x-i)
          print(X-i)
        except:
          print(X+i)
        break

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


l = [0]*N

for i in range(N):
  l[abs(p[i] - X)] += 1

for i in range(N):
  if i == 0:
    if l[0] == 1:
      continue
    else:
      print(X)
  else:
    if l[i] == 0:
      print(X-i)
      break
    elif l[i] == 1:
      try:
        p_index = p.index(x-i)
        print(X-i)
      except:
        print(X+i)
      break
Problem p02646 (python)

Fixed submission:
A, V = map(int, input().split())
B, W = map(int, input().split())
T = int(input())

if V-W <= 0:
  print("NO")
else:
  if (abs(B-A)/(V-W)) <= T:
      print("YES")
  else:
    print("NO")

Buggy submission (verdict: Runtime Error):
A, V = map(int, input().split())
B, W = map(int, input().split())
T = int(input())

if ((B-A)/(V-W)) <= T:
  print("Yes")
else:
  print("No")
Problem p02848 (python)

Fixed submission:
# -*- coding: utf-8 -*-
N = int(input())
S = input()

moji_list = []

q, mod = divmod(N, 26)
for i in range(len(S)):
  if (ord(S[i])+mod) <= 90:
    moji_list.append(chr(ord(S[i]) + mod))
  else:
    moji_list.append(chr(ord(S[i]) + mod - 26))
    
  
print("".join(moji_list))

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
N = int(input())
S = input()

moji_list = []
for i in range(N):
  if (ord(S[i])+N) <= 90:
    moji_list.append(chr(ord(S[i]) + N))
  else:
    moji_list.append(chr(ord(S[i]) + N - 26))
    
  
print("".join(moji_list))

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
N = int(input())
S = input()

moji_list = []
for i in range(N):
  moji_list.append(chr(ord(S[i]) + N))
  
print("".join(moji_list))
Problem p02923 (python)

Fixed submission:
# -*- coding: utf-8 -*-
N = int(input())
H = list(map(int,input().split()))

sum = 0
L = []

for i in range(len(H)):
  if i == 0:
    sum = 0
    L.append(sum)
  elif i == N-1:
    if H[i] <= H[i-1]:
      sum += 1
      L.append(sum)
    else:
      L.append(sum)
  else:
    if H[i] <= H[i-1]:
      sum += 1
    else:
      L.append(sum)
      sum = 0
    
print(max(L))

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
N = int(input())
H = list(map(int,input().split()))

sum = 0
L = []

for i in range(len(H)):
  if i == 0:
    sum = 0
  elif i == N-1:
    if H[i] <= H[i-1]:
      sum += 1
      L.append(sum)
    else:
      L.append(sum)
  else:
    if H[i] <= H[i-1]:
      sum += 1
    else:
      L.append(sum)
      sum = 0
    
print(max(L))
Problem p02971 (python)

Fixed submission:
# -*- coding: utf-8 -*-
N = int(input())
A = [int(input()) for _ in range(N)]
setA = set(A)
tempA = list(setA)
R = sorted(tempA, reverse=True)
max_v = R[0]
if len(R) >= 2:
  max_v2 = R[1]
else:
  max_v2 = R[0]
R2 = sorted(A, reverse=True)
if R2[0] == R2[1]:
  signal = 1
else:
  signal = 0
  
for i in range(N):
  if A[i] == max_v and signal == 0:
    print(max_v2)
  else:
    print(max_v)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
N = int(input())
A = [int(input()) for _ in range(N)]
setA = set(A)
tempA = list(setA)
R = sorted(tempA, reverse=True)
max_v = R[0]
if len(R) >= 1:
  max_v2 = R[1]
  signal = 1
else:
  max_v2 = R[0]

for i in range(N):
  if A[i] == max_v:
    print(max_v2)
  else:
    print(max_v)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
N = int(input())
A = [int(input()) for _ in range(N)]
setA = set(A)
tempA = list(setA)
R = sorted(tempA, reverse=True)
max_v = R[0]
max_v2 = R[1]

for i in range(N):
  if A[i] == max_v:
    print(max_v2)
  else:
    print(max_v)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
N = int(input())
A = [int(input()) for _ in range(N)]
setA = set(A)
tempA = list(setA)
R = sorted(tempA, reverse=True)
max_v = R[0]
max_v2 = R[1]

for i in range(N):
  if A[i] == R[0]:
    print(R[0])
  else:
    print(R[1])
Problem p02678 (python)

Fixed submission:
N, M = map(int, input().split())
from collections import defaultdict
AB_dict = defaultdict(list)
dist_list = [-1] * N
dist_list[0] = 0
pre_list = []
for _ in range(M):
    a, b = [int(i)-1 for i in input().split()]
    AB_dict[a].append(b)
    AB_dict[b].append(a)
    if a == 0:
        pre_list.append(b)
        dist_list[b] = 0
    if b == 0:
        pre_list.append(a)
        dist_list[a] = 0
#print(AB_dict)

    
while True:
    tmp = []
    #print(pre_list)
    for p in pre_list:
        #print(p)
        for node in AB_dict[p]:
            #print("node", node)
            if dist_list[node] == -1:
                #print(node, "=", p)
                dist_list[node] = p
                tmp.append(node)
    if tmp == []:
        break
    pre_list = tmp
    
if -1 in dist_list:
    print('No')
    exit()
    
print('Yes')
for dist in dist_list[1:]:
    print(dist+1)

Buggy submission (verdict: Runtime Error):
import numpy as np
from scipy.sparse.csgraph import shortest_path

N, M = map(int, input().split())
AB_list = []
for _ in range(M):
    AB_list.append([int(i)-1 for i in input().split()])

#print(N,M)
#print(AB_list)

mat = np.zeros((N, N))
for a, b in AB_list:
    mat[a][b] = 1
    mat[b][a] = 1
#print(mat)


def get_path(start, goal, pred):
    return get_path_row(start, goal, pred[start])

def get_path_row(start, goal, pred_row):
    path = []
    i = goal
    while i != start and i >= 0:
        path.append(i)
        i = pred_row[i]
    if i < 0:
        return []
    path.append(i)
    return path[::-1]


dist_list = [-1] * N

d, p = shortest_path(mat, return_predecessors=True, unweighted=True)
for n in range(1, N):
    shpath = get_path(n, 0, p)
    #print(n, shpath)
    for i in range(len(shpath)-1):
        #print(shpath[i], shpath[i+1], dist_list)
        if dist_list[shpath[i]] == -1: 
            dist_list[shpath[i]] = shpath[i+1]
        else:
            if dist_list[shpath[i]] != shpath[i+1]:
                print('No')
                exit()
print('Yes')
for dist in dist_list[1:]:
    print(dist+1)
Problem p02783 (python)

Fixed submission:
import math
H, A = map(int, input().strip().split())
print(math.ceil(H/A))

Buggy submission (verdict: Runtime Error):
import math
H,A = input().strip().split()
print(math.ceil(H/A))
Problem p02911 (python)

Fixed submission:
from collections import Counter
N, K, Q = map(int, input().strip().split())
ansl = [int(input().strip()) for _ in range(Q)]
countl = Counter(ansl)
sumcountl = sum(countl.values())
for i in range(N):
    print('Yes') if sumcountl-countl[i+1] < K else print('No')

Buggy submission (verdict: Runtime Error):
N, K, Q = map(int, input().strip().split())
ansl = [int(input().strip()) for _ in range(Q)]
countl = Counter(ansl)
sumansl = sum(countl.values())
for i in range(N):
    print('Yes') if sumansl-countl[i+1] < K else print('No')
Problem p02573 (python)

Fixed submission:
import sys
sys.setrecursionlimit(99999999)


[n,m]=list(map(int,input().split()))
friends=[]
for i in range(m):
    friends.append(list(map(int,input().split())))

tomodachi=[[]for i in range(n)]

for i in range(m):
    tomodachi[friends[i][0]-1].append(friends[i][1]-1)
    tomodachi[friends[i][1]-1].append(friends[i][0]-1)

for i in range(n):
    tomodachi[i]=list(set(tomodachi[i]))

namelist=[1 for i in range(n)]
teams=[]

def haba(x,kari,tomodachi,namelist):
    for i in range(len(tomodachi[x])):
        if namelist[tomodachi[x][i]]==1:#生き残っているなら
            kari.append(tomodachi[x][i])
            namelist[tomodachi[x][i]]=0#殺す
            haba(tomodachi[x][i],kari,tomodachi,namelist)
    return(kari)
            


for i in range(n):
    if namelist[i]==1:
        teams.append(list(set(haba(i,[i],tomodachi,namelist))))

saidai=0

for i in range(len(teams)):
    if saidai<len(teams[i]):
        saidai=len(teams[i])

ans=saidai

print(ans)

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


[n,m]=list(map(int,input().split()))
friends=[]
for i in range(m):
    friends.append(list(map(int,input().split())))

tomodachi=[[]for i in range(n)]

for i in range(m):
    tomodachi[friends[i][0]-1].append(friends[i][1]-1)
    tomodachi[friends[i][1]-1].append(friends[i][0]-1)

for i in range(n):
    tomodachi[i]=list(set(tomodachi[i]))

namelist=[1 for i in range(n)]
teams=[]

def haba(x,kari,tomodachi,namelist):
    for i in range(len(tomodachi[x])):
        if namelist[tomodachi[x][i]]==1:#生き残っているなら
            kari.append(tomodachi[x][i])
            namelist[tomodachi[x][i]]=0#殺す
            haba(tomodachi[x][i],kari,tomodachi,namelist)
    return(kari)
            


for i in range(n):
    if namelist[i]==1:
        teams.append(list(set(haba(i,[i],tomodachi,namelist))))

saidai=0

for i in range(len(teams)):
    if saidai<len(teams[i]):
        saidai=len(teams[i])

ans=saidai

print(ans)