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

class Node:
    def __init__(self, key):
        self.key = key
        self.right = None
        self.left = None

def insert(T, z): #z is node which you would like to insert                                
        #initialization                                                                    
    y = None #parent of x                                                                  
    x = T

        #search                                                                            
    while(x!=None):
        y = x
        if(z.key < x.key):
            x = x.left
        else:
            x = x.right

	#insert                                                                            
    if(y==None):
        T = z
    elif(z.key < y.key):
	y.left = z
    else:
        y.right = z

    return T

def inorder_walk(node):
    if node.left:
	inorder_walk(node.left)
    print('', node.key, end='')
    if node.right:
	inorder_walk(node.right)


def preorder_walk(node):
    print('', node.key, end='')
    if node.left:
        preorder_walk(node.left)
    if node.right:
	preorder_walk(node.right)


T = None
num = int(sys.stdin.readline())

for _ in range(num):
    cmd = sys.stdin.readline()
    if(cmd.startwith('i')):
        n = Node(int(cmd[:7]))
        T = insert(T, n)
    else:
        inorder_walk(T)
        preorder_walk(T)

Fixed submission:
#!/usr/bin/env python
from __future__ import division, print_function
from sys import stdin
 
 
class Node(object):
    def __init__(self, key=None):
        self.key = key
        self.parent = None
        self.left = None
        self.right = None
 
 
def tree_insert(top, z):
    y = None
    x = top
    while isinstance(x, Node):
        y = x
        if z.key < x.key:
            x = x.left
        else:
            x = x.right
    z.parent = y
    if y is None:
        top = z
    elif z.key < y.key:
        y.left = z
    else:
        y.right = z
    return top
 
 
def inorder_walk(node):
    if node.left:
        inorder_walk(node.left)
    print('', node.key, end='')
    if node.right:
        inorder_walk(node.right)
 
 
def preorder_walk(node):
    print('', node.key, end='')
    if node.left:
        preorder_walk(node.left)
    if node.right:
        preorder_walk(node.right)
 
 
n = int(stdin.readline())
 
top = None
for _ in range(n):
    cmd = stdin.readline()
    if cmd.startswith('i'):
        key = int(cmd[7:])
        #assert -2000000000 <= key <= 2000000000
        top = tree_insert(top, Node(key))
    else:
        inorder_walk(top)
        print()
        preorder_walk(top)
        print()

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

#run by python3                                                                            

class Node:
    def __init__(self, key):
	self.key = key
        self.right = None
	self.left = None

def insert(T, z): #z is node which you would like to insert                                
        #initialization                                                                    
    y = None #parent of x                                                                  
    x = T

	#search                                                                            
    while(x!=None):
        y = x
        if(z.key < x.key):
            x = x.left
        else:
            x = x.right

	#insert                                                                            
    if(y==None):
        T = z
    elif(z.key < y.key):
	y.left = z
    else:
        y.right = z

    return T

def inorder_walk(node):
    if node.left:
	inorder_walk(node.left)
    print ('', node.key, end='')
    if node.right:
	inorder_walk(node.right)


def preorder_walk(node):
    print ('', node.key,end='')
    if node.left:
        preorder_walk(node.left)
    if node.right:
	preorder_walk(node.right)


T = None
num = int(sys.stdin.readline())

for _ in range(num):
    cmd = sys.stdin.readline()
    if(cmd.startswith('i')):
	n = Node(int(cmd[7:]))
	T = insert(T, n)
    else:
        inorder_walk(T)
	print()
	preorder_walk(T)
	print()

Fixed submission:
#!/usr/bin/env python
from __future__ import division, print_function
from sys import stdin
 
 
class Node(object):
    def __init__(self, key=None):
        self.key = key
        self.parent = None
        self.left = None
        self.right = None
 
 
def tree_insert(top, z):
    y = None
    x = top
    while isinstance(x, Node):
        y = x
        if z.key < x.key:
            x = x.left
        else:
            x = x.right
    z.parent = y
    if y is None:
        top = z
    elif z.key < y.key:
        y.left = z
    else:
        y.right = z
    return top
 
 
