Harryxun/stf_run huggingface dataset:
import math

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

def main():
    n = int(input())

    a, b = make_divisors(n)
    a -= 1
    b -= 1
    print(a+b)
        
        
if __name__ == "__main__":
    main()


### FIXED CODE ###

import math


def main():
    n = int(input())
    a = 1
    b = n
    
    ans = n - 1 
    
    for i in range(2, int(math.sqrt(n)) + 1):
        if n % i == 0:
            a = int(i)
            b = int(n / i)
            ans = min(ans, a+b-2)
    print(ans)
        
        
if __name__ == "__main__":
    main()
from collections import defaultdict
import heapq
N,M,S = map(int,input().split())
E=[list(map(int,input().split())) for _ in range(M)]

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

A_max=max([a for _,_,a,_ in E])

D=defaultdict(lambda :[])

for u,v,a,b in E:
    u-=1;v-=1
    for from_a in range(A_max+1):
        if from_a-a<0:
            continue
        to_state_v=(v,from_a-a)
        from_state_u=(u,from_a)
        D[from_state_u].append((b,to_state_v))
        to_state_u=(u,from_a-a)
        from_state_v=(v,from_a)
        D[from_state_v].append((b,to_state_u))

for c,d in C:
    for n in range(N):
        for a in range(A_max+1):
            if a+c>A_max:
                continue
            to_state=(n,a+c)
            from_state=(n,a)
            D[from_state].append((d,to_state))


start=(0,max(A_max,S))
Q=[(0,start)]

Dist=defaultdict(lambda :float('inf'))

Dist[start]=0

while Q:
    q = heapq.heappop(Q)
    cur_time,cur_state=q

    if Dist[cur_state]<cur_time:
        continue
    for cost,next_state in D[cur_state]:
        next_time = cost+cur_time

        if Dist[next_state]>next_time:
            Dist[next_state]=next_time
            heapq.heappush(Q,(next_time,next_state))

for dest in range(1,N):
    ans=float("inf")
    for a in range(A_max+1):
        state=(dest,a)
        ans=min(ans,Dist[state])
    print(ans)


### FIXED CODE ###

from collections import defaultdict
import heapq
N,M,S = map(int,input().split())
E=[list(map(int,input().split())) for _ in range(M)]

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

A_max=max([a for _,_,a,_ in E])*N

D=defaultdict(lambda :[])

for u,v,a,b in E:
    u-=1;v-=1
    for from_a in range(A_max+1):
        if from_a-a<0:
            continue
        from_state_u=(u,from_a)
        to_state_v=(v,from_a-a)
        D[from_state_u].append((b,to_state_v))

        from_state_v=(v,from_a)
        to_state_u=(u,from_a-a)
        D[from_state_v].append((b,to_state_u))

for n,[c,d] in enumerate(C):
    for a in range(A_max+1):
        a_after=min(A_max,a+c)
        from_state=(n,a)
        to_state=(n,a_after)
        D[from_state].append((d,to_state))


start=(0,min(A_max,S))
Q=[(0,start)]

Dist=defaultdict(lambda :float('inf'))

Dist[start]=0

while Q:
    q = heapq.heappop(Q)
    cur_time,cur_state=q

    if Dist[cur_state]<cur_time:
        continue
    for cost,next_state in D[cur_state]:
        next_time = cost+cur_time

        if Dist[next_state]>next_time:
            Dist[next_state]=next_time
            heapq.heappush(Q,(next_time,next_state))

for dest in range(1,N):
    ans=float("inf")
    for a in range(A_max+1):
        state=(dest,a)
        ans=min(ans,Dist[state])
    print(ans)
# -*- coding: utf-8 -*-
"""
https://atcoder.jp/contests/dp/tasks/dp_a

"""
import sys
from sys import stdin
input = stdin.readline


def solve(N, ashiba):
    dp = [0] * N
    for i in range(1, N):
        dp[i] = min(dp[i-1] + abs(ashiba[i] - ashiba[i-1]), dp[i-2] + abs(ashiba[i] - ashiba[max(i-2, 0)]))
    return dp[-1]


