Harryxun/stf_run huggingface dataset:
a,b,c,x,y = map(int, input().split())
ans = 10**12
for i in range(0, max(x,y)*2+1, 2):
    xr = max(x-i//2, 0)
    yr = max(0, y-i//2)

    if ans > (i*c)+(xr*a)+(yr*b):
        ans = (i*c)+(xr*a)+(yr*B)

print(ans)

### FIXED CODE ###

a,b,c,x,y = map(int, input().split())
ans = 10**12
for i in range(0, (max(x,y)*2)+1, 2):
    xr = max(x-(i//2), 0)
    yr = max(0, y-(i//2))

    if ans > (i*c)+(xr*a)+(yr*b):
        ans = (i*c)+(xr*a)+(yr*b)

print(ans)
n=int(input())
if n%10 == 3:
    print("bon")
else if n%10 in [0,1,6,8]:
    print("pon")
else:
    print('hon')

### FIXED CODE ###

n=int(input())
if n%10 == 3:
    print("bon")
elif n%10 in [0,1,6,8]:
    print("pon")
else:
    print('hon')
import sys

iT = int(input())
aR = [[int(x) for x in sLine.split()] for sLine in sys.stdin.readlines()]
#わからんから解説見た。解説見たけどgcdの下りが自分で導出できんかったのでとりあえ
ずバカループでなんとかしてみた。これで通るかな。
def f調1(iA,iB,iC,iD):
    if iA < iB or iD < iB:
        return False
    if iC >= iB :
        return True
    iJ = iA % iB
    iK = iD % iB
    i = 1
    while True:
        j = iJ + i * iK
        if iB <= j:
            return True
        else:
            if iC < j:
                return False
        if iK == 0:
            return True
        i += 1
    return True

for eR in aR:
    if f調1(*eR) :
        print("Yes")
    else:
        print("No")


### FIXED CODE ###

import sys

iT = int(input())
aR = [[int(x) for x in sLine.split()] for sLine in sys.stdin.readlines()]

def fGcd(iX,iY):
    while iY:
        iX,iY= iY,iX%iY
    return iX

#これものすごくわりきってるけど通るのか？

def fFunc(iA,iB,iC,iD):
    if iA < iB or iD < iB:
        return False
    elif iC >= iB :
        return True
    elif iC < iA % iB :
        return False
    elif iB -iC - 1 < fGcd(iB,iD) :
        return True
    else:
        return False

for eR in aR:
    if fFunc(*eR) :
        print("Yes")
    else:
        print("No")
from operator import itemgetter
 


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

a = list(map(int,input().split()))
bclist = [list(map(int,input().split())) for _ in range(m)]

a.sort()
bclist.sort(key=itemgetter(1))

last = 0

for bc in  reversed(bclist):
    for i in range(bc[0]):
        if bc[1] > a[last]:
            a[last] = bc[1]
            last += 1


print(sum(a))

### FIXED CODE ###

n,m = map(int, input().split())
a = list(map(int,input().split()))
bclist = [list(map(int,input().split())) for _ in range(m)]

bclist=sorted(bclist, key = lambda x:x[1], reverse=True)

all = []


for i in range(m):
    all.extend([bclist[i][1]]*bclist[i][0])
    if len(all) >n:
        break

all.extend(a)
all.sort(reverse=True)

print(sum(all[:n]))
A, B = input().split()
A = int(A)
B = int(B * 100)
print(A*B//100)

### FIXED CODE ###

A, B = input().split()
A = int(A)
B = round(float(B) * 100)
print(A*B//100)
S = str(input())
day_list = ["MON", "TUE", "WED", "THU", "FRI", "SAT"]
if S == "SUN":
  print(7)
else:
  ind = day_list.index(S)
  printt(6-ind)

### FIXED CODE ###

S = input()
day_list = ["MON", "TUE", "WED", "THU", "FRI", "SAT"]
if S == "SUN":
  print(7)
else:
  ind = day_list.index(S)
  print(6-ind)
N = int(intput())
if N == 1:
  print(1)
  exit()
X = [2, 4, 8, 16, 32, 64, 128]
for i, x in enumerate(X):
  if N < x:
    print(X[i - 1])


### FIXED CODE ###

N = int(input())
if N == 1:
    print(1)
    exit()
X = [2, 4, 8, 16, 32, 64, 128]
for i, x in enumerate(X):
    if N < x:
        print(X[i - 1])
        exit()
from collections import Counter
n = input()
s = [input() for _ in range(n)]
s = Counter(s)
m = max(s.values())

a = []
for d in s.items():
    if d[1] == m:
        a.append(d[0])
for s in a:
    print(s)

### FIXED CODE ###

from collections import Counter
n = int(input())
s = [input() for _ in range(n)]
s = Counter(s)
m = max(s.values())

a = []
for d in s.items():
    if d[1] == m:
        a.append(d[0])
for s in sorted(a):
    print(s)
n = int(input())
a = list(map(int, input().split()))
odds = 0
evens2 = 0
evens4 = 
for ai in a :
    if ai % 4 == 0 :
        evens4 += 1
    elif ai % 2 == 0 :
        evens2 += 1
    else :
        odds += 1

if evens4 >= odds :
    print('Yes')
elif odds - evens4 == 1 and evens2 == 0 :
    print('Yes')
else :
    print('No')

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
odds = 0
evens2 = 0
evens4 = 0
for ai in a :
    if ai % 4 == 0 :
        evens4 += 1
    elif ai % 2 == 0 :
        evens2 += 1
    else :
        odds += 1

if evens4 >= odds :
    print('Yes')
elif odds - evens4 == 1 and evens2 == 0 :
    print('Yes')
else :
    print('No')
import string
import itertools
n = int(input())
l = list(string.ascii_lowercase)
count = 1
for i in range(1, 100):
    n -= 26 ** i
    if n <= 0:
        break
    else:
        count += 1
n_list = []
answer = []
for i in reversed(range(count)):
    number = n // 26 ** i
    n %= 26 ** i
    n_list.append(number)
for i in n_list:
    answer.append(l[i-1])
print(''.join(answer))


### FIXED CODE ###

import string
import itertools
n = int(input())
s = n
l = list(string.ascii_lowercase)
count = 1
for i in range(1, 100):
    s -= 26 ** i
    if s <= 0:
        break
    else:
        count += 1
n_list = []
answer = []
for i in reversed(range(1, count+1)):
    number = min(26, n // 26 ** (i-1))
    n -= number * 26 ** (i-1)
    n_list.append(number)
n_l = []
for i, x in  enumerate(reversed(n_list)):
    if x <= 0:
        n_l.append(x + 26)
        n_list[-(i+2)] -= 1
    else:
        n_l.append(x)
for i in reversed(n_l):
    answer.append(l[i-1])
print(''.join(answer))
s=list(input())
a=[0]*(len(s)+1)
if s[0]=='<':
    a[0]=0
    l=0
    while s[l]=='<':
        a[l+1]=a[l]+1
        l+=1
if s[len(s)-1]=='>':
    a[len(s)]=0
    m=len(s)-1
    while s[m]=='>':
        a[m]=a[m+1]+1
        m-=1
for i in range(len(s)-1):
    if s[i]=='>' and s[i+1]=='<':
        a[i+1]=0
        k=i
        t=i+1
        while s[k]=='>':
            a[k]=a[k+1]+1
            k-=1
            if k<0 or k>len(s)-1 or s[k]=='<':
                break
        while s[t]=='<':
            a[t+1]=a[t]+1
            t+=1
            if t<0 or t>len(s)-1 or s[t]=='>':
                break
for i in range(len(s)-1):
    if s[i]=='<' and s[i+1]=='>':
        a[i+1]=max(a[i],a[i+2])+1
print(sum(a))

### FIXED CODE ###

s=list(input())
a=[0]*(len(s)+1)
if s[0]=='<':
    a[0]=0
    l=0
    while s[l]=='<':
        a[l+1]=a[l]+1
        l+=1
        if l>len(s)-1:
          break
if s[len(s)-1]=='>':
    a[len(s)]=0
    m=len(s)-1
    while s[m]=='>':
        a[m]=a[m+1]+1
        m-=1
        if m<0:
          break
for i in range(len(s)-1):
    if s[i]=='>' and s[i+1]=='<':
        a[i+1]=0
        k=i
        t=i+1
        while s[k]=='>':
            a[k]=a[k+1]+1
            k-=1
            if k<0 or k>len(s)-1:
                break
        while s[t]=='<':
            a[t+1]=a[t]+1
            t+=1
            if t<0 or t>len(s)-1:
                break
for i in range(len(s)-1):
    if s[i]=='<' and s[i+1]=='>':
        a[i+1]=max(a[i],a[i+2])+1
print(sum(a))
#D - Div Game
N = int(input())

def Prime_factorize(n):
    cnt = 0
    A = []
    #2の倍数で割っていく
    z = 2
    while n%z==0 and (n>=z):
        cnt += 1
        n //= z
        A.append(z)
        #割るたびに2倍
        z *= 2
    #割る始めの数をfとして保持
    while n%2 == 0:
        n//=2
    f = 3
    z = 3
    #sqrt(n)以内に全ての素因数は含まれる
    while f*f <= n:
        if n%z == 0:
            cnt += 1
            n //= z
            A.append(z)

            #割るたびにf倍
            z = z*f
        #fで割り切れなかったら(f+2)してf_divもリセット
        else:
            f += 2
            z = f

    #残ったnが以前に選んだもので割り切れないとき
    if n != 1 and all((n%i != 0 for i in A)):
        A.append(z)
        cnt += 1
    #素数のとき
    if cnt == 0:
        cnt = 1
    return cnt
if N == 1:
    ans = 0
else:
    ans = Prime_factorize(N)
print(ans)

### FIXED CODE ###

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

print(A*B)
from collections import deque
from heapq import heappush,heappop
import re
def int_raw():
    return int(input())

def ss_raw():
    return input().split()

def ints_raw():
    return list(map(int, ss_raw()))

INF = 1<<29

def getDeci(tree):
    def saiki(p,v):
        ans = [0,v]
        for e in tree[v]:
            if e ==p:
                continue
            tmp = saiki(v,e)
            tmp[0]=tmp[0]+1
            if ans[0]<tmp[0]:
                ans = tmp
        return ans
    leaf = saiki(-1,0)
    ans = saiki(-1,leaf[1])
    return ans

    
N = int_raw()
tree = [[] for _ in range(N)]
for _ in range(N-1):
    a,b = ints_raw()
    a = a-1
    b = b-1
    tree[a].append(b)
    tree[b].append(a)



def main():
    ans = getDeci(tree)
    if (ans[0]+2)%3==0:
        return "Second"
    else:
        return "First"

print(main())


### FIXED CODE ###

from collections import deque
from heapq import heappush,heappop
import re
def int_raw():
    return int(input())

def ss_raw():
    return input().split()

def ints_raw():
    return list(map(int, ss_raw()))

INF = 1<<29

def getDeci(tree):
    def saiki(v):
        root = [0,v,-1]
        cur = None
        qu = deque()
        qu.append(root)
        while len(qu)!=0:
            cur = qu.popleft()
            for e in tree[cur[1]]:
                if e ==cur[2]:
                    continue
                qu.append([cur[0]+1,e,cur[1]])
        return cur
    leaf = saiki(0)
    ans = saiki(leaf[1])
    return ans

    
N = int_raw()
tree = [[] for _ in range(N)]
for _ in range(N-1):
    a,b = ints_raw()
    a = a-1
    b = b-1
    tree[a].append(b)
    tree[b].append(a)



def main():
    ans = getDeci(tree)
    if (ans[0]+2)%3==0:
        return "Second"
    else:
        return "First"

print(main())
while True:
    H, W = map(int, raw_input().split()
    if H == W == 0:
        break
    for i in range(H):
        print "#" * W
    print


### FIXED CODE ###

while True:
    H, W = map(int, input().split())
    if H == W == 0:
        break
    for i in range(H):
        print("#"*W)
    print()
import numpy as np

n_ID, n_gates = [int(data) for data in input().split()]
L = np.empty(n_gates, dtype = int)
R = np.empty(n_gates, dtype = int)

for i in range(n_gates):
  L[i], R[i] = [int(data) for data in input().split()]

ID_gate_matrix = np.zeros((n_ID, n_gates))

for j in range(n_gates):
  for i in range(L[j] - 1, R[j]):
    ID_gate_matrix[i][j] = 1

Card_Counter = 0
for i in range(n_ID):
  for j in range(n_gates):
    if ID_gate_matrix[i][j] != 1:
      break
  else:
    Card_Counter += 1

print(Card_Counter)

### FIXED CODE ###

age, cost = [int(x) for x in input().split()]

if age <= 5:
  print(0)
elif age <= 12:
  print(int(cost / 2))
else:
  print(cost)
#print#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code
from collections import Counter
def resolve():
    A,B,C,K=pin()
    for i in range(K)
        x,y,z=B+C,C+A,A+B
        A,B,C=x,y,z
    t=(A-B)
    if abs(t)>10**18:print("Unfair");return
    print(t)
    
#%%submit!    
resolve()

### FIXED CODE ###

#print#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code
from collections import Counter
def resolve():
    A,B,C,K=pin()
    
    k=K%2
    t=(A-B)
    if abs(t)>10**18:print("Unfair");return
    if k%2:t=(-1)*t
    print(t)
    #print(A,B,C)


#%%submit!
resolve()
e=int(input())
sum=1
for i in e:
  sum*=i**e
print(sum)

### FIXED CODE ###

print(int(input())**3)
import sys

def main():
    input = sys.stdin.readline
    N, K = map(int, input().split())
    ans = 0
    if K == 0:
        print(N * N)
        break
    for i in range(1, N+1):
        if i <= K:
            continue
        if N % i < K:
            ans += (N // i) * (i - K)
        else:
            ans += (N // i ) * (i - K) + (N % i - K + 1)
    print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys

def main():
    input = sys.stdin.readline
    N, K = map(int, input().split())
    ans = 0
    if K == 0:
        print(N * N)
        return 0
    for i in range(1, N+1):
        if i <= K:
            continue
        if N % i < K:
            ans += (N // i) * (i - K)
        else:
            ans += (N // i ) * (i - K) + (N % i - K + 1)
    print(ans)


if __name__ == '__main__':
    main()
S=map(str,input())
if "A" in S:
    print("Yes")
elif :
    S="AAA"
else :
    print("No")

### FIXED CODE ###





s = input()

if s == 'AAA' or s == 'BBB':
  print('No')
else:
  print('Yes')
from sys import exit
def groupby(a):
    a2=[[a[0],1]]
    for i in range(1,len(a)):
        if a2[-1][0]==a[i]:
            a2[-1][1]+=1
        else:
            a2.append([a[i],1])
    return a2

n,k=map(int,input().split())
s=list(input())
x=groupby(s)
l=len(x)
y=[x[i][1] for i in range(l)]
if x[0][0]=="1":
    su=sum(y[:2*k+1])
    ans=su
    l_sub=(l-(2*k+1))//2
    for i in range(l_sub):
        su-=y[2*i]
        su-=y[2*i+1]
        su+=y[2*k+1+(2*i)]
        su+=y[2*k+1+(2*i+1)]
        ans=max(su,ans)
    if l%2==0:
        su-=y[2*l_sub]
        su+=y[2*k+1+2*i]
        ans=max(su,ans)
    print(ans)
else:
    su=sum(y[:2*k])
    ans=su
    y.pop(0)
    l-=1
    l_sub=(l-(2*k+1))//2
    for i in range(l_sub):
        su-=y[2*i]
        su-=y[2*i+1]
        su+=y[2*k+1+(2*i)]
        su+=y[2*k+1+(2*i+1)]
        ans=max(su,ans)
    if l%2==0:
        su-=y[2*l_sub]
        su+=y[2*k+1+2*l_sub]
        ans=max(su,ans)
    print(ans)


### FIXED CODE ###

from sys import exit
def groupby(a):
    a2=[[a[0],1]]
    for i in range(1,len(a)):
        if a2[-1][0]==a[i]:
            a2[-1][1]+=1
        else:
            a2.append([a[i],1])
    return a2

n,k=map(int,input().split())
s=list(input())
x=groupby(s)
l=len(x)
y=[x[i][1] for i in range(l)]

if x[0][0]=="0":
    su=sum(y[:2*k])
    ans=su
    y.pop(0)
    l-=1
else:
    ans=0
su=sum(y[:2*k+1])
ans=max(ans,su)
l_sub=(l-(2*k+1))//2
if l_sub<=0:
    print(ans)
    exit()
for i in range(l_sub):
    su-=y[2*i]
    su-=y[2*i+1]
    su+=y[2*k+1+(2*i)]
    su+=y[2*k+1+(2*i+1)]
    ans=max(su,ans)
#最後のところの判定っぽいな
if 2*k+1+2*l_sub<l:
    su-=y[2*l_sub]
    su-=y[2*l_sub+1]
    su+=y[2*k+1+2*l_sub]
    ans=max(su,ans)
print(ans)
n = int(input())

x = n 
nums = []
ans = ''
for i in range(1, 11):
    if 26**i >= n:
        for _ in range(i):
            print(x, x%26)
            x -= 1
            l = x % 26
            x //=  26
            nums.append(l)
        break
    else:
        n -= 26**i
        
for _ in nums:
    ans +=(chr(ord('a') + _))
    
print(ans[::-1]) 

### FIXED CODE ###

n = str(input())
if n.islower():
    print('a')
else:
    print('A')
[A,B,C,N]=[int(i) for i in input().split()]
[C,B,A]=[A,B,C].sort()
cnt=0
for i in range(N//A):
  k=N-(i*A)
  for j in range(k//B):
    if (k-(B*A))%C==0:cnt+=1
print(cnt)

### FIXED CODE ###

[A,B,C,N]=[int(i) for i in input().split()]
X=[A,B,C]
X.sort()
[C,B,A]=X
cnt=0
for i in range(N//A+1):
  k=N-(i*A)
  for j in range(k//B+1):
    if (k-(B*j))%C==0:
    	cnt+=1
print(cnt)
# -*- coding: utf-8 -*-
# from collections import deque
import bisect

N, M = map(int, input().split())
A_list = list(map(int, input().split()))
A_list.sort()
# A_list = deque(A_list)

ans = 0
ans += sum(A_list[0:N - M])
del(A_list[0:N - M])
for i in range(M):
    max_price = A_list.pop()
    bisect.insort(A_list, max_price // 2)
    ans += A_list[0]
    del(A_list[0])
    

ans += sum(A_list)
print(ans)

### FIXED CODE ###

# D 終了後再チャレンジ
# -*- coding: utf-8 -*-
import heapq

N, M = map(int, input().split())
A_list = list(map(int, input().split()))
A_list = [-a for a in A_list]
heapq.heapify(A_list)

for i in range(M):
    max_price = heapq.heappop(A_list) * (-1)
    heapq.heappush(A_list, max_price // 2 * (-1))
    
ans = sum(A_list) * (-1)
print(ans)
import math

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

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

print(lcm(A, B))

### FIXED CODE ###

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

def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)

def lcm(x, y):
    return (x * y) // gcd(x, y)

print(lcm(A, B))
import math
import sys

n,p=map(int,input().split())
a=math.sqrt(P)

def C(N,P):
    if N == 1: return P

    if N >= 4 :
        a=math.sqrt(a)
    if N >= 8 :
        a=math.sqrt(a)
    if N >= 16 :
        a=math.sqrt(a)
    if N >= 32 :
        a=math.sqrt(a)
    if N >= 64 :
        a=math.sqrt(a)
    if N >= 128 :
        a=math.sqrt(a)
    if N >= 256 :
        a=math.sqrt(a)
    if N >= 512 :
        a=math.sqrt(a)
    if N >= 1024 :
        a=math.sqrt(a)
    if N >= 2048 :
        a=math.sqrt(a)
    
    res=1

    for i in range(1,int(a)+2):
        if P % i**N: continue
        res = i
        
    return res

print(C(n,p))

### FIXED CODE ###

n,p = list(map(int,input().split())) 
i = a = o = 1
m = round(p**(1/n))
for i in range(m,0,-1):
    a = i**n
    if p%a==0:
        print(i)
        exit()
n=int(input())
A=list(map(int,input().split()))
a=False
count=0

while True:
  for i in range(n):
    if A[i]%2==1:
      a=True
      break
    A[i]//=2
  if a=True:
    break    
  else:
    count+=1
  
print(count)

### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))
cnt=0

while all(i%2==0 for i in A):
  A=[i//2 for i in A]
  cnt+=1
print(cnt)
#!/usr/bin/python3
# -*- coding:utf-8 -*-

from math import floor

def main():
  n = int(input())
  la = list(map(int, input().split()))
  la = [a-i for i, a in enumerate(la, 1)]
  ix = len(la) // 2
  print(min([sum(map(lambda x: abs(x-la[ix+i]), la)) for i in range(2)]))

if __name__=='__main__':
  main()



### FIXED CODE ###

#!/usr/bin/python3
# -*- coding:utf-8 -*-

from math import floor

def main():
  n = int(input())
  la = list(map(int, input().split()))
  la = [a-i for i, a in enumerate(la, 1)]
  la.sort()
  if len(la) == 1:
    print(0)
  else:
    ix = (len(la)-1) // 2
    print(min([sum(map(lambda x: abs(x-la[ix+i]), la)) for i in range(2)]))

if __name__=='__main__':
  main()
a,b = map(int(input().split())

c=(-((-a)//(2*b+1)))
print(c)

### FIXED CODE ###

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

print(-((-a)//(2*b+1)))
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
cum_a = [0]*(n+1)
for i, v in enumerate(a):
    cum_a[i+1] = cum_a[i]+a[i]
cum_b = [0]*(m+1)
for i, v in enumerate(b):
    cum_b[i+1] = cum_b[i]+b[i]
cum_b = [i for i in cum_b if i <= k]
cum_a = [i for i in cum_a if i <= k]
n = len(cum_a)-1
m = len(cum_b)-1
a_idx = n
b_idx = 0
res = 0
for i in range(n+1):
    current_a_idx = a_idx-i
    sum_a = cum_a[current_a_idx]
    if sum_a > k:
        continue
    sum_b = cum_b[b_idx]
    while sum_a+sum_b <= k and b_idx < m:
        b_idx += 1
        sum_b = cum_b[b_idx]
        if sum_a + sum_b > k:
            b_idx -= 1
            break
    res = max(b_idx+current_a_idx, res)
a_idx = 0
b_idx = m
for i in range(n+1):
    current_b_idx = b_idx-i
    sum_b = cum_b[current_b_idx]
    if sum_b > k:
        continue
    sum_a = cum_a[a_idx]
    while sum_a+sum_b <= k and a_idx < n:
        a_idx += 1
        sum_a = cum_a[a_idx]
        if sum_a + sum_b > k:
            a_idx -= 1
            break
    res = max(current_b_idx+a_idx, res)


print(res)



### FIXED CODE ###

n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
cum_a = [0] * (n + 1)
for i, v in enumerate(a):
    cum_a[i + 1] = cum_a[i] + a[i]
cum_b = [0] * (m + 1)
for i, v in enumerate(b):
    cum_b[i + 1] = cum_b[i] + b[i]

a_idx = n
b_idx = 0
res = 0
for i in range(n + 1):
    current_a_idx = a_idx - i
    sum_a = cum_a[current_a_idx]
    if sum_a > k:
        continue
    sum_b = cum_b[b_idx]
    while sum_a + sum_b <= k and b_idx < m:
        b_idx += 1
        sum_b = cum_b[b_idx]
        if sum_a + sum_b > k:
            b_idx -= 1
            break
    res = max(b_idx + current_a_idx, res)
a_idx = 0
b_idx = m
for i in range(m + 1):
    current_b_idx = b_idx - i
    sum_b = cum_b[current_b_idx]
    if sum_b > k:
        continue
    sum_a = cum_a[a_idx]
    while sum_a + sum_b <= k and a_idx < n:
        a_idx += 1
        sum_a = cum_a[a_idx]
        if sum_a + sum_b > k:
            a_idx -= 1
            break
    res = max(current_b_idx + a_idx, res)

print(res)
N,A,B,C=[input() for i in range(4)]
ans=0
for i in range(N):
    if A[i]!=B[i] and A[i]!=C[i] and B[i]!=C[i]:
        ans+=2
    elif A[i]!=B[i] or A[i]!=C[i]:
        ans+=1
print(ans)

### FIXED CODE ###

N=int(input())
A,B,C=[input() for i in range(3)]
ans=0
for i in range(N):
    if A[i]!=B[i] and A[i]!=C[i] and B[i]!=C[i]:
        ans+=2
    elif A[i]!=B[i] or A[i]!=C[i]:
        ans+=1
print(ans)
#n=int(input())
#n,m=list(map(int,input().split()))
#a=list(map(int,input().split()))
import math
import itertools
from collections import defaultdict
from collections import Counter
import numpy as np

import heapq
a,b=list(map(int,input().split()))
ans=[False for _ in range(a)]
t=0
for i in range(a):
    if ans[i]:
        continue
    t+=1
    n=i+1
    ans[i+t]=True
    print(n,n+t)
    if t==b:
        exit()
    


### FIXED CODE ###

#n=int(input())
#n,m=list(map(int,input().split()))
#a=list(map(int,input().split()))
import math
import itertools
from collections import defaultdict
from collections import Counter
import numpy as np

import heapq
a,b=list(map(int,input().split()))
b_i=a
a_i=1
for i in range(b,0,-1):
    if i%2==1:
        print(b_i-i,b_i)
        b_i-=1

    else:
        print(a_i,a_i+i)
        a_i+=1
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()])

def max_n_book(desk_a, desk_b, count=0, k=K):
    if k < 0:
        return count - 1
    if len(desk_a) != 0:
        book_a = desk_a.popleft()
        count_a = max_n_book(desk_a, desk_b, count=count+1, k=k-book_a)
    else:
        count_a = count
    if len(desk_b) != 0:
        book_b = desk_b.popleft()
        count_b = max_n_book(desk_b, desk_b, count=count+1, k=k-book_b)
    else:
        count_b = count
    return max(count_a, count_b)

n_book = max_n_book(desk_a, desk_b, count=0, k=K)
print(n_book)


### FIXED CODE ###

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

sum_a = [0]
sum_b = [0]

for i in range(N):
    sum_a.append(sum_a[-1] + desk_a[i])
for i in range(M):
    sum_b.append(sum_b[-1] + desk_b[i])

ans = 0
j = M
for i in range(N+1): 
    a = sum_a[i]
    if K - a < 0:
        break
    while sum_b[j] > K - a: 
        j -= 1
    ans = max(ans, i+j)

print(ans)