def inorder_walk(node):
    if node.left:
        inorder_walk(node.left)
    print('', node.key, end='')
    if node.right:
        inorder_walk(node.right)
 
 
def preorder_walk(node):
    print('', node.key, end='')
    if node.left:
        preorder_walk(node.left)
    if node.right:
        preorder_walk(node.right)
 
 
n = int(stdin.readline())
 
top = None
for _ in range(n):
    cmd = stdin.readline()
    if cmd.startswith('i'):
        key = int(cmd[7:])
        #assert -2000000000 <= key <= 2000000000
        top = tree_insert(top, Node(key))
    else:
        inorder_walk(top)
        print()
        preorder_walk(top)
        print()

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

class Node:
    def __init__(self, key):
	self.key = key
        self.right = None
	self.left = None

def insert(T, z):                                                                    
    y = None
    x = T
                                                                          
    while(x!=None):
        y = x
        if(z.key < x.key):
            x = x.left
        else:
            x = x.right

    if(y==None):
        T = z
    elif(z.key < y.key):
	y.left = z
    else:
        y.right = z

    return T

def inorder_walk(node):
    if node.left:
	inorder_walk(node.left)
    print ('', node.key, end='')
    if node.right:
	inorder_walk(node.right)


def preorder_walk(node):
    print ('', node.key,end='')
    if node.left:
        preorder_walk(node.left)
    if node.right:
	preorder_walk(node.right)


T = None
num = int(sys.stdin.readline())

for _ in range(num):
    cmd = sys.stdin.readline()
    if(cmd.startswith('i')):
	n = Node(int(cmd[7:]))
	T = insert(T, n)
    else:
        inorder_walk(T)
	print()
	preorder_walk(T)
	print()

Fixed submission:
#!/usr/bin/env python
from __future__ import division, print_function
from sys import stdin
 
 
class Node(object):
    def __init__(self, key=None):
        self.key = key
        self.parent = None
        self.left = None
        self.right = None
 
 
def tree_insert(top, z):
    y = None
    x = top
    while isinstance(x, Node):
        y = x
        if z.key < x.key:
            x = x.left
        else:
            x = x.right
    z.parent = y
    if y is None:
        top = z
    elif z.key < y.key:
        y.left = z
    else:
        y.right = z
    return top
 
 
def inorder_walk(node):
    if node.left:
        inorder_walk(node.left)
    print('', node.key, end='')
    if node.right:
        inorder_walk(node.right)
 
 
def preorder_walk(node):
    print('', node.key, end='')
    if node.left:
        preorder_walk(node.left)
    if node.right:
        preorder_walk(node.right)
 
 
n = int(stdin.readline())
 
top = None
for _ in range(n):
    cmd = stdin.readline()
    if cmd.startswith('i'):
        key = int(cmd[7:])
        #assert -2000000000 <= key <= 2000000000
        top = tree_insert(top, Node(key))
    else:
        inorder_walk(top)
        print()
        preorder_walk(top)
        print()

Buggy python submission (verdict: Runtime Error):

def preorder_walk(node):
    print ('', node.key,end='')
    if node.left:
        preorder_walk(node.left)
    if node.right:
	preorder_walk(node.right)


T = None
num = int(sys.stdin.readline())

for _ in range(num):
    cmd = sys.stdin.readline()
    if(cmd.startswith('i')):
	n = Node(int(cmd[7:]))
	T = insert(T, n)
    else:
        inorder_walk(T)
	print()
	preorder_walk(T)
	print()

Fixed submission:
#!/usr/bin/env python
from __future__ import division, print_function
from sys import stdin
 
 
class Node(object):
    def __init__(self, key=None):
        self.key = key
        self.parent = None
        self.left = None
        self.right = None
 
 
def tree_insert(top, z):
    y = None
    x = top
    while isinstance(x, Node):
        y = x
        if z.key < x.key:
            x = x.left
        else:
            x = x.right
    z.parent = y
    if y is None:
        top = z
    elif z.key < y.key:
        y.left = z
    else:
        y.right = z
    return top
 
 
def inorder_walk(node):
    if node.left:
        inorder_walk(node.left)
    print('', node.key, end='')
    if node.right:
        inorder_walk(node.right)
 
 
