Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
#coding:utf-8
data = input()
xmax = len(data)
data_list = list(data)
data_list.reverse()
reverse_data = []
for sig in data_list:
    if sig == "\\":
        reverse_data.append("/")
    elif sig == "/":
        reverse_data.append("\\")
    else:
        reverse_data.append(sig)

reverse_data = "".join(reverse_data)


def partialSqu(h, sig):
    if sig == "\\":
        squ = h + 1/2
        h += 1
    elif sig == "/":
        squ = h - 1/2
        h -= 1
    elif sig == "_":
        squ = h
    return squ, h


x_squ_dict = {}
cnt = 0
sw, x, h, totalSqu = 0, 0, 0, 0
for sig in data:
    x += 1
    if sw == 0 and sig == "\\":
        sw = 1
    if sw == 1 :
        squ, h = partialSqu(h, sig)
        totalSqu += squ
        
        if h == 0:
            x_squ_dict[x] = totalSqu
            totalSqu = 0
            sw = 0



keys = x_squ_dict.keys()
sw, x, h, totalSqu = 0, 0, 0, 0
for sig in reverse_data:
    x += 1
    if sw == 0 and sig == "\\" :
        sw = 1
        x_p = xmax - x +1
    if sw == 1 :
        squ, h = partialSqu(h, sig)
        totalSqu += squ            
        if h == 0:
            x_squ_dict[x_p] = totalSqu
            totalSqu = 0
            sw = 0

)
keys = x_squ_dict.keys()
keys = list(keys)
keys.sort()
squ_list = []
for key in keys:
    squ_list.append(x_squ_dict[key])
    
a = int(sum(squ_list))
print(a)    
squ_list.insert(0,len(keys))

squ_list = " ".join([str(int(num)) for num in squ_list])
print(squ_list)



Fixed submission:
#coding:utf-8
data = input()
xmax = len(data)
data_list = list(data)
data_list.reverse()
reverse_data = []
for sig in data_list:
    if sig == "\\":
        reverse_data.append("/")
    elif sig == "/":
        reverse_data.append("\\")
    else:
        reverse_data.append(sig)

reverse_data = "".join(reverse_data)


def partialSqu(h, sig):
    if sig == "\\":
        squ = h + 1/2
        h += 1
    elif sig == "/":
        squ = h - 1/2
        h -= 1
    elif sig == "_":
        squ = h
    return squ, h


x_squ_dict = {}
cnt = 0
sw, x, h, totalSqu = 0, 0, 0, 0
for sig in data:
    x += 1
    if sw == 0 and sig == "\\":
        sw = 1
    if sw == 1 :
        squ, h = partialSqu(h, sig)
        totalSqu += squ
        
        if h == 0:
            x_squ_dict[x] = totalSqu
            totalSqu = 0
            sw = 0



keys = x_squ_dict.keys()
sw, x, h, totalSqu = 0, 0, 0, 0
for sig in reverse_data:
    x += 1
    if sw == 0 and sig == "\\" :
        sw = 1
        x_p = xmax - x +1
    if sw == 1 :
        squ, h = partialSqu(h, sig)
        totalSqu += squ            
        if h == 0:
            x_squ_dict[x_p] = totalSqu
            totalSqu = 0
            sw = 0


keys = x_squ_dict.keys()
keys = list(keys)
keys.sort()
squ_list = []
for key in keys:
    squ_list.append(x_squ_dict[key])
    
a = int(sum(squ_list))
print(a)    
squ_list.insert(0,len(keys))

squ_list = " ".join([str(int(num)) for num in squ_list])
print(squ_list)
Buggy python submission (verdict: Time Limit Exceeded):
#coding:utf-8
   
n, k = map(int, input().split())
backList = []
for i in range(n):
    backList.append(int(input()))

def capa(p,k):
    cnt = 0
    pcopy = p
    num = 0
    for back in backList:
        if back > p:
            break
        if back <= pcopy:
            pcopy -= back
            cnt += 1
            continue
        elif back > pcopy:
            if num == k-1:
                return cnt
            pcopy = p - back
            cnt += 1
            num += 1          
    return cnt


p_min = 0
p_max = 100000 * 10000
def biSearch(p_min, p_max):
    p = p_max - p_min
    if p_min == p_max:
        return p_min
    if p % 2 == 0:
        p = int(p/2)
    else:
        p = int((p+1)/2)
    v = capa(p,k)
    if v < n:
        p_min = p_min + p
    else:
        p_max = p_min + p

    return biSearch(p_min, p_max)
            

