Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N,M=map(int, input().split())

L=[]
R=[]

for i in range(M):
    a,b=map(int, input().split())
    L.append(a)
    R.append(b)


ans=max(R)-max(L)+1
if ans<0:
  print(0)
else:
  prnit(ans)

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

L=[]
R=[]

for i in range(M):
    a,b=map(int, input().split())
    L.append(a)
    R.append(b)

ans=min(R)-max(L)+1
print("0" if ans<0 else ans)

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

s=[[] for i in range(M)]

for i in range(M):
    L,R=map(int, input().split())
    for j in range(L,R+1):
        s[i].append(j)

for i in range(M-1):
    s=set(s[i]) & set(s[i+1])

print(len(s))

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

L=[]
R=[]

for i in range(M):
    a,b=map(int, input().split())
    L.append(a)
    R.append(b)

ans=min(R)-max(L)+1
print("0" if ans<0 else ans)

Buggy python submission (verdict: Time Limit Exceeded):
N,M=map(int, input().split())

L,R=map(int, input().split())
s=[i for i in range(L,R+1)]
t=[]
for i in range(M-1):
    L,R=map(int, input().split())
    t=[j for j in range(L,R+1)]
    s = set(s) & set(t)
    #print(s)

print(len(s))

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

L=[]
R=[]

for i in range(M):
    a,b=map(int, input().split())
    L.append(a)
    R.append(b)

ans=min(R)-max(L)+1
print("0" if ans<0 else ans)
Buggy python submission (verdict: Time Limit Exceeded):
N,M=map(int, input().split())
a=[int(i) for i in input().split()]
a.sort()
'''
for i in range(M):
    B,C=map(int, input().split())
    for j in range(B):
        if a[j]<C:
            a[j]=C   
    a.sort()

print(sum(a))
'''
for i in range(M):
    B,C=map(int, input().split())
    j=0
    while j<B:
        if a[j]>=C:
            break
        a[j]=C
        j+=1
    a.sort()
#    print(a)

print(sum(a))


Fixed submission:
N,M = map(int, input().split())
a = [int(i) for i in input().split()]
c = [[int(i) for i in input().split()] for j in range(M)]

a.sort()
c2=sorted(c,key=lambda x:(-int(x[1])))

d = []
for i in range(M):
    for j in range(c2[i][0]):
        d.append(c2[i][1])
        if len(d) == N:
            break
    else:
        continue
    break

i = 0
while a[i] < d[i]:
    a[i] = d[i]
    i += 1
    if i == N or i == len(d):
        break

print(sum(a))

Buggy python submission (verdict: Runtime Error):
N,M=map(int, input().split())
a=[int(i) for i in input().split()]
a.sort()
'''
for i in range(M):
    B,C=map(int, input().split())
    for j in range(B):
        if a[j]<C:
            a[j]=C   
    a.sort()

print(sum(a))
'''
for i in range(M):
    B,C=map(int, input().split())
    j=0
    while j<B:
        if a[j]>C:
            break
        a[j]=C
        j+=1
    a.sort()
    print(a)

print(sum(a))


Fixed submission:
N,M = map(int, input().split())
a = [int(i) for i in input().split()]
c = [[int(i) for i in input().split()] for j in range(M)]

a.sort()
c2=sorted(c,key=lambda x:(-int(x[1])))

d = []
for i in range(M):
    for j in range(c2[i][0]):
        d.append(c2[i][1])
        if len(d) == N:
            break
    else:
        continue
    break

i = 0
while a[i] < d[i]:
    a[i] = d[i]
    i += 1
    if i == N or i == len(d):
        break

print(sum(a))

Buggy python submission (verdict: Time Limit Exceeded):
N,M=map(int, input().split())
a=[int(i) for i in input().split()]
a.sort()

for i in range(M):
    B,C=map(int, input().split())
    for j in range(B):
        if a[j]<C:
            a[j]=C   
    a.sort()
#    print(a)

print(sum(a))

