peterverebics/CodeNet_Python_118 huggingface dataset:
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)
for i in range(N+1):
  if a[i] > K:
    break
  j = 0
  while K - a[i] >= b[j]:
    if j >= M:
      break
    j = j+1
  j = 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()))

suma=[]
tmp=0
for aa in a:
    tmp+=aa
    suma.append(tmp)

sumb=[]
tmp=0
for bb in b:
    tmp+=bb
    sumb.append(tmp)

ans=0

for i in range(n):
    if suma[i]<=k:
        for j in range(m):
            if suma[i]+sumb[j]<=k:
                ans=max(ans,i+j+2)
            else:
                break
print(ans)
import numpy as np
n,m,k=map(int,input().split())
A=[0]+list(map(int, input().split()))
B=[0]+list(map(int, input().split()))
ans=0
a=np.cumsum(np.array(A)).tolist()
b=np.cumsum(np.array(B)).tolist()
for i in range(n+1):
    if k<a[i]:
        break
    j=m
    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()))
r=0
t=0
m_i=0
n_i=0
m+=-1
n+=-1
for i in range(m+n+2):
  #print(n_i)
  a_i=a[min(n_i,n)]
  b_i=b[min(m_i,m)]
  if ((a_i>b_i and m_i <=m) or (n_i > n)):
    m_i+=1
    t+=b_i
    #m_i=min(m_i,m)
  else:
    n_i+=1
    t+=a_i
    #n_i=min(n_i,n)
  if t>k:
    break
  r+=1
print(r)
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()))
INF=10**12
A.append(INF)
B.append(INF)
A=A[::-1]
B=B[::-1]
for i in range(N+M+1):
  if A[-1]<=B[-1]:
    if K<A[-1]:
      print(i)
      exit()
    K-=A[-1]
    del A[-1]
  else:
    if K<B[-1]:
      print(i)
      exit()
    K-=B[-1]
    del B[-1]
n, m, k = map(int, input().split())

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

c = []
         
while((len(a) != 0 or len(b) != 0)):
  if(len(a) == 0):
    c.append(b[0]);b.pop(0);continue
  if(len(b) == 0):
    c.append(a[0]);a.pop(0);continue
  
  if(a[0] > b[0]):
    c.append(b[0]);b.pop(0);continue
  else:
    c.append(a[0]);a.pop(0);continue

tmp = 0
ans = 0
for i in c:
  tmp += i
  if(tmp <= k):ans+=1
  else:print(ans);exit()
print(ans)
n,m,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
na = []
c = 0
for booka in a:
  c += booka
  na.append(c)
nb = []
d = 0
for bookb in b:
  d += bookb
  nb.append(d)
maxa = 0
for i in range(n-1,-1,-1):
  for j in range(m-1,-1,-1):
    if na[i] + nb[j] <= k:
      maxa = max(maxa,i+j+2)
      break
print(maxa)
M, N, K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

time = 0
ai = 0
bj = 0
am = 0
bm = 0

while time < K:
  if ai < len(A):
    am = A[ai]
  else:
    am = K
  if bj < len(B):
    bm = B[bj]
  else:
    bm = K

  if am < bm:
    if (time + am) > K:
      break
    else:
      time += am
      ai += 1
  else:
    if (time + bm) > K:
      break
    else:
      time += bm
      bj += 1

print(ai + bj)
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

max_num = 0
j = 0
j_max = M + 1
A_sums=[sum(A[:i]) for i in range(N+1)]
B_sums=[sum(B[:i]) for i in range(M+1)]

for i in range(N + 1):
    j = 0
    while j < j_max:
        print(i, j)
        if A_sums[i] + B_sums[j] > K:
            j_max = j
            break

        max_num = max(max_num, i + j)
        j += 1
print(max_num)
N,M,K = list(map(int,input().split()))
A = list(map(int,input().split()))
B = list(map(int,input().split()))

sumA = [0] * (N+1)
sumB = [0] * (M+1)
for i in range(N):
    sumA[i+1] = sumA[i] + A[i]
for i in range(M):
    sumB[i+1] = sumB[i] + B[i]

ans = 0
import bisect
for i in range(N+1):
    idx = bisect.bisect_left(sumB,K-sumA[i])
    ans = max(ans,i + idx - 1)