def preorder_walk(node):
    print('', node.key, end='')
    if node.left:
        preorder_walk(node.left)
    if node.right:
        preorder_walk(node.right)
 
 
n = int(stdin.readline())
 
top = None
for _ in range(n):
    cmd = stdin.readline()
    if cmd.startswith('i'):
        key = int(cmd[7:])
        #assert -2000000000 <= key <= 2000000000
        top = tree_insert(top, Node(key))
    else:
        inorder_walk(top)
        print()
        preorder_walk(top)
        print()

Buggy python submission (verdict: Runtime Error):

def preorder_walk(node):
    print ('', node.key,end='')
    if node.left:
        preorder_walk(node.left)
    if node.right:
	preorder_walk(node.right)


T = None
num = int(sys.stdin.readline())

for _ in range(num):
    cmd = sys.stdin.readline()
    if(cmd.startswith('i')):
	n = Node(int(cmd[7:]))
	T = insert(T, n)
    else:
        inorder_walk(T)
	print()
	preorder_walk(T)
	print()

Fixed submission:
#!/usr/bin/env python
from __future__ import division, print_function
from sys import stdin
 
 
class Node(object):
    def __init__(self, key=None):
        self.key = key
        self.parent = None
        self.left = None
        self.right = None
 
 
def tree_insert(top, z):
    y = None
    x = top
    while isinstance(x, Node):
        y = x
        if z.key < x.key:
            x = x.left
        else:
            x = x.right
    z.parent = y
    if y is None:
        top = z
    elif z.key < y.key:
        y.left = z
    else:
        y.right = z
    return top
 
 
def inorder_walk(node):
    if node.left:
        inorder_walk(node.left)
    print('', node.key, end='')
    if node.right:
        inorder_walk(node.right)
 
 
def preorder_walk(node):
    print('', node.key, end='')
    if node.left:
        preorder_walk(node.left)
    if node.right:
        preorder_walk(node.right)
 
 
n = int(stdin.readline())
 
top = None
for _ in range(n):
    cmd = stdin.readline()
    if cmd.startswith('i'):
        key = int(cmd[7:])
        #assert -2000000000 <= key <= 2000000000
        top = tree_insert(top, Node(key))
    else:
        inorder_walk(top)
        print()
        preorder_walk(top)
        print()

Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3                                                                     
import sys

#run by python3                                                                            

class Node:
    def __init__(self, key):
        self.key = key
        self.right = None
        self.left = None

def insert(T, z): #z is node which you would like to insert                                
        #initialization                                                                    
    y = None #parent of x                                                                  
    x = T

        #search                                                                            
    while(x!=None):
        y = x
        if(z.key < x.key):
            x = x.left
        else:
            x = x.right

        #insert                                                                            
    if(y==None):
        T = z
    elif(z.key < y.key):
        y.left = z
    else:
        y.right = z

    return T

def inorder_walk(node):
    if node.left:
        inorder_walk(node.left)
    print ('', node.key, end='')
    if node.right:
        inorder_walk(node.right)


def preorder_walk(node):
    print ('', node.key,end='')
    if node.left:
        preorder_walk(node.left)
    if node.right:
	preorder_walk(node.right)


T = None
num = int(sys.stdin.readline())

for _ in range(num):
    cmd = sys.stdin.readline()
    if(cmd.startswith('i')):
        n = Node(int(cmd[7:]))
	T = insert(T, n)
    else:
        inorder_walk(T)
        print()
        preorder_walk(T)
        print()

Fixed submission:
#!/usr/bin/env python
from __future__ import division, print_function
from sys import stdin
 
 
class Node(object):
    def __init__(self, key=None):
        self.key = key
        self.parent = None
        self.left = None
        self.right = None
 
 
def tree_insert(top, z):
    y = None
    x = top
    while isinstance(x, Node):
        y = x
        if z.key < x.key:
            x = x.left
        else:
            x = x.right
    z.parent = y
    if y is None:
        top = z
    elif z.key < y.key:
        y.left = z
    else:
        y.right = z
    return top
 
 
