TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it.  It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M).  Consider the following action:    * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk.  How many books can we read at most by repeating this action so that it takes us at most K minutes in total? We ignore the time it takes to do anything other than reading.

Submission attempts (in order):
N, M, K = map(int, input().split())
A_temp = [int(i) for i in input().split()]
B_temp = [int(i) for i in input().split()]

A, B = [0]*(N+1), [0]*(M+1)
for i in range(1, N):
    A[i] = A[i-1] + A_temp[i-1]
    
for j in range(1, M):
    B[j] = B[j-1] + B_temp[j-1]
    
ans = 0
for a in range(N+1):
    if A[a] > K:
        break
    for b in range(ans-a+1, M+1):
        if A[a] + B[b] > K:
            break
        ans = max(ans, a+b)
        
print(ans)

N, M, K = map(int, input().split())
A_temp = [int(i) for i in input().split()]
B_temp = [int(i) for i in input().split()]

A, B = [0]*(N+1), [0]*(M+1)
for i in range(1, N):
    A[i] = A[i-1] + A_temp[i-1]
    
for j in range(1, M):
    B[j] = B[j-1] + B_temp[j-1]
    
ans = 0
for a in range(N+1):
    if A[a] > K:
        break
    for b in range(M+1):
        if A[a] + B[b] > K:
            break
        ans = max(ans, a+b)
        
print(ans)

import sys
input = sys.stdin.readline

N, M, K = map(int, input().split())
A_temp = [int(i) for i in input().split()]
B_temp = [int(i) for i in input().split()]

A, B = [0]*(N+1), [0]*(M+1)
for i in range(1, N+1):
    A[i] = A[i-1] + A_temp[i-1]
for i in range(1, M+1):
    B[i] = B[i-1] + B_temp[i-1]

ans = 0
b = M
for a in range(N+1):
    if A[a] > K:
        break
    while B[b] > K - A[a]:
        b -= 1
    ans = max(ans, a + b)
print(ans)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it.  It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M).  Consider the following action:    * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk.  How many books can we read at most by repeating this action so that it takes us at most K minutes in total? We ignore the time it takes to do anything other than reading.

Submission attempts (in order):
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

tmp = []
s = 0
for i in a:
    if s + i <= k:
        tmp.append(i)
        s += i
    else:
        break
a = tmp
tmp = []
s = 0
for i in b:
    if s + i <= k:
        tmp.append(i)
        s += i
    else:
        break
b = tmp
line = b[::-1] + a
print(line)
ans = 0
right = 0
sum_ = 0
for left in range(len(line)):
    while right < len(line) and sum_ + line[right] <= k:
        sum_ += line[right]
        right += 1
    l = right -left 
    if l > ans:
        ans = l

    if right == left: right += 1
    else: sum_ -= line[left]

print(ans) 

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

tmp = []
s = 0
for i in a:
    if s + i <= k:
        tmp.append(i)
        s += i
    else:
        break
a = tmp
tmp = []
s = 0
for i in b:
    if s + i <= k:
        tmp.append(i)
        s += i
    else:
        break
b = tmp
line = b[::-1] + a

ans = 0
right = 0
sum_ = 0
for left in range(len(line)):
    while right < len(line) and sum_ + line[right] <= k:
        sum_ += line[right]
        right += 1
    l = right -left 
    if l > ans:
        ans = l

    if right == left: right += 1
    else: sum_ -= line[left]

print(ans) 

Verdicts: Wrong Answer

Accepted
Problem: We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it.  It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M).  Consider the following action:    * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk.  How many books can we read at most by repeating this action so that it takes us at most K minutes in total? We ignore the time it takes to do anything other than reading.

Submission attempts (in order):
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
from itertools import accumulate
ar=[0]+list(accumulate(a))
bru=[0]+list(accumulate(b))
from bisect import bisect_left as bl,bisect_right as br
ans=0
print(ar,bru)
for i in range(n+1):
    g=ar[i]
    if g>k:break
    if k-g>=bru[-1]:ans=max(ans,i+m);continue
    j=bl(bru,k-g)
    ans=max(ans,i+j-1)

print(ans)

n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
from itertools import accumulate
ar=[0]+list(accumulate(a))
bru=[0]+list(accumulate(b))
from bisect import bisect_left as bl,bisect_right as br
ans=0

for i in range(n+1):
    g=ar[i]
    if g>k:break
    if k-g>=bru[-1]:ans=max(ans,i+m);continue
    j=br(bru,k-g)
    ans=max(ans,i+j-1)
    #print(i,j-1)
print(ans)


Verdicts: Wrong Answer

