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

Fixed submission:
import sys
sys.setrecursionlimit(10**5)

N, M = map(int, input().split())
#dp[v]: start from v maxpath
dp = [-1 for _ in range(N)]

gragh = [[] for _ in range(N)]
for _ in range(M):
    x,y = map(int, input().split())
    gragh[x-1].append(y-1)

#solve DAG and topological sort by memo recursive funciton
def f(v,G=gragh):
    if dp[v] != -1:
        return dp[v]
    ret = 0
    for u in G[v]:
        ret = max(ret, f(u) + 1)
    dp[v] = ret
    return ret
for v in range(N):
    dp[v] = f(v)
print(max(dp))

Buggy submission (verdict: Runtime Error):
import numpy as np
sys.setrecursionlimit(10**5)

N, M = map(int, input().split())
#dp[v]: start from v maxpath
dp = np.ones((N),dtype=int) * -1

gragh = [[] for i in range(N)]
for _ in range(M):
    x,y = map(int, input().split())
    gragh[x-1].append(y-1)

#solve DAG and topological sort by recursive funciton
def f(v,G=gragh):
    if dp[v] != -1:
        return dp[v]
    ret = 0
    for u in G[v]:
        ret = max(ret, f(u) + 1)
    return ret
for v in range(N):
    dp[v] = f(v)
print(np.max(dp))

Buggy submission (verdict: Runtime Error):
import numpy as np

N, M = map(int, input().split())
#dp[v]: start from v maxpath
dp = np.ones((N),dtype=int) * -1

gragh = [[] for i in range(N)]
for _ in range(M):
    x,y = map(int, input().split())
    gragh[x-1].append(y-1)

#solve DAG and topological sort by recursive funciton
def f(v,G=gragh):
    if dp[v] != -1:
        return dp[v]
    ret = 0
    for u in G[v]:
        ret = max(ret, f(u) + 1)
    return ret
for v in range(N):
    dp[v] = f(v)
print(np.max(dp))
Problem p03174 (python)

Fixed submission:
N = int(input())
dp = [0] * (1 << N)
dp[0] = 1
MOD = 10 ** 9 + 7
now = {0}
for _ in range(N):
    mat = [1<<i for i, v in enumerate(input().split()) if v == '1']
    nxt = set()
    for k in now:
        p = dp[k] % MOD
        for m in mat:
            if k & m: # 1101 & 0100 3番目の人はすでにペアになっているためはじく
                continue
            dp[k | m] += p # 1001 | 0010 = 1101
            nxt.add(k | m)
    now = nxt
print(dp[-1] % MOD) #dp[11...11]が答えになる

Buggy submission (verdict: Runtime Error):
N = int(input())
dp = [0] * (1 << N)
dp[0] = 1
MOD = 10 ** 9 + 7
now = {0}
for _ in range(N):
    mat = [1<<i for i, v in enumerate(input().split()) if v == '1']
    nxt = set()
    for k in now:
        p = dp[k] % MOD
        for m in mat:
            if k & m: # 1101 & 0100 3番目の人はすでにペアになっているためはじく
                continue
            dp[k | m] += p # 1001 | 0010 = 1101
            nxt.add(k | m)
    now = nxt
print(dp[-1] % MOD) #dp[11...11]が答えになる
Problem p03245 (python)

Fixed submission:
n = int(input())
grid = [list(map(int, input().split())) for i in range(n)]

for i in range(n - 1):
    if (grid[i][0] + grid[i][1]) % 2 != (grid[i + 1][0] + grid[i + 1][1]) % 2:
        print(-1)
        exit()
m = 31
D = [2 ** i for i in range(m)]
if (grid[0][0] + grid[0][1]) % 2 == 0:
    D.insert(0, 1)
    m += 1
w = [[] for i in range(n)]
for i, g in enumerate(grid):
    x, y = g
    for d in D[::-1]:
        if abs(x) >= abs(y):
            if x > 0:
                x -= d
                w[i].append('R')
            else:
                x += d
                w[i].append('L')
        else:
            if y > 0:
                y -= d
                w[i].append('U')
            else:
                y += d
                w[i].append('D')

print(m)
print(*D)
for ans in w:
    print(*ans[::-1], sep='')

Buggy submission (verdict: Runtime Error):
n = int(input())
grid = [list(map(int, input().split())) for i in range(n)]

