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

Fixed submission:
n = int(input())
t, a =map(int, input().split())
h = list(map(int, input().split()))
d_degree = 100000
ans = 0
for i in range(n):
    degree = t - h[i]*0.006
    if d_degree > abs(a - degree):
        d_degree = abs(a - degree)
        ans = i+1
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
t, a =map(int, input().split())
h = list(map(int, input().split()))
d_degree = 100000j
ans = 0
for i in range(n):
    degree = t - h[i]*0.006
    if d_degree > abs(a - degree):
        d_degree = abs(a - degree)
        ans = i+1
print(ans)
Problem p03289 (python)

Fixed submission:
s = input()
ans = 'WA'
if s[0] == 'A' and s[2:-1].count('C') == 1\
   and s.replace('A', '').replace('C', '').islower():
  ans = 'AC'
print(ans)

Buggy submission (verdict: Runtime Error):
s = input()
ans = 'WA'
if s[0] == 'A' and s[2:-1].count('C') == 1\
   s.replace('A', '').replace('C', '').islower():
  ans = 'AC'
print(ans)

Buggy submission (verdict: Runtime Error):
s = input()
ans = 'WA'
if s[0] == 'A' and s[2:-1].count('C') == 1\
   s.replace('A', '').replace('C', '').islower():
  ans = 'AC'
print(ans)nn
Problem p03292 (python)

Fixed submission:
a = sorted(map(int, input().split()))
ans = 0
for i, j in zip(a, a[1:]):
  ans += abs(j - i)
print(ans)

Buggy submission (verdict: Runtime Error):
a = map(int, input().split())
a.sort()
ans = 0
for i, j in zip(a, a[1:]):
  ans += abs(j - i)
print(ans)
Problem p03294 (python)

Fixed submission:
n = int(input())
a = map(int, input().split())
print(sum(x-1 for x in a))

Buggy submission (verdict: Runtime Error):
n = int(input())
a = map(int, input().split())
print(sum(x-1 for x in s))
Problem p03337 (python)

Fixed submission:
a, b = map(int, input().split())
print(max(a-b, a+b, a*b))

Buggy submission (verdict: Runtime Error):
a, b = map(int, input())
print(max(a-b, a+b, a*b))
Problem p03351 (python)

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

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

Fixed submission:
import sys
from collections import deque

readline = sys.stdin.readline
H, W = map(int, readline().split())
S = [['#'] * (W+2)] + [['#'] + list(readline().rstrip()) + ['#'] for _ in range(H)] + [['#'] * (W+2)] 
black = sum(row.count('#') for row in S) - 2*(W+2) - 2*H

# bfs
q = deque([(1, 1)])
S[1][1] = 1
direction = ((0, 1), (1, 0), (0, -1), (-1, 0))
while q:
    x, y = q.popleft()
    d = S[x][y]
    for dx, dy in direction:
        # print(x+dx, y+dy, S[x+dx][y+dy])
        if S[x+dx][y+dy] == '.':
            S[x+dx][y+dy] = d + 1
            q.append((x+dx, y+dy))
ans = -1
if S[H][W] != '.':
    ans = H*W - S[H][W] - black
print(ans)

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

readline = sys.stdin.readline
H, W = map(int, readline().split())
S = [['#'] * (W+2)] + [['#'] + list(readline().rstrip()) + ['#'] for _ in range(H)] + [['#'] * (W+2)] 
black = sum(row.count('#') for row in S) - 2*(W+2) - 2*H

# bfs
q = deque([(1, 1)])
S[1][1] = 1
direction = ((0, 1), (1, 0), (0, -1), (-1, 0))
while q:
    x, y = q.popleft()
    d = S[x][y]
    for dx, dy in direction:
        # print(x+dx, y+dy, S[x+dx][y+dy])
        if S[x+dx][y+dy] == '.':
            S[x+dx][y+dy] = d + 1
            q.append((x+dx, y+dy))
