Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/python3
def left(i):
    return i * 2

def right(i):
    return i * 2 + 1

def parent(i):
    return i // 2

def heap_increase_key(A, key):
    i = len(A) - 1
    A[i] = key
    while i > 1 and A[parent(i)] < A[i]:
        A[i], A[parent(i)] = A[parent(i)], A[i]
        i = parent(i)

def insert(A, key):
    A.append(-float('inf'))
    heap_increase_key(A, key)

def max_heapify(A, i):
    H = len(A) - 1
    if H == 0:
        return
    l = left(i)
    r = right(i)

    child = {}
    child[i] = A[i] 
    if l <= H:
        child[l] = A[l]
    if r <= H:
        child[r] = A[r]
    largest = max(child.items(), key=lambda x:x[1])[0]

    if largest != i:
        A[i], A[largest] = A[largest], A[i]
        max_heapify(A, largest)

def heap_extract_max(A):
    H = len(A) - 1
    m = A[1]
    A[1] = A[H]
    del A[H]
    max_heapify(A, 1)
    return m

# main
A = [0]
while True:
    s = input().split()
    if s[0].startswith('i'):
        insert(A, int(s[1]))
    elif s[0].startswith('ex'):
        print(heap_extract_max(A))
    if s[0] == 'end':
        exit()

Fixed submission:
#!/usr/bin/python3
import sys
import heapq

# main
q = []
S = sys.stdin.readlines()
for line in S:
    if line[0].startswith('i'):
        heapq.heappush(q, -int(line.split()[1]))
    elif line[1] == 'x':
        print(-heapq.heappop(q))
    else:
        exit()

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/python3
import sys
def left(i):
    return i * 2

def right(i):
    return i * 2 + 1

def parent(i):
    return i // 2

def heap_increase_key(A, key):
    i = len(A) - 1
    A[i] = key
    while i > 1 and A[parent(i)] < A[i]:
        A[i], A[parent(i)] = A[parent(i)], A[i]
        i = parent(i)

def insert(A, key):
    A.append(-float('inf'))
    heap_increase_key(A, key)

def max_heapify(A, i):
    H = len(A) - 1
    if H == 0:
        return
    l = left(i)
    r = right(i)

    child = {}
    child[i] = A[i] 
    if l <= H:
        child[l] = A[l]
    if r <= H:
        child[r] = A[r]
    largest = max(child.items(), key=lambda x:x[1])[0]

    if largest != i:
        A[i], A[largest] = A[largest], A[i]
        max_heapify(A, largest)

def heap_extract_max(A):
    H = len(A) - 1
    m = A[1]
    A[1] = A[H]
    del A[H]
    max_heapify(A, 1)
    return m

# main
A = [0]
while True:
    s = sys.stdin.readline().split()
    if s[0].startswith('i'):
        insert(A, int(s[1]))
    elif s[0].startswith('ex'):
        print(heap_extract_max(A))
    if s[0] == 'end':
        exit()

Fixed submission:
#!/usr/bin/python3
import sys
import heapq

# main
q = []
S = sys.stdin.readlines()
for line in S:
    if line[0].startswith('i'):
        heapq.heappush(q, -int(line.split()[1]))
    elif line[1] == 'x':
        print(-heapq.heappop(q))
    else:
        exit()

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/python3
import sys
import queue

# main
q = queue.PriorityQueue()
m = 2 * (10 ** 9)
while True:
    s = sys.stdin.readline().split()
    if s[0].startswith('i'):
        q.put(m - int(s[1]))
    elif s[0].startswith('ex'):
        print(m - q.get())
    if s[0] == 'end':
        exit()

Fixed submission:
#!/usr/bin/python3
import sys
import heapq

# main
q = []
S = sys.stdin.readlines()
for line in S:
    if line[0].startswith('i'):
        heapq.heappush(q, -int(line.split()[1]))
    elif line[1] == 'x':
        print(-heapq.heappop(q))
    else:
        exit()

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/python3
import sys
import queue

# main
q = queue.PriorityQueue()
m = 2 * (10 ** 9)
S = sys.stdin.readlines()
for line in S:
    s = line.split()
    if s[0].startswith('i'):
        q.put(m - int(s[1]))
    elif s[0].startswith('ex'):
        print(m - q.get())
    if s[0] == 'end':
        exit()

Fixed submission:
#!/usr/bin/python3
import sys
import heapq

# main
q = []
S = sys.stdin.readlines()
for line in S:
    if line[0].startswith('i'):
        heapq.heappush(q, -int(line.split()[1]))
    elif line[1] == 'x':
        print(-heapq.heappop(q))
    else:
        exit()