Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
a,b,k = map(int,input().split())
c = list(range(a,b+1))
ans = c[:k] + c[-k:]
ans = list(set(ans))
ans.sort()
for i in ans:
    print(i)

Fixed submission:
a,b,k = map(int,input().split())
ans = [a+i for i in range(k) if a+i <= b] + [b-i for i in range(k) if b-i >= a]
ans = list(set(ans))
ans.sort()

for i in ans:
    print(i)

Buggy python submission (verdict: Runtime Error):
a,b,k = map(int,input().split())
c = list(range(a,b+1))

if 2*k <= len(c):
    ans = c[:k] + c[-k:]
else:
    ans = c

for i in ans:
    print(i)

Fixed submission:
a,b,k = map(int,input().split())
ans = [a+i for i in range(k) if a+i <= b] + [b-i for i in range(k) if b-i >= a]
ans = list(set(ans))
ans.sort()

for i in ans:
    print(i)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [0] + list(map(int,input().split())) + [0]
sa = [abs(a[i]-a[i+1]) for i in range(n+1)]

for i in range(n):
    yen = sum(sa) + abs(a[i+2]-a[i]) - sa[i] - sa[i+1]
    print(yen)

Fixed submission:
n = int(input())
a = [0] + list(map(int,input().split())) + [0]
sa = [abs(a[i]-a[i+1]) for i in range(n+1)]
sum_sa = sum(sa)

for i in range(n):
    yen = sum_sa + abs(a[i+2]-a[i]) - sa[i] - sa[i+1]
    print(yen)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [0] + list(map(int,input().split())) + [0]
sa = [abs(a[i]-a[i+1]) for i in range(n+1)]

for i in range(n):
    p = list(range(n+1)) + [0]
    p.pop(i+1)

    yen = sum(sa) + abs(a[p[i+1]] - a[p[i]]) - sa[i] - sa[i+1]
    print(yen)

Fixed submission:
n = int(input())
a = [0] + list(map(int,input().split())) + [0]
sa = [abs(a[i]-a[i+1]) for i in range(n+1)]
sum_sa = sum(sa)

for i in range(n):
    yen = sum_sa + abs(a[i+2]-a[i]) - sa[i] - sa[i+1]
    print(yen)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [0]
a += list(map(int,input().split()))
w = [[0]*(n+1) for _ in range(n+1)]

for i in range(n+1):
    for j in range(n+1):
        w[i][j] += abs(a[i] - a[j])

for i in range(1,n+1):
    yen = 0
    p = list(range(n+1)) + [0]
    p.pop(i)

    for j in range(n):
        yen += w[p[j]][p[j+1]]
    print(yen)

Fixed submission:
n = int(input())
a = [0] + list(map(int,input().split())) + [0]
sa = [abs(a[i]-a[i+1]) for i in range(n+1)]
sum_sa = sum(sa)

for i in range(n):
    yen = sum_sa + abs(a[i+2]-a[i]) - sa[i] - sa[i+1]
    print(yen)
Buggy python submission (verdict: Runtime Error):
n,k = map(int,input().split())

if k == 0:
    print(n**2)
else:
	total = 0
    for i in range(k+1,n+1):
        d,m = divmod(n,i)
        
        if (i-k) > 0:
            total += d*(i-k)
        if (m-k+1) > 0:
            total += m-k+1

    print(total)

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

if k == 0:
    print(n**2)
else:
    total = 0
    for i in range(k+1,n+1):
        d,m = divmod(n,i)
        
        if (i-k) > 0:
            total += d*(i-k)
        if (m-k+1) > 0:
            total += m-k+1

    print(total)
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
import collections

n = int(input())
name = []
for i in range(n):
    a = input()
    if a[0] in 'MARCH':
        name.append(a)

b = list(itertools.combinations(name,3))
total = 0
for tap in b:
    d = []
    for c in tap:
        d.append(c[0])
        
    d.sort()    
    e = collections.Counter(d)

    cnt = 0
    for v in e.values():
        if v == 1:
            cnt += 1
    if cnt == 3:
        total += 1

print(total)

Fixed submission:
import itertools
import collections

n = int(input())
name = []
for i in range(n):
    a = input()
    if a[0] in 'MARCH':
        name.append(a[0])

b = collections.Counter(name)
d = []
for v in b.values():
    d.append(v)

c = list(itertools.combinations(list(range(len(b))), 3))

total = 0
for tap in c:
    total += d[tap[0]] * d[tap[1]] * d[tap[2]]
