Buggy python submission (verdict: Runtime Error):
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 or 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)

Fixed submission:
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 python submission (verdict: Time Limit Exceeded):
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 True:
    if len(b_list) >= 1:
        if b_list[-1] >= a:
            b = b_list.pop(-1)
            H -= b
            count += 1
            if H <= 0:
                break
        else:
            H -= a
            count += 1
            if H <= 0:
                break
    else:
        H -= a
        count += 1
        if H <= 0:
            break
        
print(count)

Fixed submission:
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 python submission (verdict: Time Limit Exceeded):
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()
b_list.reverse()
while True:
    if len(b_list) >= 1:
        if b_list[0] >= a:
            b = b_list.pop(0)
            H -= b
            count += 1
            if H <= 0:
                break
        else:
            H -= a
            count += 1
            if H <= 0:
                break
    else:
        H -= a
        count += 1
        if H <= 0:
            break
        
print(count)

Fixed submission:
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 python submission (verdict: Time Limit Exceeded):
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_list.sort()
a_list.reverse()
b_list.sort()
b_list.reverse()
while True:
    if len(b_list) >= 1:
        if b_list[0] >= a_list[0]:
            b = b_list.pop(0)
            H -= b
            count += 1
            if H <= 0:
                break
        else:
            a = a_list[0]
            H -= a
            count += 1
            if H <= 0:
                break
    else:
        a = a_list[0]
        H -= a
        count += 1
        if H <= 0:
            break
        
print(count)

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