Buggy python submission (verdict: Runtime Error):
import numpy as np
import bisect
N,M,K= map(int, input().split())
A=list(map(int, input().split()))
B=list(map(int, input().split()))
if A[0]>K and B[0]>K:print(0);exit()

Asum=[0]
for i in range(N):
  if Asum[-1]+A[i]<=K:
    Asum.append(Asum[-1]+A[i])  

Bsum=[0]
for j in range(M):
  if Bsum[-1]+B[j]<=K:
    Bsum.append(Bsum[-1]+B[j])
AAsum=[]
for i in range(N):
  AAsum.append(K-Asum[i])

#print(Asum)
#print(AAsum)
#print(Bsum)

C=[]
for i in range(len(Asum)):
  C.append(bisect.bisect(Bsum,K-Asum[i])+i-1)

#print(Asum)
#print(AAsum)
#print(Bsum)
#print(C)
print(max(C))

Fixed submission:
import numpy as np
import bisect
N,M,K= map(int, input().split())
A=list(map(int, input().split()))
B=list(map(int, input().split()))
if A[0]>K and B[0]>K:print(0);exit()

Asum=[0]
for i in range(N):
  if Asum[-1]+A[i]<=K:
    Asum.append(Asum[-1]+A[i])  
  else:break
    
Bsum=[0]
for j in range(M):
  if Bsum[-1]+B[j]<=K:
    Bsum.append(Bsum[-1]+B[j])
  else:break
    #AAsum=[]
#for i in range(len(Asum)):
#  AAsum.append(K-Asum[i])

#print(Asum)
#print(AAsum)
#print(Bsum)

C=[]
for i in range(len(Asum)):
  C.append(bisect.bisect(Bsum,K-Asum[i])+i-1)

#print(Asum)
#print(AAsum)
#print(Bsum)
#print(C)
print(max(C))
#176882

Buggy python submission (verdict: Runtime Error):
import numpy as np
import bisect
N,M,K= map(int, input().split())
A=list(map(int, input().split()))
B=list(map(int, input().split()))
if A[0]>K and B[0]>K:print(0);exit()

Asum=[0]
for i in range(N):
  if Asum[-1]+A[i]<=K:
    Asum.append(Asum[-1]+A[i])  

Bsum=[0]
for j in range(M):
  if Bsum[-1]+B[j]<=K:
    Bsum.append(Bsum[-1]+B[j])
AAsum=[]
for i in range(N):
  AAsum.append(K-Asum[i])

print(Asum)
print(AAsum)
print(Bsum)
exit()
C=[]
for i in range(len(Asum)):
  C.append(bisect.bisect(Bsum,K-Asum[i])+i-1)

#print(Asum)
#print(AAsum)
#print(Bsum)
#print(C)
print(max(C))

Fixed submission:
import numpy as np
import bisect
N,M,K= map(int, input().split())
A=list(map(int, input().split()))
B=list(map(int, input().split()))
if A[0]>K and B[0]>K:print(0);exit()

Asum=[0]
for i in range(N):
  if Asum[-1]+A[i]<=K:
    Asum.append(Asum[-1]+A[i])  
  else:break
    
Bsum=[0]
for j in range(M):
  if Bsum[-1]+B[j]<=K:
    Bsum.append(Bsum[-1]+B[j])
  else:break
    #AAsum=[]
#for i in range(len(Asum)):
#  AAsum.append(K-Asum[i])

#print(Asum)
#print(AAsum)
#print(Bsum)

C=[]
for i in range(len(Asum)):
  C.append(bisect.bisect(Bsum,K-Asum[i])+i-1)

#print(Asum)
#print(AAsum)
#print(Bsum)
#print(C)
print(max(C))
#176882

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N,M,K= map(int, input().split())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
Asummax=sum(A)
Bsummax=sum(B)
if Asummax+Bsummax<=K:
  print(N+M)
  exit()

Asum=[0]*(N+1)
for i in range(N+1):
  Asum[i]=sum(A[0:i])
  if Asum[i]>K:
    Asum[i]=0
    Amax=i-1
    break
  Amax=i

Bsum=[0]*(M+1)
for i in range(M+1):
  Bsum[i]=sum(B[0:i])
  if Bsum[i]>K:
    Bsum[i]=0
    Bmax=i-1
    break
  Bmax=i

Csum=[0]*(Amax+1)*(Bmax+1)
for i in range(Amax+1):
  for j in range(Bmax+1):
    if Asum[i]+Bsum[j]>K:
      Csum[i*(Bmax+1)+j]=0
    else:Csum[i*(Bmax+1)+j]=Asum[i]+Bsum[j]

Cmax=max(Csum)
D=np.array([i for i, x in enumerate(Csum) if x == Cmax])
D=D//(Bmax+1)+D%(Bmax+1)
print(max(D))

Fixed submission:
import numpy as np
import bisect
N,M,K= map(int, input().split())
A=list(map(int, input().split()))
B=list(map(int, input().split()))
if A[0]>K and B[0]>K:print(0);exit()

Asum=[0]
for i in range(N):
  if Asum[-1]+A[i]<=K:
    Asum.append(Asum[-1]+A[i])  
  else:break
    
Bsum=[0]
for j in range(M):
  if Bsum[-1]+B[j]<=K:
    Bsum.append(Bsum[-1]+B[j])
  else:break
    #AAsum=[]
#for i in range(len(Asum)):
#  AAsum.append(K-Asum[i])

#print(Asum)
#print(AAsum)
#print(Bsum)

C=[]
for i in range(len(Asum)):
  C.append(bisect.bisect(Bsum,K-Asum[i])+i-1)

#print(Asum)
#print(AAsum)
#print(Bsum)
#print(C)
print(max(C))
#176882

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N,M,K= map(int, input().split())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]

Asum=[0]*(N+1)
for i in range(N+1):
  Asum[i]=sum(A[0:i])
  if Asum[i]>K:
    Asum[i]=0
    Amax=i-1
    break
  Amax=i

Bsum=[0]*(M+1)
for i in range(M+1):
  Bsum[i]=sum(B[0:i])
  if Bsum[i]>K:
    Bsum[i]=0
    Bmax=i-1
    break
  Bmax=i
  
Csum=[0]*(Amax+1)*(Bmax+1)
for i in range(Amax+1):
  for j in range(Bmax+1):
    if Asum[i]+Bsum[j]>K:
      Csum[i*(Bmax+1)+j]=0
    else:Csum[i*(Bmax+1)+j]=Asum[i]+Bsum[j]

Cmax=max(Csum)
D=np.array([i for i, x in enumerate(Csum) if x == Cmax])
D=D//(Bmax+1)+D%(Bmax+1)
print(max(D))

Fixed submission:
import numpy as np
import bisect
N,M,K= map(int, input().split())
A=list(map(int, input().split()))
B=list(map(int, input().split()))
if A[0]>K and B[0]>K:print(0);exit()

Asum=[0]
for i in range(N):
  if Asum[-1]+A[i]<=K:
    Asum.append(Asum[-1]+A[i])  
  else:break
    
Bsum=[0]
for j in range(M):
  if Bsum[-1]+B[j]<=K:
    Bsum.append(Bsum[-1]+B[j])
  else:break
    #AAsum=[]
#for i in range(len(Asum)):
#  AAsum.append(K-Asum[i])

#print(Asum)
#print(AAsum)
#print(Bsum)

C=[]
for i in range(len(Asum)):
  C.append(bisect.bisect(Bsum,K-Asum[i])+i-1)

#print(Asum)
#print(AAsum)
#print(Bsum)
#print(C)
print(max(C))
#176882