def inorder_walk(node):
    if node.left:
        inorder_walk(node.left)
    print('', node.key, end='')
    if node.right:
        inorder_walk(node.right)
 
 
def preorder_walk(node):
    print('', node.key, end='')
    if node.left:
        preorder_walk(node.left)
    if node.right:
        preorder_walk(node.right)
 
 
n = int(stdin.readline())
 
top = None
for _ in range(n):
    cmd = stdin.readline()
    if cmd.startswith('i'):
        key = int(cmd[7:])
        #assert -2000000000 <= key <= 2000000000
        top = tree_insert(top, Node(key))
    else:
        inorder_walk(top)
        print()
        preorder_walk(top)
        print()

Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3                                                                     
import sys

#run by python3                                                                            

class Node:
    def __init__(self, key):
        self.key = key
        self.right = None
        self.left = None

def insert(T, z): #z is node which you would like to insert                                
        #initialization                                                                    
    y = None #parent of x                                                                  
    x = T

        #search                                                                            
    while(x!=None):
        y = x
        if(z.key < x.key):
            x = x.left
        else:
            x = x.right

        #insert                                                                            
    if(y==None):
        T = z
    elif(z.key < y.key):
        y.left = z
    else:
        y.right = z

    return T


def inorder_walk(node):
    if node.left:
        inorder_walk(node.left)
    print ('', node.key, end='')
    if node.right:
	inorder_walk(node.right)


def preorder_walk(node):
    print ('', node.key,end='')
    if node.left:
        preorder_walk(node.left)
    if node.right:
	preorder_walk(node.right)

if __name__ == '__main__':

    T = None
    num = int(sys.stdin.readline())

    for _ in range(num):
        cmd = sys.stdin.readline()
        if(cmd.startswith('i')):
            n = Node(int(cmd[7:]))
            T = insert(T, n)
        else:
            inorder_walk(T)
            print()
            preorder_walk(T)
            print()

Fixed submission:
#!/usr/bin/env python
from __future__ import division, print_function
from sys import stdin
 
 
class Node(object):
    def __init__(self, key=None):
        self.key = key
        self.parent = None
        self.left = None
        self.right = None
 
 
def tree_insert(top, z):
    y = None
    x = top
    while isinstance(x, Node):
        y = x
        if z.key < x.key:
            x = x.left
        else:
            x = x.right
    z.parent = y
    if y is None:
        top = z
    elif z.key < y.key:
        y.left = z
    else:
        y.right = z
    return top
 
 
def inorder_walk(node):
    if node.left:
        inorder_walk(node.left)
    print('', node.key, end='')
    if node.right:
        inorder_walk(node.right)
 
 
def preorder_walk(node):
    print('', node.key, end='')
    if node.left:
        preorder_walk(node.left)
    if node.right:
        preorder_walk(node.right)
 
 
n = int(stdin.readline())
 
top = None
for _ in range(n):
    cmd = stdin.readline()
    if cmd.startswith('i'):
        key = int(cmd[7:])
        #assert -2000000000 <= key <= 2000000000
        top = tree_insert(top, Node(key))
    else:
        inorder_walk(top)
        print()
        preorder_walk(top)
        print()

Buggy python submission (verdict: Runtime Error):
def inorder_walk(node):
    if node.left:
        inorder_walk(node.left)
    print ('', node.key, end='')
    if node.right:
	inorder_walk(node.right)


def preorder_walk(node):
    print ('', node.key,end='')
    if node.left:
        preorder_walk(node.left)
    if node.right:
	preorder_walk(node.right)

if __name__ == '__main__':

    T = None
    num = int(sys.stdin.readline())

    for _ in range(num):
        cmd = sys.stdin.readline()
        if(cmd.startswith('i')):
            n = Node(int(cmd[7:]))
            T = insert(T, n)
        else:
            inorder_walk(T)
            print()
            preorder_walk(T)
            print()

Fixed submission:
#!/usr/bin/env python
from __future__ import division, print_function
from sys import stdin
 
 
class Node(object):
    def __init__(self, key=None):
        self.key = key
        self.parent = None
        self.left = None
        self.right = None
 
 
