Harryxun/stf_run huggingface dataset:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys

LIMIT = 1000000
is_prime = [True for i in range(LIMIT+1)]
p = 2
while p**2 <= LIMIT:
    if is_prime[p]:
        for i in range(p*2, n+1, p):
            is_prime[i] = False
    p += 1

for line in sys.stdin.readlines():
    n = int(line.strip())
    if n <= 1:
        print(0)
        continue
    if n == 2:
        print(1)
        continue
    num_prime = 1
    for i in range(3, n+1):
        if is_prime[i]:
            num_prime += 1
    print(num_prime)

### FIXED CODE ###

#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys

LIMIT = 1000000
is_prime = [True] * (LIMIT+1)
p = 2
while p**2 <= LIMIT:
    if is_prime[p]:
        for i in range(p*2, LIMIT+1, p):
            is_prime[i] = False
    p += 1

for line in sys.stdin.readlines():
    n = int(line.strip())
    if n <= 1:
        print(0)
        continue
    if n == 2:
        print(1)
        continue
    num_prime = 1
    for i in range(3, n+1):
        if is_prime[i]:
            num_prime += 1
    print(num_prime)
import sys
input = sys.stdin.readline

k, x = [int(i) for i in input().split()]
minimum = 1_000_000 - k + 1 if x + k - 1 > 1_000_000 else max(x - k + 1, -1_000_000)
maximum = -1_000_000 + k - 1 if x - k - 1 < -1_000_000 else min(x + k - 1, 1_000_000)
print(*range(minimum, maximum + 1))

### FIXED CODE ###

k, x = [int(i) for i in input().split()]
minimum = 1000000 - k + 1 if x + k - 1 > 1000000 else max(x - k + 1, -1000000)
maximum = -1000000 + k - 1 if x - k - 1 < -1000000 else min(x + k - 1, 1000000)
print(*range(minimum, maximum + 1))
#天秤
  
a,b,c,d=map(int,input().split())

l=a+b
r=c+d

if l==r:
	print("Balanced")
else:
	if l>r:
		print("Left")
	else:
		print("Right")

### FIXED CODE ###

#1以上N以下の整数のうち、10進法で各桁の和がA以上B以下であるものについて総和
  
n,a,b=map(int,input().split())
def s(x):
        return x//10000 + x%10000//1000 + x%1000//100 + x%100//10 + x%10

sum=0

for i in range(n+1):
        if a<=int(s(i))<=b:
                sum+=i

print(sum)
H, W = map(int, input().split())
S = [input() for _ in range(H)]
# print(S)
INF = 10**9

V = H*W
d = [[INF for _ in range(V)] for _ in range(V)]
for i in range(H):
    for j in range(W):
        if S[i][j] == '.':
            v = i*H + j
            d[v][v] = 0
            if i != 0 and S[i-1][j] == '.':
                x = (i-1)*H + j
                d[v][x] = 1
                d[x][v] = 1
            if i != H-1 and S[i+1][j] == '.':
                x = (i+1)*H + j
                d[v][x] = 1
                d[x][v] = 1
            if j != 0 and S[i][j-1] == '.':
                x = i*H + j-1
                d[v][x] = 1
                d[x][v] = 1
            if j != W-1 and S[i][j+1] == '.':
                x = i*H + j+1
                d[v][x] = 1
                d[x][v] = 1

def warshall_floyd(d):
    #d[i][j]: iからjへの最短距離
    for k in range(V):
        for i in range(V):
            for j in range(V):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d

d = warshall_floyd(d)
# print(d)
ans = 0
for i in range(V):
    for j in range(V):
        if d[i][j] != INF:
            ans = max(ans, d[i][j])

print(ans)


### FIXED CODE ###

INF = 1001001001
from collections import deque
h,w = map(int,input().split())
s = [input() for _ in range(h)]
di = (-1, 0, 1, 0)
dj = ( 0,-1, 0, 1)

