Buggy python submission (verdict: Runtime Error):
from numpy import cumsum
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
a=cumsum(a)
b=cumsum(b)

for i in range(n):
    if a[i]>k:
        read=i
        break
if a[n-1]<k:
    read=n
time=a[read-1]
ans=read
start=read-1
if read==n:
    for i in range(m):
        if time+b[i]>k:
            read+=i
            ans=max(ans,read)
            read-=i
        if i==m-1:
            print(n+m)
            exit()
            
for i in range(start+1):
    read-=1
    time-=a[start-i]
    for j in range(m):
        if time+b[j]>k:
            read+=j
            ans=max(ans,read)
            read-=j
            break
        if j==m-1:
            read+=m
            print(max(ans,read))
            exit()
print(ans)

Fixed submission:
from bisect import bisect
from numpy import cumsum
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
a=cumsum(a)
b=cumsum(b)

read=bisect(a,k)
time=a[read-1]
ans=read

for i in range(read):
    extra=k-time
    r=bisect(b,extra)
    ans=max(ans,read+r)
    read-=1
    time=a[read-1]
read=bisect(b,k)
ans=max(ans,read)
print(ans)

Buggy python submission (verdict: Runtime Error):
from numpy import cumsum
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
a=cumsum(a)
b=cumsum(b)

for i in range(n):
    if a[i]>k:
        read=i
        break
if a[n-1]<k:
    read=n
time=a[read-1]
ans=read
start=read-1
if read==n:
    for i in range(m):
        if time+b[i]>k:
            read+=i
            ans=max(ans,read)
            read=-i
        if i==m-1:
            print(n+m)
            exit()
            
for i in range(start+1):
    read-=1
    time-=a[start-i]
    for j in range(m):
        if time+b[j]>k:
            read+=j
            ans=max(ans,read)
            read-=j
            break
        if j==m-1:
            read+=m
            print(max(ans,read))
            exit()
print(ans)

Fixed submission:
from bisect import bisect
from numpy import cumsum
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
a=cumsum(a)
b=cumsum(b)

read=bisect(a,k)
time=a[read-1]
ans=read

for i in range(read):
    extra=k-time
    r=bisect(b,extra)
    ans=max(ans,read+r)
    read-=1
    time=a[read-1]
read=bisect(b,k)
ans=max(ans,read)
print(ans)

Buggy python submission (verdict: Runtime Error):
from numpy import cumsum
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
a=cumsum(a)
b=cumsum(b)

for i in range(n):
    if a[i]>k:
        read=i
        break
if a[n-1]<k:
    read=n
time=a[read-1]
ans=read
start=read-1
if read==n:
    for i in range(m):
        if time+b[i]>k:
            read+=i
            ans=max(ans,read)
            read=-i
        if i==m-1:
            print(n+m)
            exit()
            
for i in range(read):
    read-=1
    time-=a[start-i]
    for j in range(m):
        if time+b[j]>k:
            read+=j
            ans=max(ans,read)
            read-=j
            break
        if j==m-1:
            read+=m
            print(max(ans,read))
            exit()
print(ans)

Fixed submission:
from bisect import bisect
from numpy import cumsum
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
a=cumsum(a)
b=cumsum(b)

read=bisect(a,k)
time=a[read-1]
ans=read

for i in range(read):
    extra=k-time
    r=bisect(b,extra)
    ans=max(ans,read+r)
    read-=1
    time=a[read-1]
read=bisect(b,k)
ans=max(ans,read)
print(ans)