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

Fixed submission:
n = input()
n_ichi = int(n) % 10
 
if n_ichi == 3:
    print('bon')
elif n_ichi == 0 or n_ichi == 1 or n_ichi == 6 or n_ichi == 8:
    print('pon')
else:
    print('hon')

Buggy submission (verdict: Runtime Error):
n = input()
n_ichi = n % 10

if n_ichi == 3:
    print('bon')
elif n_ichi == 0 or n_ichi == 1 or n_ichi == 6 or n_ichi == 8:
    print('pon')
else:
    print('hon')
Problem p02690 (python)

Fixed submission:
x = int(input())

p5 = []
m = 1000
for i in range(-m, m+1):
    p5.append(i**5)

for ci in range(2*m+1):
    if p5[ci] - x in p5:
        a = [ci-m, p5.index(p5[ci] - x)-m]
        break
a = [str(i) for i in a]
print(' '.join(a))

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

p5 = []
for i in range(-100, 101):
    p5.append(i**5)

for ci in range(201):
    if p5[ci] - x in p5:
        a = [ci-100, p5.index(p5[ci] - x)-100]
        break
a = [str(i) for i in a]
print(' '.join(a))
Problem p02782 (python)

Fixed submission:
import copy


def prepare(n, MOD):
 
    # 1! - n! の計算
    f = 1
    factorials = [1]  # 0!の分
    for m in range(1, n + 1):
        f *= m
        f %= MOD
        factorials.append(f)
    # n!^-1 の計算
    inv = pow(f, MOD - 2, MOD)
    # n!^-1 - 1!^-1 の計算
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv
     
    return factorials, invs

def func(r, c):
    return f[r+1+c+1] * i[r+1] % MOD * i[c+1] % MOD

MOD = 10**9+7
f, i = prepare(2*10**6 + 2, MOD)


r1, c1, r2, c2 = map(int,input().split())

combi = func(r2, c2) - func(r2, c1-1) - func(r1-1, c2) + func(r1-1, c1-1)
print(combi % MOD)

Buggy submission (verdict: Runtime Error):
import copy


def prepare(n, MOD):
 
    # 1! - n! の計算
    f = 1
    factorials = [1]  # 0!の分
    for m in range(1, n + 1):
        f *= m
        f %= MOD
        factorials.append(f)
    # n!^-1 の計算
    inv = pow(f, MOD - 2, MOD)
    # n!^-1 - 1!^-1 の計算
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv
     
    return factorials, invs

def func(r, c):
    return f[r+1+c+1] * i[r+1] % MOD * i[c+1] % MOD

MOD = 10**9+7
f, i = prepare(10**6, MOD)


r1, c1, r2, c2 = map(int,input().split())

combi = func(r2, c2) - func(r2, c1-1) - func(r1-1, c2) + func(r1-1, c1-1)
print(combi % MOD)
Problem p02787 (python)

Fixed submission:
def rec_z():
    for i in range(N):
        for j in range(Hmax+1):
            if j >= a[i]:
                dp[j] = min(dp[j], dp[j-a[i]] + b[i])
    return min(dp[H:Hmax+1])
 
 
H, N = map(int,input().split())
a = []
b = []
for i in range(N):
    aa, bb = map(int, input().split())
    a.append(aa)
    b.append(bb)
Hmax = H + max(a)
INF = 10**9
dp = [INF for _ in range(Hmax+1)] 
dp[0] = 0
print(rec_z())

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

def rec_z():
    for i in range(N):
        for j in range(a[i],Hmax+1):
            dp[j] = min(dp[j], dp[j-a[i]] + b[i])
    return min(dp[H:Hmax+1])


H, N = map(int,input().split())
a = []
b = []
for i in range(N):
    aa, bb = map(int, input().split())
    a.append(aa)
    b.append(bb)
Hmax = H + max(a)
INF = 10**9
dp = np.full(Hmax+1, INF, dtype=int)
dp[0] = 0
print(rec_z())
Problem p02788 (python)

Fixed submission:
from collections import deque
import sys

input = sys.stdin.buffer.readline
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

n, d, a = MAP()
xh = [LIST() for i in range(n)]