Fixed submission:
N,M = map(int, input().split())
a = [int(i) for i in input().split()]
c = [[int(i) for i in input().split()] for j in range(M)]

a.sort()
c2=sorted(c,key=lambda x:(-int(x[1])))

d = []
for i in range(M):
    for j in range(c2[i][0]):
        d.append(c2[i][1])
        if len(d) == N:
            break
    else:
        continue
    break

i = 0
while a[i] < d[i]:
    a[i] = d[i]
    i += 1
    if i == N or i == len(d):
        break

print(sum(a))
Buggy python submission (verdict: Runtime Error):
N=int(input())
a=[int(i) for i in input().split()]
 
count=0
ans=0
for i in range(N):
    if a[i]<0:
        c+=1        
    a[i]=abs(a[i])

if c%2==0:
    ans=sum(a)
else:
    a.sort()
    ans=sum(a)-a[0]

Fixed submission:
N = int(input())

a = [int(i) for i in input().split()]

count=0
ans=0

for i in range(N):
    if a[i]<0:
        count+=1
    a[i]=abs(a[i])

if count%2==0:
    ans=sum(a)

else:
    a.sort()
    ans=sum(a)-a[0]*2

print(ans)

Buggy python submission (verdict: Runtime Error):
N=int(input())
a=[int(i) for i in input().split()]
 
count=0
ans=0
for i in range(N):
    if a[i]<0:
        c+=1        
    a[i]=abs(a[i])

if c%2==0
    ans=sum(a)
else:
    a.sort()
    ans=sum(a)-a[0]

Fixed submission:
N = int(input())

a = [int(i) for i in input().split()]

count=0
ans=0

for i in range(N):
    if a[i]<0:
        count+=1
    a[i]=abs(a[i])

if count%2==0:
    ans=sum(a)

else:
    a.sort()
    ans=sum(a)-a[0]*2

print(ans)

Buggy python submission (verdict: Runtime Error):
N=int(input())
a=[int(i) for i in input().split()]

count=0
ans=0
for i in range(N):
    if a[i]<0:
        c+=1
        
a[i]=abs(a[i])
if c%2==0
    ans=sum(a)
else:
    a.sort()
    ans=sum(a)-a[0]

Fixed submission:
N = int(input())

a = [int(i) for i in input().split()]

count=0
ans=0

for i in range(N):
    if a[i]<0:
        count+=1
    a[i]=abs(a[i])

if count%2==0:
    ans=sum(a)

else:
    a.sort()
    ans=sum(a)-a[0]*2

print(ans)

Buggy python submission (verdict: Runtime Error):
N=int(input())
a=[int(i) for i in input().split()]

count=0
ans=0
for i in range(N):
    if a[i]<0:
        c+=1
        
a[i]=abs[i]
if c%2==0
    ans=sum(a)
else:
    a.sort()
    ans=sum(a)-a[0]

Fixed submission:
N = int(input())

a = [int(i) for i in input().split()]

count=0
ans=0

for i in range(N):
    if a[i]<0:
        count+=1
    a[i]=abs(a[i])

if count%2==0:
    ans=sum(a)

else:
    a.sort()
    ans=sum(a)-a[0]*2

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)
    
    # 根を検索する関数
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.find(self.par[x])
  
    # 結合(unite)する関数
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
    
    # 根が同じかどうか判定する関数
    def same_check(self, x, y):
        return self.find(x) == self.find(y)


if __name__ == "__main__":
    N,M = map(int, input().split())
    uf = UnionFind(N)

    A, B = [0] * M, [0] * M
    for i in range(M):
        A[i], B[i] = [int(j) for j in input().split()]

    total = int(N * (N-1) / 2)
    ans = []
    for i in range(M):
        count = 0
        for j in range(1,N):
            for k in range(j+1,N+1):
                if uf.same_check(j, k):
                    count += 1
        uf.union(A[-(i+1)], B[-(i+1)])
        ans.append(total - count)
    
    for i in (reversed(ans)):
        print(i)


