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

nss = [0]
for i, v in enumerate(ns): nss.append(nss[i] + ns[i])
mss = [0]
for i, v in enumerate(ms): mss.append(mss[i] + ms[i])

from bisect import bisect_left

mx = 0
for i in range(n + 1):
    if nss[i] > k:
        break

    v = k - nss[i]
    j = bisect_left(mss, v)
    print(i, nss, j, mss, k)
    if j < m and mss[j] != v:
        j -= 1

    mx = max(mx, i + j)

print(mx)


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

nss = [0]
for i, v in enumerate(ns):
    nss.append(nss[i] + ns[i])

mss = [0]
for i, v in enumerate(ms):
    mss.append(mss[i] + ms[i])

mx = 0
j = m
for i in range(n + 1):
    if nss[i] > k:
        break

    while mss[j] > k - nss[i]:
        j -= 1
    
    mx = max(mx, i + j)

print(mx)

Buggy python submission (verdict: Time Limit Exceeded):
n, m, k = list(map(int, input().split()))
ns = list(map(int, input().split()))
ms = list(map(int, input().split()))

nss = [0]
for i, v in enumerate(ns): nss.append(nss[i] + ns[i])
mss = [0]
for i, v in enumerate(ms): mss.append(mss[i] + ms[i])

mx = 0
for i in range(n + 1):
    if nss[i] > k:
        break

    j = -1
    for v in mss:
        if nss[i] + v > k:
            break
        j += 1
    mx = max(mx, i + j)

print(mx)


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

nss = [0]
for i, v in enumerate(ns):
    nss.append(nss[i] + ns[i])

mss = [0]
for i, v in enumerate(ms):
    mss.append(mss[i] + ms[i])

mx = 0
j = m
for i in range(n + 1):
    if nss[i] > k:
        break

    while mss[j] > k - nss[i]:
        j -= 1
    
    mx = max(mx, i + j)

print(mx)

Buggy python submission (verdict: Time Limit Exceeded):
n, m, k = list(map(int, input().split()))
ns = list(map(int, input().split()))
ms = list(map(int, input().split()))

nss = [sum(ns[:i]) for i in range(n+1)]
mss = [sum(ms[:i]) for i in range(m+1)]

mx = 0
for i in range(n + 1):
    if nss[i] > k:
        break

    j = -1
    for v in mss:
        if nss[i] + v > k:
            break
        j += 1
    mx = max(mx, i + j)

print(mx)


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

nss = [0]
for i, v in enumerate(ns):
    nss.append(nss[i] + ns[i])

mss = [0]
for i, v in enumerate(ms):
    mss.append(mss[i] + ms[i])

mx = 0
j = m
for i in range(n + 1):
    if nss[i] > k:
        break

    while mss[j] > k - nss[i]:
        j -= 1
    
    mx = max(mx, i + j)

print(mx)

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

import pandas as pd
nss = pd.Series([0] + ns).cumsum()
mss = pd.Series([0] + ms).cumsum()

mx = 0
for i in range(n + 1):
    if nss[i] > k:
        break

    j = -1
    for v in mss:
        if nss[i] + v > k:
            break
        j += 1
    mx = max(mx, i + j)

print(mx)

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

nss = [0]
for i, v in enumerate(ns):
    nss.append(nss[i] + ns[i])

mss = [0]
for i, v in enumerate(ms):
    mss.append(mss[i] + ms[i])

mx = 0
j = m
for i in range(n + 1):
    if nss[i] > k:
        break

    while mss[j] > k - nss[i]:
        j -= 1
    
    mx = max(mx, i + j)

print(mx)