Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

def main():

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

    from collections import Counter
    C = Counter(A)
    #print(C)

    X = [0]*(max(A)+1)
    for i in A:
        j = i*2
        while j <= max(A):
            X[j] = 1
            j += i
    #print(X)

    ans = 0
    for a in A:
        if C[a] == 1 and X[a] != 1:
            ans += 1
    print(ans)

if __name__ == '__main__':
    main()


### FIXED CODE ###

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

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    #divisors.sort(reverse=True)
    return divisors

def main():
    A.sort()
    S = set(A)
    m = max(A)
    X = [0]*(m+1)
    for i in range(1, m+1):
        j = i
        if j not in S:
            continue
        while j <= m:
            X[j] += 1
            j += i
    #print(X)

    D = {}
    for i in range(n):
        if A[i] not in D:
            D[A[i]] = 1
        else:
            D[A[i]] += 1

    ans = 0
    for a in A:
        if X[a] == 1 and D[a] == 1:
            ans += 1
    print(ans)

    #for i in range(m+1):
    #    if X[i] == 1:
            #print(i)

if __name__ == '__main__':
    main()
### BUGGY CODE ###

def main():
    n, a, b = map(int, input().split())
    if (b-a) % 2 == 0:
        print((b-a)//2)
    else:
        temp = [(min(n-a, b-1))]

        cnt1 = 0
        cnt2 = 0
        for i in range(0, (min(n-a, b-1))):
            if (b-(a-1) - i) % 2 == 0 and cnt1 == 0:
                temp.append(a - 1 + i + (b-(a-1) - i) // 2)
                cnt1 += 1
            elif (n - (a+(n-b)+i)) % 2 == 0 and cnt2 == 0:
                temp.append(n - b + i + (n - (a+(n-b)+i)) // 2)
                cnt2 += 1

        print(min(temp))

if __name__ == "__main__":
    main()

### FIXED CODE ###

def main():
    n, a, b = map(int, input().split())
    if (b-a) % 2 == 0:
        print((b-a)//2)
    else:
        temp = [(min(n-a, b-1))]

        cnt1 = 0
        cnt2 = 0
        for i in range(0, (min(n-a, b-1))):
            if (b-(a-1) - i) % 2 == 0 and cnt1 == 0:
                temp.append(a - 1 + i + (b-(a-1) - i) // 2)
                cnt1 += 1
            elif (n - (a+(n-b)+i)) % 2 == 0 and cnt2 == 0:
                temp.append(n - b + i + (n - (a+(n-b)+i)) // 2)
                cnt2 += 1

            if cnt1 == 1 and cnt2 == 1:
                break

        print(min(temp))

if __name__ == "__main__":
    main()
### BUGGY CODE ###

n = int(input())
a = []
for i in range(n):
    a.append(int(input()))

max_val = max(a)

for i in range(n):
    if max_val > a[i]:
        print(max_val)
        
    elif max_val == a[i]:
        temp = a[i]
        a[i] = 0
        print(max(a))
        a[i] = temp

### FIXED CODE ###

n = int(input())
a = []
for i in range(n):
    a.append(int(input()))

a_sort = sorted(set(a))

max_val_1 = a_sort[-1]
max_total_1 = a.count(max_val_1)

if len(a_sort) >= 2:
    max_val_2 = a_sort[-2]

#print("max val:{}".format(max_val_1))
#print("max total:{}".format(max_total_1))

for i in range(n):
    if max_total_1 >=2:
        print(max_val_1)
    
    elif a[i] < max_val_1:
        print(max_val_1)

    elif a[i] == max_val_1 and max_total_1 == 1:
        print(max_val_2)
    else:
        print("err")
### BUGGY CODE ###

N,K = map(int,input().split())
A = list(map(int,input().split()))
S = []
for i in range(N):
    t = i
    s = 0
    for j in range(t,N):
        s += A[j]
        S.append(s)
n = len(S)
x = 0
for i in range(40):
    m = 40 - i
    t = m - 1
    k = 0
    for j in range(n):
        if (x+2**t)&S[j] == x+2**t:
            k += 1
    if k >= K:
        x += 2**t
print(x)

### FIXED CODE ###

N,K = map(int,input().split())
A = list(map(int,input().split()))
S = []
for i in range(N):
    t = i
    s = 0
    for j in range(t,N):
        s += A[j]
        S.append(s)
n = len(S)
x = 0
for i in range(40):
    m = 40 - i
    t = m - 1
    k = 0
    for j in range(n):
        if (x+2**t)&S[j] == x+2**t:
            k += 1
    if k >= K:
        x += 2**t
print(x)
### BUGGY CODE ###

H, N = map(int, input().split())
AB = []
for _ in range(N):
    AB.append(tuple(map(int, input().split())))
max_a = max(ab[0] for ab in AB)
table = [0] + [float('inf')] * (H + max_a)

for i in range(N):
    for j in range(AB[i][0], H + max_a):
        table[j] = min(table[j], table[j - AB[i][0]] + AB[i][1])
print(min(table[H:]))


### FIXED CODE ###

H, N = map(int, input().split())
AB = []
for _ in range(N):
    AB.append(tuple(map(int, input().split())))
max_a = max(ab[0] for ab in AB)
table = [0] + [float('inf')] * (H + max_a)

for i in range(N):
    for j in range(AB[i][0], H + max_a):
        table[j] = min(table[j], table[j - AB[i][0]] + AB[i][1])
print(min(table[H:]))
### BUGGY CODE ###

N,Q=map(int,input().split())
S=input()
for q in range(Q):
    l,r=map(int,input().split())
    y=S[l-1:r]
    ans=0
    for i in range(len(y)-1):
        if y[i:i+2]=='AC':
            ans+=1
    print(ans)    

### FIXED CODE ###

import numpy as np

N,Q=map(int,input().split())
y=input()
arr=np.zeros(len(y))
for i in range(len(y)-1):
    if y[i:i+2]=='AC':
        arr[i+1]=arr[i]+1
    else:
        arr[i+1]=arr[i]
              
for q in range(Q):
    l,r=map(int,input().split())
    print(int(arr[r-1]-arr[l-1]))
### BUGGY CODE ###

import numpy as np
N,T=map(int,input().split())
D=[ [x,y,z,x+y+z,10000*x+5000*y+1000*z] for x in range(N+1) for y in range(N+1)for z in range(N+1)]
D=np.array(D)
index = np.where(D[:, -1] == T)
DD=D[index]
ans = np.where(DD[:, -2] == N)
if len(DD[ans])==0:
  print("-1 -1 -1")
else:
  print(str(DD[ans][0][0])+" "+str(DD[ans][0][1])+" "+str(DD[ans][0][2]))

### FIXED CODE ###

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

L=[[h,i,N-h-i]for h in range(N+1) for i in range(N+1) if h*1000+i*5000+(N-h-i)*10000==Y and (N-h-i)>=0]

if len(L)>0:
  print(L[0][2],end=" ")
  print(L[0][1],end=" ")  
  print(L[0][0])
else:
  print("-1 -1 -1")
### BUGGY CODE ###

from collections import deque
import sys
input = sys.stdin.readline

def bfs(count,adj):
    st = deque([(0,-1)])
    while st:
        n,par = st.popleft()
        val = count[n]   
        for node in adj[n]:
            if node == par:
                continue
            else:
                count[node] += val
                st.append([node,n])
    return count

        
N,Q = map(int, input().split())
A = [() for i in range(N)]

for _ in range(N-1):
    a,b = map(int, input().split())
    A[a-1] += (b-1,)
    A[b-1] += (a-1,)

cnt = [0]*N   
for q in range(Q):
   p,x = map(int, input().split())
   cnt[p-1] += x

cnt = bfs(cnt,A)

print(*cnt)

### FIXED CODE ###

from collections import deque
import sys
input = sys.stdin.readline
        
N,Q = (int(i) for i in input().split())
A = [[] for _ in range(N)]

for _ in range(N-1):
    a,b = (int(i) for i in input().split())
    A[a-1].append(b-1)
    A[b-1].append(a-1)

cnt = [0]*N   
for q in range(Q):
   p,x = (int(i) for i in input().split())
   cnt[p-1] += x

st = deque([(0,-1)])
while st:
    n,par = st.popleft()
    val = cnt[n]   
    for node in A[n]:
        if node == par:
            continue
        else:
            cnt[node] += val
            st.append([node,n])

print(*cnt)
### BUGGY CODE ###

n, q = map(int, input().split())
s = input()
l = [list(map(int, input().split())) for i in range(q)]
for i in l:
    print(s[i[0]-1:i[1]].count("AC"))

### FIXED CODE ###

N, Q = map(int, input().split())
S = input()

nums = [0] * N
count = 0
for i in range(len(S)-1):
    nums[i] = count
    if S[i] == "A" and S[i+1] == "C":
        count += 1
nums[-1] = count

for _ in range(Q):
    l,r = map(int, input().split())
    print(nums[r-1] - nums[l-1])
### BUGGY CODE ###

N=int(input())
array=sorted([int(x) for x in input().split()])
duplicate={}
for i in array:
	if i in duplicate:
		duplicate[i]+=1
	else:
		duplicate[i]=1







for i in range(N):
	for j in range(i+1,N):
		if array[i]==False:
			break
		if array[j]%array[i]==0:
			array[j]=False

array=[x for x in array if x!=False]
for i in range(len(array)):
	if duplicate[array[i]]>1:
		array[i]=False
array=[x for x in array if x!=False]

print(len(array))

### FIXED CODE ###

N=int(input())
lineup=sorted([int(x) for x in input().split()])
duplicate={}
for i in lineup:
	if i in duplicate:
		duplicate[i]+=1
	else:
		duplicate[i]=1
b=max(lineup)+1
sieve=[1]*(b)
counter=0
for i in range(N):
	for j in range(lineup[i]*2,b,lineup[i]):
		sieve[j]=0
	if duplicate[lineup[i]]==1 and sieve[lineup[i]]==1:
		counter+=1
print(counter)
### BUGGY CODE ###

import collections
N = int(input())
A = []
for i in range(N):
  A.append(input())
a = collections.Counter(A)
n = a.most_common()[0][1]
l = []
for i in range(len(a)):
  if a.most_common()[i][1] != n:
    break
  l.append(a.most_common()[i][0])
l.sort()
for o in l:
  print(o)

### FIXED CODE ###

N = int(input())
d = {}
for i in range(N):
  s = input()
  if s in d.keys():
    d[s] += 1
  else:
    d[s] = 1
mx = 0
for i in d.values():
  mx = max(mx, i)
for i in sorted(d.items()):
  if i[1] == mx:
    print(i[0])
### BUGGY CODE ###

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

x = 0

for i in range(N):
	s = A[i]
	if s == 0:
		x += 1
	for j in range(i + 1, N):
		s += A[j]
		if s == 0:
			x += 1

print(x)

### FIXED CODE ###

from collections import defaultdict

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

d = defaultdict(int)
s = 0
d[0] += 1
for i in range(N):
	s += A[i]
	d[s] += 1

ans = 0
for key in d:
	if d[key] <= 1:
		pass
	else:
		ans += int(d[key] * (d[key] - 1) / 2)

print(ans)
### BUGGY CODE ###

from collections import defaultdict
n = int(input())
s = input()
c_dic = defaultdict(list)
for idx,i in enumerate(s):
    c_dic[i].append(idx)
ans = 0
for i in c_dic['R']:
    for j in c_dic['G']:
        ma = max(i,j)
        mi = min(i,j)
        for l in c_dic['B']:
            ma1 = max(ma,l)
            middle = max(min(ma,l),mi)
            mi1 = min(l,mi)
            if ma1 - middle !=  middle - mi1:
                ans += 1
print(ans)

### FIXED CODE ###

from collections import defaultdict
n = int(input())
s = input()
c_dic = defaultdict(list)
for idx,i in   enumerate(s):
    c_dic[i].append(idx)
ans = len(c_dic['R'])*len(c_dic['G'])*len(c_dic['B'])
for i in range(0,n-1):
    for j in range(i+1,n):
        k = 2*j - i
        if k < n and s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
            ans -= 1
print(ans)
### BUGGY CODE ###

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

p = list(map(lambda x: int(x) * (int(x)+1) // 2 / int(x), input().split()))


sum_max = 0
for i in range(n-k+1):
    sum_max = max(sum_max, sum(p[i:i+k]))
print(sum_max)

### FIXED CODE ###

n, k = map(int, input().split())
p = list(map(lambda x: int(x) * (int(x)+1) // 2 / int(x), input().split()))

prev = sum(p[0:k])
sum_max = prev
for i in range(n-k+1):
    if i == 0:
        tmp = prev
    else:
        tmp = prev - p[i-1] + p[i+k-1]

    sum_max = max(sum_max, tmp)
    prev = tmp

print(sum_max)
### BUGGY CODE ###

import bisect
from collections import deque
import math 
n,m = map(int,input().split())
a = sorted(deque(map(int, input().split())))
for i in range(m):
    p = a.pop()
    p = math.floor(p/2)
    index = bisect.bisect_left(a,p)
    a.insert(index,p)
print(sum(a))

### FIXED CODE ###

import heapq 
import math 
n,m = map(int,input().split())
a = list(map(lambda x:int(x)*(-1), input().split()))
heapq.heapify(a)
for i in range(m):
    p = heapq.heappop(a)
    p = math.ceil(p/2)
    heapq.heappush(a,p)
print(sum(a)*(-1))
### BUGGY CODE ###

N=int(input())
S=list(map(int,input().split()))
S.sort()
p = [S.pop(-1)]
r = S

for i in range(N):
    for p_ in p[::-1]:
        for k in range(len(r)):
            if r[-k-1] < p_:
                p.append(r.pop(-k-1))
                break
    p.sort()

print("Yes" if len(r)==0 else "No")

### FIXED CODE ###

N=int(input())
S=list(map(int,input().split()))
S.sort()
p = [S.pop(-1)]
r = S

for i in range(N):
    nr = []
    for p_ in p[::-1]:
        while r:
            r_ = r.pop()
            if r_ < p_:
                p.append(r_)
                break
            nr.append(r_)
    p.sort()
    r+=nr[::-1]

print("Yes" if len(r)==0 else "No")
### BUGGY CODE ###

N=int(input())
minList=[]
for i in range(N):
  if i==0:
    a=int(input())
    minList.append([a])
  else:
    a=int(input())
    MAX=-1
    argmax=-1
    for j in range(len(minList)):
      if minList[j][-1]>=MAX and minList[j][-1]<a:
        argmax=j
        MAX=minList[j][-1]
    if MAX==-1:
      minList.append([a])
    else:
      minList[argmax].append(a)

print(len(minList))

### FIXED CODE ###

from bisect import bisect_left
from collections import deque

N=int(input())
minList=deque([])
minmax=-1
for i in range(N):
  if i==0:
    a=int(input())
    minList.append(a)
    minmax=a
  else:
    a=int(input())
    if a<=minmax:
      minmax=a
      minList.appendleft(a)
    else:
      idx=bisect_left(minList,a)
      if idx==1:minmax=a
      minList[idx-1]=a
print(len(minList))
### BUGGY CODE ###

S = str(input())
a = 1
count=0
while a != 0:
    a = S.count("BW")
    count+=a
    S = S.replace("BW","WB")
print(count)

### FIXED CODE ###

S = str(input())
slist = list(S)
L = len(slist)
count = 0
fcount = 0
for i in range(L):
  if slist[i] == "W":
    count+=(i-fcount)
    fcount+=1
print(count)
### BUGGY CODE ###

#!/usr/bin/env python3
 
import sys
# 以下を記述しないとTLEになる, 何故？
#from heapq import heappush, heappop,heappushpop
from collections import defaultdict
# ---- ここまで -----------------------

S = input()
T = input()
lenS = len(S)
lenT = len(T)
F1 = [False]*26
F2 = [False]*26
alpha = 'abcdefghijklmnopqrstuvwxyz'
for i in range(lenS):
    F1[alpha.index(S[i])] = True
for i in range(lenT):
    F2[alpha.index(T[i])] = True
for i in range(26):
    if not F1[i] and F2[i]:
        print(-1)
        sys.exit()

ind = S.index(T[0])
ans = ind+1
for i in range(1,lenT):
    S = S[ind+1:] + S[:ind+1]
    ind = S.index(T[i])
    ans += ind+1

print(ans)


### FIXED CODE ###

#!/usr/bin/env python3
#ABC138 E

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

s = input()
t = input()
n = len(s)
m = len(t)
f = [False]*26
f2 = [False]*26
alpha = 'abcdefghijklmnopqrstuvwxyz'
for i in range(n):
    f[alpha.index(s[i])] = True
for i in range(m):
    f2[alpha.index(t[i])] = True
for i in range(26):
    if not f[i] and f2[i]:
        print(-1)
        quit()
ans = 0
inde = s.index(t[0])
ans += inde+1
for i in range(1,m):
    s = s[inde+1:] + s[:inde+1]
    inde = s.index(t[i])
    ans += inde+1
print(ans)
### BUGGY CODE ###

import math
n=int(input())
for i in range(int(math.sqrt(n)),n+1):
    if n%i == 0:
        a=int(n/i)-1
        b=i-1
        break
    else:
        continue
print(a+b)



### FIXED CODE ###

import math

ans=1000000000000000
n=int(input())
for i in range(1,int(math.sqrt(n))+2):
    if n%i==0:
        tmp = (i-1)+(int(n//i)-1)
        ans = min(tmp,ans)

print(ans)
### BUGGY CODE ###

N, M = map(int, input().split())
A = [int(input()) for _ in range(M)]
B = [0] * (N + 1)
B[0] = 1
if 1 not in A:
    B[1] = 1
else:
    B[1] = 0

for i in range(2, N + 1):
    if i != 2 and i - 1 in A and i - 2 in A:
        print(0)
        exit()
    elif i - 2 in A:
        B[i] = B[i - 1]
    elif i - 1 in A:
        B[i] = B[i - 2]
    else:
        B[i] = B[i - 1] + B[i - 2]
mod = 10**9 + 7
print(B[N] % mod)


### FIXED CODE ###

import sys
input = sys.stdin.readline


def binary_search(l, value):
    low = 0
    high = len(l) - 1
    while low <= high:
        mid = (low + high) // 2
        if l[mid] == value:
            return True
        elif l[mid] < value:
            low = mid + 1
        else:
            high = mid - 1
    return False


N, M = map(int, input().split())
A = [int(input()) for _ in range(M)]

A.append(10**6)
A.append(10**6)
B = [0] * (N + 1)
B[0] = 1
if binary_search(A, 1) is True:
    B[1] = 0
else:
    B[1] = 1
mod = 10**9 + 7

for i in range(2, N + 1):
    if i != 2 and binary_search(A, i - 1) is True and binary_search(
            A, i - 2) is True:
        print(0)
        exit()
    elif binary_search(A, i - 2) is True:
        B[i] = B[i - 1]
    elif binary_search(A, i - 1) is True:
        B[i] = B[i - 2]
    else:
        B[i] = B[i - 1] + B[i - 2]
    B[i] %= mod
print(B[N] % mod)
### BUGGY CODE ###

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


class SegmentTree():
    '''
    非再帰
    segment tree
    '''

    def __init__(self, n, func, init=float('inf')):
        '''
        n->配列の長さ
        func:func(a,b)->val,　func=minだとRMQになる
        木の高さhとすると,
        n:h-1までのノード数。h段目のノードにアクセスするために使う。
        data:ノード。
        parent:k->child k*2+1とk*2+2
        '''
        self.n = 2**(n-1).bit_length()
        self.init = init
        self.data = [init]*(2*self.n)
        self.func = func

    def set(self, k, v):
        '''
        あたいの初期化
        '''
        self.data[k+self.n-1] = v

    def build(self):
        '''
        setの後に一斉更新
        '''
        for k in reversed(range(self.n-1)):
            self.data[k] = self.func(self.data[k*2+1], self.data[k*2+2])

    def update(self, k, a):
        '''
        list[k]=aに更新する。
        更新ぶんをrootまで更新
        '''
        k += self.n-1
        self.data[k] = a

        while k > 0:
            k = (k-1)//2
            self.data[k] = self.func(self.data[k*2+1], self.data[k*2+2])

    def query(self, l, r):
        '''
        [l,r)のfuncを求める
        '''
        L = l+self.n
        R = r+self.n
        ret = self.init
        while L < R:
            if R & 1:
                R -= 1
                ret = self.func(ret, self.data[R-1])
            if L & 1:
                ret = self.func(ret, self.data[L-1])
                L += 1
            L >>= 1
            R >>= 1
        return ret


N, K = map(int, input().split())
A = list(map(int, input().split()))
Seg = SegmentTree(N, lambda a, b: (a+b) % K, 0)
for i, a in enumerate(A):
    Seg.set(i, a)
Seg.build()

ans = 0
for l in range(N):
    for r in range(l+1, N+1):
        if Seg.query(l, r) == r-l:
            ans += 1
print(ans)


### FIXED CODE ###

from collections import defaultdict
from itertools import accumulate
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

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

A_acc = [0]+list(accumulate(A))


ans = 0
D = defaultdict(int)
for l in range(N+1):
    t = (A_acc[l]-l) % K
    if l>=K:
      r = (A_acc[l-K]-(l-K))
      D[r%K]-=1
    ans += D[t]
    D[t] += 1


print(ans)
### BUGGY CODE ###

import sys
import heapq

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))

N, K = inm()
A = inl()
F = inl()
A.sort()
F.sort(reverse=True)


def solve():
    if N == 1:
        return max(A[0] - K, 0) * F[0]
    hp = []
    for i in range(N):
        heapq.heappush(hp, (-A[i] * F[i], F[i]))
    k = K
    while k > 0:
        t0, f0 = heapq.heappop(hp)
        if t0 == 0:
            break
        t0 = -t0
        t1, f1 = hp[0]
        t1 = -t1
        if t0 == t1:
            m = 1
        else:
            assert t0 > t1
            m = ((t0 - t1) + f0 - 1) // f0
        m = min(m, k)
        k -= m
        t0 -= m * f0
        heapq.heappush(hp, (-t0, f0))

    t0, _ = hp[0]
    return -t0


print(solve())


### FIXED CODE ###

import sys
import heapq

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))

N, K = inm()
A = inl()
F = inl()
A.sort()
F.sort(reverse=True)


def check(val):
    k = K
    for i in range(N):
        tmp = A[i] * F[i]
        if tmp <= val:
            continue
        dec = ((tmp - val) + F[i] - 1) // F[i]
        assert A[i] >= dec
        assert (A[i] - dec) * F[i] <= val
        k -= dec
        if k < 0:
            return False
    return True


def solve():
    ng, ok = -1, max([A[i] * F[i] for i in range(N)])
    while ok - ng > 1:
        mid = (ok + ng) // 2
        if check(mid):
            ok = mid
        else:
            ng = mid
    return ok


print(solve())
### BUGGY CODE ###

from itertools import accumulate
n = int(input())
a = list(accumulate(range(n)))
print(a[-1])

### FIXED CODE ###

n = int(input())
print(n*(n-1)//2)
### BUGGY CODE ###

def _integral(A):
    result = []
    sum_value = 0
    result.append(sum_value)
    for i in range(len(A)):
        sum_value += A[i]
        result.append(sum_value)
    return result


def _main(N, M, K, A, B):
    integral_a = _integral(A)
    integral_b = _integral(B)
    top_count = 0
    for a_index in range(len(A) + 1):
        a_value = integral_a[a_index]
        for b_index in range(len(B) + 1):
            if a_value + integral_b[b_index] <= K:
                if top_count < a_index + b_index:
                    top_count = a_index + b_index
    print(top_count)
    #
    #
    # sum_k = 0.0
    # a_index = 0
    # a_len = len(A)
    # b_index = 0
    # b_len = len(B)
    # while sum_k < K:
    #     current_a = A[a_index] if a_index < a_len else None
    #     current_b = B[b_index] if b_index < b_len else None
    #     if current_a is None and current_b is None:
    #         break
    #
    #     if current_a is not None and current_b is None:
    #         if K < sum_k + current_a:
    #             break
    #         sum_k += current_a
    #         a_index += 1
    #     elif current_a is None and current_b is not None:
    #         if K < sum_k + current_b:
    #             break
    #         sum_k += current_b
    #         b_index += 1
    #     elif current_a < current_b:
    #         if K < sum_k + current_a:
    #             break
    #         sum_k += current_a
    #         a_index += 1
    #     else:
    #         if K < sum_k + current_b:
    #             break
    #         sum_k += current_b
    #         b_index += 1
    #
    # print(a_index + b_index)


if __name__ == "__main__":
    Na, Ma, Ka = map(int, input().split())
    Aa = list(map(float, input().split()))
    Ba = list(map(float, input().split()))
    _main(Na, Ma, Ka, Aa, Ba)


### FIXED CODE ###

def _integral(A):
    result = []
    sum_value = 0
    result.append(sum_value)
    for i in range(len(A)):
        sum_value += A[i]
        result.append(sum_value)
    return result


def _main(N, M, K, A, B):
    integral_a = _integral(A)
    integral_b = _integral(B)
    top_count = 0
    b_max = len(B)
    for a_index in range(len(A) + 1):
        a_value = integral_a[a_index]
        if K < a_value:
            break
        for b_index in range(0, min(len(B) + 1, b_max + 1))[::-1]:
            if a_value + integral_b[b_index] <= K:
                if top_count < a_index + b_index:
                    top_count = a_index + b_index
                b_max = b_index
                break
    print(top_count)


if __name__ == "__main__":
    Na, Ma, Ka = map(int, input().split())
    Aa = list(map(float, input().split()))
    Ba = list(map(float, input().split()))
    _main(Na, Ma, Ka, Aa, Ba)