Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
stack = []
for _ in range(n):
    stack.append(int(input()))

candidate = []
for i, v in enumerate(stack):
    for j in stack[:i]:
        candidate.append(v - j)
        candidate = [max(candidate)]

print(candidate[0])

Fixed submission:
n = int(input())
stack = []
for _ in range(n):
    stack.append(int(input()))

maxv = -10**9
minv = stack[0]
for i in range(1, len(stack)):
    maxv = max(maxv, stack[i] - minv)
    minv = min(minv, stack[i])

print(maxv)

Buggy python submission (verdict: Runtime Error):
n = int(input())
stack = []
for _ in range(n):
    stack.append(int(input()))

candidate = []
for i, v in enumerate(stack):
    for j in [el for el in stack[:i] if v > el]:
        candidate.append(v - j)
        candidate = [max(candidate)]

print(candidate[0])

Fixed submission:
n = int(input())
stack = []
for _ in range(n):
    stack.append(int(input()))

maxv = -10**9
minv = stack[0]
for i in range(1, len(stack)):
    maxv = max(maxv, stack[i] - minv)
    minv = min(minv, stack[i])

print(maxv)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
stack = []
for _ in range(n):
    stack.append(int(input()))

candidate = [-10**10]
for i, v in enumerate(stack):
    for j in stack[:i]:
        candidate.append(v - j)
    candidate = [max(candidate)]

print(candidate[0])

Fixed submission:
n = int(input())
stack = []
for _ in range(n):
    stack.append(int(input()))

maxv = -10**9
minv = stack[0]
for i in range(1, len(stack)):
    maxv = max(maxv, stack[i] - minv)
    minv = min(minv, stack[i])

print(maxv)

Buggy python submission (verdict: Runtime Error):
n = int(input())
stack = []
for _ in range(n):
    stack.append(int(input()))

for i in range(len(stack) - 1):
    for r1, r2 in zip(stack[::1], stack[i::1]):
        candidate.append(r2 - r3)
    candidate = [max(candidate)]

print(candidate[0])

Fixed submission:
n = int(input())
stack = []
for _ in range(n):
    stack.append(int(input()))

maxv = -10**9
minv = stack[0]
for i in range(1, len(stack)):
    maxv = max(maxv, stack[i] - minv)
    minv = min(minv, stack[i])

print(maxv)

Buggy python submission (verdict: Runtime Error):
n = int(input())
stack = []
for _ in range(n):
    stack.append(int(input()))

for i in range(len(stack) - 1):
    for r1, r2 in zip(stack[::1], stack[i::1]):
        candidate.append(r2 - r1)
    candidate = [max(candidate)]

print(candidate[0])

Fixed submission:
n = int(input())
stack = []
for _ in range(n):
    stack.append(int(input()))

maxv = -10**9
minv = stack[0]
for i in range(1, len(stack)):
    maxv = max(maxv, stack[i] - minv)
    minv = min(minv, stack[i])

print(maxv)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
stack = []
for _ in range(n):
    stack.append(int(input()))

candidate = [-float('inf')]
for i in range(1, len(stack)):
    for r1, r2 in zip(stack[::1], stack[i::1]):
        candidate.append(r2 - r1)
    candidate = [max(candidate)]

print(candidate[0])

Fixed submission:
n = int(input())
stack = []
for _ in range(n):
    stack.append(int(input()))

maxv = -10**9
minv = stack[0]
for i in range(1, len(stack)):
    maxv = max(maxv, stack[i] - minv)
    minv = min(minv, stack[i])

print(maxv)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
stack = []
for _ in range(n):
    stack.append(int(input()))

candidate = [-float('inf')]
for i in range(1, len(stack) // 2 + 1):
    for r1, r2 in zip(stack[::1], stack[i::1]):
        candidate.append(r2 - r1)
    for r1, r2 in zip(stack[::1], stack[len(stack) - i::1]):
        candidate.append(r2 - r1)
    candidate = [max(candidate)]

print(candidate[0])

Fixed submission:
n = int(input())
stack = []
for _ in range(n):
    stack.append(int(input()))

maxv = -10**9
minv = stack[0]
for i in range(1, len(stack)):
    maxv = max(maxv, stack[i] - minv)
    minv = min(minv, stack[i])

print(maxv)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
stack = []
for _ in range(n):
    stack.append(int(input()))

candidate = [-float('inf')]
for i in range(1, len(stack) // 2 + 1):
    for r1, r2 in zip(stack[::1], stack[i::1]):
        if r2 - r1 > candidate[0]:
            candidate.append(r2 - r1)
    for r1, r2 in zip(stack[::1], stack[len(stack) - i::1]):
        if r2 - r1 > candidate[0]:
            candidate.append(r2 - r1)
    candidate = [max(candidate)]

print(candidate[0])

Fixed submission:
n = int(input())
stack = []
for _ in range(n):
    stack.append(int(input()))

maxv = -10**9
minv = stack[0]
for i in range(1, len(stack)):
    maxv = max(maxv, stack[i] - minv)
    minv = min(minv, stack[i])

print(maxv)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
stack = []
for _ in range(n):
    stack.append(int(input()))
length = len(stack)

candidate = [-float('inf')]
for i in range(1, length // 2 + 1):
    for r1, r2 in zip(stack[::1], stack[i::1]):
        if r2 - r1 > candidate[0]:
            candidate.append(r2 - r1)
    if i - length != i:
        for r1, r2 in zip(stack[::1], stack[length - i::1]):
            if r2 - r1 > candidate[0]:
                candidate.append(r2 - r1)
    candidate = [max(candidate)]

print(candidate[0])

Fixed submission:
n = int(input())
stack = []
for _ in range(n):
    stack.append(int(input()))

maxv = -10**9
minv = stack[0]
for i in range(1, len(stack)):
    maxv = max(maxv, stack[i] - minv)
    minv = min(minv, stack[i])

print(maxv)