p = biSearch(p_min, p_max)
n_init = n
while n_init <= n:
    p -= 1
    n = capa(p,k)

print(p+1)



Fixed submission:
#coding:utf-8
   
n, k = map(int, input().split())
backList = []
for i in range(n):
    backList.append(int(input()))

def capa(p,k):
    cnt = 0
    pcopy = p
    num = 0
    for back in backList:
        if back > p:
            break
        if back <= pcopy:
            pcopy -= back
            cnt += 1
            continue
        elif back > pcopy:
            if num == k-1:
                return cnt
            pcopy = p - back
            cnt += 1
            num += 1          
    return cnt


p_min = 0
p_max = 100000 * 10000
def biSearch(p_min, p_max):
    p = p_max - p_min
    if p_max - p_min <= 1:
        return p_max
    if p % 2 == 0:
        c = p_min + int(p/2)
    else:
        c = p_min + int((p+1)/2)
    v = capa(c,k)
    if v < n:
        p_min = c
    else:
        p_max = c

    return biSearch(p_min, p_max)
            

p = biSearch(p_min, p_max)
n_init = n
while n_init <= n:
    p -= 1
    n = capa(p,k)

print(p+1)
Buggy python submission (verdict: Runtime Error):
#coding:utf-8
from copy import deepcopy
n = int(input())
A = []
for i in range(n):
    ch, num = input().split()
    A.append([ch, int(num)])

B = deepcopy(A)



def Merge(A, left, mid, right):
    L = A[left:mid]
    R = A[mid:right]
    L.append(["S",20000000])
    R.append(["S",20000000])
    i,j = 0,0
    for k in range(left,right):
        if L[i][1] <= R[j][1]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1

def MergeSort(A, left, right):
    if left+1 < right:
        mid = (left + right)//2
        MergeSort(A, left, mid)
        MergeSort(A, mid, right)
        Merge(A, left, mid, right)

    

def partition(A, p, r):
    x = A[r-1][1]
    i = p-1
    for j in range(p, r):
        if A[j][1] <= x:
            i += 1
            A[i], A[j] = A[j], A[i]
    return i


def quickSort(A, p, r):
    if p < r:
        q = partition(A, p, r)
        quickSort(A, p, q)
        quickSort(A, q+1, r)




        
quickSort(A, 0, n)
MergeSort(B, 0, n)

if A == B:
    print("Stable")
else:
    print("Not stable")
    
for a in A:
    a = " ".join([a[0],str(a[1])])
    print(a)


Fixed submission:
#coding:utf-8
from copy import deepcopy
n = int(input())
A = []
for i in range(n):
    ch, num = input().split()
    A.append([ch, int(num)])

B = deepcopy(A)



def Merge(A, left, mid, right):
    L = A[left:mid]
    R = A[mid:right]
    L.append(["S",2000000000])
    R.append(["S",2000000000])
    i,j = 0,0
    for k in range(left,right):
        if L[i][1] <= R[j][1]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1

def MergeSort(A, left, right):
    if left+1 < right:
        mid = (left + right)//2
        MergeSort(A, left, mid)
        MergeSort(A, mid, right)
        Merge(A, left, mid, right)

    

def partition(A, p, r):
    x = A[r-1][1]
    i = p-1
    for j in range(p, r):
        if A[j][1] <= x:
            i += 1
            A[i], A[j] = A[j], A[i]
    return i


def quickSort(A, p, r):
    if p < r:
        q = partition(A, p, r)
        quickSort(A, p, q)
        quickSort(A, q+1, r)




        
quickSort(A, 0, n)
MergeSort(B, 0, n)

if A == B:
    print("Stable")
else:
    print("Not stable")
    
for a in A:
    a = " ".join([a[0],str(a[1])])
    print(a)
Buggy python submission (verdict: Runtime Error):
#coding:utf-8
N = int(input())

class Tree:
    def __init__(self, ID,p=-1):
        self.ID = ID

    def makeTree(self, tree):
        ID = tree.ID
        if ID == -1:
            return
        else:
            [ID,l,r] = trees[ID]
            tree.l = Tree(l)
            tree.r = Tree(r)
            treeL = tree.l
            treeR = tree.r
            treeL.p = tree
            treeR.p = tree

            self.makeTree(self,treeL)
            self.makeTree(self,treeR)