Fixed submission:
class UnionFind_size:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.size = [1] * (n+1)
    
    # 根を検索する関数
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.find(self.par[x])
  
    # 結合(unite)する関数
    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.size[x] < self.size[y]:
            self.par[x] = y
            self.size[y] += self.size[x]
        else:
            self.par[y] = x
            self.size[x] += self.size[y]
           
    # 同じグループに属するかを判定する関数
    def same_check(self, x, y):
        return self.find(x) == self.find(y)
    
    # 要素が属する木のサイズを返す関数
    def get_size(self, x):
        return self.size[self.find(x)]
    
    # グループ数を返す関数
    def group_sum(self):
        c = 0
        for i in range(len(self.par)):
            if self.find(i) == i:
                c += 1
        return c


if __name__ == "__main__":
    N,M = map(int, input().split())
    uf = UnionFind_size(N)

    A, B = [0] * M, [0] * M
    for i in range(M):
        A[i], B[i] = [int(j) for j in input().split()]

    total = int(N * (N-1) / 2)
    ans = [total]
    for i in range(M-1):
        if uf.same_check(A[-(i+1)], B[-(i+1)]):
            ans.append(ans[i])
        else:
            ans.append(ans[i] - uf.get_size(A[-(i+1)]) * uf.get_size(B[-(i+1)]))
        uf.unite(A[-(i+1)], B[-(i+1)])
    
    for i in (reversed(ans)):
        print(i)
Buggy python submission (verdict: Time Limit Exceeded):
import sys

def main():
    N,M = map(int, input().split())
    PY_input = []
    PY_dict = {}
    for _ in range(M):
        p, y = map(int, sys.stdin.readline().split())
        PY_input.append((p, y))
        PY_dict.setdefault(p, []).append(y)

    for i in PY_dict.values():
        i.sort()

    for p, y in PY_input:
        print("{:06}{:06}".format(p, PY_dict[p].index(y)+1))


if __name__ == "__main__":
    main()


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

def main():
    N,M = map(int, input().split())
    PY_input = []
    PY_dict = {}
    for _ in range(M):
        p, y = map(int, input().split())
        PY_input.append((p, y))
        PY_dict.setdefault(p, []).append(y)

    for i in PY_dict.values():
        i.sort()

    for p, y in PY_input:
        print("{:06}{:06}".format(p, bisect.bisect_right(PY_dict[p], y)))


if __name__ == "__main__":
    main()

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

def main():
    N,M = map(int, input().split())
    PY_input = []
    PY = [[] for i in range(N+1)]
    for _ in range(M):
        p, y = map(int, sys.stdin.readline().split())
        PY_input.append((p, y))
        PY[p].append(y)

    for i in PY:
        i.sort()

    for p, y in PY_input:
        print("{:06}{:06}".format(p, PY[p].index(y)+1))


if __name__ == "__main__":
    main()


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

def main():
    N,M = map(int, input().split())
    PY_input = []
    PY_dict = {}
    for _ in range(M):
        p, y = map(int, input().split())
        PY_input.append((p, y))
        PY_dict.setdefault(p, []).append(y)

    for i in PY_dict.values():
        i.sort()

    for p, y in PY_input:
        print("{:06}{:06}".format(p, bisect.bisect_right(PY_dict[p], y)))


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
from collections import deque
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines


def bfs(field, d, sx, sy, gx, gy):
    queue = deque([(sx, sy)])
    d[sx][sy] += 1
    
    while queue:
        x, y = queue.popleft()
        if (x, y) == (gx, gy):
            return d[x][y]

        dx = [1, 0, -1, 0]
        dy = [0, 1, 0, -1]
        for i in range(4):
            nx = x + dx[i]
            ny = y + dy[i]
            
            # field内かつ障害物じゃないかつ未訪問なら追加
            if (0 <= nx <= gx and 0 <= ny <= gy
                and field[nx][ny] != "#" 
                and d[nx][ny] == -1):
                d[nx][ny] = d[x][y] + 1
                queue.append((nx, ny))

