peterverebics/CodeNet_Python_118 huggingface dataset:
import numpy as np

def main():
  n,m,k=map(int,input().split())
  a=list(map(int,input().split()))
  b=np.array(list(map(int,input().split())))
  b=np.cumsum(b)
  k0=k+1
  b0=np.searchsorted(b,k)
  r=b0
  i=0
  for i, ia in enumerate(a):
    k0=k0-ia
    if k0<0:
      break
    b0=np.searchsorted(b,k0)
    b0+=i+1
    if b0 > r:
      r=b0
  print(r)
main()
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
books = sorted(A + B)

ans = len(books)
for i, t in enumerate(books):
  if K < t:
    ans = i
    break
  K -= t
  
print(ans)
N, M, K = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = a + b
c.sort()
count = 0
t = 0
for i in range(len(c)):
  t += c[i]
  if t > K:
    print(i)
    exit()
print(len(c))
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()))
c = []
c = a + b
c.sort()
minuites = 0
cnt_book = 0
for min in c:
    if minuites + min <= K:
        minuites += min
        cnt_book += 1
    else:
        break
print(cnt_book)
n, m, k = input().split()
a = input().split()
b = input().split()

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

a.extend(b)
a.sort()

add = 0
cnt = 0
for item in a:
  if add > k:
    break
  add += item
  cnt += 1
print(cnt)
import bisect
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a = A[0]
b = B[0]
a_lis = [a]
b_lis = [b]
for i in range(1,N):
    a += A[i]
    a_lis.append(a)
for j in range(1,M):
    b += B[j]
    b_lis.append(b)
ans = 0
for i in range(N):
    j = bisect.bisect_right(b_lis,K-a_lis[i])
    tmp_ans = i + j + 1
    if ans < tmp_ans:
        ans = tmp_ans
print(ans)
from collections import deque
n, m, k = map(int, input().split())
a = deque(map(int, input().split()))
b = deque(map(int, input().split()))
t = 0
c = 0
while True:
    if len(a) == 0 and len(b) == 0:
        break
    if len(a) == 0:
        t += b.popleft()
    elif len(b) == 0:
        t += a.popleft()
    else:
        if a[0] >= b[0]:
            t += b.popleft()
        else:
            t += a.popleft()
    if t > k:
        break
    c += 1
print(c)
n,m,k = list(map(int,input().split()))
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = 0

while k >= 0:
  if len(a) != 0 and len(b) != 0:
    p = a.pop(0) if a[0] < b[0] else b.pop(0)
  elif len(a) == 0 and len(b) != 0:
    p = b.pop(0)
  elif len(a) != 0 and len(b) == 0:    
    p = a.pop(0)
  else:
    break;
  k -= p
  
  if  k >= 0:
    c += 1
  
print(c)
from collections import deque

N, M, K = [int(n) for n in input().split()]
desk_a = deque([int(n) for n in input().split()])
desk_b = deque([int(n) for n in input().split()])

print(2)
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
# k分以内
ans=a+b
ans.sort()
i=0
kotae=0
while True:
    if ans[i]+kotae>k:
        break
    else:
        kotae+=ans[i]
    i+=1
    if i>=len(ans):
        print(len(ans))
        quit()
print(i)
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

ans = 0
total = 0
idx = -1

for i in range(N):
  t = total + A[i]
  if t > K:
    break
  total = t
  ans += 1
  idx = i

for j in range(M):
  t = total + B[j]
  if t > K:
    # print(idx)
    for k in range(idx, -1, -1):
      t -= A[k]
      if t <= K:
        total = t
        ans -= (idx - k - 1)
        idx = k - 1
  else:
    total = t
    ans += 1

print(ans)
from collections import deque
n, m, k = map(int, input().split())
A = deque(map(int, input().split()))
B = deque(map(int, input().split()))

cnt = 0
while k >= 0:
    if not A:
        a = 10 ** 9
    else:
        a = A.popleft()
    if not B:
        b = 10 ** 9
    else:
        b = B.popleft()
    if a <= b:
        k -= a
        B.appendleft(b)
        cnt += 1
    else:
        k -= b
        A.appendleft(a)
        cnt += 1