print(ans)
from collections import deque
n,m,k=[int(_) for _ in input().split()]
A=deque([int(_) for _ in input().split()])
B=deque([int(_) for _ in input().split()])
jikan=0
yomi=0
while (A or B):
    if A and B:
        if A[0]<B[0]:
            jikan+=A.popleft()
        else:
            jikan+=B.popleft()
    elif A:
        jikan+=A.popleft()
    else:
        jikan+=B.popleft()
    
    if jikan<=k:
        yomi+=1
    else:
        break
print(yomi)
import bisect

N, M, K = map(int, input().split())
Alist = [0] + list(map(int, input().split()))
Blist = list(map(int, input().split()))

B = [Blist[0]]
for b in Blist[1:]:
    B.append(b + Blist[-1])

sums = 0
ans = 0
for idx, a in enumerate(Alist):
    sums += a
    if sums > K:
        break
    k = K - sums
    tmp = bisect.bisect_left(B, k)
    ans = max(ans, idx + tmp)

print(ans)
from itertools import accumulate
import bisect
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
aa=list(accumulate(a))
b=list(map(int,input().split()))
bb=list(accumulate(b))
ans=0
for i in range(n):
    if aa[i]>k:
        break
    tmp=k-aa[i]
    t=bisect.bisect(bb,tmp)
    if i+1+t>ans:
        ans=i+t+1
print(ans)
import bisect
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

ar = [0]*N
br = [0]*M
ar[0] = A[0]
br[0] = B[0]

for i in range(1, N):
    ar[i] = ar[i-1]+A[i]
for i in range(1, M):
    br[i] = br[i-1]+B[i]

res = bisect.bisect_right(br, K)

for i in range(N):
    if ar[i] < K:
        res = max(i+bisect.bisect_right(br, K-ar[i])+1, res)

print(res)
n,m,k=map(int,input().split())
a=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]
c=[0]
for i in a:
    c+=[c[-1]+i]
d=[0]
for i in b:
    d+=[d[-1]+i]
ans=j=0
for i in range(m):
    if d[i]>k:
        ans=j=i-1


for i in range(n+1):
    while c[i]+d[j]>k and c[i]<k:
        j-=1
    if c[i]+d[j]<=k:    
        ans=max(ans,i+j)
print(ans)
n, m, k = map(int, input().split(' '))
a_list = list(map(int, input().split(' ')))
b_list = list(map(int, input().split(' ')))
a_sum = 0
b_sum = sum(b_list)

j = m-1
best=0
for i, a in enumerate(a_list):
  a_sum+=a
  if a_sum>k:
    break
  while ((a_sum + b_sum) > k) & (j>=0):
    b_sum-=b_list[j]
    j-=1
    
  best = max(best,i+j+2)
      
  
    
print(best)
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]

I = bisect.bisect_right(a, k)
ans = 0
li = list(range(I))
li = li[::-1]
for i in li:
    tmp = bisect.bisect_right(b, k-a[i])
    ans = max(ans, i+tmp+1)

print(ans)
N, M, K = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
res = 0
tmp = 0
A.extend(B)

for i in range(N + M):
    tmp += A[i]
    if tmp > K:
        break
    res += 1
print(res)
from collections import deque
N, M, K  = map(int, input().split())

A = deque([int(i) for i in input().split()])
B = deque([int(i) for i in input().split()])
ans = 0
while True:
    a = A[0] if len(A) else float('inf')
    b = B[0] if len(B) else float('inf')
    if a > b:
        if len(B): B.popleft()
        K -= b
    else:
        if len(A): A.popleft()
        K -= a
    if K < 0:
        break
    ans += 1
print(ans)
N, M, K = map(int,input().split()) 
arr = input() 
A= list(map(int,arr.split(' '))) 
i=0
la=len(A)
B= list(map(int,arr.split(' '))) 
lb=len(B)
for x in range(la):
    if(A[x]<K):
        K=K-A[0]
        i=i+1
    for y in range(lb):
    	if(B[y]<K):
        	K=K-B[0]
        	i=i+1
print(i)
n,m,k = map(int, input().split())

a_list = list(map(int, input().split()))
b_list = list(map(int, input().split()))

all_list = a_list + b_list
all_list.sort()

book_num = 0
time = 0

