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

Fixed submission:
import sys
input = sys.stdin.readline

NUM = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
INF = 10**14

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

dp = [-INF]*(N+1)
dp[0] = 0
for i in range(N):
    for a in A:
        c = NUM[a]
        if i + c <= N:
            dp[i+c] = max(dp[i+c], dp[i]+1)

D = dp[N]
ind = N
ans = ''
for _ in range(D):
    for a in A:
        c = NUM[a]
        if ind - c < 0: continue
        if dp[ind] == dp[ind-c] + 1:
            ind -= c
            ans += str(a)
            break
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

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

COUNT = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]

dic = {}
for a in A:
    dic[COUNT[a]] = a

C = sorted(dic.keys(), key=lambda x: -dic[x])
min_c = min(C)
C.remove(min_c)
#print(C)

def dfs(remain, l, now, L):
    #print(remain, l, now)
    if remain == 0:
        L.append(now)
        return L
    if l == len(C):
        return L
    loop = remain//(C[l]-min_c)
    for h in reversed(range(loop+1)):
        L = dfs(remain-(C[l]-min_c)*h, l+1, now+[dic[C[l]]]*h, L)
    return L


k = 0
while True:
    r = N%min_c + k*min_c
    p = N//min_c - k
    if r == 0:
        ans = {dic[min_c]: p}
        break
    L = dfs(r, 0, [], [])
    #print(L)
    ans = []
    for now in L:
        l = len(now)
        if l > p: continue
        P = sorted(now+[dic[min_c]]*(p-l), reverse=True)
        #print(P)
        if not ans:
            ans = P
            continue
        ok = True
        for i in range(p):
            if P[i] < ans[i]:
                ok = False
                break
            elif P[i] > ans[i]:
                ok = True
                break
        if ok:
            ans = P

    if ans: break
    k += 1

ans.sort(reverse=True)
print("".join([str(a) for a in ans]))

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

seg = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]

B = {}
for a in A:
    ind = seg[a]
    if not ind in B.keys():
        B[ind] = a
    else:
        if B[ind] < a:
            B[ind] = a

I = sorted(list(B.keys()))
#print(I)
def search(ind, remain, ret):
    if ind >= len(I):
        return False, ret
    #print(I[ind], remain, ret)
    a = I[ind]
    p = remain // a
    r = remain % a 
    if p == 0:
        return False, ret
    if r == 0:
        ret.append((a, p))
        return True, ret
    for q in range(p-1, -1, -1):
        r += a
        oldr = ret[:]
        ok, newr = search(ind+1, r, oldr)
        if ok:
            newr.append((a, q))
            if ind == 0:
                Ap.append(newr)
                continue
            return True, newr
    if ind == 0:
        return Ap
    return False, ret

Ap = []
Ls = search(0, N, [])
#print(Ls)
anss = []
for L in Ls:
    Q = []
    for k, v in L:
        Q.extend([B[k]]*v)
    Q.sort(reverse=True)
    num = int(''.join([str(q) for q in Q]))
    anss.append(num)

print(max(anss))
Problem p03214 (python)

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

S = sum(A)
d = 10**14
for i, a in enumerate(A):
  if abs(a*n-S) < d:
    d = abs(a*n-S)
    ind = i
    
print(ind)

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

S = sum(A)
d = 10**14
for i, a in enumerate(A):
  if abs(a*N-S) < d:
    d = abs(a*N-S)
    ind = i
    
print(ind)
Problem p03240 (python)

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

for cx in range(101):
    for cy in range(101):
        H = -1
        ok = True
        for x, y, h in P:
            if h == 0:
                continue
            Hi = abs(x-cx) + abs(y-cy) + h
            if H == -1:
                H = Hi
                continue
            if Hi != H:
                ok = False
                break
        if not ok:
            continue
        for x, y, h in P:
            if h != max(H-abs(cx-x)-abs(cy-y), 0):
                ok = False
        if ok:
            print(cx, cy, H)
            break
    if ok:
        break

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