def main():
    H,W = map(int, readline().split())
    s = [readline() for i in range(H)]

    #スタートからの距離(-1は未訪問)
    d = [[-1]*W for i in range(H)]

    min_path = bfs(s, d, 0, 0, H-1, W-1) + 1

    black = 0
    for line in s:
        black += line.count("#")

    ans = H * W - min_path - black
    print(ans)


if __name__ == "__main__":
    main()


Fixed submission:
from collections import deque
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines


def bfs(field, d, sx, sy, gx, gy):
    queue = deque([(sx, sy)])
    d[sx][sy] += 1
    
    while queue:
        x, y = queue.popleft()
        if (x, y) == (gx, gy):
            return d[x][y]

        dx = [1, 0, -1, 0]
        dy = [0, 1, 0, -1]
        for i in range(4):
            nx = x + dx[i]
            ny = y + dy[i]
            
            # field内かつ障害物じゃないかつ未訪問なら追加
            if (0 <= nx <= gx and 0 <= ny <= gy
                and field[nx][ny] != "#" 
                and d[nx][ny] == -1):
                d[nx][ny] = d[x][y] + 1
                queue.append((nx, ny))

def main():
    H,W = map(int, readline().split())
    s = [readline() for i in range(H)]

    #スタートからの距離(-1は未訪問)
    d = [[-1]*W for i in range(H)]

    min_path = bfs(s, d, 0, 0, H-1, W-1)
    if min_path is not None:
        min_path += 1
    else:
        print(-1)
        exit()

    black = 0
    for line in s:
        black += line.count("#")

    ans = H * W - min_path - black
    print(ans)


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import math
import numpy as np

def eratos(n):
    if n == 1:
        return 0, 0
    prime_list = []
    #2からnumberまでの数字をsearch_listに入れる
    search_list = list(range(2,n+1))
    while True:
      #search_listの先頭の値が√nの値を超えたら処理終了
        if search_list[0] > math.sqrt(n):
            #prime_listにsearch_listを結合
            prime_list.extend(search_list)
            break
        else:
            #search_listの先頭をprime_listに入れる
            head_num = search_list[0]
            prime_list.append(head_num)
            #search_listの先頭をpopする
            search_list.pop(0)
            #head_numの倍数を取り除く
            search_list = [num for num in search_list if num % head_num != 0]

    p_list = np.array(prime_list)
    p_like = (p_list + 1) // 2
    inter = np.intersect1d(p_list, p_like)

    if (p_list[-1] + 1) // 2 == inter[-1]:
        return len(inter), 1
    else:
        return len(inter), 0


def main():
    Q = int(input())
    l = [None]*Q
    r = [None]*Q
    for i in range(Q):
        l[i], r[i] = map(int, input().split())
    
    for i in range(Q):
        R, _ = eratos(r[i])
        L, me = eratos(l[i])
        #print(l[i], L, r[i], R)
        print(R - L + me)


if __name__ == "__main__":
    main()


Fixed submission:
import math
import numpy as np

n = 10**5 + 1
p = [False] * n
c = [0] * n

