Buggy python submission (verdict: Runtime Error):
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

a_sum = [0]
b_sum = [0]
for i in range(n):
    a_sum.append(a_sum[i] + a[i])
for i in range(m):
    b_sum.append(b_sum[j] + b[j])
    
ans, j = 0, m
for i in range(n + 1):
    if a_sum[i] > k:
        break
    while b_sum[i] > k - a_sum[i]:
        j -= 1
    ans = max(ans, i + j)
print(ans)

Fixed submission:
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

a_sum = [0]
b_sum = [0]
for i in range(n):
    a_sum.append(a_sum[i] + a[i])
for i in range(m):
    b_sum.append(b_sum[i] + b[i])
    
ans, j = 0, m
for i in range(n + 1):
    if a_sum[i] > k:
        break
    while b_sum[j] > k - a_sum[i]:
        j -= 1
    ans = max(ans, i + j)
print(ans)

Buggy python submission (verdict: Runtime Error):
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

a_sum = [0]
b_sum = [0]
for i in range(n):
    a_sum.append(a_sum[i] + a[i])
for i in range(m):
    b_sum.append(b_sum[j] + b[j])
    
ans, j = 0, m
for i in range(n + 1):
    if a_sum[i] > k:
        break
    while b_sum[i] > k - a_sum[i]:
        j -= 1
    ans = max(ans, i + j)
print(ans)

Fixed submission:
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

a_sum = [0]
b_sum = [0]
for i in range(n):
    a_sum.append(a_sum[i] + a[i])
for i in range(m):
    b_sum.append(b_sum[i] + b[i])
    
ans, j = 0, m
for i in range(n + 1):
    if a_sum[i] > k:
        break
    while b_sum[j] > k - a_sum[i]:
        j -= 1
    ans = max(ans, i + j)
print(ans)

Buggy python submission (verdict: Runtime Error):
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

a_sum = [0]
b_sum = [0]
for i in range(n):
    a_sum.append(a_sum[i] + a[i])
for i in range(m):
    b_sum.append(b_sum[j] + b[j])
    
ans, j = 0, m
for i in range(n + 1):
    if a[i] > k:
        break
    while b[i] > k - a[i]:
        j -= 1
    ans = max(ans, i + j)
print(ans)

Fixed submission:
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

a_sum = [0]
b_sum = [0]
for i in range(n):
    a_sum.append(a_sum[i] + a[i])
for i in range(m):
    b_sum.append(b_sum[i] + b[i])
    
ans, j = 0, m
for i in range(n + 1):
    if a_sum[i] > k:
        break
    while b_sum[j] > k - a_sum[i]:
        j -= 1
    ans = max(ans, i + j)
print(ans)

Buggy python submission (verdict: Runtime Error):
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

cnt = 0
sum_ = k
idx_a = 0
idx_b = 0
while sum_ > 0:
    if a[idx_a] == 0 and b[idx_b] != 0:
        while sum_ > 0:
            sum_ = sum_ - b[idx_b]
            idx_b += 1
            cnt += 1
    elif b[idx_b] == 0 and a[idx_a]!= 0:
        while sum_ > 0:
            sum_ = sum_ - a[idx_a]
            idx_a += 1        
            cnt += 1
    else:
        while sum_ > 0:
            if a[idx_a] > b[idx_b]:
                sum_ = sum_ - b[idx_b]
                b[idx_b] = 0
                idx_b += 1
                cnt += 1
#             elif a[idx_a] < b[idx_b]:
            else:
                sum_ = sum_ - a[idx_a]
                a[idx_a] = 0
                idx_a += 1
                cnt += 1
print(cnt - 1)

Fixed submission:
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

a_sum = [0]
b_sum = [0]
for i in range(n):
    a_sum.append(a_sum[i] + a[i])
for i in range(m):
    b_sum.append(b_sum[i] + b[i])
    
ans, j = 0, m
for i in range(n + 1):
    if a_sum[i] > k:
        break
    while b_sum[j] > k - a_sum[i]:
        j -= 1
    ans = max(ans, i + j)
print(ans)