print(total)
Buggy python submission (verdict: Runtime Error):
h,w,d = map(int,input().split())
hw = [[0,0] for _ in range(h*w+1)]
for i in range(h):
    row = list(map(int,input().split()))
    for j in range(w):
        hw[row[j]] = [i,j]

a = [0]*(h*w)
for i in range(d,h*w):
    a[i] = a[i-d] + abs(hw[i][0] - hw[i-d][0]) + abs(hw[i][1] - hw[i-d][1])

q = int(input())
for i in range(q):
    L,R = map(int,input().split())
    print(a[R] - a[L])

Fixed submission:
h,w,d = map(int,input().split())
hw = [[] for _ in range(h*w+1)]
for i in range(h):
    row = list(map(int,input().split()))
    for j in range(w):
        hw[row[j]] = [i,j]
 
a = [0 for _ in range(h*w+1)]
for i in range(d+1,h*w+1):
    a[i] = a[i-d] + abs(hw[i][0] - hw[i-d][0]) + abs(hw[i][1] - hw[i-d][1])
 
q = int(input())
for i in range(q):
    L,R = map(int,input().split())
    print(a[R] - a[L])

Buggy python submission (verdict: Time Limit Exceeded):
h,w,d = map(int,input().split())
hw = ['' for _ in range(h*w)]

for i in range(h):
    row = list(map(int,input().split()))
    for j in range(w):
        hw[row[j]-1] = [i+1,j+1]

q = int(input())
for i in range(q):
    L,R = map(int,input().split())
    a = list(range(L,R+1,d))
    
    total = 0
    for j in range(len(a)-1):
        total += abs(hw[a[j+1]-1][0] - hw[a[j]-1][0]) + abs(hw[a[j+1]-1][1] - hw[a[j]-1][1])        
        
    print(total)

Fixed submission:
h,w,d = map(int,input().split())
hw = [[] for _ in range(h*w+1)]
for i in range(h):
    row = list(map(int,input().split()))
    for j in range(w):
        hw[row[j]] = [i,j]
 
a = [0 for _ in range(h*w+1)]
for i in range(d+1,h*w+1):
    a[i] = a[i-d] + abs(hw[i][0] - hw[i-d][0]) + abs(hw[i][1] - hw[i-d][1])
 
q = int(input())
for i in range(q):
    L,R = map(int,input().split())
    print(a[R] - a[L])

Buggy python submission (verdict: Time Limit Exceeded):
h,w,d = map(int,input().split())
HW = [list(map(int,input().split())) for _ in range(h)]

q = int(input())
a = []
c = []
for i in range(q):
    L,R = map(int,input().split())
    b = list(range(L,R+1,d))
    
    x = 0
    for hw in HW:
        y = 0
        for num in hw:
            if num in b:
                c.append([num,[x+1,y+1]])
            y += 1
        x += 1
    c.sort()
    
    total = 0
    for j in range(len(b)-1):
        total += abs(c[j+1][1][0] - c[j][1][0]) + abs(c[j+1][1][1] - c[j][1][1])        
        
    print(total)

Fixed submission:
h,w,d = map(int,input().split())
hw = [[] for _ in range(h*w+1)]
for i in range(h):
    row = list(map(int,input().split()))
    for j in range(w):
        hw[row[j]] = [i,j]
 
a = [0 for _ in range(h*w+1)]
for i in range(d+1,h*w+1):
    a[i] = a[i-d] + abs(hw[i][0] - hw[i-d][0]) + abs(hw[i][1] - hw[i-d][1])
 
q = int(input())
for i in range(q):
    L,R = map(int,input().split())
    print(a[R] - a[L])
Buggy python submission (verdict: Runtime Error):
s = list(input())
sums = sum([int(ss) for ss in s])

if len(s) == 1:
    print(1)
elif sums == len(s):
    print(len(s))
else:
    a = []
    for i in range(len(s)-1):
        if s[i] != s[i+1]:
            a.append(max(i+1, len(s)-i-1))
            
    print(min(a))

Fixed submission:
s = list(input())
l = len(s)
a = [l]
for i in range(len(s)-1):
    if s[i] != s[i+1]:
        a.append(max(i+1, len(s)-i-1))
        
print(min(a))

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

if s == '1':
    print(1)
else:
    a = []
    for i in range(len(s)-1):
        if s[i] != s[i+1]:
            a.append(max(len(s[:i+1]), len(s[i+1:])))
            
    print(min(a))

