Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import math

n, p = map(int, input().split())
i = 1
while n * math.log(i) <= math.log(p):
    i += 1
for j in reversed(range(i)):
    pn = p
    for k in range(n):
        if (pn / j) % 1 != 0:
            break
        else:
            pn = pn / j
    else:
        print(j)
        break


Fixed submission:
n, p = map(int, input().split())
d = {}
while p % 2 == 0:
    if 2 not in d:
        d[2] = 1
    else:
        d[2] += 1
    p //= 2
f = 3
while f * f <= p:
    if p % f == 0:
        if f not in d:
            d[f] = 1
            p //= f 
        else:
            d[f] += 1
            p //= f
    else:
        f += 2
if p != 1:
    if p not in d:
        d[p] = 1
    else:
        d[p] += 1
d = sorted(d.items(), key=lambda x:x[1], reverse=True)
ans = 1
for k, v in d:
    if v < n:
        break
    else:
        ans *= k ** (v // n)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import math

n, p = map(int, input().split())
i = 1
while n * math.log(i) <= math.log(p):
    i += 1
for j in reversed(range(i)):
    if (p / j ** n) % 1 == 0:
        print(j)
        break


Fixed submission:
n, p = map(int, input().split())
d = {}
while p % 2 == 0:
    if 2 not in d:
        d[2] = 1
    else:
        d[2] += 1
    p //= 2
f = 3
while f * f <= p:
    if p % f == 0:
        if f not in d:
            d[f] = 1
            p //= f 
        else:
            d[f] += 1
            p //= f
    else:
        f += 2
if p != 1:
    if p not in d:
        d[p] = 1
    else:
        d[p] += 1
d = sorted(d.items(), key=lambda x:x[1], reverse=True)
ans = 1
for k, v in d:
    if v < n:
        break
    else:
        ans *= k ** (v // n)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n, p = map(int, input().split())
i = 1
while i ** n <= p:
    i += 1
for j in reversed(range(i)):
    if (p / j ** n) % 1 == 0:
        print(j)
        break


Fixed submission:
n, p = map(int, input().split())
d = {}
while p % 2 == 0:
    if 2 not in d:
        d[2] = 1
    else:
        d[2] += 1
    p //= 2
f = 3
while f * f <= p:
    if p % f == 0:
        if f not in d:
            d[f] = 1
            p //= f 
        else:
            d[f] += 1
            p //= f
    else:
        f += 2
if p != 1:
    if p not in d:
        d[p] = 1
    else:
        d[p] += 1
d = sorted(d.items(), key=lambda x:x[1], reverse=True)
ans = 1
for k, v in d:
    if v < n:
        break
    else:
        ans *= k ** (v // n)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
li = []
d = {}
for _ in range(m):
    p, y = map(int, input().split())
    li.append([p, y])
    if p not in d:     
        d[p] = [y]
    else:
        d[p].append(y)
for k, v in d.items():
    v.sort()
for p, y in li:
    r = d[p].index(y) + 1
    print(str(p).zfill(6) + str(r).zfill(6))


Fixed submission:
import bisect

n, m = map(int, input().split())
li = []
d = {}
for _ in range(m):
    p, y = map(int, input().split())
    li.append([p, y])
    if p not in d:     
        d[p] = [y]
    else:
        d[p].append(y)
for k, v in d.items():
    v.sort()
for p, y in li:
    r = bisect.bisect_right(d[p], y)
    print(str(p).zfill(6) + str(r).zfill(6))
Buggy python submission (verdict: Runtime Error):
from collections import deque

n = int(input())
a = sorted(int(input()) for _ in range(n))
q = deque(a)
l = q.popleft()
r = q.pop()
ans = abs(l - r)
while q:
    if flag == 0:
        x = q.popleft()
        flag = 1
    else:
        x = q.pop()
        flag = 0
    if abs(l - x) >= abs(x - r):
        ans += abs(l - x)
        l = x
    else:
        ans += abs(x - r)
        r = x
print(ans)


Fixed submission:
n = int(input())
a = sorted(int(input()) for _ in range(n))
m = n // 2
if n % 2 == 0:
    ans = (sum(a[m:]) - sum(a[:m])) * 2 - a[m] + a[m-1]
    print(ans)
else:
    ans1 = (sum(a[m+1:]) - sum(a[:m])) * 2 - a[m] + a[m-1]
    ans2 = (sum(a[m+1:]) - sum(a[:m])) * 2 - a[m+1] + a[m]
    print(max(ans1, ans2))
Buggy python submission (verdict: Runtime Error):
INF = float('inf')
n, k = map(int, input().split())
L = list(map(int, input().split()))
for i in range(n):
    if L[i] >= 0:
        break
l = L[max(0, (i-k)):i]
l.sort(reverse=True)
r = L[i:(i+k)]
s = min(k, len(r))
e = min(k, len(l))
ans = INF
for j in range(max(1, min(s, e))):
    tr = r[(s-1)-j]
    u = k - (s - 1) + j - 1
    tl = -l[u-1] if u > 0 else 0
    t = tr + tl + min(tr, tl)
    ans = min(ans, t)
print(ans)


Fixed submission:
INF = float('inf')
n, k = map(int, input().split())
L = list(map(int, input().split()))
ans = INF
for i in range(n-k+1):
    r = L[i+k-1]
    l = L[i]
    tr = abs(r) + abs(l - r)
    tl = abs(l) + abs(r - l)
    t = min(tr, tl)
    ans = min(ans, t)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import math

def comb(n, r):
    if r == 0:
        return 1
    else:
        return math.factorial(n) // (math.factorial(r) * math.factorial(n - r))

n = int(input())
a = sorted(map(int, input().split()))
M = 0
for i in range(n // 2 + 1):
    c = comb(a[-1], a[i])
    if c > M:
        M = c
        ans = [a[-1], a[i]]
print(*ans)


Fixed submission:
n = int(input())
a = sorted(map(int, input().split()))
m = a[-1]
for i in range(n - 1):
    c = abs(a[i] - a[-1] / 2)
    if c < m:
        m = c
        r = i
print(a[-1], a[r])
Buggy python submission (verdict: Runtime Error):
s = str(input())
alpha = 'abcdefghijklmnopqrstuvwxyz'
if len(s) == 26:
    if s == 'zyxwvutsrqponmlkjihgfedcba':
        print(-1)
    else:
        for i in range(26):
            if ord(s[i+1]) - ord(s[i]) != 1:
                S = sorted(set(s) - set(s[:i+1]))
                print(s[:i] + S[0])
                break
else:
    S = sorted(set(alpha) - set(s))
    print(s + S[0])


Fixed submission:
s = str(input())
alpha = 'abcdefghijklmnopqrstuvwxyz'
inv_alpha = 'zyxwvutsrqponmlkjihgfedcba'
if len(s) == 26:
    if s == inv_alpha:
        print(-1)
    else:
        for i in reversed(range(25)):
            for j in reversed(range(i+1, 26)):
                if s[i] < s[j]:
                    print(s[:i] + s[j])
                    break
            else:
                continue
            break
else:
    S = sorted(set(alpha) - set(s))
    print(s + S[0])
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
print(n - 1)
s0 = str(input())
if s0 == 'Vacant':
    exit()
l = 0
r = n - 1
while abs(l - r) > 1:
    m = (l + r) // 2
    print(m)
    s = str(input())
    if s == 'Vacant':
        exit()
    else:
        if s0 != s:
            l = m
        else:
            r = m
        s0 = s
else:
    print(l)
    s = str(input())


Fixed submission:
n = int(input())
l = 0
r = n - 1
print(l)
s_l = str(input())
if s_l == 'Vacant':
    exit()
while abs(l - r) > 1:
    m = (l + r) // 2
    print(m)
    s_m = str(input())
    if s_m == 'Vacant':
        exit()
    else:
        if (m - l) % 2:
            if s_m != s_l:
                l = m
                s_l = s_m
            else:
                r = m
                s_r = s_m
        else:
            if s_m != s_l:
                r = m
                s_r = s_m
            else:
                l = m
                s_l = s_m
else:
    print(r)
    s = str(input())

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
print(0)
s0 = str(input())
if s0 == 'Vacant':
    exit()
l = 0
r = n
while abs(l - r) > 1:
    m = (l + r) // 2
    print(m)
    s = str(input())
    if s == 'Vacant':
        exit()
    else:
        if s0 == s:
            l = m
        else:
            r = m
        s0 = s
else:
    print(l)
    s = str(input())


Fixed submission:
n = int(input())
l = 0
r = n - 1
print(l)
s_l = str(input())
if s_l == 'Vacant':
    exit()
while abs(l - r) > 1:
    m = (l + r) // 2
    print(m)
    s_m = str(input())
    if s_m == 'Vacant':
        exit()
    else:
        if (m - l) % 2:
            if s_m != s_l:
                l = m
                s_l = s_m
            else:
                r = m
                s_r = s_m
        else:
            if s_m != s_l:
                r = m
                s_r = s_m
            else:
                l = m
                s_l = s_m
else:
    print(r)
    s = str(input())
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
L = list(map(int, input().split()))
d = {}
for a in L:
    if a not in d:
        d[a] = 1
    else:
        d[a] += 1
l = []
for v in d.values():
    l.append(v)

if len(l) <= k:
    print(0)
else:
    ans = float('inf')
    for i in range(2 ** len(l)):
        b = [0] * len(l)
        for j in range(len(l)):
            if ((i >> j) & 1):
                b[j] = 1
        if b.count(1) <= k:
            cnt = 0
            for m in range(len(l)):
                if b[m] == 0:
                    cnt += l[m]
            ans = min(ans, cnt)
    print(ans)


Fixed submission:
n, k = map(int, input().split())
L = list(map(int, input().split()))
d = {}
for a in L:
    if a not in d:
        d[a] = 1
    else:
        d[a] += 1
l = []
for v in d.values():
    l.append(v)
l.sort(reverse=True)
print(n - sum(l[:k]))

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
L = list(map(int, input().split()))
d = {}
for a in L:
    if a not in d:
        d[a] = 1
    else:
        d[a] += 1
l = []
for v in d.values():
    l.append(v)

if len(l) <= k:
    print(0)
else:
    ans = float('inf')
    for i in range(2 ** len(l)):
        b = [0] * len(l)
        for j in range(len(l)):
            if ((i >> j) & 1):
                b[j] = 1
        cnt = 0
        val = len(l)
        for m in range(len(l)):
            if l[m] * b[m] == 0:
                cnt += l[m]
                val -= 1
        if val <= k:
            ans = min(ans, cnt)
    print(ans)


Fixed submission:
n, k = map(int, input().split())
L = list(map(int, input().split()))
d = {}
for a in L:
    if a not in d:
        d[a] = 1
    else:
        d[a] += 1
l = []
for v in d.values():
    l.append(v)
l.sort(reverse=True)
print(n - sum(l[:k]))
Buggy python submission (verdict: Time Limit Exceeded):
import bisect

n = int(input())
A = sorted(map(int, input().split()))
B = sorted(map(int, input().split()))
C = sorted(map(int, input().split()))
ans = 0
L = [0] * n
for i in range(n):
    a = bisect.bisect_left(A, B[i])
    L[i] = a
for i in range(n):
    b = bisect.bisect_left(B, C[i])
    ans += sum(L[:b])
print(ans)

Fixed submission:
import bisect

n = int(input())
A = sorted(map(int, input().split()))
B = sorted(map(int, input().split()))
C = sorted(map(int, input().split()))
ans = 0
L = [0] * n
for i in range(n):
    a = bisect.bisect_left(A, B[i])
    L[i] = a
cum = [0] * (n + 1)
for i in range(n):
    cum[i+1] = cum[i] + L[i]
for i in range(n):
    b = bisect.bisect_left(B, C[i])
    ans += cum[b]
print(ans)
Buggy python submission (verdict: Runtime Error):
h, w = map(int, input().split())
s = [list(input()) for _ in range(h)]
for i in range(h):
    for j in range(w):
        if s[i][j] == '.':
            l = max(0, j - 1)
            r = min(j + 2, w)
            if i == 0:
                s[i][j] = s[i][l:r].count('#') + s[i + 1][l:r].count('#')
            elif i == h - 1:
                s[i][j] = s[i - 1][l:r].count('#') + s[i][l:r].count('#')
            else:
                s[i][j] = s[i - 1][l:r].count('#') + s[i][l:r].count('#') + s[i + 1][l:r].count('#')
    print(*s[i], sep='')


Fixed submission:
h, w = map(int, input().split())
s = [list(input()) for _ in range(h)]
for i in range(h):
    for j in range(w):
        if s[i][j] == '.':
            l = max(0, j - 1)
            r = min(j + 2, w)
            if i == 0:
                if h == 1:
                    s[i][j] = s[i][l:r].count('#')
                else:
                    s[i][j] = s[i][l:r].count('#') + s[i + 1][l:r].count('#')
            elif i == h - 1:
                s[i][j] = s[i - 1][l:r].count('#') + s[i][l:r].count('#')
            else:
                s[i][j] = s[i - 1][l:r].count('#') + s[i][l:r].count('#') + s[i + 1][l:r].count('#')
    print(*s[i], sep='')

Buggy python submission (verdict: Runtime Error):
h, w = map(int, input().split())
s = [list(input()) for _ in range(h)]
for i in range(h):
    for j in range(w):
        if s[i][j] == '.':
            if i == 0:
                s[i][j] = s[i][max(0, j - 1):j + 2].count('#') + s[i + 1][max(0, j - 1):j + 2].count('#')
            elif i == h - 1:
                s[i][j] = s[i - 1][max(0, j - 1):j + 2].count('#') + s[i][max(0, j - 1):j + 2].count('#')
            else:
                s[i][j] = s[i - 1][max(0, j - 1):j + 2].count('#') + s[i][max(0, j - 1):j + 2].count('#') + s[i + 1][max(0, j - 1):j + 2].count('#')
    print(*s[i], sep='')


Fixed submission:
h, w = map(int, input().split())
s = [list(input()) for _ in range(h)]
for i in range(h):
    for j in range(w):
        if s[i][j] == '.':
            l = max(0, j - 1)
            r = min(j + 2, w)
            if i == 0:
                if h == 1:
                    s[i][j] = s[i][l:r].count('#')
                else:
                    s[i][j] = s[i][l:r].count('#') + s[i + 1][l:r].count('#')
            elif i == h - 1:
                s[i][j] = s[i - 1][l:r].count('#') + s[i][l:r].count('#')
            else:
                s[i][j] = s[i - 1][l:r].count('#') + s[i][l:r].count('#') + s[i + 1][l:r].count('#')
    print(*s[i], sep='')
Buggy python submission (verdict: Runtime Error):
n = int(input())
d = list(map(int, input().split()))
m = int(input())
t = list(map(int, input().split()))
D = {}
for i in range(n):
    if d[i] not in D:
        D[d[i]] = 1
    else:
        D[d[i]] += 1
T = {}
for j in range(m):
    if t[j] not in T:
        T[t[j]] = 1
    else:
        T[t[j]] += 1
for k in T:
    if T[k] <= D[k]:
        continue
    else:
        print('NO')
        break
else:
    print('YES')



Fixed submission:
n = int(input())
d = list(map(int, input().split()))
m = int(input())
t = list(map(int, input().split()))
D = {}
for i in range(n):
    if d[i] not in D:
        D[d[i]] = 1
    else:
        D[d[i]] += 1
T = {}
for j in range(m):
    if t[j] not in T:
        T[t[j]] = 1
    else:
        T[t[j]] += 1
for k in T:
    try:
        if T[k] <= D[k]:
            continue
        else:
            print('NO')
            break
    except:
        print('NO')
        break
else:
    print('YES')
Buggy python submission (verdict: Runtime Error):
N = int(input())
for h in range(1, 3501):
    for n in range(1, 3501):
        w = (N * h * n) / (4 * h * n - N * n - N * h)
        if w > 0 and w % 1 == 0:
            print(h, n, int(w))
            exit()

Fixed submission:
N = int(input())
for h in range(1, 3501):
    for n in range(1, 3501):
        if 4 * h * n - N * n - N * h > 0:
            w = (N * h * n) / (4 * h * n - N * n - N * h)
            if w > 0 and w % 1 == 0:
                print(h, n, int(w))
                exit()
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(input()) for _ in range(n)]
cnt = 0
a_set = set(a)
for i in a_set:
    if a.count(i) % 2 != 0:
        cnt += 1
print(cnt)


Fixed submission:
n = int(input())
D = {}
cnt = 0
for _ in range(n):
    a = int(input())
    if a not in D:
        D[a] = 1
    else:
        D[a] += 1
for i in D:
    if D[i] % 2 != 0:
        cnt += 1
print(cnt)
Buggy python submission (verdict: Runtime Error):
def gcd(a, b):
    if a < b:
        a, b = b, a
    while a % b != 0:
        a, b = b, a % b
    return b
def lcm(a, b):
    return a * b // gcd(a, b)

n = int(input())
t = [int(input()) for _ in range(n)]
l = lcm(t[0], t[1])
for i in range(1, n):
    l = lcm(l, t[i])
print(l)


Fixed submission:
def gcd(a, b):
    if a < b:
        a, b = b, a
    while a % b != 0:
        a, b = b, a % b
    return b
def lcm(a, b):
    return a * b // gcd(a, b)

n = int(input())
t = [int(input()) for _ in range(n)]
if n == 1:
    print(t[0])
else:
    l = lcm(t[0], t[1])
    for i in range(1, n):
        l = lcm(l, t[i])
    print(l)
Buggy python submission (verdict: Runtime Error):
import math

n, k = map(int, input().split())
L = list(map(int, input().split()))
if n == 1:
    g = L[0]
else:
    g = math.gcd(L[0], L[1])
    for i in range(2, n):
        g = math.gcd(g, L[i])
M = max(L)
if M >= k and k % g == 0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')


Fixed submission:
import fractions

n, k = map(int, input().split())
L = list(map(int, input().split()))
if n == 1:
    g = L[0]
else:
    g = fractions.gcd(L[0], L[1])
    for i in range(2, n):
        g = fractions.gcd(g, L[i])
M = max(L)
if M >= k and k % g == 0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(input()) for _ in range(n)]
L = []
cnt = 0
i = 0
while True:
    if i in L:
        print(-1)
        break
    else:
        L.append(i)
        i = a[i] - 1
        cnt += 1
        if i == 1:
            print(cnt)
            break


Fixed submission:
n = int(input())
a = [int(input()) for _ in range(n)]
L = [0] * n
cnt = 0
i = 0
while True:
    if L[i] == 1:
        print(-1)
        break
    else:
        L[i] = 1
        i = a[i] - 1
        cnt += 1
        if i == 1:
            print(cnt)
            break
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
d = {i: 0 for i in range(1, n+1)}
for _ in range(n):
    a, b = map(int, input().split())
    d[a] += 1
    d[b] += 1
for k, v in d.items():
    if v % 2:
        print('NO')
        break
else:
    print('YES')


Fixed submission:
n, m = map(int, input().split())
d = {i: 0 for i in range(1, n+1)}
for _ in range(m):
    a, b = map(int, input().split())
    d[a] += 1
    d[b] += 1
for k, v in d.items():
    if v % 2:
        print('NO')
        break
else:
    print('YES')

Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
d = {i: 0 for i in range(1, n)}
for _ in range(n):
    a, b = map(int, input().split())
    d[a] += 1
    d[b] += 1
for k, v in d.items():
    if v % 2:
        print('NO')
        break
else:
    print('YES')


Fixed submission:
n, m = map(int, input().split())
d = {i: 0 for i in range(1, n+1)}
for _ in range(m):
    a, b = map(int, input().split())
    d[a] += 1
    d[b] += 1
for k, v in d.items():
    if v % 2:
        print('NO')
        break
else:
    print('YES')

Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
d = {i: 0 for i in range(1, n)}
for _ in range(n):
    a, b = map(int, input().split())
    if a != 1:
        d[a] = 1 if a not in d else d[a] + 1
    if b != 1:
        d[b] = 1 if b not in d else d[b] + 1
for k, v in d.items():
    if v % 2:
        print('NO')
        break
else:
    print('YES')


Fixed submission:
n, m = map(int, input().split())
d = {i: 0 for i in range(1, n+1)}
for _ in range(m):
    a, b = map(int, input().split())
    d[a] += 1
    d[b] += 1
for k, v in d.items():
    if v % 2:
        print('NO')
        break
else:
    print('YES')
Buggy python submission (verdict: Runtime Error):
n = int(input())
L = list(map(int, input().split()))
cnt = 1
state = None
i = 1
while i < n:
    if state is None:
        if L[i] > L[i - 1]:
            state = 'up'
        elif L[i] < L[i - 1]:
            state = 'down'
        i += 1
    else:
        if state == 'up':
            while L[i] >= L[i - 1]:
                i += 1
                if i == n - 1:
                    print(cnt)
                    exit()
            cnt += 1
            i += 1
            state = None
        else:
            while L[i] <= L[i - 1]:
                i += 1
                if i == n - 1:
                    print(cnt)
                    exit()
            cnt += 1
            i += 1
            state = None
print(cnt)

Fixed submission:
n = int(input())
L = list(map(int, input().split()))
cnt = 1
state = None
i = 1
while i < n:
    if state is None:
        if L[i] > L[i - 1]:
            state = 'up'
        elif L[i] < L[i - 1]:
            state = 'down'
        i += 1
    else:
        if state == 'up':
            while L[i] >= L[i - 1]:
                i += 1
                if i >= n - 1:
                    print(cnt)
                    exit()
            cnt += 1
            i += 1
            state = None
        else:
            while L[i] <= L[i - 1]:
                i += 1
                if i >= n - 1:
                    print(cnt)
                    exit()
            cnt += 1
            i += 1
            state = None
print(cnt)
Buggy python submission (verdict: Runtime Error):
from collections import Counter

n = int(input())
L = [Counter(str(input())) for _ in range(n)]
ans = ''
for k in L[0]:
    for i in range(1, n):
        m = L[0][k]
        if L[i][k] < L[0][k]:
            m = min(m, L[i][k])
    ans = ans + k * m
print(ans)


Fixed submission:
from collections import Counter

n = int(input())
L = [Counter(str(input())) for _ in range(n)]
C = sorted(L[0])
ans = ''
for k in C:
    m = L[0][k]
    for i in range(n):
        m = min(m, L[i][k])
    ans += k * m
print(ans)
Buggy python submission (verdict: Runtime Error):
def pfact(n):
    d = {}
    while n % 2 == 0:
        d[2] = 1 if 2 not in d else d[2] + 1
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            d[f] = 1 if f not in d else d[f] + 1
            n //= f
        else:
            f += 2
    if n != 1:
        d[n] = 1 if n not in d else d[n] + 1
    return d

n = int(input())
d = pfact(n)
L = sorted(d, reverse=True)
a = L[0]
d[L[0]] -= 1
b = 1
for k in L:
    while d[k] > 0:
        if b > a:
            a, b = b, a
        b *= k
        d[k] -= 1
print(max(len(str(a)), len(str(b))))


Fixed submission:
n = int(input())
ans = float('inf')
for a in range(1, int(n ** 0.5) + 1):
    if n / a % 1 == 0:
        b = n // a
        ans = min(ans, max(len(str(a)), len(str(b))))
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
p = 1
for i in range(1, n + 1):
    p *= i
print(p % (10 ** 9 + 7))

Fixed submission:
import math

n = int(input())
print(math.factorial(n) % (10 ** 9 + 7))
Buggy python submission (verdict: Runtime Error):
s = str(input())
k = int(input())
S = []
for i in range(len(s)):
    S.append(ord(s[i]) - 97)
i = 0
while k > 0:
    if 26 - S[i] <= k:
        k -= 26 - S[i]
        S[i] = 0
        i += 1
    else:
        i += 1
    if i >= len(s):
        S[-1] += k
        break
ans = ''
for x in S:
    ans += chr(x + 97)
print(ans)


Fixed submission:
s = str(input())
k = int(input())
S = []
for i in range(len(s)):
    S.append(ord(s[i]) - 97)
i = 0
while k > 0:
    if S[i] > 0 and 26 - S[i] <= k:
        k -= 26 - S[i]
        S[i] = 0
        i += 1
    else:
        i += 1
    if i >= len(s):
        S[-1] += k
        break
ans = ''
for x in S:
    ans += chr((x % 26) + 97)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
a=list(map(int,input().split()))
b=a[0]
for i in range(N-1):
  b=b^a[i+1]
ans=""
for i in range(N):
  if(i<N-1):
    ans+=str(b^a[i])+" "
  else:
    ans+=str(b^a[i])
print(ans)

Fixed submission:
N=int(input())
a=list(map(int,input().split()))
b=a[0]
for i in range(N-1):
  b=b^a[i+1]
x=[0 for i in range(N)]
for i in range(N):
  x[i]=b^a[i]
x=map(str,x)
ans=' '.join(x)
print(ans)