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

Fixed submission:
import sys


sys.setrecursionlimit(100000)
MOD = 10**9 + 7
n = int(input())
tree = [[] for i in range(n)]
for i in range(n-1):
    tmp1, tmp2 = map(int, input().split())
    tree[tmp1 - 1].append(tmp2 - 1) 
    tree[tmp2 - 1].append(tmp1 - 1)
visited = [False]*n

def dfs(i):
    visited[i] = True
    if all([visited[j] for j in tree[i]]):
        return 1, 1  #黒の通り数, 白の通り数
    else:
        ans1 = 1
        ans2 = 1
        for j in tree[i]:
            if not visited[j]:
                tmp1, tmp2 = dfs(j)
                ans1 *= tmp2
                ans2 *= (tmp1 + tmp2)
                ans1 %= MOD
                ans2 %= MOD
        return ans1, ans2  #黒の通り数, 白の通り数

print(sum(dfs(0)) % MOD)

Buggy submission (verdict: Runtime Error):
MOD = 10**9 + 7
n = int(input())
tree = [[] for i in range(n)]
for i in range(n-1):
    tmp1, tmp2 = map(int, input().split())
    tree[tmp1 - 1].append(tmp2 - 1) 
    tree[tmp2 - 1].append(tmp1 - 1)
visited = [False]*n

def dfs(i):
    visited[i] = True
    if all([visited[j] for j in tree[i]]):
        return 1, 1  #黒の通り数, 白の通り数
    else:
        ans1 = 1
        ans2 = 1
        for j in tree[i]:
            if not visited[j]:
                tmp1, tmp2 = dfs(j)
                ans1 *= tmp2
                ans2 *= (tmp1 + tmp2)
                ans1 %= MOD
                ans2 %= MOD
        return ans1, ans2  #黒の通り数, 白の通り数

print(sum(dfs(0)) % MOD)
Problem p03193 (python)

Fixed submission:
N, H, W = map(int,input().split())
 
count =0
 
for num in range(N):
  A, B = map(int,input().split())
  if A >=H and B >= W:
    count +=1
print(count)

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

count =0

for num in range(N):
  A, B = map(int,inp().split())
  if H >=A and W>=B:
    count +=1
print(count)
Problem p03194 (python)

Fixed submission:
N, P = map(int,input().split())
 
output=1
 
if P==1:
  output=1
elif N==1:
  output=P
else:
  for num in range(2,round(P**(1/N))+1):
    if P%(num**N) == 0:
      output = num
 
print(output)

Buggy submission (verdict: Runtime Error):
N, P = map(int,input().split())
 
output=1
 
if P==1:
  
else:
  for num in range(2,round(P**(1/N))+1):
    if P%(num**N) == 0:
      output = num
 
print(output)
Problem p03203 (python)

Fixed submission:
from operator import itemgetter
import bisect


h, w, n = map(int, input().split())
info = [tuple(map(int, input().split())) for i in range(n)]

memo = set()
for i, j in info:
    memo.add(i * 10**6 + j)

pos = [[] for _ in range(w + 1)]
info = sorted(info, key = itemgetter(0))
for i, j in info:
    pos[j].append(i)

ans = 10**18
pos_i, pos_j = 1, 1
ind = bisect.bisect_right(pos[pos_j], pos_i)
try:
    ans = min(pos[pos_j][ind] - 1, ans)
except:
    pass

while True:
    if (pos_i + 1) * 10**6 + pos_j in memo or pos_i == h:
        ans = min(ans, pos_i)
        break
    pos_i += 1

    if pos_i * 10**6 + (pos_j + 1) in memo or pos_j == w:
        continue
    else:
        pos_j += 1
    ind = bisect.bisect_right(pos[pos_j], pos_i)
    try:
        ans = min(pos[pos_j][ind] - 1, ans)
    except:
        pass
print(ans)

Buggy submission (verdict: Runtime Error):
import bisect


