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

n,m,k=map(int,input().split())
a=np.array(list(map(int,input().split())))
b=np.array(list(map(int,input().split())))

ak=np.cumsum(a,dtype=np.int64)
bk=np.cumsum(b,dtype=np.int64)
ak=ak[ak<=k]
bk=bk[bk<=k]
lak=len(ak)
lbk=len(bk)

an=lak
j=0
for i in range(lak-1,-1,-1):
    while bk[j]+ak[i]<=k:
        an=max(an,i+j+2)
        j+=1
        if j>=lbk:
            j=0
            break
an=max(an,lbk)

print(an)

Fixed submission:
import numpy as np

n,m,k=map(int,input().split())
a=np.array(list(map(int,input().split())))
b=np.array(list(map(int,input().split())))

ak=np.cumsum(a,dtype=np.int64)
bk=np.cumsum(b,dtype=np.int64)
ak=ak[ak<=k]
bk=bk[bk<=k]
lak=len(ak)
lbk=len(bk)

an=lak
j=0
for i in range(lak-1,-1,-1):
    while bk[j]+ak[i]<=k:
        an=max(an,i+j+2)
        j+=1
        if j>=lbk:
            j-=1
            break
an=max(an,lbk)

print(an)

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

n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
wk=0
aa=[]
bb=[]
for i in a:
    wk+=i
    aa.append(wk)
wk=0
for i in b:
    wk+=i
    bb.append(wk)
ak=np.array(aa)
bk=np.array(bb)

ass = len([1 for i in ak if i<=k]) 
bs = len([1 for i in bk if i<=k]) 

an=0
for i in range(ass-1,-1,-1):
    wk = len([1 for j in bk if j<=(k-ak[i])]) 
    an=max(an,(i+1+wk))
an=max(an,ass)
an=max(an,bs)

print(an)

Fixed submission:
import numpy as np

n,m,k=map(int,input().split())
a=np.array(list(map(int,input().split())))
b=np.array(list(map(int,input().split())))

ak=np.cumsum(a,dtype=np.int64)
bk=np.cumsum(b,dtype=np.int64)
ak=ak[ak<=k]
bk=bk[bk<=k]
lak=len(ak)
lbk=len(bk)

an=lak
j=0
for i in range(lak-1,-1,-1):
    while bk[j]+ak[i]<=k:
        an=max(an,i+j+2)
        j+=1
        if j>=lbk:
            j-=1
            break
an=max(an,lbk)

print(an)

Buggy python submission (verdict: Runtime Error):
import sys

def syoki(k,skk,atk,):
    sks=ats=0
    for i in range(len(skk)):
        if skk[i]<=k:
            sks=i+1
        else:
            break
    for i in range(len(atk)):
        if atk[i]+skk[sks-1]<=k:
            ats=i+1
        else:
            break
    return(sks,ats)

def keisan(o,s,k,ok,sk,os,ss):
    swk=ss
    for i in range(os-2,-1,-1):
        while k> ok[i]+sk[swk]:
            swk+=1
            if swk<s:
                break
    return max(os+ss,i+swk)

n,m,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
ak=[]
aa=0
for i in a:
    aa+=i
    ak.append(aa)
bk=[]
bb=0
for i in b:
    bb+=i
    bk.append(bb)

xa,xb=syoki(k,ak,bk)
yb,ya=syoki(k,bk,ak)
if xa+xb>yb>ya:
    ass=xa
    bs=xb
else:
    ass=ya
    bs=yb

wk=ass+bs

if wk==n+m:
    print(n+m)
    sys.exit()
if ass ==0 and bs==0:
    print(0)
    sys.exit()
if ass>bs:
    an=keisan(n,m,k,ak,bk,ass,bs)
else:
    an=keisan(m,n,k,bk,ak,bs,ass)

print(an)

Fixed submission:
import numpy as np

n,m,k=map(int,input().split())
a=np.array(list(map(int,input().split())))
b=np.array(list(map(int,input().split())))

ak=np.cumsum(a,dtype=np.int64)
bk=np.cumsum(b,dtype=np.int64)
ak=ak[ak<=k]
bk=bk[bk<=k]
lak=len(ak)
lbk=len(bk)

an=lak
j=0
for i in range(lak-1,-1,-1):
    while bk[j]+ak[i]<=k:
        an=max(an,i+j+2)
        j+=1
        if j>=lbk:
            j-=1
            break
an=max(an,lbk)

print(an)

Buggy python submission (verdict: Runtime Error):
import sys

n,m,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
ak=[]
aa=0
for i in a:
    aa+=i
    ak.append(aa)
bk=[]
bb=0
for i in b:
    bb+=i
    bk.append(bb)
ass=bs=0
for i in range(len(ak)):
    if ak[i]<=k:
        ass=i+1
    else:
        break
for i in range(len(bk)):
    if bk[i]+ak[ass-1]<=k:
        bs=i+1
    else:
        break
wk=ass+bs
aswk=ass
bswk=bs
if wk==n+m:
    print(n+m)
    sys.exit()

for i in range(ass-2,-1,-1):
    while k> ak[i]+bk[bswk]:
        bswk+=1
        if bswk<=m:
            break
an = max(ass+bs,i+bswk)        
        
print(an)

Fixed submission:
import numpy as np

n,m,k=map(int,input().split())
a=np.array(list(map(int,input().split())))
b=np.array(list(map(int,input().split())))

ak=np.cumsum(a,dtype=np.int64)
bk=np.cumsum(b,dtype=np.int64)
ak=ak[ak<=k]
bk=bk[bk<=k]
lak=len(ak)
lbk=len(bk)

an=lak
j=0
for i in range(lak-1,-1,-1):
    while bk[j]+ak[i]<=k:
        an=max(an,i+j+2)
        j+=1
        if j>=lbk:
            j-=1
            break
an=max(an,lbk)

print(an)

Buggy python submission (verdict: Runtime Error):
import sys

n,m,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
ak=[]
aa=0
for i in a:
    aa+=i
    ak.append(aa)
bk=[]
bb=0
for i in b:
    bb+=i
    bk.append(bb)
ass=bs=0
for i in range(len(ak)):
    if ak[i]<=k:
        ass=i+1
    else:
        break
for i in range(len(bk)):
    if bk[i]+ak[ass-1]<=k:
        bs=i+1
    else:
        break
wk=ass+bs
aswk=ass
bswk=bs
if wk==n+m:
    print(n+m)
    sys.exit()

while aswk>1:
    aswk-=1
    while k< ak[aswk-1]+bk[bswk-1]:
        if bswk <=m:
            bswk+=1
        else:
            break
    if bs<=bswk-1:
        bs=bswk
        ass=aswk
    else:
        break        
print(ass+bs)

Fixed submission:
import numpy as np

n,m,k=map(int,input().split())
a=np.array(list(map(int,input().split())))
b=np.array(list(map(int,input().split())))

ak=np.cumsum(a,dtype=np.int64)
bk=np.cumsum(b,dtype=np.int64)
ak=ak[ak<=k]
bk=bk[bk<=k]
lak=len(ak)
lbk=len(bk)

an=lak
j=0
for i in range(lak-1,-1,-1):
    while bk[j]+ak[i]<=k:
        an=max(an,i+j+2)
        j+=1
        if j>=lbk:
            j-=1
            break
an=max(an,lbk)

print(an)