peterverebics/CodeNet_Python_118 huggingface dataset:
n,m,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
cntA = 0
ans = 0
for i in range(n):
  if cntA+a[i] > k:
    break
  ans += 1
  cntA += a[i]
indA = ans-1
nc = indA+1
copyA = cntA+1
for j in range(indA+1):
  temp = 0
  adds = 0
  for v in b:
    adds += v
    if cntA + adds > k:
      break
    temp += 1
  cntA -= a[nc-1-j]
  ans = max(ans,indA+1+temp)
  indA -= 1
print(ans)
n,m,k=map(int,input().strip().split())

arr=list(map(int,input().strip().split()))
arr.extend(list(map(int,input().strip().split())))
arr.sort()
i=0
re=0
x=[]
while(k>0):
    if(k>=arr[i]):
        k-=arr[i]
        re+=1
        i+=1
    else:
        break
    
print(re)
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ans=0
while 1:
  if len(a)==0 and len(b)==0:
    break
  elif len(a)==0:
    read=b.pop(0)
  elif len(b)==0:
    read=a.pop(0)
  elif a[0]>b[0]:
    read=b.pop(0)
  else:
    read=a.pop(0)
  if read<=k:
    k-=read
    ans+=1
  else:
    break
print(ans)
n,m,k = map(int,input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

ac = 0
bc = 0
ans = 0
t = 0

while t<=k:
  if bc<=m-1 and ac <=n-1:
    if a[ac] > b[bc]:
      t += b[bc]
      bc +=1
    else:
      t+= a[ac]
      ac+=1
  elif ac >= n and bc<=m-1:
    t += b[bc]
    bc +=1
  elif bc == m and ac<=n-1:
    t+= a[ac]
    ac+=1
  ans+=1

if t>k:
  ans -=1

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

N = list()
M = list()
N.append(A[0])
for i in range(1, info[0]):
  N.append(N[i-1]+A[i])
M.append(B[0])
for i in range(1, info[1]):
  M.append(M[i-1]+B[i])

ans = 0
for i in range(info[0]-1, -1, -1):
  if N[i] > info[2]:
    continue
  for j in range(info[1]-1, -1, -1):
    if N[i]+M[j] <= info[2]:
      ans = max(ans, i+j+2)
      break
    
print(ans)
n, m, k = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = a + b
c = sorted(c)
d = [0]
res = 0

for i, elem in enumerate(c):
  d.append(d[i] + elem)
  if d[i + 1] <= k:
    res += 1
  else:
    break
print(res)
import numpy as np
from bisect import bisect_right

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

ac = np.cumsum(a)
bc = np.cumsum(b)
ans = 0

for i in range(n):
    if k < ac[i]:
        break
    time = k - ac[i]
    j = bisect_right(bc, time)
    ans = max(ans, j + i + 1)
print(ans)
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
import numpy as np
def main():
    n, m, k = map(int, input().split())
    a = np.array(readline().split(), np.int64)
    b = np.array(readline().split(), np.int64)
    aa = a.cumsum()
    ba = b.cumsum()
    r = np.searchsorted(ba, k)
    aaa = k - aa
    for i1, aaae in enumerate(aaa):
        if aaae > 0:
            r = max(r, np.searchsorted(ba, aaae) + i1 + 2)
    print(r)

if __name__ == '__main__':
    main()
def main():
    n, m, k = map(int,input().split())
    A = list(map(int,input().split()))
    B = list(map(int,input().split()))
    C = []
    for x in range(n+1):
        sumA = int(sum(A[0:x]))
        for y in range(m+1):
            sumB = int(sum(B[0:y]))
            if sumA + sumB < k:
                C.append(x+y)
    print(max(C))
main()
import itertools


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

a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]

p = range(1,n+m+1)
#print(list(p))
nmax = 0
for i in p:
  flag = False
  for j in range(i+1):
    x = j
    y = i-j
    sum_ = sum(a[:j]+b[:i-j])
    if sum_ <= k:
      flag = True
      nmax = i
      #print(sum_, i)
  if not flag:
    break