xh = sorted(xh, key=lambda x:(x[0]))
q = deque()
ca = 0
cnt = 0
for i in range(n):
    cx, ch = xh[i][0], xh[i][1]
    
    while q and q[0][0] < cx:
        qx, qa = q.popleft()
        ca -= qa
    
    if ch - ca <= 0:
        continue
    
    cn = (ch - ca + a - 1) // a
    cnt += cn
    ca += cn * a
    q.append([cx+2*d, cn*a])
    
print(cnt)

Buggy submission (verdict: Runtime Error):
import copy
import numpy as np
import sys
input = sys.stdin.buffer.readline
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

n, d, a = MAP()
xh = [LIST() for i in range(n)]
xh = sorted(xh, key=lambda x:(x[0]))
if d == 0:
    di = 0
else:
    di = 1 + 2*d
cnt = 0
while xh:
    c = xh.pop(0)
    cx, ch = c[0], c[1]
    if ch <= 0:
        continue
    if ch % a == 0:
        cn = ch // a
    else:
        cn = 1 + ch // a
    cnt += copy.deepcopy(cn)
    for nx in range(cx+1, cx+di+1):
        for i in range(len(xh)):
            if xh[i][0] == nx:
                xh[i][1] -= a * cn
print(cnt)
Problem p02789 (python)

Fixed submission:
import sys
input = sys.stdin.buffer.readline
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))


n, m = MAP()
print('Yes') if n == m else print('No')

Buggy submission (verdict: Runtime Error):
from sys import stdin
input = sys.stdin.buffer.readline
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

n, m = MAP()
print('Yes') if n == m else print('No')
Problem p02830 (python)

Fixed submission:
n = int(input())
s, t = input().split()

a = []
for i in range(n):
    a.append(s[i])
    a.append(t[i])
print(''.join(a))

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()
t = input()

ans = []
for i in range(n):
    a.append(s[i])
    a.append(t[i])
print(''.join(a))
Problem p02866 (python)

Fixed submission:
from collections import Counter


def solve(n, ddd):
    if ddd[0] != 0:
        return 0
    cnt = Counter(ddd)
    if cnt[0] != 1:
        return 0
    max_c = max(cnt)
    for i in range(max_c + 1):
        if i not in cnt:
            return 0

    MOD = 998244353
    ans = 1
    for i in range(max_c):
        prev = cnt[i]
        curr = cnt[i + 1]
        ans = ans * pow(prev, curr, MOD) % MOD
    return ans


n = int(input())
ddd = list(map(int, input().split()))

print(solve(n, ddd))

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

n = int(input())
d = list(map(int,input().split()))
MOD = 998244353
if d[0] != 0:
    print(0)
    exit()

else:
    cnt = Counter(d)

ans = 1
for i in range(1 n):
    ans *= pow(cnt[i-1], cnt[i], MOD) % MOD

if cnt[0] != 1:
    ans = 0
max_c = max(cnt)
for i in range(max_c + 1):
    if i not in cnt:
        ans = 0
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
d = list(map(int,input().split()))
d.sort()
if d[0] != 0 or d[1] == 0:
    ans = 0
else:
    cnt = [0]*n
    for i in range(1, n):
        cnt[d[i]] += 1

ans = 1
for i in range(2, n):
    ans *= cnt[i-1]**cnt[i]
print(ans)
Problem p02885 (python)

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

Buggy submission (verdict: Runtime Error):
a, b = map(int,input().split())
print(max(0, a-2b))
Problem p02900 (python)

Fixed submission:
# 素因数分解
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

  
a, b = map(int,input().split())
aa = prime_factorize(a)
bb = prime_factorize(b)
ab = list(set(aa) & set(bb))
ab.sort()
print(len(ab)+1)

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

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

  
a, b = map(int,input().split())
ad = make_divisors(a)
bd = make_divisors(b)
ab = list(set(ad) & set(bd))
ab.sort()
# print(ab)

prime = [1]
is_p = np.array([True]*(ab[-1]+1))
is_p[0] = False
for i in range(2, ab[-1]+1):
    if is_p[i]:
        prime.append(i)
        is_p[i::i] = False
# print(prime)

ans = list(set(ab) & set(prime))
print(len(ans))
Problem p03000 (python)

Fixed submission:
n, x = map(int,input().split())
l = list(map(int,input().split()))

cnt = 1
now = 0
flg = True
while l:
    now += l.pop(0)
    if now <= x:
        cnt += 1
    else:
      break
print(cnt)

Buggy submission (verdict: Runtime Error):
n, x = map(int,input().split())
l = list(map(int,input().split()))

