Problem p03472 (python)

Fixed submission:
import sys
import heapq
import time
from math import *

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, H] = [long(input_raw[0]), long(input_raw[1])]
    a_list = []
    b_list = []
    for i in range(N):
        input_raw = read_func().strip().split()
        [a, b] = [-long(input_raw[0]), -long(input_raw[1])]
        heapq.heappush(a_list, (a, i))
        heapq.heappush(b_list, (b, i))
    (max_a, max_a_i) = a_list[0]
    count = 0
    while (H > 0):
        if len(b_list) > 0:
            (max_b, max_b_i) = b_list[0]
        else:
            max_b = 0
        if -max_a >= -max_b:
            attack_num = (H ) / (-max_a)
            attack_num += (1 if ( H % (-max_a) >0 ) else 0)
            H += attack_num  * max_a
            count += attack_num
            #print "max a", H, count
        #elif max_a_i != max_b_i:
        else:
            heapq.heappop(b_list)
            H += max_b
            count += 1
            #print "max_b",H, count
        '''
        elif H + max_b <= 0:
            heapq.heappop(b_list)
            H += max_b
            count += 1
            print "max_a_i == max_b_i and max b can ",H, count
        else:
            attack_num = (H  + max_b) / (-max_a)
            attack_num += 1 if ( ((H + max_b)  % (-max_a)) >0 ) else 0
            H += attack_num * max_a
            count += attack_num
            print "max_a_i == max_b_i and max b cant ", H, count
        '''
    print count;

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
import heapq
import time
from math import *

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, H] = [long(input_raw[0]), long(input_raw[1])]
    a_list = []
    b_list = []
    for i in range(N):
        input_raw = read_func().strip().split()
        [a, b] = [-long(input_raw[0]), -long(input_raw[1])]
        heapq.heappush(a_list, (a, i))
        heapq.heappush(b_list, (b, i))
    (max_a, max_a_i) = a_list[0]
    count = 0
    while (H > 0):
        (max_b, max_b_i) = b_list[0]
        if -max_a >= -max_b:
            attack_num = (H ) / (-max_a)
            attack_num += (1 if ( H % (-max_a) >0 ) else 0)
            H += attack_num  * max_a
            count += attack_num
            #print "max a", H, count
        #elif max_a_i != max_b_i:
        else:
            heapq.heappop(b_list)
            H += max_b
            count += 1
            #print "max_b",H, count
        '''
        elif H + max_b <= 0:
            heapq.heappop(b_list)
            H += max_b
            count += 1
            print "max_a_i == max_b_i and max b can ",H, count
        else:
            attack_num = (H  + max_b) / (-max_a)
            attack_num += 1 if ( ((H + max_b)  % (-max_a)) >0 ) else 0
            H += attack_num * max_a
            count += attack_num
            print "max_a_i == max_b_i and max b cant ", H, count
        '''
    print count;

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
import heapq
import time
from math import *

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, H] = [long(input_raw[0]), long(input_raw[1])]
    a_list = []
    b_list = []
    for i in range(N):
        input_raw = read_func().strip().split()
        [a, b] = [-long(input_raw[0]), -long(input_raw[1])]
        heapq.heappush(a_list, (a, i))
        heapq.heappush(b_list, (b, i))
    (max_a, max_a_i) = a_list[0]
    count = 0
    while (H > 0):
        (max_b, max_b_i) = b_list[0]
        if -max_a >= -max_b:
            attack_num = (H ) / (-max_a)
            attack_num += (1 if ( H % (-max_a) >0 ) else 0)
            H += attack_num  * max_a
            count += attack_num
            print "max a", H, count
        #elif max_a_i != max_b_i:
        else:
            heapq.heappop(b_list)
            H += max_b
            count += 1
            print "max_b",H, count
        '''
        elif H + max_b <= 0:
            heapq.heappop(b_list)
            H += max_b
            count += 1
            print "max_a_i == max_b_i and max b can ",H, count
        else:
            attack_num = (H  + max_b) / (-max_a)
            attack_num += 1 if ( ((H + max_b)  % (-max_a)) >0 ) else 0
            H += attack_num * max_a
            count += attack_num
            print "max_a_i == max_b_i and max b cant ", H, count
        '''
    print count;

if __name__ == '__main__':
    main()