print(nmax)
n,m,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
count = 0
i = 0
j = 0
while k >= a[i] or k >= b[j]:
    read = min(a[i],b[j])
    if read == a[i]:
        i += 1
        count += 1
        k -= read
        if i == n:
            a.append(10**10)
    else:
        j += 1
        count += 1
        k -= read
        if j == m:
            b.append(10**10)
print(count)
from collections import deque
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
t=0
ans=0
aq=deque(a)
bq=deque(b)
aq.append(k*100)
bq.append(k*100)
while t<k and len(aq)!=0 and len(bq)!=0:
    ans+=1
    if aq[0]<=bq[0]:
        t+=aq.popleft()
    else:
        t+=bq.popleft()
if t>k:
    print(ans-1)
else:
    print(ans)
import numpy as np
param_list = np.array(input().split()).astype(int)
a_list = np.array(input().split()).astype(int)
b_list = np.array(input().split()).astype(int)
ans=0
for i in range(param_list[0]+1):
    for l in range(param_list[1]+1):
        a = sum(a_list[:i]) + sum(b_list[:l])
        b= 0
        if  a <= param_list[2]:
            if b <= i+l:
                b = i+l
            
print(b)
n,m,k=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
cnt=0
while cnt!=n+m:
  if len(B)==0:
    k-=A[0]
    del A[0]
    cnt+=1
  elif len(A)==0:
    k-=B[0]
    del B[0]
    cnt+=1
  elif A[0]<=B[0] and k>A[0]:
    k-=A[0]
    del A[0]
    cnt+=1
  elif B[0]<A[0] and k>B[0]:
    k-=B[0]
    del B[0]
    cnt+=1
  else:
    break
print(cnt)
from bisect import bisect_right

n, m, k = map(int, input().split())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
A = [0]
B = [0]
for i in range(n):
    A.append(A[-1] + a[i])
for j in range(m):
    B.append(B[-1] + b[j])
    
ans = 0
for i in range(n + 1):
    time = A[i]
    b_index = 0
    if time > k:
        break
    if k  - time > 0:
        b_index = bisect_right(B, k - time)
    ans = max(ans, i + b_index - 1)
print(ans)
n,m,k=map(int,input().split())
a=sorted(map(int,input().split()))
b=sorted(map(int,input().split()))[::-1]
x=sum(a)
z=n
ans=0
while a:
  while b and b[-1]+x<=k:
    c=b.pop()
    x+=c
    z+=1
  ans=max(ans,z)
  c=a.pop()
  x-=c
  z-=1
  if x>k:continue
  ans=max(ans,z)
print(ans)
from _collections import deque
n,m,k=map(int,input().split())
A=deque(list(map(int,input().split())))
B=deque(list(map(int,input().split())))

t=0
ans=0
while True:
    if (not A) and (not B):
        break
    elif not A:
        t+=B.popleft()
    elif not B:
        t+=A.popleft()
    else:
        if A[0]<B[0]:
            t+=A.popleft()
        else:
            t+=B.popleft()
    if t>k:
        break
    ans+=1
print(ans)
[N, M, K] = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]

c = 0

A.append(10**10)
A.reverse()
B.append(10**10)
B.reverse()

a = A.pop()
b = B.pop()

while True:
  if a < b:
    if K >= a:
      c += 1
      K -= a
      a = A.pop()
    else:
      break
  else:
    if K >= b:
      c += 1
      K -= b
      b = B.pop()
    else:
      break

print(c)
a = [input() for l in range(0,3)]
a1 = [int(p) for p in a[0].split()]
a2 = [int(p) for p in a[1].split()]
a3 = [int(p) for p in a[2].split()]
a4 = a2 + a3
b = sorted(a4)
s = 0
t = 0
while s <= a1[2] and t < len(b):
    s = s + b[t]
    t = t + 1
print(t-1)
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
x = a + b
x.sort()
sum = 0
for i in range(len(x)):
    sum += x[i]
    if sum > k:
        print(i)
        exit()

print(len(x))
N, M, K = [int(i) for i in input().split()]

A = [10**10] * 100000 + [int(i) for i in input().split()][::-1]
B = [10**10] * 100000 + [int(i) for i in input().split()][::-1]

