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()))
sa = [0]
sb = [0]
for i in range(n):
  sa.append(sa[i]+a[i])
for i in range(m):
  sb.append(sb[i]+b[i])
maxn = 0
j = m
for i in range(n+1):
  if sa[i] <= k:
    while sa[i] + sb[j] > k:
      j -= 1
    maxn = max(maxn,i+j)
print(maxn)
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 j in range(M):
    b.append(b[j] + B[j])

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

lia = [0]
lib = [0]
j = M
ans = 0

for i in range(N):
    lia.append(lia[i]+A[i])
for i in range(M):
    lib.append(lib[i]+B[i])

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

    while lib[j] > K-lia[i]:
        j -= 1
    ans = max(ans, i+j)

print(ans)
import bisect

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 += [a[i] + A[i]]
for i in range(M):
    b += [b[i] + B[i]]

ans = 0
for i in range(N+1):
    if a[i] <= K:
        ans = max(ans, i + bisect.bisect_right(b, K - a[i])-1)

print(ans)
import numpy as np
from bisect import bisect_right

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

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

# print(ac)
# print(bc)

for i in range(n+1):
    if k < ac[i]:
        break
    time = k - ac[i]
    j = bisect_right(bc, time)
    ans = max(ans, j + i)

print(ans)
from itertools import accumulate

N, M, K = map(int, input().split())
A = list(accumulate(int(i) for i in input().split()))
B = list(accumulate(int(i) for i in input().split()))

a,b = [0],[0]
for ai in A:
    a.append(ai)
for bj in B:
    b.append(bj)

cnt = 0
best0 = M
for i in range(N+1):
   ai = a[i]
   for j in range(best0, -1, -1):
       bj = b[j]
       if ai + bj <= K:
           cnt = max(cnt, i + j)
           best0 = j
           break

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

p, q = [0], [0]
for i in range(n):
	p.append(p[i] + a[i])
for i in range(m):
	q.append(q[i] + b[i])

j, ans = m, 0
for i in range(n+1):
	if p[i] > k:
		break

	while q[j] > k - p[i]:
		j -= 1

	ans = max(ans, i+j)

print(ans)
# C - Tsundoku

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

Asum = [0]
for i in range(N):
    Asum.append(Asum[i] + A[i])

Bsum = [0]
for j in range(M):
    Bsum.append(Bsum[j] + B[j])

ans = 0
for i in range(N+1):
    if Asum[i] > K:
        continue
    tmp = K - Asum[i]
    j = bisect.bisect_right(Bsum, tmp) - 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 a[i] + b[j] > K:
        j -= 1
    ans = max(ans, i + j)
print(ans)
import bisect
n,m,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
sa,sb = [0],[0]
ans = 0
for i in range(n):
    sa.append(sa[i]+a[i])
for i in range(m):
    sb.append(sb[i]+b[i])


for i in range(n+1):
    sai = sa[i]
    x = k-sai
    if x>=0:
        ans = max(ans,bisect.bisect_right(sb,x)-1+i)
print(ans)
# -*- coding: utf-8 -*-
# 標準入力を取得
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, 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)
import itertools

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

sumA = list(itertools.accumulate(A))
sumB = list(itertools.accumulate(B))
j=M-1
while K<sumB[j] and j>=0:
    j-=1
ans=j+1
for i in range(N):
    if sumA[i]>K:
        break
    while K<sumA[i]+sumB[j] and j>=0:
        j-=1
    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, 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)
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()))

from itertools import accumulate
import bisect

SA=[0]+list(accumulate(A))
SB=[0]+list(accumulate(B))

ANS=0
for i in range(N+1):
    if K-SA[i]<0:
        break
    x=bisect.bisect_right(SB,K-SA[i])
    ANS=max(ANS,i+x-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)
n,m,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
t = sum(b)
ans = 0
j = m

for i in range(n+1):
    while j > 0 and t>k:
        j -= 1
        t -= b[j]
    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()))
ans = 0
a_list = [0]
b_list = [0]
for i in range(n):
    a_list.append(a[i] + a_list[i])
for i in range(m):
    b_list.append(b[i] + b_list[i])

ans = 0
num = m
for i in range(n+1):
    if a_list[i] > k:
        break
    while b_list[num] > k - a_list[i]:
        num -= 1
    ans = max(ans,i + num)
print(ans)
n,m,k = list(map(int,input().split()))
a = list(map(int,input().split()))
b = list(map(int,input().split()))
 
import numpy as np
a = [0] + a
b = [0] + b
sa = np.cumsum(a)
sb = np.cumsum(b)
ans = 0
r = m
for i in range(n+1):
  if sa[i] > k:
    break
  while sa[i] + sb[r] > k:
    r -= 1
  ans = max(ans, i+r)