def tree_insert(top, z):
    y = None
    x = top
    while isinstance(x, Node):
        y = x
        if z.key < x.key:
            x = x.left
        else:
            x = x.right
    z.parent = y
    if y is None:
        top = z
    elif z.key < y.key:
        y.left = z
    else:
        y.right = z
    return top
 
 
def inorder_walk(node):
    if node.left:
        inorder_walk(node.left)
    print('', node.key, end='')
    if node.right:
        inorder_walk(node.right)
 
 
def preorder_walk(node):
    print('', node.key, end='')
    if node.left:
        preorder_walk(node.left)
    if node.right:
        preorder_walk(node.right)
 
 
n = int(stdin.readline())
 
top = None
for _ in range(n):
    cmd = stdin.readline()
    if cmd.startswith('i'):
        key = int(cmd[7:])
        #assert -2000000000 <= key <= 2000000000
        top = tree_insert(top, Node(key))
    else:
        inorder_walk(top)
        print()
        preorder_walk(top)
        print()

Buggy python submission (verdict: Runtime Error):
File Edit Options Buffers Tools Python Help                                                
#!/usr/bin/env python3                                                                     
#run by python3                                                                            

class Node:
    def __init__(self, key):
        self.key = key
        self.right = None
        self.left = None

def insert(T, z): #z is node which you would like to insert                                
        #initialization                                                                    
    y = None #parent of x                                                                  
    x = T

        #search                                                                            
    while(x!=None):
        y = x
        if(z.key < x.key):
            x = x.left
        else:
            x = x.right

        #insert                                                                            
    if(y==None):
	T = z
    elif(z.key < y.key):
        y.left = z
    else:
        y.right = z

    return T


def inorder_walk(node):
    if node.left:
        inorder_walk(node.left)
    print ('', node.key, end='')
    if node.right:
        inorder_walk(node.right)


def preorder_walk(node):
    print ('', node.key,end='')
    if node.left:
        preorder_walk(node.left)
    if node.right:
        preorder_walk(node.right)

if __name__ == '__main__':

    T = None
    num = int(input())

    for _ in range(num):
        cmd = input()
        if(cmd.startswith('i')):
            n = Node(int(cmd[7:]))
            T = insert(T, n)
        else:
            inorder_walk(T)
            print()
            preorder_walk(T)
            print()

Fixed submission:
#!/usr/bin/env python
from __future__ import division, print_function
from sys import stdin
 
 
class Node(object):
    def __init__(self, key=None):
        self.key = key
        self.parent = None
        self.left = None
        self.right = None
 
 
def tree_insert(top, z):
    y = None
    x = top
    while isinstance(x, Node):
        y = x
        if z.key < x.key:
            x = x.left
        else:
            x = x.right
    z.parent = y
    if y is None:
        top = z
    elif z.key < y.key:
        y.left = z
    else:
        y.right = z
    return top
 
 
def inorder_walk(node):
    if node.left:
        inorder_walk(node.left)
    print('', node.key, end='')
    if node.right:
        inorder_walk(node.right)
 
 
def preorder_walk(node):
    print('', node.key, end='')
    if node.left:
        preorder_walk(node.left)
    if node.right:
        preorder_walk(node.right)
 
 
n = int(stdin.readline())
 
top = None
for _ in range(n):
    cmd = stdin.readline()
    if cmd.startswith('i'):
        key = int(cmd[7:])
        #assert -2000000000 <= key <= 2000000000
        top = tree_insert(top, Node(key))
    else:
        inorder_walk(top)
        print()
        preorder_walk(top)
        print()

Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3                                                                     
#run by python3                                                                            

class Node:
    def __init__(self, key):
        self.key = key
        self.right = None
        self.left = None

def insert(T, z): #z is node which you would like to insert                                
        #initialization                                                                    
    y = None #parent of x                                                                  
    x = T

        #search                                                                            
    while(x!=None):
        y = x
        if(z.key < x.key):
            x = x.left
        else:
            x = x.right

        #insert                                                                            
    if(y==None):
	T = z
    elif(z.key < y.key):
        y.left = z
    else:
        y.right = z

    return T


def inorder_walk(node):
    if node.left:
        inorder_walk(node.left)
    print ('', node.key, end='')
    if node.right:
        inorder_walk(node.right)


