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

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


def read_values():
    return map(int, input().split())


def read_list():
    return list(read_values())


def read_lists(N):
    return [read_list() for n in range(N)]


def root(P, C, a):
    if P[a] == a:
        return a
    r = a
    while P[r] != r:
        r = P[r] 
    
    P[a] = r
    C[a] = C[r]
    return r


def main():
    N, M = read_values()
    V = [read_list() for _ in range(M)]
    P = [i for i in range(N)]
    C = [1] * N
    res = [N * (N - 1) // 2] * M
    total = 0
    for i in range(M - 2, -1, -1):
        a, b = V[i + 1]
        a -= 1
        b -= 1

        ra = root(P, C, a)
        rb = root(P, C, b)
        if ra == rb:
            res[i] -= total
            continue

        P[ra] = rb
        total += C[ra] * C[rb]
        C[ra] += C[rb]
        C[rb] = C[ra]
        res[i] -= total

    print("\n".join(map(str, res)))
    

if __name__ == "__main__":
    main()

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

def read_values():
    return map(int, input().split())


def read_list():
    return list(read_values())


def read_lists(N):
    return [read_list() for n in range(N)]


def root(P, C, a):
    if P[a] == a:
        return a
    r = root(P, C, P[a])
    P[a] = r
    C[a] = C[r]
    return r


def main():
    N, M = read_values()
    V = [read_list() for _ in range(M)]
    P = [i for i in range(N)]
    C = [1] * N
    res = [N * (N - 1) // 2] * M
    total = 0
    for i in range(M - 2, -1, -1):
        a, b = V[i + 1]
        a -= 1
        b -= 1

        ra = root(P, C, a)
        rb = root(P, C, b)
        if ra == rb:
            res[i] -= total
            continue

        P[ra] = rb
        total += C[ra] * C[rb]
        C[ra] += C[rb]
        C[rb] = C[ra]
        res[i] -= total

    print("\n".join(map(str, res)))
    

if __name__ == "__main__":
    main()

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


def read_values():
    return map(int, input().split())


def read_list():
    return list(read_values())


def read_lists(N):
    return [read_list() for n in range(N)]


def root(P, C, a):
    if P[a] == a:
        return a
    r = root(P, C, P[a])
    P[a] = r
    C[a] = C[r]
    return r


def main():
    N, M = read_values()
    V = [read_list() for _ in range(M)]
    P = [i for i in range(N)]
    C = [1] * N
    res = [N * (N - 1) // 2] * M
    total = 0
    for i in range(M - 2, -1, -1):
        a, b = V[i + 1]
        a -= 1
        b -= 1

        ra = root(P, C, a)
        rb = root(P, C, b)
        if ra == rb:
            res[i] -= total
            continue

        P[ra] = rb
        total += C[ra] * C[rb]
        C[ra] += C[rb]
        C[rb] = C[ra]
        res[i] -= total

    print("\n".join(map(str,res)))
    

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

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

dp = [0]*(N+1)
acc = [0]*(N+1) # acc[i] = dp[1] + ... dp[i]

dp[1] = 1
acc[1] = 1
for i in range(2, N+1):
    for lr in LR:
        l = lr[0]
        r = lr[1]

        dp[i] += (acc[max(0, i - l)] - acc[max(0, i - r - 1)] + MOD)
        dp[i] %= MOD
    acc[i] = (acc[i-1] + dp[i]) % MOD
    
    

print(dp[N])
# print(acc)
# print(dp[N])

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

ans = X
A = X
TF = True
srt = 1000000
retu = dict()
retu[X] = 1
loop = X
for i in range(N-1):
    if TF:
        A = A**2 % M
        if retu.get(A) != None:
          srt = j
          goal = i
          TF = False
          break   
        if TF:
          retu[A] = 1
          loop += A
    else:
      break
      
if N-1 > srt:
    n = (N-srt)//(goal-srt+1)
    saisyo = sum(retu[:srt])
    loop -= saisyo
    print(saisyo + loop*n + sum(retu[srt:N-n*(goal-srt+1)]))
    
else:
    print(sum(retu[:N]))
Problem p02550 (python)

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

candicate = [pow(i, 2, M) for i in range(M)]
ans = 0
now = X
A = [0]
X2 = pow(X, 2, M)

d = dict()

flag = True
for i in range(1, N+1):
    if i == 1:
        A.append(X)
    
    else:
        nxt = candicate[A[i-1]]

        if d.get(nxt) == None:
            if nxt == 0:
                A.append(nxt)
                break
            else:
                A.append(nxt)
                d[nxt] = i

        else:
            flag = False
            break


if flag:
    print(sum(A))
else:
    l = d[nxt]
    r = i - 1
    circle_total = 0
    for j in range(l, r+1):
        circle_total += A[j]
    
    for j in range(1, l):
        ans += A[j]

    width = r - l + 1
    N -= (l - 1)
    ans += circle_total * (N // width)

    for j in range(l, l + N % width):
        ans += A[j]

    print(ans)

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

ans = X
A = X
TF = True
srt = 1000000
retu = [X]
d = dict()
d[X] = 0
loop = X
for i in range(N-1):
    if TF:
        A = A**2 % M
        if d.get(A) != None:
          srt = d[A] + 1
          goal = i
          TF = False
          
        if TF:
          retu.append(A)
          d[A] = i
          loop += A
    else:
      break
      
if N-1 > srt:
    n = (N-srt)//(goal-srt+1)
    saisyo = sum(retu[:srt])
    loop -= saisyo
    print(saisyo + loop*n + sum(retu[srt:N-n*(goal-srt+1)]))
    
else:
    print(sum(retu[:N]))

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

ans = X
A = X
TF = True
srt = 1000000
retu = dict()
retu[X] = 1
loop = X
for i in range(N-1):
    if TF:
        A = A**2 % M
        if retu.get(A) != None:
          srt = j
          goal = i
          TF = False
          break   
        if TF:
          retu[A] = 1
          loop += A
    else:
      break
      
if N-1 > srt:
    n = (N-srt)//(goal-srt+1)
    saisyo = sum(retu[:srt])
    loop -= saisyo
    print(saisyo + loop*n + sum(retu[srt:N-n*(goal-srt+1)]))
    
else:
    print(sum(retu[:N]))
Problem p02598 (python)

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

def p(length): # p = 1 => その長さに切り分けることは可能
    if length == 0:
        return 1

    tmp = 0
    for a in A:
        if a % length == 0:
            tmp += (a // length) - 1
        else:
            tmp += a // length
        if tmp > K:
            return 0
    
    # print("length", length, "tmp ", tmp)
    
    return 1
    

def bin_search(arr): #答え(最長の丸太の最小値)として取りうる最大値
    lb = 0
    ub = 1000000000

    while ub - lb > 1:
        mid = (ub + lb) // 2
        if p(mid) == 1:
            ub = mid
        else:
            lb = mid
    
    return lb

def just(num):
    if num == 0:
        return 0
        
    tmp = 0
    for a in A:
        if a % num != 0:
            return 0
        else:
            tmp += a // num
    if tmp != K:
        return 0
    else:
        return 1

ans_tmp = bin_search(A)
if just(ans_tmp) == 1:
    print(ans_tmp)
else:
    print(ans_tmp + 1)

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

def p(length): # p = 1 => その長さに切り分けることは可能
    if length == 0:
        return 1
        
    tmp = 0
    for a in A:
        if a % length == 0:
            tmp += (a // length) - 1
        else:
            tmp += a // length
        if tmp > K:
            return 0
    
    # print("length", length, "tmp ", tmp)
    
    return 1
    

def bin_search(arr): #答え(最長の丸太の最小値)として取りうる最大値
    lb = 0
    ub = 1000000000

    while ub - lb > 1:
        mid = (ub + lb) // 2
        if p(mid) == 1:
            ub = mid
        else:
            lb = mid
    
    return lb

def just(num):
    tmp = 0
    for a in A:
        if a % num != 0:
            return 0
        else:
            tmp += a // num
    if tmp != K:
        return 0
    else:
        return 1

ans_tmp = bin_search(A)
if just(ans_tmp) == 1:
    print(ans_tmp)
else:
    print(ans_tmp + 1)

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

def p(length): # p = 1 => その長さに切り分けることは可能
    tmp = 0
    for a in A:
        if a % length == 0:
            tmp += (a // length) - 1
        else:
            tmp += a // length
        if tmp > K:
            return 0
    
    # print("length", length, "tmp ", tmp)
    
    return 1
    

def bin_search(arr): #答え(最長の丸太の最小値)として取りうる最大値
    lb = 0
    ub = 1000000000

    while ub - lb > 1:
        mid = (ub + lb) // 2
        if p(mid) == 1:
            ub = mid
        else:
            lb = mid
    
    return lb

def just(num):
    tmp = 0
    for a in A:
        if a % num != 0:
            return 0
        else:
            tmp += a // num
    if tmp != K:
        return 0
    else:
        return 1

ans_tmp = bin_search(A)
if just(ans_tmp) == 1:
    print(ans_tmp)
else:
    print(ans_tmp + 1)
Problem p02688 (python)

Fixed submission:
N, K = map(int, input().split())
people = [1]*N
for i in range(K):
    d = int(input())
    A = list(map(int, input().split()))
    for j in range(d):
        if people[A[j] - 1] == 1:
            people[A[j] - 1] = 0

print(sum(people))

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
Sunuke = [0]*N
d = list()
A = list()
for _ in range(K):
  d = int(input()
  A = list(map(int, input().split()))
  for a in A:
    Sunuke[a-1] += 1

ans = 0
for s in Sunuke:
  if s == 0:
     ans += 1
print(ans)
Problem p02792 (python)

Fixed submission:
N = int(input())

c = [[0 for i in range(10)] for j in range(10)]
for i in range(N+1):
    str_i = str(i)
    c[int(str_i[0])][int(str_i[-1])] += 1

ans = 0
for i in range(1, 10):
    for j in range(1, 10):
        ans += c[i][j]*c[j][i]

print(ans)

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

c = [[0 for i in range(9)] for j in range(9)]
for i in range(9):
    for j in range(9):
        c[str(i)[0]][str(j)[-1]] += 1

ans = 0
for i in range(9):
    for j in range(9):
        ans += c[i][j]*c[j][i]

print(ans)

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

ans_1 = 0
for i in range(N):
  str_i = str(i)
  length = len(str_i)
  if str_i[0] == str_i[length-1]:
    ans_1 += 1

ans_2 = 0
half = N // 2
for i in range(half):
  if i <= 9:
    j = 0
    tmp_num =int(str(i)+str(j)+str(i))
    while tmp_num <= N:
      ans_2 += 1
      j += 1
      tmp_num =int(str(i)+str(j)+str(i))
   
  else:
    j = 0
    tmp_num =int(str(i[-1])+str(j)+str(i[0]))
    while tmp_num <= N:
      ans_2 += 1
      j += 1
      tmp_num =int(str(i[-1])+str(j)+str(i[0]))

print(ans_1+2*ans_2)

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

ans_1 = 0
for i in range(N):
  str_i = str(i)
  length = len(str_i)
  if str_i[0] == str_i[length-1]:
    ans_1 += 1

ans_2 = 0
for i in range(N // 2):
  if i <= 9:
    j = 0
    tmp_num =int(str(i)+str(j)+str(i))
    while tmp_num <= N:
      ans_2 += 1
      j += 1
      tmp_num =int(str(i)+str(j)+str(i))
   
  else:
    j = 0
    tmp_num =int(str(i[-1])+str(j)+str(i[0]))
    while tmp_num <= N:
      ans_2 += 1
      j += 1
      tmp_num =int(str(i[-1])+str(j)+str(i[0]))

print(ans_1+2*ans_2)
Problem p02819 (python)

Fixed submission:
X = int(input())

def get_sieve_of_eratosthenes_new(n):
    import math
    if not isinstance(n, int):
        raise TypeError('n is int type.')
    if n < 2:
        raise ValueError('n is more than 2')
    prime = []
    limit = math.sqrt(n)
    data = [i + 1 for i in range(1, n)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]

prime = get_sieve_of_eratosthenes_new(10**6)
for num in prime:
    if num >= X:
        print(num)
        break

Buggy submission (verdict: Runtime Error):
x= int(input())

def prime_check(num,count):
    if (num % count) != 0:
        if num <= count**2:
            return num
        else:
            return prime_check(num,count+1)
    else :
        return prime_check(num+1,2)

if x==2 :
    print (2)
else:
    print(prime_check(x,2))

Buggy submission (verdict: Runtime Error):
x= int(input())

def prime_check(num,count):
    if (num % count) != 0:
        if num <= count**2:
            print(num)
        else:
            prime_check(num,count+1)
    else :
        prime_check(num+1,2)

if x==2 :
    print (2)
else:
    print(prime_check(x,2))

Buggy submission (verdict: Runtime Error):
x= int(input())

def prime_check(num,count):
    if (num % count) != 0:
        if num <= count**2:
            return num
        else:
            return prime_check(num,count+1)
    else :
        return prime_check(num+1,2)

if x==2 :
    print (2)
else:
    prime_check(x,2)
Problem p02771 (python)

Fixed submission:
a,b,c=map(int,input().split())
ans="No"
if a==b:
  if b==c:
    ans="No"
  else:
    ans="Yes"
if b==c:
  if c==a:
    ans="No"
  else:
    ans="Yes"
if c==a:
  if a==b:
    ans="No"
  else:
    ans="Yes"
print(ans)

Buggy submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
if a==b:
  if b==c:
    ans="No"
  else:
    ans="Yes"
if b==c:
  if c==a:
    ans="No"
  else:
    ans="Yes"
if c==a:
  if a==b:
    ans="No"
  else:
    ans="Yes"
print(ans)
Problem p03038 (python)

Fixed submission:
n,m=map(int,input().split())
a=list(map(int,input().split()))
b=[]
sum=0
res=0
for i in range(m):
  d,e=map(int,input().split())
  b.append([e,d])
a.sort()
b.sort()
b.reverse()

for i in range(1,m):
  b[i][1]+=b[i-1][1]

id=0
if b[0][1]>0 and b[0][0]>a[0]:
  a[0]=b[0][0]
if n>=2:
  for i in range(1,n):
    while i>b[id][1]-1:
      id+=1

      if id>m-1:
        break
    if id>m-1:
      break
    if b[id][0]>a[i]:
      a[i]=b[id][0]
    else:
      break
for i in range(n):
  res+=a[i]
print(res)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=list(map(int,input().split()))
b=[]
sum=0
res=0
for i in range(m):
  d,e=map(int,input().split())
  b.append([e,d])
a.sort()
b.sort()
b.reverse()
for i in range(1,m):
  b[i][1]+=b[i-1][1]
m=0
if b[0][1]>0 and b[0][0]>a[0]:
  a[0]=b[0][0]
if n>=2:
  for i in range(1,n):
    while i>b[m][1]-1:
      m+=1
    if b[m][0]>a[i]:
      a[i]=b[m][0]
    else:
      break
for i in range(n):
  res+=a[i]
print(res)
Problem p03315 (python)

Fixed submission:
s=input()
num=0
for i in s:
  if i=="-":
    num-=1
  else:
    num+=1
print(num)

Buggy submission (verdict: Runtime Error):
s=input()
num=0
for i in s:
  if i=="-":
    num-=1
  else
    num+=1
print(num)
Problem p02598 (python)

Fixed submission:
def binary_search(c1, c2):
    m = (c1 + c2 + 1) // 2
    if abs(c1 - c2) <= 1:
        return m
    else:
        cnt = 0
        for i in a:
            cnt += (i - 1) // m
        #print(cnt, m)
        if cnt <= k:
            c2 = m
        else:
            c1 = m
        return binary_search(c1, c2)

n, k = map(int, input().split())
a = list(map(int, input().split()))
x = binary_search(0, 10 ** 9)
for i in range(x + 5, max(x - 5, 0), -1):
    cnt = 0
    for j in a:
        cnt += (j - 1) // i
    if cnt <= k:
        ans = i
print(ans if not k == 0 else max(a))

Buggy submission (verdict: Runtime Error):
def binary_search(c1, c2):
    m = (c1 + c2 + 1) // 2
    if abs(c1 - c2) <= 1:
        return m
    else:
        cnt = 0
        for i in a:
            cnt += i // m
        #print(cnt, m)
        if cnt <= k:
            c2 = m
        else:
            c1 = m
        return binary_search(c1, c2)

n, k = map(int, input().split())
a = list(map(int, input().split()))
x = binary_search(-1, 10 ** 9)
for i in range(x + 5, max(x - 5, 0), -1):
    cnt = 0
    for j in a:
        cnt += j // i
    if cnt <= k:
        ans = i
print(ans if not k == 0 else max(a))
Problem p02831 (python)

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

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
	
def lcm(x, y):
    return (x * y) // gcd(x, y)

print(lcm(a, b))

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
import math
def lcm(x, y):
    return (x * y) // math.gcd(x, y)

print(lcm(a, b))

Buggy submission (verdict: Runtime Error):
import math
a, b = map(int, input().split())
def lcm(x, y):
    return (x * y) // math.gcd(x, y)

print(lcm(a, b))

Buggy submission (verdict: Runtime Error):
import math
a, b = map(int, input().split())
c = math.gcd(a, b)
print(int(a * b / c))
Problem p02851 (python)

Fixed submission:
n, k = map(int, input().split())
a = list(map(int, input().split()))
b = [0] * (n + 1)
for i in range(1, n + 1):
    b[i] = b[i - 1] + a[i - 1]
for i in range(n + 1):
    b[i] -= i
    b[i] %= k
d = dict()
for i in range(min(n + 1, k)):
    if b[i] in d:
        d[b[i]] += 1
    else:
        d[b[i]] = 1
ans = []
j = min(n + 1, k)
for i in range(n):
    ans.append(d[b[i]])
    d[b[i]] -= 1
    if j <= n:
        if b[j] in d:
            d[b[j]] += 1
        else:
            d[b[j]] = 1
    j += 1
ans = sum(ans) - n
print(ans)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
a = list(map(int, input().split()))
b = [0] * (n + 1)
for i in range(1, n + 1):
    b[i] = b[i - 1] + a[i - 1]
for i in range(n + 1):
    b[i] -= i
    b[i] %= k
d = dict()
for i in range(k):
    if b[i] in d:
        d[b[i]] += 1
    else:
        d[b[i]] = 1
ans = []
j = k
for i in range(n):
    ans.append(d[b[i]])
    d[b[i]] -= 1
    if j <= n:
        if b[j] in d:
            d[b[j]] += 1
        else:
            d[b[j]] = 1
    j += 1
ans = sum(ans) - n
print(ans)
Problem p03253 (python)

Fixed submission:
def prime_factorize(n):
    ans = []
    for i in range(2, int(n ** (1 / 2)) + 1):
        while True:
            if not n % i == 0:
                break
            ans.append(i)
            n /= i
        if n == 1:
            break
    if n != 1:
        ans.append(int(n))
    return ans

def comb(n, r, p):
    x, y = 1, 1
    for i in range(n, n - r, -1):
        x *= i
        y *= i + r - n
        x %= p
        y %= p
    return pow(y, p - 2, p) * x % p

n, m = map(int, input().split())
mod = 10 ** 9 + 7
s = prime_factorize(m)
if m == 1:
    s = [1]
c = 0
d = s[0]
ans = 1
for i in range(len(s)):
    if d == s[i]:
        c += 1
    else:
        d = s[i]
        ans *= comb(n - 1 + c, c, mod)
        ans %= mod
        c = 1
ans *= comb(n - 1 + c, c, mod)
ans %= mod
if m == 1:
    ans = 1
print(ans)

Buggy submission (verdict: Runtime Error):
def prime_factorize(n):
    ans = []
    for i in range(2, int(n ** (1 / 2)) + 1):
        while True:
            if not n % i == 0:
                break
            ans.append(i)
            n /= i
        if n == 1:
            break
    if n != 1:
        ans.append(int(n))
    return ans

def comb(n, r, p):
    x, y = 1, 1
    for i in range(n, n - r, -1):
        x *= i
        y *= i + r - n
        x %= p
        y %= p
    return pow(y, p - 2, p) * x % p

n, m = map(int, input().split())
mod = 10 ** 9 + 7
s = prime_factorize(m)
c = 0
d = s[0]
ans = 1
for i in range(len(s)):
    if d == s[i]:
        c += 1
    else:
        d = s[i]
        ans *= comb(n - 1 + c, c, mod)
        ans %= mod
        c = 1
ans *= comb(n - 1 + c, c, mod)
ans %= mod
print(ans)
Problem p03745 (python)

Fixed submission:
from collections import deque

n = int(input())
a = list(map(int, input().split()))
b = []
if n >= 2:
    for i in range(n - 1):
        if a[i] != a[i + 1]:
            b.append(a[i])
    if b[len(b) - 1] != a[n - 1]:
        b.append(a[n - 1])
    l = len(b)
    m = 0
    ans = 1
    for i in range(l - 1):
        if m == 0:
            if b[i] < b[i + 1]:
                m = 1
            else:
                m = -1
        elif m == 1:
            if b[i] > b[i + 1]:
                ans += 1
                m = 0
        else:
            if b[i] < b[i + 1]:
                ans += 1
                m = 0
else:
    ans = 1
print(ans)

Buggy submission (verdict: Runtime Error):
from collections import deque

n = int(input())
a = list(map(int, input().split()))
b = []
for i in range(n - 1):
    if a[i] != a[i + 1]:
        b.append(a[i])
if b[len(b) - 1] != a[n - 1]:
    b.append(a[n - 1])
l = len(b)
m = 0
ans = 1
for i in range(l - 1):
    if m == 0:
        if b[i] < b[i + 1]:
            m = 1
        else:
            m = -1
    elif m == 1:
        if b[i] > b[i + 1]:
            ans += 1
            m = 0
    else:
        if b[i] < b[i + 1]:
            ans += 1
            m = 0
print(ans)
Problem p02557 (python)

Fixed submission:
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()
from collections import Counter
from random import randrange
def resolve():
    n = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))

    if Counter(A + B).most_common()[0][1] > n:
        print("No")
        return

    for i in range(n):
        if A[i] != B[i]:
            continue
        while 1:
            j = randrange(0, n)
            if A[i] != B[j] and A[j] != B[i]:
                B[i], B[j] = B[j], B[i]
                break
    print("Yes")
    print(*B)
resolve()

Buggy submission (verdict: Runtime Error):
from time import time
from random import randrange

n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
start = time()

for i in range(n):
    if A[i] != B[i]:
        continue
    while time() - start < 1.8:
        j = randrange(n)
        if A[i] != B[j] and A[j] != B[i]:
            B[i], B[j] = B[j], B[i]
            break
    else:
        print("No")
        return

print("Yes")
print(*B)
Problem p02629 (python)

Fixed submission:
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()
def resolve():
    n = int(input()) - 1
    res = []
    while 1:
        res.append(chr(ord('a') + n % 26))
        n = n // 26 - 1
        if n == -1:
            break

    res.reverse()
    print(''.join(res))
resolve()

Buggy submission (verdict: Runtime Error):
n = input()
ans = []
while n:
  n, r = divmod(n - 1, 26)
  ans.append(chr(ord('a') + r))
ans.reverse()
print(''.join(ans))

Buggy submission (verdict: Runtime Error):
n = input()
ans = []
while n:
  n, r = divmod(n - 1, 26)
  ans.append(chr(ord('a') + r))
ans.reverse()
print(''.join())