Harryxun/stf_run huggingface dataset:
X, Y, A, B, C = list(map(int,input().split()))
p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))
 
p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)
 
Z = 0
while True:
  if p[X - 1] < r[Z]:
    X -= 1
    Z += 1
  else if q[Y - 1] < r[Z]:
    Y -= 1
    Z += 1
  else:
    break
 
print(sum(p[:X]) + sum(q[:Y]) + sum(r[:Z]))

### FIXED CODE ###

X, Y, A, B, C = list(map(int,input().split()))
p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))
 
p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)
 
p.append(float("inf"))
q.append(float("inf")) 

Z = 0
while Z < C:
  if min(p[X - 1], q[Y - 1]) < r[Z]:
    if p[X - 1] < q[Y - 1]:
      X -= 1
      Z += 1
    else:
      Y -= 1
      Z += 1
    continue
  break
 
print(sum(p[:X]) + sum(q[:Y]) + sum(r[:Z]))
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

string s,t;
int i;

int main(){
    cin >> s;
    cin >> t;

    s = s + s;
    if(s.find(t) != s.npos){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    
    return 0;
}

### FIXED CODE ###

s = str(input())
t = str(input())
for i in range(len(s)):
  if s == t:
    print("Yes")
    exit()
  nu = t[-1]
  t = nu+t[:-1]
print("No")
X = int(input())

if X >= 0 and X <= 10 ** 9:
    while True:
        if X > 500:
            C = X // 500
            P = 500 * C
            X = X - P
            continue
        if X > 5:
            D = X // 5
            L = 5 * D
            X = X - L
            continue
        break

total = (1000 * C) + (5 * D)

print(total)

### FIXED CODE ###

X = int(input())

C = 0
P = 0
D = 0
L = 0
total = 0

if X >= 0 and X <= 10 ** 9:
    while True:
        if X >= 500:
            C = X // 500
            P = 500 * C
            X = X - P
        elif X >= 5:
            D = X // 5
            L = 5 * D
            X = X - L
        else:
            break
man = 1000 * C
t   = 5 * D

total = man + t

print(total)
test = input().split(" ")
if int(test[0])== int(test[1]):
  print("Yes")
else
 print("No")

### FIXED CODE ###

test = input().split(" ")
if int(test[0])== int(test[1]):
	print("Yes")
else:
	print("No")
A = list(map(int, input().split())).sorted
print(A[2] - A[0])

### FIXED CODE ###

A = list(map(int, input().split()))
A.sort()
print(A[2] - A[0])
N,K,*A = map(int, open(0).read().split())
n = len(A)

def left(i, d):
    if not (0 <= i < n):
        return 0
    v = A[i] - d + 0.5
    if v <= 0:
        return 0 + left(i - 1, d + 1)
    else:
        return 1 + left(i - 1, d + 1)

def right(i, d):
    if not (0 <= i < n):
        return 0
    v = A[i] - d + 0.5
    if v <= 0:
        return 0 + right(i + 1, d + 1)
    else:
        return 1 + right(i + 1, d + 1)

for _ in range(K):
    X = [0 for _ in range(n)]
    for i in range(n):
        l = left(i-1, 1)
        r = right(i+1, 1)
        v = 1 if i < N else 0
        c = v + l + r
        X[i] = c
    if A == X:
        print(" ".join(map(str, A)))
        exit(0)
    A = X

print(" ".join(map(str, A)))

### FIXED CODE ###

N,K,*A = map(int, open(0).read().split())
                                         
for _ in range(K):                       
    b = [0] * N                          
    for i, d in enumerate(A):            
        b[max(0, i-d)] += 1              
        if i+d+1 < N:                    
            b[i+d+1] -= 1                
    for i in range(1, N):                
        b[i] += b[i-1]                   
    if A == b:                           
        break                            
    A = b                                
                                         
print(" ".join(map(str, A)))
dp={}
#これからかかる分のコストを計算
def dfs(pos,n,h):
    if pos >= n:
        return 999999999
    if pos == n-1:
        return 0
    if pos in dp:
        return dp[pos]
    step1 = dfs(pos+1,n,h) + abs(h[pos+1] - h[pos])
    step2 = dfs(pos+2,n,h) + abs(h[pos+2] - h[pos])
    dp[pos] = min(step1, step2)
    return dp[pos]

if __name__=="__main__":
    n = int(input())
    h = list(map(int, input().split()))
    h.append(0)
    print(dfs(0,n,h))

### FIXED CODE ###

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

dp=[0]
dp.append(abs(h[1]-h[0]))

for i in range(2,n):
    step1=dp[i-1]+abs(h[i]-h[i-1])
    step2=dp[i-2]+abs(h[i]-h[i-2])
    dp.append(min(step1,step2))
print(dp[-1])
N = int(input())
S = [input() for i in range(N)]
C = dict()


for i in range(N):
    a = input()
    if(a not in C.keys()):
        C[a] = 1
    else:
        val = C[a]
        C[a] = val + 1

maxv=0
for i in C.values():
    if(i > maxv):
        maxv=i

ans = sorted(C.items())
for i  in ans:
    if(maxv==i[1]):
        print(i[0])

### FIXED CODE ###


N = int(input())
C = dict()


for i in range(N):
    a = input()
    if(a not in C.keys()):
        C[a] = 1
    else:
        val = C[a]
        C[a] = val + 1

m=0
for i in C.values():
    if(i > m):
        m=i

ans = sorted(C.items())
for i  in ans:
    if(m==i[1]):
        print(i[0])
import collections
n = int(input())
v = list(map(int,input().split()))
ve = [v[2*i] for i in range(n//2)]
vo = [v[2*i + 1] for i in range(n//2)]
Cve = collections.Counter(ve)
Cvo = collections.Counter(vo)
Cve1 = Cve.most_common()[0]
Cvo1 = Cvo.most_common()[0]

# eとoが1種しか数字をもたない
if len(Cve) == 1 and len(Cvo) == 1:
    if Cve1[0] == Cvo1[0]:
        ans = n//2 - Cvo1[1]
    else:
        ans = 0
elif len(Cve) == 1 and len(Cvo) != 1:
    Cvo2 = Cvo.most_common()[1]
    if Cve1[0] == Cvo1[0]:
        ans = n//2 - Cvo2[1]
    else:
        ans = n//2 - Cvo1[1]

elif len(Cve) != 1 and len(Cvo) == 1:
    Cve2 = Cve.most_common()[1]
    if Cve1[0] == Cvo1[0]:
        ans = n//2 - Cve2[1]
    else:
        ans = n//2 - Cve1[2]
else:
    Cve2 = Cve.most_common()[1]
    Cvo2 = Cvo.most_common()[1]

    if Cve1[0] != Cvo1[0]:
        ans = n - Cve1[1] - Cvo1[1] 
    if Cve1[0] == Cvo1[0]:
        if Cve1[1] > Cvo1[1]:
            ans = n - Cve1[1] - Cvo2[1]
        else:
            an

### FIXED CODE ###

import collections
n = int(input())
v = list(map(int,input().split()))
ve = [v[2*i] for i in range(n//2)]
vo = [v[2*i + 1] for i in range(n//2)]
Cve = collections.Counter(ve)
Cvo = collections.Counter(vo)
Cve1 = Cve.most_common()[0]
Cvo1 = Cvo.most_common()[0]
if len(Cve) == 1 and len(Cvo) == 1: #eo両方1種類
    if Cve1[0] == Cvo1[0]: ans = n//2 #eo top同じ
    else: ans = 0 #eo異なる
elif len(Cve) == 1 and len(Cvo) > 1: #eのみ1種類
    Cvo2 = Cvo.most_common()[1]
    if Cve1[0] == Cvo1[0]: ans = n//2 - Cvo2[1] #eo top同じ
    else: ans = n//2 - Cvo1[1] #eo top異なる
elif len(Cve) > 1 and len(Cvo) == 1: #oのみ1種類
    Cve2 = Cve.most_common()[1]
    if Cve1[0] == Cvo1[0]: ans = n//2 - Cve2[1] #eo top同じ
    else: ans = n//2 - Cve1[1] #eo top異なる
else:
    Cve2 = Cve.most_common()[1]
    Cvo2 = Cvo.most_common()[1]
    if Cve1[0] != Cvo1[0]: ans = n - Cve1[1] - Cvo1[1] #top異なる
    if Cve1[0] == Cvo1[0]:
        if Cve1[1] < Cvo1[1]: ans = n - Cve2[1] - Cvo1[1]
        elif Cve2[1] > Cvo2[1] : ans = n - Cve2[1] - Cvo1[1]
        else: ans = n - Cve1[1] - Cvo2[1]
print(ans)
#coding:utf-8
n, d = map(int, input().split())

flag = [0] * n
people = 0

for i in range(0,d):
    flag[i] = 1

for i in range(n-d, n):
    flag[i] = 1

#print(flag)

for i in range(d, n):
    if flag[i] == 0:
        people += 1
        #print(i)
        for j in range(i, i+d+1):
            if j > n-d:
                break 
            else:
                flag[j] = 1
        #print(flag)


#print(flag)
print(people)


### FIXED CODE ###

#coding:utf-8
n, d = map(int, input().split())

#監視員は2D+1本の木を監視する
#最小の監視員はN/2D+1 の切り上げ
print(-(-n // (2*d + 1)))
dr ="dream" 
dre = "dreamer" 
er ="erase" 
ere = "eraser" 
a = input()
ret = "YES"
while len(a) != 0:
    if (a.endswith(dr) or a.endswith(er)):
        a = a[:len(a)-5]
    elif(a.endswith(dre) ):
        a = a[:len(a)-7]
	elif(a.endswith(ere)):
        a = a[:len(a)-6]
    else:
        ret = "NO"
        break
        
print(ret)


### FIXED CODE ###

a = input()
if( a== "a" or a=="i" or a=="u" or a=="e" or a=="o" ):
    print("vowel")
else:
    print("consonant")
s = input()
sum_ = 0
if s[0] == 'R':
  sum_ += 1
  if s[1] == 'R':
    sum_ += 1
    if s[2] == 'R':
      sum_ += 1
  else:
    sum_ = 1
else:
  if s[1] == 'R':
    sum_ += 1
    if s[2] == 'R':
      sum_ += 1
  else:
    s[2] == 'R':
      sum_ = 1
print(sum_)

### FIXED CODE ###

s = input()
sum_ = 0
if s[0] == 'R':
  sum_ += 1
  if s[1] == 'R':
    sum_ += 1
    if s[2] == 'R':
      sum_ += 1
  else:
    sum_ = 1
else:
  if s[1] == 'R':
    sum_ += 1
    if s[2] == 'R':
      sum_ += 1
  else:
    if s[2] == 'R':
      sum_ = 1
print(sum_)
a = int(input())
i=0
sum=0
for i<len(a):
  if str(a)[i]==1:
    sum=sum+1
  i=i+1
  
print(sum)

### FIXED CODE ###

a = int(input())
i=0
sum=0
while i<len(str(a)):
  if str(a)[i]=="1":
    sum=sum+1
  i=i+1
  
print(sum)
import sys

dishes = [int(line.strip()) for line in sys.stdin]
min1 = None
for d in dishes:
  if 0 < d%10 < min1:
    min1 = d%10
if not min1:
  min1 = 0
    
dishes = [((d+9)//10)*10 for d in dishes]
print(sum(dishes)-(10-min1))


### FIXED CODE ###

import sys

dishes = [int(line.strip()) for line in sys.stdin]
min1 = 10
for d in dishes:
  if 0 < d%10 < min1:
    min1 = d%10
if min1 == 0:
  min1 = 10
dishes = [((d+9)//10)*10 for d in dishes]
print(sum(dishes)-(10-min1))
n = int(input())
a = list(map(int, input().split()))

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

memo = {}
def doit(i, f):
    if i == len(a) - 1:
        return a[i]
    if not (i, f) in memo:
        ret = gcd(a[i], doit(i + 1, f))
        if f == 0:
            ret = max(ret, doit(i + 1, 1))
        memo[(i, f)] = ret
    return memo[(i, f)]

print(doit(0, 0))

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
def gcd(a, b):
    return b if a == 0 else gcd(b % a, a)
l = [0]
r = [0]
for i in range(n):
    l.append(gcd(l[-1], a[i]))
    r.append(gcd(r[-1], a[n - i - 1]))
ret = 0
for i in range(n):
    ret = max(ret, gcd(l[i], r[n - i - 1]))
print(ret)
i = map(int, raw_input().split()).sort()
for x in i:
	print x,
print ""

### FIXED CODE ###

s = map(int, raw_input().split())
s.sort()
print ' '.join(map(str, s))
# -*- coding: utf-8 -*-
import math

N = int(input())
# print(N)
ai = input().split(' ')
# print(ai)
num = 0
for i in range(math.floor(N/2) + 1):
    if int(ai[i*2]) % 2 == 1:
        # print('asd' + str(i))
        # print('hoge' + str(ai[i*2]))
        num += 1

print(num)

### FIXED CODE ###

# -*- coding: utf-8 -*-
import math

N = int(input())
# print(N)
ai = input().split(' ')
# print(ai)
num = 0
for i in range(N):
    if i % 2 == 0:
        if int(ai[i]) % 2 == 1:
            # print('asd' + str(i))
            # print('hoge' + str(ai[i*2]))
            num += 1

print(num)
from collections import defaultdict

S = input()
K = int(input())

alphabet = defaultdict(list)
for i, s in enumerate(S):
    alphabet[s].append(i)

alpha_list = sorted(alphabet.keys())
cand = []
i = 0
while len(cand) < K:
    for j in alphabet[alpha_list[i]]:
        for l in range(1, len(S)-j+1):
            cand.append(S[j:j+l])
    cand = list(set(cand))
    if len(cand) < K:
        break
    i += 1
cand = sorted(cand)
print(cand[K-1])

### FIXED CODE ###

# ABC 097 C

from collections import defaultdict

S = input()
K = int(input())

alphabet = defaultdict(list)
for i, s in enumerate(S):
    alphabet[s].append(i)

alpha_list = sorted(alphabet.keys())
cand = []
i = 0
while len(cand) < K:
    for j in alphabet[alpha_list[i]]:
        if len(S)-j+1 >= K:
            for l in range(1, K+1):
                cand.append(S[j:j+l])
        else:
            for l in range(1, len(S)-j+1):
                cand.append(S[j:j+l])
    cand = list(set(cand))
    if len(cand) >= K:
        break
    i += 1
cand = sorted(cand)
print(cand[K-1])
N,M = map(int,input().split())
graph = [[] for i in range(10**5 + 10)]
dp = [-1 for i in range(10**5 + 10)]

for i in range(M):
    x,y = map(int,input().split())
    graph[x-1].append(y-1)
    
def rec(v):
    if dp[v] != -1:
        return dp[v]
    tmp = 0
    for x in graph[v]:
        r = rec(x)+1
        if tmp < r:
            tmp = r
    dp[v] = tmp
    return dp[v]

result = 0
for i in range(N):
    r = rec(i)
    result = r if r>result else result
print(result)

### FIXED CODE ###

import sys
sys.setrecursionlimit(100000)
N,M = map(int,input().split())
graph = [[] for i in range(10**5 + 10)]
dp = [-1 for i in range(10**5 + 10)]

for i in range(M):
    x,y = map(int,input().split())
    graph[x-1].append(y-1)
    
def rec(v):
    if dp[v] != -1:
        return dp[v]
    tmp = 0
    for x in graph[v]:
        r = rec(x)+1
        if tmp < r:
            tmp = r
    dp[v] = tmp
    return dp[v]

result = 0
for i in range(N):
    r = rec(i)
    result = r if r>result else result
print(result)
a,b=map(str, input().split())

if (a="H" and b="H") or (a="D" and b="D"):
    print("H")
else:
    print("D")


### FIXED CODE ###

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

if (a=="H" and b=="H") or (a=="D" and b=="D"):
    print("H")
else:
    print("D")
n = int(input())
v = list(map(int, input().split()))

v1 = v.sort().reverse()
k = 0

for i in range(n):
  k += v[i] * (2 ** ( - (i + 1)))

print(k + v[n] * (2 ** ( - (n + 1)))

### FIXED CODE ###

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

v1 = list(sorted(v))
v2 = list(reversed(v1))
k = 0

for i in range(n):
  k += v2[i] * (2 ** ( -i - 1))

k += v2[n - 1] * (2 ** ( -n)) 

print(k)
1 1000000000000000000 3

### FIXED CODE ###

a, b, x = map(int, input().split())
print(b//x-(a-1)//x)
a, b, c = map(int, input().split())

num_lists = [a, b, c]
maximum = a
if a == b or a == c or b == c:
  ans = 'No'
else:
  if maximum < b:
    maximum = b
  if maximum < c:
    maximum = c

num_lists.remove(maximum)
if num_lists[0] + num_lists[1] == maximum:
  ans ='Yes'

print(ans)

### FIXED CODE ###

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

num_lists = [a, b, c]
maximum = a
if maximum < b: maximum = b
if maximum < c: maximum = c

max_index = num_lists.index(maximum)
num_lists.pop(max_index)

remainder = num_lists[0] + num_lists[1]
if maximum == remainder:
  ans = 'Yes'
else:
  ans = 'No'
  
print(ans)
import sys

n,m = input().split()
n,m = [int(n), int(m)]
num = 0
flag = 0
s = []
c = []

if m == 0:
  if n == 1:
    print(0)
    sys.exit()
    
  print(pow(10, n-1))
  sys.exit()

for i in range(m):
  s_i,c_i = input().split()
  s_i,c_i = [int(s_i), int(c_i)]
  if n >= 2 and (s_i == 1 and c_i == 0):
    print(-1)
    sys.exit()
    
  for j in range(i):
    if s[j] == s_i and c[j] != c_i:
      print(-1)
      sys.exit()
    elif s[j] == s_i and c[j] == c_i:
      flag = 1
  
  if flag == 1:
    continue
    
  s.append(s_i)
  c.append(c_i)
  
  num += c_i * pow(10, n-s_i)
  
print(num)

### FIXED CODE ###

import sys

n,m = input().split()
n,m = [int(n), int(m)]
num = 0
flag = 0
s = []
c = []

if m == 0:
  if n == 1:
    print(0)
    sys.exit()
    
  print(pow(10, n-1))
  sys.exit()

for i in range(m):
  s_i,c_i = input().split()
  s_i,c_i = [int(s_i), int(c_i)]
  flag = 0
  if n >= 2 and (s_i == 1 and c_i == 0):
    print(-1)
    sys.exit()
    
  for j in range(len(s)):
    if s[j] == s_i and c[j] != c_i:
      print(-1)
      sys.exit()
    elif s[j] == s_i and c[j] == c_i:
      flag = 1
  
  if flag == 1:
    continue
    
  s.append(s_i)
  c.append(c_i)
  
  num += c_i * pow(10, n-s_i)
  
  
if n >= 2 and num < pow(10, n-1):
  num += pow(10, n-1)
    
print(num)
N = int(input())
As = list(map(int, input().split()))
dp = [0] * 100000
mod = 10**9 + 7
ans = 1
dp[0] = 3
for a in As:
    a += 1
    ans *= dp[a-1]-dp[a]
    ans %= mod
    dp[a] += 1
print(ans%mod)

### FIXED CODE ###

N = int(input())
As = list(map(int, input().split()))
dp = [0] * 1000000
mod = 10**9 + 7
ans = 1
dp[0] = 3
for a in As:
    a += 1
    ans *= dp[a-1]-dp[a]
    ans %= mod
    dp[a] += 1
print(ans%mod)
n = int(input())
a = list(map(int, input().split()))
import fractions

lcm = a[0]
for i in range(1, n):
    lcm = lcm * a[i] // fractions.gcd(lcm, a[i])

b = [0]*n
for i in range(n):
    b[i] = lcm/a[i]

print(int(sum(b)) % (10**9+7))




### FIXED CODE ###

n = int(input())

import fractions
import collections
a = collections.deque(list(map(int, input().split())))
 
lcm = a.popleft()
a.append(lcm)
for i in range(1, n):
    tem = a.popleft()
    lcm = lcm * tem // fractions.gcd(lcm, tem)
    a.append(tem)
 
ans = 0
for i in range(n):
    tem = a.popleft()
    ans += lcm // tem
 
print(ans % (10**9+7))
N, M = map( int, input().split() )
A = list( map( int, input().split() ) )


# 桁数の一番大きいものが最大。そのあと数を大きい順に並べればいい
dp = [-float('inf')] * (N+1)             # dp[i]: i 本のマッチで条件を満たす整数の最大桁数
cost = [ 0, 2, 5, 5, 4, 5, 6, 3, 7, 6 ]  # 各数字に必要なマッチ棒の数(逆順)

dp[0] = 0
for num_match in range( 2, N+1 ):
    for Aj in A:
        if num_match >= cost[Aj]:
            dp[num_match] = max( dp[num_match], dp[num_match-cost[Aj]]+1 )


print( dp )

ans = ""
digit = dp[N]

A.sort( reverse=True )
while N > 0:
    for Ai in A:
        if dp[N-cost[Ai]] == digit-1 :
            ans += str(Ai)
            N -= cost[Ai]
            digit -= 1
            break

print( ans )

### FIXED CODE ###

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


# 桁数の一番大きいものが最大。そのあと数を大きい順に並べればいい
dp = [0] + [-float('inf')] * (N+1)       # dp[i]: i 本のマッチで条件を満たす整数の最大桁数
cost = [ 0, 2, 5, 5, 4, 5, 6, 3, 7, 6 ]  # 各数字に必要なマッチ棒の数(逆順)

for num_match in range( 2, N+1 ):
    for Aj in A:
        if num_match >= cost[Aj]:
            dp[num_match] = max( dp[num_match], dp[num_match-cost[Aj]]+1 )


ans = ""
digit = dp[N]

A.sort( reverse=True )
while N > 0:
    for Ai in A:
        if N-cost[Ai] >=0 and dp[N-cost[Ai]] == digit-1:
            ans += str(Ai)
            N -= cost[Ai]
            digit -= 1
            break

print( ans )
n, *p = map(int, open(0).read().split())
t = 0
for i in range(n):
    t += 1 if p[i] != sorted(p)[i] 
print("YES" if t == 0 or t == 2 else "NO")

### FIXED CODE ###

n, *p = map(int, open(0).read().split())
t = 0
for i in range(n):
    t += p[i] != sorted(p)[i]
print("YES" if t == 0 or t == 2 else "NO")
A=int(input())
B=int(input())
C=int(input())
D=int(input())
E=int(input())
list1=[A,B,C,D,E]
sum=0
for item in list1:
  if(w%10==0):
    sum+=w
  else:
    sum=sum+(10-w%10)
print(sum)

### FIXED CODE ###

a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
k=int(input())
f=[b-a,c-b,d-c,e-d]
 
if((f[0]>k) or (f[1]>k) or (f[2]>k)or (f[3]>k)):
  print(':(')
elif(((f[0]+f[1])>k)or ((f[1]+f[2])>k)or ((f[2]+f[3])>k)):
  print(':(')
elif(((f[0]+f[1]+f[2])>k) or((f[1]+f[2]+f[3])>k)):
  print(':(')
elif((e-a)>k):
  print(':(')
else:
  print('Yay!')
x = int(input())

my_dict = dict()

for i in range(10 ** 5):
    my_dict[i**5] = i

for i in range(-10 ** 5, 10 ** 5):
    target = x + (i ** 5)
    if target in my_dict:
        print(my_dict[target], i)
        exit()
    elif (- target) in my_dict:
        print(-my_dict[target], i)
        exit()


### FIXED CODE ###

x = int(input())

my_dict = dict()

for i in range(1000):
    my_dict[i**5] = i

for i in range(-1000, 1000):
    target = x + (i ** 5)
    if (- target) in my_dict:
        print(-my_dict[-target], i)
        exit()
    elif target in my_dict:
        print(my_dict[target], i)
        exit()
N=int(input())
i=int(input())
print(N-i+1)

### FIXED CODE ###

N,i=map(int, input().split())
print(N-i+1)
import numpy as np

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

A.insert(0, 0)
B.insert(0, 0)

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

A_cumsum = np.cumsum(A)
B_cumsum = np.cumsum(B)

ans = 0

for i, a in enumerate(A_cumsum):
    for j, b in enumerate(B_cumsum):
        n = i + j
        if n > ans:
            if a + b <= k:
                ans = n
            else:
                break

print(ans)
    

### FIXED CODE ###

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

A_cumsum, B_cumsum = [0], [0]

for i in range(n):
    A_cumsum.append(A_cumsum[i] + A[i])
    
for j in range(m):
    B_cumsum.append(B_cumsum[j] + B[j])
    
ans, j = 0, m

for i in range(n + 1): # 0を最初に代入した分
    if A_cumsum[i] > k:
        break
    while A_cumsum[i] + B_cumsum[j] > k:
        j -= 1
    ans = max(ans, i + j)

print(ans)
n = int(input())

div, mod = divmod(n, 4)
ans = []
for i in range(div):
    ans.append(6*i + 2)
    ans.append(6*i + 3)
    ans.append(6*i + 4)
    ans.append(6*i + 6)

if mod == 1:
    ans.append(6*(i+1) + 6)
if mod == 2:
    ans.append(6*(i+1) + 2)
    ans.append(6*(i+1) + 4)
if mod == 3:
    ans.append(6*(i+1) + 2)
    ans.append(6*(i+1) + 4)
    ans.append(6*(i+1) + 6)

print(*ans)

### FIXED CODE ###

n = int(input())

div, mod = divmod(n, 4)
ans = []

if n == 3:
    print(2, 5, 63)
    exit()
if n == 4:
    print(2, 5, 20, 63)
    exit()
if n == 5:
    print(2, 5, 20, 30, 63)
    exit()
    
cnt = 0
i = 0
for i in range(div):
    cnt += 15
    ans.append(6*i + 2)
    ans.append(6*i + 3)
    ans.append(6*i + 4)
    ans.append(6*i + 6)
if mod == 1:
    i += 1
    cnt += 2
    ans.append(6*i + 2)
if mod == 2:
    i += 1
    cnt += 5
    ans.append(6*i + 2)
    ans.append(6*i + 3)
if mod == 3:
    i += 1
    cnt += 9
    ans.append(6*i + 2)
    ans.append(6*i + 3)
    ans.append(6*i + 4)

if cnt % 6 == 0:
    pass
if cnt % 6 == 2:
    ans = ans[0:4] + ans[5:] + [ans[-1] - ans[-1] % 6 + 6]
if cnt % 6 == 3:
    ans = ans[0:5] + ans[6:] + [ans[-1] - ans[-1] % 6 + 6]
if cnt % 6 == 5:
    ans = ans[0:5] + ans[6:] + [6 * (ans[-1] // 6) + 4]
print(*ans)
# Acceptance of input

import sys

f_i = sys.stdin

n = int(f_i.readline())

edges = [[] for i in range(n)]

for l_i in f_i:
    s, t, w = map(int, l_i.split())
    edges[s].append([t, w])
    edges[t].append([s, w])

# Tree Walk and Output

distance = [0] * n

sys.setrecursionlimit(10000)

def tree_walk(u, d, p):
    for v, w in edges[u]:
        if v != p:
            c_d = d + w
            distance[v] = c_d
            tree_walk(v, c_d, u)

tree_walk(0, 0, None)

end_point = distance.index(max(distance))

tree_walk(end_point, 0, None)

print(max(distance))

### FIXED CODE ###

# Acceptance of input

import sys

f_i = sys.stdin

n = int(f_i.readline())

edges = [[] for i in range(n)]

for l_i in f_i:
    s, t, w = map(int, l_i.split())
    edges[s].append((t, w))
    edges[t].append((s, w))

# Tree Walk function

import collections

def tree_walk(start, switch = 0):
    path = collections.deque()
    path.append(start)

    weight = collections.deque()
    weight.append(0)
    
    unvisited = [True] * n
    unvisited[start] = False
    
    rest = n - 1
    end_point = start
    diameter = 0
    
    while True:
        u = path[-1]
        for v, w in edges[u]:
            if unvisited[v]:
                path.append(v)
                unvisited[v] = False
                rest -= 1
                weight.append(w)
                break

        if u == path[-1]:
            distance = sum(weight)
            if diameter < distance:
                diameter = distance
                end_point = u
            if rest == 0:
                break
            path.pop()
            weight.pop()

    if switch:
        print(diameter)
    else:
        return end_point

# Output

tree_walk(tree_walk(0), 1)
N ,K = map(int, input().split())

import math

A = list(map(int, input().split()))
d = [0] * N

#二分探索
min = 1
max = max(A)

while True:
    X = (min + max)//2
    for i in range(N):
        if a[i] % X == 0:
            d[i] = A[i]//X - 1
        else:
            d[i] = A[i]//X
    if sum(d) <= K:
        max = X 
    else:
        min = X
    #print(min, max)
    
    if max - min <= 1:
        print(int(max))
        break

### FIXED CODE ###

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

A = list(map(int, input().split()))
d = [0] * N

#二分探索
min1 = 0
max1 = max(A) + 1

while True:
    X = (min1 + max1)//2
    for i in range(N):
        if A[i] % X == 0:
            d[i] = A[i]//X - 1
        else:
            d[i] = A[i]//X
    if sum(d) <= K:
        max1 = X 
    else:
        min1 = X
    #print(min1, max1)

    if max1 - min1 <= 1:
        print(int(max1))
        break