Accepted
Problem: We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it.  It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M).  Consider the following action:    * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk.  How many books can we read at most by repeating this action so that it takes us at most K minutes in total? We ignore the time it takes to do anything other than reading.

Submission attempts (in order):
# -*- coding: utf-8 -*-
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
sumbook,sumt,i,j=0,0,0,0
while True:
  if i<=(n-1) and j<=(m-1):
    if a[i]>b[j]:
      sumt+=b[j]
      j+=1
    else:
      sumt+=a[i]
      i+=1
  elif i>(n-1) and j<=(m-1):
    sumt+=b[j]
    j+=1
  elif i<=(n-1) and j>(m-1):
    sumt+=a[i]
    i+=1


  if sumt>=k:
    sumbook+=1
    break
  sumbook+=1
print(sumbook)

# -*- coding: utf-8 -*-
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))

asum,bsum=[0],[0]

for i in range(n):
  asum.append(asum[i]+a[i])
for i in range(m):
  bsum.append(bsum[i]+b[i])

ans,j=0,m
for i in range(n+1):
  if asum[i]>k:
    break
  while bsum[j]>k-asum[i]:
    j-=1
  ans=max(ans,i+j)
print(ans)  

Verdicts: Wrong Answer

Accepted
Problem: We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it.  It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M).  Consider the following action:    * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk.  How many books can we read at most by repeating this action so that it takes us at most K minutes in total? We ignore the time it takes to do anything other than reading.

Submission attempts (in order):
n, m, k = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))

C = [0]
D = [0]
for a in A:
    C.append(C[-1] + a)
for b in B:
    D.append(D[-1] + b)

p = n
for i in range(n + 1):
    if C[i] > k:
        p = i - 1
        break

_max = 0
keep = 0
for i in range(p, -1, -1):
    for j in range(keep, m + 1):
        if C[i] + D[j] > k:
            _max = i + j - 1
            keep = j
            break
print(_max)

n, m, k = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))

C = [0]
D = [0]
for a in A:
    C.append(C[-1] + a)
for b in B:
    D.append(D[-1] + b)

p = n
for i in range(n + 1):
    if C[i] > k:
        p = i - 1
        break

_max = p
keep = 0
for i in range(p, -1, -1):
    for j in range(keep, m + 1):
        if C[i] + D[j] > k:
            keep = j - 1
            break
        elif _max < i + j:
            _max = i + j
    if j == m:
        break
print(_max)

Verdicts: Wrong Answer

Accepted
Problem: We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it.  It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M).  Consider the following action:    * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk.  How many books can we read at most by repeating this action so that it takes us at most K minutes in total? We ignore the time it takes to do anything other than reading.

Submission attempts (in order):
from bisect import bisect_left
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())))

if A.sum() + B.sum() <= K:
    print(N + M)
    exit()

cumsum_A = [0] + A.cumsum()
cumsum_B = [0] + B.cumsum()
print('cusmum_A', cumsum_A)
print('cusmum_B', cumsum_B)

ans = 0
for num_A, t in enumerate(cumsum_A, start=1):
    if t > K:
        continue
    if t == K:
        ans = max(ans, num_A)
    num_B = bisect_left(cumsum_B, K - t)
    
    ans = max(ans, num_A + num_B)

for num_B, t in enumerate(cumsum_B, start=1):
    if t <= K:
        ans = max(ans, num_B)
print(ans)


from bisect import bisect_left
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())))

if A.sum() + B.sum() <= K:
    print(N + M)
    exit()

cumsum_A = [0] + A.cumsum()
cumsum_B = [0] + B.cumsum()
print('cusmum_A', cumsum_A)
print('cusmum_B', cumsum_B)

ans = 0
for num_A, t in enumerate(cumsum_A, start=1):
    if t > K:
        break
    if t == K:
        ans = max(ans, num_A)
    num_B = bisect_left(cumsum_B, K - t)
    
    ans = max(ans, num_A + num_B)

for num_B, t in enumerate(cumsum_B, start=1):
    if t <= K:
        ans = max(ans, num_B)
print(ans)


import numpy as np
from bisect import bisect_right

N, M, K = map(int, input().split())
A: np.ndarray = np.array([0] + list(map(int, input().split())))
B: np.ndarray = np.array([0] + list(map(int, input().split())))

if A.sum() + B.sum() <= K:
    print(N + M)
    exit()

A_cumsum = A.cumsum()
B_cumsum = B.cumsum()

# print(f'{A_cumsum=}')
# print(f'{B_cumsum=}')

ans = 0
for i in range(N + 1):
    A_time = A_cumsum[i]
    if A_time > K:
        continue
    j = bisect_right(B_cumsum, K - A_time) - 1
    ans = max(ans, i + j)