ans = -1
if S[H][W] != '#':
    ans = H*W - S[H][W] - black
print(ans)
Problem p03612 (python)

Fixed submission:
N = int(input())
P = list(map(int, input().split()))
ans = 0
for i in range(N-1):
    if i + 1 == P[i]:
        ans += 1
        P[i+1] = P[i]
if N == P[-1]:
    ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
P = list(map(int, input().split()))
ans = 0
for i in range(N):
    if i + 1 == P[i]:
        ans += 1
        P[i+1] = P[i]
print(ans)
Problem p03633 (python)

Fixed submission:
from fractions import gcd
from functools import reduce
import sys

lcm = lambda x, y : x*y // gcd(x, y)
N, *T = map(int, sys.stdin.read().split())
ans = reduce(lcm, T)
print(ans)

Buggy submission (verdict: Runtime Error):
from math import gcd
from functools import reduce
import sys

lcm = lambda x, y : x*y // gcd(x, y)
N, *T = map(int, sys.stdin.read().split())
ans = reduce(lcm, T)
print(ans)
Problem p02976 (python)

Fixed submission:
from sys import setrecursionlimit
setrecursionlimit(10 ** 8)

n, m = [int(i) for i in input().split()]
A = [[int(i) for i in input().split()] for i in range(m)]

if m % 2 == 1:
    print(-1)
    exit()

E = [[] for i in range(n + 1)]
used_e = [False] * m
ans = []

for i, (a, b) in enumerate(A):
    E[a].append((b, i))
    E[b].append((a, i))

used = [False] * (n + 1)

def dfs(prev, v):
    if used[v]:
        return
    used[v] = True
    cnt = 0

    for to, i in E[v]:
        dfs(v, to)
        if not used_e[i]:
            cnt += 1

    for to, i in E[v]:
        if cnt % 2 == 1 and to == prev:
            continue
        if not used_e[i]:
            ans.append((v, to))
            used_e[i] = True

dfs(0, 1)

for a in ans:
    print(*a)

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

if m % 2 == 1:
    print(-1)
    exit()

E = [[] for i in range(n + 1)]
used_e = [False] * m
ans = []

for i, (a, b) in enumerate(A):
    E[a].append((b, i))
    E[b].append((a, i))

used = [False] * (n + 1)

def dfs(v):
    if used[v]:
        return
    used[v] = True
    cnt = 0

    for to, i in E[v]:
        dfs(to)
        if not used_e[i]:
            cnt += 1

    if cnt % 2 == 1:
        cnt -= 1

    for to, i in E[v]:
        if not used_e[i] and cnt > 0:
            ans.append((v, to))
            used_e[i] = True

dfs(1)

for a in ans:
    print(*a)
Problem p02985 (python)

Fixed submission:
from sys import setrecursionlimit
setrecursionlimit(10 ** 8)

n, k = [int(i) for i in input().split()]
A = [[int(i) for i in input().split()] for j in range(n - 1)]
p = 10 ** 9 + 7

E = [[] for i in range(n + 1)]

for a, b in A:
    E[a].append(b)
    E[b].append(a)

visited = [False] * (n + 1)

def dfs(i, f, s):
    if visited[i]:
        return 1
    b = f + s
    visited[i] = True
    
    res = k - b
    s = f
    f = 1
    for v in E[i]:
        if visited[v]:
            continue
        res *= dfs(v, f, s)
        res %= p
        s += 1

    return res if res > 0 else 0

print(dfs(1, 0, 0) % p)

Buggy submission (verdict: Runtime Error):
n, k = [int(i) for i in input().split()]
A = [[int(i) for i in input().split()] for j in range(n - 1)]
p = 10 ** 9 + 7

E = [[] for i in range(n + 1)]

for a, b in A:
    E[a].append(b)
    E[b].append(a)

visited = [False] * (n + 1)