h, w, n = map(int, input().split())
info = [list(map(int, input().split())) for i in range(n)]

set_ = set()
tate = [[] for i in range(w + 1)]
for i, j in info:
    tate[j].append(i)
    set_.add((i, j))
for j in range(w + 1):
    tate[j].append(h + 1)

i, j = 1, 1
ans = 10 ** 18
while True:
    if i == w + 1:
        break
    ind = bisect.bisect_right(tate[j], i)
    ans = min(ans, tate[j][ind] - 1)

    i += 1
    if (i, j + 1) in set_ or j == w:
        pass
    else:
        j += 1

print(ans)

Buggy submission (verdict: Runtime Error):
from operator import itemgetter
import bisect


h, w, n = map(int, input().split())
info = [tuple(map(int, input().split())) for i in range(n)]

memo = set()
for i, j in info:
    memo.add(i*10**6 + j)

pos = [[] for _ in range(w + 1)]
info = sorted(info, key = itemgetter(1))
for i, j in info:
    pos[j].append(i)

ans = 10**9
pos_i, pos_j = 1, 1
while True:
    if (pos_i + 1)*10**6 + pos_j in memo:
        break
    if pos_i == h:
        ans = min(ans, h)
        break
    pos_i += 1

    if pos_i*10**6 + pos_j + 1 in memo:
        continue
    else:
        pos_j += 1
    ind = bisect.bisect_right(pos[pos_j], pos_i)
    try:
        ans = min(pos[pos_j][ind] - 1, ans)
    except:
        pass
print(ans)
Problem p03240 (python)

Fixed submission:
n = int(input())
 
#zahyo[i][j], iはi番目の地点、j=0はx座標、j=1はy座標、j=2は高さhを表す
zahyo = [list(map(int,input().split())) for i in range(n)] 
 
for cx in range(101):
  for cy in range(101):
    flag =0
    for i in range(n):
      if zahyo[i][2]>0:
        H0 = abs(cx-zahyo[i][0])+abs(cy-zahyo[i][1])+zahyo[i][2]
        break
    for i in range(n):
      if zahyo[i][2] != max(0, H0-abs(cx-zahyo[i][0])-abs(cy-zahyo[i][1])):  
        flag=1
        break
    if flag==0:
      print(cx,cy,H0)
      exit()

Buggy submission (verdict: Runtime Error):
n = int(input())
 
#zahyo[i][j], iはi番目の地点、j=0はx座標、j=1はy座標、j=2は高さhを表す
zahyo = [list(map(int,input().split())) for i in range(n)] 
flag = 0
for cx in range(101):
  for cy in range(101):
    if flag == 0:
      for i in range(0,n):
        if zahyo[0][2]>0:
          H0 = abs(cx-zahyo[i][0])+abs(cy-zahyo[i][1])+zahyo[i][2]
          break
      for i in range(1,n):
        H = abs(cx-zahyo[i][0])+abs(cy-zahyo[i][1])+zahyo[i][2]  
        if H != H0:
          break
      if H == H0 and H != 0:
        print(cx,cy,H0)
        flag = 1
    else:
      break
Problem p03244 (python)

Fixed submission:
a=[0]*100001
b=[0]*100001

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

for i in range(0,n,2):
  a[v[i]]+=1
for i in range(1,n,2):
  b[v[i]]+=1

if a.index(max(a))==b.index(max(b)):
  a= sorted(a, reverse=True)
  b= sorted(b, reverse=True)
  print(min(n-a[1]-b[0],n-a[0]-b[1]))
else:
  print(n-max(a)-max(b))

Buggy submission (verdict: Runtime Error):
a=[0]*100001
b=[0]*100001

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

for i in range(0,n,2):
  a[v[i]]+=1
for i in range(1,n,2):
  b[v[i]]+=1

if a.index(max(a))==b.index(max(b)):
  a= sorted(a[v[i]])
  b= sorted(b[v[i]])
  print(min(n-a[2]+b[1],n-a[1]-b[2]))