for i in range(n):
    if (grid[i][0] + grid[i][1]) % 2 != (grid[i][0] + grid[i][1]) % 2:
        print(-1)
        exit()
m = 31
D = [2 ** i for i in range(m)]
if (grid[0][0] + grid[0][1]) % 2 == 0:
    d.insert(0, 1)
w = [[] for i in range(n)]
for i, g in enumerate(grid):
    x, y = g
    for d in D[::-1]:
        if abs(x) >= abs(y):
            if x > 0:
                x -= d
                w[i].append('L')
            else:
                x += d
                w[i].append('R')
        else:
            if y > 0:
                y -= d
                w[i].append('D')
            else:
                y += d
                w[i].append('U')

print(m)
print(*D)
for ans in w:
    print(*ans[::-1], sep='')
Problem p03267 (python)

Fixed submission:
L = int(input())
b = format(L, 'b')
n = len(b)
m = 2 * (n - 1) + b.count('1') - 1
print(n, m)
for i in range(1, n):
    print(i, i + 1, 0)
    print(i, i + 1, 2 ** (i - 1))
w = 2 ** (n - 1)
for j in range(20,-1,-1):
    if (L - w) >> j & 1:
        print(j + 1, n, w)
        w += 2 ** j

Buggy submission (verdict: Runtime Error):
L = int(input())
n = len(format(L - 1, 'b')) + 1
m = 2 ** (n - 1) + format(L - 1, 'b').count('1') - 1
print(n, m)
for i in range(n - 1):
    print(i + 1, i + 2, 0)
    print(i + 1, i + 2, 2 ** i)
w = 2 ** (n - 1)
b = int(format(L - 1, 'b')[1:], 2)
for j in range(20, -1, -1):
    if b >> j & 1:
        print(j + 1, n, w)
        w += 2 ** j
Problem p03282 (python)

Fixed submission:
s = input()
k = int(input())
s = s[:k]
for c in s:
    if c == '1':
        continue
    else:
        print(c)
        break
else:
    print(1)

Buggy submission (verdict: Runtime Error):
s = input()
k = int(input())
for i in range(k+1):
    if s[i] == '1':
        continue
    else:
        print(s[i])
        break
else:
    print('1')
Problem p03351 (python)

Fixed submission:
a, b, c, d = map(int, input().split())
print('Yes' if (abs(a-b) <= d and abs(b-c) <= d) or abs(a-c) <= d else 'No')

Buggy submission (verdict: Runtime Error):
, b, c, d = map(int, input().split())
print('Yes' if (abs(a-b) <= d and abs(b-c) <= d) or abs(a-c) <= d else 'No')
Problem p03399 (python)

Fixed submission:
a = int(input())
b = int(input())
c = int(input())
d = int(input())
print(min(a, b) + min(c, d))

Buggy submission (verdict: Runtime Error):
 = int(input())
b = int(input())
c = int(input())
d = int(input())
print(min(a, b) + min(c, d))
Problem p03469 (python)

Fixed submission:
s = input()
s = '2018' + s[4:]
print(s)

Buggy submission (verdict: Runtime Error):
#input
n, h = map(int, input().split())
A = []
B = []
for i in range(n):
    a, b = map(int,input().split())
    A.append(a)
    B.append(b)
#manipulation
count = 0
a = max(A)
B.sort(reverse=True)
for b in B:
    if (b > a) & (h > 0):
        h -= b
        count += 1
count += (h + a - 1) // a
#output
print(count)
Problem p03599 (python)

Fixed submission:
a, b, c, d, e, f = map(int, input().split())
density = 0
for water_a in range(0,3001,a * 100):
    for water_b in range(0,3001,b * 100):
        if water_a + water_b > f:
            break
        for suger_c in range(0,3001,c):
            if water_a + water_b + suger_c > f:
                break
            for suger_d in range(0,3001,d):
                if water_a + water_b + suger_c + suger_d > f:
                    break
                if e * (water_a + water_b) - 100 * (suger_c + suger_d) < 0:
                    break
                water = water_a + water_b
                suger = suger_c + suger_d
                if water + suger == 0:
                    break
                if 1 >= suger / (water + suger) >= density:
                    sugerwater = water + suger
                    meltsuger = suger
                    density = suger / (water + suger)
print(sugerwater, meltsuger)