print(cnt - 1)
from itertools import accumulate as ia 
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a = list(ia(A))
b = list(ia(B))
na = 0
nb = 0
for i in a:
  if i <= K:
    na += 1
  else:
    break
for i in b:
  if i <= K:
    nb += 1
  else:
    break
print(na, nb)
t = a[na-1]
for i in B:
  if t + i > K:
    break
  else:
    na += 1
    t += i
t = b[nb-1]
for i in A:
  if t + i > K:
    break
  else:
    nb += 1
    t += i
print(max(na, nb))
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
h, j = max(A), max(B)
fe = max(h,j)
c = 0
time = 0
num = N+M
while num > 0:
    if A[0] < B[0]:
        K -= A.pop(0)
    elif A[0] > B[0]:
        K -= B.pop(0)
    c += 1
    if len(A) == 0:
        A = A + [fe+1]
    if len(B) == 0:
        B = B + [fe+1]
    num -= 1
print(c)
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
t = 0
cnt = 0
i = 0
j = 0

while True:
  if i < N:
    a = A[i]
  else:
    a = 10 ** 10
  if j < M:
    b = B[j]
  else:
    b = 10 ** 10
  if t + a > K and t + b > K:
    break
  
  if a < b:
    t += a
    i += 1
  else:
    t += b
    j += 1
  cnt += 1
print(cnt)
N, M, K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
list = []
tmp = 0
count = 0
while len(A) != 0 and len(B) != 0:
  if A[0] < B[0]:
    list.append(A.pop(0))
  else:
    list.append(B.pop(0))
  if len(A) == 0:
    list.extend(B)
  elif len(B) == 0:
    list.extend(A)
while len(list) != 0:
  tmp += list.pop(0)
  if tmp > K:
    break
  count += 1
print(count)
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(1, N+1):
    for j in range(1, M+1):
        a = sum(A[:i])
        b = sum(B[:j])
        if a + b <= K:
            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()))
ans1=0
i=0
while i<N:
    ans1+=A[i]
    i=i+1
    if ans1>K :
        print(ans1)
        ans1=ans1-A[i-1]
        break
ans2=0
j=0
while j<M:
    ans2+=B[j]
    j=j+1
    if ans2>K :
        ans2=ans2-B[j-1]
        break
print(i+j)
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())))

point=0
while k>0:
    try:
        if len(A)!=0 and len(B)!=0:
            if A[0]>B[0]:k -=B.popleft()
            else:k -=A.popleft()
        elif len(A)==0:k -=B.popleft()
        elif len(B)==0:k -=A.popleft()

        if k>=0:point +=1
        else:break
    except:break
print(point)
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = 0

a.append(10 ** 9 + 1)
b.append(10 ** 9 + 1)

while True:
    if min(a[0], b[0]) > 10 ** 9 or min(a[0], b[0]) > k:
        break
    
    if a[0] <= b[0]:
        k -= a.pop(0)
        ans += 1
    else:
        k -= b.pop(0)
        ans += 1
print(ans)
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n,m,k = na()
a = na()
b = na()
c = a+b
c.sort()
tl = 0

for i in range(n+m):
    tl += c[i]
    if tl > k:
        print(i)
        exit()

print(n+m)
N,M,K=map(int, input().split())

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

books = sorted(A+B)

cnt=0
max = N+M-1

while K >= 0:

  K-=books[cnt]
  cnt+=1
  
  if cnt > max:
    cnt = N+M+1
    break
  
print(cnt-1)
a,b,c=map(int,input().split())
li_a=list(map(int,input().split()))
li_b=list(map(int,input().split()))
for i in li_b:
  li_a.append(i)
li_a.sort()
count=0
while c>0:

      
    c=c-li_a[count]
    if c<0:
      break
    count+=1
    
    
print(count)
from bisect import bisect_left

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

