Buggy python submission (verdict: Time Limit Exceeded):
N,M,K = list(map(int,input().split()))
A = list(map(int,input().split()))
B = list(map(int,input().split()))
a,b = [0],[0]
for i in range(N):
  a.append(a[i]+A[i])
for j in range(M):
  b.append(b[j]+B[j])
max = 0
#print(a,b,N+1)
for i in range(N+1):
  if a[i] > K:
    break
  j = 0
  while K - a[i] >= b[j]:
    if max < i + j:
      max = i + j
    if j >= M:
      break
    j = j+1

print(max)

Fixed submission:
N,M,K = list(map(int,input().split()))
A = list(map(int,input().split()))
B = list(map(int,input().split()))
a,b = [0],[0]
for i in range(N):
  a.append(a[i]+A[i])
for j in range(M):
  b.append(b[j]+B[j])
ans = 0
#print(a,b,N+1)
j = M
for i in range(N+1):
  if a[i] > K:
    break

  while K - a[i] < b[j]:
    j = j-1
  ans = max(ans,i+j)

print(ans)

Buggy python submission (verdict: Runtime Error):
n,m,l = map(int,input().split(" "))
Ns = input().split(" ")
N = [int (n) for n in Ns]
Ms = input().split(" ")
M = [int(n) for n in Ms]
#print(n,m,l)
#print(N,M)
i = 0
j = 0
total = 0
cnt = 0
while total < l:
  #print(i,j,total,cnt)
  if  i == n and j == m:
    break
  elif i < n and j == m:
    if total + N[i] <= l:
      total = total + N[i]
      i = i+1
      cnt = cnt + 1
    else:
      break
  elif i == n and j < m:
    if total + M[i] <= l:
      total = total + M[j]
      j = j+1
      cnt = cnt +1
    else:
      break
  elif i < n and j < m and (total+N[i] <= l or total+M[j] <= l):
    if N[i] <= M[j]:
      total = total + N[i]
      i = i+1
      cnt = cnt +1
    elif N[i] > M[j]:
      total = total + M[j]
      j = j+1
      cnt = cnt +1
  else:
    break
print(cnt)#,i,j,total,n,m,l)

Fixed submission:
N,M,K = list(map(int,input().split()))
A = list(map(int,input().split()))
B = list(map(int,input().split()))
a,b = [0],[0]
for i in range(N):
  a.append(a[i]+A[i])
for j in range(M):
  b.append(b[j]+B[j])
ans = 0
#print(a,b,N+1)
j = M
for i in range(N+1):
  if a[i] > K:
    break

  while K - a[i] < b[j]:
    j = j-1
  ans = max(ans,i+j)

print(ans)

Buggy python submission (verdict: Runtime Error):
n,m,l = map(int,input().split(" "))
Ns = input().split(" ")
N = [int (n) for n in Ns]
Ms = input().split(" ")
M = [int(n) for n in Ms]
#print(n,m,l)
#print(N,M)
i = 0
j = 0
total = 0
cnt = 0
while total <= l:
  #print(i,j,total,cnt)
  if  i == n and j == m:
    break
  elif i < n and j == m:
    if total + N[i] <= l:
      total = total + N[i]
      i = i+1
      cnt = cnt + 1
    else:
      break
  elif i == n and j < m:
    if total + M[i] <= l:
      total = total + M[j]
      j = j+1
      cnt = cnt +1
    else:
      break
  elif i < n and j < m and (total+N[i] <= l or total+M[j] <= l):
    if N[i] <= M[j]:
      total = total + N[i]
      i = i+1
      cnt = cnt +1
    elif N[i] > M[j]:
      total = total + M[j]
      j = j+1
      cnt = cnt +1
  else:
    break
print(cnt)#,i,j,total,n,m,l)

Fixed submission:
N,M,K = list(map(int,input().split()))
A = list(map(int,input().split()))
B = list(map(int,input().split()))
a,b = [0],[0]
for i in range(N):
  a.append(a[i]+A[i])
for j in range(M):
  b.append(b[j]+B[j])
ans = 0
#print(a,b,N+1)
j = M
for i in range(N+1):
  if a[i] > K:
    break

  while K - a[i] < b[j]:
    j = j-1
  ans = max(ans,i+j)

print(ans)

Buggy python submission (verdict: Runtime Error):
n,m,l = map(int,input().split(" "))
Ns = input().split(" ")
N = [int (n) for n in Ns]
Ms = input().split(" ")
M = [int(n) for n in Ms]
#print(n,m,l)
#print(N,M)
i = 0
j = 0
total = 0
cnt = 0
while total <= l:
  if  N[i] <= M[j]:
    total = total + N[i]
    i = i+1
    cnt = cnt +1
  else:
    total = total + M[j]
    j = j+1
    cnt = cnt +1
print(cnt-1)

Fixed submission:
N,M,K = list(map(int,input().split()))
A = list(map(int,input().split()))
B = list(map(int,input().split()))
a,b = [0],[0]
for i in range(N):
  a.append(a[i]+A[i])
for j in range(M):
  b.append(b[j]+B[j])
ans = 0
#print(a,b,N+1)
j = M
for i in range(N+1):
  if a[i] > K:
    break

  while K - a[i] < b[j]:
    j = j-1
  ans = max(ans,i+j)

print(ans)

Buggy python submission (verdict: Runtime Error):
n,m,l = map(int,input().split(" "))
Ns = input().split(" ")
N = [int (n) for n in Ns]
Ms = input().split(" ")
M = [int(n) for n in Ms]
#print(n,m,l)
#print(N,M)
i = 0
j = 0
total = 0
cnt = 0
while total <= l:
  if  N[i] <= M[j]:
    total = total + N[i]
    i = i+1
    cnt = cnt +1
  else:
    total = total + M[j]
    j = j+1
    cnt = cnt +1
print(cnt)

Fixed submission:
N,M,K = list(map(int,input().split()))
A = list(map(int,input().split()))
B = list(map(int,input().split()))
a,b = [0],[0]
for i in range(N):
  a.append(a[i]+A[i])
for j in range(M):
  b.append(b[j]+B[j])
ans = 0
#print(a,b,N+1)
j = M
for i in range(N+1):
  if a[i] > K:
    break

  while K - a[i] < b[j]:
    j = j-1
  ans = max(ans,i+j)

print(ans)

Buggy python submission (verdict: Runtime Error):
n,m,l = map(int,input().split(" "))
Ns = input().split(" ")
N = [int (n) for n in Ns]
Ms = input().split(" ")
M = [int(n) for n in Ms]
#print(n,m,l)
#print(N,M)
i = 0
j = 0
total = 0
cnt = 0
while total <= l:
  if  N[i] <= M[j]:
    total = total + N[i]
    i = i+1
    cnt = cnt +1
  else:
    total = total + M[j]
    j = j+1
    cnt = cnt +1
print(cnt-1)

Fixed submission:
N,M,K = list(map(int,input().split()))
A = list(map(int,input().split()))
B = list(map(int,input().split()))
a,b = [0],[0]
for i in range(N):
  a.append(a[i]+A[i])
for j in range(M):
  b.append(b[j]+B[j])
ans = 0
#print(a,b,N+1)
j = M
for i in range(N+1):
  if a[i] > K:
    break

  while K - a[i] < b[j]:
    j = j-1
  ans = max(ans,i+j)

print(ans)