def main():
    # 2からnまでの数字をsearch_listに入れる
    search_list = list(range(2,n))
    while True:
        # search_listの先頭の値が√nの値を超えたら処理終了
        if search_list[0] > math.sqrt(n):
            # search_listの残りの素数フラグを立てる
            for num in search_list:
                p[num] = True
            break
        else:
            # search_listの先頭の素数フラグを立てる
            tmp = search_list[0]
            p[tmp] = True
            # search_listの先頭をpopする
            search_list.pop(0)
            # search_listの先頭の倍数を取り除く
            search_list = [num for num in search_list if num % tmp != 0]

    # 1以上i以下のN-like数の数をc[i]とする
    for i in range(1,n):
        if p[i] and p[(i+1)//2]:
            c[i] = c[i-1] + 1
        else:
            c[i] = c[i-1]


    Q = int(input())
    for i in range(Q):
        l, r = map(int, input().split())
        print(c[r] - c[l-1])
    

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

ans = 1

for i in range(1,N+1):
    ans *= i

print(ans%(10**9+7))


Fixed submission:
N = int(input())

ans = 1

for i in range(1,N+1):
    ans *= i
    ans %= (10**9+7)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from heapq import heappop, heappush
from math import sqrt
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

INF = 10**15

def dijkstra(E, s, g):
    d = [INF] * len(E)
    d[0] = 0

    queue = []
    heappush(queue, (0, s))

    while queue:
        dist_v, v = heappop(queue)
        if dist_v > d[v]:
            continue
        
        for e, w in E[v]:
            tmp = d[v] + w
            if tmp < d[e]:
                d[e] = tmp
                heappush(queue, (tmp, e))
    
    return d[g]


def main():
    x_s, y_s, x_t, y_t = map(int, readline().split())
    N,*xyr = map(int, read().split())

    XYR = []
    XYR.append((x_s, y_s, 0))
    XYR.append((x_t, y_t, 0))
    for x, y, r in zip(*[iter(xyr)]*3):
        XYR.append((x, y, r))
    
    E = [[] for _ in range(N+2)]
    for i in range(N+1):
        x_i, y_i, r_i = XYR[i]
        for j in range(i+1, N+2):
            x_j, y_j, r_j = XYR[j]
            d = sqrt((x_i - x_j)**2 + (y_i - y_j)**2)
            d -= r_i + r_j
            d = max(0, d)
            E[i].append((j, d))
            E[j].append((i, d))

    ans = dijkstra(E, 0, 1)
    print(ans)


if __name__ == "__main__":
    main()


Fixed submission:
from heapq import heappop, heappush
from math import sqrt
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

INF = 10**15

def dijkstra(E, s, g):
    d = [INF] * len(E)
    d[0] = 0

    queue = []
    heappush(queue, (0, s))

    while queue:
        dist_v, v = heappop(queue)
        if dist_v > d[v]:
            continue
        
        for e, w in E[v]:
            tmp = d[v] + w
            if tmp < d[e]:
                d[e] = tmp
                heappush(queue, (tmp, e))
    
    return d[g]


def main():
    x_s, y_s, x_t, y_t = map(int, readline().split())
    N,*xyr = map(int, read().split())

    XYR = []
    XYR.append((x_s, y_s, 0))
    XYR.append((x_t, y_t, 0))
    for x, y, r in zip(*[iter(xyr)]*3):
        XYR.append((x, y, r))
    
    E = [[] for _ in range(N+2)]
    for i in range(N+1):
        x_i, y_i, r_i = XYR[i]
        for j in range(i+1, N+2):
            x_j, y_j, r_j = XYR[j]
            d = sqrt((x_i - x_j)**2 + (y_i - y_j)**2)
            d -= r_i + r_j
            d = max(0, d)
            E[i].append((j, d))
            E[j].append((i, d))

    ans = dijkstra(E, 0, 1)
    print(ans)


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
from collections import deque

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

A.sort(reverse=True)

deq = deque([A[0]])
ans = 0

for x in A[1:]:
    print(f"{deq=}, {x=}")
    ans += deq.popleft()
    deq.append(x)
    deq.append(x)

print(ans)


Fixed submission:
import sys
from collections import deque

read = sys.stdin.buffer.read

N, *A = map(int, read().split())
A.sort(reverse=True)

deq = deque([A[0]])
ans = 0

for x in A[1:]:
    ans += deq.popleft()
    deq.append(x)
    deq.append(x)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(4100000)

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

ans_cand = []

def dfs(a_i, b_i, ans, time):
    if time == K:
        ans_cand.append(ans)
        return 0

    if time > K:
        ans_cand.append(ans - 1)
        return 0

    if a_i < N:
        dfs(a_i + 1, b_i, ans + 1, time + A[a_i])
    if b_i < M:
        dfs(a_i, b_i + 1, ans + 1, time + B[b_i])
    return 0


dfs(0, 0, 0, 0)

print(max(ans_cand))


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

a, b = [0], [0]
for i in range(N):
    a.append(a[i] + A[i])
for i in range(M):
    b.append(b[i] + B[i])

ans = 0
j = M

for i in range(N + 1):
    if a[i] > K:
        break
    while b[j] > K - a[i]:
        j -= 1
    ans = max(ans, i + j)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(4100000)

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

ans_cand = []

def dfs(a_i, b_i, ans, time):
    if time == K:
        ans_cand.append(ans)
        return 0

    if time > K:
        ans_cand.append(ans - 1)
        return 0

    if a_i < N:
        dfs(a_i + 1, b_i, ans + 1, time + A[a_i])
    if b_i < M:
        dfs(a_i, b_i + 1, ans + 1, time + B[b_i])
    return 0


dfs(0, 0, 0, 0)

print(max(ans_cand))


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

a, b = [0], [0]
for i in range(N):
    a.append(a[i] + A[i])
for i in range(M):
    b.append(b[i] + B[i])

ans = 0
j = M

for i in range(N + 1):
    if a[i] > K:
        break
    while b[j] > K - a[i]:
        j -= 1
    ans = max(ans, i + j)

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

N, K = map(int, input().split())
p = list(map(int, input().split()))

ans = sum(p)
for v in itertools.permutations(p, K):
    ans = min(ans, sum(v))

print(ans)


Fixed submission:
import itertools

N, K = map(int, input().split())
p = list(map(int, input().split()))

ans = 0
for _ in range(K):
    min_index = p.index(min(p))
    minv = p.pop(min_index)
    ans += minv

print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
alphabet = [chr(ord('a') + i) for i in range(26)]
num2alphabet = {i + 1: a for i, a in enumerate(alphabet)}

ans = ""

while N > 0:
    num = N % 26
    ans += num2alphabet[num]
    N = N // 26

print(''.join(list(reversed(ans))))


Fixed submission:
import string

N = int(input())
alphabet = list(string.ascii_lowercase)
num2alphabet = {i + 1: a for i, a in enumerate(alphabet)}
num2alphabet[0] = "z"
ans = ""

while N > 0:
    num = N % 26
    ans += num2alphabet[num]
    if N <= 26:
        break

    if num == 0:
        N -= 1

    N = N // 26

print(''.join(list(reversed(ans))))

Buggy python submission (verdict: Runtime Error):
import string

N = int(input())
alphabet = [chr(ord('a') + i) for i in range(26)]
num2alphabet = {i + 1: a for i, a in enumerate(alphabet)}

ans = ""

while N > 0:
    num = N % 26
    ans += num2alphabet[num]
    N = N // 26

print(''.join(list(reversed(ans))))


Fixed submission:
import string

N = int(input())
alphabet = list(string.ascii_lowercase)
num2alphabet = {i + 1: a for i, a in enumerate(alphabet)}
num2alphabet[0] = "z"
ans = ""

while N > 0:
    num = N % 26
    ans += num2alphabet[num]
    if N <= 26:
        break

    if num == 0:
        N -= 1

    N = N // 26

print(''.join(list(reversed(ans))))

Buggy python submission (verdict: Runtime Error):
import string

N = int(input())
alphabet = list(string.ascii_lowercase)
num2alphabet = {i + 1: a for i, a in enumerate(alphabet)}

ans = ""

while N > 0:
    num = N % 26
    ans += num2alphabet[num]
    N = N // 26

print(''.join(list(reversed(ans))))


Fixed submission:
import string

N = int(input())
alphabet = list(string.ascii_lowercase)
num2alphabet = {i + 1: a for i, a in enumerate(alphabet)}
num2alphabet[0] = "z"
ans = ""

while N > 0:
    num = N % 26
    ans += num2alphabet[num]
    if N <= 26:
        break

    if num == 0:
        N -= 1

    N = N // 26

print(''.join(list(reversed(ans))))