Fixed submission:
s = list(input())
l = len(s)
a = [l]
for i in range(len(s)-1):
    if s[i] != s[i+1]:
        a.append(max(i+1, len(s)-i-1))
        
print(min(a))
Buggy python submission (verdict: Runtime Error):
p0 = []
maxp = []
for i in range(n):
    p0.append(p[i][0])
    sumf = sum(f[i])
    maxp.append(max(p[i][1:(sumf+1)]))

cnt = 0
sum_max = 0
for i in range(n):
    if p0[i] > maxp[i]:
        cnt += 1
    sum_max += max(p0[i],maxp[i])

if cnt == n:
    a = []
    for i in range(n):
        a.append(p0[i] + sum(maxp[:i]) + sum(maxp[i+1:]))
    print(max(a))
else:
    print(sum_max)

Fixed submission:
import itertools
n = int(input())
f = [list(map(int,input().split())) for _ in range(n)]
p = [list(map(int,input().split())) for _ in range(n)]

a = list(range(10))
cnt = 0
total = 0
total_p = []
for i in range(1,11):
    c = list(itertools.combinations(a,i))
    
    for tap in c:
        for j in range(n):
            for num in tap:
                if f[j][num] == 1:
                    cnt += 1
                    
            total += p[j][cnt]
            cnt = 0
        
        total_p.append(total)
        total = 0

print(max(total_p))
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = 2
b = 1
for i in range(n-1):
    c = a+b
    a = b
    b = c
print(c)

Fixed submission:
n = int(input())
a = 2
b = 1
if n == 1:
    print(b)
else:
    for i in range(n-1):
        c = a+b
        a = b
        b = c
    print(c)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
u = list(map(int,input().split()))
m = list(map(int,input().split()))
d = list(map(int,input().split()))
u.sort()
m.sort()
d.sort()

cnt = 0
a = []
for i in range(n):
    for j in range(cnt,n):
        if u[j] < m[i]:
            cnt += 1
        else:
            a.append(cnt)
            break
    else:
        a.append(cnt)

cnt = 0
ans = 0
for i in range(n):
    for j in range(cnt,n):
        if d[i] > m[j]:
            cnt += 1
        else:
            break
    ans += sum(a[:cnt])
print(ans)

Fixed submission:
import bisect

n = int(input())
u = list(map(int,input().split()))
m = list(map(int,input().split()))
d = list(map(int,input().split()))
u.sort()
m.sort()
d.sort()

ans = 0
for a in m:
    ans += bisect.bisect_left(u,a) * (n - bisect.bisect_right(d,a))
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
u = list(map(int,input().split()))
m = list(map(int,input().split()))
d = list(map(int,input().split()))

cnt = 0
for i in range(n):
    for j in range(n):
        if m[j] < d[i]:
            for k in range(n):
                if u[k] < m[j]:
                    cnt += 1
print(cnt)

Fixed submission:
import bisect

n = int(input())
u = list(map(int,input().split()))
m = list(map(int,input().split()))
d = list(map(int,input().split()))
u.sort()
m.sort()
d.sort()

ans = 0
for a in m:
    ans += bisect.bisect_left(u,a) * (n - bisect.bisect_right(d,a))
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
p = []
for i in range(n):
    a = int(input())
    if a in p:
        ind = p.index(a)
        p.pop(ind)
    else:
        p.append(a)

print(len(p))

Fixed submission:
import collections
n = int(input())
a = [int(input()) for _ in range(n)]

c = collections.Counter(a)
cnt = 0
for v in c.values():
    if v % 2 == 1:
        cnt += 1
print(cnt)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))

t = 0
cnt = 0
for i in range(n):
    if a[i] == i+1:
        t += 1

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

print(t-cnt)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
 
t = 0
for i in range(n):
    if a[i] == i+1:
        t += 1

i = 0
cnt = 0
while i < n-1:
    if a[i] == i+1 and a[i+1] == i+2:
        cnt += 1
        i += 2
    else:
        i += 1

print(t-cnt)
Buggy python submission (verdict: Runtime Error):
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)

def lcm(a, b):
    return a * b / gcd(a, b)

n = int(input())
a = [int(input()) for _ in range(n)]

b = lcm(a[0],a[1])
for i in range(2,n):
    b = lcm(b,a[i])
print(int(b))

Fixed submission:
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)

def lcm(a, b):
    return a * b // gcd(a, b)

n = int(input())
a = [int(input()) for _ in range(n)]