for book in all_list:
    time += book
    if time <= k:
        book_num += 1
    else:
        break
print(book_num)
#!/usr/bin/env python3

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

t = 0
ret = 0
while True:

    if len(A) == 0 and len(B) == 0:
        break
    elif len(A) == 0:
        t += B.pop(0)
    elif len(B) == 0:
        t += A.pop(0)
    elif A[0] > B[0]:
        t += B.pop(0)
    else:
        t += A.pop(0)

    ret += 1
    if t > K:
        ret -= 1
        break

print(ret)
def resolve():
    M, N, K = map(int, input().split())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))

    count = 0
    for m in range(1, M+1):
        for n in range(1, N+1):
            if (sum(a[:m] + b[:n]) <= K):
                count = max(count, m + n)
    print(count)

if __name__ == "__main__":
    resolve()
from itertools import accumulate
from bisect import bisect_right

R = lambda: map(int, input().split())
*_, k = R()
a = accumulate(R())
b = list(accumulate(R()))
r = 0
for i, x in enumerate(a, 1):
  if x > k:
    break
  j = bisect_right(b, k - x)
  r = max(r, i + j) 
print(r)
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
A += [10**10]
B += [10**10]

ans = 0
T = 0
a, b = 0, 0
while True:
    if A[a] <= B[b]:
        T += A[a]
        a += 1
    else:
        T += B[b]
        b += 1
    if T > K:
        break
    ans += 1
    
print(ans)
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

n,m,k=nm()
a=nl()
b=nl()

sm=0

ai=0
bi=0

cnt=0
for i in range(n+m):
  bk = 0
  if ai==n:
    bk = b[bi]
    bi+=1
  elif bi==m:
    bk = a[ai]
    ai+=1
  else:
    if a[ai] < b[bi]:
      bk = a[ai]
      ai+=1
    else:
      bk = b[bi]
      bi+=1

  if sm+bk > k:
    break
  sm+=bk
  cnt+=1

print(cnt)
# ABC C-Tsundoku
n,m,k = map(int,input().split())
an = list(map(int,input().split()))
bn = list(map(int,input().split()))

suma = [0]
sumb = [0]
a = 0
b = 0
for i in an:
    a += i
    suma.append(a)
for i in bn:
    b += i
    sumb.append(b)

res = [0]
l = m
for j in range(n+1):
    if k-suma[j] < 0:
        break
    while k-suma[j]-sumb[l] < 0 and l > 0:
        l -= 1
    res.append(j+l-1)
print(max(res))
n,m,k = map(int,input().split())
a = tuple(map(int,input().split()))
b = tuple(map(int,input().split()))

t = 0
i = 0
j = 0
while (t <= k):
  #print(i,j,t)
  if i < n:
    ai = a[i]
  else:
    ai = 10**10
  if j < m:
    bi = b[j]
  else:
    bi = 10**10
  if ai < bi:
    i += 1
    t += ai
  else:
    j += 1
    t += bi
if t <= k:
  print(n+m)
else:
  print(i+j-1)
#print(t,i,j)
N,M,K = map(int, input().split())
A=list(map(int, input().split()))
B=list(map(int, input().split()))
A.append(10**9+1)
B.append(10**9+1)
t=0
a=0
while t<=K:
  if A[0] < B[0]:
    t+=A[0]
    if t>K:
      print(a)
      exit()
    A.pop(0)
    a+=1
  elif A[0] >= B[0]:
    t+=B[0]
    if t>K:
      print(a)
      exit()
    B.pop(0)
    a+=1
N,M,K=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
cnt=0
T=K+1
while(K>0):
  if(A[0]<B[0]):
    read=A[0]
    del A[0]
    A.append(T)
  else:
    read=B[0]
    del B[0]
    B.append(T)
  if(K>=read):
    K-=read
    cnt+=1
  else:
    break
print(cnt)
n,m,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
i,j = 0,0
a.append(k+1)
b.append(k+1)
ans = 0
flag = 1
while flag:
    if a[i] <= b[j] and a[i] <= k:
        k -= a[i]
        i += 1
        ans += 1
    elif a[i] > b[j] and b[j] <= k:
        k -= b[j]
        j += 1
        ans += 1
    else:
        flag = 0
print(ans)
# -*- coding: utf-8 -*-