for x in range(101):
    for y in range(101):
        check = []
        for d in xyh:
            ifd0 = False
            if d[2] == 0:
                ifd0 = True
            ch = abs(d[0] - x) + abs(d[1] - y) + d[2]
            check.append([ch, ifd0])
        ifans = True
        for c in check:
            if c[0] - check[0][0] != 0:
                if ifd0:
                    continue
                ifans = False
                break
        if ifans:
            ans = [x, y, ch]
            break

print(' '.join([str(a) for a in ans]))

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

ans = []
c = 0
for x in range(101):
    for y in range(101):
        for i, d in enumerate(xyh):
            if d[2] == 0:
                continue
            ch = abs(d[0] - x) + abs(d[1] - y) + d[2]
            if i == 0:
                chpre = ch
            if chpre != ch:
                break
        if chpre == ch:
            ans = [x, y, ch]
            break
    if ans:
        break

print(' '.join([str(a) for a in ans]))
Problem p03351 (python)

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

if abs(c-a) <= d or (abs(b-a) <= d and abs(c-b) <= d):
    print('Yes')
else:
    print('No')

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

S1 = {}
for i, s in enumerate(S):
    if not s in S1.keys():
        S1[s] = [i]
    else:
        S1[s].append(i)
alp = sorted(list(S1.keys()))

c = 0
for a in alp:
    aset = set()
    inds = S1[a]
    for d in inds:
        for i in range(N-d+1):
            aset.add(S[d:d+i])
    if len(aset)-1 >= K-c:
        break
    c += len(aset)-1


for _ in range(5):
    for i, a in enumerate(aset):
        if i == 0:
            min = a
            continue
        if a < min:
            min = a
    aset.discard(min)
    if min == '':
        continue
    c += 1
    if c >= K:
        ans = min
        break

print(ans)
Problem p03353 (python)

Fixed submission:
def main():
    S = input()
    N = len(S)
    K = int(input())

    S1 = {}
    for i, s in enumerate(S):
        if not s in S1.keys():
            S1[s] = [i]
        else:
            S1[s].append(i)
    alp = sorted(list(S1.keys()))

    c = 0
    for a in alp:
        aset = set()
        inds = S1[a]
        for d in inds:
            up = min(N-d+1, K+1)
            for i in range(up):
                aset.add(S[d:d+i])
        L = len(aset)-1
        if L >= K-c:
            break
        c += L

    for _ in range(10):
        M = '何だこれはもうやめてくれよ'
        for a in aset:
            if a < M:
                M = a
        aset.discard(M)
        if M == '':
            continue
        c += 1
        if c >= K:
            ans = M
            break

    print(ans)



if __name__=='__main__':
    main()

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

S1 = {}
for i, s in enumerate(S):
    if not s in S1.keys():
        S1[s] = [i]
    else:
        S1[s].append(i)
alp = sorted(list(S1.keys()))

c = 0
for a in alp:
    aset = set()
    inds = S1[a]
    for d in inds:
        for i in range(N-d+1):
            aset.add(S[d:d+i])
    if len(aset)-1 >= K-c:
        break
    c += len(aset)-1


for _ in range(5):
    for i, a in enumerate(aset):
        if i == 0:
            min = a
            continue
        if a < min:
            min = a
    aset.discard(min)
    if min == '':
        continue
    c += 1
    if c >= K:
        ans = min
        break

print(ans)

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

S1 = {}
for i, s in enumerate(S):
    if not s in S1.keys():
        S1[s] = [i]
    else:
        S1[s].append(i)
alp = sorted(list(S1.keys()))

c = 0
for a in alp:
    aset = set()
    inds = S1[a]
    for d in inds:
        for i in range(N-d+1):
            aset.add(S[d:d+i])
    if len(aset)-1 > K-c:
        break
    c += len(aset)-1


alist = sorted(list(aset))
for al in alist:
    if al == '':
        continue
    c += 1
    if c == K:
        ans = al
        break

