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()))

Asum_li = [0]
Asum = 0
Bsum_li = [0]
Bsum = 0

for A_ in A:
    Asum = Asum + A_
    Asum_li.append(Asum)

for B_ in B:
    Bsum = Bsum + B_
    Bsum_li.append(Bsum)

cnt_max = 0
cnt_b = M

for cnt_a in range(N+1):

    while (Bsum_li[cnt_b] + Asum_li[cnt_a]) > K:
        cnt_b = cnt_b - 1
        if cnt_b < 0: break

    if (cnt_max < cnt_b + cnt_a): cnt_max = cnt_b + cnt_a


print(cnt_max)


Fixed submission:
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

Asum_li = [0]
Asum = 0
Bsum_li = [0]
Bsum = 0

for A_ in A:
    Asum = Asum + A_
    Asum_li.append(Asum)

for B_ in B:
    Bsum = Bsum + B_
    Bsum_li.append(Bsum)

cnt_max = 0
cnt_b = M

for cnt_a in range(N+1):

    if Asum_li[cnt_a] > K : break

    while (Bsum_li[cnt_b] + Asum_li[cnt_a]) > K:
        cnt_b = cnt_b - 1
        if cnt_b < 0: break

    if (cnt_max < cnt_a + cnt_b): cnt_max = cnt_a + cnt_b


print(cnt_max)

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()))

b_li = [0]
b_ = 0

for B_ in B:
    b_ = b_ + B_
    b_li.append(b_)

book_max = 0
book_cnt_a = 0
book_cnt_ab = 0
a_ = 0
book_cnt_ab = M

for i in range(N+1):
    while (b_li[book_cnt_ab-1] + a_) > K:
        book_cnt_ab = book_cnt_ab - 1
        if book_cnt_ab == 0: break
    if (book_max <= book_cnt_ab + book_cnt_a):
            book_max = book_cnt_ab + book_cnt_a
    book_cnt_a = book_cnt_a + 1
    if i >= N: break
    a_ = a_ + A[i]

print(book_max)



Fixed submission:
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

Asum_li = [0]
Asum = 0
Bsum_li = [0]
Bsum = 0

for A_ in A:
    Asum = Asum + A_
    Asum_li.append(Asum)

for B_ in B:
    Bsum = Bsum + B_
    Bsum_li.append(Bsum)

cnt_max = 0
cnt_b = M

for cnt_a in range(N+1):

    if Asum_li[cnt_a] > K : break

    while (Bsum_li[cnt_b] + Asum_li[cnt_a]) > K:
        cnt_b = cnt_b - 1
        if cnt_b < 0: break

    if (cnt_max < cnt_a + cnt_b): cnt_max = cnt_a + cnt_b


print(cnt_max)

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()))

b_li = [0]
b_ = 0

for B_ in B:
    b_ = b_ + B_
    b_li.append(b_)

book_max = 0
book_cnt_a = 0
book_cnt_ab = 0
a_ = 0
book_cnt_ab = M

for i in range(N+1):
    while (b_li[book_cnt_ab-1] + a_) > K:
        book_cnt_ab = book_cnt_ab - 1
    if (book_max <= book_cnt_ab + book_cnt_a):
            book_max = book_cnt_ab + book_cnt_a
    book_cnt_a = book_cnt_a + 1
    if i >= N: break
    a_ = a_ + A[i]

print(book_max)


Fixed submission:
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

Asum_li = [0]
Asum = 0
Bsum_li = [0]
Bsum = 0

for A_ in A:
    Asum = Asum + A_
    Asum_li.append(Asum)

for B_ in B:
    Bsum = Bsum + B_
    Bsum_li.append(Bsum)

cnt_max = 0
cnt_b = M

for cnt_a in range(N+1):

    if Asum_li[cnt_a] > K : break

    while (Bsum_li[cnt_b] + Asum_li[cnt_a]) > K:
        cnt_b = cnt_b - 1
        if cnt_b < 0: break

    if (cnt_max < cnt_a + cnt_b): cnt_max = cnt_a + cnt_b


print(cnt_max)

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_li = [0]
a_ = 0
b_li = [0]
b_ = 0

for A_ in A:
    a_ = a_ + A_
    a_li.append(a_)

for B_ in B:
    b_ = b_ + B_
    b_li.append(b_)

book_max = 0
book_cnt_a = 0
book_cnt_ab = 0

for a_ in a_li:
    book_cnt_ab = M
    for b_ in b_li.reverse():
        if (a_ + b_) < K:
            if (book_max <= book_cnt_ab + book_cnt_a):
                book_max = book_cnt_ab + book_cnt_a
            break
        book_cnt_ab = book_cnt_ab - 1
    book_cnt_a = book_cnt_a + 1

print(book_max)


Fixed submission:
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

Asum_li = [0]
Asum = 0
Bsum_li = [0]
Bsum = 0

for A_ in A:
    Asum = Asum + A_
    Asum_li.append(Asum)

for B_ in B:
    Bsum = Bsum + B_
    Bsum_li.append(Bsum)

cnt_max = 0
cnt_b = M

for cnt_a in range(N+1):

    if Asum_li[cnt_a] > K : break

    while (Bsum_li[cnt_b] + Asum_li[cnt_a]) > K:
        cnt_b = cnt_b - 1
        if cnt_b < 0: break

    if (cnt_max < cnt_a + cnt_b): cnt_max = cnt_a + cnt_b


print(cnt_max)