x = [0] * (N + 1)
y = [0] * (M + 1)
for i in range(N):
    x[i + 1] = x[i] + A[i]

for i in range(M):
    y[i + 1] = y[i] + B[i]

ans = 0
for i in range(N + 1):
    if x[i] > K:
        continue
    j = bisect_left(y, K - x[i])
    if j < M and y[j] != K - x[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()))

from itertools import accumulate
aa=list(accumulate(a))
bb=list(accumulate(b))

from bisect import bisect_left,bisect

kmax=0
for i in range(n):
    if k<aa[i]:
        break
    kk=k-aa[i]
    k2=min(bisect(bb,kk),m-1)
#    print(i,k2)
    kmax=max(kmax,k2+i+1)

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

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

t = 0
cnt = 0
while A and B and t <= K:
    if A[-1] < B[-1]:
        t += A.pop()
    else:
        t += B.pop()
    cnt += 1

if not A:
    A = B

while A and t <= K:
    t += A.pop()
    cnt += 1

print(cnt - (t > K))
N,M,K=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
cnt=0
T=K
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)
  last=K-read
  if(last>=0):
    K=last
    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()))
a.sort()
b.sort()
ans=0
i=0
j=0
while (k>=0 and i <max(n,m) and j<max(n,m)):
  temp=min(a[i],b[j]) if i<n and j<m else a[i] if i<n else b[j] 
  k-=temp
  if i<n and temp==a[i]:
      i+=1
  else:
      if j<m:
        j+=1
  
  if k>=0:
    ans+=1
 
print(ans)
N, M, K = map(int, input().split())
As = [int(i) for i in input().split()]
Bs = [int(i) for i in input().split()]
x = 0
i = 0
while x < K:
  if(As != [] and Bs != []):
    if(As[0] >= Bs[0]):
      x += Bs.pop(0)
      i += 1
    elif(As[0] < Bs[0]):
      x += As.pop(0)
      i += 1
  elif(As == []):
    x += Bs.pop(0)
    i += 1
  elif(Bs == []):
    x += As.pop(0)
    i += 1
print(i - 1)
n, m, k = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
total_time = 0
num = 0
i, j = 0, 0
while num < (n+m):
  if i == n and j < m:
    total_time = total_time + B[j]
    j += 1
  if j == m and i < n:
    total_time = total_time + A[i]
    i += 1
  if i < n and j < m:
    if A[i] <= B[j]:
      total_time = total_time + A[i]
      i += 1
    else:
      total_time = total_time + B[j]
      j += 1
  if total_time > k:
    break
  num += 1
print(num)
def resolve():
    N, M, K = map(int, input().split())
    A = list(map(int, input().split()))
    A += list(map(int, input().split()))
    A.sort(reverse=True)
    ans = 0
    time = 0
    while A:
        a = A.pop()
        if time+a > K:
            break
        time += a
        ans += 1
    print(ans)

if __name__ == "__main__":
    resolve()
N, M ,K = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
B = list(map(int,input().split()))
newList = []
z = 0
while True:
    if z < len(A):
        newList.append(A[z])
    if z < len(B):
        newList.append(B[z])
    z += 1
    if (z > len(A)) and (z > len(B)):
        break

while K >= 0:
    if newList[0] > K:
        break
    K = K - newList[0]
    newList.pop(0)
    if len(newList) == 0:
        break



print((N+M) - len(newList))
N, M, X = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
A.append(100000000000000000)
B.append(100000000000000000)
A.reverse()
B.reverse()


ans = 0
c = 0
while True:
  if A[-1] > B[-1]:
    b = B.pop()
    if ans+b > X:
      break
    ans += b
    c += 1
  else:
    a = A.pop()
    if ans+a > X:
      break
    ans += a
    c += 1
print(c)
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
a.append(10**9)
b.append(10**9)
# k分以内
ans=0
i=0
while True:
    if a[0]>b[0]:
        ans+=b.pop(0)
    else:
        ans+=a.pop(0)
        
    if ans>k:
        print(i)
        quit()
    i+=1
