Harryxun/stf_run huggingface dataset:
n,m,k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
 
ans = 0
time = 0
 
 
for i in range(len(a)):
    time += a[i]
    if time > k:
        time -=a[i]
        break
    ans += 1
    
count_a = ans
 
for j in range(len(b)):
    time += b[j]
    if time > k:
        while count_a > 0 & time > k:
            time -= a[count_a]
            count_a -= 1
        if time > k:
            tmp = 0
        else:
            tmp = count_a + j
    if tmp > ans :
        ans = tmp
    
print(ans)

### FIXED CODE ###

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

sum_a = [0]
sum_b = [0]

for i in range(n):
    sum_a.append(sum_a[i] + a[i])
for j in range(m):
    sum_b.append(sum_b[j] + b[j])

temp = 0
j = m
ans = 0
for i in range(n+1):
    if sum_a[i] > k:
        temp = i -1
        if temp > ans:
            ans = temp
        break
    else:
        while k - sum_a[i] < sum_b[j]:
            j -= 1
        temp = i + j
        if temp > ans:
            ans = temp
            
print(ans)
lis=0
S=0
L=0
lis=input().split()
S=int(lis[0])*int(lis[1])
L=int(lis[0])*2+int(lis[1]*2)
print(S L)

### FIXED CODE ###

lis=0
S=0
L=0
lis=input().split()
S=int(lis[0])*int(lis[1])
L=int(lis[0])*2+int(lis[1])*2
print(S,L)
s = list(input())
sr = []
ans=0
m = len(s)/2

for i in s[::-1]:
    sr.append(i)


for i in range(m):
    if s[i] != sr[i]:
        ans +=1

print(ans)

### FIXED CODE ###

s = list(input())
sr = []
ans=0
m = len(s)//2

for i in s[::-1]:
    sr.append(i)


for i in range(m):
    if s[i] != sr[i]:
        ans +=1

print(ans)
import numpy as np
n = int(input())
t = list(int(input()) for _ in range(n))

print(np.lcm.reduce(t))


### FIXED CODE ###

from fractions import gcd
n = int(input())
t = list(int(input()) for _ in range(n))


def lcm(a, b):
    return a * b // gcd(a, b)


ans = 1
for i in t:
    ans = lcm(ans, i)

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

a[m] = a[m].remove("A","a").remove("B","b").remove("C","c")
print("".join(a))

### FIXED CODE ###

import sys,collections as cl,bisect as bs
Max = sys.maxsize
def l():
	return list(map(int,input().split()))
def m():
	return map(int,input().split())
def s(x):
	a = []
	aa = x[0]
	su = 1
	for i in range(len(x)-1):
		if aa == x[i+1]:
			a.append([aa,su])
			aa = x[i+1]
			su = 1
		else:
			su += 1
	a.append([aa,su])
	return a
def jo(x):
	return " ".join(map(str,x))

n,m = m()
a = list(input())

if a[m-1] == "A":
	a[m-1] = "a"
elif a[m-1] == "B":
	a[m-1] = "b"
else:
	a[m-1] = "c"
print("".join(a))
n,l=input().split()
N=int(n)
L=int(l)
s=[]
for i in range(N):
  s.append(input())
s.sort()
print(s.join(""))

### FIXED CODE ###

n,l=input().split()
N=int(n)
L=int(l)
s=[]
for i in range(N):
  s.append(input())
s.sort()
print(("").join(s))
s, t = input().split()
print(t+c)

### FIXED CODE ###

s, t = input().split()
print(t+s)
N = int(input())
s = str(input())
types = []
for i in range(len(s)-1):
    x = s[:i]
    y = s[i:]
    x.sort()
    y.sort()
    x_str = []
    y_str = []
    x_str.append(x[0])
    y_str.append(y[0])
    count = 0
    for i in range(len(x)):
        if i == 0:
            x_str.append(x[0])
        else:
            if x[i-1] != x[i]:
                x_str.append(x[i])
    for i in range(len(y)):
        if i == 0:
            y_str.append(y[0])
        else:
            if y[i-1] != y[i]:
                y_str.append(y[i])
    for i in range(len(x_str)):
        if x_str[i] in y_str:
            count += 1
    types.append(count)
