Buggy python submission (verdict: Runtime Error):
import numpy as np
N, M, K = map(int, input().split())

A = [0] + list(map(int, input().split()))
B = [0] + list(map(int, input().split()))

cum_A = np.cumsum(A)
cum_B = np.cumsum(B)

a = 0
b = 0

flg = False

ans = 0

if cum_A[N] + cum_B[M] <= K:
    ans = N + M
else:
    while True:
        if cum_A[a] <= cum_B[b]:
            if (a < N) & (cum_A[a + 1] + cum_B[b] <= K):
                a += 1
            else:
                flg = True
        elif cum_A[a] > cum_B[b]:
            if (b < M) & (cum_A[a] + cum_B[b + 1] <= K):
                b += 1
            else:
                flg = True
        
        if flg:
            ans = a + b
            break


print(ans)


Fixed submission:
# author:  Taichicchi
# created: 15.09.2020 21:14:18

import sys

N, M, K = map(int, input().split())

A = list(map(int, input().split()))
B = list(map(int, input().split()))

a = [0]
b = [0]

for i in range(N):
    a.append(a[i] + A[i])
for i in range(M):
    b.append(b[i] + B[i])

ans = 0
j = 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 as np
N, M, K = map(int, input().split())

A = [0] + list(map(int, input().split()))
B = [0] + list(map(int, input().split()))

cum_A = np.cumsum(A)
cum_B = np.cumsum(B)

a = 0
b = 0

flg = False

if cum_A[N] + cum_B[M] <= K:
    ans = N + M
else:
    while True:
        if cum_A[a] <= cum_B[b]:
            if (a < N) & (cum_A[a + 1] + cum_B[b] <= K):
                a += 1
            else:
                flg = True
        elif cum_A[a] > cum_B[b]:
            if (b < M) & (cum_A[a] + cum_B[b + 1] <= K):
                b += 1
            else:
                flg = True
        
        if flg:
            ans = a + b
            break


print(ans)


Fixed submission:
# author:  Taichicchi
# created: 15.09.2020 21:14:18

import sys

N, M, K = map(int, input().split())

A = list(map(int, input().split()))
B = list(map(int, input().split()))

a = [0]
b = [0]

for i in range(N):
    a.append(a[i] + A[i])
for i in range(M):
    b.append(b[i] + B[i])

ans = 0
j = 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 as np
N, M, K = map(int, input().split())

A = [0] + list(map(int, input().split()))
B = [0] + list(map(int, input().split()))

cum_A = np.cumsum(A)
cum_B = np.cumsum(B)

a = 0
b = 0

flg = False

if cum_A[N] + cum_B[M] <= K:
    ans = N + M
elif cum_A[N - 1] + cum_B[M] <= K:
    ans = N + M - 1
elif cum_A[N] + cum_B[M - 1] <= K:
    ans = N + M - 1
else:
    while True:
        if cum_A[a] <= cum_B[b]:
            if cum_A[a + 1] + cum_B[b] <= K:
                a += 1
            else:
                flg = True
        elif cum_A[a] > cum_B[b]:
            if cum_A[a] + cum_B[b + 1] <= K:
                b += 1
            else:
                flg = True
        
        if flg:
            ans = a + b
            break

print(ans)


Fixed submission:
# author:  Taichicchi
# created: 15.09.2020 21:14:18

import sys

N, M, K = map(int, input().split())

A = list(map(int, input().split()))
B = list(map(int, input().split()))

a = [0]
b = [0]

for i in range(N):
    a.append(a[i] + A[i])
for i in range(M):
    b.append(b[i] + B[i])

ans = 0
j = 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)