Buggy python submission (verdict: Runtime Error):
s = list(input())
k = int(input())
n = len(s)
c = ord("z") + 1
i = 0
for i in range(n):
    tmp = c - ord(s[i])
    if k >= tmp:
        s[i] = "a"
        k -= tmp
if k > 0:
    s[n-1] = chr(ord(s[n-1])+k)
print("".join(s))


Fixed submission:
s = list(input())
k = int(input())
n = len(s)
map = {(chr(ord("a") + i)): (26-i)%26 for i in range(26)}
for i in range(n):
    if k >= map[s[i]]:
        k -= map[s[i]]
        s[i] = "a"
if k > 0:
    s[n-1] = chr((ord(s[n-1])+k%26)%123)
print("".join(s))

Buggy python submission (verdict: Runtime Error):
s = list(input())
k = int(input())
n = len(s)
c = ord("z") + 1
i = 0
for i in range(n):
    tmp = c - ord(s[i])
    if k > 0 and k >= tmp:
        s[i] = "a"
        k -= tmp
else:
    s[n-1] = chr(ord(s[n-1])+k)
print("".join(s))


Fixed submission:
s = list(input())
k = int(input())
n = len(s)
map = {(chr(ord("a") + i)): (26-i)%26 for i in range(26)}
for i in range(n):
    if k >= map[s[i]]:
        k -= map[s[i]]
        s[i] = "a"
if k > 0:
    s[n-1] = chr((ord(s[n-1])+k%26)%123)
print("".join(s))

Buggy python submission (verdict: Runtime Error):
s = list(input())
k = int(input())
n = len(s)
c = ord("z") + 1
i = 0
for i in range(n):
    tmp = c - ord(s[i])
    if k >= tmp:
        s[i] = "a"
        k -= tmp
else:
    s[n-1] = chr(ord(s[n-1])+k)
print("".join(s))


Fixed submission:
s = list(input())
k = int(input())
n = len(s)
map = {(chr(ord("a") + i)): (26-i)%26 for i in range(26)}
for i in range(n):
    if k >= map[s[i]]:
        k -= map[s[i]]
        s[i] = "a"
if k > 0:
    s[n-1] = chr((ord(s[n-1])+k%26)%123)
print("".join(s))

Buggy python submission (verdict: Runtime Error):
s = input()
k = int(input())
n = len(s)
c = ord("z") + 1
i = 0
for i in range(n):
    tmp = c - ord(s[i])
    if k >= tmp:
        s = s[:i] + "a" + s[i+1:]
        k -= tmp
else:
    s = s[:n-1] + chr(ord(s[n-1])+k)
print(s)


Fixed submission:
s = list(input())
k = int(input())
n = len(s)
map = {(chr(ord("a") + i)): (26-i)%26 for i in range(26)}
for i in range(n):
    if k >= map[s[i]]:
        k -= map[s[i]]
        s[i] = "a"
if k > 0:
    s[n-1] = chr((ord(s[n-1])+k%26)%123)
print("".join(s))

Buggy python submission (verdict: Runtime Error):
a = input().replace("S", " S").replace("H", " H").replace("D", " D").replace("C", " C").split()
m, s, h, d, c = [], [], [], [], []
ans = []
for i in range(len(a)):
    if a[i][1] in ["2", "3", "4", "5", "6", "7", "8", "9"]:
        m.append(i)
    else:
        if a[i][0] == "S":
            s.append(i)
            if len(s) == 5:
                ans = s
                break
        elif a[i][0] == "H":
            h.append(i)
            if len(h) == 5:
                ans = h
                break
        elif a[i][0] == "D":
            d.append(i)
            if len(d) == 5:
                ans = d
                break
        else:
            c.append(i)
            if len(c) == 5:
                ans = c
                break
ch = 0
d = ""
for i in ans:
    d += "".join(a[ch:i])
    ch = i+1
if d == "":
    print(0)
else:
    print(d)

Fixed submission:
s = list(input())
k = int(input())
n = len(s)
map = {(chr(ord("a") + i)): (26-i)%26 for i in range(26)}
for i in range(n):
    if k >= map[s[i]]:
        k -= map[s[i]]
        s[i] = "a"
if k > 0:
    s[n-1] = chr((ord(s[n-1])+k%26)%123)
print("".join(s))