Buggy python submission (verdict: Runtime Error):
import copy

def selection_sort(A,n):
    for i in range(n):
        minj = i
        for j in range(i,n):
            if A[j] < A[minj]:
                minj = j
        A[i],A[minj] = A[minj], A[i]
    return A

n = int(input())
r = [0]*n
for i in range(n):
    r[i] = input().split()

for i in range(n):
    if r[i][0] == "insert":
        root= int(r[i][1])
        key = i + 1
        break
    

left = []
right = []
for i in range(key, n):
    if r[i][0] == "insert" and int(r[i][1]) < root:
        left += [int(r[i][1])]
    elif r[i][0] == "insert" and int(r[i][1]) > root:
        right += [int(r[i][1])]
    else:
        pre = [root]+ left + right
        a = copy.deepcopy(pre)
        print(" " + *selection_sort(a,len(a)))
        print(" " + *pre)





        
    
    


Fixed submission:
class Node():
    def __init__(self, key):
        self.key = key
        self.left = self.right = None
        
def insert(key):
    global root

    x = root
    y = None
    while x:x, y = x.left if key < x.key else x.right , x
    if y == None:root = Node(key)
    elif y.key < key:y.right = Node(key)
    else:y.left = Node(key)
        
        
def pre(node):
    if node == None:return
    print('',node.key, end = '');pre(node.left);pre(node.right)
    
def ino(node):
    if node == None:return
    ino(node.left);print('',node.key,end='');ino(node.right)


n = int(input())
root = None
for j in range(n):
    s, *i = input().split()
    if s[0] == 'i':insert(int(i[0]))
    else:
        ino(root);print();pre(root);print()

Buggy python submission (verdict: Runtime Error):
import copy

def selection_sort(A,n):
    for i in range(n):
        minj = i
        for j in range(i,n):
            if A[j] < A[minj]:
                minj = j
        A[i],A[minj] = A[minj], A[i]
    return A

n = int(input())
r = [0]*n
for i in range(n):
    r[i] = input().split()

for i in range(n):
    if r[i][0] == "insert":
        root= int(r[i][1])
        key = i + 1
        break
    else:
        print()
        print()

left = []
right = []
for i in range(key, n):
    if r[i][0] == "insert" and int(r[i][1]) < root:
        left += [int(r[i][1])]
    elif r[i][0] == "insert" and int(r[i][1]) > root:
        right += [int(r[i][1])]
    elif r
        pre = [root]+ left + right
        a = copy.deepcopy(pre)
        print(pre)
        print("", *selection_sort(a,len(a)))
        print("", *pre)
        


Fixed submission:
class Node():
    def __init__(self, key):
        self.key = key
        self.left = self.right = None
        
def insert(key):
    global root

    x = root
    y = None
    while x:x, y = x.left if key < x.key else x.right , x
    if y == None:root = Node(key)
    elif y.key < key:y.right = Node(key)
    else:y.left = Node(key)
        
        
def pre(node):
    if node == None:return
    print('',node.key, end = '');pre(node.left);pre(node.right)
    
def ino(node):
    if node == None:return
    ino(node.left);print('',node.key,end='');ino(node.right)


n = int(input())
root = None
for j in range(n):
    s, *i = input().split()
    if s[0] == 'i':insert(int(i[0]))
    else:
        ino(root);print();pre(root);print()

Buggy python submission (verdict: Runtime Error):
class Node():
    def __init__(self, key):
        self.key = key
        self.left = self.right = None
        
def insert(key):
    global root

    x = root
    y = None
    while x:x, y = x.left if key < x.key else x.right , x
    if y == None:root = Node(key)
    elif y.key < key:y.right = Node(key)
    else:y.left = Node(key)
        
        
def pre(node):
    if node == None:return
    print('',node.key, end = '');pre(node.left);pre(node.right)
    
def ino(node):
    if node == None:return
    ino(node.left);print('',node.key,end='');ino(node.right)


n = int(input())
root = None
for j in range(n):
    s, *i = input().split()
    if s[0] == 'i':insert(int(i[0]))
    else:
        ino(root);print('');pre(root)print()
        
    


Fixed submission:
class Node():
    def __init__(self, key):
        self.key = key
        self.left = self.right = None
        
def insert(key):
    global root

    x = root
    y = None
    while x:x, y = x.left if key < x.key else x.right , x
    if y == None:root = Node(key)
    elif y.key < key:y.right = Node(key)
    else:y.left = Node(key)
        
        
def pre(node):
    if node == None:return
    print('',node.key, end = '');pre(node.left);pre(node.right)
    
def ino(node):
    if node == None:return
    ino(node.left);print('',node.key,end='');ino(node.right)


n = int(input())
root = None
for j in range(n):
    s, *i = input().split()
    if s[0] == 'i':insert(int(i[0]))
    else:
        ino(root);print();pre(root);print()