Buggy python submission (verdict: Time Limit Exceeded):
def swap(A, x, y):
    i = A[x]
    A[x] = A[y]
    A[y] = i

def left(i):
    return ((i+1) * 2) - 1

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

def  maxHeapify(A, i, H):
    l = left(i)
    r = right(i)
#    print("i:{} left:{} right:{} MAX:{}".format(i,l,r,H))
    #  ????????????????????????????????§???????????§????????????????????¶
    if l < H and A[l] > A[i]:
#        print("i[{}]:{} left[{}]:{}".format(i,A[i],l,A[l]))
        largest = l
    else:
        largest = i
    if r < H and A[r] > A[largest]:
#        print("i[{}]:{} left[{}]:{}".format(i,A[i],l,A[l]))
        largest = r

    if largest != i: #// i ???????????????????????§????????´???
        swap(A, i, largest) # ??????
        maxHeapify(A, largest, H) # ?????°??????????????????

def buildMaxHeap(A, H):
    for i in range(int(H/2)-1,-1,-1):
        maxHeapify(A, i, H)

def main():

    """ ????????? """
    end = False
    S = []
    
    while end != True:
        cmd = input()
#        print("cmd:{} S:{}".format(cmd,S))
        if cmd == "extract":
            buildMaxHeap(S, len(S))
            print(S[0])
            S = S[1:]
        elif cmd == "end":
            end = True
        elif cmd[0] == "i":
            S.append(int(cmd[7:]))

if __name__ == '__main__':
    main()

Fixed submission:
import sys

def extractMax(A):
    x = A[0]
    A[0] = A[-1]
    A.pop()
    H = len(A)
    i = 0
    while i < H: # ???????????????
        v = A[i]
        rv = 0
        lv = 0
        r = (i+1) * 2
        l = r - 1
        if l < H:
            lv = A[l]
            if r < H:
                rv = A[r]

        if v < lv and lv > rv:
            A[l] = v
            A[i] = lv
            i = l
        elif v < rv:
            A[r] = v
            A[i] = rv
            i = r
        else:
            break
    return x

def insert(A, n):
    i = len(A)
    A.append(n)
    while i > 0: # ???????????????
        p = int((i + 1) / 2) - 1
        v = A[i]
        pv = A[p]
        if pv < v: # ???????????§??????
            A[p] = v
            A[i] = pv
            i = p
        else:
            break

def main():
    """ ????????? """
    istr = sys.stdin.read()
    cmds = list(istr.splitlines())

    end = False
    S = []
    for cmd in cmds: # input()
#        print("cmd:{} S:{}".format(cmd,S))
        if cmd[0] == "i":
            insert(S,int(cmd[7:]))

        elif cmd == "extract":
            a = extractMax(S)
            print(a)

        elif cmd == "end":
            end = True
            break


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def extractMax(A):
    x = A[0]
    A[0] = A[-1]
    A.pop()
    H = len(A)
    i = 0
    while i < H:
        r = (i+1) * 2
        l = r - 1
        if l < H:
            lv = A[l]
        else:
            lv = 0
        if r < H:
            rv = A[r]
        else:
            rv = 0
        if lv == 0 and rv == 0:
            break
        elif A[i] < lv and lv > rv:
            A[l] = A[i]
            A[i] = lv
            i = l
        elif A[i] < rv:
            A[r] = A[i]
            A[i] = rv
            i = r
        else:
            break
    return x

def insert(A,n):
    A.append(n)
    i = len(A) - 1
    while i > 0:
        p = int((i + 1) / 2) - 1
        if A[p] < A[i]: # ???????????§??????
            x = A[p]
            A[p] = A[i]
            A[i] = x
            i = p
        else:
            break

def main():

    """ ????????? """
    end = False
    S = []
    
    while end != True:
        cmd = input()
#        print("cmd:{} S:{}".format(cmd,S))
        if cmd == "extract":
            a = extractMax(S)
            print(a)
            
        elif cmd == "end":
            end = True

        elif cmd[0] == "i":
            insert(S,int(cmd[7:]))

