qyliang/CodeNanoFix huggingface dataset:
Buggy code:
import sys
input = sys.stdin.readline

n, h = map(int, input().split())

a = []
b = []

for _ in range(n):
    x, y = map(int, input().split())
    a.append(x)
    b.append(y)

a.sort(reverse=True)
b.sort(reverse=True)
a_max = a[0]

b_nage = [i for i in b if i>a_max]

count = 0
for i in b_nage:
    h -= i
    count += 1
    if h<=0:
        print(count)

count += -(-h//a_max)

print(count)

Fixed code:
import sys
input = sys.stdin.readline

n, h = map(int, input().split())

a = []
b = []

for _ in range(n):
    x, y = map(int, input().split())
    a.append(x)
    b.append(y)

a.sort(reverse=True)
b.sort(reverse=True)
a_max = a[0]

b_nage = [i for i in b if i>a_max]

count = 0
for i in b_nage:
    h -= i
    count += 1
    if h<=0:
        print(count)
        exit()

count += -(-h//a_max)

print(count)
Buggy code:
import re
import math
def comb(n, r):
    if n == 0 or r == 0:
        return 1
    return int(comb(n, r-1) * (n-r+1) / r)

if __name__ == '__main__':
    
    N, H = [int(x) for x in input().split()]
    A = []
    B = []
    for i in range(N):
        ta, tb = [int(x) for x in input().split()]
        A.append(ta)
        B.append(tb)

    B = sorted(B)
    B.reverse()
    maxA = max(A)

    cntAtk = 0
    dmg = 0
    for b in B:
        if b <= maxA:
            break
        cntAtk += 1
        dmg += b
        print('atk B', b)
        if dmg >= H:
            print(cntAtk)
            exit()

    print('throwed', dmg, H)
    print('maxA', maxA)
    cntAtk += math.ceil((H-dmg) / maxA)
    print(cntAtk)


Fixed code:
import re
import math
def comb(n, r):
    if n == 0 or r == 0:
        return 1
    return int(comb(n, r-1) * (n-r+1) / r)

if __name__ == '__main__':
    
    N, H = [int(x) for x in input().split()]
    A = []
    B = []
    for i in range(N):
        ta, tb = [int(x) for x in input().split()]
        A.append(ta)
        B.append(tb)

    B = sorted(B)
    B.reverse()
    maxA = max(A)

    cntAtk = 0
    dmg = 0
    for b in B:
        if b <= maxA:
            break
        cntAtk += 1
        dmg += b
        if dmg >= H:
            print(cntAtk)
            exit()

    cntAtk += math.ceil((H-dmg) / maxA)
    print(cntAtk)
Buggy code:
import math
n, h = map(int,input().split())
thr = []
att = []
ans = 0
for i in range(n):
 a, b = map(int,input().split())
 att.append(a)
 thr.append(b)
thr.sort(reverse = True)
att.sort(reverse = True)
print(h,sum(thr))

for m in range(n):
 if h > 0:
  if thr[m] > att[0]:
   h = h -thr[m]
   ans = ans+1
  else:
   h = h-att[0]
   ans = ans+1
if h > 0:
 turn = h/att[0]
 turn = math.ceil(turn)
 ans = ans+ turn
print(att,thr,h)
print(ans)

Fixed code:
import math
n, h = map(int,input().split())
thr = []
att = []
ans = 0
for i in range(n):
 a, b = map(int,input().split())
 att.append(a)
 thr.append(b)
thr.sort(reverse = True)
att.sort(reverse = True)


for m in range(n):
 if h > 0:
  if thr[m] > att[0]:
   h = h -thr[m]
   ans = ans+1
  else:
   h = h-att[0]
   ans = ans+1
if h > 0:
 turn = h/att[0]
 turn = math.ceil(turn)
 ans = ans+ turn

print(ans)
Buggy code:
import sys
input = sys.stdin.readline
N,H=map(int,input().split())
A=[]
B=[]
for _ in range(N):
    a,b=map(int,input().split())
    A.append(a)
    B.append(b)


amax=max(A)
#print(amax)
b=[]
for i in range(N):
    if B[i]>=amax:
        b.append(B[i])
b.sort()
#print(b)
cnt=0
while b:
    if H>0:
        H-=b.pop()
        cnt+=1
    if H<=0:
        #print(cnt)
        exit()

cnt+=-(-H//amax)
print(cnt)


Fixed code:
import sys
input = sys.stdin.readline
N,H=map(int,input().split())
A=[]
B=[]
for _ in range(N):
    a,b=map(int,input().split())
    A.append(a)
    B.append(b)


amax=max(A)
#print(amax)
b=[]
for i in range(N):
    if B[i]>=amax:
        b.append(B[i])
b.sort()
#print(b)
cnt=0
while b:
    if H>0:
        H-=b.pop()
        cnt+=1
    if H<=0:
        print(cnt)
        exit()

cnt+=-(-H//amax)
print(cnt)
Buggy code:
n,h=map(int,input().split())
ab=[[int(i) for i in input().split()] for _ in range(n)]
maxa=max(map(lambda x:x[0], ab))
ab.sort(key:lambda x:x[1],reverse=True)
ans=0
for a,b in ab:
  if b>maxa:
    h-=b
    ans+=1
  if h<=0:
    print(ans)
    exit(0)
print(ans+(h-1)//maxa+1)

Fixed code:
n,h=map(int,input().split())
ab=[[int(i) for i in input().split()] for _ in range(n)]
maxa=max(map(lambda x:x[0], ab))
ab.sort(key=lambda x:x[1],reverse=True)
ans=0
for a,b in ab:
  if b>maxa:
    h-=b
    ans+=1
  if h<=0:
    print(ans)
    exit(0)
print(ans+(h-1)//maxa+1)
Buggy code:
def main():
    N, H = (int(i) for i in input().split())
    ab = [[int(i) for i in input().split()] for j in range(N)]
    a_max = -1
    a_max_idx = -1
    b_max = -1
    for i,v in enumerate(ab):
        b_max = max(b_max,v[1])
        if a_max < v[0]:
            a_max = v[0]
            a_max_idx = i
    b = [val[1] for i,val in enumerate(ab) if val[1] >= a_max]
    b.sort(reverse=True)
    ans = 0
    for throw in b:
        if H <= 0:
            break
        ans += 1
        H -= throw
    else:
        ans += 1
        H -= ab[a_max_idx][1]
    if 0 < H:
        from math import ceil
        ans += int(ceil(H/a_max))
    print(ans)

if __name__ == '__main__':
    main()

Fixed code:
def main():
    N, H = (int(i) for i in input().split())
    ab = [[int(i) for i in input().split()] for j in range(N)]
    a_max = -1
    a_max_idx = -1
    b_max = -1
    for i,v in enumerate(ab):
        b_max = max(b_max,v[1])
        if a_max < v[0]:
            a_max = v[0]
            a_max_idx = i
    b = [val[1] for i,val in enumerate(ab) if val[1] >= a_max]
    b.sort(reverse=True)
    ans = 0
    for throw in b:
        if H <= 0:
            break
        ans += 1
        H -= throw
    if 0 < H:
        from math import ceil
        ans += int(ceil(H/a_max))
    print(ans)

if __name__ == '__main__':
    main()
Buggy code:
n,h=map(int,input().split())
a=[];b=[]
for i in range(n):
  q,w=map(int,input().split())
  a+=[q]
  b+=[w]
m=max(a)
b.sort(reverse=True)
x=0
for i in b:
  h-=i
  x+=1
  if h<=0:
    break
if h>0:
  x+=-(-h//m)
print(x)

Fixed code:
n,h=map(int,input().split())
a=[];b=[]
for i in range(n):
  q,w=map(int,input().split())
  a+=[q]
  b+=[w]
m=max(a)
b=[i for i in b if i>=m]
b.sort(reverse=True)
x=0
for i in b:
  h-=i
  x+=1
  if h<=0:
    break
if h>0:
  x+=-(-h//m)
print(x)
Buggy code:
n, h = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]

a_all = [_ab[0] for _ab in ab]
b_all = [_ab[1] for _ab in ab]

a_max = max(a_all)

b_all_useful = []
for b in b_all:
    if b > a_max:
        b_all_useful.append(b)

b_all_useful.sort()

useful_sum = sum(b_all_useful)
if useful_sum > h:
    counter = 0
    i = 0
    while True:
        counter += b_all_useful[-1 * ii]
        i += 1
        if counter >= h:
            break
    print(i)

else:
    h_new = h - useful_sum
    import math
    print(math.ceil(h_new / a_max) + len(b_all_useful))


Fixed code:
n, h = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]

a_all = [_ab[0] for _ab in ab]
b_all = [_ab[1] for _ab in ab]

a_max = max(a_all)

b_all_useful = []
for b in b_all:
    if b > a_max:
        b_all_useful.append(b)

b_all_useful.sort()

useful_sum = sum(b_all_useful)
if useful_sum > h:
    counter = 0
    i = 0
    while True:
        counter += b_all_useful[-1 * (i + 1)]
        i += 1
        if counter >= h:
            break
    print(i)

else:
    h_new = h - useful_sum
    import math
    print(math.ceil(h_new / a_max) + len(b_all_useful))
Buggy code:
# coding: utf-8
# Your code here!
n,H=map(int,input().split())
S=[]
for i in range(n):
    
    S.append(list(map(int,input().split())))
    
a=[]
b=[]
for i in range(n):
    a.append(S[i][0])
    
for i in range(n):
    if(max(a)<S[i][1]):
        b.append(S[i][1])

b.sort()
b.reverse()
k=0
count=0
while H>0:
    if len(b)>k:
        H-=b[k]
        k+=1
        count+=1
    else:
        
        count+=H//max(a)
        H=0

print(count)


Fixed code:
# coding: utf-8
# Your code here!
n,H=map(int,input().split())
S=[]
for i in range(n):
    
    S.append(list(map(int,input().split())))
    
a=[]
b=[]
for i in range(n):
    a.append(S[i][0])

maxa=max(a)    
for i in range(n):
    if(maxa<S[i][1]):
        b.append(S[i][1])

b.sort()
b.reverse()
k=0
count=0
lenb=len(b)
while H>0:
    if lenb>k:
        H-=b[k]
        k+=1
        count+=1
    else:
        
        count+=H//maxa
        if(H%maxa!=0):
            count+=1
        H=0

print(count)
Buggy code:
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)

Fixed code:
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 code:
n, h = map(int, input().split())
amax = 0
bl=[]
for i in range(n):
    a, b = map(int, input().split())
    amax = max(amax, a)
    bl.append(b)
bl.sort()
bl.reverse()

ans = 0
for i in range(n):
    if h == 0:break
    if bl[i] <= amax: break
    ans += 1
    h -= bl[i]
if h > 0:
    h -= h // amax
    ans += h // amax
    if h > 0:
        ans += 1

print(ans)

Fixed code:
n, h = map(int, input().split())
amax = 0
bl = []
for i in range(n):
    a, b = map(int, input().split())
    amax = max(amax, a)
    bl.append(b)
bl.sort()
bl.reverse()

ans = 0
for i in range(n):
    if h <= 0:
        break
    if bl[i] <= amax:
        break
    ans += 1
    h -= bl[i]
if h > 0:
    ans += h // amax
    h -= (h // amax) * amax
if h > 0:
    ans += 1

print(ans)
Buggy code:
import heapq
import math
N,H = map(int,input().split())

a_ls = [0]*N
b_ls =[0]*N
for i in range(N):
    a, b = map(int,input().split())
    a_ls[i] = a
    b_ls[i] = -b

a_max = max(a_ls)

heapq.heapify(b_ls)

total = 0
count = 0
for i in range(len(b_ls)):
    b_max = -heapq.heappop(b_ls)

    if a_max>=b_max:
        count += math.ceil((H-total)/a_max)
        total = H
        break
    total += b_max
    count +=1
    
    if total <=H:
        break

count += math.ceil((H-total)/a_max)

print(count)

Fixed code:
import heapq
import math
N,H = map(int,input().split())

a_ls = [0]*N
b_ls =[0]*N
for i in range(N):
    a, b = map(int,input().split())
    a_ls[i] = a
    b_ls[i] = -b

a_max = max(a_ls)

heapq.heapify(b_ls)

total = 0
count = 0
for i in range(len(b_ls)):
    b_max = -heapq.heappop(b_ls)

    if a_max>=b_max:
        count += math.ceil((H-total)/a_max)
        total = H
        break
    total += b_max
    count +=1

    if total >=H:
        break

count += math.ceil(max(0,(H-total))/a_max)

print(count)
Buggy code:
import sys
import collections


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    n, h = list(map(int, input().rstrip('\n').split()))
    al = []
    bl = []
    for i in range(n):
        a, b = list(map(int, input().rstrip('\n').split()))
        al.append(a)
        bl.append(b)
    al.sort()
    bl.sort()
    al = collections.deque(al)
    bl = collections.deque(bl)
    k = al[-1]
    cnt = 0
    while True:
        if len(bl) != 0:
            p = bl.pop()
            if p > k:
                h -= max(p, h)
                cnt += 1
            else:
                print(cnt + (h + k - 1) // k)
                exit()
        else:
            print(cnt + (h + k - 1) // k)
            exit()


if __name__ == '__main__':
    solve()


Fixed code:
import sys
import collections


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    n, h = list(map(int, input().rstrip('\n').split()))
    al = []
    bl = []
    for i in range(n):
        a, b = list(map(int, input().rstrip('\n').split()))
        al.append(a)
        bl.append(b)
    al.sort()
    bl.sort()
    al = collections.deque(al)
    bl = collections.deque(bl)
    k = al[-1]
    cnt = 0
    while True:
        if len(bl) != 0:
            p = bl.pop()
            if p > k and h != 0:
                h -= min(p, h)
                cnt += 1
            else:
                print(cnt + (h + k - 1) // k)
                exit()
        else:
            print(cnt + (h + k - 1) // k)
            exit()


if __name__ == '__main__':
    solve()
Buggy code:
import math
n,h = (map(int,input().split()))
katanas = [[int(el) for el in input().split()] for _ in range(n)]

hit_max = max([el[0] for el in katanas])

katanas.sort(key=lambda x:(x[1],x[0]),reverse=True)

count = 0
for katana in katanas:

    if h <= 0:
        break
    if katana[1] > hit_max:
        h -= katana[1]
        count += 1
    else:
        break
    
if h <= 0:
    print(count)
else:
    print(count+math.ceil(count/hit_max))


Fixed code:
import math
n,h = (map(int,input().split()))
katanas = [[int(el) for el in input().split()] for _ in range(n)]

hit_max = max([el[0] for el in katanas])

katanas.sort(key=lambda x:(x[1],x[0]),reverse=True)

count = 0
for katana in katanas:

    #print(katana[1])

    if h <= 0:
        break
    if katana[1] > hit_max:
        h -= katana[1]
        count += 1
    else:
        break

    
if h <= 0:
    print(count)
else:
    print(count+math.ceil(h/hit_max))
Buggy code:
import math

N, H = map(int, input().split())

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

swords_T = [list(x) for x in zip(*swords)]

#print(swords_T)

swing_max = max(swords_T[0])

order = sorted(swords_T[1])
print(order)
count = 0

while H > 0 and len(order) != 0:
    tmp = order.pop()
    if tmp > swing_max:
        H -= tmp
        count += 1
#print(f'{H=}')

count += math.ceil(H/swing_max)

print(count)

Fixed code:
import math

N, H = map(int, input().split())

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

swords_T = [list(x) for x in zip(*swords)]

#print(swords_T)

swing_max = max(swords_T[0])

order = sorted(swords_T[1])
#print(order)
count = 0

while H > 0 and len(order) != 0:
    tmp = order.pop()
    if tmp > swing_max:
        H -= tmp
        count += 1
#print(f'{H=}')
if H > 0:
    count += math.ceil(H/swing_max)

print(count)
Buggy code:
N, H = map(int, input().split())
a_list = []
b_list = []
for i in range(N):
    a, b = map(int, input().split())
    a_list.append(a)
    b_list.append(b)
count = 0
a = max(a_list)
b_list.sort()
while len(b_list) >= 1:
    if b_list[-1] >= a:
        b = b_list.pop(-1)
        H -= b
        count += 1
        if H <= 0:
            print(count)
            exit()
    else:
        break
print(count + H // a+ 1)

Fixed code:
N, H = map(int, input().split())
a_list = []
b_list = []
for i in range(N):
    a, b = map(int, input().split())
    a_list.append(a)
    b_list.append(b)
count = 0
a = max(a_list)
b_list.sort()
while len(b_list) >= 1 and H >= 1:
    if b_list[-1] >= a:
        b = b_list.pop(-1)
        H -= b
        count += 1
    else:
        break
if H <= 0:
    print(count)
else:
    tmp = H // a if H % a == 0 else H //a + 1
    print(count + tmp)
Buggy code:
N,H=map(int,input().split())
Katana=[[int(i) for i in input().split()] for i in range(N)]
a_max=max(list(zip(*Katana))[0])
B=list(list(zip(*Katana))[1])
B.sort(key=lambda x:(-1)*x)
n=N
for i in range(N):
  if B[i]<=a_max:
    n=i
    break
del B[n:N]
m=0
for b in B:
  if H>0:
    H-=b
    m+=1
if H>0:
  m+=int(H/a_max)+1
print(m)

Fixed code:
import math
N,H=map(int,input().split())
Katana=[[int(i) for i in input().split()] for i in range(N)]
a_max=max(list(zip(*Katana))[0])
B=list(list(zip(*Katana))[1])
B.sort(key=lambda x:(-1)*x)
n=N
for i in range(N):
  if B[i]<=a_max:
    n=i
    break
del B[n:N]
m=0
for b in B:
  if H>0:
    H-=b
    m+=1
if H>0:
  m+=math.ceil(H/a_max)
print(m)
Buggy code:
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)

import numpy
A = numpy.array(A)
B = numpy.array(B)
AsortA = numpy.sort(A)[::-1]
BsortB = numpy.sort(B)[::-1]

ans = 0
if(sum(B) >= H):
    for i in range(1,N+1):
        print(sum(BsortB[:i]))
        if(sum(BsortB[:i]) >= H):
            ans = i
            break
else:
    resH = H - sum(B)
    maxattack = AsortA[0]
    ak = int(numpy.ceil(resH/maxattack))
    ans = ak + N
    
print(ans)

Fixed code:
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)

import numpy
A = numpy.array(A)
B = numpy.array(B)
AsortA = numpy.sort(A)[::-1]
BsortB = numpy.sort(B)[::-1]

ans = 0
maxattack = AsortA[0]
throw = BsortB[maxattack < BsortB]
if(sum(throw) >= H):
    ak = 0
    for i in range(len(throw)):
        ak += throw[i]
        if(ak >= H):
            ans = i+1
            break
else:
    resH = H - sum(throw)
    ak = int(numpy.ceil(resH/maxattack))
    ans = ak + len(throw)
    
print(ans)
Buggy code:
from operator import itemgetter
N, H = map(int, input().split())
a = []
b = []
ab = []
for i in range(N):
    n, m = map(int, input().split())
    a.append(n)
    b.append(m)
    ab.append([n, m])

max_count = 0
ab.sort(reverse = True, key = itemgetter(1))
a_max = max(a)
for i in range(N):
    if a[i] == a_max:
        max_count += 1

ans = 0
for i in range(N):
    if H <= ab[0][1] or H <= a_max:
        ans += 1
        break
    if a_max < ab[0][1]:
        if ab[0][0] == a_max:
            if max_count > 1:
                max_count -= 1
                H -= ab.pop(0)[1]
                ans += 1
            else:
                H -= ab[0][1]
                print(H)
                ans += 1
                if H <= 0:
                    break
                else:
                    ans += 1 + (H-1) // ab[0][0]
                    break
        else:
            H -= ab.pop(0)[1]
            ans += 1
    else:
        ans += 1 + (H-1) // a_max
print(ans)


Fixed code:
from operator import itemgetter
N, H = map(int, input().split())
b = []
a = []
for i in range(N):
    n, m = map(int, input().split())
    b.append(m)
    a.append(n)
a_max = max(a)
ans = 0
b.sort(reverse = True)
for i in range(N):
    if H <= b[i] or H <= a_max:
        ans += 1
        break
    if b[i] >= a_max:
        H -= b[i]
        ans += 1
        if i == N-1:
            ans += 1 + ((H-1) // a_max)

    else:
        ans += 1 + ((H-1) // a_max)
        break
print(ans)
Buggy code:
from collections import deque
n, h = map(int, input().split())
a_list = []
b_list = []
time = 0
for _ in range(n):
    a, b = map(int, input().split())
    a_list.append(a)
    b_list.append(b)
a_list.sort()
b_list.sort(reverse=True)
b_stack = deque(b_list)
while h > 0:
    if len(b_stack) > 0:
        if a_list[-1] < b_stack[0]:
            h -= b_stack.popleft()
            time += 1
        else:
            
            time += h // a_list[-1]
            h = 0
    else:        
        time += h // a_list[-1]
        h = 0
    
print(time)

Fixed code:
from collections import deque
import math
n, h = map(int, input().split())
a_list = []
b_list = []
time = 0
for _ in range(n):
    a, b = map(int, input().split())
    a_list.append(a)
    b_list.append(b)
a_list.sort()
b_list.sort(reverse=True)
b_stack = deque(b_list)
while h > 0:
    if len(b_stack) > 0:
        if a_list[-1] < b_stack[0]:
            h -= b_stack.popleft()
            time += 1
        else:
            
            time += math.ceil(h / a_list[-1])
            h = 0
    else:        
        time += math.ceil(h / a_list[-1])
        h = 0
    
print(time)
Buggy code:
# https://beta.atcoder.jp/contests/abc085/tasks/abc085_d

def solve():
    # n, m = map(int, input().split())
    n, m = 4, 1000000000
    swing, throw = [1, 1, 1, 1], [1, 10000000, 99999999, 30000000]
    # swing, throw = [], []
    # for _ in range(n):
    #     a, b = map(int, input().split())
    #     swing.append(a)
    #     throw.append(b)
    swing = sorted(swing)
    throw = sorted(throw)
    max_swing = swing[-1]
    will_throw = [x for x in throw if x > max_swing]

    all_damage = sum(will_throw)
    answer = len(will_throw)
    if all_damage > m:
        for damage in will_throw:
            if all_damage - damage < m:
                print(answer)
            else:
                all_damage -= damage
                answer -= 1
    else:
        print(answer + ((m - all_damage) + (max_swing - 1)) // max_swing)

solve()

Fixed code:
# https://beta.atcoder.jp/contests/abc085/tasks/abc085_d

def solve():
    n, m = map(int, input().split())
    # n, m = 4, 1000000000
    # swing, throw = [1, 1, 1, 1], [1, 10000000, 99999999, 30000000]
    swing, throw = [], []
    for _ in range(n):
        a, b = map(int, input().split())
        swing.append(a)
        throw.append(b)
    swing = sorted(swing)
    throw = sorted(throw)
    max_swing = swing[-1]
    will_throw = [x for x in throw if x > max_swing]

    all_damage = sum(will_throw)
    answer = len(will_throw)
    if all_damage > m:
        for damage in will_throw:
            if all_damage - damage < m:
                print(answer)
                return
            else:
                all_damage -= damage
                answer -= 1
    else:
        print(answer + ((m - all_damage) + (max_swing - 1)) // max_swing)
        return

solve()
Buggy code:
N, H = [int(i) for i in input().split()]
ken_a = 0
ken_b = []
for _ in range(N):
    a,b = input().split()
    if a >= H or b >= H:
        print(1)
        quit()
    if ken_a < int(a):
        ken_a = int(a)
    ken_b.append(int(b))
res = 0
for b_ in ken_b:
    if b_ > ken_a:
        H = H - b_
        res += 1

res = res + (H//ken_a)
if H%ken_a != 0:
    res += 1
print(res)

Fixed code:
N, H = [int(i) for i in input().split()]
ken_a = 0
ken_b = []
for _ in range(N):
    a,b = input().split()
    if int(a) >= H or int(b) >= H:
        print(1)
        quit()
    if ken_a < int(a):
        ken_a = int(a)
    ken_b.append(int(b))
res = 0
for b_ in sorted(ken_b,reverse=True):
    if b_ > ken_a:
        H = H - b_
        res += 1
        if H <= 0:
            print(res)
            quit()

res = res + (H//ken_a)
if H%ken_a != 0:
    res += 1
print(res)
Buggy code:
import math
N, H = map(int, input().split())
A = 0
B = []
ans = 0
for _ in range(N):
    a, b = map(int, input().split())
    A = max(A, a)
    B.append(b)
B.sort(reverse=True)
for i in range(N):
    if B[i] < A:
        break
    H -= B[i]
    ans += 1

ans += (H // A) + 1
print(ans)

Fixed code:
import math
N, H = map(int, input().split())
A = 0
B = []
ans = 0
for _ in range(N):
    a, b = map(int, input().split())
    A = max(A, a)
    B.append(b)
B.sort(reverse=True)
for i in range(N):
    if B[i] < A:
        break
    if H <= 0:
        print(ans)
        exit()
    H -= B[i]
    ans += 1
if H % A == 0:
    ans += H // A
    print(ans)
else:
    ans += math.ceil(H / A)
    print(ans)
Buggy code:
a,b = map(int,input().split())
s = input()
s1,s2 = s.split("-")

if s.count("-") ==1:
  if a == len(s1) and b == len(s2):
    print("Yes")
  else:
    print("No")
  

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

 
if s.count("-") ==1:
  s1,s2 = s.split("-")
  if a == len(s1) and b == len(s2):
    print("Yes")
  else:
    print("No")
 
else:
  print("No")
Buggy code:
A, B = map(int, input().split())
S = input()

print ("Yes" if S[A] == A and S.count("-") == 1 else "No")

Fixed code:
A, B = map(int, input().split())
S = input()

print ("Yes" if S[A] == "-" and S.count("-") == 1 else "No")