print(ans)
Problem p03361 (python)

Fixed submission:
H, W = map(int, input().split())
state = [[1 if a == '#' else 0 for a in list(input()+'.')] for _ in range(H)]
state.extend([[0]*(W+1)])


ans = 'Yes'
for h in range(H):
    for w in range(W):
        if state[h][w] == 0:
            continue
        nexts = [[h+1, w], [h-1, w], [h, w+1], [h, w-1]]
        ok = False
        for n in nexts:
            if state[n[0]][n[1]] == 1:
                ok = True
        if not ok:
            ans = 'No'
            break
    if ans == 'No':
        break

print(ans)

Buggy submission (verdict: Runtime Error):
H, W = map(int, input().split())
state = [[1 if a == '#' else 0 for a in list(input()+'.')] for _ in range(H)]
state.extend([[0]*(W+1)])

ans = 'Yes'
for h in range(H):
    for w in range(W):
        if state[h][w] == 0:
            continue
        nexts = [[h+1, w], [h-1, w], [h, w+1], [h, w-1]]
        ok = False
        for n in nexts:
            if state[n[0]][n[1]] == 1:
                ok = True
        if not ok:
            ans = 'No'
            break
    if not ok:
        break

print(ans)
Problem p03393 (python)

Fixed submission:
import string

S = input()

abc = [chr(i) for i in range(97, 97+26)]

if len(S) < 26:
    for s in S:
        abc.remove(s)
    add = abc[0]
    print(S + add)
elif S == ''.join(sorted(abc, reverse=True)):
    print(-1)
else:
    N = len(S)
    for i in range(1, N):
        now = S[N-i-1]
        fow = S[N-i:]
        fows = sorted(list(fow))
        for f in fows:
            if now < f:
                now = f
                break
        if now != S[N-i-1]:
            ans = S[:N-i-1] + now
            break
    print(ans)

Buggy submission (verdict: Runtime Error):
import string

S = input()

abc = [chr(i) for i in range(97, 97+26)]

if len(S) < 26:
    for s in S:
        abc.remove(s)
    add = abc[0]
    print('wahaha')
    print(S + add)
elif S == ''.join(sorted(abc, reverse=True)):
    print(-1)
else:
    N = len(S)
    for i in range(1, N):
        now = S[N-i]
        fow = S[N-i+1:]
        fows = sorted(list(fow))
        for f in fows:
            if now < f:
                now = f
                break
        if now != S[N-i]:
            ans = S[:N-i] + now
            break
    print(ans)

Buggy submission (verdict: Runtime Error):
import string

S = input()

abc = [chr(i) for i in range(97, 97+26)]

if len(S) < 26:
    for s in S:
        abc.remove(s)
    add = abc[0]
    print(S + add)
elif S == ''.join(sorted(abc, reverse=True)):
    print(-1)
else:
    N = len(S)
    for i in range(1, N):
        now = S[N-i]
        fow = S[N-i+1:]
        fows = sorted(list(fow))
        for f in fows:
            if now < f:
                now = f
                break
        if now != S[N-i]:
            ans = S[:N-i] + now
            break
    print(ans)
Problem p03479 (python)

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

for i in range(300):
    if X * 2**i > Y:
        ans = i
        break
print(ans)

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

for i in range(60):
    if X * 2**i > Y:
        ans = i
        break
print(ans)
Problem p03498 (python)

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

mina = 10**10
maxa = -10**10
for i, a in enumerate(A):
    if a < mina:
        l = i+1
        mina = a
    if a > maxa:
        r = i+1
        maxa = a


if maxa <= 0:
    print(N-1)
    for n in range(N, 1, -1):
        print(n, n-1)
elif mina >= 0:
    print(N-1)
    for n in range(1, N):
        print(n, n+1)
else:
    print(2*N-1)
    if abs(maxa) > abs(mina):
        for i in range(1, N+1):
            print(r, i)
        for n in range(1, N):
            print(n, n+1)
    else:
        for i in range(N, 0, -1):
            print(l, i)
        for n in range(N, 1, -1):
            print(n, n-1)

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