cnt = 0
now = 0
while now <= x:
    cnt += 1
    now += l.pop(0)
print(cnt)
Problem p03061 (python)

Fixed submission:
import math

n = int(input())
a = list(map(int,input().split()))

ar = a[::-1]
l = [0]
r = []

tmp1 = 0
tmp2 = 0
for i in range(n-1):
    tmp1 = math.gcd(tmp1, a[i])
    l.append(tmp1)
    tmp2 = math.gcd(tmp2, ar[i])
    r.append(tmp2)

r.reverse()
r.append(0)
ans = 1
for i in range(n):
    ans = max(ans, math.gcd(l[i], r[i]))
print(ans)

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

n = int(input())
a = list(map(int,input().split()))

if len(a) == 2:
    ans = max(a)
else:
    ans = 1
    a.sort()
    m = a[1]
    check = np.array([-1]*(m+1))
    
    for i in range(2, m+1):
        if check[i] == 0:
            continue
        cnt = 0
        for j in range(n):
            if a[j] % i > 0:
                cnt += 1
            if cnt >= 2:
                check[i::i] = 0
                break
            if j == n-1:
                ans = copy.deepcopy(i)

print(ans)

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

n = int(input())
a = list(map(int,input().split()))

if len(a) == 2:
    ans = max(a)
else:
    a.sort()
    m = a[1]
    check = np.array([-1]*(m+1))
    
    for i in range(2, m+1):
        if check[i] == 0:
            continue
        cnt = 0
        for j in range(n):
            if a[j] % i > 0:
                cnt += 1
            if cnt >= 2:
                check[i::i] = 0
                break
            if j == n-1:
                ans = copy.deepcopy(i)

print(ans)
Problem p03078 (python)

Fixed submission:
import heapq

x, y, z, k =  map(int,input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)

hq = [[-a[0]-b[0]-c[0], 0, 0, 0]]
heapq.heapify(hq)
visited = {(0,0,0)}

for i in range(k):
    ii, ia, ib, ic = heapq.heappop(hq)
    print(-ii)
    na = min(ia+1, x-1)
    nb = min(ib+1, y-1)
    nc = min(ic+1, z-1)
    if not (na, ib, ic) in visited:
        heapq.heappush(hq, [-a[na] -b[ib] -c[ic], na, ib, ic])
        visited.add((na, ib, ic))
    if not (ia, nb, ic) in visited:
        heapq.heappush(hq, [-a[ia] -b[nb] -c[ic], ia, nb, ic])
        visited.add((ia, nb, ic))
    if not (ia, ib, nc) in visited:
        heapq.heappush(hq, [-a[ia] -b[ib] -c[nc], ia, ib, nc])
        visited.add((ia, ib, nc))

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

x, y, z, k =  map(int,input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)

hq = [[-a[0]-b[0]-c[0], 0, 0, 0]]
heapq.heapify(hq)
# visited = [[[0] * z for yy in range(y)] for xx in range(x)]
visited = np.zeros((x, y, z), dtype=int)

for i in range(k):
    ii, ia, ib, ic = heapq.heappop(hq)
    print(-ii)
    na = min(ia+1, x-1)
    nb = min(ib+1, y-1)
    nc = min(ic+1, z-1)
    if visited[na][ib][ic] == 0:
        heapq.heappush(hq, [-a[na] -b[ib] -c[ic], na, ib, ic])
        visited[na][ib][ic] = 1
    if visited[ia][nb][ic] == 0:
        heapq.heappush(hq, [-a[ia] -b[nb] -c[ic], ia, nb, ic])
        visited[ia][nb][ic] = 1
    if visited[ia][ib][nc] == 0:
        heapq.heappush(hq, [-a[ia] -b[ib] -c[nc], ia, ib, nc])
        visited[ia][ib][nc] = 1

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

x, y, z, k =  map(int,input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)

hq = [[-a[0]-b[0]-c[0], 0, 0, 0]]
heapq.heapify(hq)
# visited = [[[0] * z for yy in range(y)] for xx in range(x)]
visited = np.zeros((x, y, z), dtype=int)