if __name__ == '__main__':
    main()

Fixed submission:
import sys

def extractMax(A):
    x = A[0]
    A[0] = A[-1]
    A.pop()
    H = len(A)
    i = 0
    while i < H: # ???????????????
        v = A[i]
        rv = 0
        lv = 0
        r = (i+1) * 2
        l = r - 1
        if l < H:
            lv = A[l]
            if r < H:
                rv = A[r]

        if v < lv and lv > rv:
            A[l] = v
            A[i] = lv
            i = l
        elif v < rv:
            A[r] = v
            A[i] = rv
            i = r
        else:
            break
    return x

def insert(A, n):
    i = len(A)
    A.append(n)
    while i > 0: # ???????????????
        p = int((i + 1) / 2) - 1
        v = A[i]
        pv = A[p]
        if pv < v: # ???????????§??????
            A[p] = v
            A[i] = pv
            i = p
        else:
            break

def main():
    """ ????????? """
    istr = sys.stdin.read()
    cmds = list(istr.splitlines())

    end = False
    S = []
    for cmd in cmds: # input()
#        print("cmd:{} S:{}".format(cmd,S))
        if cmd[0] == "i":
            insert(S,int(cmd[7:]))

        elif cmd == "extract":
            a = extractMax(S)
            print(a)

        elif cmd == "end":
            end = True
            break


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def extractMax(A):
    x = A[0]
    A[0] = A[-1]
    A.pop()
    H = len(A)
    i = 0
    while i < H:
        r = (i+1) * 2
        l = r - 1
        if l < H:
            lv = A[l]
        else:
            lv = 0
        if r < H:
            rv = A[r]
        else:
            rv = 0
        if lv == 0 and rv == 0:
            break
        elif A[i] < lv and lv > rv:
            A[l] = A[i]
            A[i] = lv
            i = l
        elif A[i] < rv:
            A[r] = A[i]
            A[i] = rv
            i = r
        else:
            break
    return x

def insert(A,n):
    A.append(n)
    i = len(A) - 1
    while i > 0:
        p = int((i + 1) / 2) - 1
        if A[p] < A[i]: # ???????????§??????
            x = A[p]
            A[p] = A[i]
            A[i] = x
            i = p
        else:
            break

def main():

    """ ????????? """
    end = False
    S = []
    
    while end != True:
        cmd = input()
#        print("cmd:{} S:{}".format(cmd,S))
        if cmd == "extract":
            a = extractMax(S)
            print(a)
            
        elif cmd == "end":
            end = True

        elif cmd[0] == "i":
            insert(S,int(cmd[7:]))

if __name__ == '__main__':
    main()

Fixed submission:
import sys

def extractMax(A):
    x = A[0]
    A[0] = A[-1]
    A.pop()
    H = len(A)
    i = 0
    while i < H: # ???????????????
        v = A[i]
        rv = 0
        lv = 0
        r = (i+1) * 2
        l = r - 1
        if l < H:
            lv = A[l]
            if r < H:
                rv = A[r]

        if v < lv and lv > rv:
            A[l] = v
            A[i] = lv
            i = l
        elif v < rv:
            A[r] = v
            A[i] = rv
            i = r
        else:
            break
    return x

def insert(A, n):
    i = len(A)
    A.append(n)
    while i > 0: # ???????????????
        p = int((i + 1) / 2) - 1
        v = A[i]
        pv = A[p]
        if pv < v: # ???????????§??????
            A[p] = v
            A[i] = pv
            i = p
        else:
            break

def main():
    """ ????????? """
    istr = sys.stdin.read()
    cmds = list(istr.splitlines())

    end = False
    S = []
    for cmd in cmds: # input()
#        print("cmd:{} S:{}".format(cmd,S))
        if cmd[0] == "i":
            insert(S,int(cmd[7:]))

        elif cmd == "extract":
            a = extractMax(S)
            print(a)

        elif cmd == "end":
            end = True
            break


if __name__ == '__main__':
    main()