Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
dp = [[[-1] * (5 * 10 ** 6) for _ in range(n + 1)] for _ in range(2)]
dp[0][0][1000] = 0
dp[1][0][1000] = 0
for i in range(n):
    for j in range(5 * 10 ** 6):
        dp[0][i + 1][j], dp[1][i + 1][j] = dp[0][i][j], dp[1][i][j]
    for j in range(5 * 10 ** 6):
        u, v = dp[0][i][j], dp[1][i][j]
        if max(u, v) < 0:
            continue
        dp[0][i + 1][j] = u
        dp[1][i + 1][j] = v
        # print(i, j, u, v)
        dp[0][i + 1][j + max(u, v) * a[i]] = 0
        dp[1][i + 1][j % a[i]] = max(u, v) + j // a[i]
ans = 0
for j in range(5 * 10 ** 6):
    if dp[0][n][j] != -1 or dp[1][n][j] != -1:
        ans = max(ans, j)
print(ans)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
c = 1000
for i in range(1, n):
    if a[i] > a[i - 1]:
        c = c // a[i - 1] * a[i] + c % a[i - 1]
print(c)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
dp = [[[-1] * (5 * 10 ** 6) for _ in range(n)] for _ in range(2)]
dp[0][0][1000] = 0
dp[1][0][1000] = 0
for i in range(n):
    for j in range(5 * 10 ** 6):
        dp[0][i + 1][j], dp[1][i + 1][j] = dp[0][i][j], dp[1][i][j]
    for j in range(5 * 10 ** 6):
        u, v = dp[0][i][j], dp[1][i][j]
        if max(u, v) < 0:
            continue
        dp[0][i + 1][j] = u
        dp[1][i + 1][j] = v
        # print(i, j, u, v)
        dp[0][i + 1][j + max(u, v) * a[i]] = 0
        dp[1][i + 1][j % a[i]] = max(u, v) + j // a[i]
ans = 0
for j in range(10 ** 4):
    if dp[0][n][j] != -1 or dp[1][n][j] != -1:
        ans = max(ans, j)
print(ans)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
c = 1000
for i in range(1, n):
    if a[i] > a[i - 1]:
        c = c // a[i - 1] * a[i] + c % a[i - 1]
print(c)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
dp = [[[-1] * (10 ** 4) for _ in range(n)] for _ in range(2)]
dp[0][0][1000] = 0
dp[1][0][1000] = 0
for i in range(n):
    for j in range(10 ** 4):
        dp[0][i + 1][j], dp[1][i + 1][j] = dp[0][i][j], dp[1][i][j]
    for j in range(10 ** 4):
        u, v = dp[0][i][j], dp[1][i][j]
        if max(u, v) < 0:
            continue
        dp[0][i + 1][j] = u
        dp[1][i + 1][j] = v
        # print(i, j, u, v)
        dp[0][i + 1][j + max(u, v) * a[i]] = 0
        dp[1][i + 1][j % a[i]] = max(u, v) + j // a[i]
ans = 0
for j in range(10 ** 4):
    if dp[0][n][j] != -1 or dp[1][n][j] != -1:
        ans = max(ans, j)
print(ans)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
c = 1000
for i in range(1, n):
    if a[i] > a[i - 1]:
        c = c // a[i - 1] * a[i] + c % a[i - 1]
print(c)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
dp = [[[-1] * (10 ** 4) for _ in range(80)] for _ in range(2)]
dp[0][0][1000] = 0
dp[1][0][1000] = 0
for i in range(n):
    for j in range(10 ** 4):
        dp[0][i + 1][j], dp[1][i + 1][j] = dp[0][i][j], dp[1][i][j]
    for j in range(10 ** 4):
        u, v = dp[0][i][j], dp[1][i][j]
        if max(u, v) < 0:
            continue
        dp[0][i + 1][j] = u
        dp[1][i + 1][j] = v
        # print(i, j, u, v)
        dp[0][i + 1][j + max(u, v) * a[i]] = 0
        dp[1][i + 1][j % a[i]] = max(u, v) + j // a[i]
ans = 0
for j in range(10 ** 4):
    if dp[0][n][j] != -1 or dp[1][n][j] != -1:
        ans = max(ans, j)
print(ans)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
c = 1000
for i in range(1, n):
    if a[i] > a[i - 1]:
        c = c // a[i - 1] * a[i] + c % a[i - 1]
print(c)