Harryxun/stf_run huggingface dataset:
import numpy as np

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

AA=np.sort(A)
BB=np.sort(B)[::-1]
S=np.sum(A)
CC=np.array([AA[i]*BB[i] for i in range(N)])
if K>S:
    K=S

for j in range(K):
    m=np.argmax(CC)
    AA[m]-=1
    CC[m]=AA[m]*BB[m]
print(np.max(CC))

### FIXED CODE ###

A,B=map(int,input().split())
if A<10 and B<10:
    print(A*B)
else:
    print(-1)
N = int(input())
list_A = input().split()
list_A = [int(i) for i in list_A]

temp_sum = 1
flag = False
flag_0 = False

if 0 in list_A:
    flag_0 = True
    break
else:
    for i in range(N):
        temp_sum *= list_A[i]
        if temp_sum >= 10**18:
            flag = True
            break
        else:
            continue

if flag_0:
    print(0)
elif (flag_0 == False) and flag:
    print(-1)
else:
    print(temp_sum)

### FIXED CODE ###

N = int(input())
given_list = [int(i) for i in input().split()]

limit = 10**18
ans = 1

if 0 in given_list:
    print(0)
else:
    for i in given_list:
        ans *= i
        if ans > limit:
            print('-1')
            break
    if ans <= limit:
        print(ans)
N = int(input())
a = list(map(int, input().split()))

import fractions
lcm_m = a[0]
for i in range(1, N):
    lcm_m = lcm_m * a[i] // fractions.gcd(lcm_m, a[i])
#    lcm_m = (lcm_m%(10^9+7))*(a[i]%(10^9+7))//(fractions.gcd(lcm_m,a[i])%(10^9+7))
#    lcm_m = (lcm_m%(10**9+7))*a[i]//(fractions.gcd(lcm_m%(10**9+7),a[i]))
#print(lcm_m)

sol = 0
for i in range(N):
    sol += lcm_m / a[i]