import sys
input = sys.stdin.readline
N,M,K= [int(x) for x in sys.stdin.readline().split()]

A = [int(x) for x in sys.stdin.readline().split()]

B = [int(x) for x in sys.stdin.readline().split()]

a = sorted(A + B)

# print(a)

time = 0
i = 0
ans = 0
while True:
    # print(i)
    if i == len(a):
        break
    if time + a[i] <= K:
        time += a[i]
        i += 1
        continue
    else:
        break
print(i)
# -*- coding: utf-8 -*-
n, m, k = map(int, input().split())

alist = input().split()
blist = input().split()

work = k
acount = 0
while (acount < n) and (work >= int(alist[acount])):
    work -= int(alist[acount])
    acount += 1

maxCount = acount
bCount = 0
for num in range(0, acount):
    if (num > 1):
        work += int(alist[acount-num])

    while (bCount < m) and (work >= int(blist[bCount])):
        work -= int(blist[bCount])
        bCount += 1
    maxCount = max(maxCount, acount-num+bCount)




print(maxCount)
A,B,Time=[int(x) for x in input().split()]
ArrayA=[int(x) for x in input().split()]+[10**10]
ArrayB=[int(x) for x in input().split()]+[10**10]
TotalTime=0
x,y=0,0
while TotalTime<=Time:
	if ArrayA[x]>ArrayB[y]:
		TotalTime+=ArrayB[y]
		y+=1
		#print(x,y)
		continue
	if ArrayA[x]<ArrayB[y]:
		TotalTime+=ArrayA[x]
		x+=1
		#print(x,y)
		continue
	if x+y==len(ArrayA)+len(ArrayB)-2:
		print(x+y)
		exit()
	if x+y==0:
		print("0")
		exit()
print(x+y-1)
N,M,K=map(int,input().split())
import numpy as np
a=np.array(list(map(int,input().split())))
b=np.array(list(map(int,input().split())))
a_s=a.cumsum()
b_s=b.cumsum()
an=0
ans=0
while an<N and a_s[an]<=K:
  bn=0
  while bn<M and a_s[an]+b_s[bn]<=K:
    bn+=1
  if an+bn+1>ans:
    ans=an+bn+1
  an+=1
print(ans)
N,M,K=map(int, input().split())
A=list(map(int, input().split()))
B=list(map(int, input().split()))

A_sum=[sum(A[:_+1]) for _ in range(len(A))]
B_sum=[sum(B[:_+1]) for _ in range(len(B))]

ans=0

for i in range(len(A_sum)):
	for h in range(len(B_sum)):
		if A_sum[i]+B_sum[h]>K and A_sum[i]+B_sum[h-1]<=K and h>0:
			ans=max(ans,i+1+h)

print(ans)
def main():
  M, N, K = map(int, input().split())
  A = list(map(int, input().split()))
  B = list(map(int, input().split()))
  spent_time = 0
  count = 0
  AB = A + B
  AB.sort()
  
  while(True):
    if count == M + N:
      break
    temp = AB[count]
    #print(temp, spent_time)
    if spent_time + temp > K:
      break
    spent_time = spent_time + temp
    count += 1
  
  #print('----')
  #print(spent_time)
  print(count)
  
main()
n,m,k=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
la=len(A)
lb=len(B)
ia=0
ib=0
c=10**10
ans=0
while(ia+ib<la+lb):
  a=A[ia] if ia<la else c
  b=B[ib] if ib<lb else c
  dk=min(a,b)
  if a>=b:
    ib+=1
  else:
    ia+=1
  if k>=dk:k-=dk
  else: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 = [0]
b = [0]
for i in range(n):
  a.append(a[i]+A[i])
for i in range(m):
  b.append(b[i]+B[i])
ans = -100
for i in range(n):
  if(a[i]>k):
    break
  for j in range(1,m):
    if(a[i]+b[(-1)*j]>k):
      break
    ans = max(ans,i+j)
print(ans)
from bisect import *

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