def dfs(i, f, s):
    if visited[i]:
        return 1
    b = f + s
    visited[i] = True
    
    res = k - b
    s = f
    f = 1
    for v in E[i]:
        if visited[v]:
            continue
        res *= dfs(v, f, s)
        res %= p
        s += 1

    return res if res > 0 else 0

print(dfs(1, 0, 0))

Buggy submission (verdict: Runtime Error):
n, k = [int(i) for i in input().split()]
A = [[int(i) for i in input().split()] for j in range(n - 1)]
p = 10 ** 9 + 7

E = [[] for i in range(n + 1)]

for a, b in A:
    E[a].append(b)
    E[b].append(a)

visited = [False] * (n + 1)

def dfs2(i, k):
    if k > 2:
        return 0
    res = 0
    for v in E[i]:
        res += dfs2(v, k + 1)
    return res + visited[i]

def dfs(i):
    if visited[i]:
        return 1
    b = dfs2(i, 0)
    visited[i] = True
    
    res = k - b
    for v in E[i]:
        res *= dfs(v)
        res %= p

    return res if res > 0 else 0

print(dfs(1))
Problem p03023 (python)

Fixed submission:
n = int(input())
print(180 * (n - 2))

Buggy submission (verdict: Runtime Error):
q = int(input())
Q = [[int(i) for i in input().split()] for j in range(q)]
p = 10 ** 6 + 3

def fact(n, p=10**9 + 7):
    f = [1]
    for i in range(1, n+1):
        f.append(f[-1]*i%p)
    return f

def invfact(n, f, p=10**9 + 7):
    inv = [pow(f[n], p-2, p)]
    for i in range(n, 0, -1):
        inv.append(inv[-1]*i%p)
    return inv[::-1]

f = fact(p - 1, p)
invf = invfact(p - 1, f, p)

for x, d, n in Q:
    if n >= p or x == 0:
        print(0)
        continue
    if d == 0:
        print(pow(x, n, p))
        continue
    
    inv_d = pow(d, p - 2, p)
    d_n = pow(d, n, p)
    x_over_d = x * inv_d % p

    if x_over_d + n - 1 >= p:
        print(0)
        continue

    print(d_n * f[x_over_d + n - 1] * invf[x_over_d - 1] % p)
Problem p03044 (python)

Fixed submission:
from sys import setrecursionlimit
setrecursionlimit(10 ** 9)

n = int(input())
U = [[int(i) for i in input().split()] for j in range(n - 1)]

E = [[] for i in range(n + 1)]

for u, v, w in U:
    E[u].append((v, w))
    E[v].append((u, w))

visited = [False] * (n + 1)
color = [0] * (n + 1)

def dfs(v, w):
    if visited[v]:
        return None
    visited[v] = True
    color[v] = 1 if w % 2 == 1 else 0
    for u, weight in E[v]:
        dfs(u, w + weight)

    return None

dfs(1, 0)

for c in color[1:]:
    print(c)

Buggy submission (verdict: Runtime Error):
n = int(input())
U = [[int(i) for i in input().split()] for j in range(n - 1)]

E = [[] for i in range(n + 1)]

for u, v, w in U:
    E[u].append((v, w))
    E[v].append((u, w))

visited = [False] * (n + 1)
color = [0] * (n + 1)

def dfs(v, w):
    if visited[v]:
        return None
    visited[v] = True
    color[v] = 1 if w % 2 == 1 else 0
    for u, weight in E[v]:
        dfs(u, w + weight)

    return None

dfs(1, 0)

for c in color[1:]:
    print(c)
Problem p03049 (python)

Fixed submission:
n = int(input())
S = [input() for i in range(n)]

ans = 0
start_b = 0
end_a = 0
ab = 0

for i in range(n):
    for j in range(len(S) - 1):
        if S[i][j:j+2] == 'AB':
            ans += 1

    if S[i][0] == 'B' and S[i][-1] == 'A':
        ab += 1
        continue 
    if S[i][0] == 'B':
        start_b += 1
    if S[i][-1] == 'A':
        end_a += 1
    