for l in range(N+1):
    B = A[:]
    ok = True
    ans = []
    if l < N:
        if A[l] <= 0:
            ok = False
        for r in range(l, N-1):
            a, b = B[r], B[r+1]
            if a <= b:
                count = 0
            else:
                count = (a-b)//a
                if b%a != 0: count += 1
            B[r+1] += a*count
            if count > 2:
                ok = False
                break
            ans += [(r+1, r+2)]*count
    
    while l > 0:
        if A[l-1] != 0:
            break
        l -= 1
    
    if l > 0:
        if A[l-1] >= 0:
            ok = False
        for r in range(l-1, 0, -1):
            a, b = B[r], B[r-1]
            if b <= a:
                count = 0
            else:
                count = (a-b)//a
                if b%a != 0: count += 1
            B[r-1] += a*count
            if count > 2:
                ok = False
                break
            ans += [(r+1, r)]*count
    if ok:
        print(len(ans))
        for a, b in ans:
            print(a, b)
Problem p03503 (python)

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

def dfs(i, A, ans):
    if i == 10:
        ans.append(A)
        return ans
    B = A[:]
    B.append(0)
    ans = dfs(i+1, B, ans)
    C = A[:]
    C.append(1)
    ans = dfs(i+1, C, ans)
    return ans

def main():
    D = dfs(0, [], [])
    for ind, A in enumerate(D):
        if ind == 0:
            continue
        gain = 0
        for i in range(N):
            c = 0
            for day in range(10):
                c += F[i][day]*A[day]
            gain += P[i][c]
        if ind == 1:
            ans = gain
            continue
        ans = max(ans, gain)

    print(ans)

if __name__ == "__main__":
    main()

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

def dfs(i, A, ans):
    if i == 10:
        ans.append(A)
        return ans
    B = A[:]
    B.append(0)
    ans = dfs(i+1, B, ans)
    C = A[:]
    C.append(1)
    ans = dfs(i+1, C, ans)
    return ans

def main()
    D = dfs(0, [], [])
    for ind, A in enumerate(D):
        if ind == 0:
            continue
        gain = 0
        for i in range(N):
            c = 0
            for day in range(10):
                c += F[i][day]*A[day]
            gain += P[i][c]
        if ind == 1:
            ans = gain
            continue
        ans = max(ans, gain)

    print(ans)

if __name__ == "__main__":
    main()
Problem p03533 (python)

Fixed submission:
S = input()

K = ['A', 'K', 'I', 'H', 'B', 'R']

ans = 'YES'
p = 0
cont = False
for s in S:
    if not s in K:
        ans = 'NO'
    elif s == 'A':
        if (p == 0 or p == 3 or p == 4 or p == 5) and not cont:
            cont = True
        else:
            ans = 'NO'
    elif p == 5:
        ans = 'NO'
        break
    elif s == K[p+1]:
        p += 1
        cont = False
    else:
        ans = 'NO'
if p != 5:
    ans = 'NO'
print(ans)

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

K = ['A', 'K', 'I', 'H', 'B', 'R']

ans = 'YES'
p = 0
cont = False
for s in S:
    if not s in K:
        ans = 'NO'
    elif s == 'A':
        if (p == 0 or p == 3 or p == 4 or p == 5) and not cont:
            cont = True
        else:
            ans = 'NO'
    elif s == K[p+1]:
        p += 1
        cont = False
    else:
        ans = 'NO'
if p != 5:
    ans = 'NO'
print(ans)
Problem p03651 (python)

Fixed submission:
N, K = map(int, input().split()) # 横に2個
A = list(map(int, input().split()))

A.sort(reverse=True)

dif = []
for i in range(N-1):
    d = A[i] - A[i+1]
    if d != 0:
        dif.append(d)
if dif:
    mind = min(dif)
else:
    mind = A[0]