print(ans)
n,m,k=map(int,raw_input().split())
a=map(int,raw_input().split())
b=map(int,raw_input().split())
cnt1=0
cnt2=0
a1=[0]
b1=[0]
for i in range(n):
    a1.append(a1[-1]+a[i])
for i in range(m):
    b1.append(b1[-1]+b[i])
ans=0
j=m
for i in range(n+1):
    if a1[i]>k:
        break
    while b1[j]>k-a1[i]:
        j-=1
    ans=max(ans,i+j)
print ans
from itertools import accumulate
n,m,k = map(int,input().split())
deskA = list(map(int,input().split()))
deskB = list(map(int,input().split()))
cumA = list(accumulate(deskA))
cumB = list(accumulate(deskB))
cumA = [0] + cumA
cumB = [0] + cumB
ans = 0
l = m
for i in range(n+1):
    tmp = k - cumA[i]
    if tmp<0:
        continue
    j = l
    tmp -= cumB[j]
    while tmp < 0:
        tmp += cumB[j]
        j -= 1
        tmp -= cumB[j]
    l = j
    ans = max(i+j,ans)
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 j in range(M):
    b.append(b[j] + B[j])

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

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)
from bisect import bisect
from numpy import cumsum
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
a=cumsum(a)
b=cumsum(b)

read=bisect(a,k)
time=a[read-1]
ans=read

for i in range(read):
    extra=k-time
    r=bisect(b,extra)
    ans=max(ans,read+r)
    read-=1
    time=a[read-1]
read=bisect(b,k)
ans=max(ans,read)
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()))

A = np.array(A).cumsum()
B = np.array(B).cumsum()

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

import bisect

alist = [0]
blist = [0]

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

res = 0
ans = 0
for i in range(n+1):
  border = k - alist[i]
  if border < 0:
    continue
  ans = i
  ans += bisect.bisect_right(blist, border)-1
  res = max(res, ans)
  
print(res)
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(1, n+1):
    a[i] += a[i-1]
for i in range(1, m+1):
    b[i] += b[i-1]

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

print(ans)
import bisect


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

cumA = [0]
cumB = []

a_sum = 0
for a in A:
    a_sum += a
    cumA.append(a_sum)

b_sum = 0
for b in B:
    b_sum += b
    cumB.append(b_sum)


candidates = []
for i, aa in enumerate(cumA):
    if aa > k:
        break

    residue = k - aa
    j = bisect.bisect_right(cumB, residue)
    candidates.append(i + j)

print(max(candidates))
from bisect import bisect_right

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

SA = [0]*(N+1)
SB = [0]*(M+1)
for i in range(N):
  SA[i+1] = SA[i] + A[i]
for i in range(M):
  SB[i+1] = SB[i] + B[i]
  
ans = 0
for i in range(N+1):
  cntA = i
  rest = K - SA[i]
  if rest < 0:
    break
  cntB = bisect_right(SB, rest) - 1
  ans = max(ans, cntA+cntB)

print(ans)
from itertools import accumulate
import bisect
n, m, k = map(int, input().split())
Acum = [0]+list(accumulate(map(int, input().split())))
Bcum = [0]+list(accumulate(map(int, input().split())))

ans = 0
for a in range(n+1):
    if k-Acum[a] < 0:
        break
    b = bisect.bisect_right(Bcum, k-Acum[a])-1
    if ans < a+b:
        ans = a+b
print(ans)
import sys
input = lambda: sys.stdin.readline().rstrip()

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

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

a = [0] + A
b = [0] + B

for i in range(len(a)-1):
    a[i+1] += a[i]

for i in range(len(b)-1):
    b[i+1] += 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)
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from bisect import bisect_right
n,k,m = map(int,readline().split())
a = [int(i) for i in readline().split()]
b = [int(i) for i in readline().split()]

aa = [0]*(n+1)
bb = [0]*(k+1)
for i in range(n):
  aa[i+1] = aa[i]+a[i]
for i in range(k):
  bb[i+1] = bb[i]+b[i]
  
ans = 0
for num,i in enumerate(bb):
  M = m-i
  if M >= 0:
    ind = bisect_right(aa,M)
    ans = max(ans,num+ind-1)
  
