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

class TreeNode:
    def __init__(self, val):
        self.val = val
        self.left = self.right = None

class BST:
    def __init__(self):
        self.root = None
    
    def insert(self, node):
        def helper(root):
            if root is None:
                root = node
            elif node.val < root.val:
                lr = helper(root.left)
                root.left = lr
            else:
                rr = helper(root.right)
                root.right = rr
            return root
            
        self.root = helper(self.root)
    
    def inorder(self):
        def helper(root):
            if root is None:
                return []
            else:
                return helper(root.left) + [root.val] + helper(root.right)
        return helper(self.root)

if __name__ == '__main__':
    q = sys.stdin.readline()
    q = int(q)
    bst = BST()
    for i in range(q):
        tmp = sys.stdin.readline()
        if tmp.startswith('print'):
            print ' '.join(map(lambda x: str(x), bst.inorder()))
        else:
            _, val = tmp.split()
            node = TreeNode(int(val))
            sys.stdout.write(' '.join(map(lambda x: str(x), bst.insert(node)) + '\n'))

Fixed submission:
import sys

class TreeNode:
    def __init__(self, val):
        self.val = val
        self.left = self.right = None

class BST:
    def __init__(self):
        self.root = None
    
    def insert(self, node):
        def helper(root):
            y, x = None, root
            while isinstance(x, TreeNode):
                y = x
                if node.val < x.val:
                    x = x.left
                else:
                    x = x.right
            if y is None:
                root = node
            elif node.val < y.val:
                y.left = node
            else:
                y.right = node
            return root
            
        self.root = helper(self.root)
    
    def inorder(self):
        def helper(root):
            return [] if root is None else helper(root.left) + [root.val] + helper(root.right)
        return helper(self.root)

    def preorder(self):
        def helper(root):
            return [] if root is None else [root.val] + helper(root.left) + helper(root.right)
        return helper(self.root)

if __name__ == '__main__':
    q = sys.stdin.readline()
    q = int(q)
    bst = BST()
    for i in range(q):
        tmp = sys.stdin.readline()
        if tmp.startswith('print'):
            print ' ' + ' '.join(map(lambda x: str(x), bst.inorder()))
            print ' ' + ' '.join(map(lambda x: str(x), bst.preorder()))
        else:
            _, val = tmp.split()
            node = TreeNode(int(val))
            bst.insert(node)

Buggy python submission (verdict: Time Limit Exceeded):
import sys

class TreeNode:
    def __init__(self, val):
        self.val = val
        self.left = self.right = None

class BST:
    def __init__(self):
        self.root = None
    
    def insert(self, node):
        def helper(root):
            if root is None:
                root = node
            elif node.val < root.val:
                lr = helper(root.left)
                root.left = lr
            else:
                rr = helper(root.right)
                root.right = rr
            return root
            
        self.root = helper(self.root)
    
    def inorder(self):
        def helper(root):
            return [] if root is None else helper(root.left) + [root.val] + helper(root.right)
        return helper(self.root)

    def preorder(self):
        def helper(root):
            return [] if root is None else [root.val] + helper(root.left) + helper(root.right)
        return helper(self.root)

if __name__ == '__main__':
    q = sys.stdin.readline()
    q = int(q)
    bst = BST()
    for i in range(q):
        tmp = sys.stdin.readline()
        if tmp.startswith('print'):
            print ' ' + ' '.join(map(lambda x: str(x), bst.inorder()))
            print ' ' + ' '.join(map(lambda x: str(x), bst.preorder()))
        else:
            _, val = tmp.split()
            node = TreeNode(int(val))
            bst.insert(node)

Fixed submission:
import sys

class TreeNode:
    def __init__(self, val):
        self.val = val
        self.left = self.right = None

class BST:
    def __init__(self):
        self.root = None
    
    def insert(self, node):
        def helper(root):
            y, x = None, root
            while isinstance(x, TreeNode):
                y = x
                if node.val < x.val:
                    x = x.left
                else:
                    x = x.right
            if y is None:
                root = node
            elif node.val < y.val:
                y.left = node
            else:
                y.right = node
            return root
            
        self.root = helper(self.root)
    
    def inorder(self):
        def helper(root):
            return [] if root is None else helper(root.left) + [root.val] + helper(root.right)
        return helper(self.root)

    def preorder(self):
        def helper(root):
            return [] if root is None else [root.val] + helper(root.left) + helper(root.right)
        return helper(self.root)

if __name__ == '__main__':
    q = sys.stdin.readline()
    q = int(q)
    bst = BST()
    for i in range(q):
        tmp = sys.stdin.readline()
        if tmp.startswith('print'):
            print ' ' + ' '.join(map(lambda x: str(x), bst.inorder()))
            print ' ' + ' '.join(map(lambda x: str(x), bst.preorder()))
        else:
            _, val = tmp.split()
            node = TreeNode(int(val))
            bst.insert(node)