Harryxun/stf_run huggingface dataset:
import math
from functools import reduce

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

N = int(input())
A = tuple(map(int, input().split()))
ans = 1

for i in range(N):
    AL = list(A)
    AL.pop(i)
    ans = max(ans, gcd_list(AL))

print(ans)

### FIXED CODE ###

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

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

L = [0 for i in range(N)]
R = [0 for i in range(N)]

for i in range(1,N):
    L[i] = gcd(L[i-1],A[i-1])

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

Z=[gcd(L[i],R[i]) for i in range(N)]

print(max(Z))
a,b = map(int,input().split())
lis = [0]*b
for i in range(a):
  c = int(input())
  d = input().split()
  
  for l in range(c):
    lis[int(d[l])-1] += 1
    
count = 0
for i in range(b):
  if(lis[i] == 0):
    count += 1

print(count)

### FIXED CODE ###

input_l = input()

if(input_l =="ARC"):
  print("ABC")
  
else:
  print("ARC")
from collections import defaultdict
N,M = list(map(int,input().split()))
price_howmany = defaultdict(int)
price_list = []
for _ in range(N):
    tmp = list(map(int,input().split()))
    price_howmany[tmp[0]] += tmp[1]
    price_list.append(tmp[0])
price_list.sort(reverse=True)

price_howmany = dict(price_howmany)

def solve():
    price = 0
    many = 0
    global M
    while M > 0:
        # low_price = min(price_howmany.keys())
        low_price = price_list.pop()
        many = min(M,price_howmany[low_price])
        price += many * low_price
        M -= many
        price_howmany.pop(low_price)
    print(price)

if __name__ == "__main__":
    solve()

### FIXED CODE ###

# from collections import defaultdict
# N,M = list(map(int,input().split()))
# price_howmany = defaultdict(int)
import sys

stdin = sys.stdin

read_int = lambda : list(map(int,stdin.readline().split()))

N,M = read_int()
price_howmany = {}
# price_list = []

price_set = set()
for _ in range(N):
    tmp = read_int()
    # if tmp[0] not in price_set:
        # price_list.append(tmp[0])
    price_set.add(tmp[0])
    if tmp[0] in price_howmany:
        price_howmany[tmp[0]] += tmp[1]
    else:
        price_howmany[tmp[0]] = tmp[1]
# price_list.sort(reverse=True)
price_list = sorted(list(price_set))

# price_howmany = dict(price_howmany)

def solve():
    price = 0
    global M
    # while M > 0:
        # low_price = min(price_howmany.keys())
        # low_price = price_list.pop()
        # many = min(M,price_howmany.pop(low_price))
        # price += many * low_price
        # M -= many
    for low_price in price_list:
        many = min(M,price_howmany.pop(low_price))
        price += many * low_price
        M -= many
        if M == 0: break
    print(price)

if __name__ == "__main__":
    solve()
import math
phi = (1 + math.sqrt(5)) / 2

def counter(n):
    if n == 0:
        return 0
    else:
        f = round(phi**(n) / math.sqrt(5)) % (10**9+7)
        return f
N, M = map(int, input().split())
a = [int(input()) for _ in range(M)]
a.append(N+1)
ans = counter(a[0])
for i in range(1,M+1):
    ans = (ans * counter(a[i]-a[i-1]-1)) % (10**9+7)
#ans = ans * round(phi**(N-a[-1]) / math.sqrt(5)) % (10**9+7)
print(ans)

### FIXED CODE ###

def fib(n):
    if n == 1 or n == 2:
        return 1
    else:
        a = 1
        b = 0
        for _ in range(n-1):
            (a, b) = (a+b, a)
        return a % (10 ** 9 + 7)


def counter(n):
    if n == 0:
        return 0
    else:
#        f = round(phi**(n) / math.sqrt(5)) % (10**9+7)
        return fib(n)


N, M = map(int, input().split())
a = [int(input()) for _ in range(M)]
if M == 0:
    print(counter(N+1))
    exit()
a.append(N+1)
ans = counter(a[0])
for i in range(1,M+1):
    ans = (ans * counter(a[i]-a[i-1]-1)) % (10**9+7)
print(ans)
n = int(input())
l0 = 2
l1 = 1
for i in range(2, n+1):
  if i == 2:
    li = l0
    lj = l1
  l = li + lj
  li = lj
  lj = l
print(l)

### FIXED CODE ###