elif max(a)+max(b)==n and v[1]==v[0]:
  print(n//2)
else:
  print(n-max(a)-max(b))

Buggy submission (verdict: Runtime Error):
a=[0]*100000
b=[0]*100000

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

for i in range(0,n,2):
  a[v[i]]+=1


for i in range(1,n,2):
  b[v[i]]+=1

if max(a)+max(b)==n and v[1]==v[0]:
  print(n//2)
else:
  print(n-max(a)-max(b))
Problem p03274 (python)

Fixed submission:
n,k = map(int,input().split())
x = list(map(int,input().split()))
 
kyori=10**9
for i in range(n-k+1):
#print(x[i:k+i])
  if x[k+i-1]<=0:
    kyori = min(kyori,abs(x[i]))
  elif x[i]<0 and 0<x[k+i-1]:
    kyori = min(kyori,abs(x[i]*2)+abs(x[k+i-1]),abs(x[i])+abs(x[k+i-1]*2))
  elif 0<=x[i]:
    kyori = min(kyori,abs(x[k+i-1]))
print(kyori)

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

kyori=2*10**8+1
for i in range(n-k+1):
#print(x[i:k+i])
  if x[k+i-1]<=0:
    kyori = min(kyori,abs(x[i]))
  elif x[i]<=0 and 0<=x[k+1-1]:
    kyori = min(kyori,abs(x[i]*2)+abs(x[k+i-1]),abs(x[i])+abs(x[k+i-1]*2))
  elif 0<=x[i]:
    kyori = min(kyori,abs(x[k+i-1]))
print(kyori)
Problem p03284 (python)

Fixed submission:
n,k= map(int,input().split())
print(0 if n%k==0 else 1)

Buggy submission (verdict: Runtime Error):
n,k= int(input().split())
print(0 if n%k==0 else 1)

Buggy submission (verdict: Runtime Error):
n,k= int(input().split())
print(0 if n%k=0 else 1)
Problem p03328 (python)

Fixed submission:
import sys
sys.setrecursionlimit(2000)

a,b = map(int,input().split())

c = b - a 

def count(n):
  if n ==1:
    return 1
  else:
    return count(n-1)+n

print(count(c)-b)

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

c = b - a 

def count(n):
  if n ==1:
    return 1
  else:
    return count(n-1)+n

print(count(c)-b)
Problem p03388 (python)

Fixed submission:
def solve(ab,i):
    return (ab - 1) // i
    
q = int(input())
for i in range(q):
    a, b = map(int, input().split())
    if a > b:
        a, b = b, a
    ans = a - 1
    
    start_a = a + 1
    num = int((a * b) ** 0.5)
    while True:
        if solve(a*b, num) == solve(a*b, num + 1):
            break
        else:
            num += 1
    ans = num - 1
    ans += (solve(a*b, num) - 1)
    if a == b:
        ans += 1
    print(ans)

Buggy submission (verdict: Runtime Error):


q = int(input())
info = [list(map(int, input().split())) for i in range(q)]

for i in range(q):
    min_, max_ = info[i]
    min_, max_ = min(min_, max_), max(min_, max_)
    mul = min_ * max_
    ans = 2 * (min_ - 1)

    ok = 0
    ng = max_ + 10
    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        if mid <= (mul - 1) // mid:
            ok = mid
        else:
            ng = mid
    ans += max(ok - (min_ - 1), 0)
    ans += max(ok - min_, 0)
    
    if ok == (mul - 1) // ok:
        ans -= 1
    print(ans)
Problem p03394 (python)

Fixed submission:
n = int(input())

div, mod = divmod(n, 4)
ans = []

if n == 3:
    print(2, 5, 63)
    exit()
if n == 4:
    print(2, 5, 20, 63)
    exit()
if n == 5:
    print(2, 5, 20, 30, 63)
    exit()
    
cnt = 0
i = 0
for i in range(div):
    cnt += 15
    ans.append(6*i + 2)
    ans.append(6*i + 3)
    ans.append(6*i + 4)
    ans.append(6*i + 6)
if mod == 1:
    i += 1
    cnt += 2
    ans.append(6*i + 2)
if mod == 2:
    i += 1
    cnt += 5
    ans.append(6*i + 2)
    ans.append(6*i + 3)
if mod == 3:
    i += 1
    cnt += 9
    ans.append(6*i + 2)
    ans.append(6*i + 3)
    ans.append(6*i + 4)

if cnt % 6 == 0:
    pass
if cnt % 6 == 2:
    ans = ans[0:4] + ans[5:] + [ans[-1] - ans[-1] % 6 + 6]
if cnt % 6 == 3:
    ans = ans[0:5] + ans[6:] + [ans[-1] - ans[-1] % 6 + 6]
if cnt % 6 == 5:
    ans = ans[0:5] + ans[6:] + [6 * (ans[-1] // 6) + 4]
print(*ans)

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

div, mod = divmod(n, 4)
ans = []
for i in range(div):
    ans.append(6*i + 2)
    ans.append(6*i + 3)
    ans.append(6*i + 4)
    ans.append(6*i + 6)

if mod == 1:
    ans.append(6*(i+1) + 6)
if mod == 2:
    ans.append(6*(i+1) + 2)
    ans.append(6*(i+1) + 4)
if mod == 3:
    ans.append(6*(i+1) + 2)
    ans.append(6*(i+1) + 4)
    ans.append(6*(i+1) + 6)

print(*ans)
Problem p03412 (python)

Fixed submission:
from bisect import bisect_left
import sys
input = sys.stdin.buffer.readline


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))


ans = 0
for keta in range(0, 29)[::-1]:
    MOD = 1 << (keta + 1)
    T = 1 << keta
    for i in range(n):
        a[i] %= MOD
        b[i] %= MOD
    a.sort(reverse=True)
    b.sort()

    # T <= a[i] + b[j] < 2T もしくは 3T <= a[i] + b[j] < 4T
    # を満たすi, jの組の個数を尺取り法で探す
    T1 = [0] * n
    l = 0
    for i in range(n):
        while l < n and a[i] + b[l] < T:
            l += 1
        T1[i] = l

    T2 = [0] * n
    l = 0
    for i in range(n):
        while l < n and a[i] + b[l] < 2 * T:
            l += 1
        T2[i] = l

    T3 = [0] * n
    l = 0
    for i in range(n):
        while l < n and a[i] + b[l] < 3 * T:
            l += 1
        T3[i] = l

    T4 = [0] * n
    l = 0
    for i in range(n):
        while l < n and a[i] + b[l] < 4 * T:
            l += 1
        T4[i] = l

    cnt = 0  
    for i in range(n):
        cnt += (T2[i] - T1[i]) + (T4[i] - T3[i])

    # i, jの組の個数が奇数だったら、xorしたときにTが残る
    if cnt % 2 == 1:
        ans += T

print(ans)

Buggy submission (verdict: Runtime Error):
from bisect import bisect_left
import sys
input = sys.stdin.buffer.readline


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))