import numpy as np

def main(args):
    N = int(input())
    ashiba = [int(a) for a in input().split()]
    if N <= 50000:
        ans = solve(N, ashiba)
    else:
        route_list=np.zeros((N, N))
        ans = 0
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
https://atcoder.jp/contests/dp/tasks/dp_a

"""
import sys
from sys import stdin
input = stdin.readline


def solve(N, ashiba):
    dp = [0] * N
    for i in range(1, N):
        dp[i] = min(dp[i-1] + abs(ashiba[i] - ashiba[i-1]), dp[i-2] + abs(ashiba[i] - ashiba[max(i-2, 0)]))
    return dp[-1]


def main(args):
    N = int(input())
    ashiba = [int(a) for a in input().split()]
    ans = solve(N, ashiba)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])
N,R = map(int, input().split())
if N >= 10:
  print(R)
else:
  print(R+100*(10-K))

### FIXED CODE ###

N,R = map(int, input().split())
if N >= 10:
  print(R)
else:
  print(R+100*(10-N))
s=input();print([int(s[0])*int(s[2]),-1][len(s)!=3])
  

### FIXED CODE ###

a,b=map(int,input().split());print([a*b,-1][a>9 or b>9])
n=int(input())
v=list(map(int, input().split()))

v.sort()
dif=[v[i+1]-v[i] for i in range(n-1)]

while len(v)>2:
  i=dif.index(min(dif))
  v[i]=(v[i]+v.pop(i+1))/2
  dif.pop(i)
  dif[i]=v[i+1]-v[i]
  if i!=0: dif[i-1]=v[i]-v[i-1]

print((v[0]+v[1])/2)  

### FIXED CODE ###

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

v.sort()
ans=(v[0]+v[1])/2

for i in range(2,n):
  ans=(ans+v[i])/2

print(ans)
n, k = map(int, input().split())
m = n
while m > 0:
  n = min(abs(n - k), n)
  if m > n:
      m = n
  else:
      print(m)
      break

### FIXED CODE ###

a, b, c = map(int, input().split())
print(c, a, b)
from bisect import bisect_right

n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort()
bc = [list(map(int, input().split())) for _ in range(m)]
bc.sort(key=lambda x: x[1], reverse=True)

res = 0
fin = 0
for b, c in bc:
    count = bisect_right(a, c, lo=fin, hi=min(b, len(a))) - fin
    fin += count
    res += count * c
for i in range(fin, len(a)):
    res += a[i]

print(res)


### FIXED CODE ###

a, b = map(int, input().split())
if a >= 13:
    print(b)
elif a >= 6:
    print(b//2)
else:
    print(0)
from itertools import count
n = int(input())
l = [ int(input()) for i in range(n)]
ans = tuple(sorted(l))

checked = set()

s = [(l, 0)]
for loop_count in count():
    #print(s, checked)
    tl, ns = s.pop(0)
    #print(loop_count, ns, len(s), len(checked))
    if tuple(tl) in checked:
        continue
    if ans == tuple(tl):
        print(ns)
        break
    for i in range(n):
        n1 = list(tl)
        if i != n - 1 and i != 0 and n1[i] != n1[i-1] + 1:
            c = n1.pop(i)
            n1.append(c)
            if(tuple(n1) not in checked):
                s.append((n1, ns+1))
        n2 = list(tl)
        if i != 0 and i != n - 1 and n2[i] + 1 != n2[i+1]:
            c = n2.pop(i)
            n2.insert(0, c)
            if(tuple(n2) not in checked):
                s.append((n2, ns+1))
    checked.add(tuple(tl))


### FIXED CODE ###

def main():
    n = int(input())
    l = [ int(input().rstrip()) for i in range(n)]

    s = {}
    for i in l:
        if i - 1 in s:
            s[i] = s[i - 1] + 1
            del s[i - 1]
        else:
            s[i] = 1
    print(n - max(s.values()))

if __name__ == '__main__':
    main()
n = input()
hn = list(map(int, input().split()))

ans = 0

while sum(hn) > 0:
    ans+= 1
    flag = False
    for i in range(n):
        if hn[i] > 0:
            hn[i] -= 1
            flag = True
        else:
            break

print(ans)

### FIXED CODE ###

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

ans = 0

while sum(hn) > 0:
    ans+= 1
    flag = False
    for i in range(n):
        if hn[i] > 0:
            hn[i] -= 1
            flag = True
        elif flag is True:
            break

print(ans)
n = input()
for i in range(n):
    a, b, c = map(int, input().strip().split())
    print('YES' if a**2 + b**2 == c**2 else 'NO')

### FIXED CODE ###

n = int(input())
for i in range(n):
    a, b, c = sorted(map(int, input().strip().split()))
    print('YES' if a**2 + b**2 == c**2 else 'NO')
N = int(input())
l = list(map(int, input().split()))
k = []
for j in range(min(l), max(l)):
  ans=0
  for i in range(len(l)):
    x = (l[i] - j)**2
    ans += x
  k.append(ans)
print(min(k))

### FIXED CODE ###

N = int(input())
l = list(map(int, input().split()))
k = []
for j in range(101):
  ans=0
  for i in range(N):
    ans += (l[i] - j)**2
  k.append(ans)
print(min(k))
import math
A, B, H, M = map(int,input().split())
n = 11
# 長針の角度
long = 6 * M
# 短針の角度
short = 30*(H) + 0.5*M
if long < short:
    theta = short - long
if long > short:
    theta = lomg - short
if theta > 180:
    theta = 360 - theta
cos = math.cos(math.radians(theta))
x = A**2 + B**2 - 2*A*B*cos
y = math.floor(x * 10 ** n) / (10 ** n)
print(math.sqrt(y))

### FIXED CODE ###

import math
from decimal import *
A, B, H, M = map(int,input().split())
# 長針の角度
long = 6 * M
# 短針の角度
short = 30*(H) + 0.5*M
theta = abs(long - short)
if theta > 180:
    theta = 360 - theta
cos = math.cos(math.radians(theta))
x = A**2 + B**2 - 2*A*B*cos
x = math.sqrt(x) # 平方根に変換
n = 10 # 小数点10位以下を切り捨て
y = Decimal(str(x)).quantize(Decimal(str(10**(n*-1))), rounding=ROUND_DOWN)
print(y)
a,b=map(int,input().split())
if a+b < 24:
print(a+b)
else : print(24-a-b)

### FIXED CODE ###

a,b=map(int,input().split())
if a+b < 24:print(a+b)
else : print(abs(24-a-b))
a=input(int())
b=input(int())
c=input(int())
if a>c>b or b>c>a:
    print("Yes")
else:print("No")

### FIXED CODE ###

a,b,c=map(int, input().split())
if a>c>b or b>c>a:
    print("Yes")
else:print("No")
n,m=map(int,input().split())
x=list(map(int,input().split()))
x.sort()
a=[0]
for i in range(m-1):
   a.append(x[i+1]-x[i])
a.sort(reverse=True)
for i in range(n-1):
    a[i]=0
print(sum(a))

### FIXED CODE ###

n,m=map(int,input().split())
x=list(map(int,input().split()))
if n>=m:
    print("0")
    exit()
x.sort()
a=[0]
for i in range(m-1):
   a.append(x[i+1]-x[i])
a.sort(reverse=True)
for i in range(n-1):
    a[i]=0
print(sum(a))
N,A,B=map(int,input().split())
if (A+B)%2==0:
  print((B-A)//2)
else:
  if (A-1)<=(N-B):
    print((2A-1)+(B-A)//2)
  else:
    print((2B-1)+(B-A)//2)

### FIXED CODE ###

N,A,B=map(int,input().split())
if (A+B)%2==0:
  print((B-A)//2)
else:
  print(min(A-1,N-B)+1+(B-A-1)//2)
A = input()
B = input()
C = input()

xa = 0
xb = 0
xc = 0

#配列の次のカードの文字を返す
def next(X, i):
    if X[i] == 'a':
        return A[xa]
    elif X[i] == 'b':
        return B[xb]
    else:
        return C[xc]

h = 'A'
xa += 1
k = next(A, xa - 1) #最初

while True:
    if k == 'a':
        h = 'A'
        xa += 1
        if xa < len(A):
            k = next(A, xa - 1)
        else:
            break
    elif k == 'b':
        h = 'B'
        xb += 1
        if xb < len(B):
            k = next(B, xb - 1)
        else:
            break
    else:
        h = 'C'
        xc += 1
        if xc < len(C):
            k = next(C, xc - 1)
        else:
            break

print(h)


### FIXED CODE ###

A = input()
B = input()
C = input()

xa = 0
xb = 0
xc = 0

h = 'A'
k = A[0] #最初の１枚を抜く
xa += 1

while True:

    if k == 'a':
        h = 'A'
        if xa < len(A):
            k = A[xa]
            xa += 1
        else:
            break
    elif k == 'b':
        h = 'B'
        xb += 1
        if xb < len(B):
            k = B[xb]
            xb += 1
        else:
            break
    elif k == 'c':
        h = 'C'
        xc += 1
        if xc < len(C):
            k = C[xc]
            xc += 1
        else:
            break

print(h)
def solve(m_list):
    m_val = m_list[0]
    for i in m_list:
        m_val = min(m_val,gcd(min_val,m))
    return min_val

def gcd(a,b):
    while b:
        a,b = b,a%b
    return a

def main():
    n = int(input())
    m_list = list(map(int,input().split()))

    ans = solve(m_list)
    print(ans)
main()

### FIXED CODE ###

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

if B % A == 0:
    print(A+B)
else:
    print(B-A)
#!/usr/bin/env pypy3
# N,M = map(int,sys.stdin.readline().split())
# a = tuple(map(int,sys.stdin.readline().split())) # single line with multi param
# a = tuple(int(sys.stdin.readline()) for _ in range(N)) # multi line with single param
# a = tuple(tuple(map(int,sys.stdin.readline().rstrip().split())) for _ in range(N)) # multi line with multi param
# s = sys.stdin.readline().rstrip()
# N = int(sys.stdin.readline())
# INF = float("inf")
import sys,collections

N = int(sys.stdin.readline())
a = tuple(map(int,sys.stdin.readline().split())) # single line with multi param

from math import gcd
import math
acc = a[0]
LIMIT=10**6
minPrime = [0]*(LIMIT+1)
#minPrime[1] = 1
count = 0
for i in range(2,LIMIT):
    if minPrime[i] == 0:
        count += 1
        j = i
        while j <= LIMIT:
            if minPrime[j] == 0:
                minPrime[j] = i
            j += i
#print(minPrime)
def factrial(N):
    ret = []
    while minPrime[N] != N:
        ret.append(minPrime[N])
        N = N//minPrime[N]
    if N != 1:
        ret.append(N)
    return ret

pairwise = True
# facts = [set(factrial(e)) for e in a]
p = set() #all prime
s = set(factrial(a[0])) # pair prime
for e in a:
    f = set(factrial(e))
    s = s & f
    if p & f:
        pairwise = False
    p = p | f
#print(p,s,pairwise)

if s:
    print("not coprime")
elif pairwise:
    print("pairwise coprime")
else:
    print("setwise coprime")

### FIXED CODE ###

import math
from collections import defaultdict
pc = True
n = int(input())
a = list(map(int,input().split()))
g = math.gcd(a[0],a[1])
for i in range(2,n):
    g = math.gcd(g,a[i])
M = max(a)
class Sieve_of_Eratosthenes:
    def __init__(self, N):
        self.sieve = [-1] * (N+1)
 
        for i in range(2,N+1):
            if self.sieve[i] == -1:
                for j in range(1,1+N//i):
                    self.sieve[i*j] = i
 
    def isprime(self, num):
        if num <= 1:
            return False
        else:
            return self.sieve[num] == num
 
    def factorization(self, num):
        ret = set([])
        while num != 1:
            div = self.sieve[num]
            ret.add(div)
            num //= div
        return ret
 
sofe = Sieve_of_Eratosthenes(M)
ddic = defaultdict()
judge = set([])
 
for i in a:
    if not pc:
        break
    asf = sofe.factorization(i)
    
    if judge & asf != set():
        pc = False
    judge |= asf
if pc:
    print("pairwise coprime")
elif g == 1:
    print("setwise coprime")
else:
    print("not coprime")
x = raw=_input().split()
a,op,b = x[0],x[1],x[2]
while 1:
	if op == "+":
		print a+b
	elif op == "-":
		print a-b
	elif op == "/":
		print a/b
	elif op == "*":
		print a*b
	else:
		break

### FIXED CODE ###

while 1:
	x = raw_input().split()
	a,op,b = int(x[0]),x[1],int(x[2])
	if op == "+":
		print a+b
	elif op == "-":
		print a-b
	elif op == "/":
		print a/b
	elif op == "*":
		print a*b
	else:
		break
s=input()
aa=int(s[:2])
bb=int(s[3:])
if aa>12 and bb==0 or aa==0 and bb>12: ans='NA'
elif 0<aa<=12 and 0<bb<=12: ans='AMBIGUOUS'
elif aa>12 or aa==0 and 0<bb<=12: ans='YYMM'
else :ans='MMYY'
print(ans)1

### FIXED CODE ###

s=input()
aa=int(s[:2])
bb=int(s[2:])
if 0<aa<=12 and 0<bb<=12: ans='AMBIGUOUS'
elif 0<bb<=12: ans='YYMM'
elif 0<aa<=12: ans='MMYY'
else: ans='NA'
print(ans)
s=list(input())
l=len(s)
for i  in range(0,l):
  if i%2==0:
    if s[i]=="R":
      print("No")
      exit()
  if i%2==1:
    if s[i]=="L":
      pirnt("No")
      exit()
print("Yes")

### FIXED CODE ###

s=list(input())
l=len(s)
for i  in range(0,l):
  if i%2==0:
    if s[i]=="L":
      print("No")
      exit()
  elif i%2==1:
    if s[i]=="R":
      print("No")
      exit()
  else:
    pass
print("Yes")
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from itertools import accumulate
def main():
    n, ko = map(int, input().split())
    p = tuple(map(int, input().split()))
    c = tuple(map(int, input().split()))

    scores_all = set()
    for k1 in range(n):
        scores = []
        kita = [0] * n
        cnt = ko
        koko = k1
        kita[koko] = cnt
        cycle_long = n
        cnt -= 1
        koko = p[koko] - 1
        while cnt:
            if kita[koko]:
                cycle_long = kita[koko] - cnt
                scores.append(c[koko])
                break
            else:
                scores.append(c[koko])
                kita[koko] = cnt
                koko = p[koko] - 1
                cnt -= 1
        scores_a = tuple(accumulate(scores))
        if cnt:
            if scores_a[-1] > 0:
                kaisuu = ko // cycle_long
                s = scores_a[-1] * kaisuu
                amari = ko % cycle_long
                if amari:
                    s += max(scores_a[:amari])
                scores_all.add(s)
            else:
                scores_all.add(max(scores_a))
        else:
            scores_all.add(max(scores_a))
    print(max(scores_all))

if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from itertools import accumulate
from collections import deque, defaultdict
def main():
    n, ko = map(int, input().split())
    p = tuple(map(int, input().split()))
    c = tuple(map(int, input().split()))

    scores_all = deque()
    for k1 in range(n):
        scores = deque()
        kita = defaultdict(int)
        kita[k1] = ko
        cnt = ko - 1
        koko = p[k1] - 1
        scores.append(c[koko])
        kita[koko] = cnt
        while cnt:
            cnt -= 1
            koko = p[koko] - 1
            scores.append(c[koko])
            if kita[koko]:
                break
            else:
                kita[koko] = cnt
        cycle_long = kita[koko] - cnt
        scores_a = tuple(accumulate(scores))

        if cnt:
            if scores_a[-1] > 0:
                kaisuu = ko // cycle_long
                s1 = scores_a[-1] * kaisuu
                amari = ko % cycle_long
                if amari:
                    t = max(0, max(scores_a[:amari]))
                    s1 += t
                s2 = scores_a[-1] * (kaisuu - 1)
                s2 += max(scores_a)
                scores_all.append(max(s1, s2))
            else:
                scores_all.append(max(scores_a))
        else:
            scores_all.append(max(scores_a))
    print(max(scores_all))

if __name__ == '__main__':
    main()
from collections import deque
H,W = map(int,input().split())
grid = [0] * H
num_black = 0
for i in range(H):
    s = input()
    for j in range(len(s)):
        if s[j] == '#':
            num_black += 1
    grid[i] = list(s)
time_grid = [[0] * W for _ in range(H)]
queue = deque()
queue.append([0,0,0])
while queue:
    y,x,t = queue.popleft()
    for next_y, next_x in [[y+1,x],[y,x+1],[y-1,x],[y,x-1]]:
        if next_y == H-1 and next_x == W-1:
            time = t+1
            break
        if 0 <= next_x < W and 0 <= next_y < H and grid[next_y][next_x] == '.':
            queue.append([next_y,next_x,t+1])
            grid[next_y][next_x] = '#'
print(H*W-time-1-num_black)




### FIXED CODE ###

from collections import deque
H,W = map(int,input().split())
grid = [0] * H
num_black = 0
for i in range(H):
    s = input()
    for j in range(len(s)):
        if s[j] == '#':
            num_black += 1
    grid[i] = list(s)
time_grid = [[-1] * W for _ in range(H)]
time_grid[0][0] = 0
queue = deque()
queue.append([0,0,0])
while queue:
    y,x,t = queue.popleft()
    for next_y, next_x in [[y+1,x],[y,x+1],[y-1,x],[y,x-1]]:
        if 0 <= next_x < W and 0 <= next_y < H and grid[next_y][next_x] == '.':
            queue.append([next_y,next_x,t+1])
            time_grid[next_y][next_x] = t+1
            grid[next_y][next_x] = '#'
if time_grid[H-1][W-1] != -1:
    print(H*W-time_grid[-1][-1]-1-num_black)
else:
    print(-1)
H, N = map(int, input().split())

List = []
for _ in N:
  List.append(int(input()))

total = 0
for l in len(List):
  total += List[l]
  
if H > total:
  print('No')
  
elif H <= total:
  print('Yes')


### FIXED CODE ###

H, N = map(int, input().split())
 
List = list(map(int, input().split()))
 
total = 0
for l in range(len(List)):
  total += List[l]
  
if H > total:
  print('No')
  
elif H <= total:
  print('Yes')
import math

if __name__ == "__main__":

    A,B,C,D = map(int,input().split())
    ac = A%C
    #bc = B%C
    E = int(C * D / math.gcd(C,D))
    if ac == 0:
        modc = B//C - A//C + 1
    else:
        modc = B//C - A//C
    ad = A%D
    if ad == 0:
        modd = B//D - A//D + 1
    else:
        modd = B//D - A//D
    ae = A%E
    if ae == 0:
        mode = B//E - A//E + 1
    else:
        mode = B//E - A//E
    print(int(B-A+1-modc-modd+mode))


### FIXED CODE ###

def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a

if __name__ == "__main__":
    A,B,C,D = map(int,input().split())
    ac = A%C
    E = int(C*D/gcd(C,D))
    if ac == 0:
        modc = B//C - A//C + 1
    else:
        modc = B//C - A//C
    ad = A%D
    if ad == 0:
        modd = B//D - A//D + 1
    else:
        modd = B//D - A//D
    ae = A%E
    if ae == 0:
        mode = B//E - A//E + 1
    else:
        mode = B//E - A//E
    print(int(B-A+1-modc-modd+mode))
a,b = map(int,input(),split())
n = 1
c = 0
while n < b:
    n += a-1
    c += 1
print(c)

### FIXED CODE ###

a,b = map(int,input().split())
n = 1
c = 0
while n < b:
    n += a-1
    c += 1
print(c)
def dfs(a, b, k):
    nonlocal cnt
    seen[a][b] = True
    na = a + 1
    nb = b + 1
    if na <= N and seen[na][b] is False and k >= book_a[na]:
        k -= book_a[na]
        cnt = max(cnt, na + b)
        dfs(na, b, k)
    if nb <= M and seen[a][nb] is False and k >= book_b[nb]:
        k -= book_b[nb]
        cnt = max(cnt, a + nb)
        dfs(a, nb, k)
        
N, M, k = map(int, input().split())
book_a = [int(x) for x in input().split()]
book_b = [int(x) for x in input().split()]
book_a.insert(0, 0)
book_b.insert(0, 0)
cnt = 0
seen = [[False] * (M + 1) for _ in range(N + 1)]
dfs(0, 0, k)
print(cnt)

### FIXED CODE ###

def resolve():
    N, M, K = map(int, input().split())
    A = [int(x) for x in input().split()]
    B = [int(x) for x in input().split()]

    # a,bをA,Bの累積和のリストとして作成
    a, b = [0], [0]
    for i in range(N):
        a.append(a[i] + A[i])
    for i in range(M):
        b.append(b[i] + B[i])

    # i+jの最大値をiをインクリメントとしながら全探索
    ans, j = 0, M
    for i in range(N + 1):
        if a[i] > K:
            break
        while b[j] > K - a[i]:  # i,Kの値が定まればjは一位に定まる
            j -= 1
        ans = max(ans, i + j)
    print(ans)



if __name__ == "__main__":
    resolve()
n = int(input())
a = list(map(int, input().split()))

m = 0
im = 0
for i, ai in enumerate(a):
  if abs(ai) >= abs(m):
    m = ai
    im = i
print(2*n)

for i in range(n):
  print(im+1, i+1)

if im > 0:
  for i in range(0, n-1):
    print(i+1, i+2)
else:
  for i in reversed(1, n):
    print(i+1, i)
    

### FIXED CODE ###

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

m = 0
im = 0
for i, ai in enumerate(a):
  if abs(ai) >= abs(m):
    m = ai
    im = i
print(2*n-1)

for i in range(n):
  print(im+1, i+1)

if m > 0:
  for i in range(0, n-1):
    print(i+1, i+2)
else:
  for i in reversed(range(1, n)):
    print(i+1, i)
n = int(input())
v = list(map(int, input().split()))
c = list(map(int, input().split()))
count = 0
for i in range(n):
  if v[i] > c[i]:
    x += v[i]
    y += c[i]
print(x-y)

### FIXED CODE ###

n = int(input())
v = list(map(int, input().split()))
c = list(map(int, input().split()))
x, y = 0, 0
for i in range(n):
  if v[i] > c[i]:
    x += v[i]
    y += c[i]
print(x-y)
_, *a = map(int, open(0).read().split())
a.sorted()
print(sum(a[-1::2] - a[-2::2]))

### FIXED CODE ###

_, *a = map(int, open(0).read().split())
a.sort()
print(sum(a[-1::-2]) - sum(a[-2::-2]))
cond = map(raw_input().split())
a = cond[0]
b = cond[1]

print "(a*b) (a*2 + b*2)"

### FIXED CODE ###

cond = map(int, raw_input().split())
a = cond[0]
b = cond[1]

print (a*b),
print (a*2 + b*2)