n = int(input())
l0 = 2
l1 = 1
if n == 1:
  print(l1)
else:
  for i in range(2, n+1):
    if i == 2:
      li = l0
      lj = l1
    l = li + lj
    li = lj
    lj = l
  print(l)
a,b = [int(i) for i in input().split()]

if a < b:
    print("a < b")

elif a > b:
    print("a > b")

else a == b:
    print("a == b")

### FIXED CODE ###

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

if a < b:
   print("a < b")


elif a > b:
     print("a > b")


else:
  print("a == b")
N,A,B = map(int,list(input()))
S = input()
tmp = 0
tmpf = 0
for i in range(1,N+1):
  s = S[i]
  if s == "a":
    if tmp <= A+B:
      print("Yes")
      tmp +=1
    else:
      print("No")
  elif s == "b":
    if tmp <= A+B and tmpf <=B:
      print("Yes")
      tmp +=1
      tmpf += 1
    else:
      print("No")
  else:
    print("No")
  
  
  

### FIXED CODE ###

from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(input())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())

N,A,B = inpl()
S = input()
tmp = 1
tmpf = 1

for s in S:
	if s == 'a':
		if tmp <= A+B:
			print('Yes')
			tmp += 1
		else:
			print('No')
	elif s == 'b':
		if tmp <= A+B and tmpf <= B:
			print('Yes')
			tmpf += 1
			tmp += 1
		else:
			print('No')
	else:
		print('No')
# 21-String-Transformation.py

# ???????????????
# ????????? str ?????????????????????????????????????????????????????????????????°????????????????????????????????????
# ???????????\?????????????????????????????§??????

# print a b: str ??? a ??????????????? b ??????????????§??????????????????
# reverse a b: str ??? a ??????????????? b ??????????????§?????????????????????
# replace a b p: str ??? a ??????????????? b ??????????????§??? p ?????????????????????
# ????????§??????????????? str ????????????????????? 0 ???????????¨????????????

# Input
# 1 ?????????????????? str ????????????????????????str ?????±?°????????????????????????????
# 2 ????????????????????° q ?????????????????????????¶???? q ??????????????????????¨??????¢?????§?????????????????????

# Output
# ??? print ???????????¨???????????????????????????????????????????????????

# Constraints
# 1???str????????????1000
# 1???q???100
# 0???a???b<str?????????
# replace ????????§??? b???a+1=p?????????

# Sample Input 1
# abcde
# 3
# replace 1 3 xyz
# reverse 0 2
# print 1 4
# Sample Output 1
# xaze

# Sample Input 2
# xyz
# 3
# print 0 2
# replace 0 2 abc
# print 0 2
# Sample Output 2
# xyz
# abc

#??\???
while 1:
	# str = input()
	# op_num = int( input() )
	# for i in range(op_num):
	# 	op = input().split()
	# 	a = int(op[1])
	# 	b = int(op[2])
		# if op[0]=="replace":
		# 	str = str.replace(str[ a:b+1 ], op[3])
		# elif op[0]=="reverse":
		# 	str = str.replace(str[a:b+1], str[ b-len(str) : a-len(str)-1 : -1 ] )
		# elif op[0]=="print":
		# 	print(str[a:b+1])

### FIXED CODE ###

# 21-String-Transformation.py

# ???????????????
# ????????? str ?????????????????????????????????????????????????????????????????°????????????????????????????????????
# ???????????\?????????????????????????????§??????

# print a b: str ??? a ??????????????? b ??????????????§??????????????????
# reverse a b: str ??? a ??????????????? b ??????????????§?????????????????????
# replace a b p: str ??? a ??????????????? b ??????????????§??? p ?????????????????????
# ????????§??????????????? str ????????????????????? 0 ???????????¨????????????

# Input
# 1 ?????????????????? str ????????????????????????str ?????±?°????????????????????????????
# 2 ????????????????????° q ?????????????????????????¶???? q ??????????????????????¨??????¢?????§?????????????????????

# Output
# ??? print ???????????¨???????????????????????????????????????????????????

# Constraints
# 1???str????????????1000
# 1???q???100
# 0???a???b<str?????????
# replace ????????§??? b???a+1=p?????????

# Sample Input 1
# abcde
# 3
# replace 1 3 xyz
# reverse 0 2
# print 1 4
# Sample Output 1
# xaze