def main():
    from bisect import bisect
    from itertools import accumulate

    import sys
    input = sys.stdin.readline

    n, m, k = map(int, input().split())
    a = list(accumulate([0] + list(map(int, input().split()))))
    b = list(accumulate([0] + list(map(int, input().split()))))

    i1 = bisect(a, k) - 1
    j1 = bisect(b, max(0, k - a[i1])) - 1
    i2 = bisect(b, k) - 1
    j2 = bisect(a, max(0, k - b[i2])) - 1

    print(max(i1 + j1, i2 + j2))


if __name__ == '__main__':
    main()
import bisect
N,M,K=map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
A=[0]*N
A[0]=a[0]
ans=0
for i in range(N-1):
 A[i+1]=A[i]+a[i+1]
B=[0]*M
B[0]=b[0]
for i in range(M-1):
 B[i+1]=B[i]+b[i+1]
a=[1,2,2,2,3]
for i in range(N):
 if A[i]<K:
  ans=max(bisect.bisect_right(B,K-A[i])+i+1,ans)
ans=max(bisect.bisect_right(B,K),ans)
print(ans)
n,m,k=map(int,input().split())
a=list(map(int,input().split()))+[k+1]
b=list(map(int,input().split()))+[k+1]
ans=0
while k>=a[0] or k>=b[0] :
    if a[0]<=b[0]:
        k-=a[0]
        a.pop(0)
    else:
        k-=b[0]
        b.pop(0)
    ans+=1
print(ans)
N ,M ,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
result = -1

A.append(10**10)
B.append(10**10)
i,j = 0,0
while K >= 0:
    K -= min(A[i],B[j])
    if A[i] <= B[j]:
        i += 1
    else:
        j += 1
    result += 1
print(result)
R = lambda: map(int, input().split())
*_, k = R()
k += 1
a = R(), R()
x = [next(y) for y in a]
m = min(x)
r = 0
while m < k:
  r += 1
  i = x.index(m)
  x[i] = next(a[i], k)
  k -= m
  m = min(x)
print(r)
N, M, K = map(int, input().split())
As = input().split()
Bs = input().split()

time = 0
cnt = 0
while True:
  A, B = int(As[0]) , int(Bs[0])
  if A<B:
    if time + A > K:
      break
    time+=A
    del As[0]
    if As == []:
      As.append(10**10)
  else:
    if time + B > K:
      break
    time+=B
    del Bs[0]
    if Bs == []:
      Bs.append(10**10)
  cnt+=1
print(cnt)
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

A.reverse()
B.reverse()

count = 0
time = 0

while count < K and time < N + M:
    try:
        if A[-1] <= B[-1]:
            count += A.pop()
        else:
            count += B.pop()
    
    except:
        if A:
            count += A.pop()
        else:
            count += B.pop()
    
    time += 1
   
if count > K:
  time -= 1

print(time)
from collections import deque
N,M,K=list(map(int,input().split()))
a_list = list(map(int,input().split()))
b_list = list(map(int,input().split()))
a = deque(a_list)
b = deque(b_list)

book = 0
k = 0
while len(a) > 0 or len(b) > 0:
  if len(a) == 0:
    k += b.popleft()
  elif len(b) == 0:
    k += a.popleft()
  elif a[0]<b[0]:
    k += a.popleft()
  else:
    k += b.popleft()
  if k<=K:
    book+=1
  else:
    break
print(book)
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

total = 0
cur = 0
len_A = len(A)
len_B = len(B)
i = 0
j = 0
while True:
  a_i = A[i] if i < len_A else 1e10
  b_j = B[j] if j < len_B else 1e10
  if a_i < b_j:
    cur += a_i
    i += 1
  else:
    cur += b_j
    j += 1
  if cur > K:
    break
  total += 1
  if i >= len_A and j >= len_B:
    break
    
print(total)
n,m,sus = map(int,input().split()); ans,l,r,ct = 0,0,0,0
A,B = list(map(int,input().split())),list(map(int,input().split()))
while ans < sus:
  if min(A[l],B[r]) == A[l]:
    if ans + A[l] > sus : break
    ans += A[l]; A[l] = 2e10; l = (l+1)%n; ct +=1
  else: 
    if ans + B[r] > sus : break
    ans += B[r]; B[r] = 2e10; r = (r+1)%m; ct += 1