def preParse(tree):
    ID = tree.ID
    if ID == -1:
        return
    else:
        global preList
        preList.append(ID)
        treeL = tree.l
        treeR = tree.r
        preParse(treeL)
        preParse(treeR)
        
def inParse(tree):
    ID = tree.ID
    if ID == -1:
        return
    else:
        global inList
        treeL = tree.l
        treeR = tree.r
        inParse(treeL)
        inList.append(ID)
        inParse(treeR)

def posParse(tree):
    ID = tree.ID
    if ID == -1:
        return
    else:
        global posList
        treeL = tree.l
        treeR = tree.r
        posParse(treeL)
        posParse(treeR)
        posList.append(ID)
        
    
trees = [list(map(int,input().split())) for i in range(N)]
tree = Tree(0)
Tree.makeTree(Tree,tree)

preList = []
inList = []
posList = []
preParse(tree)
inParse(tree)
posParse(tree)

def convert(List):
    return " ".join([str(num) for num in List])
a = convert(preList)
b = convert(inList)
c = convert(posList)
print("Preorder")
print(a)
print("Inorder")
print(b)
print("Postorder")
print(c)


Fixed submission:
#coding:utf-8
N = int(input())
T = []
class Tree:
    def __init__(self,ID,l=None,r=None,p=-1):
        self.ID = ID
        self.l = l
        self.r = r
        self.p = p

    def makeTree(self):
        for i in range(N):
            T.append(Tree(i))


def preParse(tree):
    if tree == None:
        return
    else:
        ID = tree.ID
        global preList
        preList.append(ID)
        preParse(tree.l)
        preParse(tree.r)
        
def inParse(tree):
    if tree == None:
        return
    else:
        ID = tree.ID
        global inList
        inParse(tree.l)
        inList.append(ID)
        inParse(tree.r)

def posParse(tree):
    if tree == None:
        return
    else:
        ID = tree.ID
        global posList
        posParse(tree.l)
        posParse(tree.r)
        posList.append(ID)
        
    
trees = [list(map(int,input().split())) for i in range(N)]
Tree.makeTree(Tree)
for i in range(N):
    ID,l,r = trees[i]
    tree = T[ID]
    if l != -1:
        T[l].p = tree
        tree.l = T[l]
    if r != -1:
        T[r].p = tree
        tree.r = T[r]
    
for i in range(N):
    if T[i].p == -1:
        parent = T[i]

preList = []
inList = []
posList = []
preParse(parent)
inParse(parent)
posParse(parent)

def convert(List, order):
    a =  " " + " ".join([str(num) for num in List])
    print("{}".format(order))
    print(a)
convert(preList, "Preorder")
convert(inList, "Inorder")
convert(posList, "Postorder")
Buggy python submission (verdict: Runtime Error):
#coding:utf-8
N = int(input())
preList = "".join(list(input().split()))
inList = "".join(list(input().split()))

def recon(l,r):
    if l >= r:
        return
    global pos
    c = preList[pos]
    index = inList.find(c)
    pos += 1
    recon(l,index)
    recon(index+1,r)
    
    global answer
    answer.append(c)

answer = []
pos = 0
recon(0,N)

answer = " ".join(answer)
print(answer)




Fixed submission:
#coding:utf-8
N = int(input())
preList = list(input().split())
inList = list(input().split())

def recon(l,r):
    if l >= r:
        return
    global pos
    c = preList[pos]
    index = inList.index(c)
    pos += 1
    recon(l,index)
    recon(index+1,r)
    
    global answer
    answer.append(c)

answer = []
pos = 0
recon(0,N)

answer = " ".join(answer)
print(answer)
Buggy python submission (verdict: Time Limit Exceeded):
#coding:utf-8
N = int(input())
trees = [list(input().split()) for i in range(N)]

class BinaryTree:
    def __init__(self,key,p=None,l=None,r=None):
        self.key = key
        self.p = p
        self.l = l
        self.r = r

def Insert(root,z):
    y = None
    x = root
    while x != None:
        y = x
        if z.key < x.key:
            x = x.l
        else:
            x = x.r
    z.p = y

    if y == None:
        root = z
    elif z.key < y.key:
        y.l = z
    else:
        y.r = z
    return root