if n == 1:
    print(a[0])
    exit()

for i in range(n-1):
    if i == 0:
        b = lcm(a[i],a[i+1])
    else:
        b = lcm(b,a[i+1])
print(b)
Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())
first = []
second = []
for i in range(m):
    a,b =  map(int,input().split())
    if a == 1:
        first.append(b)
    if b == n:
        second.append(a)

for i in range(len(first)):
    if first[i] in second:
        print('POSSIBLE')
        exit()
else:
    print('IMPOSSIBLE')

Fixed submission:
n,m = map(int,input().split())
c = []
for i in range(m):
    a,b =  map(int,input().split())
    if a == 1:
        c.append(b)
    if b == n:
        c.append(a)
        
if len(c) == len(set(c)):
    print('IMPOSSIBLE')
else:
    print('POSSIBLE')
Buggy python submission (verdict: Runtime Error):
n,a,b = map(int,input().split())
if a == b:
    print(1)
elif n == 1 or a > b:
    print(0)
else:
    print(len(list(range(a*(n-1)+b, a+(n-1)*b+1))))

Fixed submission:
n,a,b = map(int,input().split())
if a == b:
    print(1)
elif n == 1 or a > b:
    print(0)
else:
    print((a+(n-1)*b) - (a*(n-1)+b) + 1)

Buggy python submission (verdict: Runtime Error):
n,a,b = map(int,input().split())
if n == 1 and a == b:
    print(1)
elif n == 1 or a > b:
    print(0)
else:
    print(len(list(range(a*(n-1)+b, a+(n-1)*b+1))))

Fixed submission:
n,a,b = map(int,input().split())
if a == b:
    print(1)
elif n == 1 or a > b:
    print(0)
else:
    print((a+(n-1)*b) - (a*(n-1)+b) + 1)

Buggy python submission (verdict: Runtime Error):
n,a,b = map(int,input().split())
if a > b or (n == 1 and a != b):
    print(0)
else:
    print(len(list(range(a*(n-1)+b, a+(n-1)*b+1))))

Fixed submission:
n,a,b = map(int,input().split())
if a == b:
    print(1)
elif n == 1 or a > b:
    print(0)
else:
    print((a+(n-1)*b) - (a*(n-1)+b) + 1)
Buggy python submission (verdict: Runtime Error):
a,b,c = map(int,input().split())
if b-a = c-b:
    print('YES')
else:
    print('NO')

Fixed submission:
a,b,c = map(int,input().split())
if b-a == c-b:
    print('YES')
else:
    print('NO')
Buggy python submission (verdict: Runtime Error):
o = input()
e = input()
a = ''
for i in range(len(o)):
    a += o[i] + e[i]
print(a)

Fixed submission:
o = input()
e = input()
a = ''
for i in range(len(e)):
    a += o[i] + e[i]
if len(o) > len(e):
    a += o[-1]
print(a)
Buggy python submission (verdict: Runtime Error):
s = input()
a = z =  ''
for i, v in enumerate(s):
    if not a:
        if v == 'A':
            a = i
    if not z:
        if s[len(s) - i -1] == 'Z':
            z = len(s) - i
            
    if a >= 0 and z >= 0:
        print(z - a)
        exit()

Fixed submission:
s = input()
for i, a in enumerate(s):
    if a == 'A':
        l = i
        break
for i, z in enumerate(s[::-1]):
    if z == 'Z':
        r = len(s) - i
        break
print(r - l)
Buggy python submission (verdict: Time Limit Exceeded):
cnt = 0
k, s = map(int,input().split())
for i in range(k+1):
    for j in range(k+1):
        for l in range(k+1):
            if i + j + l == s:
                cnt += 1
print(cnt)

Fixed submission:
k, s = map(int,input().split())
cnt = 0
for i in range(k+1):
    for j in range(k+1):
        if 0 <= s - i - j <= k:
            cnt += 1
print(cnt)
Buggy python submission (verdict: Runtime Error):
n, x = map(int,input().split())
a = list(map(int,input().split()))
mina = min(a)
b = x - mina

a2 = []
a3 = []
for i in range(n):
    if i % 2 == 0:
        a2.append(mina)
        a3.append(b)
    else:
        a2.append(b)
        a3.append(mina)

cnt2 = 0
cnt3 = 0
for i in range(n):
    if a[i] >= a2[i]:
        cnt2 += a[i] - a2[i]
    else:
        cnt2 = None
        break
    