print(max(types))

### FIXED CODE ###

N = int(input())
s = str(input())
types = []
for i in range(len(s)-1):
    x = list(s[:i+1])
    y = list(s[i+1:])
    x.sort()
    y.sort()
    x_str = []
    y_str = []
    count = 0
    for j in range(len(x)):
        if j == 0:
            x_str.append(x[0])
        else:
            if x[j-1] != x[j]:
                x_str.append(x[j])
    for j in range(len(y)):
        if j == 0:
            y_str.append(y[0])
        else:
            if y[j-1] != y[j]:
                y_str.append(y[j])
    for j in range(len(x_str)):
        if x_str[j] in y_str:
            count += 1
    types.append(count)
print(max(types))
def solve(index: int, dp: list, footing: list) -> int:
    if dp[index] != -1:
        return dp[index]

    if index == 0:
        return 0
    elif index == 1:
        return abs(footing[1]-footing[0])

    tmp = min(solve(index-1, dp, footing)+abs(footing[index]-footing[index-1]), solve(index-2, dp, footing)+abs(footing[index]-footing[index-2]))
    #print(f'{tmp=}')
    dp[index] = tmp
    return tmp

N = int(input())
footing = list(map(int, input().split()))

dp = [-1] * N

ans = solve(N-1, dp, footing)

print(ans)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 7)

def solve(index: int, dp: list, footing: list) -> int:
    if dp[index] != -1:
        return dp[index]

    if index == 0:
        return 0
    elif index == 1:
        return abs(footing[1]-footing[0])

    tmp = min(solve(index-1, dp, footing)+abs(footing[index]-footing[index-1]), solve(index-2, dp, footing)+abs(footing[index]-footing[index-2]))
    #print(f'{tmp=}')
    dp[index] = tmp
    return tmp

N = int(input())
footing = list(map(int, input().split()))

dp = [-1] * N

ans = solve(N-1, dp, footing)

print(ans)
#dt = {} for i in x: dt[i] = dt.get(i,0)+1
ipnl = lambda n: [int(input()) for _ in range(n)]
inp = lambda :int(input())
ip = lambda :[int(w) for w in input().split()]

n = inp()
x = ip()
ele = 10**18
prod = 1
if 0 in x:
    print(0)
    exit()
for i in x:
    prod *= i
    if prod > ele:
        print(-1)
        exit()
print(prod)

### FIXED CODE ###

#dt = {} for i in x: dt[i] = dt.get(i,0)+1
ipnl = lambda n: [int(input()) for _ in range(n)]
inp = lambda :int(input())
ip = lambda :[int(w) for w in input().split()]