def preOrder(x):
    if x == None:
        return
    global preList
    preList.append(x.key)
    
    preOrder(x.l)
    preOrder(x.r)

def inOrder(x):
    if x == None:
        return
    inOrder(x.l)

    global inList
    inList.append(x.key)
    
    inOrder(x.r)

def Find(x,target):
    if x == None:
        return 
    if x.key == target:
        global yes
        yes = True
        return True
    Find(x.l,target)
    Find(x.r,target)

root = None
for data in trees:
    if data[0] == "insert":
        z = BinaryTree(int(data[1]))
        root = Insert(root,z)
    if data[0] == "find":
        yes = False
        a = Find(root, int(data[1]))
        if yes:
            print("yes")
        else:
            print("no")
        
    if data[0] == "print":
        inList = []
        preList = []
        inOrder(root)
        a = " " + " ".join([str(num) for num in inList])
        print(a)

        preOrder(root)
        a = " " + " ".join([str(num) for num in preList])
        print(a)


Fixed submission:
#coding:utf-8
N = int(input())
trees = [list(input().split()) for i in range(N)]

class BinaryTree:
    def __init__(self,key,p=None,l=None,r=None):
        self.key = key
        self.p = p
        self.l = l
        self.r = r

def Insert(root,z):
    y = None
    x = root
    while x != None:
        y = x
        if z.key < x.key:
            x = x.l
        else:
            x = x.r
    z.p = y

    if y == None:
        root = z
    elif z.key < y.key:
        y.l = z
    else:
        y.r = z
    return root

def preOrder(x):
    if x == None:
        return
    global preList
    preList.append(x.key)
    
    preOrder(x.l)
    preOrder(x.r)

def inOrder(x):
    if x == None:
        return
    inOrder(x.l)

    global inList
    inList.append(x.key)
    
    inOrder(x.r)

def Find(x,target):
    while x != None:
        y = x
        if target < x.key:
            x = x.l
        elif target > x.key:
            x = x.r
        else:
            print("yes")
            return
    print("no")

root = None
for data in trees:
    if data[0] == "insert":
        z = BinaryTree(int(data[1]))
        root = Insert(root,z)
    if data[0] == "find":
        Find(root, int(data[1]))
      
    if data[0] == "print":
        inList = []
        preList = []
        inOrder(root)
        a = " " + " ".join([str(num) for num in inList])
        print(a)

        preOrder(root)
        a = " " + " ".join([str(num) for num in preList])
        print(a)
Buggy python submission (verdict: Runtime Error):
def swap(a,b):
	x = a
	a = b
	b = x
	
'''
l = input().split()

l = list(map(int, l))
a,b,c = l[0],l[1],l[2]
'''
a,b,c = map(int, input().split)
if a > b:
	a,b = b,a

if b > c:
	b,c = c,b
	
if a > b:
	a,b = b,a
	
print(a,b,c)


Fixed submission:

'''
l = input().split()

l = list(map(int, l))
a,b,c = l[0],l[1],l[2]
'''
a,b,c = map(int, input().split())
if a > b:
	a,b = b,a

if b > c:
	b,c = c,b
	
if a > b:
	a,b = b,a
	
print(a,b,c)

Buggy python submission (verdict: Runtime Error):

'''
l = input().split()

l = list(map(int, l))
a,b,c = l[0],l[1],l[2]
'''
a,b,c = map(int, input().split)
if a > b:
	a,b = b,a

if b > c:
	b,c = c,b
	
if a > b:
	a,b = b,a
	
print(a,b,c)


Fixed submission:

'''
l = input().split()

l = list(map(int, l))
a,b,c = l[0],l[1],l[2]
'''
a,b,c = map(int, input().split())
if a > b:
	a,b = b,a

if b > c:
	b,c = c,b
	
if a > b:
	a,b = b,a
	
print(a,b,c)
Buggy python submission (verdict: Runtime Error):
W,H,x,y,r = map(int,input().split())

w,h = W-r,h=r

if 0<x<w and 0<y<h: print('Yes')

else: print('No')


Fixed submission:
W,H,x,y,r = map(int,input().split())



if x-r<0 or W<x+r or y-r<0 or H<y+r: print('No')

else: print('Yes')

Buggy python submission (verdict: Runtime Error):
W,H,x,y,r = map(int,input().split())

w,h = W-r,H=r

if 0<x<w and 0<y<h: print('Yes')

else: print('No')