if ab > 0:
    ans += ab - 1
    if start_b > 0:
        ans += 1
        start_b -= 1
    if end_a > 0:
        ans += 1
        end_a -= 1
        
ans += min(start_b, end_a)

print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
S = [input() for i in range(n)]

ans = 0
start_b = 0
end_a = 0
ab = 0

for i in range(n):
    for j in range(len(S) - 1):
        if S[i][j] + S[i][j + 1] == 'AB':
            ans += 1

    if S[i][0] == 'B' and S[i][-1] == 'A':
        ab += 1
        continue 
    if S[i][0] == 'B':
        start_b += 1
    if S[i][-1] == 'A':
        end_a += 1
    

if ab > 0:
    ans += ab - 1
    if start_b > 0:
        ans += 1
        start_b -= 1
    if end_a > 0:
        ans += 1
        end_a -= 1
        
ans += min(start_b, end_a)

print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
S = [input() for i in range(n)]

ans = 0
start_b = 0
end_a = 0
ab = 0

for i in range(n):
    for j in range(len(S) - 1):
        if S[i][j] + S[i][j + 1] == 'AB':
            ans += 1

    if S[i][0] == 'B' and S[i][-1] == 'A':
        ab += 1
        continue 
    if S[i][0] == 'B':
        start_b += 1
    if S[i][-1] == 'A':
        end_a += 1
    

if ab > 0:
    ans += ab - 1
    if start_b > 0:
        ans += 1
        start_b -= 1
    if end_a > 0:
        ans += 1
        end_a -= 1
        
ans += min(start_b, end_a)

print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
S = [input() for i in range(n)]

ans = 0
start_b = 0
end_a = 0
ab = 0

for i in range(n):
    for j in range(len(S) - 1):
        if S[i][j] + S[i][j + 1] == 'AB':
            ans += 1

    if S[i][0] == 'B' and S[i][-1] == 'A':
        ab += 1
        continue 
    if S[i][0] == 'B':
        start_b += 1
    if S[i][-1] == 'A':
        end_a += 1
    

if ab > 0:
    ans += ab - 1
    if start_b > 0:
        ans += 1
        start_b -= 1
    if end_a > 0:
        ans += 1
        end_a -= 1
        
ans += min(start_b, end_a)

print(ans)
Problem p03081 (python)

Fixed submission:
n, m = [int(i) for i in input().split()]
S = input()
Q = [[i for i in input().split()] for j in range(m)]

def solve(i):
    cur = i
    for t, d in Q:
        if S[cur] == t:
            cur += 1 if d == 'R' else -1
        if cur < 0 or cur >= n:
            return False
    return True

def b_search(ok, ng):
    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        if solve(mid):
            ok = mid
        else:
            ng = mid
    return ok

print(max(0, b_search(-1, n) - b_search(n, -1) + 1))

Buggy submission (verdict: Runtime Error):
n, m = [int(i) for i in input().split()]
S = input()
Q = [[i for i in input().split()] for j in range(m)]

l = 0
r = n - 1

for t, d in Q[::-1]:
    if d == 'L' and t == S[l]:
        l += 1
    if d == 'R' and t == S[r]:
        r -= 1

print(r - l + 1)
Problem p03083 (python)

Fixed submission:
b, w = [int(i) for i in input().split()]
p = 10 ** 9 + 7

def fact(n, p=10**9 + 7):
    f = [1]
    for i in range(1, n+1):
        f.append(f[-1]*i%p)
    return f

def invfact(n, f, p=10**9 + 7):
    inv = [pow(f[n], p-2, p)]
    for i in range(n, 0, -1):
        inv.append(inv[-1]*i%p)
    return inv[::-1]