print(ct)
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))

a.append(10**10)
b.append(10**10)

i,j,ans=0,0,0
while k>=0:
    if a[i]>b[j]:
        k-=b[j]
        j+=1
    else:
        k-=a[i]
        i+=1
    ans+=1

print(ans-1)
N,M,K = map(int,input().split())
Ali = list(map(int,input().split()))
Bli = list(map(int,input().split()))

ans=0

if (sum(Ali)+sum(Bli))==K: 
    print(N+M)
    exit()
if (sum(Ali)+sum(Bli))>K:
    print(0)
    exit()
while K>0 or (Ali!=[] and Bli!=[]) :

    if Ali[0]<Bli[0] and Ali != []:
        a=Ali.pop(0)
    elif Bli!=[]:
        a=Bli.pop(0)
    K -= a
    ans+=1

print(ans-1)
import sys
readline = sys.stdin.readline

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

for i in range(1, len(A)):
  A[i] = A[i] + A[i - 1]
  
for i in range(1, len(B)):
  B[i] = B[i] + B[i - 1]
  
#print(A)
#print(B)
import bisect
ans = 0
for i in range(len(A)):
  rest = K - A[i]
  # あとrest分大丈夫
  ind = bisect.bisect_left(B, rest)
  if ind != 0:
    if (i + 1) + (ind) > ans:
      ans = (i + 1) + (ind)

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

a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = 0


for i in range(n):
    cnt = sum(a[:i + 1])
    if cnt > k:
        ans = max(ans, i)
        break
    for j in range(m):
        cnt += b[j]
        if cnt > k:
            ans = max(ans, i + 1 + j)
            break
    else:
        ans = max(ans, i + j + 2)
print(ans)
n,m,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
a.append(float('inf'))
b.append(float('inf'))
at = 0
bt = 0
time = 0
cnt = 0

while time+a[at]<=k or time+b[bt]<=k:
    if a[at] <= b[bt]:
        time += a[at]
        at += 1
        cnt += 1
    elif a[at] > b[bt]:
        time += b[bt]
        bt += 1
        cnt += 1

print(cnt)
N,M,K=map(int,input().split())
costA=list(map(int,input().split()))
costB=list(map(int,input().split()))
time=0
count=0
cost=sorted(costA+costB)
while time<=K:
    time+=cost[0]
    count+=1
    del cost[0]
    if len(cost)==0:
        break
print(count-1)
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())))

cnt=0

while k>0:
  if len(A)==0:
    A.append(9999999999999999999999999999999999)
  if len(B)==0:
    B.append(9999999999999999999999999999999999)
    
  if A[0]<=B[0] and A[0]<=k:
    k=k-A.popleft()
    cnt+=1
  elif A[0]>=B[0] and B[0]<=k:
    k=k-B.popleft()
    cnt+=1
  else:
    break

print(cnt)
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):
  if M!=0:
    for j in reversed(range(M)):
      if K-A[i]>=B[j]:
        if c<i+j+2:
          c=i+j+2
        M=j+1
        break
  elif K-A[i]>=0 and c<i+1:
    c=i+1
    M=0
print(c)
import bisect
n,m,k=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
RA=[0]*(n+1)
RB=[0]*(m+1)
for i in range(n):
    RA[i+1]=RA[i]+A[i]
for i in range(m):
    RB[i+1]=RB[i]+B[i]
#print(RA)
#print(RB)

r=0
for i in range(n+1):
    a=RA[i]
    if k-a>0:
        j=bisect.bisect_right(RB,k-a)
        r=max(r,i+j-1)
        #print(i,k-a,j)
print(r)
import numpy as np

N, M, K = list(map(int, input().split()))
As = list(map(int, input().split()))
Bs = list(map(int, input().split()))

As.append(np.inf)
Bs.append(np.inf)

count = 0
while K >= min(As[0], Bs[0]):
    if As[0] <= Bs[0]:
        t = As.pop(0)
    else:
        t = Bs.pop(0)
    K -= t
    count += 1

print(count)
x = input().split()
N = int(x[0])
M = int(x[1])
K = int(x[2])
C =[]
A = input().split()
B = input().split()
A.append(10000000000)
B.append(10000000000)
for i in range(N + M):
    if int(A[0]) <= int(B[0]):
        C.append(int(A[0]))
        del A[0]
    else:
        C.append(int(B[0]))
        del B[0]