ans = 0
for si in range(h):
    for sj in range(w):
        if s[si][sj] == '#': continue
        dist = [[INF] * w for _ in range(h)]
        dist[si][sj] = 0
        q = deque([(si,sj)])
        while len(q) > 0:
            i,j = q.popleft()
            for dir in range(4):
                ni = i + di[dir]
                nj = j + dj[dir]
                if (ni<0 or ni>=h or nj<0 or nj>=w): continue
                if s[ni][nj] == '#': continue
                if dist[ni][nj] != INF: continue
                q.append((ni,nj))
                dist[ni][nj] = dist[i][j] + 1
        for i in range(h):
            for j in range(w):
                if dist[i][j] == INF: continue
                ans = max(ans, dist[i][j])
print(ans)
import sys
 
a = []
for l in sys.stdin:
    if l == '\n' or l == '\r' or l == '\r\n':
        break
    else :
        a.append(l)
 
target = a[int(a[0])]
num = 0

sortedA = []

for i in a:
    sortedA.append(''.join(sorted(a[i])))
sortedA.pop(0)

for i in range(1, len(a) - 1):
    for j in range(i + 1, len(a)):
        flag = False
        if sortedA[i]==sortedA[j]:
            flag = True
        else:
            flag = False
        if flag:
            num = num + 1
print(num)

### FIXED CODE ###

import sys
import collections

n=int(input())
a=[''.join(sorted(input())) for _ in range(n)]

ans = 0
for v in collections.Counter(a).values():
    if v != 1:
        ans += v * (v - 1) // 2
print(ans)
n = int(input())
s = input()
seq = list(set(list(s)))
genkai_list = []
for i in range(0,1000):
    if 0 <= i <= 9:
        ap = "00" + str(i)
        genkai_list.append(ap)
    elif 10 <= i <= 99:
        ap = "0" + str(i)
        genkai_list.append(ap)
    else:
        genkai_list.append(str(i))
ans = []
for a in range(len(genkai_list)):
    for i in range(len(s)):
        if s[i] == genkai_list[a][0]:
            for j in range(i + 1, len(s)):
                if s[j] == genkai_list[a][1]:
                    for k in range(j + 1, len(s)):
                        if s[k] == genkai_list[a][2]:
                            ans.append(a)
                            break # break1
                    else:  # break1されなかった場合
                        continue
            else:
                continue # jのループが全部回った（2文字目で一致しなかった）ら、iを次の文字に
    else:
        continue # iのループが全部回った（1文字目で一致しなかった）ら、aを次の文字に
                
print(len(set(ans)))

### FIXED CODE ###

from math import ceil,floor
x = int(input())

lower_sum = ceil(x/105)
upper_sum = floor(x/100)
num_list = list(range(lower_sum, upper_sum+1))

for i in num_list:
    for a in range(i+1):
        for b in range(i+1-a):
            for c in range(i+1-a-b):
                for d in range(i+1-a-b-c):
                    for e in range(i+1-a-b-c-d):
                        for f in range(i+1-a-b-c-d-e):
                            if 100*a + 101*b + 102*c + 103*d + 104*e + 105*f == x:
                                print("1")
                                exit()

print("0")
from collections import deque

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

A.sort(reverse=True)

if N == 2:
    print(A[1])
else:
    ans = A[0]
    friendly_deque = deque()
    friendly_deque.append(A[1])
    friendly_deque.append(A[1])
    
    #print(ans,friendly_deque)
    
    for i in range(2,N):
        add = friendly_deque.popleft()
        ans += add
        friendly_deque.append(A[i])
        friendly_deque.append(A[i])
        #print(ans,friendly_deque)
print(ans)

### FIXED CODE ###

from collections import deque

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


A.sort(reverse=True)

if N == 2:
    print(A[0])
else:
    ans = A[0]
    friendly_deque = deque()
    friendly_deque.append(A[1])
    friendly_deque.append(A[1])
    
    for i in range(2,N):
        add = friendly_deque.popleft()
        ans += add
        friendly_deque.append(A[i])
        friendly_deque.append(A[i])

    print(ans)
A,B = map(int, input().split())
X = int((A/0.08)+0.5)
Y = int((B/0.1)+0.5)
min = 0
if X == Y:
    min = X
elif X > Y:
    if int(X*0.1) == B:
        min = X
    else :
        min = -1
elif X < Y:
    if int(Y*0.08) == A:
        min = Y
    else :
        min = -1
else :
    min = -1

print(min)

### FIXED CODE ###

S = input()
if S == 'AAA' or S == 'BBB':
    print('No')
else :
    print('Yes')