for i in range(k):
    ii, ia, ib, ic = heapq.heappop(hq)
    print(-ii)
    na = min(ia+1, x-1)
    nb = min(ib+1, y-1)
    nc = min(ic+1, z-1)
    if visited[na][ib][ic] == 0:
        heapq.heappush(hq, [-a[na] -b[ib] -c[ic], na, ib, ic])
        visited[na][ib][ic] = 1
    if visited[ia][nb][ic] == 0:
        heapq.heappush(hq, [-a[ia] -b[nb] -c[ic], ia, nb, ic])
        visited[ia][nb][ic] = 1
    if visited[ia][ib][nc] == 0:
        heapq.heappush(hq, [-a[ia] -b[ib] -c[nc], ia, ib, nc])
        visited[ia][ib][nc] = 1
Problem p03087 (python)

Fixed submission:
import copy

n, q = map(int, input().split())
s = input()

cnt = [0]
for i in range(n-1):
    if s[i] == 'A' and s[i+1] == 'C':
        cnt.append(cnt[-1] + 1)
    else:
        cnt.append(cnt[-1])

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

Buggy submission (verdict: Runtime Error):
import copy

n, q = map(int, input().split())
s = input()

cnt = [0]
for i in range(n):
    if s[i] == 'A' and s[i+1] == 'C':
        cnt.append(cnt[-1] + 1)
    else:
        cnt.append(cnt[-1])

for i in range(q):
    l, r = map(int, input().split())
    print(cnt[r-1] - cnt[l-1])
Problem p03244 (python)

Fixed submission:
import copy
import numpy as np

n = int(input())
v = list(map(int,input().split()))
a = v[0::2] 
b = v[1::2]