t = 0
c = 0
while t < K:
    a, b = A[-1], B[-1]
    if min(a, b) <= (K-t):
        if a <= b:
            t += A.pop()
            c += 1
        else:
            t += B.pop()
            c += 1
    else:
        break
print(c)
import bisect
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
for i in range(1,N):
  A[i] += A[i-1]
for i in range(1,M):
  B[i] += B[i-1]
  
ans = 0
for i in range(N):
  K1 = K - A[i]
  if(K1 >= 0 and K1 < B[0]):
    ans = max(ans, i+1)
  elif(K1 >= 0):
    j = bisect.bisect_right(B, K1)
    ans = max(ans, i+j+1)
print(ans)
from collections import deque

n, m, k = map(int, input().split())
INF = 10**18
A = deque(list(map(int, input().split())) + [INF])
B = deque(list(map(int, input().split())) + [INF])
total = 0
cnt = 0
while True:
    if A[0] < B[0]:
        a = A.popleft()
        total += a
    else:
        b = B.popleft()
        total += b
    if total > k:
        break
    cnt += 1
print(cnt)
N,M,K = map(int, input().split())
A = map(int, input().split())
B = map(int, input().split())

sa = [0]
for i, val in enumerate(A):
  sa.append(sa[i] + val)

sb = [0]
for i, val in enumerate(B):
  sb.append(sb[i] + val)

max_num = 0
ind_max = M
for i in range(N+1):
  if(sa[i]>K):
    break
  for k in range(ind_max+1):
    if(sb[ind_max-k]<=K-sa[i]):
      break
    ind_max -= 1
  max_num = max(max_num,i+ind_max)

      
      
print(max_num)
N,M,K = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
A.append(10**9+7)
B.append(10**9+7)
ans = 0

while True:
    if A[0] >= B[0]:
        K = K- B[0]
        B = B[1:]
        ans +=1
    else:
        K = K-A[0]
        A = A[1:]
        ans +=1
    if K <0:
        break
print(ans-1)
n,m,k = map(int,input().split())
lsa = list(map(int,input().split()))
lsb = list(map(int,input().split()))
import numpy 
na = [e for e in numpy.cumsum(numpy.array(lsa)) if e <= k]
nb = [e for e in numpy.cumsum(numpy.array(lsb)) if e <= k]
mx = 0
for i in range(len(na)):
    for j in range(len(nb)):
        a = na[i]+nb[j]
        if a <= k:
            if i+j+2 > mx:
                mx = i+j+2
print(mx)
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
book = sorted(A + B)
#print(book)
count = 0
ans = 0
for bo in book:
    if count + bo <= K:
        #print(count)
        count += bo
        ans += 1
print(ans)
x = input().split()
y = input().split()
z = input().split()
s = 0
for nn in range(2000000):
    y.append(10000000001)
    z.append(10000000001)
for nn in range(2000000):
    if int(x[2]) < 0:
        break
    if int(y[0]) <= int(z[0]) :
        x[2] = int(x[2]) - int(y[0])
        del y[0]   
        s += 1
    else:
        x[2] = int(x[2]) - int(z[0])
        del z[0]
        s += 1
print(s-1)
a,c,v=map(int,input().split())
arr1=list(map(int,input().strip().split()))[:a]
arr2=list(map(int,input().strip().split()))[:c]
arr3=arr1+arr2
arr3.sort()
sum=0
ct=0
for x in range(0,(a+c)):
  sum=sum+arr3[x]
  ct+=1
  if(sum>=v):
    break
if(sum>v):
  print(ct-1)
else:
  print(ct)
import collections as cs

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

A.append(K + 1)
B.append(K + 1)

print(A)

count = 0
time = 0
num = len(A) + len(B)

for i in range(num):
    if A[0] <= B[0]:
        if A[0] + time <= K:
            time += A.popleft()
            count += 1

    elif A[0] > B[0]:
        if B[0] + time <= K:
            time += B.popleft()
            count += 1

print(count)
n,m,k,*x=map(int,open(0).read().split())
s=sum(x[:n])
z=i=j=n
while~i:
	while j<n+m and s+x[j]<=k:s+=x[j];j+=1;z=max(z,i+j)
	i-=1
	s-=x[i]