# Sample Input 2
# xyz
# 3
# print 0 2
# replace 0 2 abc
# print 0 2
# Sample Output 2
# xyz
# abc

#??\???

str = input()
op_num = int( input() )
for i in range(op_num):
	op = input().split()
	a = int(op[1])
	b = int(op[2])
	if op[0]=="replace":
		# str = str.replace(str[ a:b+1 ], op[3])
		str = str[0:a] + op[3] + str[b+1:]
	elif op[0]=="reverse":
		# str = str.replace(str[a:b+1], str[ b-len(str) : a-len(str)-1 : -1 ] )
		str = str[:a] + str[a:b+1][::-1] + str[b+1:]
	# elif op[0]=="print":
	else:
		print(str[a:b+1])
import numpy as np
A,B,H,M=list(map(int,input().split()))

short_angle = 360*(1-(H+M/60)/12)
long_angle = 360*(1-M/60)

angle=abs(short_angle-long_angle)

if angle > 180:
    angle =360-angle
    
# print(angle)

ans_2=A**2+B**2-2*A*B*np.cos(np.pi*angle/180)
ans=np.sqrt(ans_2)

print(ans)

### FIXED CODE ###

import numpy as np

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

short_angle = 360*(1-(H+M/60)/12)
long_angle = 360*(1-M/60)

angle=abs(short_angle-long_angle)

if angle > 180:
    angle =360-angle
    
# print(angle)

ans_2=A**2+B**2-2*A*B*np.cos(np.pi*angle/180)
ans=np.sqrt(ans_2)

print(ans)
N=int(input())
ans=0

for i in range(N):
  x,u=input().split()
  if u=='BTC':
    ans+=x*380000
  else:
    ans+=x

print(ans)

  
  

### FIXED CODE ###

N=int(input())
ans=0

for i in range(N):
  x,u=input().split()
  if u=='BTC':
    ans+=float(x)*380000
  else:
    ans+=int(x)

print(ans)
def main():
    k = int(input())
    s = input()
    n = len(s)

    def cmb1(n, r, mod):
        if ( r<0 or r>n ):
            return 0
        r = min(r, n-r)
        return g1[n] * g2[r] * g2[n-r] % mod

    mod = 10**9+7 #出力の制限
    N = 10**6
    g1 = [1, 1] # 元テーブル
    g2 = [1, 1] #逆元テーブル
    inverse = [0, 1] #逆元テーブル計算用テーブル

    for i in range( 2, N + 1 ):
        g1.append( ( g1[-1] * i ) % mod )
        inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
        g2.append( (g2[-1] * inverse[-1]) % mod )

    def power(a, n, mod):
        bi=str(format(n,"b")) #2進数
        res=1
        for i in range(len(bi)):
            res=(res*res) %mod
            if bi[i]=="1":
                res=(res*a) %mod
        return res

    ans = 0
    for i in range(k+1):
        temp = power(25, i, mod)
        temp *= cmb1(i+n-1, n-1, mod)
        temp %= mod
        temp *= power(26, k-i, mod)
        temp %= mod
        ans += temp
    print(ans%mod)

if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    k = int(input())
    s = input()
    n = len(s)

    def cmb1(n, r, mod):
        if ( r<0 or r>n ):
            return 0
        r = min(r, n-r)
        return g1[n] * g2[r] * g2[n-r] % mod

    mod = 10**9+7
    N = 2*10**6
    fac = [1]*(N+1)
    finv = [1]*(N+1)
    for i in range(N):
        fac[i+1] = fac[i] * (i+1) % mod
    finv[-1] = pow(fac[-1], mod-2, mod)
    for i in reversed(range(N)):
        finv[i] = finv[i+1] * (i+1) % mod

    def cmb1(n, r, mod):
        if r <0 or r > n:
            return 0
        r = min(r, n-r)
        return fac[n] * finv[r] * finv[n-r] % mod

    def power(a, n, mod):
        bi=str(format(n,"b")) #2進数
        res=1
        for i in range(len(bi)):
            res=(res*res) %mod
            if bi[i]=="1":
                res=(res*a) %mod
        return res

    ans = 0
    for i in range(k+1):
        temp = power(25, i, mod)
        temp *= cmb1(i+n-1, n-1, mod)
        temp %= mod
        temp *= power(26, k-i, mod)
        temp %= mod
        ans += temp
    print(ans%mod)

if __name__ == '__main__':
    main()
y, m, d = int(input().split("/"))