print(ans)


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it.  It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M).  Consider the following action:    * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk.  How many books can we read at most by repeating this action so that it takes us at most K minutes in total? We ignore the time it takes to do anything other than reading.

Submission attempts (in order):
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
aa,bb=[0],[0]
for i in range(n):
    aa.append(aa[-1]+a[i])
for i in range(m):
    bb.append(bb[-1]+b[i])
ans,j=0,m
for i in range(n+1):
    if a[i]>k:
        break
    while b[j]>k-a[i]:
        j-=1
    ans=max(ans,i+j)
print(ans)

n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
aa,bb=[0],[0]
for i in range(n):
    aa.append(aa[-1]+a[i])
for i in range(m):
    bb.append(bb[-1]+b[i])
ans,j=0,m
for i in range(n+1):
    if aa[i]>k:
        break
    while bb[j]>k-aa[i]:
        j-=1
    ans=max(ans,i+j)
print(ans)

Verdicts: Runtime Error

Accepted
Problem: We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it.  It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M).  Consider the following action:    * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk.  How many books can we read at most by repeating this action so that it takes us at most K minutes in total? We ignore the time it takes to do anything other than reading.

Submission attempts (in order):
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
A=[0]
for i in range(n):
  A.append(a[i])
B=[0]
for i in range(m):
  B.append(b[i])
ans=0
j=m
for i in range(n+1):
  if A[i]>k:
      break
  while B[j]>(k-A[i]):
    j-=1
  ans=max(ans,i+j)
print(ans)

n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
A=[0]
for i in range(n):
  A.append(a[i])
B=[0]
for i in range(m):
  B.append(b[i])
ans=0
j=m
for i in range(n+1):
  while B[j]>(k-A[i]):
    j-=1
  ans=max(ans,i+j)
print(ans)

n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
A=[0]
for i in range(n):
  A.append(A[i]+a[i])
B=[0]
for i in range(m):
  B.append(B[i]+b[i])
ans=0
j=m
for i in range(n+1):
  if A[i]>k:
      break
  while B[j]>(k-A[i]):
    j-=1
  ans=max(ans,i+j)
print(ans)

Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it.  It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M).  Consider the following action:    * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk.  How many books can we read at most by repeating this action so that it takes us at most K minutes in total? We ignore the time it takes to do anything other than reading.

Submission attempts (in order):
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

a.insert(0, 0)
b.insert(0, 0)

ans, j = 0, m
for i in range(n+1):
  if a[i] > k:
    break
  while b[j] > k - a[i]:
    j -= 1
  ans = max(ans, i+j)
print(ans)

n, m, k = 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 i in range(m):
  B.append(b[i] + B[i])

ans, j = 0, m
for i in range(n+1):
  if A[i] > k:
    break
  while B[j] > k - A[i]:
    j -= 1
  ans = max(ans, i+j)
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it.  It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M).  Consider the following action:    * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk.  How many books can we read at most by repeating this action so that it takes us at most K minutes in total? We ignore the time it takes to do anything other than reading.

Submission attempts (in order):
from sys import stdin,stdout
def ss(s,a):
    nn=len(a)
    for i in range(nn):
        if a[i]>s:return i
    return nn
n,m,s=map(int, stdin.readline().split());M=10**9+2
dn=list(map(int, stdin.readline().split()))#+[M]
dm=list(map(int, stdin.readline().split()))#+[M]
pn=[dn[0]];pm=[dm[0]]
for v in dn[1:]:
    pn+=[pn[-1]+v]
for v in dm[1:]:
    pm+=[pm[-1]+v]
p=ss(s,pn)
q=ss(0 if p-1<0 else pn[p-1],pm)
pp=ss(s,pm)
qq=ss(0 if pp-1<0 else pm[pp-1],pn)
print(max(p+q,pp+qq))

'''cn=0;cm=0;cs=0
for v in dn:
    cs+=v
    if cn>=n-1 or cs>s:
        f=1;cs-=v
        for v1 in dm:
            cs+=v1
            if cs>s:
                f=0
                break
            cn+=1
        if f==0:break
    #print(v)
    cn+=1
cs=0
for v in dm:
    cs+=v
    if cm>=m-1 or cs>s:
        f=1;cs-=v
        for v1 in dn:
            cs+=v1
            if cs>s:
                f=0
                break
            cm+=1
        if f==0:break
    cm+=1
print(max(cn,cm))'''

from sys import stdin,stdout
import bisect as bs
n,m,s=map(int, stdin.readline().split())
dn=list(map(int, stdin.readline().split()))
dm=list(map(int, stdin.readline().split()))
pre=[dm[0]];s1=0
for v in dm[1:]:
    pre+=[pre[-1]+v]