#print(int(sol)%(10**9+7))
sol=sum([lcm_m//x for x in a])
print(sol%(10**9+7))

### FIXED CODE ###

N = int(input())
a = list(map(int, input().split()))
mod=10**9+7
import fractions
lcm_m = a[0]%mod
for i in range(1, N):
#    lcm_m = lcm_m * a[i] // fractions.gcd(lcm_m, a[i])
#    lcm_m = (lcm_m%(10^9+7))*(a[i]%(10^9+7))//(fractions.gcd(lcm_m,a[i])%(10^9+7))
#    lcm_m = (lcm_m%(10**9+7))*a[i]//(fractions.gcd(lcm_m%(10**9+7),a[i]))
#    lcm_m = ((lcm_m%mod)*(a[i]%mod))%mod//(fractions.gcd(lcm_m,a[i]))
    lcm_m = ((lcm_m)*(a[i]%mod))//(fractions.gcd(lcm_m,a[i]%mod))
#print(lcm_m)

#sol = 0
#for i in range(N):
#    sol += lcm_m / a[i]
#print(int(sol)%(10**9+7))
sol=sum([lcm_m//x for x in a])
print(sol%mod)
#print(sol)
n = int(input())
ki = [[] for _ in range(n)]
for i in range(n - 1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    ki[a].append([b, i])
ans = [-1] * (n - 1)


# print(ki)


def d(index, color):
    cnt = 1
    for (t, jid) in ki[index]:
        if cnt == color:
            cnt += 1
        ans[jid] = cnt
        d(t, cnt)
        cnt += 1


d(0, 0)
print(max(ans))
for i in ans:
    print(i)


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**7)

n = int(input())
ki = [[] for _ in range(n)]
for i in range(n - 1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    ki[a].append([b, i])
ans = [-1] * (n - 1)


# print(ki)


def d(index, color):
    cnt = 1
    for (t, jid) in ki[index]:
        if cnt == color:
            cnt += 1
        ans[jid] = cnt
        d(t, cnt)
        cnt += 1


d(0, 0)
print(max(ans))
for i in ans:
    print(i)
l = list(map(int,input().split()))
N = l[0]
K = l[1] 
S = input()
list_S = list(S)
if list_S[K-1] == 'A':
    list_S[K-1] = 'a'
elif list_S[K-1] == 'B':
    list_S[K-1] = 'b'
if list_S[K-1] == 'C':
    list_S[K-1] = 'c'
L = ''.join(list_S)
print(L)


### FIXED CODE ###

l = list(map(int,input().split()))
N = l[0]
K = l[1] 
S = input()
list_S = list(S)
if list_S[K-1] == 'A':
    list_S[K-1] = 'a'
elif list_S[K-1] == 'B':
    list_S[K-1] = 'b'
if list_S[K-1] == 'C':
    list_S[K-1] = 'c'
L = ''.join(list_S)
print(L)
X=input()
Y=input()
if X>Y:
  print('>')
elif X<Y:
  print('<')
else:
  print('=')

### FIXED CODE ###

X,Y=input().split()
if X>Y:
    print(">")
elif X<Y:
    print("<")
else:
    print("=")
6 2 4

### FIXED CODE ###

def resolve():
    N, A, B = map(int, input().split())  

    ao_count = 0

    count_num = N // (A + B)
    amari_num = N % (A + B)



    ao_count = count_num * A

    if A <= amari_num:
        ao_count += A
    else:
        ao_count += amari_num

    print(ao_count)



if __name__ == "__main__":
    resolve()
#El Patron
A = int(input())
B = list(map(int, input().split()))

a = 0
b = 0
ans = 0
while b < A:
    if b < A - 1 and B[b + 1] <= B[b]:
        b += 1
        res = max(res, b - l)
    elif b != a:
        a += 1
    else:
        a += 1
        b += 1
print(res)

### FIXED CODE ###

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

a = 0
b = 0
res = 0
while a < A:
    if a < A - 1 and B[a + 1] <= B[a]:
        a += 1
        res = max(res, a - b)
    elif a != b:
        b += 1
    else:
        b += 1
        a += 1
print(res)
agct = ["A":"T","G":"C","T":"A","C":"G"]
print(agct[input()])

### FIXED CODE ###

b = input()
aa = {"A":"T", "T":"A", "G":"C", "C":"G"}
print(aa[b])
W, H, N = map(int, input().split())
P = [list(map(int, input().split())) for _ in range(N)]
X1, X2, Y1, Y2 = 0, W, 0, H

for x, y, a in P:
    if a == 1:
        X1 = max(X1, x)
    elif a == 2:
        X2 = min(X2, x)
    elif a == 3:
        Y1 = max(Y1, y)
    elif a == 4:
        Y2 = min(Y2, y)

if X2 <= X1 or Y2 <= Y1:
    print(0)
else:
    print((X2 - X1) * (Y2 - Y1))

### FIXED CODE ###

[a,b,c]=list(map(int,input().split()))
if a+b==c or a+c==b or b+c==a :
    print("Yes")
else:
    print("No")
def func():
	i = input()
	if i == 'A':
    	return 'T'
    else if i == 'T':
    	return 'A'
    else if i == 'C':
    	return 'G'
    else if i == 'G':
    	return 'C'

print(func())
  

### FIXED CODE ###

i = input()
if i == 'A':
  print('T')
elif i == 'T':
  print('A')
elif i == 'C':
  print('G')
elif i == 'G':
  print('C')
k = int(input())

tasu = k // 2
lst = list(range(tasu, tasu+2))
amari = k % 2
for i in range(amari):
    idx = 2 - i
    lst[idx] += 1

print(2)
print(' '.join(map(str, lst)))


### FIXED CODE ###

k = int(input())

n = 50
a = k//n
m = k%n
ans = list(range(a,a+n))
for i in range(m):
    ans[n-i-1] += 1

print(50)
print(*ans)
strings = raw_input().split(',')
new_strings = ""
for string in strings:
  if string.islower():
    new_strings.append(string.upper()+',')
  else:
    new_strings.append(string.lower()+',')
print  new_strings

### FIXED CODE ###

print raw_input().swapcase()
N, K = [int(x) for x in input().split()]
arr = [0] * (10**5+1)
for _ in range(N):
    a, b = [int(x) for x in input().split()]
    arr[a] += b

remain = K
for i in range(1, 10**5+1):
    if arr[i] != 0:
        remain -= arr[i]
    if remain <= 0:
        print(i)
        exit()

### FIXED CODE ###

a, b, c = [int(x) for x in input().split()]

if c >= a and c <= b:
    print("Yes")
else:
    print("No")
L, R = [int(i) for i in input().split(" ")]

flag=True
if (R - L) >= 2019:
  print(0)
else:
  min_mod = 2019
  for i in range(L, R):
    for j in range(i+1, R+1):
      tmp = (i*j) % 2019
      if tmp == 0:
        print(0)
        flag=False
        break
      elif tmp < min_mod:
        min_mod = tmp
    if flag==False:
      break

if (flag):
  print(min_mod)

### FIXED CODE ###

L, R = [int(i) for i in input().split(" ")]

flag=True
if (R - L) >= 2019:
  flag=False
  print(0)
else:
  min_mod = 2019
  for i in range(L, R):
    for j in range(i+1, R+1):
      tmp = (i*j) % 2019
      if tmp == 0:
        print(0)
        flag=False
        break
      elif tmp < min_mod:
        min_mod = tmp
    if flag==False:
      break

if flag==True:
  print(min_mod)
x, y, z=list(map(int, input().split(/)))
if y>=5:
  print("TBD")
else:
  print("Heisei")

### FIXED CODE ###

x, y, z=list(map(int, input().split("/")))
if y>=5:
  print("TBD")
else:
  print("Heisei")
# https://atcoder.jp/contests/abc088/tasks/abc088_d

H, W = map(int, input().split())
s = [input() for _ in range(H)]
d = [[-1] * W for _ in range(W)]

# 0,0 to h-1, w-1
d[0][0] = 0

queue = []
queue.append([0, 0])

while len(queue) > 0:
    p = queue.pop(0)
    y, x = p[0], p[1]

    dx4 = [0, 0, 1, -1]
    dy4 = [1, -1, 0, 0]

    for dx, dy in zip(dx4, dy4):
        next_y = y + dy
        next_x = x + dx
        # if 0 <= next_y < H and 0 <= next_x < W and s[next_y][next_x] != "#" and d[next_y][next_x] == -1:
        #     d[next_y][next_x] = d[y][x] + 1
        #     queue.append([next_y, next_x])

count = 0
for l in s:
    count += l.count(".")

if d[H-1][W-1] == -1:
    print(-1)
else:
    print(count - d[H-1][W-1] - 1)

# [print(l) for l in s]
# [print(l) for l in d]


### FIXED CODE ###

from queue import Queue

inf = 10 ** 20

def bfs(H, W, s):
    d = [[inf for i in range(W)] for j in range(H)]
    q = Queue()

    d[0][0] = 1
    q.put([0, 0])

    dx = (0, -1, 1, 0)
    dy = (-1, 0, 0, 1)

    while not q.empty():
        p = q.get()
        x = p[0]
        y = p[1]
        for i in range(4):
            nx = x + dx[i]
            ny = y + dy[i]
            if(nx >= 0 and nx < H and ny >= 0 and ny < W):
                if(s[nx][ny] == '.' and d[x][y] + 1 < d[nx][ny]):
                    d[nx][ny] = d[x][y] + 1
                    q.put([nx, ny])

    return d[H-1][W-1]

H, W = map(int, input().split())
s = []
wnum = 0
for i in range(H):
    s.append(input())
    for j in range(W):
        if(s[i][j] == "."):
            wnum += 1
d = bfs(H, W, s)
if(d == inf):
    print("-1")
else:
    print(wnum - d)
n=int(input())
for i in range(n)
        s=input().split(" ")
        s=[int(j) for j in s]
        s.sort()
        
        if(s[0]**2+s[1]**2==s[2]**2):
            print("YES")

        else:
            print("NO")
        

  

### FIXED CODE ###

n=int(input())
for i in range(n):
        s=input().split(" ")
        s=[int(j) for j in s]
        s.sort()
        
        if(s[0]**2+s[1]**2==s[2]**2):
            print("YES")

        else:
            print("NO")
X,Y = map(int,unput().split())
ans = 0
while Y<=X:
  ans += 1
  X*=2
print(ans)

### FIXED CODE ###

X,Y = map(int,input().split())
ans = 0
while Y>=X:
  ans += 1
  X*=2
print(ans)
#!/usr/bin/env python3
import sys
args = sys.argv
if len(args) == 2:
  from IPython import embed
  em = True
else:
  em = False
input = sys.stdin.readline
a, b, x = map(int, input().split())
import math
if 2*x/b <= a:
  ans = math.degrees(math.atan(a*b**2/(2*x)))
else:
  ans = 90 - math.degrees(math.atan(a/(2*b - 2*x/(a**2))))
print(ans)
if em: sys.stdin = open('/dev/tty')


### FIXED CODE ###

#!/usr/bin/env python3
import sys
args = sys.argv
if len(args) == 2:
  from IPython import embed
  em = True
else:
  em = False
input = sys.stdin.readline
a, b, x = map(int, input().split())
if a**2*b == x:
  print(0)
  exit()
import math
if 2*x <= a**2*b:
  t1 = a*b**2
  t2 = 2*x
  ans = math.degrees(math.atan(t1/t2))
else:
  t1 = a**3
  t2 = 2*a**2*b - 2*x
  ans = 90 - math.degrees(math.atan(t1/t2))
print(ans)
if em: sys.stdin = open('/dev/tty')
x=input()
a=[1]
for i in range(1,len(x)):
    if x[i]==x[i-1]:
        a[-1]+=1
    else:a+=[1]
ans=0    
if x[0]=="T":
    ans+=a.pop(0)
if x[-1]=="S":
    ans+=a.pop(-1)
    
while len(a)>1:
    a=[i-j for i,j in zip(a[::2],a[1::2]) if i!=j]
    while a and a[0]<0:
        ans+=abs(a.pop(0))
    while a and a[-1]>0:
        ans+=a.pop(-1)
    b=[]    
    if a:
        b=a[0]
        for i in range(1,len(a)):
            if a[i]*a[i-1]>0:
                b[-1]+=a[i]
            else:b+=a[i]
    a=[abs(i) for i in b]
            
print(ans+abs(a[0]) if a else ans) 

### FIXED CODE ###

a=[]
for i in input():
    if i=="S":
        a+=i
    
    if a:
        if i=="T" and a[-1]=="T":
            a+=i
        if i=="T" and a[-1]=="S":
            a.pop(-1)
    elif i=="T" and len(a)==0:
        a+=i    
print(len(a))
def resolve():
    a, b, k = list(map(int, input().split()))
    small = list(range(a, b))[:k]
    large = list(range(a, b + 1))[::-1][:k]
    ans = sorted(set(small + large))
    for i in ans:
        print(i)


if __name__ == "__main__":
    resolve()


### FIXED CODE ###

def resolve():
    a, b, k = list(map(int, input().split()))
    s = set()
    for i in range(a, min(a + k, b + 1)):
        s.add(i)
    for i in range(max(a, b - k + 1), b + 1):
        s.add(i)
    for i in sorted(s):
        print(i)


if __name__ == "__main__":
    resolve()
n,m=map(int,input().split(' '))
print(sum((n-1)*(m-1)))

### FIXED CODE ###

n,m=map(int,input().split(' '))
print(str((n-1)*(m-1)))
n=input()
print(n**2)

### FIXED CODE ###

n=int(input())
print(n**2)
a, b, x = map(int, input().split())
if a * 1e9 + b * 10 <= x:
    print(int(1e9))
elif a * 1 + b * 1 > x:
    print(0)
else:
    atari = x // a
    price = atari * a + b * len(str(atari))
    if atari > 100:
        while price > x:
            atari -= 100
            atari = max(0, atari)
            price = atari * a + b * len(str(atari))
        atari_bottom = atari
        while price < x:
            atari_bottom += 1
            price = atari_bottom * a + b * len(str(atari_bottom))
        print(atari_bottom-1)
    else:
        while price > x:
            atari -= 1
            price = atari * a + b * len(str(atari))
        print(atari)


### FIXED CODE ###

today = input()
days = {'SUN':7,
        'MON':6,
        'TUE':5,
        'WED':4,
        'THU':3,
        'FRI':2,
        'SAT':1
}
print(days[today])
N = int(input())
edg = [list(map(int,input().split())) for _ in range(N-1)]
vtx = [[] for _ in range(N)]
for e in edg:
    v1,v2,w = e
    vtx[v1-1].append([v2-1,w])
    vtx[v2-1].append([v1-1,w])

colors = [1 for _ in range(N)]
def dfs(vtx,i=0,p=-1): # vertex and its parent
    for c,w in vtx[i]:
        if c == p:
            continue
        colors[c] = 1 - colors[i] if w%2 != 0 else colors[i]
        dfs(vtx,c,i)
dfs(vtx)

for v in colors:
    print(v)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)
N = int(input())
edg = [list(map(int,input().split())) for _ in range(N-1)]
vtx = [[] for _ in range(N)]
for e in edg:
    v1,v2,w = e
    vtx[v1-1].append([v2-1,w])
    vtx[v2-1].append([v1-1,w])

colors = [1 for _ in range(N)]

def dfs(vtx,i=0,p=-1,c=1): # vertex and its parent
    colors[i] = c
    for v,w in vtx[i]:
        if v == p:
            continue
        dfs(vtx,v,i,1-c if w%2 != 0 else c)
dfs(vtx)

for v in colors:
    print(v)
n,a,b,c,d = map(int,input().split())
s = input()
s = s + "."
cant = 0
sanrenzoku = 0
for i in range(a+1,d+1):
    if s[i] == "#":
        if s[i+1] == "#":
            cant = 1
    if c > d:
        if s[i] == ".":
            if s[i+1] == ".":
                if s[i+2] == ".":
                    if i > b-2:
                        if i < d:
                            sanrenzoku = 1

if cant == 1:
    print("No")
elif c > d:
    if sanrenzoku == 0:
        print("No")
    else:
        print("Yes")
else:
    print("Yes")

### FIXED CODE ###


n,a,b,c,d = map(int,input().split())
s = input()
s = s + "."
cant = 0
sanrenzoku = 0
for i in range(a-1,max(c-1,d-1)):
    if s[i] == "#":
        if s[i+1] == "#":
            cant = 1

if c > d:
    for i in range(b-2,d-1):
        if s[i] == ".":
            if s[i+1] == ".":
                if s[i+2] == ".":
                   sanrenzoku = 1

if cant == 1:
    print("No")
elif c > d:
    if sanrenzoku == 0:
        print("No")
    else:
        print("Yes")
else:
    print("Yes")
import sys
input = sys.stdin.readline

n = int(input())
cnt = 0
decrement = 0
profit = []
loss = []

for _ in range(n):
    s = input()
    min_p = 0
    end_p = 0
    point = 0
    for c in s:
        if c == '(':
            point += 1
        elif c == ')':
            point -= 1
            if point < min_p:
                min_p = point
    else:
        end_p = point
    if 0 <= min_p:
        cnt += end_p
    else:
        if min_p == end_p:
            decrement += end_p
        else:
            if 0 <= end_p:
                profit.append((min_p, end_p))
            else:
                loss.append((min_p, end_p))


profit.sort(reverse=True)
while profit:
    min_p, end_p = profit.pop()
    if cnt+min_p < 0:
        print('No')
        exit()
    cnt += end_p


loss.sort()
while loss:
    min_p, end_p = profit.pop()
    if cnt+min_p < 0:
        print('No')
        exit()
    cnt += end_p

print('Yes' if cnt+decrement == 0 else 'No')


### FIXED CODE ###

import sys
input = sys.stdin.readline

n = int(input())
cnt = 0
decrement = 0
profit = []
loss = []

for _ in range(n):
    s = input().rstrip()
    min_p = 0
    end_p = 0
    point = 0
    for c in s:
        if c == '(':
            point += 1
        elif c == ')':
            point -= 1
            if point < min_p:
                min_p = point
    else:
        end_p = point
    if 0 <= min_p:
        cnt += end_p
    else:
        if min_p == end_p:
            decrement += end_p
        else:
            if 0 <= end_p:
                profit.append((min_p, end_p))
            else:
                loss.append((min_p, end_p))



profit.sort()
while profit:
    min_p, end_p = profit.pop()
    if cnt+min_p < 0:
        print('No')
        exit()
    cnt += end_p


loss.sort(reverse=True)
while loss:
    min_p, end_p = loss.pop()
    if cnt+min_p < 0:
        print('No')
        exit()
    cnt += end_p

print('Yes' if cnt+decrement == 0 else 'No')
del = list(map(int, input().split()))
n = len(del)
sum = 0
i = 0

while i < n - 1:
 
  k = i
  while k < n - 1:
    k += 1
    sum += del[i] * del[k]
    
  i += 1
  
print(str(sum))



### FIXED CODE ###

n = int(input())
deliciousness = list(map(int, input().split()))
sum = 0
i = 0

while i < n - 1:
  k = i
  while k < n - 1:
    k += 1
    sum += deliciousness[i] * deliciousness[k]
  i += 1
  
print(sum)
import sys

N = int(input())
nums = list(map(int, input().split(' ')))

output = 1

if 0 in nums:
  print(0)
  
else:
  for x in nums:
    output *= x

    if output > 10**18
      print('-1')
      sys.exit()

  print(output)

### FIXED CODE ###

import sys

N = int(input())
nums = list(map(int, input().split(' ')))

output = 1

if 0 in nums:
  print(0)
  sys.exit()
  
else:
  for x in nums:
    output *= x

    if output > 10**18:
      print(-1)
      sys.exit()

  print(output)
#!/usr/bin/python3

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

c = 0
if p == 2 or p == 5:
    for i in range(n - 1, -1, -1):
        if int(s[i]) % p == 0:
            c += i + 1

else:
    mm = {}
    for i in range(n - 1, -1, -1):
        u = int(s[i:])
        r = u % p
        if r in mm:
            c += l
            mm[r] += 1
        else:
            mm[r] = 1

        if r == 0:
            c += 1
        
print(c)


### FIXED CODE ###

#!/usr/bin/python3

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

c = 0
if p == 2 or p == 5:
    for i in range(n - 1, -1, -1):
        if int(s[i]) % p == 0:
            c += i + 1

else:
    mm = {}
    r = 0
    mten = 1
    for i in range(n - 1, -1, -1):
        ch = int(s[i])
        r = (r + ch * mten) % p
        mten = (mten * 10) % p
        if r in mm:
            c += mm[r]
            mm[r] += 1
        else:
            mm[r] = 1

        if r == 0:
            c += 1
        
print(c)
import math

N=list(map(int,input().split()))
print(math.gcd(N[0].N[1]))

### FIXED CODE ###

import fractions
N=list(map(int,input().split()))
print(int(N[0]*N[1]/fractions.gcd(N[0],N[1])))
mi, ma, num = map(int,input().split())
ans = []
if num <= ma-mi+1
  for i in range(mi,mi+num):
    ans.append(i)
  for j in range(ma-num+1,ma+1):
    if j not in ans:
      ans.append(j)
  for k in ans:
    print(k)
else:
  for l in range(mi,ma+1):
    print(l)


### FIXED CODE ###

mi, ma, num = map(int,input().split())
ans = []
if num <= ma-mi+1:
  for i in range(mi,mi+num):
    ans.append(i)
  for j in range(ma-num+1,ma+1):
    if j not in ans:
      ans.append(j)
  for k in ans:
    print(k)
else:
  for l in range(mi,ma+1):
    print(l)
def check_words(w):
    if len(w) != len(set(w)):
        return False
    for i in range(n-1):
        if w[i][-1] != w[i+1][0]:
            return False
    return True

n = int(input())
w = list(map(str, input().split()))
if check_words(w):
    ret = 'Yes'
else:
    ret = 'No'
print(ret)

### FIXED CODE ###

n = int(input())
w = [input() for i in range(n)]

if n != len(set(w)):
    print('No')
    exit()
for i in range(n-1):
    if w[i][-1] != w[i+1][0]:
        print('No')
        exit()

print('Yes')
N = int(input())
S = [ input() for _ in range(N) ]
print(len(set(S)))

### FIXED CODE ###

S = str(input())
N = len(S)

ans = 0
amari = [0] * 2019
amari[0] = 1
follow = 0
POW = 1

for i in reversed(S):
  follow += int(i) * POW
  follow %= 2019
  amari[follow] += 1
  POW *= 10
  POW %= 2019
  
print(sum( i * (i-1) // 2 for i in amari ))
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

cnt = 0
def dfs(a, b, t):
    global cnt
    cnt = max(cnt, a+b)
    if a < N and t + A[a] <= K:
        dfs(a+1, b, t+A[a])
    if b < M and t + B[b] <= K:
        dfs(b+1, a, t+B[b])
    
dfs(0, 0, 0)
print(cnt)


### FIXED CODE ###

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

def ruiseki(lst):
    return [0]+list(accumulate(lst))

ar = ruiseki(A)
br = ruiseki(B)
ans = 0
for i in range(1+N):
    left = K - ar[i]
    if left < 0:
        continue
    bidx = bisect_right(br, left) - 1
    ans = max(ans,i+bidx)

print(ans)
# coding: utf-8
 
N  = int(input())
sum = 0

import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

for i in range (N):
    for j in range(N):
        for k in range(N):
            sum += gcd([i, j, k])

print(sum)

### FIXED CODE ###

# coding: utf-8
 
N  = int(input())
sum = 0
 
import math
from functools import reduce
 
def gcd(*numbers):
    return reduce(math.gcd, numbers)
 
for i in range (N):
    for j in range(N):
        for k in range(N):
            sum += gcd(*[i+1, j+1, k+1])
 
print(sum)
a = input().split(' ')
b = input().split(' ')
a = [int(a) for a in a]
b = [int(b) for b in b]

b.sort(reverse=True)
v = sum(b)

ans = 'Yes'

if b[a[1]-1] / v < 1 /( 4 * a[1]):
    ans = 'No'
            
print(ans)

### FIXED CODE ###

a = input().split(' ')
s = [int(i) for i in a]
print(s[2], s[0], s[1])
from numpy import*;v,c=loadtxt(open(0),skiprows=1);i=v>c;print(sum(v[i]-c[i]))

### FIXED CODE ###

n,*t=map(int,open(0).read().split());print(sum((x-y)*(x>y)for x,y in zip(t[:n],t[n:])))
s=input()
if s[-1]=s:
  print(s[-1].replace("s","es"))
else:
  s1=s+"s"
print(s1)

### FIXED CODE ###

s=input()
if(s[-1:]=='s'):
  s1=s+"es"
  print(s1)
else:
  s2=s+"s"
  print(s2)
#!/usr/bin/env python
N = int(input())
A = [int(i) for i in input().split()]
if N == 2:
    print(max(A) - min(A))
    print(max(A), min(A))
else:
    A.sort()
    As = []
    t = A[0]
    for a in A[1:-1]:
        As.append([t, a])
        t = t - a
    ans = A[-1] - t
    As.append([A[-1], t])
    print(ans)
    for a in As:
        print(*a)

### FIXED CODE ###

#!/usr/bin/env python
n, k = map(int, input().split())
if k == 1:
    print(0)
else:
    print(n-k)
K, S = map(int, input().split())

count = 0
for x in range(0,K+1):
    for y in range(0,K+1):
        a = S-x-y
        if a <= K and a>= 0:
            count += 1
print (count)

### FIXED CODE ###

sx, sy, tx, ty = map(int, input().split())

x = tx - sx
y = ty - sy

s = 'U'*y + 'R'*x +'U' + 'L'* (x+1) + 'D'*(y+1) + 'R'
s += 'R'*x + 'U'*y +'R' + 'D'* (y+1) + 'L'*(x+1) + 'U'
print(s)
a=input()
a=int(x)
s=input()
if y>=3200:
  print(s)
else:
  print("red")

### FIXED CODE ###

a=int(input())
s=input()
if a>=3200:
  print(s)
else:
  print('red')