Fixed submission:
W,H,x,y,r = map(int,input().split())



if x-r<0 or W<x+r or y-r<0 or H<y+r: print('No')

else: print('Yes')

Buggy python submission (verdict: Runtime Error):
W,H,x,y,r = map(int,input().split())

w,h = W-r,H=r

if x<w and y<h: print('Yes')

else: print('No')


Fixed submission:
W,H,x,y,r = map(int,input().split())



if x-r<0 or W<x+r or y-r<0 or H<y+r: print('No')

else: print('Yes')

Buggy python submission (verdict: Runtime Error):
W,H,x,y,r = map(int,input().split())

w,h = W-r,h=r

if x<0 and w<x and y<0 and h<y: print('No')

else: print('Yes')



Fixed submission:
W,H,x,y,r = map(int,input().split())



if x-r<0 or W<x+r or y-r<0 or H<y+r: print('No')

else: print('Yes')
Buggy python submission (verdict: Runtime Error):

while True:
	a,b  = map(int, input().split())
	if a,b = 0,0: break
	if a > b: a,b = b,a
	print(f"{a} {b}")


Fixed submission:

while True:
	a,b  = map(int, input().split())
	if a == 0 and b == 0: break
	if a > b: a,b = b,a
	print(f"{a} {b}")

Buggy python submission (verdict: Runtime Error):

while True:
	a,b  = map(int, input().split())
	if a,b == 0,0: break
	if a > b: a,b = b,a
	print(f"{a} {b}")


Fixed submission:

while True:
	a,b  = map(int, input().split())
	if a == 0 and b == 0: break
	if a > b: a,b = b,a
	print(f"{a} {b}")
Buggy python submission (verdict: Runtime Error):

pi = 3.141592653589

r = float(input())

print("{.5f} {.5f}".format(r*r*pi,2*pi*r))


Fixed submission:

pi = 3.141592653589

r = float(input())

print(r*r*pi,2*pi*r)

Buggy python submission (verdict: Runtime Error):

pi = 3.141592653589

r = float(input())

print("{.5f} {.5f}".format(r*r*pi,2*pi*r))


Fixed submission:

pi = 3.141592653589

r = float(input())

print(r*r*pi,2*pi*r)

Buggy python submission (verdict: Runtime Error):

pi = 3.141592653589

r = float(input())