m=bs.bisect_right(pre,s)
for i in range(n):
    s1+=dn[i]
    if s-s1>=0:m=max(m,i+1+bs.bisect_right(pre,s-s1))
print(m)


Verdicts: Wrong Answer

Accepted
Problem: We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it.  It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M).  Consider the following action:    * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk.  How many books can we read at most by repeating this action so that it takes us at most K minutes in total? We ignore the time it takes to do anything other than reading.

Submission attempts (in order):
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
assert len(A) == N
assert len(B) == M

import numpy as np
cumA = np.cumsum([0] + A)
cumB = np.cumsum([0] + B)
maximum = 0
for maxA,timeA in enumerate(cumA):
  if timeA > K:
     break
  timeB = K - timeA
  maxB = np.sum(timeA + cumB <= K)
  maximum = max(maximum, maxA + maxB)
print(maximum)

N , M, K = 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 i in range(M): b.append(b[i] + B[i])
ans,j=0,0
for i in range(N+1):
  if a[i]>K:
    break
  while b[j] <= K - a[i]:
    j += 1
  ans = max(ans, i+j)
print(ans)

N , M, K = 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 i in range(M): b.append(b[i] + B[i])
ans,j=0,0
for i in range(N+1):
  if a[i]>K:
    break
  while b[j] <= K - a[i]:
    j += 1
  ans = max(ans, i+j-1)
print(ans)

N , M, K = 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 i in range(M): b.append(b[i] + B[i])
ans,j=0,M
for i in range(N+1):
  if a[i]>K:
    break
  while b[j] > K - a[i]:
    j -= 1
  ans = max(ans, i+j)
print(ans)

Verdicts: Wrong Answer

Runtime Error

Runtime Error

Accepted
Problem: We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it.  It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M).  Consider the following action:    * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk.  How many books can we read at most by repeating this action so that it takes us at most K minutes in total? We ignore the time it takes to do anything other than reading.

Submission attempts (in order):
def main():
    N,M,K = map(int, input().split())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    
    indb = M-1
    now = sum(B)
    count = M
    while now > K:
        now -= B[indb]
        count -= 1
        indb -= 1
    
    ans = count
    
    for a in A:
        count += 1
        now += a
        
        while now >K and indb >= 0:
            now -= B[indb]
            count -= 1
            indb -= 1
        
        if now <= K:
            if ans < count:
                ans = count
    print(ans)
    

if __name __ == "__main__":
    main()

import bisect
import itertools
N,M,K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
k = 0
for i in range(M):
    index = bisect.bisect_left(A,B[i],k+1)
    A.insert(index, B[i])
    k = index
S = 0
if K>= sum(A):
    print(N+M)
else:
    for d, j in enumerate(A):
        S += j
        if S >=K:
            print(d)

from itertools import accumulate
from bisect import bisect_right

N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a = [0] + list(accumulate(A))
b = [0] + list(accumulate(B))

result = 0
for i in range(N + 1):
    if a[i] > K:
        break
    j = bisect_right(b, K - a[i])
    result = max(result, i + j - 1)
print(result)

Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it.  It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M).  Consider the following action:    * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk.  How many books can we read at most by repeating this action so that it takes us at most K minutes in total? We ignore the time it takes to do anything other than reading.

Submission attempts (in order):
import copy
N,M,K = map(int,input().split())
A = [0]*N
B = [0]*M
A = list(map(int,input().split()))
B = list(map(int,input().split()))
a = 0
b = 0

tmp = 0
ans = 0

#     if A[a] < B[b]:
#         if tmp <= K:
#             tmp += A[a]
#             ans += 1
#             a += 1
#     elif A[a] > B[b]:
#         if tmp <= K:
#             tmp += B[b]
#             ans += 1
#             b += 1
#     if a > len(A)-1 or b > len(B)-1:
#         break
fa = False
fb = False

while len(A) > 0 or len(B) > 0:
    AA = copy.copy(A)
    BB = copy.copy(B)
    if len(AA) != 0:
        a = AA.pop(0)
        fa = True
    if len(BB) != 0:
        b = BB.pop(0)
        fb = True
    if fa and fb:
        if a<=b:
            tmp += a
            ans += 1
            A = AA
        else:
            tmp += b
            ans += 1
            B = BB
    else:
        if fa:
            tmp += a
            ans += 1
            A = AA
        if fb:
            tmp += b
            ans += 1
            B = BB

    if tmp > K:
        break
    fa = False
    fb = False
    
    print(tmp,A,B)
    
if len(A)==0 and len(B)==0:
    print(ans)
else:
    print(ans-1)