ans = 'IMPOSSIBLE'
for a in A:
    if a < K:
        break
    if a == K:
        ans = 'POSSIBLE'
        break
    if (a-K) % mind == 0:
        ans = 'POSSIBLE'
        break

print(ans)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split()) # 横に2個
A = list(map(int, input().split()))

A.sort(reverse=True)

dif = []
for i in range(N-1):
    d = A[i] - A[i+1]
    if d != 0:
        dif.append(d)
mind = min(dif)

ans = 'IMPOSSIBLE'
for a in A:
    if a < K:
        break
    if a == K:
        ans = 'POSSIBLE'
        break
    if (a-K) % mind == 0:
        ans = 'POSSIBLE'
        break

print(ans)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split()) # 横に2個
A = list(map(int, input().split()))

A.sort(reverse=True)

dif = []
for i in range(N-1):
    dif.append(A[i] - A[i+1])
mind = min(dif)

ans = 'IMPOSSIBLE'
for a in A:
    if a < K:
        break
    if a == K:
        ans = 'POSSIBLE'
        break
    if (a-K) % mind == 0:
        ans = 'POSSIBLE'
        break

print(ans)
Problem p03660 (python)

Fixed submission:
import sys
sys.setrecursionlimit(600000)

N = int(input())

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

def dfs(p, checked, now):
    #print(p, checked, now)
    if p == N-1:
        return now, True
    ok = False
    for q in graph[p]:
        if not checked[q]:
            now.append(q)
            checked[q] = True
            nbw, ok1 = dfs(q, checked, now)
            if ok1:
                bw = nbw
                ok = True
    if not ok:
        now.pop()
        return now, False
    return bw, True

checked = [False for _ in range(N)]
checked[0] = True
bw, ok = dfs(0, checked, [0])
#print(bw)

