Buggy python submission (verdict: Runtime Error):
N,M,K=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
c=0
import numpy as np
A=np.array(A).cumsum()
B=np.array(B).cumsum()
for i in range(N):
  d=K-A[i]
  if d>=0:
    for j in reversed(range(M)):
      if d>=B[j]:
        if c<i+j+2:
          c=i+j+2
        M=j+1
        break
    if d<B[0]:
      c=i+1
  else:
    for j in reverse(range(M)):
      if K-B[j]>=0:
        if c<j+1:
          c=j+1
        break
    break
print(c)

Fixed submission:
N,M,K=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
c=0
k=M
import numpy as np
A=np.array(A).cumsum()
B=np.array(B).cumsum()
for i in range(N):
  d=K-A[i]
  if d<0:
    for j in reversed(range(M)):
      if K-B[j]>=0:
        if c<j+1:
          c=j+1
        break
    break
  else:
    for j in reversed(range(k)):
      if d>=B[j]:
        if c<i+j+2:
          c=i+j+2
        k=j+1
        break
    if d<B[0]:
      if c<i+1:
        c=i+1
      k=0
for j in reversed(range(M)):
  if K-B[j]>=0:
    if c<j+1:
      c=j+1
print(c)

Buggy python submission (verdict: Runtime Error):
N,M,K=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list()
a=0
b=0
for i in range(N+M):
  if a+1<=N and b+1<=M and A[a]<B[b]:
    C.append(A[a])
    a+=1
  elif a+1<=N and b+1<=M and A[a]>B[b]:
    C.append(B[b])
    b+=1
  elif  a+1<=N and b+1<=M and A[a]==B[b]:
    if a+2==N:
      C.append(B[b])
      b+=1
    elif b+2==M:
      C.append(A[a])
      a+=1
    elif A[a+1]<B[b+1]:
      C.append(A[a])
      a+=1
    else:
      C.append(B[b])
      b+=1
  elif a==N:
    C.append(B[b])
    b+=1
  elif b==M:
    C.append(A[a])
    a+=1
import numpy as np
L=np.array(C).cumsum()
print(len(L[L <= K]))

Fixed submission:
N,M,K=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
c=0
k=M
import numpy as np
A=np.array(A).cumsum()
B=np.array(B).cumsum()
for i in range(N):
  d=K-A[i]
  if d<0:
    for j in reversed(range(M)):
      if K-B[j]>=0:
        if c<j+1:
          c=j+1
        break
    break
  else:
    for j in reversed(range(k)):
      if d>=B[j]:
        if c<i+j+2:
          c=i+j+2
        k=j+1
        break
    if d<B[0]:
      if c<i+1:
        c=i+1
      k=0
for j in reversed(range(M)):
  if K-B[j]>=0:
    if c<j+1:
      c=j+1
print(c)

Buggy python submission (verdict: Runtime Error):
N,M,K=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list()
a=0
b=0
for i in range(N+M):
  if a+1<=N and b+1<=M and A[a]<B[b]:
    C.append(A[a])
    a+=1
  elif a+1<=N and b+1<=M and A[a]>B[b]:
    C.append(B[b])
    b+=1
  elif  a+1<=N and b+1<=M and A[a]==B[b]:
    if a+2==N:
      C.append(B[b])
      b+=1
    elif b+2==N:
      C.append(A[a])
      a+=1
    elif A[a+1]<B[b+1]:
      C.append(A[a])
      a+=1
    else:
      C.append(B[b])
      b+=1
  elif a==N:
    C.append(B[b])
    b+=1
  elif b==M:
    C.append(A[a])
    a+=1
import numpy as np
L=np.array(C).cumsum()
print(len(L[L <= K]))

Fixed submission:
N,M,K=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
c=0
k=M
import numpy as np
A=np.array(A).cumsum()
B=np.array(B).cumsum()
for i in range(N):
  d=K-A[i]
  if d<0:
    for j in reversed(range(M)):
      if K-B[j]>=0:
        if c<j+1:
          c=j+1
        break
    break
  else:
    for j in reversed(range(k)):
      if d>=B[j]:
        if c<i+j+2:
          c=i+j+2
        k=j+1
        break
    if d<B[0]:
      if c<i+1:
        c=i+1
      k=0
for j in reversed(range(M)):
  if K-B[j]>=0:
    if c<j+1:
      c=j+1
print(c)