Buggy submission (verdict: Runtime Error):
a, b, c, d, e, f = map(int, input().split())
density = 0
for water_a in range(0,3001,a * 100):
    for water_b in range(0,3001,b * 100):
        if water_a + water_b > f:
            break
        for suger_c in range(0,3001,c):
            if water_a + water_b + suger_c > f:
                break
            for suger_d in range(0,3001,d):
                if water_a + water_b + suger_c + suger_d > f:
                    break
                if e * (water_a + water_b) - 100 * (suger_c + suger_d) < 0:
                    break
                water = water_a + water_b
                suger = suger_c + suger_d
                if water + suger == 0:
                    break
                if 1 >= suger / (water + suger) > density:
                    sugerwater = water + suger
                    meltsuger = suger
                    density = suger / (water + suger)
print(sugerwater, meltsuger)
Problem p03681 (python)

Fixed submission:
n, m = map(int, input().split())
mod = 10 ** 9 + 7


def n_factorial_mod(n, mod):
    ret = 1
    while n != 1:
        ret = ret * n % mod
        n -= 1
    return ret


if abs(n - m) > 1:
    print(0)
elif abs(n - m) == 1:
    print(n_factorial_mod(n, mod) * n_factorial_mod(m, mod) % mod)
else:
    print(2 * n_factorial_mod(n, mod) * n_factorial_mod(m, mod) % mod)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
mod = 10 ** 9 + 7


def n_factorial_mod(n, mod):
    ret = 1
    while n != 1:
        ret = ret * n % mod
        n -= 1
    return ret


if abs(n - m) > 1:
    print(0)
elif abs(n - m) == 1:
    print(n_factorial_mod(n, mod) * n_factorial_mod(m, mod) % mod)
else:
    print(2 * n_factorial_mod(n, mod) * n_factorial_mod(m, mod) % mo
d)
Problem p03722 (python)

Fixed submission:
N, M = map(int, input().split())
egdes = [list(map(int, input().split())) for _ in range(M)]

INF = 10 ** 13

G = [[INF] * (N + 1) for _ in range(N + 1)]
for a, b, c in egdes:
    G[a][b] = -c
dist = [INF] * (N + 1)
dist[1] = 0
for _ in range(N - 1):
    for a, b, c in egdes:
        dist[b] = min(dist[b], dist[a] - c)
ans = dist[N]
for a, b, c in egdes:
    dist[b] = min(dist[b], dist[a] - c)
print(-ans if ans == dist[N] else 'inf')

Buggy submission (verdict: Runtime Error):
import sys

sys.setrecursionlimit(10 ** 9)

N, M = map(int, input().split())
egdes = [list(map(int, input().split())) for _ in range(M)]

INF = 10 ** 13
G = [[] for _ in range(N + 1)]
for a, b, c in egdes:
    G[a].append((b, c))

# ループをチェックしてコストが正ならinf
def check_loop(a, b, d):
    if a == b:
        return d > 0
    ret = False
    for to, c in G[a]:
        d += c
        ret |= check_loop(to, b, d)
    return ret


for a, b, c in egdes:
    if a > b:
        if check_loop(a, b, c):
            print('inf')
            exit()

# 動的計画法のために隣接行列
G = [[-INF] * (N + 1) for _ in range(N + 1)]
for a, b, c in egdes:
    G[a][b] = c
dp = [-INF] * (N + 10)
dp[1] = 0
for i in range(1, N + 1):
    for j in range(1, i):
        dp[i] = max(dp[i], dp[j] + G[j][i])
print(dp[N])

Buggy submission (verdict: Runtime Error):
import sys

sys.setrecursionlimit(100000)

N, M = map(int, input().split())
egdes = [list(map(int, input().split())) for _ in range(M)]

INF = 10 ** 13
G = [[] for _ in range(N + 1)]
for a, b, c in egdes:
    G[a].append((b, c))

# ループをチェックしてコストが正ならinf
def check_loop(a, b, d):
    if a == b:
        return d > 0
    ret = False
    for to, c in G[a]:
        d += c
        ret |= check_loop(to, b, d)
    return ret


for a, b, c in egdes:
    if a > b:
        if check_loop(a, b, 0):
            print('inf')
            exit()

# 動的計画法のために隣接行列
G = [[-INF] * (N + 1) for _ in range(N + 1)]
for a, b, c in egdes:
    G[a][b] = c
dp = [-INF] * (N + 10)
dp[1] = 0
for i in range(1, N + 1):
    for j in range(1, i):
        dp[i] = max(dp[i], dp[j] + G[j][i])
print(dp[N])

