Buggy python submission (verdict: Runtime Error):
r = []
N = int(input())
for i in range(0, N):
    r.append(int(input()))

min_i = N-2
max_i = N-1

for i in range(N-1)[::-1]:
    for j in range(i+1, N):
        if r[j] - r[i] > r[max_i] - r[min_i]:
            max_i = j
            min_i = i


print(tmp)

Fixed submission:
N = int(input())
r = [int(input()) for i in range(N)]
 
min = r[0]
max = -9999999999999999
 
for i in range(1, N):
    if r[i] - min > max:
        max = r[i] - min
    if r[i] < min:
        min = r[i]
 
print(max)

Buggy python submission (verdict: Time Limit Exceeded):
r = []
N = int(input())
for i in range(0, N):
    r.append(int(input()))

min_i = N-2
max_i = N-1

for i in range(N-1)[::-1]:
    for j in range(i+1, N):
        if r[j] - r[i] > r[max_i] - r[min_i]:
            max_i = j
            min_i = i


print(r[max_i] - r[min_i])

Fixed submission:
N = int(input())
r = [int(input()) for i in range(N)]
 
min = r[0]
max = -9999999999999999
 
for i in range(1, N):
    if r[i] - min > max:
        max = r[i] - min
    if r[i] < min:
        min = r[i]
 
print(max)

Buggy python submission (verdict: Time Limit Exceeded):
r = []
N = int(input())
for i in range(0, N):
    r.append(int(input()))

min_i = N-2
max_i = N-1

for i in range(N-1)[::-1]:
    if r[i] < r[i+1] or r[max_i] - r[min_i] < 0:
        for j in range(i+1, N):
            if r[j] - r[i] > r[max_i] - r[min_i]:
                max_i = j
                min_i = i

                
print(r[max_i] - r[min_i])

Fixed submission:
N = int(input())
r = [int(input()) for i in range(N)]
 
min = r[0]
max = -9999999999999999
 
for i in range(1, N):
    if r[i] - min > max:
        max = r[i] - min
    if r[i] < min:
        min = r[i]
 
print(max)

Buggy python submission (verdict: Time Limit Exceeded):
r = []
N = int(input())
for i in range(0, N):
    r.append(int(input()))

min = r[N-2]
max = r[N-1]

for i in range(N-1)[::-1]:
    for j in range(i+1, N):
        if r[j] - r[i] > max - min:
            max = r[j]
            min = r[i]

print(max - min)

Fixed submission:
N = int(input())
r = [int(input()) for i in range(N)]
 
min = r[0]
max = -9999999999999999
 
for i in range(1, N):
    if r[i] - min > max:
        max = r[i] - min
    if r[i] < min:
        min = r[i]
 
print(max)

Buggy python submission (verdict: Time Limit Exceeded):
r = []
N = int(input())
for i in range(0, N):
    r.append(int(input()))

min_i = N-2
max_i = N-1

for i in range(N-1)[::-1]:
    if (r[i] - r[i+1]) * r[max_i] - r[min_i] < 0:
        for j in range(i+1, N):
            if r[j] - r[i] > r[max_i] - r[min_i]:
                max_i = j
                min_i = i

                
print(r[max_i] - r[min_i])

Fixed submission:
N = int(input())
r = [int(input()) for i in range(N)]
 
min = r[0]
max = -9999999999999999
 
for i in range(1, N):
    if r[i] - min > max:
        max = r[i] - min
    if r[i] < min:
        min = r[i]
 
print(max)

Buggy python submission (verdict: Time Limit Exceeded):
r = []
N = int(input())
for i in range(0, N):
    r.append(int(input()))

min_i = N-2
max_i = N-1

for i in range(N-1)[::-1]:
    if r[i] < r[i+1]:
        for j in range(i+1, N):
            if r[j] - r[i] > r[max_i] - r[min_i]:
                max_i = j
                min_i = i
    if r[max_i] - r[min_i] < 0:
        if r[i+1] - r[i] > r[max_i] - r[min_i]:
            max_i = i+1
            min_i = i

                
print(r[max_i] - r[min_i])

Fixed submission:
N = int(input())
r = [int(input()) for i in range(N)]
 
min = r[0]
max = -9999999999999999
 
for i in range(1, N):
    if r[i] - min > max:
        max = r[i] - min
    if r[i] < min:
        min = r[i]
 
print(max)