between = [0 for _ in range(N)]
k = len(bw)
if k % 2 == 0:
    s0 = bw[k//2-1]
    sN = bw[k//2]
else:
    s0 = bw[k//2]
    sN = bw[k//2+1]
between[s0] = True
between[sN] = True

def dfs2(p, checked, c):
    c += 1
    for q in graph[p]:
        if not checked[q]:
            checked[q] = True
            c = dfs2(q, checked, c)
    return c

c0 = dfs2(s0, between, 0)
cN = dfs2(sN, between, 0)
#print(c0, cN)



if cN < c0:
    print('Fennec')
else:
    print('Snuke')

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

N = int(input())

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

def dfs(p, checked, now):
    #print(p, checked, now)
    if p == N-1:
        return now, True
    ok = False
    for q in graph[p]:
        if not checked[q]:
            now.append(q)
            checked[q] = True
            bw, ok = dfs(q, checked, now)
    if not ok:
        now.pop()
        return now, False
    return bw, True

checked = [False for _ in range(N)]
checked[0] = True
bw, ok = dfs(0, checked, [0])
#print(bw)
cb = len(bw) - 2

between = [False for _ in range(N)]
for b in bw:
    between[b] = True

def dfs2(p, checked, c):
    c += 1
    for q in graph[p]:
        if not checked[q]:
            checked[q] = True
            c = dfs2(q, checked, c)
    return c

c0 = dfs2(0, between, 0)-1
cN = dfs2(N-1, between, 0)-1
#print(c0, cN)

if cb % 2 == 0:
    c0 += cb//2
    cN += cb//2
else:
    c0 += cb//2+1
    cN += cb//2

if cN < c0:
    print('Fennec')
else:
    print('Snuke')
Problem p03680 (python)

Fixed submission:
N = int(input())
A = [int(input()) for _ in range(N)]

c = 0
n = 1
checked = [False for _ in range(N)]
checked[0] = True
for _ in range(N+1):
    n = A[n-1]
    c += 1
    if n == 2:
        ok = True
        break
    if checked[n-1]:
        ok = False
        break
    checked[n-1] = True
if ok:
    print(c)
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(input()) for _ in range(N)]

c = 0
n = 1
checked = [False for _ in range(N)]
checked[0] = True
for _ in range(N+1):
    n = A[n-1]
    c += 1
    if n == 2:
        ok = True
        break
    if checked[n-1]:
        ok = False
        break
if ok:
    print(c)
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(input()) for _ in range(N)]

c = 0
n = 1
for _ in range(N+1):
    n = A[n-1]
    c += 1
    if n == 1:
        ok = False
        break
    if n == 2:
        ok = True
        break
if ok:
    print(c)
else:
    print(-1)
Problem p03702 (python)

Fixed submission:
N, A, B = map(int, input().split())
H = [int(input()) for _ in range(N)]

l = 0
r = max(H)
T = 1
while r > l+1:
    T = (l+r)//2
    c = 0
    for h in H:
        if h > B*T:
            c += (h-B*T)//(A-B)
            if (h-B*T)%(A-B) != 0:
                c += 1
    if c <= T:
        r = T
    else:
        l = T

if l == T:
    print(T+1)
else:
    print(T)

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

l = 0
r = max(H)

while r > l+1:
    T = (l+r)//2
    c = 0
    for h in H:
        if h > B*T:
            c += (h-B*T)//(A-B)
            if (h-B*T)%(A-B) != 0:
                c += 1
    if c <= T:
        r = T
    else:
        l = T

if l == T:
    print(T+1)
else:
    print(T)
Problem p03739 (python)

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

def count(s):
    ans = 0
    for i, a in enumerate(A):
        if i == 0:
            continue
        if s < 0:
            if 1-s-a >= 0:
                ans += 1-s-a
                s = 1
            else:
                s += a
        elif s > 0:
            if s+a+1 >= 0:
                ans += s+a+1
                s = -1
            else:
                s += a
    return ans

b = A[0]
ans1 = count(b)
if b > 0:
    ans2 = count(-1)+b+1
elif b < 0:
    ans2 = count(1)+1-b
else:
    ans1 = count(1)+1
    ans2 = count(-1)+1
print(min(ans1, ans2))

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

def count(s):
    ans = 0
    for i, a in enumerate(A):
        if i == 0:
            continue
        if s < 0:
            if 1-s-a >= 0:
                ans += 1-s-a
                s = 1
            else:
                s += a
        elif s > 0:
            if s+a+1 >= 0:
                ans += s+a+1
                s = -1
            else:
                s += a
    return ans

b = A[0]
ans1 = count(b)
if b > 0:
    ans2 = count(-1)+b+1
elif b < 0:
    ans2 = count(1)+1-b

print(min(ans1, ans2))
Problem p03909 (python)

Fixed submission:
H, W = map(int, input().split())
state = [list(map(str, input().split())) for _ in range(H)]

A = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
for h in range(H):
  for w in range(W):
    if state[h][w] == 'snuke':
      ans = A[w] + str(h+1)
print(ans)

Buggy submission (verdict: Runtime Error):
H, W = map(int, input().split())
state = [list(map(str, input().split())) for _ in range(h)]

A = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
for h in range(H):
  for w in range(W):
    if state[h][w] == 'snuke':
      ans = A[w] + str(h+1)
print(ans)
Problem p03994 (python)

Fixed submission:
S = input()
K = int(input())

alp = [chr(i) for i in range(97, 97+26)]

ans = ''
for s in S:
    loc = alp.index(s)
    if s == 'a' or loc + K < 26:
        ans += s
    else:
        K -= 26 - loc
        ans += 'a'

if K > 0:
    K %= 26
    ans = ans[:-1] + alp[(alp.index(ans[-1])+K)%26]
print(ans)

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

alp = [chr(i) for i in range(97, 97+26)]

ans = ''
for s in S:
    loc = alp.index(s)
    if s == 'a': continue
    if loc + K >= 26:
        K -= 26 - loc
        ans += 'a'
    else:
        ans += s
if K > 0:
    K %= 26
    ans = ans[:-1] + alp[(alp.index(ans[-1])+K)%26]
print(ans)