N,M,K = map(int,input().split())
A = [0]*N
B = [0]*M
A = list(map(int,input().split()))
B = list(map(int,input().split()))

b = []
b.append(0)
tmp = 0
for i in range(M):
    b.append(tmp+B[i])
    tmp = tmp+B[i]
a = [0]
for i in range(N):
    a.append(a[i]+A[i])
#print(b)
ans,j = 0,M
for i in range(N+1):
    if a[i]>K:
        break
    while b[j] > K - a[i]:
        j -= 1
    ans = max(ans,i+j)

print(ans)


Verdicts: Runtime Error

Accepted
Problem: We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it.  It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M).  Consider the following action:    * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk.  How many books can we read at most by repeating this action so that it takes us at most K minutes in total? We ignore the time it takes to do anything other than reading.

Submission attempts (in order):
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))


t = 0

for i in range(m):
    t += b[i]


j = m
ans = 0

for i in range(n+1):
    
    while j > 0 and t > k:
        j -= 1
        t -= b[i]
    
    
    if t > k:
        break

    ans = max(ans, i+j)
    
    
    if i == n:
        break
    
    
    t += a[i]

print(ans)




N, M, K = 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 i in range(M):
    b.append(b[i] + B[i])

ans = 0

j = M

for i in range(N + 1):
    
    if a[i] > K:
        break

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


Verdicts: Runtime Error

Accepted
Problem: We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it.  It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M).  Consider the following action:    * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk.  How many books can we read at most by repeating this action so that it takes us at most K minutes in total? We ignore the time it takes to do anything other than reading.

Submission attempts (in order):
n, m, k = 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[i] + B[i])

ans, j = 0, m
for i in range(n + 1):
    if a[i] > k:
        break
    while b[j] > k - a[i]:
        j -= 1
    ans = max(ans, i + j)
print(ans)

n, m, k = 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 i in range(m):
    b.append(b[i] + B[i])

ans, j = 0, m
for i in range(n + 1):
    if a[i] > k:
        break
    while b[j] > k - a[i]:
        j -= 1
    ans = max(ans, i + j)
print(ans)

Verdicts: Runtime Error

Accepted
Problem: We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it.  It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M).  Consider the following action:    * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk.  How many books can we read at most by repeating this action so that it takes us at most K minutes in total? We ignore the time it takes to do anything other than reading.

Submission attempts (in order):
N, M, K = 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 i in range(M):
	b.append(b[i] + B[i])
 
ans, j = 0, M
for i in range(N + 1):
	if a[i] > K:
		break
	while b[j] > K - a[i]:
        j -= 1
        ans = max(ans, i + j)
print(ans)


N, M, K = 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 i in range(M):
	b.append(b[i] + B[i])

ans, j = 0, M
for i in range(N + 1):
	if a[i] > K:
		break
	while b[j] > K - a[i]:
	j -= 1
	ans = max(ans, i + j)
print(ans)

N, M, K = 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 i in range(M):
	b.append(b[i] + B[i])
 
ans, j = 0, M
for i in range(N + 1):
    if a[i] > K:
        break
    while b[j] > K - a[i]:
        j -= 1
    ans = max(ans, i + j)
print(ans)


Verdicts: Runtime Error

Runtime Error

Accepted
Problem: We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it.  It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M).  Consider the following action:    * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk.  How many books can we read at most by repeating this action so that it takes us at most K minutes in total? We ignore the time it takes to do anything other than reading.

Submission attempts (in order):
N, M, K = map(int, input().split())
times_a = list(map(int, input().split()))
times_b = list(map(int, input().split()))
read_time = 0
read_time_a = [0]
read_time_b = [0]
for i in range(len(times_a)):
    read_time_a.append(read_time_a[i]+times_a[i])
for i in range(len(times_b)):
    read_time_b.append(read_time_b[i]+times_b[i])
count = 0
for i in range(N+1):
    t = read_time_a[i]
    l = 0
    r = len(read_time_b)
    while l + 1 < r:
        c = (l + r) // 2
        if t + read_time_b[c] <= K:
            l = c
        else:
            r = c
    if read_time_a[i] + read_time_b[l] <= K:
        ans = max(ans, i + l)
print(ans)


N, M, K = map(int, input().split())
times_a = list(map(int, input().split()))
times_b = list(map(int, input().split()))
read_time = 0
read_time_a = [0]
read_time_b = [0]
for i in range(N):
    read_time_a.append(read_time_a[i]+times_a[i])
for i in range(M):
    read_time_b.append(read_time_b[i]+times_b[i])

