Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys


def max_heapify(index):
    left, right, largest = 2 * index, 2 * index + 1, None

    if left <= heap_length and heap_array[left] > heap_array[index]:
        largest = left
    else:
        largest = index

    if right <= heap_length and heap_array[right] > heap_array[largest]:
        largest = right

    if largest != index:
        heap_array[index], heap_array[largest] = heap_array[largest], heap_array[index]
        max_heapify(largest)

    return None


def extract():
    global heap_length
    if heap_length < 1:
        raise SystemExit('Heap underflow!')
    heap_max = heap_array[1]
    heap_array[1] = heap_array[heap_length]
    heap_length -= 1
    # print('max', heap_max, heap_length, heap_array)
    print(heap_max)
    max_heapify(1)
    return heap_max


def insert(data):
    global heap_length
    heap_length += 1
    heap_array.append(-1)
    # print(heap_length, heap_array)
    # assert len(heap_array) == heap_length + 1
    insert_data(heap_length, data)


def insert_data(index, data):
    if data < heap_array[index]:
        raise SystemExit('Not a max-heap!')
    heap_array[index] = data
    while index > 1:
        parent = index // 2
        if heap_array[parent] >= heap_array[index]:
            break
        heap_array[index], heap_array[parent] = heap_array[parent], heap_array[index]
        index //= 2
    return None


def action(_command, _content):
    if _command.startswith('in'):
        insert(int(_content))
    elif _command.startswith('ex'):
        extract()
    else:
        pass

    return None


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    command_list = list(map(lambda x: x.split(), _input))

    allowed_commands = ('insert', 'extract', 'end')
    heap_array, heap_length = [None], 0
    for each in command_list:
        command, content = each[0], each[-1]
        if command not in allowed_commands:
            raise SystemExit('Illegal command!')

        action(command, content)

Fixed submission:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys
import heapq as hp

if __name__ == '__main__':
    _input = sys.stdin.readlines()

    heap_array = []
    for each in _input:
        if each.startswith('in'):
            hp.heappush(heap_array, -1 * int(each[7:]))
        elif each.startswith('ex'):
            print(-1 * hp.heappop(heap_array))

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys


def max_heapify(index):
    # global heap_length
    left, right, largest = 2 * index, 2 * index + 1, None

    if left <= heap_length and heap_array[left] > heap_array[index]:
        largest = left
    else:
        largest = index

    if right <= heap_length and heap_array[right] > heap_array[largest]:
        largest = right

    if largest != index:
        heap_array[index], heap_array[largest] = heap_array[largest], heap_array[index]
        max_heapify(largest)

    return None


def extract():
    global heap_length
    if heap_length < 1:
        raise SystemExit('Heap underflow!')
    # the root of the heap is always the largest
    heap_max = heap_array[1]

    # move new data to heap root
    heap_array[1] = heap_array[heap_length]
    heap_length -= 1

    # print
    heap_array.pop()
    print(heap_max)
    max_heapify(1)
    # assert len(heap_array) == heap_length + 1
    return heap_max


def insert(data):
    global heap_length
    heap_length += 1
    heap_array.append(-1)
    # assert len(heap_array) == heap_length + 1
    insert_data(heap_length, data)


def insert_data(index, data):
    if data < heap_array[index]:
        raise SystemExit('Not a max-heap!')
    heap_array[index] = data
    while index > 1:
        parent = index // 2
        if heap_array[parent] >= heap_array[index]:
            break
        heap_array[index], heap_array[parent] = heap_array[parent], heap_array[index]
        index //= 2
    return None


def action(_command):
    if _command.startswith('in'):
        insert(int(each[7:]))
    elif _command.startswith('ex'):
        extract()

    return None


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    # command_list = list(map(lambda x: x.split(), _input))

    # allowed_commands = ('insert', 'extract', 'end')
    heap_array, heap_length = [-1], 0
    for each in _input:
        # command, content = each[0], each[-1]
        # if command not in allowed_commands:
        #     raise SystemExit('Illegal command!')

        action(each)

Fixed submission:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys
import heapq as hp

if __name__ == '__main__':
    _input = sys.stdin.readlines()

    heap_array = []
    for each in _input:
        if each.startswith('in'):
            hp.heappush(heap_array, -1 * int(each[7:]))
        elif each.startswith('ex'):
            print(-1 * hp.heappop(heap_array))

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys


def max_heapify(index):
    # global heap_length
    left, right, largest = 2 * index, 2 * index + 1, None

    if left <= heap_length and heap_array[left] > heap_array[index]:
        largest = left
    else:
        largest = index

    if right <= heap_length and heap_array[right] > heap_array[largest]:
        largest = right

    if largest != index:
        heap_array[index], heap_array[largest] = heap_array[largest], heap_array[index]
        max_heapify(largest)

    return None


def extract():
    global heap_length
    if heap_length < 1:
        raise SystemExit('Heap underflow!')
    # the root of the heap is always the largest
    heap_max = heap_array[1]

    # move new data to heap root
    heap_array[1] = heap_array[heap_length]
    heap_length -= 1

    # print
    heap_array.pop()
    print(heap_max)
    max_heapify(1)
    # assert len(heap_array) == heap_length + 1
    return heap_max


def insert(data):
    global heap_length
    heap_length += 1
    heap_array.append(-1)
    # assert len(heap_array) == heap_length + 1
    insert_data(heap_length, data)


def insert_data(index, data):
    if data < heap_array[index]:
        raise SystemExit('Not a max-heap!')
    heap_array[index] = data
    while index > 1:
        parent = index // 2
        if heap_array[parent] >= heap_array[index]:
            break
        heap_array[index], heap_array[parent] = heap_array[parent], heap_array[index]
        index //= 2
    return None


def action(_command):
    if _command.startswith('in'):
        insert(int(each[7:]))
    elif _command.startswith('ex'):
        extract()

    return None


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    # command_list = list(map(lambda x: x.split(), _input))

    # allowed_commands = ('insert', 'extract', 'end')
    heap_array, heap_length = [-1], 0
    for each in _input:
        # command, content = each[0], each[-1]
        # if command not in allowed_commands:
        #     raise SystemExit('Illegal command!')

        action(each)

Fixed submission:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys
import heapq as hp

if __name__ == '__main__':
    _input = sys.stdin.readlines()

    heap_array = []
    for each in _input:
        if each.startswith('in'):
            hp.heappush(heap_array, -1 * int(each[7:]))
        elif each.startswith('ex'):
            print(-1 * hp.heappop(heap_array))