ans = 0
for keta in range(0, 29)[::-1]:
    MOD = 1 << (keta + 1)
    T = 1 << keta
    for i in range(n):
        a[i] %= MOD
        b[i] %= MOD
    a.sort()
    b.sort()

    # i, jの組の個数が奇数だったら、xorしたときにTが残る
    if cnt % 2 == 1:
        ans += T

print(ans)
Problem p03417 (python)

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

if m==1 and n==1:
  print(1)
elif m==2:
  print(0)
elif n==2:
  print(0)
else:
  print(max(1,n-2)*max(1,m-2))

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

if m==1 and n==1:
  print(1)
elif m==2:
  print(0)
elif n==2:
  print(0):
else:
  print(max(1,n-2)*max(1,m-2))
Problem p03421 (python)

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

min_b = -((-n) // a)
if not(min_b <= b and a + b <= n + 1):
    print(-1)
    exit()

ans = []
i = 0
while True:
    tmp = []
    break_flag = False
    for j in range(a):
        if i * a + j >= n:
            break_flag = True
            break
        tmp.append(i * a + j + 1)
    if not tmp:
        break
    ans.append(tmp)
    i += 1
    if break_flag:
        break

ans.sort(reverse=True)
nokori_b = b - len(ans)

for i in range(len(ans) - 1):
    cnt_elems = len(ans[i])
    if nokori_b >= len(ans[i]) - 1:
        ans[i].sort(reverse=True)
        nokori_b -= (len(ans[i]) - 1)
    else:
        ans[i] = sorted(ans[i][:nokori_b + 1], reverse=True) + ans[i][nokori_b + 1:]
        break

res = []
for li in ans:
    for num in li:
        res.append(num)
print(*res)

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

min_b = -((-n) // a)

if not(min_b <= b and a + b <= n + 1):
    print(-1)
else:
    print(re)
Problem p03436 (python)

Fixed submission:
from collections import deque

h,w = map(int,input().split())
s = [input() for i in range(h)]

def bfs(i,j):
  visited = [[-1]*w for i in range(h)]
  que = deque()
  que.append([i,j])
  visited[i][j]=0
  
  while True:
    if not que:
      return -1
    
    [current_i,current_j] = que.popleft()
    
    if  current_i == h-1 and current_j == w-1:
      return visited[current_i][current_j]
  
    for next in [[-1,0],[+1,0],[0,-1],[0,+1]]:
      next_i = current_i + next[0]
      next_j = current_j + next[1]
      if 0<=next_i<h and 0<=next_j<w:
        if visited[next_i][next_j] == -1 and s[next_i][next_j]==".":
          visited[next_i][next_j] = visited[current_i][current_j]+1
          que.append([next_i,next_j])

count_point=0
for i in range(h):
  for j in range(w):
    if s[i][j] == ".":
      count_point += 1 


if bfs(0,0)==-1:
  print(-1)
else:
  print(count_point-bfs(0,0)-1)

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

h,w = map(int,input().split())
s = [input() for i in range(h)]
visited = [[-1]*w for i in range(h)]
que = deque()

def bfs(i,j):
  que.append([i,j])
  visited[i][j]=0
  
  while True:
    if not que:
      return "答えなし"
    
    [current_i,current_j] = que.popleft()
    
    if  current_i == h-1 and current_j == w-1:
      return visited[current_i][current_j]
  
    for next in [[-1,0],[+1,0],[0,-1],[0,+1]]:
      next_i = current_i + next[0]
      next_j = current_j + next[1]
      if 0<=next_i<h and 0<=next_j<w:
        if visited[next_i][next_j] == -1 and s[next_i][next_j]==".":
          visited[next_i][next_j] = visited[current_i][current_j]+1
          que.append([next_i,next_j])

count_point=0
for i in range(h):
  for j in range(w):
    if s[i][j] == ".":
      count_point += 1 
  
print(count_point-bfs(0,0)-1)
Problem p03440 (python)

Fixed submission:
import heapq
from collections import deque


n, m = map(int, input().split())
a = list(map(int, input().split()))
info = [list(map(int, input().split())) for i in range(m)]
tree = [[] for i in range(n)]

for b, c in info:
    tree[b].append(c)
    tree[c].append(b)

visited = [False] * n
group = []
for i in range(n):
    if visited[i]:
        continue
    q = deque([i])
    visited[i] = True
    tmp = [a[i]]
    while q:
        pos = q.pop()
        for next_pos in tree[pos]:
            if visited[next_pos]:
                continue
            visited[next_pos] = True
            q.append(next_pos)
            tmp.append(a[next_pos])
    group.append(tmp)

for i in range(len(group)):
    group[i] = sorted(group[i])

ans = 0
cnt = len(group)*2 - 2

if cnt == 0:
    print(0)
    exit()
    
for i in range(len(group)):
    ans += group[i][0]
    cnt -= 1
    group[i][0] = 10**9 + 7

q = []
for i in range(len(group)):
    for num in group[i]:
        if num != 10**9 +7:
            heapq.heappush(q, num)

for i in range(cnt):
    if not q:
        print("Impossible")
        exit()
    ans += heapq.heappop(q)
print(ans)

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

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

info = [list(map(int, input().split())) for i in range(m)]
tree = [[] for i in range(n)]

for b, c in info:
    tree[b].append(c)
    tree[c].append(b)

visited = [False] * n
group = []
for i in range(n):
    if visited[i]:
        continue
    q = deque([i])
    visited[i] = True
    tmp = [a[i]]
    while q:
        pos = q.pop()
        for next_pos in tree[pos]:
            if visited[next_pos]:
                continue
            visited[next_pos] = True
            q.append(next_pos)
            tmp.append(a[next_pos])
    group.append(tmp)

for i in range(len(group)):
    group[i] = sorted(group[i])
    
ans = 0
cnt = len(group)*2 - 2

if cnt == 0:
    print(0)
    exit()
    
for i in range(len(group)):
    ans += group[i][0]
    cnt -= 1
    group[i][0] = 10**9 + 7

q = []
for i in range(len(group)):
    for num in group[i]:
        if num != 10**9 +7:
            heapq.heappush(q, num)

for i in range(cnt):
    if not q:
        print("Impossible")
        exit()
    ans += heapq.heappush(q)
print(ans)
Problem p03455 (python)

Fixed submission:
a,b = map(int,input().split())
print("Even" if (a*b)%2==0 else "Odd")

Buggy submission (verdict: Runtime Error):
a,b = int(input())
print("Even" if (a*b)%2==0 else "Odd")
Problem p03488 (python)

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

muki = "plus_x"

#info[muki][kaisu]

info=[["plus_x",0]]
count = 0
for i in range(len(s)):
  if s[i]=="F":
    if muki == "plus_x":
      info[0][1] += 1
    else:
      info[count][1] +=1
      
  if s[i] =="T":
    if muki =="plus_x" or muki=="x":
      muki ="y"
      info.append(["y",0])
      count += 1
    elif muki =="y":
      muki ="x"
      info.append(["x",0])
      count += 1
      
#print(info)
x_set=set([info[0][1]])
y_set=set([0])

for i in range(1,count+1):
  if info[i][0]=="x":
    x_set = set(map(lambda x: x+info[i][1], x_set))|set(map(lambda x: x-info[i][1], x_set))
  if info[i][0]=="y":
    y_set = set(map(lambda y: y+info[i][1], y_set))|set(map(lambda y: y-info[i][1], y_set))

if (x in x_set) and (y in y_set):
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
s = input() + "T"
x, y = map(int, input().split())
n = len(s)

tmp = n 
for i in range(n):
    if s[i] == "T":
        tmp = i
        break
    x -= 1
    
up_down = False
cnt = 0
ud =[]
lr = []
for i in range(tmp, n):
    if s[i] == "T":
        if up_down and cnt != 0:
            ud.append(cnt)
        if not up_down and cnt != 0:
            lr.append(cnt)
        cnt = 0
        up_down = not up_down
    else:
        cnt += 1

def is_subset_sum(array, k, x_y):
    if (k + x_y) % 2 != 0:
        return False
    MOD = 10**9 + 1
    n = len(array)

    # dp[i][j] := i番目までを選んだときにsumがjになるかどうか
    dp = [[False] * (k + 1) for i in range(n + 1)]
    dp[0][0] = True

    for i in range(n):
        for j in range(k + 1):
            if j - array[i] < 0:
                dp[i + 1][j] = dp[i][j]
            else:
                dp[i + 1][j] = dp[i][j] or dp[i][j - array[i]]

    return dp[n][abs(k + x_y)//2]


if is_subset_sum(lr, sum(lr), x) and is_subset_sum(ud, sum(ud), y):
    print("Yes")
else:
    print("No")
Problem p03533 (python)

Fixed submission:
s = input()
for i in range(2):
    for j in range(2):
        for k in range(2):
            for l in range(2):
                tmp = "A"[:i] + "KIH" + "A"[:j] + "B" + "A"[:k]+ "R" + "A"[:l]
                if tmp == s:
                    print("YES")
                    exit()
print("NO")

Buggy submission (verdict: Runtime Error):
goal = 'AKIHABARA'
s = input()
if s[-1] != "A":
    s += "A"

i = 0
j = 0
while True:
    if j == len(goal):
        break
    if s[i] == goal[j]:
        i += 1
        j += 1
    elif s[i] != goal[j]:
        j += 1
if i == len(s):
    print("YES")
else:
    print("NO")
Problem p03574 (python)

Fixed submission:
h,w = map(int,input().split())
s =[input() for i in range(h)]


for i in range(h):
  for j in range(w):
    count = 0 
    if s[i][j]==".":
      for k in [[0,1],[1,0],[-1,0],[0,-1],[1,1],[-1,-1],[1,-1],[-1,1]]:
        if 0<=k[0]+i<h and  0<=k[1]+j<w:
          if s[k[0]+i][k[1]+j]=="#":
            count = count +1
      s[i] = s[i][0:j]+str(count)+s[i][j+1:w]
      
for i in range(h):
  for j in range(w):
    print(s[i][j], end="")
  print()

Buggy submission (verdict: Runtime Error):
h,w = map(int,input().split())
s =[input() for i in range(h)]


for i in range(h):
  for j in range(w):
    count = 0 
    if s[i][j]==".":
      for k in [[0,1],[1,0],[-1,0],[0,-1],[1,1],[-1,-1],[1,-1],[-1,1]]:
        if 0<=k[0]+i<h and  0<=k[1]+j<w:
          if s[k[0]+i][k[1]+j]=="#":
            count = count +1
      s[i] = s[i][0:j]+str(count)+s[i][j+1:w]
      
for i in range(h):
  for j in range(w):
    print(s[i][j], end="")
  h,w = map(int,input().split())
s =[input() for i in range(h)]


for i in range(h):
  for j in range(w):
    count = 0 
    if s[i][j]==".":
      for k in [[0,1],[1,0],[-1,0],[0,-1],[1,1],[-1,-1],[1,-1],[-1,1]]:
        if 0<=k[0]+i<h and  0<=k[1]+j<w:
          if s[k[0]+i][k[1]+j]=="#":
            count = count +1
      s[i] = s[i][0:j]+str(count)+s[i][j+1:w]
      
for i in range(h):
  for j in range(w):
    print(s[i][j], end="")
  h,w = map(int,input().split())
s =[input() for i in range(h)]


for i in range(h):
  for j in range(w):
    count = 0 
    if s[i][j]==".":
      for k in [[0,1],[1,0],[-1,0],[0,-1],[1,1],[-1,-1],[1,-1],[-1,1]]:
        if 0<=k[0]+i<h and  0<=k[1]+j<w:
          if s[k[0]+i][k[1]+j]=="#":
            count = count +1
      s[i] = s[i][0:j]+str(count)+s[i][j+1:w]
      
for i in range(h):
  for j in range(w):
    print(s[i][j], end="")
  print()
Problem p03588 (python)

Fixed submission:
from operator import itemgetter


n = int(input())
info = [list(map(int, input().split())) for i in range(n)]

info = sorted(info, key = itemgetter(1))
print(info[0][0] + info[0][1])

Buggy submission (verdict: Runtime Error):
from operator import itemgetter


n = int(input())
info = [list(map(int, input().split())) for i in range(n)]

info = sorted(info, key = itemgetter(1))
print(info[0][0] + info[0][])