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

Fixed submission:
from collections import deque

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

S = []
for i in s: #S[i]=0なら頂点iのラベルは"A"、S[i]=1なら頂点iのラベルは"B"
    if i == "A": S.append(0)
    else: S.append(1)

#R[i]には頂点iと辺でつながっている頂点を入れる
R = [list() for _ in range(N)]
#C[i][0]には頂点iと辺でつながっているラベル"A"の数
#C[i][1]には頂点iと辺でつながっているラベル"B"の数
C = [[0, 0] for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    R[a-1].append(b-1)
    R[b-1].append(a-1)
    C[a-1][S[b-1]] += 1
    C[b-1][S[a-1]] += 1

O = [0] * N #ダメな頂点には1を入れる
q = deque() #調べる頂点の候補リスト
for i in range(N):
    if C[i][0] * C[i][1] == 0: #もし少なくとも"A","B"どちらかに行けないなら
        q.append(i)
        O[i] = 1

while q:
    x = q.popleft()
    for v in R[x]:
        C[v][S[x]] -= 1
        if C[v][S[x]] == 0 and O[v] == 0:
            O[v] = 1
            q.append(v)

if sum(O) == N:
    answer = "No"
else:
    answer = "Yes"

print(answer)

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

N, M = map(int, input().split())
s = [list(input()) for i in range(N)]

S = []
for i in s: #S[i]=0なら頂点iのラベルは"A"、S[i]=1なら頂点iのラベルは"B"
    if i == "A": S.append(0)
    else: S.append(1)

#R[i]には頂点iと辺でつながっている頂点を入れる
R = [list() for _ in range(N)]
#C[i][0]には頂点iと辺でつながっているラベル"A"の数
#C[i][1]には頂点iと辺でつながっているラベル"B"の数
C = [[0, 0] for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    R[a-1].append(b-1)
    R[b-1].append(a-1)
    C[a-1][S[b-1]] += 1
    C[b-1][S[a-1]] += 1

O = [0] * N #ダメな頂点には1を入れる
q = deque() #調べる頂点の候補リスト
for i in range(N):
    if C[i][0] * C[i][1] == 0: #もし少なくとも"A","B"どちらかに行けないなら
        q.append(i)
        O[i] = 1

while q:
    x = q.popleft()
    for v in R[x]:
        C[v][S[x]] -= 1
        if C[v][S[x]] == 0 and O[v] != 0:
            O[v] = 1
            q.append(v)

if sum(O) == N:
    answer = "No"
else:
    answer = "Yes"

print(answer)
Problem p03409 (python)

Fixed submission:
N = int(input())
ab = [[int(i) for i in input().split()] for _ in range(N)]
cd = [[int(i) for i in input().split()] for _ in range(N)]

ab.sort(key = lambda x: x[1], reverse=True)
cd.sort()

x = 0
for c, d in cd:
    for a, b in ab:
        if a < c and b < d:
            x += 1
            ab.remove([a, b])
            break

print(x)

Buggy submission (verdict: Runtime Error):
N = int(input())
ab = [[int(i) for i in input().split()] for _ in range(N)]
cd = [[int(i) for i in input().split()] for _ in range(N)]

ab.sort(key = lambda x: x[1], reverse=True)
cd.sort()

a = 0
for c, d in cd:
    for a, b in ab:
        if a < c and b < d:
            a += 1
            ab.remove([a, b])
            break

print(a)
Problem p03410 (python)

Fixed submission:
import numpy as np
N = int(input())
A = np.array(input().split(), dtype=np.int32)
B = np.array(input().split(), dtype=np.int32)

ans = 0
mod = 1
for k in range(30):
    T = mod
    mod *= 2
    c = 0
    b = np.sort(B % mod)
    a = A % mod
    L1, R1, L2, R2 = (np.searchsorted(b, x - a).sum() for x in (T, 2*T, 3*T, 4*T))
    c += R1 - L1
    c += R2 - L2

    if c % 2:
        ans += T

print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
N = int(input())
A = np.array(input().split())
B = np.array(input().split())

ans = 0
mod = 1
for k in range(30):
    T = mod
    mod *= 2
    c = 0
    b = np.sort(B % mod)
    a = A % mod
    L1, R1, L2, R2 = (np.searchsorted(b, x - a).sum() for x in (T, 2*T, 3*T, 4*T))
    c += R1 - L1
    c += R2 - L2

    if c % 2:
        ans += T

print(ans)
Problem p03416 (python)

Fixed submission:
def f(x):
    l = len(x)
    i = 0
    while x[i] == x[l-i-1]:
        i += 1
        if i > (l//2):
            return True
            break
    return False

A, B = map(int, input().split())
count = 0
for i in range(A, B+1):
    if f(str(i)):
        count += 1
print(count)

Buggy submission (verdict: Runtime Error):
def f(x):
    l = len(x)
    i = 0
    while x[i] == x[l-i-1]:
        i += 1
        if i > (l//2):
            return True
            break
    return False

A, B = map(input().split())
count = 0
for i in range(A, B+1):
    if f(i):
        count += 1
print(count)

Buggy submission (verdict: Runtime Error):
def f(x):
    l = len(x)
    i = 0
    while x[i] == x[l-i-1]:
        i += 1
        if i > (l//2):
            return True
            break
    return False

A, B = map(int, input().split())
count = 0
for i in range(A, B+1):
    if f(i):
        count += 1
print(count)
Problem p03417 (python)

Fixed submission:
N, M = map(int, input().split())

if N==1 and M==1:
    print(1)
elif N==1:
    print(M-2)
elif M==1:
    print(N-2)
elif N==2 or M==2:
    print(0)
else:
    print((N-2)*(M-2))

Buggy submission (verdict: Runtime Error):
def f(x):
    if x == 0:
        return 1
    elif x == 1:
        return 0

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

a = [[0]*(M+2) for _ in range(N+2)]
for i in range(N):
    for j in range(M):
        a[i][j] = f(a[i][j])
        a[i][j+1] = f(a[i][j+1])
        a[i][j+2] = f(a[i][j+2])
        a[i+1][j] = f(a[i+1][j])
        a[i+1][j+1] = f(a[i+1][j+1])
        a[i+1][j+2] = f(a[i+1][j+2])
        a[i+2][j] = f(a[i+2][j])
        a[i+2][j+1] = f(a[i+2][j+1])
        a[i+2][j+2] = f(a[i+2][j+2])
print(sum(a[1:N+1, 1:M+1]))

Buggy submission (verdict: Runtime Error):
def f(x):
    if x == 0:
        return 1
    elif x == 1:
        return 0

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

a = [[0]*(M+2) for _ in range(N+2)]
for i in range(N):
    for j in range(M):
        for k in range(3):
            for l in range(3):
                a[i+k][j+l] = f(a[i+k][j+l])
print(sum(a[1:N+1, 1:M+1]))
Problem p03436 (python)

Fixed submission:
import collections

H, W = map(int, input().split())
s = [list(input()) for i in range(H)]

z = [["b"] * W for _ in range(H)] #チェックしたマスはb(before)からa(after)にする
black = 0
for i in range(H):
    black += s[i].count("#") #最初の黒の数を数える
v = [[1,0], [0,1], [-1,0], [0,-1]] #動き方4パターン(↓ → ↑ ←)
que = collections.deque() #調べる候補リスト #調べ終わった要素は消す

#まず[0,0]
z[0][0] = "a"
s[0][0] = 1 #何歩で来れたかを代入していく #最初は1
que.append([0,0]) #最初の候補は[0,0]

#最短ルートを探す
while len(que) != 0: #候補がなくなるまで繰り返す
    i = que.popleft() #候補のうち1つを取り出し、リストから消す
    for dy, dx in v: #4パターンの動き方を考える
        y = i[0] + dy
        x = i[1] + dx
        if (0<=y<H and 0<=x<W and s[y][x]=="." and z[y][x]=="b"):
            z[y][x] = "a"
            s[y][x] = s[i[0]][i[1]] + 1
            que.append([y,x]) #進んだマスを新しく候補に入れる

if s[-1][-1] == ".": #[H,W]のマスに数字が入ってない→ゴールできない
    print(-1)
else: #「消せる白の最大数」=「全マス」-「黒マス」-「最短ルート」
    print(H*W - black - s[-1][-1])

Buggy submission (verdict: Runtime Error):
import collections

H, W = map(int, input().split())
s = [list(input()) for i in range(H)]

z = [["b"] * W for _ in range(H)] #チェックしたマスはb(before)からa(after)にする
black = 0
for i in range(H):
    black += s[i].count("#") #最初の黒の数を数える
v = [[1,0] [0,1] [-1,0] [0,-1]] #動き方4パターン(↓ → ↑ ←)
que = collections.deque() #調べる候補リスト #調べ終わった要素は消す

#まず[0,0]
z[0][0] = "a"
s[0][0] = 1 #何歩で来れたかを代入していく #最初は1
que.append([0,0]) #最初の候補は[0,0]

#最短ルートを探す
while len(que) != 0: #候補がなくなるまで繰り返す
    i = que.popleft() #候補のうち1つを取り出し、リストから消す
    for dy, dx in v: #4パターンの動き方を考える
        y = i[0] + dy
        x = i[1] + dx
        if (0<=y<H and 0<=x<W and s[y][x]=="." and z[y][x]=="b"):
            z[y][x] == "a"
            s[y][x] == s[i[0]][i[1]] + 1
            que.append([y,x]) #進んだマスを新しく候補に入れる

if s[-1][-1] == ".": #[H,W]のマスに数字が入ってない→ゴールできない
    print(-1)
else: #「消せる白の最大数」=「全マス」-「黒マス」-「最短ルート」
    print(H*W - black - s[-1][-1])
Problem p03449 (python)

Fixed submission:
N = int(input())
A = [[int(i) for i in input().split()] for j in range(2)]
count = 0
Max = 0

for i in range(N):
    for j in range(i+1):
        count += A[0][j]
    for j in range(N-i):
        count += A[1][i+j]
    Max = max(Max, count)
    count = 0

print(Max)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [[int(i) for i in input().split()] for j in range(2)]
count = 0
Max = 0

for i in range(N):
    for j in range(i+1):
        count += A[0][j]
    for j in range(N-i):
        count += A[1][i+j]
    Max = max(Max, count
    count = 0

print(Max)
Problem p03471 (python)

Fixed submission:
N, Y = map(int, input().split())

c =False
for i in range(N+1):
    for j in range(N+1-i):
        if Y == 10000*i + 5000*j + 1000*(N-i-j):
            a = [str(i), str(j), str(N-i-j)]
            print(" ".join(a))
            c = True
            break
    if c:
        break
if not c:
    print("-1 -1 -1")

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

m1 = Y // 10000
m2 = Y % 10000
if m1 > N:
    print("-1 -1 -1")
elif m1 == N and m2 > 0:
    print("-1 -1 -1")
else:
    c =False
    for i in range(m1+1):
        if Y - 10000*i > 5000*(N-i):
            pass
        else:
            for j in range(N+1-i):
                if Y == 10000*i + 5000*j + 1000*(N-i-j):
                    a = [str(i), str(j), str(N-i-j)]
                    print(" ".join(a))
                    c = True
                    break
        if c:
            break
if not c:
    print("-1 -1 -1")
Problem p03480 (python)

Fixed submission:
S = input()

n = len(S)
a = n
for i in range(n-1):
    if S[i] != S[i+1]:
        a = min(a, max(i+1, n-i-1))

print(a)

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

a = n
n = len(S)
for i in range(n-1):
    if S[i] != S[i+1]:
        a = min(a, max(i+1, n-i+1))

print(a)
Problem p03503 (python)

Fixed submission:
N = int(input())
F = [[int(i) for i in input().split()] for j in range(N)]
P = [[int(i) for i in input().split()] for j in range(N)]

ci = 0
c = []
P_max = -1000000000
for i in range(2):
    for j in range(2):
        for k in range(2):
            for l in range(2):
                for m in range(2):
                    for n in range(2):
                        for o in range(2):
                            for p in range(2):
                                for q in range(2):
                                    for r in range(2):
                                        if i==0 and j==0 and k==0 and l==0 and m==0 and n==0 and o==0 and p==0 and q==0:
                                            r = 1
                                        P_sample = 0
                                        for s in range(N):
                                            ci = F[s][0]*i + F[s][1]*j + F[s][2]*k + F[s][3]*l + F[s][4]*m + F[s][5]*n + F[s][6]*o + F[s][7]*p + F[s][8]*q + F[s][9]*r
                                            P_sample += P[s][ci]
                                        P_max = max(P_max, P_sample)

print(P_max)

Buggy submission (verdict: Runtime Error):
N = int(input())
F = [[int(i) for i in input().split()] for j in range(N)]
P = [[int(i) for i in input().split()] for j in range(N)]

ci = 0
c = []
P_max = -1000000000
for i in range(2):
    for j in range(2):
        for k in range(2):
            for l in range(2):
                for m in range(2):
                    for n in range(2):
                        for o in range(2):
                            for p in range(2):
                                for q in range(2):
                                    for r in range(2):
                                        if i==j==k==l==m==n==o==p==q==r==0:
                                            pass
                                        for s in range(N):
                                            ci = F[s][0]*i + F[s][1]*j + F[s][2]*k + F[s][3]*l + F[s][4]*m + F[s][5]*n + F[s][6]*o + F[s][7]*p + F[s][8]*q + F[s][9]*r
                                            c.append(ci)
                                        P_sample = P[0][c[0]] + P[1][c[1]] + P[2][c[2]] + P[3][c[3]] + P[4][c[4]] + P[5][c[5]] + P[6][c[6]] + P[7][c[7]] + P[8][c[8]] + P[9][c[9]]
                                        P_max = max(P_max, P_sample)

print(P_max)
Problem p03599 (python)

Fixed submission:
from math import gcd

A, B, C, D, E, F = map(int, input().split())

N = 0; max_SW = A*100; max_S = 0
f = F//100; a = f//A; b = f//B
cn = D // gcd(C, D)

for j in range(b+1): #Bをj杯入れる
    for i in range(a+1): #Aをi杯入れる
        if i==0 and j==0:
            continue
        elif A*i + B*j > f:
            continue
        w = (A*i + B*j) * 100 #水の量
        e = (A*i + B*j) * E #この場合において溶ける砂糖の最大値
        S = min(e, F-w) #ビーカーも考慮した砂糖を入れられる限界
        s = 0
        for ci in range(min(S//C, cn)+1):
            s = max(s, S - (S - C*ci) % D)
        if s/(w+s) > N:
            N = s/(w+s)
            max_SW = s + w
            max_S = s

print(max_SW, max_S)

Buggy submission (verdict: Runtime Error):
from math import gcd

A, B, C, D, E, F = map(int, input().split())

N = 0
f = F//100; a = f//A; b = f//B
cn = D // gcd(C, D)

for j in range(b+1): #Bをj杯入れる
    for i in range(a+1): #Aをi杯入れる
        if i==0 and j==0:
            continue
        elif A*i + B*j > f:
            continue
        w = (A*i + B*j) * 100 #水の量
        e = (A*i + B*j) * E #この場合において溶ける砂糖の最大値
        S = min(e, F-w) #ビーカーも考慮した砂糖を入れられる限界
        s = 0
        for ci in range(min(S//C, cn)+1):
            s = max(s, S - (S - C*ci) % D)
        if s/(w+s) > N:
            N = s/(w+s)
            max_SW = s + w
            max_S = s

print(max_SW, max_S)
Problem p03600 (python)

Fixed submission:
from numpy import *
N = int(input())
A = array([list(map(int,input().split())) for n in range(N)])

fill_diagonal(A, 10**10)

ans = 0
for i in range(N):
  for j in range(i+1,N):
    d = min(A[i]+A[j])
    if A[i][j] < d:
      ans += A[i][j]
    elif d < A[i][j]:
      print(-1)
      exit()

print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
N = int(input())
A = np.array([input().split() for _ in range(N)], dtype=np.int64)

fill_diagonal(A, 10**9)

ans = 0
for i in range(N):
  for j in range(i+1,N):
    d = np.min(A[i]+A[j])
    if A[i][j] < d:
      ans += A[i][j]
    elif d < A[i][j]:
      print(-1)
      exit()

print(ans)
Problem p03610 (python)

Fixed submission:
s = input()

oddstring = s[0]
a = ((len(s) + 1) // 2) - 1

if a > 0:
    for i in range(a):
        oddstring += s[2*i+2]

print(oddstring)

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

oddstring = s[0]
a = (len(s) + 1) // 2

for i in renge(a-1)}:
    oddstring += s[2*i+2]

print(oddstring)
Problem p03626 (python)

Fixed submission:
N = int(input())
S1 = list(input())
S2 = list(input())

if len(S1) == 1:
    print(3)
elif len(S1) == 2:
    print(6)
else:
    if S1[0] != S2[0]:
        t = 2
        i = 2
        a = 6
    else:
        t = 1
        i = 1
        a = 3
    while True:
        if S1[i] != S2[i]:
            if t == 2:
                a *= 3
            else:
                a *= 2
            i += 2
            t = 2
        else:
            if t == 2:
                a *= 1
            else:
                a *= 2
            i += 1
            t = 1
        a %= 1000000007
        if i == len(S1):
            print(a)
            break

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

if len(S1) == 1:
    print(3)
else:
    if S1[0] != S2[0]:
        t = 2
        i = 2
        a = 6
    else:
        t = 1
        i = 1
        a = 3
    while True:
        if S1[i] != S2[i]:
            if t == 2:
                a *= 3
            else:
                a *= 2
            i += 2
            t = 2
        else:
            if t == 2:
                a *= 1
            else:
                a *= 2
            i += 1
            t = 1
        a %= 1000000007
        if i == len(S1):
            print(a)
            break
Problem p03659 (python)

Fixed submission:
N = int(input())
a = [int(i) for i in input().split()]
sum_a = sum(a)
b = []
c = 0
for i in range(N-1):
    c += a[i]
    b.append(abs(2*c-sum_a))
print(min(b))

Buggy submission (verdict: Runtime Error):
N = int(input())
a = [int(i) for i in input().split()]
sum_a = sum(a)
b = []
c = 0
for i in range(N-1):
    c += a[i]
    b.append(abs(2*b-sum_a))
print(min(b))
Problem p03660 (python)

Fixed submission:
import collections

N = int(input())
tree = [[] for _ in range(N)] #i行目には、i番目のマスと隣り合っているマスの番号が加えられる
for _ in range(N-1):
    a, b = map(int, input().split())
    tree[a-1].append(b-1)
    tree[b-1].append(a-1)

color = [0] * N #色が塗られていなければ0、黒は1、白は-1
color[0] = 1
color[N-1] = -1
que = collections.deque() #色が塗られたマスの番号を、隣り合うマスが全て塗られるまでここに入れる
que.append(0)
que.append(N-1)
while que: #塗るべきマスがなくなるまで繰り返す
    i = que.popleft() #「左から」が重要 #n回でたどり着けるマスはn回目に全て塗って良い
    for x in tree[i]:
        if color[x] == 0:
            color[x] = color[i]
            que.append(x) #塗ったマスは調べるリストに入れる

if sum(color) > 0: #合計が正、つまり黒が多い場合は先手の勝ち
    print("Fennec")
else: #合計が0でも先手の塗るマスがないため後手の勝ち
    print("Snuke")

Buggy submission (verdict: Runtime Error):
import collections

N = int(input())
tree = [[] for _ in range(N)] #i行目には、i番目のマスと隣り合っているマスの番号が加えられる
for _ in range(N-1):
    a, b = map(int, input().split())
    tree[a-1].append(b-1)
    tree[b-1].append(a-1)

color = [0] * N #色が塗られていなければ0、黒は1、白は-1
color[0] = 1
color[N-1] = -1
que = collections.depue() #色が塗られたマスの番号を、隣り合うマスが全て塗られるまでここに入れる
que.append(0)
que.append(N-1)
while que: #塗るべきマスがなくなるまで繰り返す
    i = que.popleft() #「左から」が重要 #n回でたどり着けるマスはn回目に全て塗って良い
    for x in tree[i]:
        if color[x] == 0:
            color[x] = color[i]
            que.append(x) #塗ったマスは調べるリストに入れる

if sum(color) > 0: #合計が正、つまり黒が多い場合は先手の勝ち
    print("Fennec")
else: #合計が0でも先手の塗るマスがないため後手の勝ち
    print("Snuke")
Problem p03722 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**7)

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

R = [[] for _ in range(N)]
for _ in range(M):
    a, b, c = map(int, input().split())
    R[a - 1].append((b - 1, c))

INF = 10 ** 40
S = [-INF] * N
S[0] = 0

def score(fst, s, C):
    for nx, p in R[fst]:
        if S[nx] >= s + p or S[nx] >= INF:
            continue
        S[nx] = s + p
        if nx in C:
            S[nx] = INF
        C[nx] = C.get(nx, 0) + 1
        score(nx, S[nx], C)
        C[nx] -= 1
        if C[nx] == 0:
            del C[nx]

score(0, 0, {0: 1})

if S[-1] < INF:
    ans = S[-1]
else:
    ans = "inf"

print(ans)

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

R = [[] for _ in range(N)]
for _ in range(M):
    a, b, c = map(int, input().split())
    R[a - 1].append((b - 1, c))

INF = 10 ** 40
S = [-INF] * N
S[0] = 0

def score(fst, s, C):
    for nx, p in R[fst]:
        if S[nx] >= s + p or S[nx] >= INF:
            continue
        S[nx] = s + p
        if nx in C:
            S[nx] = INF
        C[nx] = C.get(nx, 0) + 1
        score(nx, S[nx], C)
        C[nx] -= 1
        if C[nx] == 0:
            del C[nx]

score(0, 0, {0: 1})

if S[-1] < INF:
    ans = S[-1]
else:
    ans = "inf"

print(ans)
Problem p03854 (python)

Fixed submission:
S = list(input())
N = len(S)

def f(x):
    print(x)
    exit()

if N < 5:
    f("NO")
elif S[0] == "d":
    w = 1
elif S[0] == "e":
    w = -1
else:
    f("NO")

i = 0
while True:
    if w > 0:
        if S[i]+S[i+1]+S[i+2]+S[i+3]+S[i+4] == "dream":
            i += 5
            if i == N:
                f("YES")
            elif S[i] == "d":
                pass
            elif S[i] == "e":
                if i+1 <= N-1:
                    if S[i+1] == "r":
                        if i+1 == N-1:
                            f("YES")
                        elif S[i+2] == "a":
                            w *= -1
                        elif S[i+2] == "e":
                            i += 2
                            w *= -1
                        elif S[i+2] == "d":
                            i += 2
                        else:
                            f("NO")
                    else:
                        f("NO")
                else:
                    f("NO")
            else:
                f("NO")
        else:
            f("NO")
    elif w < 0:
        if S[i]+S[i+1]+S[i+2]+S[i+3]+S[i+4] == "erase":
            i += 5
            if i == N:
                f("YES")
            if S[i] == "r":
                i += 1
                if i == N:
                    f("YES")
            if S[i] == "d":
                w *= -1
            elif S[i] == "e":
                pass
            else:
                f("NO")
        else:
            f("NO")
    if i+4 > N-1:
        f("NO")

Buggy submission (verdict: Runtime Error):
S = list(input())
N = len(S)

def f(x):
    print(x)
    exit()

if N < 5:
    f("NO")
elif S[0] == "d":
    w = 1
elif S[0] == "e":
    w = -1
else:
    f("NO")

i = 0
while True:
    if w > 0:
        if S[i]+S[i+1]+S[i+2]+S[i+3]+S[i+4] == "dream":
            i += 5
            if i == N:
                f("YES")
            elif S[i] == "d":
                pass
            elif S[i] == "e":
                if i+1 <= N-1:
                    if S[i+1] == "r":
                        if i+1 == N-1:
                            f("YES")
                        elif S[i+2] == "a":
                            w *= -1
                        elif S[i+2] == "e":
                            i += 2
                            w *= -1
                        elif S[i+2] == "d":
                            i += 2
                        else:
                            f("NO")
                    else:
                        f("NO")
                else:
                    f("NO")
            else:
                f("NO")
        else:
            f("NO")
    elif w < 0:
        if S[i]+S[i+1]+S[i+2]+S[i+3]+S[i+4] == "erase":
            i += 5
            if i == N:
            if S[i] == "r":
                i += 1
                if i == N:
            if S[i] == "d":
                w *= -1
            elif S[i] == "e":
                pass
            else:
                f("NO")
        else:
            f("NO")
    if i+4 > N-1:
        f("NO")
Problem p04044 (python)

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

s.sort()
S = ""
for i in s:
    S += i
print(S)

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

s.sort()
S = ""
for i in s:
    S += i
print(S)
Problem p04045 (python)

Fixed submission:
N, K = map(int, input().split())
D = list(input().split())

for i in range(N, 100000):
    for j in D:
        if j in str(i):
            break
    else:
        print(i)
        break

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
l = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]
for _ in range(K):
    l.remove(int(input()))
n = [int(x) for x in str(N)]
c = len(n)

max = l[0]
min = l[-1]
if N > 1111 * max:
    b = 10000*min([i for i in l if i>0]) + 1111*min
else:
    a = [max] * c
    for j in range(c):
        if a[j] > n[j]:
            a[j] = min([i for i in l if i>=n[j]])
    b = ""
    for j in range(c):
        b += str(a[j])
    b = int(b)

print(b)
Problem p03220 (python)

Fixed submission:
N = int(input())
T, A = map(int, input().split())
Hs = [int(H) for H in input().split()]
min_diff = 10e9
ans = 0
for i, H in enumerate(Hs):
    T_at_H = T - H*0.006
    diff = abs(A - T_at_H)
    if diff < min_diff:
        min_diff = diff
        ans = i + 1
print(ans)

Buggy submission (verdict: Runtime Error):
import math
N = int(input())
T, A = map(int, input().split())
Hs = [int(H) for H in input().split()]
min_diff = math.inf
ans = 0
for i, H in enumerate(Hs):
    T_at_H = T - H*0.006
    diff = abs(A - T_at_H)
    if diff < min_diff:
        min_diff = diff
        ans = i + 1
print(ans)
Problem p03369 (python)

Fixed submission:
orders = input()
price = 700
for order in orders:
  if order == "o":
    price += 100
print(price)

Buggy submission (verdict: Runtime Error):
orders = input()
price = 700
if order in orders:
  if order == "x":
    price += 100
print(price)