a,b = input().split()
a = int(a)
b = list(b.split("."))
b = ''.join(b)
b = int(b)
print(a*b//100)
input_data = input().split(" ")
product = int(input_data[0])*int(input_data[2])
if (product % 2 == 0):
  print("Even")
else:
  print("Odd")

### FIXED CODE ###

a,b = map(int, input().split())
if (a * b) % 2 == 0:
  print('Even')
else:
  print('Odd')
import sys
input = sys.stdin.readline

n,q = map(int,input().split())
t = [[] for _ in range(n+1)]
for _ in range(n-1):
  a,b = map(int,input().split())
  t[a].append(b)
  t[b].append(a)
cnt = [0]*(n+1)
for _ in range(q):
  p,x = map(int,input().split())
  cnt[p] += x
def csum(now,bef):
  for i in t[now]:
    if i != bef:
      cnt[i] += cnt[now]
      csum(i,now)
csum(1,0)
for i in range(1,n+1):
  print(cnt[i],end=" ")

### FIXED CODE ###

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

n,q = map(int,input().split())
t = [[] for _ in range(n+1)]
for _ in range(n-1):
  a,b = map(int,input().split())
  t[a].append(b)
  t[b].append(a)
cnt = [0]*(n+1)
for _ in range(q):
  p,x = map(int,input().split())
  cnt[p] += x
def csum(now,bef):
  for i in t[now]:
    if i != bef:
      cnt[i] += cnt[now]
      csum(i,now)
csum(1,0)
print(*cnt[1:])
import sympy

n, p = map(int, input().split())

list = sympy.factorint(p)

# print(list)

ans = 1
for b, e in list.items():
    tmp = e // n
    if tmp!=0:
        ans*=b

print(ans)

### FIXED CODE ###

n, p = map(int, input().split())

def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct


# print('(n, p) is ({}, {})'.format(n, p))
list = factorize(p)
# print(list)



ans = 1
for b, e in list:
    # print(b, e)
    tmp = e // n
    # print('b // n is', tmp )
    if tmp !=0:
        for i in range(tmp):
            ans*=b

print(ans)
n = int(input())
A = list(map(int,input().split()))
ans = 0
for a in A:
  if a % 2 == 0:
    if a % 3 == 0 or a % 5 == 0:
      ans = 1
      break()
      
if ans == 1:
  print(APPROVED)
else:
  print(DENIED)
  



### FIXED CODE ###

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

POINT = 0
for i in A:
    if i % 2 == 0:
        if i % 3 != 0 and i % 10 != 0:
            POINT = 1
if POINT == 1:
  print("DENIED")
else:
  print("APPROVED")
S = input()
if (S[0] == S[1] and S[2] == S[3] and S[0] != S[2]) or (S[0] == S[2] and S[1] == S[3] and S[0] != S[3]) or (S[0] == S[3] and S[1] == S[2] and S[0] != S[1]):
    print('Yes')
else:
    print('No')

### FIXED CODE ###

N = int(input())
P = list(map(int, input().split()))
C = 0
for i in range(N):
    if i == 0 or i == N-1:
        continue
    elif (P[i] > P[i-1] and P[i+1] > P[i]) or (P[i-1] > P[i] and P[i] > P[i+1]):
        C += 1
print(C)
N, K = map(int, raw_input().split())
ps = []
for i in xrange(N):
  ps.append(map(int, raw_input().split()))

xsorted = zip(*sorted(ps, key=lambda p: p[0]))[0]
ysorted = zip(*sorted(ps, key=lambda p: p[1]))[1]

ans = float('inf')
for i in xrange(N):
  bottom = ysorted[i]
  for j in xrange(i+K-1, N):
    top = ysorted[j]
    for k in xrange(N):
      if k+K-1 >= N:
        break
      right = xsorted[k]
      # 2 bun tansaku
      f, t = k+K-1, N
      sol = None
      while True:
        mid = (f+t)//2
        left = xsorted[mid]
        c = 0
        for p in ps:
          if right <= p[0] <= left and bottom <= p[1] <= top:
            c += 1
            if c >= K: break
        else:
          if f+1 >= t:
            sol = t
            break
          f = mid
          continue
        if f+1 >= t:
          sol = f
          break
        t = mid
      if sol:
        area = (xsorted[sol] - right) * (top - bottom)
        if area < ans:
          ans = area

print ans

### FIXED CODE ###

N, K = map(int, raw_input().split())
ps = []
for i in xrange(N):
  ps.append(map(int, raw_input().split()))

xsorted = zip(*sorted(ps, key=lambda p: p[0]))[0]
ysorted = zip(*sorted(ps, key=lambda p: p[1]))[1]

ans = float('inf')
for i in xrange(N):
  bottom = ysorted[i]
  for j in xrange(i+K-1, N):
    top = ysorted[j]
    for k in xrange(N):
      if k+K-1 >= N:
        break
      right = xsorted[k]
      # 2 bun tansaku
      f, t = k+K-1, N
      sol = None
      while True:
        mid = (f+t)//2
        left = xsorted[mid]
        c = 0
        for p in ps:
          if right <= p[0] <= left and bottom <= p[1] <= top:
            c += 1
            if c >= K: break
        else:
          if f+1 >= t:
            break
          f = mid
          continue
        sol = mid
        if f+1 >= t:
          break
        t = mid
      if sol:
        area = (xsorted[sol] - right) * (top - bottom)
        if area < ans:
          ans = area

print ans
l,r=1,10**9
#(2)l=rもしくはl=r-1のときにbreak
while l+1<r:
    #(3)その閉区間の中点(の小数部分を切り捨てたもの)
    #オーバーフローを考慮すると以下の書き方になる
    k=l+(r-l)//2
    #ここでは境目以上のxで真になるので、
    #x=kで真の場合は大きい方の端点をkにし、x=kで偽の場合は小さい方の端点をkにする
    if explode(k):
        r=k
    else:
        l=k

print(l if explode(l) else r)

### FIXED CODE ###

import math
n,a,b=map(int,input().split())
h=[int(input()) for i in range(n)]


def explode(x):
    global n
    c=0
    for i in range(n):
        if h[i]-x*b>0:
            c+=math.ceil((h[i]-x*b)/(a-b))
    return c<=x

l,r=1,10**9
while l+1<r:
    k=(l+r)//2
    if explode(k):
        r=k
    else:
        l=k

print(l if explode(l) else r)
for a,b in map(int, raw_input().split()):
    print '%d %d' %(a*b, 2*(a+b))

### FIXED CODE ###

a, b = map(int, raw_input().split())
print a*b, 2*(a+b)
from math import pi
i = input()
print(i * pi)

### FIXED CODE ###

from math import pi
i = input()
print(float(i) * pi * 2)
H, W, M = map(int, input().split())
dp= [[0]*W for i in range(H)]
dph = [0]*W
dpw = [0]*H
dphpos = []
dpwpos = []
ansh = 0
answ = 0
ans = 0

for i in range(M):
    h, w = map(lambda x: int(x) - 1, input().split())
    dp[h][w] = 1
    dph[w] += 1
    dpw[h] += 1

for i in range(W): #列の最大値
    if dph[i] > ansh:
        ansh = dph[i]
        dphpos = [i]
    elif dph[i] == ansh:
        dphpos.append(i)

for i in range(H):
    if dpw[i] > answ:
        answ = dpw[i]
        dpwpos = [i]
    elif dpw[i] == answ:
        dpwpos.append(i)

for i in range(len(dphpos)):
    for j in range(len(dpwpos)):
        if dp[dpwpos[j]][dphpos[i]] == 1:
            ans = max(ans, ansh + answ - 1)
        else:
            ans = ansh + answ
print(ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline

h, w, m = map(int, input().split())
col = [0]*w
row = [0]*h
ypos = []
xpos = []
bomb = []

for i in range(m):
    H, W = map(lambda x: int(x) - 1, input().split())
    col[W] += 1
    row[H] += 1
    bomb.append((H, W))

maxcol = max(col)
maxrow = max(row)

xpos = [h for h, x in enumerate(col) if x == maxcol]
ypos = [w for w, y in enumerate(row) if y == maxrow]

ans = maxcol + maxrow - 1
bomb = set(bomb)

for i in ypos:
    for j in xpos:
        if (i, j) not in bomb:
            ans += 1
            print(ans)
            exit()
print(ans)
N,K+map(int, input().split())
print(N%K)

### FIXED CODE ###

N,K=map(int,input().split())
[print(0) if K==1 else print(N-K)]
N = int(input())
L = list(map(int,input().split()))

M = L.pop(max(L))

if(M < sum(L)):
    print('Yes')
else:
    print('No')

### FIXED CODE ###

N = int(input())
L = list(map(int,input().split()))

M = max(L)

if(M < sum(L)-M):
    print('Yes')
else:
    print('No')
N = int(input())
h = N // 100
t = (N - h) // 10
o = N - h - t
if h = 7 or t = 7 or o = 7:
    print('Yes')
else:
    print('No') 

### FIXED CODE ###

N = int(input())
h = N // 100
t = (N - h * 100) // 10
o = N - h * 100 - t * 10
if h == 7 or t == 7 or o == 7:
    print('Yes')
else:
    print('No')
N = int(input())
if N == 1:
    return 1
points = []
for _ in range(N):
    x, y = map(int, input().split())
    points.append((x, y))
diff = dict()
for i in range(N):
    for j in range(N):
        if i == j:
            continue
        x1, y1 = points[i]
        x2, y2 = points[j]
        pq = x1-x2, y1-y2
        diff[pq] = diff.get(pq, 0) + 1
val, key = max((v, k) for k, v in diff.items())
print(N-val)


### FIXED CODE ###

N = int(input())
if N == 1:
    print(1)
    quit()
points = []
for _ in range(N):
    x, y = map(int, input().split())
    points.append((x, y))
diff = dict()
for i in range(N):
    for j in range(N):
        if i == j:
            continue
        x1, y1 = points[i]
        x2, y2 = points[j]
        pq = x1-x2, y1-y2
        diff[pq] = diff.get(pq, 0) + 1
val, key = max((v, k) for k, v in diff.items())
print(N-val)
(a,b,c)=int(input().split());print(min(a*b,c))

### FIXED CODE ###

(a,b,c)=map(int,input().split());print(min(a*b,c))
# -*- coding: utf-8 -*-

import math
from functools import reduce

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

print(reduce(math.gcd, a[1:]))


### FIXED CODE ###

# -*- coding: utf-8 -*-

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

def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    c = a % b
    return gcd(b, c)

if len(a) == 1:
    ans = a[0]
else:
    ans = gcd(a[0],a[1])
    for i in range(2,n):
        ans = gcd(ans,a[i])

print(ans)
import functools
import math

N = int(input())
a = list(map(int,input().split()))
ans = 1
for i in range(N):
	a_new = a[0:i]+a[i+1:N]
	gcd = functools.reduce(math.gcd,a_new)
	ans = max(ans,gcd)

print(ans)


### FIXED CODE ###

import functools
import fractions


N = int(input())
a = list(map(int,input().split()))
ans = 1
gcd = functools.reduce(fractions.gcd,a)
s_front = [1]*N
s_back = [1]*N
s_front[0] = a[0]
s_back[0] = a[N-1]

for i in range(N):
	if i > 0:
		s_front[i] = fractions.gcd(s_front[i-1],a[i])
		s_back[i] = fractions.gcd(s_back[i-1],a[N-i-1])
for i in range(N):
	if i == 0:
		gcd_new = s_back[N-2]
	elif i == N-1:
		gcd_new = s_front[N-2]
	else:
		gcd_new = fractions.gcd(s_front[i-1],s_back[N-i-2])
	ans = max(ans,gcd_new)
print(ans)
S = list(input())
acgt = ['A', 'C', 'G', 'T']
lengths = []
l = 0
for x in S:
  if x in acgt:
    l += 1
  else:
    lengths.append(l)
    l = 0
print(max(lengths))


### FIXED CODE ###

S = list(input())
acgt = ['A', 'C', 'G', 'T']
lengths = []
l = 0
for x in S:
  if x in acgt:
    l += 1
  else:
    lengths.append(l)
    l = 0

if len(lengths) == 0 or l > 0:
  lengths.append(l)

print(max(lengths))
print("1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51".split(", ")[int(input())])

### FIXED CODE ###

s="1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51"
n=int(input())
print((s.split(", "))[n-1])
n = int(input())
for i in range(n):
    x = int(input())
    y = int(input())
    ans = x + y
    if len(str(ans)) > 80 :
        print 'overflow'
    else:
        print ans

### FIXED CODE ###


#
n = int(raw_input())
for i in xrange(n):
    x = int(raw_input())
    y = int(raw_input())
    ans = x + y
    if len(str(ans)) > 80 :
        print 'overflow'
    else:
        print ans
import math
ls, lt = map(int, input().split())
s = list(input())
t = list(input())
g = math.gcd(ls,lt)
if (g == ls):
    d = lt//g
    for i in range(ls):
        if (s[i]!=t[i*d]):
            print(-1)
            exit()
elif (g == lt):
    d = ls//g
    for i in range(lt):
        if (t[i]!=s[i*d]):
            print(-1)
            exit()
print(ls*lt//g)


### FIXED CODE ###

ls, lt = map(int, input().split())
s = list(input())
t = list(input())
def gcd(m,n):
    if n == 0:
        return m
    else:
        return gcd(n,m%n)
g = gcd(ls,lt)
m = ls // g
n = lt // g
ret = g*m*n
for i in range(g):
    if s[i*m] != t[i*n]:
        ret = -1
        break
print(ret)
N,A,B= list(map(int, input().split()))
if N*A>=B:
    print(B)
else
    print(N*A)

### FIXED CODE ###

N,A,B= list(map(int, input().split()))
if N*A>=B:
    print(B)
else:
    print(N*A)
from collections import defaultdict
n,m,k = map(int,input().split())
fr = defaultdict(set)
bl = defaultdict(set)

for _ in range(m):
  a,b = map(int,input().split())
  a -= 1
  b -= 1
  fr[a].add(b)
  fr[b].add(a)

for _ in range(k):
  a,b = map(int,input().split())
  a -= 1
  b -= 1
  bl[a].add(b)
  bl[b].add(a)

def dfs(i, g):
  g.add(i)
  for a in fr[i]:
    if a not in g:
      dfs(a, g)

for i in range(n):
  s = set()
  dfs(i, s)
  for j in bl[i]:
    if j in s:
      s.remove(j)
  print(len(s) - len(fr[i]) - 1, end=' ')
print()

### FIXED CODE ###

from collections import defaultdict
import time
n,m,k = map(int,input().split())
fr = defaultdict(set)
bl = []
start = time.time()
group = [0] * n

for _ in range(m):
  a,b = map(int,input().split())
  a -= 1
  b -= 1
  fr[a].add(b)
  fr[b].add(a)

for _ in range(k):
  a,b = map(int,input().split())
  a -= 1
  b -= 1
  bl.append((a,b))


g_num = 0
for i in range(n):
    if group[i] != 0:
        continue
    g_num += 1
    unvisited = set({i})
    while len(unvisited) > 0:
        v = unvisited.pop()
        group[v] = g_num
        for w in fr[v]:
            if group[w] > 0 or w in unvisited:
                continue
            unvisited.add(w)

group_size = defaultdict(int)
for x in group:
    group_size[x] += 1

bl_in_group = [0] * n
for a,b in bl:
    if group[a] == group[b]:
        bl_in_group[a] += 1
        bl_in_group[b] += 1

for i in range(n):
    print(group_size[group[i]] - len(fr[i]) - bl_in_group[i] - 1, end=' ')

print()
if input().find('9')>-1:
  print("Yes")
  else:
    print("No")


### FIXED CODE ###

if input().find('9')>-1:
  print("Yes")
else:
    print("No")
### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline

    n,m,k=map(int, readline().rstrip().split())
    aa=list(map(int, readline().rstrip().split()))
    bb=list(map(int, readline().rstrip().split()))
    asum=[0]*n
    bsum=[0]*m
    memo=[0]*n
    asum[0]=aa[0]
    bsum[0]=bb[0]
    mp=n-1
    ans=0
    for i in range(1,n):
        asum[i]=(aa[i]+asum[i-1])
    for i in range(1,m):
        bsum[i]=(bb[i]+asum[i-1])

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

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ----------------

### FIXED CODE ###

### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline

    n,m,k=map(int, readline().rstrip().split())
    aa=list(map(int, readline().rstrip().split()))
    bb=list(map(int, readline().rstrip().split()))
    asum=[0]*n
    bsum=[0]*m
    asum[0]=aa[0]
    bsum[0]=bb[0]
    mp=n-1
    ans=0
    for i in range(1,n):
        asum[i]=(aa[i]+asum[i-1])
    for i in range(1,m):
        bsum[i]=(bb[i]+bsum[i-1])

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

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ----------------
a,b,c=map(int,input().split())
if b+c<=a:
    print(0)

else:
    print(c+b-a))

### FIXED CODE ###


a,b,c=map(int,input().split())
if b+c<=a:
    print(0)

else:
    print(c+b-a)
N, M, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))

z1 = max(x) + 1
z2 = min(y)

if X < z1 and z1 < Y:
    if X < z2 and z2 < Y:
        if z1 <= z2:
            print ('No War')
            sys.exit()
print ('War')


### FIXED CODE ###

import sys
N, M, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))

z1 = max(x) + 1
z2 = min(y)

if X < z1 and z1 < Y:
    if X < z2 and z2 < Y:
        if z1 <= z2:
            print ('No War')
            sys.exit()
print ('War')
a, b, x = map(int, input().split())
ans = 0
if a == 0: ans = b/x + 1
else: ans = b/x - (a-1)/x
print ans

### FIXED CODE ###

a, b, x = map(int, raw_input().split())
ans = 0
if a == 0: ans = b/x + 1
else: ans = b/x - (a-1)/x
print ans