ans = 0
for a_count in range(N+1):
    if read_time_a[a_count] > K:
        continue
    a_read_time = read_time_a[a_count]
    max_b_count = 0
    r = len(read_time_b)
    
    
    while max_b_count + 1 < r:
        c = (max_b_count + r) // 2
        
        if a_read_time + read_time_b[c] <= K:
            max_b_count = c
        
        else:
            r = c
    
    ans = max(ans, a_count + max_b_count)
print(ans)


Verdicts: Runtime Error

Accepted
Problem: We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it.  It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M).  Consider the following action:    * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk.  How many books can we read at most by repeating this action so that it takes us at most K minutes in total? We ignore the time it takes to do anything other than reading.

Submission attempts (in order):
alen,blen,k = map(int,input().split())
alist = list(map(int,input().split()))
blist = list(map(int,input().split()))
max = 0

bcount = blen
while sum(blist[:bcount]) > k:
    bcount -= 1

for a in range(alen+1):
    acount = alen-a
    asum = sum(alist[:acount])
    while asum + sum(blist[:bcount+1]) > k:
        bcount -= 1
    if acount + bcount > max and asum + sum(blist[:bcount])<=k:
        max = acount + bcount

print(max)


alen,blen,k = map(int,input().split())
alist = list(map(int,input().split()))
blist = list(map(int,input().split()))
max = 0

bcount = blen
while sum(blist[:bcount]) > k:
    bcount -= 1
if bcount != 0:
    bsum = sum(blist[:bcount])
for a in range(alen+1):
    acount = alen-a
    asum = sum(alist[:acount])
    if bcount != 0:
        while asum + bsum > k:
            bcount -= 1
            bsum -= blist[bcount-1]
    if acount + bcount > max and asum + sum(blist[:bcount])<=k:
        max = acount + bcount

print(max)


anum,bnum,acc = map(int,input().split())
alist = list(map(int,input().split()))
blist = list(map(int,input().split()))

asum = [0]
bsum = [0]
ans = 0
for i in range(anum):
    asum.append(asum[i]+alist[i])
for i in range(bnum):
    bsum.append(bsum[i]+blist[i])

b = bnum
for a in range(anum+1):
    if asum[a] > acc:
        break
    while asum[a] + bsum[b] > acc:
        b -=1
    ans = max(ans,a+b)

print(ans)


Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it.  It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M).  Consider the following action:    * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk.  How many books can we read at most by repeating this action so that it takes us at most K minutes in total? We ignore the time it takes to do anything other than reading.

Submission attempts (in order):
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
cnt=0

if k - min([a[0], b[0]]) < 0:
  print(0)
  exit()

while k>0:
  if a[0] < b[0]:
    k -= a.pop(0)
  elif a[0] > b[0]:
    k -= b.pop(0)
  else:
    if a[1] < b[1]:
      k -= a.pop(0)
    else:
      k -= b.pop(0)
  cnt += 1

print(cnt)

from itertools import zip_longest, count, accumulate
from bisect import bisect, bisect_left
 
def LIST(): return list(map(int, input().split()))
 
n, m, k = map(int, input().split())
a = [0] + list(accumulate(LIST()))
b = list(accumulate(LIST()))
 
num = 0
 
for i, a in enumerate(a):
    time_rest = k - a
    
    if time_rest < 0:
        continue
    
    num = max(num, i + bisect(b, time_rest))
 
print(num)


Verdicts: Runtime Error

Accepted
Problem: We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it.  It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M).  Consider the following action:    * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk.  How many books can we read at most by repeating this action so that it takes us at most K minutes in total? We ignore the time it takes to do anything other than reading.

Submission attempts (in order):

n,m,k = map(int,input().split())

a = list(map(int,input().split()))

b = list(map(int,input().split()))

x = [0]

y = [0]

for i in range(n):
    x.append(x[i]+a[i])

for i in range(m):
    y.append(y[i]+b[i])

ans = 0

cnt = m

for i in range(n+1):
    
    if x[i]<0:
        break
    
    while y[cnt]>k-x[i]:
        cnt -= 1
        
    ans = max(ans,cnt+i)
    
print(ans)

n,m,k = map(int,input().split())

a = list(map(int,input().split()))

b = list(map(int,input().split()))

x = [0]

y = [0]

for i in range(n):
    x.append(x[i]+a[i])

for i in range(m):
    y.append(y[i]+b[i])

ans = 0

cnt = m

for i in range(n+1):
    
    if k-x[i]<0:
        break
    
    while y[cnt]>k-x[i]:
        cnt -= 1
        
    ans = max(ans,cnt+i)
    
print(ans)

Verdicts: Runtime Error

Accepted
Problem: We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it.  It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M).  Consider the following action:    * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk.  How many books can we read at most by repeating this action so that it takes us at most K minutes in total? We ignore the time it takes to do anything other than reading.