print(z-n)
n,m,k = list(map(int,input().split(" ")))
a = list(map(int,input().split(" ")))
b = list(map(int,input().split(" ")))
cnt = 0
ans = 0
j = m
t = sum(b)

for i in range(n+1):
    while j>0:
        if t>k:
            j -= 1
            t -= b[j]
            continue
        ans = max(ans,i+j)
        break
    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()))
for i in range(1,n):
    a[i] += a[i-1]
for i in range(1,m):
    b[i] += b[i-1]
a = [0]+a
b = [0]+b

ans = 0
ALL = 0
from bisect import bisect
for i in range(1,n+1):
    ALL = a[i]
    if ALL > k:
        continue
    else:
        idx = bisect(b,k-ALL)
        #print(i,ALL,idx)
    ans = max(ans,i+idx-1)
print(ans)
N,M,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

reading = 0
read_book = 0
i = 0
while reading < K:
  if i+1 <= N:
    reading += A[i]
    if reading <= K:
      read_book += 1
    else:
      break
  if i+1 <= M:
    reading += B[i]
    if reading <= K:
      read_book += 1
    else:
      break
  i += 1

print(read_book)
N,M,K = map(int,input().split())

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

sumA = sum(A)

ans = []
best = M

for i in range(N):
  sumB = sum(B)
  for j in range(best):
    S = sumA + sumB
    if S <= K:
      best = j
      ans.append(N+M-i-j)
      break
    sumB -= B[M-1-j]
  sumA -= A[N-1-i]
      
if ans == []:
  print(0)
else:
  print(max(ans))
import numpy as np
n,m,k = list(map(int, input().split()))
a_list = np.array(input().split()).astype(int)
b_list = np.array(input().split()).astype(int)
ans_list=[]
for i in range(n):
    for l in range(m):
        if sum(a_list[:i]) + sum(b_list[:l]) <= k:
            ans_list.append(i+l)
            

print(max(ans_list))
import numpy as np
N,M,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

A_np = np.array(A)
B_np = np.array(B)

C_np = np.append(A_np,B_np)
C_np = np.sort(C_np)
y=0
for i in range(len(C_np)):
    if K >= C_np[i]:
        K -= C_np[i]
        y += 1
    else:
        break
print(y)
n,m,k=list(map(int,input().split()))
A=list(map(int,input().split())) + [10**9+1]
B=list(map(int,input().split())) + [10**9+1]
time,ans = 0,0
a_idx,b_idx=0,0

while time <= k and (a_idx != n or b_idx != m):
  if A[a_idx] <= B[b_idx] and a_idx < n:
    time += A[a_idx]
    a_idx += 1
    ans += 1
  elif A[a_idx] > B[b_idx] and b_idx < m:
    time += B[b_idx]
    b_idx += 1
    ans += 1
    
if time > k:
  print(ans-1)
else:
  print(ans)
M, N, K = map(int, input().split())
A = map(int,input().split())
B = map(int,input().split())
C = list(A) + list(B)
H = 0
N = 0
if min(C) < K:
    while H < K:
        min_hour = min(C)
        H += min_hour
        if H <= K:
            N += 1
        C.remove(min_hour)
print(N)
n,m,k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

cnt = 0
ans = -1
while cnt <= k:
    ans += 1
    if len(a) == 0 and len(b) == 0:
        break
    elif len(a) == 0:
        cnt += b.pop(0)
    elif len(b) == 0:
        cnt += a.pop(0)
    else:
        if a[0] >= b[0]:
            cnt += b.pop(0)
        else:
            cnt += a.pop(0)
            
print(ans)
N,M,K = input().split()
A = input().split()
B = input().split()

cnt = 0

list = A + B
list = [int(s) for s in list]
list.sort()
ans = 0

for s in range(len(list)):
    if list[s] <= int(K)-ans:
        cnt += 1
        ans += list[s]

print(cnt)
N,M,K=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
 
sum = []
a,b = [0],[0]
ans = 0
 
for i in range(N):
  a.append(a[i]+A[i])
for i in range(M):
  b.append(b[i]+B[i])
  