print(r*r*pi,2*pi*r


Fixed submission:

pi = 3.141592653589

r = float(input())

print(r*r*pi,2*pi*r)
Buggy python submission (verdict: Runtime Error):
 n = int(input())
 i = 0

 l = list(map(int, input().split()))
 Max = l[0]
 Min = l[0]
 for i in range(0,n):
 	
 	if l[i] > Max: l[i],Max = Max,l[i]
 	if l[i] < Min: l[i],Min = Min,l[i]
 	
 	sum = 0
 	sum += l[i]  
 	
 	print(f"{Min} {Max} {sum}")



Fixed submission:
n = int(input())
i = 0

l = list(map(int, input().split()))
Max = l[0]
Min = l[0]
sum = 0
for i in range(0,n):
	sum += l[i]
	a = l[i]#変数の値が下の行の処理で変わってしまうのでaとかにしておく
	if a > Max:
		a,Max = Max,a
	if  a < Min:
		a,Min = Min,a
	
	
print(f"{Min} {Max} {sum}")

Buggy python submission (verdict: Runtime Error):
 n = int(input())
 i = 0

 l = list(map(int, input().split()))
 Max = l[0]
 Min = l[0]
 for i in range(0,n):
 	
 	if l[i] > Max: l[i],Max = Max,l[i]
 	if l[i] < Min: l[i],Min = Min,l[i]
 	
 	sum = 0
 	sum += l[i]  
 	
print(f"{Min} {Max} {sum}")



Fixed submission:
n = int(input())
i = 0

l = list(map(int, input().split()))
Max = l[0]
Min = l[0]
sum = 0
for i in range(0,n):
	sum += l[i]
	a = l[i]#変数の値が下の行の処理で変わってしまうのでaとかにしておく
	if a > Max:
		a,Max = Max,a
	if  a < Min:
		a,Min = Min,a
	
	
print(f"{Min} {Max} {sum}")
Buggy python submission (verdict: Runtime Error):
H,W = int(input().split())

for y in range(0,H):
	for x in range(0,W):
		print('#')



Fixed submission:
while True:	
	H,W = map(int, input().split())
	if H==0 and W==0: break
	for y in range(0,H):
		for x in range(0,W):
			print("#",end="")
			
		print()
	print()

Buggy python submission (verdict: Runtime Error):
H,W = map(int, input().split())

for y in range(0,H):
	for x in range(0,W):
		print("#",end="")
	print(\n\n)


Fixed submission:
while True:	
	H,W = map(int, input().split())
	if H==0 and W==0: break
	for y in range(0,H):
		for x in range(0,W):
			print("#",end="")
			
		print()
	print()

Buggy python submission (verdict: Runtime Error):
while True:	
	H,W = map(int, input().split())
	if H==0 and W==0: break
	for y in range(0,H):
		for x in range(0,W):
			print("#",end="")
	    print('\n')
print('\n')


Fixed submission:
while True:	
	H,W = map(int, input().split())
	if H==0 and W==0: break
	for y in range(0,H):
		for x in range(0,W):
			print("#",end="")
			
		print()
	print()

Buggy python submission (verdict: Runtime Error):
while True:	
	H,W = map(int, input().split())
	if H==0 and W==0: break
	for y in range(0,H):
		for x in range(0,W):
			print("#",end="")
	    print('\n')



Fixed submission:
while True:	
	H,W = map(int, input().split())
	if H==0 and W==0: break
	for y in range(0,H):
		for x in range(0,W):
			print("#",end="")
			
		print()
	print()

Buggy python submission (verdict: Runtime Error):
while True:	
	H,W = map(int, input().split())
	if H==0 and W==0: break
	for y in range(0,H):
		for x in range(0,W):
			print("#",end="")
	    print('\n')
    print()


Fixed submission:
while True:	
	H,W = map(int, input().split())
	if H==0 and W==0: break
	for y in range(0,H):
		for x in range(0,W):
			print("#",end="")
			
		print()
	print()

Buggy python submission (verdict: Runtime Error):
while True:	
	H,W = map(int, input().split())
	if H==0 and W==0: break
	for y in range(0,H):
		for x in range(0,W):
			print("#",end="")
	    print('\n')
    print()
print()


Fixed submission:
while True:	
	H,W = map(int, input().split())
	if H==0 and W==0: break
	for y in range(0,H):
		for x in range(0,W):
			print("#",end="")
			
		print()
	print()

Buggy python submission (verdict: Runtime Error):
while True:	
	H,W = map(int, input().split())
	if H==0 and W==0: break
	for y in range(0,H):
		for x in range(0,W):
			print("#",end="")
	    print('\n')
    print('\n')
print('\n')


Fixed submission:
while True:	
	H,W = map(int, input().split())
	if H==0 and W==0: break
	for y in range(0,H):
		for x in range(0,W):
			print("#",end="")
			
		print()
	print()

Buggy python submission (verdict: Runtime Error):
while True:	
	H,W = map(int, input().split())
	if H==0 and W==0: break
	for y in range(0,H):
		for x in range(0,W):
			print("#",end="")
	    
    print('\n')
print('\n')


Fixed submission:
while True:	
	H,W = map(int, input().split())
	if H==0 and W==0: break
	for y in range(0,H):
		for x in range(0,W):
			print("#",end="")
			
		print()
	print()
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
R = [int(input()) for i in range(n)]
maxv = R[1] - R[0]

for i in range(0, n-1):
    for j in range(i+1, n):
        maxv = R[j] - R[i] if R[j] - R[i] > maxv else maxv

print(maxv)

Fixed submission:
n = int(input())
R = [int(input()) for i in range(n)]
maxv = R[1] - R[0]
minv = R[0]

for j in range(1, n):
    maxv = R[j] - minv if R[j] - minv > maxv else maxv
    minv = R[j] if R[j] < minv else minv

print(maxv)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
R = [int(input()) for i in range(n)]
maxv = R[1] - R[0]

for i in range(0, n-1):
    for j in range(i+1, n):
        maxv = R[j] - R[i] if R[j] - R[i] > maxv else maxv

print(maxv)

Fixed submission:
n = int(input())
R = [int(input()) for i in range(n)]
maxv = R[1] - R[0]
minv = R[0]

for j in range(1, n):
    maxv = R[j] - minv if R[j] - minv > maxv else maxv
    minv = R[j] if R[j] < minv else minv

print(maxv)