Buggy python submission (verdict: Runtime Error):
I = 0
L = 1
R = 2
P = 3
B = 4
D = 5
H = 6

def search(N, A, B, num):
    """ N ??? Nodes A???Preorder?????? B???Inorder??????
        ??????????????????????????§??? root ??? index ????????? """
#    print(A)
#    print(B)
    root = A[0]
    ld = num
    for i in range(num):
        if B[i] == root:
            ld = i
            break
    if ld > 0:
        N[root][L] = search(N,A[1:ld+1],B[:ld],ld)
    rt = ld + 1
    if rt < num:
        N[root][R] = search(N,A[rt:],B[rt:],num - rt)
    return root

def getroot(A, id):
    if A[id][P] > -1:
        return getroot(A,A[id][P])
    return A[id][I]

def preorder(N,id,A):
    if id < 0:
        return
    A.append(id)
    preorder(N,N[id][L],A)
    preorder(N,N[id][R],A)

def inorder(N,id,A):
    if id < 0:
        return
    inorder(N,N[id][L],A)
    A.append(id)
    inorder(N,N[id][R],A)

def postorder(N,id,A):
    if id < 0:
        return
    postorder(N,N[id][L],A)
    postorder(N,N[id][R],A)
    A.append(id)


def main():

    """ ????????? """
    num = int(input().strip())
    plist = list(map(int,input().split()))
    ilist = list(map(int,input().split()))
    pos = []
    
    nodes = [[i, -1, -1, -1, -1, 0, 0] for i in range(num)]

    search(nodes,plist,ilist,num)
#    pre = [""]
#    ino = [""]
    pos = []

#    preorder(nodes,plist[0],pre)
#    inorder(nodes,plist[0],ino)
    postorder(nodes,plist[0],pos)

#    print("Preorder")
#    print(" ".join(map(str,pre)))
#    print("Inorder")
#    print(" ".join(map(str,ino)))
#    print("Postorder")
    print(" ".join(map(str,pos)))

if __name__ == '__main__':
    main()

Fixed submission:
I = 0
L = 1
R = 2
P = 3
B = 4
D = 5
H = 6

def getidx(Tree,value):
    idx = -1
    for i in range(len(Tree)):
        if Tree[i][I] == value:
            idx = i
            break
    return idx

def search(Tree, A, B, num):
    root = A[0]
    rootidx = getidx(Tree,root)
    ld = num
    for i in range(num):
        if B[i] == root:
            ld = i
            break
    if ld > 0:
        left,lidx = search(Tree,A[1:ld+1],B[:ld],ld)
        Tree[rootidx][L] = lidx
    rt = ld + 1
    if rt < num:
        right,ridx = search(Tree,A[rt:],B[rt:],num - rt)
        Tree[rootidx][R] = ridx
    return (root,rootidx)

def postorder(Tree, nidx, A):
    if nidx < 0:
        return
    postorder(Tree,Tree[nidx][L],A)
    postorder(Tree,Tree[nidx][R],A)
    A.append(Tree[nidx][I])


def main():

    """ ????????? """
    num = int(input().strip())
    plist = list(map(int,input().split()))
    ilist = list(map(int,input().split()))
    tree = []
    for i in plist:
        tree.append([i, -1, -1, -1, -1, 0, 0])

    root,ridx = search(tree, plist, ilist, num)

    pos = []

    postorder(tree, ridx, pos)
    print(" ".join(map(str,pos)))

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
I = 0
L = 1
R = 2
P = 3
B = 4
D = 5
H = 6

def getidx(Tree,value):
    idx = -1
    for i in range(len(Tree)):
        if Tree[i][I] == value:
            idx = i
            break
    return idx

def search(Tree, A, B, num):
    """ Tree ??? Tree A???Preorder?????? B???Inorder??????
        ??????????????????????????§??? root ??? index ????????? """
    root = A[0]
    rootidx = getidx(Tree,root)
    ld = num
    for i in range(num):
        if B[i] == root:
            ld = i
            break
    if ld > 0:
        left,lidx = search(Tree,A[1:ld+1],B[:ld],ld)
        Tree[rootidx][L] = lidx
    rt = ld + 1
    if rt < num:
        right,ridx = search(Tree,A[rt:],B[rt:],num - rt)
        Tree[rootidx][R] = ridx
    return (root,rootidx)

def getroot(Tree, nidx):
    pidx = Tree[nidx][P]
    if pidx < 0:
        return nidx
    return getroot(Tree,pidx)

ef postorder(Tree, nidx, A):
    if nidx < 0:
        return
    postorder(Tree,Tree[nidx][L],A)
    postorder(Tree,Tree[nidx][R],A)
    A.append(Tree[nidx][I])


def main():

    """ ????????? """
    num = int(input().strip())
    plist = list(map(int,input().split()))
    ilist = list(map(int,input().split()))
    tree = []
    for i in plist:
        tree.append([i, -1, -1, -1, -1, 0, 0])

    root,ridx = search(tree, plist, ilist, num)

    pos = []

    postorder(tree, ridx, pos)
    print(" ".join(map(str,pos)))

if __name__ == '__main__':
    main()

Fixed submission:
I = 0
L = 1
R = 2
P = 3
B = 4
D = 5
H = 6

def getidx(Tree,value):
    idx = -1
    for i in range(len(Tree)):
        if Tree[i][I] == value:
            idx = i
            break
    return idx

def search(Tree, A, B, num):
    root = A[0]
    rootidx = getidx(Tree,root)
    ld = num
    for i in range(num):
        if B[i] == root:
            ld = i
            break
    if ld > 0:
        left,lidx = search(Tree,A[1:ld+1],B[:ld],ld)
        Tree[rootidx][L] = lidx
    rt = ld + 1
    if rt < num:
        right,ridx = search(Tree,A[rt:],B[rt:],num - rt)
        Tree[rootidx][R] = ridx
    return (root,rootidx)

def postorder(Tree, nidx, A):
    if nidx < 0:
        return
    postorder(Tree,Tree[nidx][L],A)
    postorder(Tree,Tree[nidx][R],A)
    A.append(Tree[nidx][I])


def main():

    """ ????????? """
    num = int(input().strip())
    plist = list(map(int,input().split()))
    ilist = list(map(int,input().split()))
    tree = []
    for i in plist:
        tree.append([i, -1, -1, -1, -1, 0, 0])

    root,ridx = search(tree, plist, ilist, num)

    pos = []

    postorder(tree, ridx, pos)
    print(" ".join(map(str,pos)))

if __name__ == '__main__':
    main()