cnta = np.zeros(10**5+1, dtype=int)
cntb = np.zeros(10**5+1, dtype=int)
for i in range(n//2):
    ca, cb = a[i], b[i]
    cnta[ca] += 1
    cntb[cb] += 1

la = np.zeros((2,2), dtype=int)
lb = np.zeros((2,2), dtype=int)
for i in range(2):
    ia = cnta.argmax()
    ib = cntb.argmax()
    la[i][0], la[i][1] = ia, cnta[ia]
    lb[i][0], lb[i][1] = ib, cntb[ib]
    cnta[ia] = 0
    cntb[ib] = 0

if la[0][0] != lb[0][0]:
    ans = n//2 - la[0][1] + n//2 - lb[0][1]
else:
    ans = min(n//2 - la[0][1] + n//2 - lb[1][1], n//2 - la[1][1] + n//2 - lb[0][1])
print(ans)

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

n = int(input())
v = list(map(int,input().split()))
a = v[0::2] 
b = v[1::2]

cnta = np.zeros(10**5+1, dtype=int)
cntb = np.zeros(10**5+1, dtype=int)
for i in range(n//2):
    ca, cb = a[i], b[i]
    cnta[ca] += 1
    cntb[cb] += 1
print(a, cnta[:5])
print(b, cntb[:5])
la = np.zeros((2,2), dtype=int)
lb = np.zeros((2,2), dtype=int)
for i in range(2):
    ia = cnta.argmax()
    ib = cntb.argmax()
    la[i][0], la[i][1] = ia, cnta[ia]
    lb[i][0], lb[i][1] = ib, cntb[ib]
    cnta[ia] = -1
    cntb[ib] = -1
print(la)
print(lb)
if la[0][0] != lb[0][0]:
    ans = n//2 - la[0][1] + n//2 - lb[0][1]
elif la[0][1] > lb[0][1]:
    ans = min(n//2 - la[0][1] + n//2 - lb[1][1], n//2 - la[1][1] + n//2 - lb[0][1])
print(ans)
Problem p03361 (python)

Fixed submission:
h, w = map(int, input().split())
f = [["."] * (w + 2)] + \
    [list("." + input() + ".") for i in range(h)] + \
    [["."] * (w + 2)]

flg = False
for y in range(h):
    for x in range(w):
        if f[y][x] == '#':
            cnt = 0
            if f[y+1][x] == f[y-1][x] == f[y][x+1] == f[y][x-1] == '.':
                flg = True

print('No') if flg else print('Yes')

Buggy submission (verdict: Runtime Error):
def dfs(f, stack, cnt):
    while stack:
        y, x = stack.pop()
        f[y][x] = '.'
        cnt += 1

        dxy = [(0,1), (0,-1), (1,0), (-1,0)]
        for dx, dy in dxy:
            nx, ny = x + dx, y + dy
            if 0 <= nx < w and 0 <= ny < h and f[ny][nx] == '#':
                stack.append([ny, nx])
                cnt, f = dfs(f, stack, cnt)
    return cnt, f

h, w = map(int, input().split())
f = [list(input()) for i in range(h)]

flg = False
dxy = [(0,1), (0,-1), (1,0), (-1,0)]
stack = []
for y in range(h):
    for x in range(w):
        if f[y][x] == '#':
            stack.append([y, x])
            cnt = 0
            cnt, f = dfs(f, stack, cnt)
            if cnt < 2:
                flg = True

print('No') if flg else print('Yes')

Buggy submission (verdict: Runtime Error):
def dfs(f, stack, cnt):
    while stack:
        y, x = stack.pop()
        f[y][x] = '.'
        cnt += 1

        dxy = [(0,1), (0,-1), (1,0), (-1,0)]
        for dx, dy in dxy:
            nx, ny = x + dx, y + dy
            if 0 <= nx < w and 0 <= ny < h and f[ny][nx] == '#':
                stack.append([ny, nx])
                cnt, f = dfs(f, stack, cnt)
    return cnt, f

h, w = map(int, input().split())
f = [list(input()) for i in range(h)]

flg = False
dxy = [(0,1), (0,-1), (1,0), (-1,0)]
stack = []
for y in range(h):
    for x in range(w):
        if f[y][x] == '#':
            stack.append([y, x])
            cnt = 0
            cnt, f = dfs(f, stack, cnt)
            if cnt < 2:
                flg = True
                break
    if flg:
        break

print('No') if flg else print('Yes')

Buggy submission (verdict: Runtime Error):
def dfs(f, stack, cnt):
    while stack:
        x, y = stack.pop()
        f[y][x] = '.'
        cnt += 1

        dxy = [(0,1), (0,-1), (1,0), (-1,0)]
        for dx, dy in dxy:
            nx, ny = x + dx, y + dy
            if 0 <= nx < w and 0 <= ny < h:
                if f[ny][nx] == '#':
                    stack.append([nx, ny])
                    cnt = dfs(f, stack, cnt)
    return cnt


h, w = map(int, input().split())
f = [list(input()) for i in range(h)]

flg = False
dxy = [(0,1), (0,-1), (1,0), (-1,0)]
stack = []
for y in range(h):
    for x in range(w):
        if f[y][x] == '#':
            stack.append([x, y])
            cnt = 0
            cnt = dfs(f, stack, cnt)
            if cnt < 2:
                flg = True
                break
    if flg:
        break

print('No') if flg else print('Yes')
Problem p03433 (python)

Fixed submission:
n = int(input())
a = int(input())
if n % 500 <= a:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
from queue import Queue
import itertools
import numpy as np
 
R, C = map(int, input().split())
sy, sx = 1, 1
gy, gx = R, C
 
field = [["#"] * (C + 2)] + \
        [list("#" + input() + "#") for i in range(R)] + \
        [["#"] * (C + 2)]
dxy = [(0,1), (0,-1), (1,0), (-1,0)]
flg = False
cnt = 0
 
field_1d = list(itertools.chain.from_iterable(field))
field01 = [1 if i == '.' else 0 for i in field_1d]
dot_num = np.array(field01).sum()
 
q = Queue()
q.put([sy, sx])
field[sy][sx] = 0
 
while flg == False:
    yx = q.get()
    cnt = field[yx[0]][yx[1]]
    for dy, dx in dxy:
        y_n, x_n = yx[0] + dy, yx[1] + dx
        if y_n == gy and x_n == gx:
            field[y_n][x_n] = cnt + 1
            flg = True
            print(dot_num - (cnt+2))
        if field[y_n][x_n] == '#':
            continue
        if field[y_n][x_n] == '.':
            q.put([y_n, x_n])
            field[y_n][x_n] = cnt + 1
if flg == False:
    print(-1)

Buggy submission (verdict: Runtime Error):
from queue import Queue
import itertools
import numpy as np

R, C = map(int, input().split())
sy, sx = 1, 1
gy, gx = R, C

field = [["#"] * (C + 2)] + \
        [list("#" + input() + "#") for i in range(R)] + \
        [["#"] * (C + 2)]
dxy = [(0,1), (0,-1), (1,0), (-1,0)]
flg = False
cnt = 0

field_1d = list(itertools.chain.from_iterable(field))
field01 = [1 if i == '.' else 0 for i in field_1d]
dot_num = np.array(field01).sum()

q = Queue()
q.put([sy, sx])
field[sy][sx] = 0

while flg == False:
    yx = q.get()
    cnt = field[yx[0]][yx[1]]
    for dy, dx in dxy:
        y_n, x_n = yx[0] + dy, yx[1] + dx
        if y_n == gy and x_n == gx:
            field[y_n][x_n] = cnt + 1
            flg = True
            print(dot_num - (cnt+2))
            break
        if field[y_n][x_n] == '#':
            continue
        if field[y_n][x_n] == '.':
            q.put([y_n, x_n])
            field[y_n][x_n] = cnt + 1
    if flg:
        print('------')
        break
if flg == False:
    print(-1)
Problem p03472 (python)

Fixed submission:
n, h = map(int,input().split())
a = []
b = []
for i in range(n):
    ca, cb = map(int,input().split())
    a.append(ca)
    b.append(cb)

amax = max(a)
b.sort(reverse=True)
cnt = 0
while h > 0:
    if b and b[0] > amax:
        h -= b.pop(0)
        cnt += 1
    else:
        cnt += h//amax
        h -= amax * (h//amax)
        if h > 0:
            h -= amax
            cnt += 1
print(cnt)

Buggy submission (verdict: Runtime Error):
n, h = map(int,input().split())
a = []
b = []
for i in range(n):
    ca, cb = map(int,input().split())
    a.append(ca)
    b.append(cb)

a.sort(reverse=True)
b.sort(reverse=True)
cnt = 0
while h > 0:
    if b[0] > a[0]:
        h -= b.pop(0)
        cnt += 1
    else:
        cnt += h//a[0]
        h -= a[0] * h//a[0]
        if h > 0:
            h -= a[0]
            cnt += 1
print(cnt)
Problem p03486 (python)

Fixed submission:
s = list(input())
t = list(input())

s.sort()
t.sort(reverse=True)

flg = False
for i in range(len(s)):
    if i >= len(t):
        break
    if ord(s[i]) > ord(t[i]):
        break
    if ord(s[i]) < ord(t[i]):
        flg = True
        break
    if i == len(s)-1 and i < len(t)-1:
        flg = True
        break
        
print('Yes') if flg else print('No')

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

s.sort()
t.sort(reverse=True)

flg = True
for i in range(len(s)):
    if ord(s[i]) > ord(t[i]):
        flg = False
        break
    if ord(s[i]) < ord(t[i]):
        break
        
print('Yes') if flg else print('No')
Problem p03611 (python)

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

cnt = [0]*(10**5+5)
for i in a:
    cnt[i] += 1

ans = 0
for i in range(1, 10**5+3):
    ans = max(ans, sum(cnt[i-1:i+2]))
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))

cnt = [0]*10**5+5
for i in a:
    cnt[i] += 1

ans = 0
for i in range(1, 10**5+3):
    ans = max(ans, sum(cnt[i-1:i+2]))
print(ans)
Problem p03623 (python)

Fixed submission:
x, a, b = map(int,input().split())
print('A') if abs(x-a) < abs(x-b) else print('B')

Buggy submission (verdict: Runtime Error):
x, a, b = map(int,input().split())
print('A') if abs(x-a) < abs(s-b) else print('B')
Problem p03644 (python)

Fixed submission:
n = int(input())
b = n.bit_length() - 1
ans = int('0b1'+'0'*b, 2)
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
b = m.bit_length() - 1
ans = int('0b1'+'0'*m, 2)
print(ans)
Problem p03658 (python)

Fixed submission:
n, k = map(int,input().split())
a = list(map(int,input().split()))
a.sort(reverse=True)

ans = 0
for i in range(k):
    ans += a[i]
print(ans)

Buggy submission (verdict: Runtime Error):
n, k = map(int,input().split())
a = list(map(int,input().split()))
a.sort(reverse=True)
print(a[0]+a[1]+a[2])
Problem p03659 (python)

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

s = a[0]
t = sum(a) - a[0]

i = 0
ans = abs(s - t)
for i in range(1, n-1):
    s += a[i]
    t -= a[i]
    ans = min(ans, abs(s - t))
    i += 1
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))

total = sum(a)
s = 0
i = 0
ans = total + 1
while True:
    s += a[i]
    total -= a[i]
    ans = min(ans, abs(s - total))
    i += 1
print(ans)