Buggy submission (verdict: Runtime Error):
import sys

sys.setrecursionlimit(100000)

N, M = map(int, input().split())
egdes = [list(map(int, input().split())) for _ in range(M)]

INF = 10 ** 13
G = [[] for _ in range(N + 1)]
for a, b, c in egdes:
    G[a].append((b, c))

# ループをチェックしてコストが正ならinf
def check_loop(a, b, d):
    if a == b:
        return d > 0
    ret = False
    for to, c in G[a]:
        d += c
        ret |= check_loop(to, b, d)
    return ret


for a, b, c in egdes:
    if a > b:
        if check_loop(a, b, 0):
            print('inf')
            exit()

# 動的計画法のために隣接行列
G = [[-INF] * (N + 1) for _ in range(N + 1)]
for a, b, c in egdes:
    G[a][b] = c
dp = [-INF] * (N + 1)
dp[1] = 0
for i in range(1, N + 1):
    for j in range(1, i):
        dp[i] = max(dp[i], dp[j] + G[j][i])
print(dp[N])
Problem p03799 (python)

Fixed submission:
n, m = map(int, input().split())
c = m - 2*n
if c <= 0:
    print(m//2)
else:
    print(n + c//4)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
c = m - 2*n
if c <= 0:
    pirnt(m//2)
else:
    print(n + c//4)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
c = m - 2*n
if c <= 0:
    pirnt(n)
else:
    print(n + c//4)
Problem p04013 (python)

Fixed submission:
n, a = map(int, input().split())
x = list(map(int, input().split()))
X = max(x)
y = [i - a for i in x]
dp = [[0 for t in range(2 * n * X + 10)] for j in range(n + 1)]
dp[0][n * X] = 1
for j in range(1, n + 1):
    for t in range(2 * n * X + 1):
        if 0 <= t - y[j - 1] <= 2 * n * X:
            dp[j][t] = dp[j - 1][t] + dp[j - 1][t - y[j - 1]]
        else:
            dp[j][t] = dp[j - 1][t]
print(dp[n][n * X] - 1)

Buggy submission (verdict: Runtime Error):
n, a = map(int, input().split())
x = list(map(int, input().split()))
dp = [[[0 for s in range(n * 50)] for k in range(n + 1)] for j in range(n + 1)]
for j in range(n + 1):
    for k in range(n + 1):
        for s in range(n * 50):
            if (j == 0) and (k == 0) and (s == 0):
                dp[j][k][s] = 1
            elif (j > 0) and (s < x[j - 1]):
                dp[j][k][s] = dp[j - 1][k][s]
            elif (j > 0) and (k > 0) and (s >= x[j - 1]):
                dp[j][k][s] = dp[j - 1][k][s] + dp[j - 1][k - 1][s - x[j - 1]]
ans = 0
for k in range(1, n + 1):
    ans += dp[j][k][k * a]
print(ans)
Problem p02789 (python)

Fixed submission:

a = list(map(int, input().split()))
if(a[0] >a[1]):
  print("No")
else:
  print("Yes")

Buggy submission (verdict: Runtime Error):
a = map(int, input().split())
if(a[0] >a[1]):
  print("No")
else:
  print("Yes")
Problem p02612 (python)

Fixed submission:
n = int(input())
tmp = 10000-n
s = tmp%1000

print(s)

Buggy submission (verdict: Runtime Error):
n = input()
tmp = int(n[-3])
if tmp==0:
    print(0)
else:
    print((10-tmp)*100)
Problem p02658 (python)

Fixed submission:
n = int(input())
ls = list(map(int, input().split()))
res = 1
if 0 in ls:
    print(0)
    quit()
for x in ls:
    res *= x
    if res > 10**18:
        print(-1)
        quit()
print(res)

Buggy submission (verdict: Runtime Error):
n = int(input())
ls = list(map(int, input().split()))
res = 1
if 0 in ls:
    res = 0
for x in ls:
    res *= x
    if res > 10**18:
        res = -1
     	break
print(res)
Problem p02700 (python)

Fixed submission:
a, b, c, d = map(int, input().split())
while True:
    c -= b
    if c <= 0:
        print('Yes')
        break
    a -= d
    if a <= 0:
        print('No')
        break

Buggy submission (verdict: Runtime Error):
a, b, c, d = map(int, input().split())
while True:
	c -= b
	a -= d
    if c <= 0:
        print('Yes')
        break
    if a <= 0:
        print('No')
        break
Problem p02706 (python)

Fixed submission:
N, M = map(int, input().split())
A = list(map(int, input().split()))
daytofinish = sum(A)
if N-daytofinish < 0:
    print(-1)
else:
    print(N-daytofinish)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = list(map(int, input().split()))
daytofinish = sum(A)
print(N-daytofinish)
N, M = map(int, input().split())
A = list(map(int, input().split()))
daytofinish = sum(A)
if N-daytofinish < 0:
    print(-1)
else:
    print(N-daytofinish)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input.split())
a = list(map(int, input.split()))
final = sum(a)
if n > 0:
    print(n - a)
else:
    print(-1)
Problem p02719 (python)

Fixed submission:
n, k = map(int, input().split())
if n==0 or k==1:
    print(0)
    exit()
elif n<k:
    print(min(n, abs(n-k)))
    exit()
elif n % k == 0:
    print(0)
    exit()
else:
    mx = n%k
print(min(abs(mx-k), mx))

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
N = (N - K)
container = []
result = 0
for i in range(int(N)):
    result = abs(i - N)
    container.append(result)
print(container[-1])

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
N = (N - K)
container = []
result = 0
for i in range(int(N)):
    result = abs(i - N)
    container.append(result)
print(min(container))
Problem p02741 (python)

Fixed submission:
container = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
unser = int(input())
print(container[unser - 1])

Buggy submission (verdict: Runtime Error):
container = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
unser = int(input())
print(container[unser])
Problem p02630 (python)

Fixed submission:
N = int(input())
A = [int(x) for x in input().split()]
Q = int(input())
B = [[int(i) for i in input().split()] for Q in range(Q)]

p = [0]*100001
for i in range(N):
    p[A[i]] += 1

cnt = 0
for j in range(100001):
    cnt += p[j]*j

for i in range(Q):
    cnt = cnt + (B[i][1]- B[i][0]) * p[B[i][0]]

    p[B[i][1]] += p[B[i][0]]
    p[B[i][0]] = 0

    print(cnt)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(x) for x in input().split()]
Q = int(input())
B = [[int(i) for i in input().split()] for Q in range(Q)]

p = [0]*100000
for i in range(N):
    p[A[i]] += 1

cnt = 0
for j in range(100000):
    cnt += p[j]*j

for i in range(Q):
    cnt = cnt + (B[i][1]- B[i][0]) * p[B[i][0]]
    
    p[B[i][1]] += p[B[i][0]]
    p[B[i][0]] = 0

    print(cnt)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(x) for x in input().split()]
Q = int(input())
B = [[int(i) for i in input().split()] for Q in range(Q)]

p = [0]*100000
for i in range(N):
    p[A[i]] += 1

for i in range(Q):
    p[B[i][1]] += p[B[i][0]]
    p[B[i][0]] = 0

    cnt = 0
    for j in range(100000):
        cnt += p[j]*j
    print(cnt)
Problem p02727 (python)

Fixed submission:
X,Y,A,B,C = (int(x) for x in input().split())
p = [int(x) for x in input().split()]
q = [int(x) for x in input().split()]
r = [int(x) for x in input().split()]

p = sorted(p, reverse=True)
q = sorted(q, reverse=True)
r = sorted(r, reverse=True)

p.append(0)
q.append(0)
r.append(0)
for i in range(X,A):
    p[i] = 0
for i in range(Y,B):
    q[i] = 0

a = 0
b = 0
c = 0
cnt = 0

for i in range(X+Y):
    if (not a == X) and p[a] >= q[b] and p[a] >= r[c]:
        cnt += p[a]
        a += 1
    elif (not b == Y) and q[b] >= r[c]:
        cnt += q[b]
        b += 1
    else:
        cnt += r[c]
        c += 1
print(cnt)

Buggy submission (verdict: Runtime Error):
X,Y,A,B,C = (int(x) for x in input().split())
p = [int(x) for x in input().split()]
q = [int(x) for x in input().split()]
r = [int(x) for x in input().split()]

p = sorted(p, reverse=True)
q = sorted(q, reverse=True)
r = sorted(r, reverse=True)

r.append(0)
for i in range(X,A):
    p[i] = 0
for i in range(Y,B):
    q[i] = 0

a = 0
b = 0
c = 0
cnt = 0

for i in range(X+Y):
    if (not a == X) and p[a] >= q[b] and p[a] >= r[c]:
        cnt += p[a]
        a += 1
    elif (not b == Y) and q[b] >= r[c]:
        cnt += q[b]
        b += 1
    else:
        cnt += r[c]
        c += 1
print(cnt)
Problem p02686 (python)

Fixed submission:
# input
N = int(input())
S = [input() for _ in range(N)]

# process
T = []
for s in S:
    while '()' in s:
        s = s.replace('()', '')
    T.append(s)

l1 = []
l2 = []
for t in T:
    op = t.find('(')
    if op < 0:
        op = len(t)
    cl = len(t) - op
    
    if cl+op != 0:
        if cl <= op:
            l1.append((cl, op))
        else:
            l2.append((op, cl))

l1.sort()
l2.sort(reverse=True)

result = False
x = 0
if len(l1)+len(l2) == 0:
    result = True
elif len(l1)>0 and len(l2)>0 and l1[0][0]+l2[-1][0] == 0:
    for cl, op in l1:
        x -= cl
        if x < 0:
            break
        x += op
    
    if x >= 0:
        for op, cl in l2:
            x -= cl
            if x < 0:
                break
            x += op
            
        if x == 0:
            result = True

# output
print("Yes" if result else "No")

Buggy submission (verdict: Runtime Error):
# input
N = int(input())
S = [input() for _ in range(N)]

# process
l1 = []
l2 = []
for s in S:
    i=0
    a = 0
    b = 0
    while i < len(s) and s[i] == ')':
        a += 1
        i += 1
    while i < len(s):
        if s[i] == '(':
            b += 1
        else:
            b -= 1
        i += 1
    
    if a+b != 0:
        if a <= b:
            l1.append((a, b))
        else:
            l2.append((b, a))

l1.sort()
l2.sort(reverse=True)

result = False
x = 0
if l1[0][0] == 0 and l2[-1][0] == 0:
    for a, b in l1:
        x += b-a
    for b, a in l2:
        x += b-a

    if x == 0:
        result = True

# output
print("Yes" if result else "No")
Problem p02690 (python)

Fixed submission:
# input
X = int(input())

# process
a, b = 0, 0

nl = []
i = 0
np = 0
n = i**5
while n - np <= 10**9:
    nl.append(n)
    i += 1
    np = n
    n = i**5

for i in range(len(nl)):
    t = X-nl[i]
    if t in nl:
        a = i
        b = -(nl.index(t))
        break

    if -t in nl:
        a = i
        b = nl.index(-t)
        break

# output
print("{} {}".format(a, b))

Buggy submission (verdict: Runtime Error):
# input
X = int(input())

# process
a, b = 0, 0

nl = []
i = 0
np = 0
n = i**5
while n - np <= 10**9:
    nl.append(n)
    i += 1
    np = n
    n = i**5

for i in range(len(nl)):
    t = X-nl[i]
    if t in nl:
        a = i
        b = -(nl.index(X-nl[i]))
        break

    if -t in nl:
        a = i
        b = nl.index(X-nl[i])
        break

# output
print("{} {}".format(a, b))
Problem p02692 (python)

Fixed submission:
# input
N, A, B, C = map(int, input().split())
S = [input() for _ in range(N)]

# process
V = {"A":A, "B":B, "C":C}
S.append("XX")
op = ""
for i in range(N):
    s0, s1 = S[i]
    if V[s0] + V[s1] == 0:
        break
    
    x, y = s0, s1
    if V[s1] == 0 or (V[s0] != 0 and s1 in S[i+1]):
        x, y = s1, s0

    V[x] += 1
    V[y] -= 1
    op += x

# output
if len(op) != N:
    print("No")
else:
    print("Yes")
    [print(x) for x in op]

Buggy submission (verdict: Runtime Error):
# input
N, A, B, C = map(int, input().split())
S = [input() for _ in range(N)]
V = {"A":A, "B":B, "C":C}

# process
a, b, c = A, B, C
op = ""
for i, s in enumerate(S):
    s0 = s[0]
    s1 = s[1]
    if V[s0] + V[s1] == 0:
        break
    
    x, y = s0, s1
    if V[s1] == 0 or (i < N-1 and s1 in S[i+1]):
        x, y = s1, s0

    V[x] += 1
    V[y] -= 1
    op += x

    print("{} {} {}".format(s, V, op))

# output
if len(op) != N:
    print("No")
else:
    print("Yes")
    [print(x) for x in op]