print(ans)
import itertools
from bisect import bisect_right
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
sum_a = [0] + list(itertools.accumulate(a))
sum_b = [0] + list(itertools.accumulate(b))
ans = 0
for i in range(n + 1):
    if sum_a[i] > k:
        break
    ans = max(ans, i + bisect_right(sum_b, k - sum_a[i]) - 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
a = list(accumulate(a))
b = list(accumulate(b))

from collections import deque
u = deque([0])
a.insert(0,0)

import bisect
for i in range(n+1):
    if k-a[i]>=0:
        index = bisect.bisect_right(b,k-a[i])
        u.append(index+i)
    else:
        break
print(max(u))
from itertools import accumulate
import bisect
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ac = [0] + list(accumulate(a))
bc = [0] + list(accumulate(b))

ans = 0
for i in range(bisect.bisect(ac, k)):
    bi = bisect.bisect(bc, k - ac[i])
    ans = max(ans, i+bi-1)
print(ans)
x = input().split()
y = input().split()
z = input().split()
s = 0

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]  
        y.append(1000000001) 
        s += 1
    else:
        x[2] = int(x[2]) - int(z[0])
        del z[0]
        z.append(1000000001)
        s += 1
print(s-1)
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):
        sumA = int(sum(A[0:x]))
        for y in range(m):
            sumB = int(sum(B[0:y]))
            if sumA + sumB < k:
                C.append(x+y)
    print(max(C))
main()
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)

c = 0
for i in range(0,len(b)):
    c = c + b[i]

if c <= a1[2]:
    print(len(b))
else:
    s = 0
    t = 0
    while s <= a1[2] and t < len(b):
        s = s + b[t]
        t = t + 1
    print(t-1)
import bisect

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

A_cum = [0]
B_cum = [0]

for i in range(n):
  A_cum.append(A_cum[i]+A[i])
  
for i in range(m):
  B_cum.append(B_cum[i]+B[i])
    
ans = 0  
for i in range(n):
  rest = k-A_cum[i]
  if rest<=0:
    continue
  ans = max(ans, bisect.bisect_left(B_cum, rest)+i)
  
print(ans)
n, m, k = (int(x) for x in input().split())

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

K = k
ans = 0

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


print(ans)
import bisect
N,M,K= map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

dpA = [0]*(N+1)
dpB = [0]*(M+1)

for i in range(1,N+1):
    dpA[i] = dpA[i-1] + A[i-1]

for i in range(1,M+1):
    dpB[i] = dpB[i-1] + B[i-1]

ans = 0
for i in range(1,N+1):
    if dpA[i] > K:
        continue
    indexB = bisect.bisect_right(dpB, K - dpA[i])
    ans = max(ans, i + indexB - 1)

print(ans)
import sys
n, m, k = list(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, 0, -1):
  p = 0
  q = 0
  if a[i-1] <= k:
    p = a[i-1]
    q = i
  for j in range(m, 0, -1):
    if p + b[j-1] <= k:
      ans = max(ans, q + j)
    
print(ans)
import bisect

N, M, K = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
arui = [0] * (N + 1)
brui = [0] * (M + 1)
for i in range(N):
    arui[i + 1] = a[i] + arui[i]
for i in range(M):
    brui[i + 1] = b[i] + brui[i]

ans = 0
for i in range(1, N + 1):
    if arui[i] > K:
        break
    bcnt = M
    while brui[bcnt] + arui[i] > K:
        bcnt -= 1
    ans = max(ans, i + bcnt)

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

while k >= 0:
  if len(a) == 0 and len(b) == 0:
    break
  elif len(a) == 0:
    k -= b.pop(0)
  elif len(b) == 0:
    k -= a.pop(0)
  else:
    if  a[0] > b[0]:
      k -= b.pop(0)
    else:
      k -= a.pop(0)
  counter += 1
if k < 0:
  counter -= 1
print(counter)
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

i = 0
for s in range(n+m):
    if i>k:
        if a[0]>=b[0]:
            i = i + a[0]
            del a[0]
        else:
            i = i + b[0]
            del a[0]
    else:
        print(s)
n,m,k = map(int, input().split())
ln_a = list( map(int, input().split()))
ln_b = list( map(int, input().split()))
total = 10**9
output = 0
for i in range(1,len(ln_a) + len(ln_b) +1):
    for j in range(i +1):
        total = min(total, sum(ln_a[:j]) +  sum(ln_a[:i-j] ))
    if total <= k:
        output = i
    total = 10**9
print(output)
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):
    if a[i] < k:
        ans = max(ans,i+1 + bisect.bisect_left(b,k-a[i]))
print(ans)
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

i = 0
for s in range(n+m):
    if i>k:
        if a[0]>=b[0]:
            i = i + a[0]
            del a[0]
        else:
            i = i + b[0]
            del a[0]
    elif i==k:
        print(s+1)
    else:
        print(s)
n, m, k = map(int, input().split())
a_list = list(map(int, input().split()))
b_list = list(map(int, input().split()))
max = 10 ** 9 + 1
time = 0
ans = 0
a = 0
b = 0

for i in range(n + m):
    if a_list[a] < b_list[b]:
        time += a_list[a]
        a += 1
    else:
        time += b_list[b]
        b += 1

    if time > k:
        break
    else:
        ans += 1

    if a >= n:
        a_list.append(max)
    if b >= m:
        b_list.append(max)