T = 0
book = 0
for i in range(len(C)):
    if T +C[i] <= K:
        T += C[i]
        book += 1
    else:
        break
print(book)
l = input()
l = l.split()
n,m,k = l[0], l[1], int(l[2])
a = input().split()
b = input().split()

total = a+b
ans = 0

for i in range(int(n)+int(m)):
    total[i] = int(total[i])

total = sorted(total)

for i in total:
    if k - i >= 0:
        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()))
a.extend(b)

time = 0
count = 0
if a[0] > k:
  print(count)
else:
  for x in a:
    if time > k:
      break
    time += x
    count += 1
  print(count)
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
count = 0
sort_array = b + c
sort_array.sort()

num = a[2]

#print(sort_array)
for i in range(0,len(sort_array)):
    if num >= sort_array[i]:
        num -= sort_array[i]
    if num >= 0:
        count += 1


print(count)
import bisect
from collections import deque

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

x = deque()
x.append(0)
for i in range(n + m):
    num = 0
    if len(a) == 0:
        num = b.popleft()
    elif len(b) == 0:
        num = a.popleft()
    elif a[0] <= b[0]:
        num = a.popleft()
    else:
        num = b.popleft()
    x.append(num + x[-1])

x.popleft()

pos = bisect.bisect_right(x, k)
print(pos)
n, m, k = map(int, input().split(' '))
a_list = list(map(int, input().split(' ')))
b_list = list(map(int, input().split(' ')))
sa = [0] * (n+1)
sb = [0] * (m+1)

for i in range(n):
  sa[i+1] = a_list[i] + sa[i]
for j in range(m):
  sb[j+1] = b_list[j] + sb[j]

best=0
r = m
for a in a_list:
  if a>k:
    break
  while ((a + sb[r]) > k) & (r>=0):
    r-=1
    
  best = max(best,i+j+2)
      
  
    
print(best)
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(0, N):
    a.append(a[i] + A[i])
for j in range(0, M):
    b.append(b[j] + B[j])

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

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

INF = 1 << 60
A.append(INF)
B.append(INF)

p, q = 0, 0
while True:
    if A[p] > B[q]:
        A, B = B, A
        p, q = q, p
    x = A[p]
    p += 1
    if K >= x:
        K -= x
    else:
        break

print(p + q - 1)
N,M,K=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
time=0
a,b=0,0

if K>=sum(A)+sum(B):
  print(N+M)
else:
  A.append(1000000000000000)
  B.append(1000000000000000)
  while time<=K:
    if A[a]<=B[b]:
      time+=A[a]
      #print(f"A{A[a]}")
      a+=1
    else:
      time+=B[b]
      #print(f"B{B[b]}")
      b+=1
  print(a+b-1)
import numpy as np
n,m,k = map(int,input().split())
a = np.array([int(i) for i in input().split()], dtype='int64')
b = np.array([int(i) for i in input().split()], dtype='int64')

a_c = np.cumsum(a)
b_c = np.cumsum(b)

a_c = a_c[a_c <= k]
b_c = b_c[b_c <= k]
ans = 0
for i,ai in enumerate(a_c):
    n = np.searchsorted(b_c, k - ai, side = 'right')
    ans = max(i+1 + n, ans)
    
print(ans)
import sys
sys.setrecursionlimit(10**6)
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
A.append(99999)
B.append(99999)
Sum = 0
i = 0
j = 0
while Sum < K:
  if A[i] <= B[j]:
    Sum += A[i]
    i += 1
  else:
    Sum += B[j]
    j += 1
if Sum >= 1000000000:
  print(0)
else:
  print(i + j)
n=list(map(int,input().split()))
m=list(map(int,input().split()))
t=list(map(int,input().split()))

li=m+t
i=0
count=0

while i< len(li):
  if li[i] + count <= n[2]:
    count +=1
  i+=1



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


count=0
count_min=0
value=0
for item in a_list :
  value+=item
  count+=1
  current=count

  cure_value=value
  for item2 in b_list :
    if cure_value+item2<=k :
      current+=1
      cure_value+=item2
  count_min=max(count_min,current)


print(count_min)