n = int(input())
t = [0] + list(map(int,input().split()))
s = sum(t)
for _ in [0]*int(input()):
  p,x = map(int,input().split())
  pritn(s-t[p]+x)


### FIXED CODE ###

n = int(input())
t = [0] + list(map(int,input().split()))
s = sum(t)
for _ in [0]*int(input()):
  p,x = map(int,input().split())
  print(s-t[p]+x)
a,b,x=map(int,input().split())
n=b-a+1
l=[0]*(n+1)
init=a
for i in range(1,n+1):
    if init%x==0:
        l[i]=l[i-1]+1
    else:
        l[i]=l[i-1]
    init+=1
    
print(l[-1]-l[0])

### FIXED CODE ###

#048-C
n,x=map(int,input().split())
a=list(map(int,input().split()))
a_sum=sum(a)
ans=0
if a[0]>x:
    a[0]=x
    ans+=a[0]-x
else:
    ans+=a[0]
for i in range(n-1):
    if a[i]+a[i+1]>x:
        a[i+1]-=a[i+1]+a[i]-x
        ans+=a[i+1]
print(a_sum-sum(a))
n=int(input())
a=list(map(int,input().split()))

inp = [0]*(n+1)
for i in range(n):
  inp[a[i]] += 1

count = [0] * (n)
for i in range(n):
  if count[a[i]] != 0:
    continue
  
  inp[a[i]] -= 1
  for j in range(1,n):
    if inp[j] <= 0:
      continue
    count[a[i]] += inp[j]*(inp[j]-1) // 2
  inp[a[i]] += 1

for i in range(n):
  print(count[a[i]])

### FIXED CODE ###

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

def choose2(n):
  if n <= 1:
    return 0
  return n*(n-1)//2

inp = [0]*(n+1)
for i in range(n):
  inp[a[i]] += 1

total = 0
for i in range(n+1):
  total += choose2(inp[i])

for i in range(n):
  count = total - choose2(inp[a[i]]) + choose2(inp[a[i]]-1)
  print(count)
n = int(input())

if(n <= 9):
    return n

elif(n <= 99):
    return 9

elif(n <= 999):
    return (n - 90)

elif(n <= 9999):
    return 909

elif(n <= 99999):
    return (n - 9090)

else:
    return 90909

### FIXED CODE ###

n = int(input())

if(n <= 9):
    print(n)

elif(n <= 99):
    print(9)

elif(n <= 999):
    print(n - 90)

elif(n <= 9999):
    print(909)

elif(n <= 99999):
    print(n - 9090)

else:
    print(90909)
n = int(input())
s = input()
k = int(input())
for i in s:
  if s[i] == s[k-1]:
    s[i] = '*'
    print(s[i], end = '')

### FIXED CODE ###

n = int(input())
s = input()
k = int(input())
for i in s:
  if i == s[k-1]:
    print(i, end = '')
  else:
    print('*', end = '')
A = input()
B = input()
A = int(A)
B = int(B)
K = (A+B) / 2

if K % 2 == 0:
    print(K)
else:
    print("IMPOSSIBLE")
    

### FIXED CODE ###

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

