Buggy python submission (verdict: Runtime Error):
from collections import deque
N,H=map(int,input().split())
a=deque([]);b=deque([])
for _ in range(N):
    ai,bi=map(int,input().split())
    a.append(ai)
    b.append(bi)
ma=max(a)
bs=sorted(b,reverse=True)
bc=0
for i in range(len(bs)):
    bi=b[i]
    if bi>ma:
        bc+=b[i]
        if H<=bc:
            print(i+1)
            exit()
ans=(H-bc)//ma+len(bc)
if (H-bc)%ma==0:
    print(ans)
else:
    print(ans+1)

Fixed submission:
N,H=map(int,input().split())
S=[[int(x) for x in input().split()] for _ in range(N)]
A,B=zip(*S)
A=max(A)
B=[b for b in B if b>A]
B.sort(reverse=True)
ans=0
cnt=0
for b in B:
    if H<=0:
        break
    cnt+=1
    H-=b
if H>0:
    cnt+=(H-1)//A+1
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
N,H=map(int,input().split())
a=deque([]);b=deque([])
for _ in range(N):
    ai,bi=map(int,input().split())
    a.append(ai)
    b.append(bi)
bb=deque([])
ma=max(a)
bc=0
for _ in range(N):
    bi=max(b)
    b.remove(bi)
    if bi>ma:
        bb.append(bi)
        bc+=bi
    if bc>=H:
        print(len(bb))
        exit()
ans=(H-sum(bb))//ma+len(bb)
if (H-sum(bb))%ma==0:
    print(ans)
else:
    print(ans+1)

Fixed submission:
N,H=map(int,input().split())
S=[[int(x) for x in input().split()] for _ in range(N)]
A,B=zip(*S)
A=max(A)
B=[b for b in B if b>A]
B.sort(reverse=True)
ans=0
cnt=0
for b in B:
    if H<=0:
        break
    cnt+=1
    H-=b
if H>0:
    cnt+=(H-1)//A+1
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
N,H=map(int,input().split())
a=deque([]);b=deque([])
for _ in range(N):
    ai,bi=map(int,input().split())
    a.append(ai)
    b.append(bi)
bb=deque([])
ma=max(a)
for _ in range(N):
    bi=max(b)
    b.remove(bi)
    if bi>ma:
        bb.append(bi)
    if sum(bb)>=H:
        print(len(bb))
        exit()
ans=(H-sum(bb))//ma+len(bb)
if (H-sum(bb))%ma==0:
    print(ans)
else:
    print(ans+1)

Fixed submission:
N,H=map(int,input().split())
S=[[int(x) for x in input().split()] for _ in range(N)]
A,B=zip(*S)
A=max(A)
B=[b for b in B if b>A]
B.sort(reverse=True)
ans=0
cnt=0
for b in B:
    if H<=0:
        break
    cnt+=1
    H-=b
if H>0:
    cnt+=(H-1)//A+1
print(cnt)

Buggy python submission (verdict: Runtime Error):
from collections import deque
N,H=map(int,input().split())
a=deque([]);b=deque([])
for _ in range(N):
    ai,bi=map(int,input().split())
    a.append(ai)
    b.append(bi)
bb=deque([])
ma=max(a)
for _ in range(N):
    bi=b.pop[b.index(max(b))]
    if bi>ma:
        bb.append(bi)
    if sum(bb)>=H:
        print(len(bb))
        exit()
ans=(H-sum(bb))//ma+len(bb)
if (H-sum(bb))%ma==0:
    print(ans)
else:
    print(ans+1)

Fixed submission:
N,H=map(int,input().split())
S=[[int(x) for x in input().split()] for _ in range(N)]
A,B=zip(*S)
A=max(A)
B=[b for b in B if b>A]
B.sort(reverse=True)
ans=0
cnt=0
for b in B:
    if H<=0:
        break
    cnt+=1
    H-=b
if H>0:
    cnt+=(H-1)//A+1
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

N,H=map(int,input().split())
a=deque([]);b=deque([])
for _ in range(N):
    ai,bi=map(int,input().split())
    a.append(ai)
    b.append(bi)
bb=deque([])
for i in range(N):
    if b[i]>=max(a):
        bb.append(b[i])
if sum(bb)>=H:
    print(len(bb))
else:
    ans=int((H-sum(bb))/max(a))+len(bb)
    if (H-sum(bb))%max(a)==0:
        print(ans)
    else:
        print(ans+1)

Fixed submission:
N,H=map(int,input().split())
S=[[int(x) for x in input().split()] for _ in range(N)]
A,B=zip(*S)
A=max(A)
B=[b for b in B if b>A]
B.sort(reverse=True)
ans=0
cnt=0
for b in B:
    if H<=0:
        break
    cnt+=1
    H-=b
if H>0:
    cnt+=(H-1)//A+1
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
N,H=map(int,input().split())
a=[];b=[]
for _ in range(N):
    ai,bi=map(int,input().split())
    a.append(ai)
    b.append(bi)
bb=[]
for i in range(N):
    if b[i]>=max(a):
        bb.append(b[i])
if sum(bb)>=H:
    print(len(bb))
else:
    ans=int((H-sum(bb))/max(a))+len(bb)
    if (H-sum(bb))%max(a)==0:
        print(ans)
    else:
        print(ans+1)

Fixed submission:
N,H=map(int,input().split())
S=[[int(x) for x in input().split()] for _ in range(N)]
A,B=zip(*S)
A=max(A)
B=[b for b in B if b>A]
B.sort(reverse=True)
ans=0
cnt=0
for b in B:
    if H<=0:
        break
    cnt+=1
    H-=b
if H>0:
    cnt+=(H-1)//A+1
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
N,H=map(int,input().split())
a=[];b=[]
for _ in range(N):
    ai,bi=map(int,input().split())
    a.append(ai)
    b.append(bi)
bb=[]
for i in range(N):
    if b[i]>=max(a):
        bb.append(b[i])
if sum(bb)>=H:
    print(len(bb))
else:
    ans=int((H-sum(bb))/max(a))+len(bb)
    if (H-sum(bb))%max(a)==0:
        print(ans)
    else:
        print(ans+1)

Fixed submission:
N,H=map(int,input().split())
S=[[int(x) for x in input().split()] for _ in range(N)]
A,B=zip(*S)
A=max(A)
B=[b for b in B if b>A]
B.sort(reverse=True)
ans=0
cnt=0
for b in B:
    if H<=0:
        break
    cnt+=1
    H-=b
if H>0:
    cnt+=(H-1)//A+1
print(cnt)