for i in range(N+M+1):
  tmp = 0
  for j in range(i):
    if a[j]+b[i-j] < K:
      tmp = i+1
      ans = max(ans,i)
      break
  if tmp ==0:
    break

print(ans)
N, M, K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
Asum = [0]
Bsum = [0]
a = 0
b = 0
for i in range(N):
    a += A[i]
    Asum.append(a)
for i in range(M):
    b += B[i]
    Bsum.append(b)
Asum.append(0)
Bsum.append(0)
res, j = 0, 0
for i in range(N+1):
    if Asum[i] > K:
        break
    while Asum[i] + Bsum[j] > K:
            j += 1
    res = max(res,i+j)
print(res)
N,M,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
def sigma(func, frm, to):
    result = 0;
    for i in range(frm, to+1):
        result += func[i-1]
    return result

a=list()
for i in range(N):
    for j in range(M):
            if sigma(A,1,i)+sigma(B,1,j)<=K:
                a.append(i+j)
print(max(a))
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_left(b, time_rest))

print(num)
n, m, k = map(int, input().split())
a_list = list(map(int, input().split()))
b_list = list(map(int, input().split()))

ans = 0
ai = 0
bi = 0
t = 0
for i in range(n+m):
  if t > k:
    break
  if ai >= n:
    t += b_list[bi]
    bi += 1
    ans += 1
  elif bi >= m:
    t += a_list[ai]
    ai += 1
    ans += 1
  elif a_list[ai] > b_list[bi]:
    t += b_list[bi]
    bi += 1
    ans += 1
  else:
    t += a_list[ai]
    ai += 1
    ans += 1
if t <= k:
  print(ans)
else:
  print(ans-1)
n, m, k = map(int, input().split())
an = list(map(int, input().split()))
bn = list(map(int, input().split()))
ls = an[::-1] + bn
l = 0
r = 0
s = 0
ans = 0
while r < n + m:
    if s <= k:
        ans = max(ans, r - l)
        s += ls[r]
        r += 1
    else:
        s -= ls[l]
        l += 1
if s <= k:
    ans = max(ans, r-l)
print(ans)
N,M,K = map(int,input().split())

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

sumA = sum(A)

ans = []
print(A,B)

for i in range(N):
  sumB = 0
  sumB = sum(B)
  for j in range(M):
    S = sumA + sumB
    sumB -= B[M-1-j]
    if S > K:
      continue
    else:
      ans.append(N+M-i-j)
      break
  sumA -= A[N-1-i]
      
if ans == []:
  print(0)
else:
  print(max(ans))
n,m,k = map(int,input().split())
a_list = list(map(int,input().split()))
b_list = list(map(int,input().split()))
c_list = a_list + b_list
count = 0
time = 0
c_list.sort()
for i in range(n+m):
  if time + c_list[i] <= k:
    count += 1
    time += c_list[i]
    
print(count)
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

mmax = 0
pre = False
num = 0
ans = 0
ans2 = 0
for i in range(N+1):
  if i == 0:
    ans = 0
  else:
    ans += A[i-1]
  if ans > K:
    break
  for j in range(M+1):
    if j == 0:
      ans2 = ans
    else:
      ans2 += B[j-1]
    if ans2 > K:
      break
    else:
      mmax = max(mmax, i+j)
    print(i, j, ans2, mmax)

print(mmax)
from bisect import bisect_right

n, m, k = map(int, input().split())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
A = [0]
B = [0]
for i in range(n):
    A.append(A[-1] + a[i])
for j in range(m):
    B.append(B[-1] + b[j])
    
ans = 0
for i in range(n + 1):
    time = A[i]
    b_index = 0
    if time > k:
        continue
    if k  - time > 0:
        b_index = bisect_right(B, k - time)
    ans = max(ans, i + b_index - 1)
print(ans)
n,m,k = map(int, input().split())
an = list(map(int, input().split()))
bn = list(map(int, input().split()))
book = n + m
nokori = k
Ans = book
an.append(1000000000)
bn.append(1000000000)
for i in range(book):
    if an[0] <= bn[0]:
        nokori = nokori - an[0]
        del an[0]
    elif an[0] > bn[0]:
        nokori = nokori - bn[0]
        del bn[0]
    if nokori < 0:
        Ans = i
        break