if (A+B) % 2 == 0 and A != B:
    print((A+B)//2)
else:
    print("IMPOSSIBLE")
N, M = map(int, input().split())
ls = []
for i in range(1,M):
  if M%i==0:
    j = M//i
    if i<=M//N:
      ls += [i]
    if j<=M//N:
      ls += [j]
  if M**0.5<i:
    break
print(max(ls))

### FIXED CODE ###

N, M = map(int, input().split())
ls = []
for i in range(1,M+1):
  if M%i==0:
    j = M//i
    if i<=M//N:
      ls += [i]
    if j<=M//N:
      ls += [j]
  if M**0.5<i:
    break
print(max(ls))
R = intinput()
print(2*R*3.1415)

### FIXED CODE ###

# from fractions import gcd
# mod = 10 ** 9 + 7
# N = int(input())
# a = list(map(int,input().split()))
# a,b,c = map(int,input().split())
# ans = [0] * N
# math.ceilで切り上げ
# dp = [[0] * 4 for i in range(3)] #2次元配列初期化
# dp = [[[0] * 2 for i in range(3)] for j in range(5)]
# (ord('A'))でASCII出力 Aは65
import math
import numpy as np
import statistics
import string
import sys
from array import array
from collections import deque
from functools import wraps
import time

def intinput():
    return int(input())
def listintinput():
    return list(map(int, input().split()))
def splitintinput():
    return map(int, input().split())
def factorialsurplus(x, y, z):  # xからyまでの階乗をzで割ったあまりを求める
    ret = 1
    for i in range(x, y + 1):
        ret = (ret * i) % z
    return (ret)
def isprime(x):
    if x == 1:
        return False
    if x == 2:
        return True
    sq = int(math.sqrt(x))
    for i in range(2,sq+1):
        if x % i == 0:
            return False
    return True
def hcfnaive(a,b):#最大公約数 math.gcdが使えない時の手段として入れとく。pythonが更新されたらいらなくなるはず
    if(b==0):
        return a
    else:
        return hcfnaive(b,a%b)

R = intinput()
print(2*R*3.1415)
n=int(input())
ab=[[]for _ in range(n)]
for _ in range(n-1):
	a,b=map(int,input().split())
	ab[a-1].append(b-1)
	ab[b-1].append(a-1)
c=list(map(int,input().split()))
c.sort()
print(sum(c)-c[-1])
ans=[-1]*n
cnt=0
node=[]
visited=[0]*n
ans=[-1]*n
def dfs(x):
	global cnt
	ans[x]=c[-cnt-1]
	visited[x]=1
	for next in ab[x]:
		if visited[next]==0:
			cnt+=1
			dfs(next)
dfs(0)
print(*ans)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**5*5)
n=int(input())
ab=[[]for _ in range(n)]
for _ in range(n-1):
	a,b=map(int,input().split())
	ab[a-1].append(b-1)
	ab[b-1].append(a-1)
c=list(map(int,input().split()))
c.sort()
print(sum(c)-c[-1])
ans=[-1]*n
cnt=0
node=[]
visited=[0]*n
ans=[-1]*n
def dfs(x):
	global cnt
	ans[x]=c[-cnt-1]
	visited[x]=1
	for next in ab[x]:
		if visited[next]==0:
			cnt+=1
			dfs(next)
dfs(0)
print(*ans)
from fraction import lcm

