Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
from functools import reduce

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

cumA = reduce(lambda x, y: x + [y + x[-1]], As, [0])
cumB = reduce(lambda x, y: x + [y + x[-1]], Bs, [0])
cumA.append(np.inf)
cumB.append(np.inf)
cumA = np.array(cumA)
cumB = np.array(cumB)

max_count = 0
a_thresh = np.where(cumA > K)[0][0]
a_count = a_thresh
b_count = 0
b_thresh = np.where(cumB > K)[0][0]
while a_count >= 0 and b_count <= b_thresh:
    while b_count <= b_thresh and cumA[a_count] + cumB[b_count] <= K:
        b_count += 1
    b_count = max(0, b_count - 1)
    if cumA[a_count] + cumB[b_count] <= K:
        max_count = max(max_count, a_count + b_count)
    a_count -= 1

print(max_count)


Fixed submission:
import numpy as np
from functools import reduce

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


def get_cum(arr):
    cum_arr = [0]
    for e in arr:
        tot = cum_arr[-1] + e
        if tot > K:
            return cum_arr
        cum_arr.append(tot)
    return cum_arr


cumA = get_cum(As)
cumB = get_cum(Bs)

max_count = 0
a_thresh = len(cumA) - 1
a_count = a_thresh
b_count = 0
b_thresh = len(cumB) - 1
while a_count >= 0 and b_count <= b_thresh:
    while b_count <= b_thresh and cumA[a_count] + cumB[b_count] <= K:
        b_count += 1
    b_count = max(0, b_count - 1)
    if cumA[a_count] + cumB[b_count] <= K:
        max_count = max(max_count, a_count + b_count)
    a_count -= 1

print(max_count)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
from functools import reduce

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

cumA = reduce(lambda x, y: x + [y + x[-1]], As, [0])
cumB = reduce(lambda x, y: x + [y + x[-1]], Bs, [0])

max_count = 0
a_count = len(As)
b_count = 0
while a_count >= 0 and b_count < len(Bs):
    while b_count <= len(Bs) and cumA[a_count] + cumB[b_count] <= K:
        b_count += 1
    b_count = max(0, b_count - 1)
    if cumA[a_count] + cumB[b_count] <= K:
        max_count = max(max_count, a_count + b_count)
    a_count -= 1

print(max_count)


Fixed submission:
import numpy as np
from functools import reduce

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


def get_cum(arr):
    cum_arr = [0]
    for e in arr:
        tot = cum_arr[-1] + e
        if tot > K:
            return cum_arr
        cum_arr.append(tot)
    return cum_arr


cumA = get_cum(As)
cumB = get_cum(Bs)

max_count = 0
a_thresh = len(cumA) - 1
a_count = a_thresh
b_count = 0
b_thresh = len(cumB) - 1
while a_count >= 0 and b_count <= b_thresh:
    while b_count <= b_thresh and cumA[a_count] + cumB[b_count] <= K:
        b_count += 1
    b_count = max(0, b_count - 1)
    if cumA[a_count] + cumB[b_count] <= K:
        max_count = max(max_count, a_count + b_count)
    a_count -= 1

print(max_count)

Buggy python submission (verdict: Runtime Error):
N, M, K = list(map(int, input().split()))
As = list(map(int, input().split()))
Bs = list(map(int, input().split()))

count = 0
while K >= min(As[0], Bs[0]):
  if As[0] <= Bs[0]:
    t = As.pop(0)
  else:
    t = Bs.pop(0)
  K -= t
  count += 1
  
print(count)

Fixed submission:
import numpy as np
from functools import reduce

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


def get_cum(arr):
    cum_arr = [0]
    for e in arr:
        tot = cum_arr[-1] + e
        if tot > K:
            return cum_arr
        cum_arr.append(tot)
    return cum_arr


cumA = get_cum(As)
cumB = get_cum(Bs)

max_count = 0
a_thresh = len(cumA) - 1
a_count = a_thresh
b_count = 0
b_thresh = len(cumB) - 1
while a_count >= 0 and b_count <= b_thresh:
    while b_count <= b_thresh and cumA[a_count] + cumB[b_count] <= K:
        b_count += 1
    b_count = max(0, b_count - 1)
    if cumA[a_count] + cumB[b_count] <= K:
        max_count = max(max_count, a_count + b_count)
    a_count -= 1

print(max_count)