Submission attempts (in order):
n,m,k = map(int, input().split())

A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]

ans = 0
ai = 0
bi = 0
t = 0
while t < k and (ai < len(A) or bi < len(B)):
  if ai < len(A) and bi < len(B):
    a = A[ai]
    b = B[bi]
    if a < b:
      ai += 1
      t += a
      if t =< k:
        ans += 1
    else:
      bi += 1
      t += b
      if t =< k:
        ans += 1
  elif ai < len(A):
    ai += 1
    t += A[ai]
    if t =< k:
      ans += 1
  else:
    bi += 1
    t += B[bi]
    if t =< k:
      ans += 1
print(ans)
    
    


n,m,k = map(int, input().split())

A = list(map(int, input().split()))
B = list(map(int, input().split()))

cum_a = []
cum_b = []
c = 0
for a in A:
  c += a
  cum_a.append(c)
c = 0
for b in B:
  c += b
  cum_b.append(b)
ans = 0
for i, a in enumerate(A):
  cnt = 0
  thresh = k-a
  for b in B:
    if b <= thresh:
      break
    cnt += 1
  cnt = len(B) - cnt
  if ans < cnt + i + 1:
    ans = cnt + i + 1
print(ans)
  

N, M, K = 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 i in range(M):
  b.append(b[i] + B[i])
ans, j = 0, M
for i in range(N + 1):
  if a[i] > K:
    break
  while b[j] > K - a[i]:
    j -= 1
  ans = max(ans, i + j)
print(ans)

Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it.  It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M).  Consider the following action:    * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk.  How many books can we read at most by repeating this action so that it takes us at most K minutes in total? We ignore the time it takes to do anything other than reading.

Submission attempts (in order):
# -*- coding: utf-8 -*-
from sys import stdin

# import numpy as np
from itertools import accumulate
from bisect import bisect_right

# import sys



def _li():
    return list(map(int, stdin.readline().split()))


def _li_():
    return list(map(lambda x: int(x) - 1, stdin.readline().split()))


def _lf():
    return list(map(float, stdin.readline().split()))


def _ls():
    return stdin.readline().split()


def _i():
    return int(stdin.readline())


def _f():
    return float(stdin.readline())


def _s():
    return stdin.readline()[:-1]


def search(cum1, cum2, iter_max, limit):
    ans = 0
    for i in range(iter_max):
        if cum1[i] > limit:
            break
        cand = bisect_right(cum2, limit - cum1[i])
        ans = max(i + 1 + cand, ans)
    return ans


N, M, K = _li()
A_list = _li()
B_list = _li()

cum_a = list(accumulate(A_list))
cum_b = list(accumulate(B_list))

if cum_a[0] < cum_b[0]:
    print(search(cum_a, cum_b, N))
else:
    print(search(cum_b, cum_a, M))


# -*- coding: utf-8 -*-
from sys import stdin

import numpy as np

# from itertools import accumulate
# from bisect import bisect_right

# import sys



def _li():
    return list(map(int, stdin.readline().split()))


def _li_():
    return list(map(lambda x: int(x) - 1, stdin.readline().split()))


def _lf():
    return list(map(float, stdin.readline().split()))


def _ls():
    return stdin.readline().split()


def _i():
    return int(stdin.readline())


def _f():
    return float(stdin.readline())


def _s():
    return stdin.readline()[:-1]


N, M, K = _li()
A_list = _li()
B_list = _li()



cum_a = np.cumsum([0] + A_list)
cum_b = np.cumsum(B_list)
#
# ans = 0
# for i, a in enumerate(cum_a):
#     if a > K:
#         cur = 0
#     else:
#         cur = i

#     ans = max(cur + cand, ans)
ans = 0
for i, a in enumerate(cum_a):
    if a > K:
        cur = 0
    else:
        cur = i
    cand = np.searchsorted(cum_b, K - a, side="right")
    ans = max(cur + cand, ans)

print(ans)


Verdicts: Runtime Error

Accepted
Problem: We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it.  It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M).  Consider the following action:    * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk.  How many books can we read at most by repeating this action so that it takes us at most K minutes in total? We ignore the time it takes to do anything other than reading.

Submission attempts (in order):
N, M, K = 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 i in range(M):
b.append(b[i] + B[i])

ans, j = 0, M
for i in range(N + 1):
a[i] > K:
break
while b[j] > K - a[i]:
j -= 1
ans = max(ans, i + j)
print(ans)

N, M, K = 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 i in range(M):
	b.append(b[i] + B[i])

ans, j = 0, M
for i in range(N + 1):
	a[i] > K:
		break
	while b[j] > K - a[i]:
		j -= 1
	ans = max(ans, i + j)
