Buggy python submission (verdict: Runtime Error):
n,h = (int(i) for i in input().split())
x = [[int(i) for i in input().split()] for i in range(n)]
a,b = 0,[]
for j in x:
	if a < j[0]: a = j[0]
	b.append(j[1])
b = [i for i in b if i>a]
b.sort().reverse()
if h <= sum(b):
	num,i = 0,0
	while h > 0:
		h -= b[i]
		num += 1
		i += 1
else:
	h -= sum(b)
	num = (h+a-1)//a + len(b)
print(num)

Fixed submission:
def main():
    N, H = map(int, input().split())
    AB = (tuple(map(int, input().split())) for _ in [0] * N)
    a, b = [], []
    appenda, appendb = a.append, b.append
    for i, j in AB:
        appenda(i)
        appendb(j)

    amax = max(a)
    b = [i for i in b if i > amax]
    b.sort(reverse=1)
    energy = H
    if energy <= sum(b):
        attack = 0
        i = 0
        while energy > 0:
            energy -= b[i]
            attack += 1
            i += 1
    else:
        energy -= sum(b)
        attack = (energy + amax - 1) // amax + len(b)

    print(attack)

main()

Buggy python submission (verdict: Runtime Error):
n,h = (int(i) for i in input().split())
x = [[int(i) for i in input().split()] for i in range(n)]
a,b = 0,[]
for j in x:
	if a < j[0]: a = j[0]
	b.append(j[1])
num = 0
b.sort().reverse()
for j2 in b:
	if j2 >=a and h>0: 
	    h -= j2
		num +=1
	else: break
if h<=0: print(num)
else:
	if h%a==0: print((h-h%a)//a + num)
	else: print((h-h%a)//a + num + 1)

Fixed submission:
def main():
    N, H = map(int, input().split())
    AB = (tuple(map(int, input().split())) for _ in [0] * N)
    a, b = [], []
    appenda, appendb = a.append, b.append
    for i, j in AB:
        appenda(i)
        appendb(j)

    amax = max(a)
    b = [i for i in b if i > amax]
    b.sort(reverse=1)
    energy = H
    if energy <= sum(b):
        attack = 0
        i = 0
        while energy > 0:
            energy -= b[i]
            attack += 1
            i += 1
    else:
        energy -= sum(b)
        attack = (energy + amax - 1) // amax + len(b)

    print(attack)

main()

Buggy python submission (verdict: Runtime Error):
n,h = (int(i) for i in input().split())
x = [[int(i) for i in input().split()] for i in range(n)]
a,b = 0,[]
for j in x:
	if a < j[0]: a = j[0]
	b.append(j[1])
num = 0
for j2 in b:
	if j2 >= a and h>0:
		h -= j2
		num +=1
if h<=0: print(num)
else:
	if h%a==0: answer = (h-h%a)//a + num
	else: answer = (h-h%a)//a + num + 1
    print(answer)

Fixed submission:
def main():
    N, H = map(int, input().split())
    AB = (tuple(map(int, input().split())) for _ in [0] * N)
    a, b = [], []
    appenda, appendb = a.append, b.append
    for i, j in AB:
        appenda(i)
        appendb(j)

    amax = max(a)
    b = [i for i in b if i > amax]
    b.sort(reverse=1)
    energy = H
    if energy <= sum(b):
        attack = 0
        i = 0
        while energy > 0:
            energy -= b[i]
            attack += 1
            i += 1
    else:
        energy -= sum(b)
        attack = (energy + amax - 1) // amax + len(b)

    print(attack)

main()

Buggy python submission (verdict: Runtime Error):
n,h = (int(i) for i in input().split())
x = [[int(i) for i in input().split()] for i in range(n)]
a,b = 0,[]
for j in x:
	if j[0] > a: a = j[0]
	b.append(j[1])
b.sort()
while b[0]<=a: b = b[1:]
h -= sum(b)
if h%a==0: answer = (h-h%a)//a + len(b)
else: answer = (h-h%a)//a + len(b) + 1
print(answer)

Fixed submission:
def main():
    N, H = map(int, input().split())
    AB = (tuple(map(int, input().split())) for _ in [0] * N)
    a, b = [], []
    appenda, appendb = a.append, b.append
    for i, j in AB:
        appenda(i)
        appendb(j)

    amax = max(a)
    b = [i for i in b if i > amax]
    b.sort(reverse=1)
    energy = H
    if energy <= sum(b):
        attack = 0
        i = 0
        while energy > 0:
            energy -= b[i]
            attack += 1
            i += 1
    else:
        energy -= sum(b)
        attack = (energy + amax - 1) // amax + len(b)

    print(attack)

main()

Buggy python submission (verdict: Time Limit Exceeded):
n,h = (int(i) for i in input().split())
x = [[int(i) for i in input().split()] for i in range(n)]
a,b = [],[]
for j in x:
	a.append(j[0])
	b.append(j[1])
num = 0
for j2 in b:
	if j2 >= max(a):
		h -= j2
		num +=1
if h%max(a)==0: answer = (h-h%max(a))//max(a) + num
else: answer = (h-h%max(a))//max(a) + num + 1
print(answer)

Fixed submission:
def main():
    N, H = map(int, input().split())
    AB = (tuple(map(int, input().split())) for _ in [0] * N)
    a, b = [], []
    appenda, appendb = a.append, b.append
    for i, j in AB:
        appenda(i)
        appendb(j)

    amax = max(a)
    b = [i for i in b if i > amax]
    b.sort(reverse=1)
    energy = H
    if energy <= sum(b):
        attack = 0
        i = 0
        while energy > 0:
            energy -= b[i]
            attack += 1
            i += 1
    else:
        energy -= sum(b)
        attack = (energy + amax - 1) // amax + len(b)

    print(attack)

main()