def get_inv(n, p=10**9 + 7):
    inv = [0, 1]
    for i in range(2, n+1):
        inv.append(-(p//i * inv[p%i]) % p)
    return inv

f = fact(b + w + 1)
invf = invfact(b + w + 1, f)

def comb(a, b):
    if a < b:
        return 0
    return f[a] * invf[b] * invf[a-b] % p

P = [[0] * 2 for i in range(b + w + 1)]
B = 0
W = 1
inv_2 = invf[2]

for i in range(1, b + w + 1):
    P[i][B] = P[i - 1][B] + comb(i - 1, b - 1) * inv_2  #i番目になくなってる確率
    P[i][W] = P[i - 1][W] + comb(i - 1, w - 1) * inv_2
    inv_2 = inv_2 * invf[2] % p 
    print((1 - P[i - 1][B] + P[i - 1][W]) * invf[2] % p)

Buggy submission (verdict: Runtime Error):
b, w = [int(i) for i in input().split()]
p = 10 ** 9 + 7

def fact(n, p=10**9 + 7):
    f = [1]
    for i in range(1, n+1):
        f.append(f[-1]*i%p)
    return f

def invfact(n, f, p=10**9 + 7):
    inv = [pow(f[n], p-2, p)]
    for i in range(n, 0, -1):
        inv.append(inv[-1]*i%p)
    return inv[::-1]

def get_inv(n, p=10**9 + 7):
    inv = [0, 1]
    for i in range(2, n+1):
        inv.append(-(p//i * inv[p%i]) % p)
    return inv

f = fact(10 ** 5)
invf = invfact(10 ** 5, f)

def comb(a, b):
    if a < b:
        return 0
    return f[a] * invf[b] * invf[a-b] % p

P = [[0] * 2 for i in range(b + w + 1)]
B = 0
W = 1
inv_2 = invf[2]

for i in range(1, b + w + 1):
    P[i][B] = P[i - 1][B] + comb(i - 1, b - 1) * inv_2  #i番目になくなってる確率
    P[i][W] = P[i - 1][W] + comb(i - 1, w - 1) * inv_2
    inv_2 = inv_2 * invf[2] % p 
    print((1 - P[i - 1][B] + P[i - 1][W]) * invf[2] % p)
Problem p03089 (python)

Fixed submission:
#後ろにある数字を消していく

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

ans = []

while len(B) > 0:
    for i in range(len(B) - 1, -1, -1):
        if B[i] == i + 1:
            ans.append(i + 1)
            del B[i]
            break
    else:
        print(-1)
        exit()

print(*ans[::-1], sep='\n')

Buggy submission (verdict: Runtime Error):
n, m = [int(i) for i in input().split()]
E = [[] for i in range(n+1)]
used = [False] * (n + 1)
IN = [0] * (n + 1)

for i in range(m):
    a, b = [int(i) for i in input().split()]
    E[a].append(b)
    E[b].append(a)
    IN[a] += 1
    IN[b] += 1

cnt_4 = 0
cnt_6 = 0
for i in IN[1:]:
    if i % 2 == 1 or i == 0:
        print('No')
        exit()
    if i >= 4:
        cnt_4 += 1
    if i >= 6:
        cnt_6 += 1

if cnt_4 >= 2 or cnt_6 >= 1:
    print('Yes')
else:
    print('No')
Problem p03091 (python)

Fixed submission:
from sys import setrecursionlimit
setrecursionlimit(10 ** 9)

n, m = [int(i) for i in input().split()]
E = [[] for i in range(n+1)]
used = [False] * (n + 1)
IN = [0] * (n + 1)

for i in range(m):
    a, b = [int(i) for i in input().split()]
    E[a].append(b)
    E[b].append(a)
    IN[a] += 1
    IN[b] += 1

cnt_4 = 0
cnt_6 = 0
v_4 = []
for j, i in enumerate(IN[1:]):
    if i % 2 == 1 or i == 0:
        print('No')
        exit()
    if i >= 4:
        cnt_4 += 1
        v_4.append(j + 1)
    if i >= 6:
        cnt_6 += 1

def dfs(p, v):
    if v == v_4[0]:
        return v_4[0]
    if v == v_4[1]:
        return v_4[1]

    for e in E[v]:
        if e == p:
            continue
        return dfs(v, e)

if cnt_4 > 2 or cnt_6 >= 1:
    print('Yes')
elif cnt_4 == 2:
    if all(dfs(v_4[0], e) == v_4[1] for e in E[v_4[0]]):
        print('No')
    else:
        print('Yes')

else:
    print('No')

Buggy submission (verdict: Runtime Error):
from sys import setrecursionlimit
setrecursionlimit(10 ** 9)

n, m = [int(i) for i in input().split()]
E = [[] for i in range(n+1)]
used = [False] * (n + 1)
IN = [0] * (n + 1)

for i in range(m):
    a, b = [int(i) for i in input().split()]
    E[a].append(b)
    E[b].append(a)
    IN[a] += 1
    IN[b] += 1

cnt_4 = 0
cnt_6 = 0
v_4 = []
for j, i in enumerate(IN[1:]):
    if i % 2 == 1 or i == 0:
        print('No')
        exit()
    if i >= 4:
        cnt_4 += 1
        v_4.append(j + 1)
    if i >= 6:
        cnt_6 += 1

def dfs(p, v):
    if v == v_4[0]:
        return v_4[0]
    if v == v_4[1]:
        return v_4[1]

    for e in E[v]:
        if e == p:
            continue
        return dfs(v, e)

if cnt_4 > 2 or cnt_6 >= 1:
    print('Yes')
elif cnt_4 == 2:
    if all(dfs(v_4[0], e) == v_4[1] for e in E[v_4]):
        print('No')
    else:
        print('Yes')

else:
    print('No')
Problem p03096 (python)

Fixed submission:
n = int(input())
C = [0] + [int(input()) for i in range(n)]
p = 10 ** 9 + 7

DP = [0] * (n + 1)
last = [0] * int(2e5 + 1)
DP[0] = 1

for i in range(n):
    if C[i + 1] == C[i]:
        DP[i + 1] = DP[i] % p
    else:
        DP[i + 1] = (DP[i] + last[C[i + 1]]) % p
    last[C[i + 1]] = DP[i + 1]

print(DP[n])

Buggy submission (verdict: Runtime Error):
n = int(input())
C = [0] + [int(input()) for i in range(n)]
p = 10 ** 9 + 7

DP = [0] * (n + 1)
last = [0] * (n + 1)
DP[0] = 1

for i in range(n):
    if C[i + 1] == C[i]:
        DP[i + 1] = DP[i] % p
    else:
        DP[i + 1] = (DP[i] + last[C[i + 1]]) % p
    last[C[i + 1]] = DP[i + 1]

print(DP[n])
Problem p03097 (python)

Fixed submission:
from sys import setrecursionlimit
setrecursionlimit(10 ** 9)

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

if bin(a ^ b).count('1') % 2 == 0:
    print('NO')
    exit()

def dfs(i, a, b):
    if i == 1:
        return [a, b]
    d = (a ^ b) & -(a ^ b)
    ad = ((a & (~d ^ d - 1)) >> 1) + (a & d - 1)
    bd = ((b & (~d ^ d - 1)) >> 1) + (b & d - 1)
    c = ad ^ 1

    res1 = dfs(i - 1, ad, c)
    res2 = dfs(i - 1, bd, c)
    ans1 = [((r & ~(d - 1)) << 1) + (r & d - 1) + (d & a) for r in res1]
    ans2 = [((r & ~(d - 1)) << 1) + (r & d - 1) + (d & b) for r in res2[::-1]]
    return ans1 + ans2

print('YES')
print(*dfs(n, a, b))

Buggy submission (verdict: Runtime Error):
from sys import setrecursionlimit
setrecursionlimit(10 ** 9)

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

if (a ^ b) % 2 == 1 and (a ^ b) != 1:
    print('NO')
    exit()

def dfs(i, a):
    if i == 1:
        return [a & 1, ~a & 1]
    res = dfs(i - 1)
    if a & ((1 << i) - 1) != res[0]:
        res.reverse()
    return [(a & (1 << (i - 1))) + r for r in res] + [((~a) & (1 << (i - 1))) + r for r in res[::-1]]

ans = [(1 << (n - 1)) + r for r in dfs(n - 1, b)[::-1]] + [r for r in dfs(n - 1, a)]
index = ans.index(a)
print('YES')
print(*(ans[index:] + ans[:index]))

Buggy submission (verdict: Runtime Error):
n, a, b = [int(i) for i in input().split()]

if (a ^ b) % 2 == 1 and (a ^ b) != 1:
    print('NO')
    exit()

def dfs(i, a):
    if i == 1:
        return [a & 1, ~a & 1]
    res = dfs(i - 1)
    if a & ((1 << i) - 1) != res[0]:
        res.reverse()
    return [(a & (1 << (i - 1))) + r for r in res] + [((~a) & (1 << (i - 1))) + r for r in res[::-1]]

ans = [(1 << (n - 1)) + r for r in dfs(n - 1, b)[::-1]] + [r for r in dfs(n - 1, a)]
index = ans.index(a)
print('YES')
print(*(ans[index:] + ans[:index]))
Problem p03110 (python)

Fixed submission:
n = int(input())
X = [[i for i in input().split()] for j in range(n)]

ans = 0

for x, u in X:
    x = float(x)
    if u == 'BTC':
        x *= 380000
    ans += x

print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
X = [[int(i) for i in input().split()] for j in range(n)]

ans = 0

for x, u in X:
    if u == 'BTC':
        x *= 380000
    ans += x

print(ans)
Problem p03113 (python)

Fixed submission:
n, k = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]

B = []
for i, a in zip(range(1, n+1), A):
    B.append([a, i])

B.sort(reverse=True)
ans = []

for i in range(n):
    B[i][0] -= 1
    B[i].append(i)
    ans.append(B[i][1])

last = n - 1
for i in range(k):
    mixi = min(B[:last] + B[last+1:])[2]
    cnt = 1
    for j in range(n):
        if j == last or j == mixi:
            continue
        B[j][0] -= 1
        if B[j][0] < 0:
            print(-1)
            exit()
        ans.append(B[j][1])

    ans.append(B[mixi][1])
    B[mixi][0] -= 1
    if B[mixi][0] < 0:
        print(-1)
        exit()
    last = mixi

print(len(ans))
print(*ans)

Buggy submission (verdict: Runtime Error):
n, k = [int(i) for i in input.split()]
A = [int(i) for i in input.split()]

print(-1)
Problem p03141 (python)

Fixed submission:
n = int(input())
A = [[int(i) for i in input().split()] for j in range(n)]

C = []
D = []
i = 0

for a, b in A:
    C.append((a + b, i))
    i += 1

C.sort(reverse=True)
ans = 0

for i, c in enumerate(C):
    if i % 2 == 0:
        ans += A[c[1]][0]
    else:
        ans -= A[c[1]][1]

print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
A = [[int(i) for i in input().split()] for j in range(n)]

C = []
D = []
i = 0

for a, b in A:
    C.append((a - b, i))
    D.append((b - a, i))
    i += 1

C.sort()
D.sort()

used = [False] * n
ans = 0

for i in range(n):
    if i % 2 == 0:
        while used[C[-1][1]]:
            C.pop()
        ans += A[C[-1][1]][0]
        used[C[-1][1]] = True
        C.pop()
    else:
        while used[D[-1][1]]:
            D.pop()
        ans -= A[C[-1][1]][1]
        used[C[-1][1]] = True
        D.pop()

print(ans)