if y < 2019:
    print("Heisei")
elif m <= 4 :
    print("Heisei")
else:
    print("TBD")

### FIXED CODE ###

year, month, day = map(int, input().split("/"))
if year <= 2019 and month <= 4 and day <= 30:
    print("Heisei")
else:
    print("TBD")
n,a,b = map(int,input().split())

mod = 10**9+7
def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)

fac = [0]*(n+1)
fac[0] = 1
fac[1] = 1
for i in range(2,n+1):
    fac[i] = fac[i-1] * i % mod

c = 0
if n % 2 == 0:
    for i in range(1,n//2 ):
        c += ( fac[n] * modinv(fac[i]) )%mod * modinv(fac[n-i]) % mod
    c *= 2
    c += ( fac[n] * modinv(fac[n//2]) )%mod * modinv(fac[n-n//2]) % mod
    c -= ( fac[n] * modinv(fac[a]) )%mod * modinv(fac[n-a]) % mod
    c -= (fac[n] * modinv(fac[b])) % mod * modinv(fac[n-b]) % mod
    c += 1
    if c > 0:
        c = c % mod
else:
    for i in range(1, n // 2 + 1):
        c += (fac[n] * modinv(fac[i])) % mod * modinv(fac[n - i]) % mod
    c *= 2
    c -= (fac[n] * modinv(fac[a])) % mod * modinv(fac[n - a]) % mod
    c -= (fac[n] * modinv(fac[b])) % mod * modinv(fac[n - b]) % mod
    c += 1
    if c >0:
        c = c % mod

print(max(c,0))

### FIXED CODE ###

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

mod = 10**9+7
def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)

def com(n,k,mod=10**9+7):
    u = 1
    s = 1
    for i in range(n,n-k,-1):
        u = u*i % mod
    for i in range(k,0,-1):
        s = s*i % mod
    return u * modinv(s)

c = pow(2,n,mod)
c -= 1
c -= com(n,a)
c -= com(n,b)
print(c%mod)
import itertools

n = int(input())
s = list(input())
s1 = [1 if s[i] == 'I' else -1 for i in range(n)]
cumsum = list(itertools.accumulate(s1))
print(s1)
print(cumsum)
ans = max(cumsum)
print(max(ans, 0))

### FIXED CODE ###

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

ans = max(a*b, c*d)
print(ans)
S=input();
K=input();
i = 0;
for i in range(len(S)) :
    if int(S[i]) > 1 :
        print(S[i]);
        break;
    elif i + 1 >= K :
        print(1);


### FIXED CODE ###

S=input();
K=input();
i = 0;
for i in range(len(S)) :
    if int(S[i]) > 1 :
        print(S[i]);
        break;
    elif i + 1 >= int(K) :
        print(1);
        break;
n = int(input())

r_min = int(input())
r_t = int(input())
g_max = r_t - r_min
r_ min = min(r_min, r_t)

for _ in range(n-2):
    r_t = int(input())
    g_max  = max(g_max, r_t - r_min)
    r_min = min(r_min,r_t)
print(g_max)

### FIXED CODE ###

n = int(input())
r_min = int(input())
r_t = int(input())
g_max = r_t - r_min
r_min = min(r_t, r_min)

for _ in range(n - 2):
    r_t = int(input())
    g_max = max(g_max, r_t -r_min)
    r_min = min(r_t, r_min)
print(g_max)
import sys
from collections import defaultdict

n, m = tuple(map(int, sys.stdin.buffer.readline().split()))
L = tuple(tuple(map(int, sys.stdin.buffer.readline().split())) for _ in range(m))

# print(n, m)
# print(L)

X = [n + 1] * (n + 1)
X[1] = 0
Y = [0] * (n + 1)
d = defaultdict(set)
for a, b in L:
    d[a].add(b)
    d[b].add(a)
# print(d)
def search(i):
    for b in d[i]:
        point = X[i] + 1
        # print(f' {X[i]}')
        if point < X[b]:
            # print(i, b, X)
            X[b] = point
            # Y[b] = i
            search(b)
    
search(1)
# print(X)
s = X[0]
try:
    X.index(X[0], 1)
except ValueError:
    print('Yes')
    # for v in X[2:]:
    #     print(v)
    for i in range(2, n + 1):
      c = X[i]
      for v in d[i]:
        # print(i, c, v, X[v], c - 1== X[v])
        if c - 1 == X[v]:
          Y[i] = v
          break
    for v in Y[2:]:
        print(v)
else:
    print('No')


### FIXED CODE ###

import sys
from collections import defaultdict, deque

n, m = tuple(map(int, sys.stdin.buffer.readline().split()))
L = tuple(tuple(map(int, sys.stdin.buffer.readline().split())) for _ in range(m))

# print(n, m)
# print(L)

X = [n + 1] * (n + 1)
Y = [0] * (n + 1)
d = defaultdict(set)
for a, b in L:
    d[a].add(b)
    d[b].add(a)
# print(d)

X0 = X[0]
X[1] = 0
qu = deque([1])
while qu:
  i = qu.popleft()
  cost = X[i]
  for b in d[i]:
    if X[b] == X0:
      X[b] = cost + 1
      qu.append(b)

# print(X)
s = X[0]
try:
    X.index(X[0], 1)
except ValueError:
    print('Yes')
    # for v in X[2:]:
    #     print(v)
    for i in range(2, n + 1):
      c = X[i]
      for v in d[i]:
        # print(i, c, v, X[v], c - 1== X[v])
        if c - 1 == X[v]:
          Y[i] = v
          break
    for v in Y[2:]:
        print(v)
else:
    print('No')
import math

m = int(input())
dc = []

sum_c = 0
before_num = 0
add_two = 0
kuriage = 0

for i in range(m):
  array = list( map(int, input().split()) )
  dc.append(array)
  sum_c += int(dc[i][1])
  
cnt = sum_c - 1

for i in range(m):
  add_two += int(dc[i][0]) * int(dc[i][1])
  if add_two % 9 == 0:
    cnt += add_to // 9
    add_two = 9
  else:
    cnt += add_two // 9
    add_two = add_two % 9

print(cnt)

### FIXED CODE ###

#https://atcoder.jp/contests/ddcc2020-qual/submissions/8587774

M = int(input())
dc = [list(map(int, input().split())) for _ in range(M)]
 
d = [dc[i][0] for i in range(M)]
c = [dc[i][1] for i in range(M)]
 
ans = sum(c) - 1
s = 0
 
for i in range(M):
    s += c[i] * d[i]
    if s % 9 != 0:
        ans += s // 9
        s = s % 9
    else:
        ans += s//9 - 1 
        s = 9
print(ans)
import sys
sys.setrecursionlimit(10**6)

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

mod = 10**9 + 7

p = [1] * (k - 1)  # {k-2}_P_{i} for i=0,1,...,k-2
for i in range(1, k - 1):
    p[i] = (p[i - 1] * (k - 1 - i)) % mod

g = [[] for _ in range(n + 1)]

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

node_left = set([i for i in range(1, n + 1)])

root = max(1, n // 2)


def dfs(t):
    if t == root:
        node_left.remove(t)
        children = g[t]
        if len(children) + 1 > k:
            return 0
        else:
            ret = k * (k - 1) * p[len(children) - 1]
            for c in children:
                node_left.remove(c)
                ret = (ret * dfs(c)) % mod
            return ret
    else:
        children = []
        for u in g[t]:
            if u in node_left:
                children.append(u)
                node_left.remove(u)
        if len(children) + 2 > k:
            return 0
        else:
            ret = p[len(children)]
            for c in children:
                ret = (ret * dfs(c)) % mod

            return ret


print(dfs(root))


### FIXED CODE ###

import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

sys.setrecursionlimit(100005)

n, k = na()
g = [[] for _ in range(n)]
for _ in range(n - 1):
    a, b = na()
    g[a - 1].append(b - 1)
    g[b - 1].append(a - 1)

mod = 10**9 + 7


def dfs(cur, par, k, g):
    ret = 1
    nc = 0 if par == -1 else 1
    for e in g[cur]:
        if e == par: continue
        nc += 1
        ret = ret * (k - nc) % mod
        ret = ret * dfs(e, cur, k, g) % mod
    return ret % mod


print(dfs(0, -1, k, g) * k % mod)
import math
N = int(input())
A_list = list(map(int,input().split()))
answer = 1.
for a in A_list:
    answer*=a

if math.log10(answer) > 18:
    print("-1")
else:
    print(answer)


### FIXED CODE ###

N = int(input())
A_list = list(map(int,input().split()))
A_list.sort()
#print(A_list)
if A_list[0]==0:
    answer = 0
else:      
    answer = 1
    for a in A_list:
        answer *= a
        if len(str(answer-1)) > 18:
            answer = -1
            break
print(answer)
t=raw_input().split(“”)
count=0
for i in t:
    if i == “1”:
        count+=1
print count

### FIXED CODE ###

t=list(raw_input())
count=0
for i in t:
    if i == "1":
        count+=1
print count
d = 0

while d == 0:
    i = raw_input()
    x, y = i.split()
    x = int(x)
    y = int(y)
    
    if x != 0 and y != 0:
        if x > y:
            print("%d %d" %(y,x))
        else:
            print("%d %d" %(x,y))
    else:
        d = 2
        

### FIXED CODE ###

i = 1

while i == 1:
    r = raw_input()
    x, y = r.split()
    x = int(x)
    y = int(y)
    
    if x == 0 and y == 0:
        i = 0
    elif x > y:
        print ("%d %d" %(y, x))
    else:
        print ("%d %d" %(x, y))
N, K   = map(int, input().split())
L = list(map(int, input().split()))
if L[-1] < 0:
    n = -1
elif L[0] >0:
    n = 0
for i in range(len(L)-1):
    if L[i] <= 0 and L[i+1] >= 0:
        n = i+1
L.insert(n,0)


dis = []
for i in range(N-K+1):
    if 0 in L[i:i+K+1]:
        l = L[i:i+K+1]
        d = abs(l[0]) + abs(l[-1])*2
        dis.append(d)
        d = abs(l[0])*2 + abs(l[-1])
        dis.append(d)
print(min(dis))


### FIXED CODE ###

N, K  = map(int,input().split())
L =list(map(int,input().split()))
Lzero = list(filter(lambda x:x==0,L))
Lright = list(filter(lambda x:x>0,L))
Lleft = list(map(lambda x:abs(x),filter(lambda x:x<0,L)))[::-1]
K -= len(Lzero)
if K <= 0:
    print(0)
    quit()

dis = []
if len(Lright) == 0:
    print(Lleft[K-1])
    quit()
if len(Lleft) == 0:
    print(Lright[K-1])
    quit()
try :
    dis.append(Lright[K-1])
    dis.append(Lleft[K-1])
except:
    pass


for i in range(len(Lright)):
    remain = K
    if i+1 >K:
        break
    elif i+1 == K:
        dis.append(Lright[i])
        break
    d = 2*Lright[i]
    remain -= (i+1)
    try :
        d += Lleft[remain-1]
        dis.append(d)
    except:
        pass
for i in range(len(Lleft)):
    remain = K
    if i+1 >K:
        break
    elif i+1 == K:
        dis.append(Lleft[i])
        break
    d = 2*Lleft[i]
    remain -= (i+1)
    try:
        d += Lright[remain-1]
        dis.append(d)
    except:
        pass
print(min(dis))
a,b = list(map(int,input()))
if a < b:
    print(a-1)
else:
    print(a)

### FIXED CODE ###

a,b = list(map(int,input().split()))
if a > b:
    print(a-1)
else:
    print(a)
ind_b = 0
max_b = 0
for i in range(1, N + 1):
    if cumsum_a[i] <= K:
        max_a = i
    else:
        break

for i in range(1, M + 1):
    if cumsum_b[i] <= K:
        max_b = i
    else:
        break

for i in range(max_a, -1, -1):
    for j in range(ind_b, max_b+1):
        if cumsum_b[j] + cumsum_a[i] <= K:
            # print("ok")
            num_book = max(i + j, num_book)
            ind_b = j
        else:
            break
print(num_book)

### FIXED CODE ###

import numpy as np

N, M, K = list(map(int, input().split()))
A = list(map(int, [0] + input().split()))
B = list(map(int, [0] + input().split()))
cost = 0
cumsum_a = np.cumsum(A)
cumsum_b = np.cumsum(B)

num_book = 0
max_a = 0
ind_b = 0
max_b = 0
for i in range(1, N + 1):
    if cumsum_a[i] <= K:
        max_a = i
    else:
        break

for i in range(1, M + 1):
    if cumsum_b[i] <= K:
        max_b = i
    else:
        break

for i in range(max_a, -1, -1):
    for j in range(ind_b, max_b+1):
        if cumsum_b[j] + cumsum_a[i] <= K:
            # print("ok")
            num_book = max(i + j, num_book)
            ind_b = j
        else:
            break
print(num_book)