print(Ans)
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a.extend(b)

time = 0
count = 0
for x in a:
  if time > k:
    count -= 1
    break
  time += x
  count += 1
print(count)
N, M, K = input().split()
N, M, K = map(int, (N, M, K))
a = input().split()
b = input().split()

def to_init(list):
    for i in range(len(list)):
        list[i] = int(list[i])
    return list

c = []
c = a + b
# print(c)
# change for int
to_init(c)
d = sorted(c)
minuite = 0
cnt_book = 0
for i in d:
    if minuite + i <= K:
        minuite += i
        cnt_book += 1
    else:
        break

print(cnt_book)
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

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


from itertools import accumulate
aacc = [0] + a
aacc = list(accumulate(aacc))
bacc = [0] + b
bacc = list(accumulate(bacc))

from bisect import bisect_right
ans = 0
for i, ac in enumerate(aacc):
    if k-ac>0:
        index = bisect_right(bacc, max(0,k-ac))
        ans = max(ans, i+index-1)

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

ac = 0
bc = 0
ans = 0
t = 0
while t<k:
  if bc<=m-1 and ac <=n-1:
    if a[ac] > b[bc]:
      t += b[bc]
      bc +=1
    else:
      t+= a[ac]
      ac+=1
  elif ac == n:
    t += b[bc]
    bc +=1
    print(t)
  elif bc == m:
    t+= a[ac]
    ac+=1
  else:
      break
  ans+=1

print(ans)
N ,M ,K = map(int, input().split())
#K = int(K/10)
#print(K)

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

m = 0

for i in range(1, N+1):
    total = A[:i]
    total = sum(total)
    if total > K:
        break
    mi = i
    for j in range(M):
        total += B[j]
        if total > K:
            break
        #print(total)
        mi += 1

    m = max(m, mi)


print(m)
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:
        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()))

s_a = [0]
s_b = [0]
for i in range(n):
    s_a.append(s_a[i] + a[i])
for i in range(m):
    s_b.append(s_b[i] + b[i])

ans = 0
ok = m
for i in range(n+1):
    for j in range(ok+1)[::-1]:
        if s_a[i] + s_b[j] <= k:
            ans = max(ans, i+j)
            tmp = j
    ok = tmp

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

max_n = 0

for i in range(n):
    for j in range(m):
        if sum(a[:i])+sum(b[:j]) > k:
            max_n =  max(i+j-1 ,max_n)
            print(i,j,sum(a[:i])+sum(b[:j]))
            break
            
print(max_n)
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
anss = []
for i in range(1, 1+N):
    if a[i] > K:
        break
    while 1:
        if a[i] + b[j] <= K:
            break
        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()))
c = a + b
ans = 0

c.sort()
#print(c)

for i in range(n+m):
    if k - c[i] >= 0:
        k -= c[i]
        ans += 1
    else:
        break
print(ans)
import numpy 
def main():
    N,M,K = map(int, input().split())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    cumsA = numpy.cumsum(A)
    cumsB = numpy.cumsum(B)
    ans = 0
    for i,ca in enumerate(cumsA):
        if ca<=K:
            b=numpy.sum(cumsB<=(K-ca))
            ans=i+1+b
    print(ans)

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

read = 0
count = 0

for i in range(len(a)+len(b)):
  if read <= k:
    if len(a) == 0:
      read += b.pop(0)
      count += 1
    elif len(b) == 0:
      read += a.pop(0)
      count += 1
    elif a[0] < b[0]:
      read += a.pop(0)
      count += 1
    else:
      read += b.pop(0)
      count += 1
  else:
    count -= 1
    break

print(count)
import bisect
n,m,k = map(int,input().split())
a= list(map(int,input().split()))
b= list(map(int,input().split()))
at=[0]
bt=[]
temp=0
for i in a:
    temp+=i
    at.append(temp)
temp=0
for i in b:
    temp+=i
    bt.append(temp)
ans=0
for i in range(len(at)):
    if at[1]>k and bt[0]>k:
        break
    ind= bisect.bisect_right(bt,k-at[i])
    ans= max(ans, ind+i)
print(ans)