a_b=[0]
for i in range(1,n+1):
  a_b.append(a_b[i-1]+a[i-1])

b_b=[0]
for i in range(1,m+1):
  b_b.append(b_b[i-1]+b[i-1])

ans=0
for i in range(n+1):
  t_ans=i
  if t_ans>k:
    break
  t_ans+=bisect_right(b_b,k-a_b[i])-1
  ans=max(ans,t_ans)

print(ans)
n,m,k=map(int,input().split())
a=[0]+list(map(int,input().split()))
b=[0]+list(map(int,input().split()))
for i in range(n):
	a[i+1]+=a[i]
for i in range(m):
	b[i+1]+=b[i]
from bisect import bisect_right
ans=0
for i in range(n+1):
	if k-a[i]>0:
		r=bisect_right(b,k-a[i])
		ans=max(r+i-1,ans)
	else:
		break
print(ans)
N, M, K = map(int, input().split())
Ai = list(map(int, input().split()))
Bi = list(map(int, input().split()))
 
def p(x, k):
  y = []
  n = 0
  for v in x:
    n += v
    if n > k:
      break
    y.append(n)
  return y

As = p(Ai, K)
Bs = p(Bi, K)

n = 0
for i in range(len(As)):
  k = K - As[i]
  n = max(n, i+1)
  for j in range(len(Bs)):
    if Bs[j] > k:
      break
    n = max(n, i+j+2)
 
print(n)
n, m, k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

l = 0
r = n + m + 1
while r - l > 1:
  p = (l + r) // 2
  total = min(sum(A[:i]) + sum(B[:p - i]) for i in range(p))
  if total <= k:
    l = p
  else:
    r = p
print(l)
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
count = 0

for i in range(M+N):
  if A[0] <= B[0]:
    K = K - A[0]
    if K < 0:
      break
    count += 1
    A.pop(0)
    if not A:
      A.append(10**9)
  elif A[0] >= B[0]:
    K = K - B[0]
    if K < 0:
      break
    count += 1
    B.pop(0)
    if not B:
      B.append(10**9)

print(count)
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
s=0
t=0
i=n+m
while s==0:
    for j in range(n):
        if i-(j+1)<=m:
            t=sum(a[0:j])+sum(b[0:i-j])
        if 0<t<=k:
            s+=1
    i=i-1
    if i==-1:
        s+=1
print(i+1)
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]+a[i-1]
for i in range(1,m): b[i]=b[i]+b[i-1]
j=m-1
ans=0
for i in range(n):
    if j<0: break
    while a[i]+b[j]>k and j>=0: j-=1
    ans=max(i+j+2,ans)
print(ans)
import itertools
import bisect
N, M, K = map(int,input().split())
A = list(map(int, input().split())) 
B = list(map(int, input().split())) 

A_ = list(itertools.accumulate(A))
B_ = list(itertools.accumulate(B))

ans = 0
l = len(A_)

for idx, i in enumerate(A_):
  if i <= K:
          ans = max(idx+1 + bisect.bisect_right(B_, K-i), ans)
print(ans)
n, m, k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

a[0:0]=[0]
b[0: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()))
ans=0
for i in range(n+m+1):
  for a in range(i+1):
    b=i-a
    t=sum(A[:a])+sum(B[:b])
    if t>k:continue
    ans=max(ans,a+b)
print(ans)
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

calc_A = [0]
calc_B = [0]

for i in range(N):
    calc_A.append(calc_A[i] + A[i])

for j in range(M):
    calc_B.append(calc_B[j] + B[j])

ans = 0
j = M

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

print(ans)
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = -1
while k > 0:
  if len(a)==0:
    k -= b[0]
    del b[0]
  elif len(b)==0:
    k -= a[0]
    del a[0]
  elif a[0] < b[0]:
    k -= a[0]
    del a[0]
  else:
    k -= b[0]
    del b[0]
  ans += 1
if len(a)==0 and len(b)==0:
  ans += 1