a,b,c,d = map(int,input().split())
a-=1
print(b//c+b//d-a//c-a//d-b//(c*d/lcm(c,d)))


### FIXED CODE ###

from fractions import gcd
def lcm(a,b):
    return a*b//gcd(a,b)
a,b,c,d = map(int,input().split())
a-=1
print((b-a)-(b//c+b//d-a//c-a//d-(b//lcm(c,d))+(a//lcm(c,d))))
from itertools import combinations as f
l,r=map(int,input().split())
print(min([i*j%2019 for i,j in f(range(l,r+1),2)]))

### FIXED CODE ###

from itertools import combinations as f
l,r=map(int,input().split())
s=set(map(lambda x:x%2019,range(l,r+1)[:2019]))
print(min([i*j%2019 for i,j in f(s,2)]))
S = list(input())
K = int(input())

if len(S) == 1:
    print(K // 2)
else :
    pre = S[0]
    flg = 0
    cnt = 0
    cnt_list =[]
    
    for i in range(1, len(S)):
        cnt += 1
        if flg == 1:
            flg = 0
            pre = S[i]
            continue
        if S[i] == pre:
            cnt_list.append(cnt)
            flg = 1
        pre = S[i]
    
    if S[0] == S[-1] and ((S[-1] == S[-2] and len(S-2) not in cnt_list) or (S[0] == S[1] and len(2) not in cnt_list)):
        print(len(cnt_list)*K)
    elif S[0] == S[-1]:
        print(len(cnt_list)*K+K)
    else :
        print(len(cnt_list)*K)

### FIXED CODE ###

S = input()
K = int(input())
 
if len(S) == 1:
    print(K // 2)
    exit()

chkd, flg = 0, 1
cnt = 0
cnt_list =[]
 
for i in range(1, len(S)):
    cnt += 1
    if S[i] != S[i-1]:
        flg = 0
    if chkd == 1:
        chkd = 0
        continue
    if S[i] == S[i-1]:
        cnt_list.append(cnt)
        chkd = 1
 
# 2個連続の場合
S2 = S*2
chkd = 0
cnt = 0
cnt_list2 =[]
 
for i in range(1, len(S2)):
    cnt += 1
    if chkd == 1:
        chkd = 0
        continue
    if S2[i] == S2[i-1]:
        cnt_list2.append(cnt)
        chkd = 1

if flg: # 全部同じ場合
    print(len(S)*K // 2)
elif S[0] == S[-1]:
    print(len(cnt_list) + (len(cnt_list2)-len(cnt_list)) * (K - 1))
else :
    print(len(cnt_list)*K)
a,b = input().split()
c = a*b
s,sc =c.split('.')
print(s)

### FIXED CODE ###

from decimal import Decimal
a,b = input().split()
c = int(a)*Decimal(b)
print(int(c))
import sys

def calc_depth(n):
    if children[n] == set():
        return 0

    depth_l = [calc_depth(child) for child in children[n]]
    depth_l.sort(reverse=True)

    return max(depth + (i+1) for (i, depth) in enumerate(depth_l))

N = int(input())

children = [set() for i in range(N + 1)]

for i in range(N - 1):
    a = int(input())
    children[a].add(i + 2)

ans = calc_depth(1)

# print(children)

print(ans)

### FIXED CODE ###

import sys

limit = 10 ** 5 * 2
sys.setrecursionlimit(limit)

def calc_depth(n):
    if children[n] == set():
        return 0

    depth_l = [calc_depth(child) for child in children[n]]
    depth_l.sort(reverse=True)

    return max(depth + (i+1) for (i, depth) in enumerate(depth_l))

N = int(input())

children = [set() for i in range(N + 1)]

for i in range(N - 1):
    a = int(input())
    children[a].add(i + 2)

ans = calc_depth(1)

# print(children)

print(ans)
x = input()
a = []
a = map(int, raw_input().split())
b = []
d = {}
for i in range(len(a)):
    if a[i] in d:
        d[a[i]]+=1
    else:
        d[a[i]] = 1
g = []
for key in d:
    if d[key]>=2:
        b.append(key)
    if d[key]>=4:
        g.append(key)
b.sort()
g.sort()
if len(b)<2 and len(g) == 0:
    print 0
else:
    if len(b)<2:
        b.append(0)
        b.append(0)
    print max(b[len(b)-1]*b[len(b)-2], g[len(g)-1]*g[len(g)-1])

### FIXED CODE ###

x = input()
a = []
a = map(int, raw_input().split())
b = []
d = {}
for i in range(len(a)):
    if a[i] in d:
        d[a[i]]+=1
    else:
        d[a[i]] = 1
g = []
for key in d:
    if d[key]>=2:
        b.append(key)
    if d[key]>=4:
        g.append(key)
b.sort()
g.sort()
if len(b)<2 and len(g) == 0:
    print 0
else:
    if len(b)<2:
        b.append(0)
        b.append(0)
    if len(g)==0:
        g.append(0)
    print max(b[len(b)-1]*b[len(b)-2], g[len(g)-1]*g[len(g)-1])
for a in range(1,10):
	for b in range(1,10):
		i = a * b
		print(a,"x",b,"=",i,sep="")
	


### FIXED CODE ###

for a in range(1,10):
	for b in range(1,10):
		i = a * b
		print(a,"x",b,"=",i,sep="")
S = input()
h = S/3600
m = (S%3600)/60
s = (S%3600)%60
print(h,":",m,":",s)

### FIXED CODE ###

S = int(input())
h = int(S/3600)
m = int((S%3600)/60)
s = int((S%3600)%60)
print (h,m,s,sep=":")
S == int(input())
print(S // 3600 ":" (S % 3600) // 60 ":" S % 60)

### FIXED CODE ###

S = int(input())
s = S % 60
m = S // 60 % 60
h = S // 3600
print("{0}"":""{1}"":""{2}".format(h,m,s))
n = int(input())
d = [list(map(int, input().split()))for _ in range(n)]
​
cnt = 0
for i, (p, q) in enumerate(d):
    if p == q:
        cnt += 1
    else:
        cnt = 0
    if cnt == 3:        
        print("Yes")
        break
else:
    print("No")
5

### FIXED CODE ###

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

cnt = 0
for i, (p, q) in enumerate(d):
    if p == q:
        cnt += 1
    else:
        cnt = 0
    if cnt == 3:
        print("Yes")
        break
else:
    print("No")
# coding: utf-8
# Your code here!

H, W = map(int, input().split(" "))

result = True
masu = [[0 for i in range(H+2)] for j in range(W+2)]
for h in range(1, H+1):
    s = "0"+input()+"0"
    masu[h] = list(s)

# print(masu)

for h in range(1,H+1):
    for w in range(1,W+1):
        if masu[h][w] == "#":
            if ("#" == masu[h+1][w]) or ("#" == masu[h][w+1]) or ("#" == masu[h-1][w]) or ("#" == masu[h][w-1]):
                pass
            else:
                result = False

if result:
    print("Yes")
else:
    print("No")

### FIXED CODE ###


H, W = map(int, input().split(" "))

# result = True
masu = [['.' for i in range(W+2)] for j in range(H+2)]
for h in range(H):
    s = "."+input()+"."
    masu[h+1] = s

# print(masu)

for h in range(1,H+1):
    for w in range(1,W+1):
        if masu[h][w] == "#":
            if "#" == masu[h+1][w] or "#" == masu[h][w+1] or "#" == masu[h-1][w] or "#" == masu[h][w-1]:
                pass
            else:
                # result = False
                print("No")
                exit()

print("Yes")
a - input()

if a.islower():
    print("a")

else:
    print("A")

### FIXED CODE ###

a = input()

if a.islower() == True:
    print("a")

else:
    print("A")
X Y = map(int, input().split())
print(X + Y//2)

### FIXED CODE ###

X,Y = map(int, input().split())
print(X + Y//2)
from sys import exit
from itertools import accumulate,chain
n,*s=open(0).read().split()
t=[2*i.count("(")-len(i) for i in s]
if sum(t)!=0:
    print("No");exit()
st=[[min(accumulate(s_,lambda a,b: a+(1 if b=="(" else -1),initial=0)),t_] for s_,t_ in zip(s,t)]
now=0
for c in chain(sorted([x for x in st if x[1]>=0])[::-1],sorted([x for x in st if x[1]<0],lambda z:z[1]-z[0])[::-1]):
    if now+c[0]<0:
        print("No");exit()
    now+=c[1]
print("Yes")

### FIXED CODE ###

import sys
n=int(input())
s=[input() for i in range(n)]
t=[2*(i.count("("))-len(i) for i in s]
if sum(t)!=0:
    print("No")
    sys.exit()
st=[[t[i]] for i in range(n)]

for i in range(n):
    now,mi=0,0
    for j in s[i]:
        if j=="(":
            now+=1
        else:
            now-=1
        mi=min(mi,now)
    st[i].append(mi)
#st.sort(reverse=True,key=lambda z:z[1])
u,v,w=list(filter(lambda x:x[1]>=0,st)),list(filter(lambda x:x[1]<0 and x[0]>=0,st)),list(filter(lambda x:x[1]<0 and x[0]<0,st))
v.sort(reverse=True)
v.sort(reverse=True,key=lambda z:z[1])
w.sort(key=lambda z:z[0]-z[1],reverse=True)
lu=len(u)
lv=len(v)
now2=0
for i in range(n):
    if i<lu:
        now2+=u[i][0]
    elif i<lu+lv:
        if now2+v[i-lu][1]<0:
            print("No")
            break
        now2+=v[i-lu][0]
    else:
        #いや、間違ってるのここなんかーーい
        if now2+w[i-lu-lv][1]<0:
            print("No")
            break
        now2+=w[i-lu-lv][0]
else:
    print("Yes")
n,m,k=map(int, input().split())
a=list(map(int, input().split()))
b=list(map(int, input().split()))

sa=[0]*n
sb=[0]*m
s=0
for i in range(n):
  s+=a[i]
  sa[i]=s
s=0
for i in range(m):
  s+=b[i]
  sb[i]=s

if sa[n-1]+sb[m-1]<=k:
  print(n+m)
  exit()
  
if m<n:
  ans=n if sa[n-1]<=k else 0
else:
  ans=m if sb[m-1]<=k else 0

j=0
for i in reversed(range(n)):
  if sa[i]+sb[j]>k:
    continue
  while j<m and sa[i]+sb[j+1] <= k:
    j+=1
  if sa[i]+sb[j] <= k and ans<i+j+2:
    ans=i+j+2

print(ans)

### FIXED CODE ###

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

sa=[0]*(n+1)
sb=[0]*(m+1)
s=0
for i in range(n):
  s+=a[i]
  sa[i+1]=s
s=0
for i in range(m):
  s+=b[i]
  sb[i+1]=s

if sa[n]+sb[m]<=k:
  print(n+m)
  exit()

ans=0
j=0
for i in reversed(range(n+1)):
  if sa[i]+sb[j]>k:
    continue
  while j<m and sa[i]+sb[j+1] <= k:
    j+=1
  if sa[i]+sb[j] <= k and ans<i+j:
    ans=i+j

print(ans)
import numpy as np
N = int(input())
div=np.zeros(N+1,np.int64)
for n in range(1 ,N+1):
    for m in range(n,N+1,n):
        div[m]+=m
print(div.sum())


### FIXED CODE ###

from  numba import njit

@njit
def main(N):
    count=0
    for n in range(1 ,N+1):
        for m in range(n,N+1,n):
            count+=m
    print(count)
if __name__ == "__main__":
    N = int(input())
    main(N)
X,Y = map(int,input().split())
mod = 10**9+7
if (2*X-Y) % 3 != 0 or (2*Y-X) % 3 != 0:
    print(0)
    exit(0)
x,y = (2*Y-X)//3,(2*X-Y)//3
N = x+y
K = min(x,y)
def pow(x, n, mod):
    ret = 1
    while n>0:
        if (n&1):
            ret = (ret*x) % mod
        x = (x*x) % mod
        n >>= 1
    return ret
fact = [0]*(N+1)
fact[0] = 1
for i in range(1, N+1):
    fact[i] = (fact[i-1]*i) % mod
finv = [0]*(N+1)
finv[N] = pow(fact[N], mod-2, mod)
for i in range(N, 0, -1):
    finv[i-1] = (finv[i]*i) %mod

print((fact[x+y]*finv[x]*finv[y]) % mod)

### FIXED CODE ###

X,Y = map(int,input().split())
mod = 10**9+7
if (2*X-Y) % 3 != 0 or (2*Y-X) % 3 != 0:
    print(0)
    exit(0)
x,y = (2*Y-X)//3,(2*X-Y)//3
if x < 0 or y < 0:
    print(0)
    exit(0)
N = x+y
K = min(x,y)
def pow(x, n, mod):
    ret = 1
    while n>0:
        if (n&1):
            ret = (ret*x) % mod
        x = (x*x) % mod
        n >>= 1
    return ret
fact = [0]*(N+1)
fact[0] = 1
for i in range(1, N+1):
    fact[i] = (fact[i-1]*i) % mod
finv = [0]*(N+1)
finv[N] = pow(fact[N], mod-2, mod)
for i in range(N, 0, -1):
    finv[i-1] = (finv[i]*i) %mod
print((fact[x+y]*finv[x]*finv[y]) % mod)
n = int(input())
a = [int(1/e) for e in input().split()]

print(1/sum(a))


### FIXED CODE ###

n = int(input())
a = [1/int(e) for e in input().split()]

print(1/sum(a))
import sys

line = sys.stdin.readline()

tate, yoko = line.split(" ")

S = tate * yoko
T = 2 * (tate + yoko)

print S, T

### FIXED CODE ###

import sys

line = sys.stdin.readline()

tate, yoko = line.split(" ")

tate = int(tate)
yoko = int(yoko)

S = tate * yoko
T = 2 * (tate + yoko)

print '%d %d' % (S, T)
x, n = map(int, input().split())
minn = 10000000
if n == 0:
    print(x)
    exit()
p = list(map(int, input().split()))

for i in range(1, 101):
    if not i in p:
        tmp = abs(x-i)
        if minn > tmp:
            ans = i
            minn = tmp
        elif minn == tmp:
            ans = min(i, ans)

print(ans)

### FIXED CODE ###

x, n = map(int, input().split())
p = list(map(int, input().split()))
for i in range(101):
    if x-i not in p:
        print(x-i)
        exit()
    elif x+i not in p:
        print(x+i)
        exit()