print(ans)
n,m,k=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
A.insert(0,0)
cntB=0
cnt_list=[]

for i in range(n+1):
  timeA=sum(A[:i+1])
  cntA=i
  time=timeA
  if timeA>k:
    break
  for j in range(m):    
    if time+B[j]<=k:
      timeB=sum(B[:j+1])
      time=timeA+timeB    
      cntB=j+1
    else:
      break
  cnt=cntA+cntB
  cnt_list.append(cnt)
  
print(max(cnt_list))
import numpy as np
import sys
input = sys.stdin.buffer.readline

N, M, K = map(int, input().split())
cumA = np.zeros(N+1, dtype=np.int32)
cumA[1:] = np.array(input().split(), dtype=np.int32).cumsum()
cumB = np.zeros(M+1, dtype=np.int32)
cumB[1:] = np.array(input().split(), dtype=np.int32).cumsum()
# print(cumA)
# print(cumB)

ans = 0
for i in range(N, -1, -1):
    if cumA[i] > K: continue
    j = np.searchsorted(cumB, K-cumA[i], side='right')
    ans = max(ans, i+j-1)
print(ans)
from sys import stdin
An, Bn, t = [int(x) for x in stdin.readline().rstrip().split()]

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


idxA = 0
idxB = 0

cnt = 0

for i in range(An + Bn):
	if t < 0 : break

	if An > i :
		t -= A[idxA]
		if t < 0 : break
		cnt += 1
		idxA += 1

	if Bn > i :
		t -= B[idxB]
		if t < 0 : break
		cnt += 1
		idxB += 1
print(cnt)
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 = input().split()
A = input().split()
B = input().split()

cnt = 0

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

min = int(int(K)/int(min(list)))
for s in range(len(list)):
    if ans <= int(K):
        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()))
A.append(K + 1)
B.append(K + 1)
ia, ib = 0, 0
time = 0
flag = True
while flag:
    flag = False
    if A[ia] <= B[ib] and time + A[ia] <= K:
        time += A[ia]
        ia += 1
        flag = True
    if B[ib] < A[ia] and time + B[ib] <= K:
        time += B[ib]
        ib += 1
        flag = True
print(ia + ib)
from bisect import bisect

N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
R_B = [0]*(M+1)
i = 0
while i < M:
  R_B[i+1] = R_B[i]+B[i]
  i += 1 
ans = 0
i = 0
while i < N and K >= A[i]:
  K -= A[i]
  idx = bisect(R_B, K)
  ans = max(ans, i+idx)
  R_B = R_B[:idx+1]
  i += 1
print(ans)
N, M, K = map(int, input().split())
pa = abs(N-M) + 1
A = list(map(int, input().split()))+ [1000000010]
B = list(map(int, input().split()))+ [1000000010]
if N < M:
    A = A + [1000000010]*(pa)
elif N > M:
    B = B + [1000000010]*(pa)
c = 0
while K >= A[0] or K >= B[0]:
    if A[0] < B[0]:
        K -= A.pop(0)
    else:
        K -= B.pop(0)
    c += 1
print(c)
from sys import stdin
input = lambda: stdin.readline().rstrip("\r\n")
from collections import defaultdict as vector, deque as que
read = lambda: list(map(int,input().split()))
from bisect import bisect
from heapq import heappush as hpush,heappop as hpop

n,m,k=read()
A=read()
B=read()
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
for i in range(1,n+1):
	curr=a[i]
	j=m
	if curr>k:
		break
	while(b[j]>k-curr):
		j-=1
	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 = len(b_list)-1
best=0
for i, a in enumerate(a_list):
  a_sum+=a
  while ((a_sum + b_sum) > k) & (j>=0):
    b_sum-=b_list[j]
    j-=1
  if (a_sum + b_sum) <= k:
    if i+j+2 > best:
      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()))
for i in range(1,n):
  a[i] += a[i-1]
for  i in range(1,m):
  b[i] += b[i-1]
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+1)
print(ans)
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
mix = sorted(A + B)
temp_sum = 0
goal = 0
for i in range(len(mix)):
    temp_sum += mix[i]
    goal = i
    if temp_sum > K:
        print(i)
        exit()
print(goal + 1)
import bisect

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

A_cum = [0]
B_cum = [0]

for i in range(n):
  A_cum.append(A_cum[i]+A[i])
  
for i in range(m):
  B_cum.append(B_cum[i]+B[i])

ans = 0  
for i in range(n+1):
  rest = k-A_cum[i]
  if rest<=0:
    continue
  
  ans = max(ans, bisect.bisect_right(B_cum, rest)-1+i)
  
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]
    if spent_time + temp > K:
      break
    spent_time = spent_time + temp
    count += 1
  print(count)
  
main()