def preorder_walk(node):
    print ('', node.key,end='')
    if node.left:
        preorder_walk(node.left)
    if node.right:
        preorder_walk(node.right)

if __name__ == '__main__':

    T = None
    num = int(input())

    for _ in range(num):
        cmd = input()
        if(cmd.startswith('i')):
            n = Node(int(cmd[7:]))
            T = insert(T, n)
        else:
            inorder_walk(T)
            print()
            preorder_walk(T)
            print()

Fixed submission:
#!/usr/bin/env python
from __future__ import division, print_function
from sys import stdin
 
 
class Node(object):
    def __init__(self, key=None):
        self.key = key
        self.parent = None
        self.left = None
        self.right = None
 
 
def tree_insert(top, z):
    y = None
    x = top
    while isinstance(x, Node):
        y = x
        if z.key < x.key:
            x = x.left
        else:
            x = x.right
    z.parent = y
    if y is None:
        top = z
    elif z.key < y.key:
        y.left = z
    else:
        y.right = z
    return top
 
 
def inorder_walk(node):
    if node.left:
        inorder_walk(node.left)
    print('', node.key, end='')
    if node.right:
        inorder_walk(node.right)
 
 
def preorder_walk(node):
    print('', node.key, end='')
    if node.left:
        preorder_walk(node.left)
    if node.right:
        preorder_walk(node.right)
 
 
n = int(stdin.readline())
 
top = None
for _ in range(n):
    cmd = stdin.readline()
    if cmd.startswith('i'):
        key = int(cmd[7:])
        #assert -2000000000 <= key <= 2000000000
        top = tree_insert(top, Node(key))
    else:
        inorder_walk(top)
        print()
        preorder_walk(top)
        print()

Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3                                                                        

class Node:
    def __init__(self, key):
        self.key = key
        self.right = None
        self.left = None

def insert(T, z):                     
    #initialization                                                                    
    y = None #parent of x                                                                  
    x = T

    #search                                                                            
    while(x!=None):
        y = x
        if(z.key < x.key):
            x = x.left
        else:
            x = x.right

    #insert                                                                            
    if(y==None):
	T = z
    elif(z.key < y.key):
        y.left = z
    else:
        y.right = z

    return T


def inorder_walk(node):
    if node.left:
        inorder_walk(node.left)
    print ('', node.key, end='')
    if node.right:
        inorder_walk(node.right)


def preorder_walk(node):
    print ('', node.key,end='')
    if node.left:
        preorder_walk(node.left)
    if node.right:
        preorder_walk(node.right)

if __name__ == '__main__':

    T = None
    num = int(input())

    for _ in range(num):
        cmd = input()
        if(cmd.startswith('i')):
            n = Node(int(cmd[7:]))
            T = insert(T, n)
        else:
            inorder_walk(T)
            print()
            preorder_walk(T)
            print()

Fixed submission:
#!/usr/bin/env python
from __future__ import division, print_function
from sys import stdin
 
 
class Node(object):
    def __init__(self, key=None):
        self.key = key
        self.parent = None
        self.left = None
        self.right = None
 
 
def tree_insert(top, z):
    y = None
    x = top
    while isinstance(x, Node):
        y = x
        if z.key < x.key:
            x = x.left
        else:
            x = x.right
    z.parent = y
    if y is None:
        top = z
    elif z.key < y.key:
        y.left = z
    else:
        y.right = z
    return top
 
 
def inorder_walk(node):
    if node.left:
        inorder_walk(node.left)
    print('', node.key, end='')
    if node.right:
        inorder_walk(node.right)
 
 
def preorder_walk(node):
    print('', node.key, end='')
    if node.left:
        preorder_walk(node.left)
    if node.right:
        preorder_walk(node.right)
 
 
n = int(stdin.readline())
 
top = None
for _ in range(n):
    cmd = stdin.readline()
    if cmd.startswith('i'):
        key = int(cmd[7:])
        #assert -2000000000 <= key <= 2000000000
        top = tree_insert(top, Node(key))
    else:
        inorder_walk(top)
        print()
        preorder_walk(top)
        print()