print(ans)
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):
    if(sb[M-k]<=K-sa[i]):
      break
    ind_max -= 1
  
  max_num = max(max_num,i+M-k)

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

a.sort()
b.sort()

s,c = 0,0
if a[0] < k or b[0] < k:
    for i in range(m+n):
        if s < k and i < len(a):
            s += a[i]
            c += 1
        if s<k and i < len(b):
            s += b[i]
            c += 1
print(c)
n,m,k=map(int,input().split())
list_a=[]
list_b=[]

list_a=list(map(int,input().split()))
list_b=list(map(int,input().split()))

list_a.extend(list_b)

list_a.sort()

#ここまでは正常#

sum=0
count=0
for i in range(0,len(list_a)):
  if sum<=k and sum+list_a[i]<k:
    sum+=list_a[i]
    count+=1
  else:
    break

print(count)
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()))

A, B

INF = 1 << 30
A = [INF] + A[::-1]
B = [INF] + B[::-1]

n = 0
while True:
    if A[-1] > B[-1]:
        A, B = B, A
    x = A.pop()
    if K >= x:
        n += 1
        K -= x
    else:
        break

print(n)
from sys import stdin
from bisect import bisect
input = stdin.readline

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, a in enumerate(A):
    time = K - a
    if time < 0:
        continue
    cnt = i + 1
    cnt += bisect(B, time)
    ans = max(ans, cnt)

print(ans)
from collections import deque
n, m, k = map(int, input().split())
A = deque(map(int, input().split()))
B = deque(map(int, input().split()))

cnt = 0
while k >= 0:
    if not A:
        a = 10 ** 11
    else:
        a = A.popleft()
    if not B:
        b = 10 ** 11
    else:
        b = B.popleft()
    if a <= b:
        k -= a
        B.appendleft(b)
        cnt += 1
    else:
        k -= b
        A.appendleft(a)
        cnt += 1
print(cnt - 1)
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 = bisect.bisect_right(b, k)
li = list(range(I))
li = li[::-1]
for i in li:
    tmp = bisect.bisect_right(b, k-a[i])
    if a[i] + b[tmp-1] <= k:
        ans = max(ans, i+tmp+1)

print(ans)
from itertools import accumulate as ia 
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a = set(ia(A))
b = set(ia(B))
na = 0
nb = 0
ans = 0
for i in a:
  if i > K:
    break
  else:
    na += 1
    nb = 0
  for j in b:
    if i + j > K:
      break
    else:
      nb += 1
  ans = max(ans, na + nb)
if ans == 0:
  for i in b:
    if i <= K:
      ans += 1
print(ans)
import math
import sys
input=sys.stdin.readline
N,M,K=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
idA,idB=0,0
cnt,time=0,0
mx=10000000000
while(True):
  if(idA>=N and idB>=M):
    break
  if(idA==N):
    A.append(mx)
  if(idB==M):
    B.append((mx))
  if(time+min(A[idA],B[idB])>K):
    break
  elif(A[idA]<B[idB]):
    time+=A[idA]
    idA+=1
  else:
    time+=B[idB]
    idB+=1
  cnt+=1
print(cnt)
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

count = 0
ar = [0] * (N + 1)
br = [0] * (M + 1)

for i, v in enumerate(A):
    ar[i+1] = ar[i] + v

for i, v in enumerate(B):
    br[i+1] = br[i] + v

max_read = 0
j = M
for i in range(N+1):
    rest = K - ar[i]
    if rest <= 0:
        break
    while br[j] > K - ar[i]:
        j -= 1
    max_read = max(max_read, i+j)

print(max_read)
import itertools
import bisect

n,m,k=map(int,input().split())
a=[0]+list(map(int,input().split()))
b=list(map(int,input().split()))
aa=list(itertools.accumulate(a))
bb=list(itertools.accumulate(b))
r=0
for i,ax in enumerate(aa):
    bis=bisect.bisect_right(bb,k-ax)
    if bis==0:print(r);exit()
    r=max(r,i+bis)
print(r)