Buggy python submission (verdict: Runtime Error):
import numpy

N, M, K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]

A_time = []
B_time = []

if sum(A) + sum(B) <= K:
    print(len(A) + len(B))
elif K < min(A) and K < min(B):
    print(0)
else:
    #A_res = list(numpy.cumsum(A))
    #B_res = list(numpy.cumsum(B))

    books = []

    for i in range(len(A)):
        A_sum = sum(A[0:i+1])
        if A_sum > K:
            break
        res = K - A_sum

        for j in range(M+1, 0, -1):
            B_sum = sum(B[0:j])
            if B_sum in B:
                books.append(i + j + 1)
                break
    print(max(books))


Fixed submission:
n,m,k = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
 
a,b = [0],[0]
for i in range(n):
    a.append(a[i] + A[i])
for i in range(m):
    b.append(b[i] + B[i])
 
ans,j = 0,m
for i in range(n+1):
    if a[i] > k:
        break
    while b[j] > k - a[i]:
        j -= 1
    ans = max(ans, i + j)
print(ans)

Buggy python submission (verdict: Runtime Error):
import numpy
 
N,M,K = [int(i) for i in input().split()]
A= [int(i) for i in input().split()]
B= [int(i) for i in input().split()]
 
A_time = []
B_time = []
 
if sum(A) + sum(B) <= K:
    print(len(A) + len(B))
elif K < min(A) and K < min(B):
    print(0)
else:
    A_res = list(numpy.cumsum(A))
    B_res = list(numpy.cumsum(B))
 
    books = []
 
    for i in range(len(A_res)):
        if A[i] > K:
            break
        res = K - A[i]

        for b_best in range(int(res), 0, -1):
            if b_best in B_res:
                books.append(i + B_res.index(b_best) + 1)
                break
    print(max(books)) 

Fixed submission:
n,m,k = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
 
a,b = [0],[0]
for i in range(n):
    a.append(a[i] + A[i])
for i in range(m):
    b.append(b[i] + B[i])
 
ans,j = 0,m
for i in range(n+1):
    if a[i] > k:
        break
    while b[j] > k - a[i]:
        j -= 1
    ans = max(ans, i + j)
print(ans)

Buggy python submission (verdict: Runtime Error):
import numpy

N,M,K = [int(i) for i in input().split()]
A= [int(i) for i in input().split()]
B= [int(i) for i in input().split()]

A_time = []
B_time = []

if sum(A) + sum(B) <= K:
    print(len(A) + len(B))
elif K < min(A) and K < min(B):
    print(0)
else:
    A_res = numpy.cumsum(A)
    B_res = numpy.cumsum(B)

    books = []

    for i in range(len(A_res)):
        if A[i] > K:
            break
        res = K - A[i]
        tmp = 0
        for j in range(1,len(B_res)):
            if B[j] > res:
                books.append(i + tmp + 1)
                break
            tmp = j
    print(max(books)) 




Fixed submission:
n,m,k = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
 
a,b = [0],[0]
for i in range(n):
    a.append(a[i] + A[i])
for i in range(m):
    b.append(b[i] + B[i])
 
ans,j = 0,m
for i in range(n+1):
    if a[i] > k:
        break
    while b[j] > k - a[i]:
        j -= 1
    ans = max(ans, i + j)
print(ans)

Buggy python submission (verdict: Runtime Error):
N,M,K = [int(i) for i in input().split()]
A= [int(i) for i in input().split()]
B= [int(i) for i in input().split()]

if sum(A) + sum(B) <= K:
    print(len(A) + len(B))
elif K < min(A) and K < min(B):
    print(0)

else:
    books = []
    for i in range(N):
        a_num = i+1
        a_time = sum(A[0:a_num+1])
        b_time = 0
        for j in range(M):
            if a_time + b_time + B[j] > K and a_time + b_time < K:
                books.append( i + j + 2)
                break
            b_time += B[j]

   
    print(max(books))




Fixed submission:
n,m,k = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
 
a,b = [0],[0]
for i in range(n):
    a.append(a[i] + A[i])
for i in range(m):
    b.append(b[i] + B[i])
 
ans,j = 0,m
for i in range(n+1):
    if a[i] > k:
        break
    while b[j] > k - a[i]:
        j -= 1
    ans = max(ans, i + j)
print(ans)