print(ans)

N, M, K = 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 i in range(M):
	b.append(b[i] + B[i])

ans, j = 0, M
for i in range(N + 1):
	if a[i] > K:
		break
	while b[j] > K - a[i]:
		j -= 1
	ans = max(ans, i + j)
print(ans)


Verdicts: Runtime Error

Runtime Error

Accepted
Problem: We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it.  It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M).  Consider the following action:    * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk.  How many books can we read at most by repeating this action so that it takes us at most K minutes in total? We ignore the time it takes to do anything other than reading.

Submission attempts (in order):


#include<algorithm>
#include<iomanip>
#include<utility>
#include<iomanip>
#include<map>

#include<cmath>
#include<cstdio>

#define rep(i,n) for(int i=0; i<(n); ++i)
#define pai 3.1415926535897932384

using namespace std;
using ll =long long;
using P = pair<int,int>;

#define MAX_N 200001
#define MAX_M 200001

int N, M;
int K = 0;
int res = 0;

int A[MAX_N];
int B[MAX_M];


int main(int argc, const char * argv[]) {

    cin >> N >> M >> K;
    
    rep(i, N){
        int a;
        cin >> a;
        if(i==0) A[i] = a;
        else A[i] = A[i-1] + a;
    }
    
    rep(i, M){
        int b;
        cin >> b;
        if(i==0) B[i] = b;
        else B[i] = B[i-1] + b;
    }
    
    int a=0;
    for(int i=0; i<N; i++){
        if(A[i]>K) continue;
        
        a=i+1;
    }
    int b=M;
    for(int j=M-1; j>=0; j--){
        if(B[j] <= K-A[a]){
            res = max(res, a+b);
            break;
        }
        b--;
    }
    
    cout << res << endl;
    
    return 0;
}


N, M, K = 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 i in range(M):
    b.append(b[i] + B[i])

ans, j = 0, M
for i in range(N + 1):
    if a[i] > K:
        break
while b[j] > K - a[i]:
    j -= 1
    ans = max(ans, i + j)
print(ans)

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

a_sum = [0]
for i in range(n):
    a_sum.append(a_sum[i] + a[i])

b_sum = [0]
for i in range(m):
    b_sum.append(b_sum[i] + b[i])
b_sum.append(10**20)
ans = 0

for i in range(n+1):
    t = a_sum[i]
    l = 0
    r = len(b_sum)
    
    while l+1<r:
        
        c = (l + r) // 2
        
        
        if t+b_sum[c]<=k:
            l = c
        
        
        else:
            r = c
    
    if a_sum[i]+b_sum[l]<=k:
        ans = max(ans,i+l)
print(ans)

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it.  It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M).  Consider the following action:    * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk.  How many books can we read at most by repeating this action so that it takes us at most K minutes in total? We ignore the time it takes to do anything other than reading.

Submission attempts (in order):
n, m, k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

ai = 0
bi = 0
ans = 0

for _ in range(n+m):
    if ai < n and bi < m:
        break
    if ai < n:
        a = A[ai]
    else: 
        a = 10e10
    if bi < m:
        b = B[bi]
    else:
        b = 10e10
    if a > b:
        k -= b
        bi += 1
    else:
        k -= a
        ai += 1
    if k < 0:
        break
    ans += 1


print(ans)

    

n, m, k = 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 i in range(m):
    b.append(b[i] + B[i])

ans, j = 0, m
for i in range(n + 1):
    if a[i] > k:
        break
    while b[j] > k - a[i]:
        j -= 1
    ans = max(ans, i + j)
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it.  It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M).  Consider the following action:    * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk.  How many books can we read at most by repeating this action so that it takes us at most K minutes in total? We ignore the time it takes to do anything other than reading.

Submission attempts (in order):
from itertools import accumulate

n, m, k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

A = [0] + A
A = list(accumulate(A))

B = [0] + B
B = list(accumulate(B))

ans = 0
b_cnt = m
for a_cnt in range(n+1):
    if a_cnt > k: continue

    while A[a_cnt]+B[b_cnt] > k:
        b_cnt -= 1
    ans = max(ans, a_cnt+b_cnt)

print(ans)

from itertools import accumulate

n, m, k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

A = [0] + A
A = list(accumulate(A))

B = [0] + B
B = list(accumulate(B))

ans = 0
b_cnt = m
for a_cnt in range(n+1):
    if A[a_cnt] > k: continue

    while A[a_cnt]+B[b_cnt] > k:
        b_cnt -= 1
    ans = max(ans, a_cnt+b_cnt)

print(ans)

Verdicts: Runtime Error

Accepted