for i in range(n):
    if a[i] >= a3[i]:
        cnt3 += a[i] - a3[i]
    else:
        cnt3 = None
        break

if cnt2 and cnt3:
    print(min(cnt2,cnt3))
elif cnta2:
    print(cnt2)
elif cnta3:
    print(cnt3)
else:
    print(0)


Fixed submission:
n, x = map(int,input().split())
a = list(map(int,input().split()))
cnt = 0
for i in range(1, n):
    if a[i] + a[i-1] > x:
        b = a[i] + a[i-1] - x
        minab = min(a[i], b)
        a[i] -= minab
        cnt += minab
        
        b -= minab
        cnt += b
        a[i-1] -= b
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
x = y = 1
for i in range(n):
    t, a = map(int, input().split())
    k = 1
    while True:
        if t*k >= x and a*k >= y:
            x, y = t*k, a*k
            break
        k += 1
print(x+y)

Fixed submission:
n = int(input())
x = y = 1
for i in range(n):
    t, a = map(int, input().split())
    bx = 1 if x % t else 0
    by = 1 if y % a else 0
    k = max(x//t + bx, y//a + by)
    x, y = t*k, a*k
print(x+y)
Buggy python submission (verdict: Runtime Error):
s = list(input())
cnt = 0
while True:
    if s[0] == 'T':
        s.pop(0)
        cnt += 1
    else:
        break
    
while True:
    if s[-1] == 'S':
        s.pop(-1)
        cnt += 1
    else:
        break

cs = 0
ct = 0
for i in range(len(s)):
    if s[i] == 'S':
        cs += 1
    else:
        ct += 1
print(cnt + abs(cs-ct))

Fixed submission:
s = input()
ans = 0
cnt = 0
for a in s:
    if a == 'S':
        cnt += 1
    else:
        if cnt > 0:
            cnt -= 1
        else:
            ans += 1
print(ans+cnt)

Buggy python submission (verdict: Runtime Error):
s = list(input())
cnt = 0
while True:
    if s[0] == 'T':
        s.pop(0)
        cnt += 1
    else:
        break
    
while True:
    if s[-1] == 'S':
        s.pop(-1)
        cnt += 1
    else:
        break
        
i = 0
now = 'on'
ans = 0
cs = 0
while i < len(s):
    if s[i] == 'S':
        cs += 1
        now = 'on'
        i += 1
    elif now == 'on' and s[i] == 'T':
        i += cs
        cs = 0
        now = 'off'
    elif now == 'off' and s[i] == 'T':
        cnt += 1
        i += 1
        
    if i >= len(s):
        break
print(cnt)

Fixed submission:
s = input()
ans = 0
cnt = 0
for a in s:
    if a == 'S':
        cnt += 1
    else:
        if cnt > 0:
            cnt -= 1
        else:
            ans += 1
print(ans+cnt)
Buggy python submission (verdict: Runtime Error):
a,b = map(int,input().split())
l = list(range(a,b+1))

ans = 1
for i in range(len(l)):
    ans *= l[i]

if ans > 0:
    print('Positive')
elif ans < 0:
    print('Negative')
else:
    print('Zero')

Fixed submission:
a,b = map(int,input().split())
if a <= 0 and b >= 0:
    print('Zero')
elif a > 0 and b > 0:
    print('Positive')
else:
    if (abs(a-b)+1) % 2 == 1:
        print('Negative')
    else:
        print('Positive')

Buggy python submission (verdict: Runtime Error):
a,b = map(int,input().split())
l = list(range(a,b+1))
ans = 1
for i in range(len(l)):
    ans *= l[i]

if ans > 0:
    print('Positive')
elif ans < 0:
    print('Negative')
else:
    print(0)


Fixed submission:
a,b = map(int,input().split())
if a <= 0 and b >= 0:
    print('Zero')
elif a > 0 and b > 0:
    print('Positive')
else:
    if (abs(a-b)+1) % 2 == 1:
        print('Negative')
    else:
        print('Positive')
Buggy python submission (verdict: Runtime Error):
_ = input()
s = input()

def rec(s,ans):
    l = s[:len(s)//2]
    r = s[len(s)//2:]
    rw = r.count('W')
    rr = r.count('R')
    lw = l.count('W')
    lr = l.count('R')
    if rr:
        if lw > rr:
            return ans + rr
        else:
            return ans + lw 
    else:
        rec(l)

print(rec(s,0))

Fixed submission:
def alter_altar(s):
    tmp = 'R' * s.count('R') + 'W' * s.count('W')
    ans = 0
    for i in range(len(s)):
        if s[i] == tmp[i]:
            pass
        else:
            ans += 1
    return ans//2
if __name__ == "__main__":
    _ = input()
    s = input()
    print(alter_altar(s))
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int,input().split())
A = list(map(int,input().split()))

res=[0]*(n-k+1)
for i in range(n-k+1):
    x = 1
    for j in A[i:k+i]:
        x *= j
    res[i]=x
for i in range(1,len(res)):
    if res[i] > res[i-1]:
        print('Yes')
    else:
        print('No')

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

for i in range(n-k):
    if A[k+i] > A[i]:
        print('Yes')
    else:
        print('No')
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = list(map(int,input().split()))
money = 1000
stock = 0
for i in range(n-1):
    if A[i] >= A[i+1]:
        while stock:
            stock -= 1
            money += A[i]
    else:
        while money >= A[i]:
            money -= A[i]
            stock += 1

print(stock * A[n-1] + money)

Fixed submission:
n = int(input())
A = list(map(int,input().split()))
money = 1000
stock = 0
for i in range(n-1):
    if A[i] >= A[i+1]:
        money += stock * A[i]
        stock = 0
    elif money >= A[i]:
        stock = money // A[i]
        money -= stock * A[i]
print(stock * A[n-1] + money)
Buggy python submission (verdict: Runtime Error):
n = input()
A = list(map(int, input().split()))

N = int(input())
ans = ''
for i in range(1, 99):
    if N <= 26 ** i:
        N -= 1
        for j in range(i):
            ans += chr(ord('a') + N % 26)
            N //= 26
        break
    else:
        N -= 26 ** i
print(ans[::-1]) 

Fixed submission:
N = int(input())
ans = ''
for i in range(1, 99):
    if N <= 26 ** i:
        N -= 1
        for j in range(i):
            ans += chr(ord('a') + N % 26)
            N //= 26
        break
    else:
        N -= 26 ** i
print(ans[::-1])
Buggy python submission (verdict: Time Limit Exceeded):
_=input();a=list(map(int,input().split(' ')));q=int(input())
for _ in range(q):
    b,c = map(int,input().split(' '))
    a = list(map(lambda i: c if i == b else i, a))
    print(sum(a))

Fixed submission:
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
q = int(input())
counter = Counter(a)
sum_res = sum(a)
for _ in range(q):
    before, after = map(int, input().split())
    sum_res -= before * counter[before]
    sum_res += after * counter[before]
    counter[after] += counter[before]
    counter[before] = 0
    print(sum_res)

Buggy python submission (verdict: Time Limit Exceeded):
_=input()
a=list(map(int,input().split(' ')))
q=int(input())
for _ in range(q):
    b,c = map(int,input().split(' '))
    a = [c if i == b else i for i in a]
    print(sum(a))

Fixed submission:
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
q = int(input())
counter = Counter(a)
sum_res = sum(a)
for _ in range(q):
    before, after = map(int, input().split())
    sum_res -= before * counter[before]
    sum_res += after * counter[before]
    counter[after] += counter[before]
    counter[before] = 0
    print(sum_res)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=input()
q=int(input())
for _ in range(q):
    b,c = input().split(' ')
    a = a.replace(b,c)
    print(sum(map(int,a.split(' '))))

Fixed submission:
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
q = int(input())
counter = Counter(a)
sum_res = sum(a)
for _ in range(q):
    before, after = map(int, input().split())
    sum_res -= before * counter[before]
    sum_res += after * counter[before]
    counter[after] += counter[before]
    counter[before] = 0
    print(sum_res)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=input()
q=int(input())
ans=[]
for _ in range(q):
    b,c = input().split(' ')
    a = a.replace(b,c)
    ans.append(sum(map(int,a.split(' '))))
for s in ans:
    print(s)

Fixed submission:
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
q = int(input())
counter = Counter(a)
sum_res = sum(a)
for _ in range(q):
    before, after = map(int, input().split())
    sum_res -= before * counter[before]
    sum_res += after * counter[before]
    counter[after] += counter[before]
    counter[before] = 0
    print(sum_res)
Buggy python submission (verdict: Runtime Error):
N = input()
A = list(map(int,input().split(' ')))
if 0 in A:
    print(0)
    exit()
x = 1
for a in A:
    x *= a
    if x > 1000000000000000000:
        print(-1)
        exit()
print(x)

Fixed submission:
A, B = map(int,input().split(' '))
print(A*B)