Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

def main():
    N, H = map(int, input().split())
    A = [0] * N
    B = [0] * N
    for i in range(N):
        A[i], B[i] = map(int, input().split())

    cnt = 0
    max_A = max(A)
    sort_B = sorted(B, reverse=True)
    for b in sort_B:
        if b > max(A):
            cnt += 1
            H -= b
        else:
            break

        if H <= 0:
            break
    
    cnt += H // max(A) if H % max(A) == 0 else H // max(A) + 1
    print(cnt)



if __name__ == "__main__":
    main()

Fixed submission:
def main():
    N, H = map(int, input().split())

    A = [0] * N
    B = [0] * N

    num_list = []
    for i in range(N):
        a, b = map(int, input().split())
        A[i] = a
        B[i] = b

    sort_B = sorted(B, reverse=True)
    max_A = max(A)
    ans = 0
    for b in sort_B:
        if b > max_A:
            ans += 1
            H -= b
        else:
            break
        
        if H <= 0:
            break
    
    if H > 0:
        ans += -(-H // max_A)

    print(ans)

main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

def main():
    N, H = map(int, input().split())
    A = [0] * N
    B = [0] * N
    for i in range(N):
        A[i], B[i] = map(int, input().split())

    cnt = 0
    sort_B = sorted(B, reverse=True)
    for b in sort_B:
        if b > max(A):
            cnt += 1
            H -= b
        else:
            break
    
    cnt += H // max(A) if H % max(A) == 0 else H // max(A) + 1
    print(cnt)



if __name__ == "__main__":
    main()

Fixed submission:
def main():
    N, H = map(int, input().split())

    A = [0] * N
    B = [0] * N

    num_list = []
    for i in range(N):
        a, b = map(int, input().split())
        A[i] = a
        B[i] = b

    sort_B = sorted(B, reverse=True)
    max_A = max(A)
    ans = 0
    for b in sort_B:
        if b > max_A:
            ans += 1
            H -= b
        else:
            break
        
        if H <= 0:
            break
    
    if H > 0:
        ans += -(-H // max_A)

    print(ans)

main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N, H = map(int, input().split())
    A = [0] * N
    B = [0] * N
    for i in range(N):
        A[i], B[i] = map(int, input().split())

    cnt = 0
    sort_B = sorted(B, reverse=True)
    for b in sort_B:
        if b > max(A):
            cnt += 1
            H -= b
        else:
            break
    
    cnt += H // max(A) if H % max(A) == 0 else H // max(A) + 1
    print(cnt)



if __name__ == "__main__":
    main()

Fixed submission:
def main():
    N, H = map(int, input().split())

    A = [0] * N
    B = [0] * N

    num_list = []
    for i in range(N):
        a, b = map(int, input().split())
        A[i] = a
        B[i] = b

    sort_B = sorted(B, reverse=True)
    max_A = max(A)
    ans = 0
    for b in sort_B:
        if b > max_A:
            ans += 1
            H -= b
        else:
            break
        
        if H <= 0:
            break
    
    if H > 0:
        ans += -(-H // max_A)

    print(ans)

main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N, H = map(int, input().split())

    A = [0] * N
    B = [0] * N

    num_list = []
    for i in range(N):
        a, b = map(int, input().split())
        A[i] = a
        B[i] = b
        num_list.append(a)
        num_list.append(b)

    num = sorted(num_list, reverse=True)

    ans = 0
    for a in num:
        if a in A:
            ans += -(-H // a)
            break
        else:
            ans += 1
            H -= a

    print(ans)

main()

Fixed submission:
def main():
    N, H = map(int, input().split())

    A = [0] * N
    B = [0] * N

    num_list = []
    for i in range(N):
        a, b = map(int, input().split())
        A[i] = a
        B[i] = b

    sort_B = sorted(B, reverse=True)
    max_A = max(A)
    ans = 0
    for b in sort_B:
        if b > max_A:
            ans += 1
            H -= b
        else:
            break
        
        if H <= 0:
            break
    
    if H > 0:
        ans += -(-H // max_A)

    print(ans)

main()