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


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

N = int(input())
p = []
for i in range(N):
    p.append(i+1)

x = p.pop(0)
p.append(x)
#p.reverse()

#p = [2,3,4,5,6,7,8,9,10,11,12,13,1]

#print(p)
count = 0
for i in range(N):
    count += (i+1) % p[i]

print(count)

### FIXED CODE ###



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


N = int(input())

# まず等差数列の和
n = N-2
count = (n*(4+(n-1)))//2

#print(count)

# 最終項
count += 1

print(count)
### BUGGY CODE ###

import sys
import math

def add_h(s,c):
    return c+s

def add_t(s,c):
    return s+c

s = input()
Q = int(input())
query = []
[query.append(input().split()) for _ in range(Q)]

inversion = -1

for i in range(Q):
    if query[i][0] == "1":
        inversion *= -1
        continue

    c = str(query[i][2])
    if query[i][1] == "1" and inversion == -1:
        s = c + s
    elif query[i][1] == "1" and inversion == 1:
        s = s + c
    elif query[i][1] == "2" and inversion == -1:
        s = s+ c
    else:
        s = c + s


if inversion == -1:
    print(s)
else:
    print(s[::-1])

        

### FIXED CODE ###

import sys
import math

s = input()
Q = int(input())
query = []
[query.append(input().split()) for _ in range(Q)]

inversion = -1

if len(s) >= 3:
    head = s[0]
    tail = s[-1]
    body = s[1:-1]
    for i in range(Q):
        if query[i][0] == "1":
            inversion *= -1
            continue

        c = str(query[i][2])
        if query[i][1] == "1" and inversion == -1:
            head = c + head
        elif query[i][1] == "1" and inversion == 1:
            tail = tail + c
        elif query[i][1] == "2" and inversion == -1:
            tail = tail + c
        else:
            head = c + head
        
    if inversion == -1:
        print(head + body + tail)
    else:
        print(tail[::-1] + body[::-1] + head[::-1])

else:
        for i in range(Q):
            if query[i][0] == "1":
                inversion *= -1
                continue

            c = str(query[i][2])
            if query[i][1] == "1" and inversion == -1:
                s = c + s
            elif query[i][1] == "1" and inversion == 1:
                s = s + c
            elif query[i][1] == "2" and inversion == -1:
                s = s + c
            else:
                s = c + s
        
        if inversion == -1 :
            print(s)
        else:
            print(s[::-1])
### BUGGY CODE ###

from collections import deque,Counter

n,m,k = map(int,input().split())
frd = [[] for _ in range(n)]
blk = [[] for _ in range(n)]
for _ in range(m):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    frd[a].append(b)
    frd[b].append(a)
for _ in range(k):
    c,d = map(int,input().split())
    c -= 1
    d -= 1
    blk[c].append(d)
    blk[d].append(c)

ucnt = 0
uni = [-1]*n
stk = deque()
for i in range(n):
    if uni[i] != -1: continue
    stk.append((i,-1))
    while stk:
        cur,prev = stk.pop()
        uni[cur] = ucnt
        for nxt in frd[cur]:
            if nxt == prev: continue
            if uni[nxt] != -1: continue
            stk.append((nxt,cur))
    ucnt += 1
cnt = Counter(uni)

for i in range(n):
    ans = cnt[uni[i]] - len(frd[i]) - 1
    for b in blk[i]:
        if uni[i] == uni[b]: ans -= 1
    print(ans,end=" ")

### FIXED CODE ###

from collections import deque,Counter

n,m,k = map(int,input().split())
frd = [[] for _ in range(n)]
blk = [[] for _ in range(n)]
for _ in range(m):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    frd[a].append(b)
    frd[b].append(a)
for _ in range(k):
    c,d = map(int,input().split())
    c -= 1
    d -= 1
    blk[c].append(d)
    blk[d].append(c)

ucnt = 0
uni = [-1]*n
stk = deque()
for i in range(n):
    if uni[i] != -1: continue
    stk.append((i,-1))
    while stk:
        cur,prev = stk.pop()
        uni[cur] = ucnt
        for nxt in frd[cur]:
            if nxt == prev: continue
            if uni[nxt] != -1: continue
            stk.append((nxt,cur))
    ucnt += 1
cnt = Counter(uni)

for i in range(n):
    ans = cnt[uni[i]] - 1
    for f in frd[i]:
        if uni[i] == uni[f]: ans -= 1
    for b in blk[i]:
        if uni[i] == uni[b]: ans -= 1
    print(ans,end=" ")
### BUGGY CODE ###

def main():
    n = int(input())
    sl = [ list(input()) for _ in range(n) ]
    ans = 0

    
    for i in sl:
        i.sort()
        
    st = tuple(sl)
    
    for i in range(len(st)-1):
        for j in range(i+1,len(st)):
            if sl[i] == sl[j]:
                ans += 1

    print(ans)

if __name__ == '__main__':
    main()

### FIXED CODE ###

A ={}
c = 0
for i in range(int(input())):
    a = str(sorted(input()))
    if a in A:
        A[a] += 1
        c += A[a]
    else:
        A[a] = 0
print(c)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
INF = float('inf')

def sol():
    _, K = map(int, input().split())
    A = list(map(int, input().split()))
    F = list(map(int, input().split()))

    A.sort()
    F.sort(reverse=True)

    def isOk(t):
        cnt = sum((max(0, a - t // f) for a, f in zip(A, F)))

        if cnt > K:
            return False
        else:
            return True

    ng = -1
    ok = max((a * f for a, f in zip(A, F))) + 1

    while ok - ng > 1:
        mid = (ok + ng) // 2
        if isOk(mid):
            ok = mid
        else:
            ng = mid
    print(ok)

sol()

### FIXED CODE ###

import sys
from heapq import heappop, heappush
from operator import itemgetter
from collections import deque, defaultdict, Counter
from bisect import bisect_left, bisect_right
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
MOD = 10**9 + 7
INF = float('inf')

def sol():
    _, K = map(int, input().split())
    A = list(map(int, input().split()))
    F = list(map(int, input().split()))

    A.sort()
    F.sort(reverse=True)

    def isOk(t):
        cnt = 0
        for a, f in zip(A, F):
            ness = t // f
            if a <= ness:
                continue
            cnt += a - ness

        if cnt > K:
            return False
        else:
            return True

    ng = -1
    ok = max(A) * max(F) + 10

    while ok - ng > 1:
        mid = (ok + ng) // 2
        if isOk(mid):
            ok = mid
        else:
            ng = mid
    print(ok)


sol()
### BUGGY CODE ###

K = int(input())
from math import gcd
ans=0
c=0
for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
            c=gcd(i,j)
            ans+=gcd(c,k)
           
print(ans)

### FIXED CODE ###

K = int(input())
from math import gcd
ans=0
c=0

for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
            c=gcd(i,j)
            ans+=gcd(c,k)
           
print(ans)
### BUGGY CODE ###

def main():
    s = input()
    q = int(input())
    S = ''
    for i in range(q):
        li = input().split()
        if li[0] == '1':
            s = s[::-1]
        else:
            if li[1] == '1':
                s = li.pop() + s
            else:
                s = s + li.pop()
    print(s)
if __name__ == '__main__':
    main()

### FIXED CODE ###

from collections import deque

s = input()
q = int(input())
S = deque(s)
head = True

for i in range(q):
    li = input().split()
    if li[0] == '1':
        head = not head
    else:
        if head:
            if li[1] == '1':
                S.appendleft(li.pop())
            else:
                S.append(li.pop())
        else:
            if li[1] == '2':
                S.appendleft(li.pop())
            else:
                S.append(li.pop())
s = ''.join(S)
if not head:
    s = s[::-1]
print(s)
### BUGGY CODE ###

n = int(input())
s = input()

S = set()
cnt = 0

for i in range(10):
    for j in range(10):
        for k in range(10):
            dig = 1
            t = str(i)+str(j)+str(k)

            for r in range(n):
                if dig == 1 and t[0] == s[r]:
                    dig +=1

                elif dig == 2 and t[1] == s[r]:
                    dig +=1
                    
                elif dig == 3 and t[2] == s[r]:
                    S.add(t)

print(len(S))

### FIXED CODE ###

n = int(input())
s = input()

S = set()
cnt = 0

for i in range(10):
    for j in range(10):
        for k in range(10):
            dig = 1
            t = str(i)+str(j)+str(k)

            for r in range(n):
                if dig == 1 and t[0] == s[r]:
                    dig +=1

                elif dig == 2 and t[1] == s[r]:
                    dig +=1
                    
                elif dig == 3 and t[2] == s[r]:
                    S.add(t)

print(len(S))
### BUGGY CODE ###

N = int(input())
A = list(map(int, input().split()))
cnt = [0]*(10**6+1)

for i in A:
  cnt[i] += 1
  
for i in range(N):
  for j in range(N):
    if i != j:
      if A[j] % A[i] == 0 and cnt[A[j]] != 0:
        cnt[A[j]] -= 1

print(sum(cnt))

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
A.sort()
MAX = 10**6+1
cnt = [0]*MAX

for x in A:
  if cnt[x] != 0:
  	cnt[x] = 2
  else:
    for i in range(x, MAX, x):
      cnt[i] += 1
  
ans = 0
for x in A:
  # 2回以上通った数字 (cnt[x]>1) は，その数字より小さい約数が存在する (割り切れる他の数が存在する)。
  if cnt[x] == 1:  
    ans += 1
    
print(ans)
### BUGGY CODE ###

# -*- coding: utf-8 -*-

N = int(input())

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

# sort
for i in range(len(list)):
    Ai, Bi = list[i]
    minIndex = None
    min = Bi
    for j in range(i+1,len(list)):
        Aj, Bj = list[j]

        if min > Bj:
            min = Bj
            minIndex = j

    if minIndex != None:
        list[i],list[minIndex] = list[minIndex],list[i]

#check
time = 0
result = True
for i in list:
    A, B = i
    time += A

    #print("work[{0}({1},{2})] time:{3}".format(i,A,B,time))

    if time > B:
        result = False
        break

message = "Yes" if result else "No"
print(message)


### FIXED CODE ###

# -*- coding: utf-8 -*-

N = int(input())

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

# sort
list.sort(key=lambda x:x[1])
#check
time = 0
result = True
for i in list:
    A, B = i
    time += A

    #print("work[{0}({1},{2})] time:{3}".format(i,A,B,time))

    if time > B:
        result = False
        break

message = "Yes" if result else "No"
print(message)
### BUGGY CODE ###

import sys
import math
from collections import defaultdict, deque
from copy import deepcopy
    
input = sys.stdin.readline
def RD(): return input().rstrip()
def F(): return float(input().rstrip())
def I(): return int(input().rstrip())
def MI(): return map(int, input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float,input().split()))
def Init(H, W, num): return [[num for i in range(W)] for j in range(H)]
    
    
def main():
    H, W, M = MI()
    Hlist = [[0, i] for i in range(H)]
    Wlist = [[0, i] for i in range(W)]
    Dlist = [[] for i in range(H)]
    H_max = -float('inf')
    W_max = -float('inf')
    
    for i in range(M):
        h, w = MI()
        Hlist[h-1][0]+=1
        Wlist[w-1][0]+=1
        Dlist[h-1].append(w-1)
        H_max = max(H_max, Hlist[h-1][0])
        W_max = max(W_max, Wlist[w-1][0])
    Hlist = [temp[1] for temp in Hlist if temp[0] == H_max]
    Wlist = [temp[1] for temp in Wlist if temp[0] == W_max]
    ans = H_max+W_max-1

    for index1 in Hlist:
        for index2 in Wlist:
            if not index2 in Dlist[index1]:
                ans += 1
                break
        else:
            continue
        break
    print(ans)

if __name__ == "__main__":
    main()

### FIXED CODE ###

import sys
import math
from collections import defaultdict, deque
from copy import deepcopy
    
input = sys.stdin.readline
def RD(): return input().rstrip()
def F(): return float(input().rstrip())
def I(): return int(input().rstrip())
def MI(): return map(int, input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float,input().split()))
def Init(H, W, num): return [[num for i in range(W)] for j in range(H)]
    
    
def main():
    H, W, M = MI()
    Hlist = [[0, i] for i in range(H)]
    Wlist = [[0, i] for i in range(W)]
    Dlist = [set() for i in range(H)]
    H_max = -float('inf')
    W_max = -float('inf')
    
    for i in range(M):
        h, w = MI()
        Hlist[h-1][0]+=1
        Wlist[w-1][0]+=1
        Dlist[h-1] |= {w-1}
        H_max = max(H_max, Hlist[h-1][0])
        W_max = max(W_max, Wlist[w-1][0])
    Hlist = set([temp[1] for temp in Hlist if temp[0] == H_max])
    Wlist = set([temp[1] for temp in Wlist if temp[0] == W_max])
    ans = H_max+W_max-1

    for index1 in Hlist:
        for index2 in Wlist:
            if not index2 in Dlist[index1]:
                ans += 1
                break
        else:
            continue
        break
    print(ans)

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

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

def binsearch(threshold, lst):
    left, right = -1, len(lst)
    while right - left > 1:
        mid = (left + right) // 2
        if lst[mid] >= threshold:
            right = mid
        else:
            left = mid
    return left


last=[]
for val in A:
    temp = binsearch(val, last)
    if temp == -1:
        last.insert(0, val)
    else:
        last[temp] = val
    #print(last)
print(len(last))




### FIXED CODE ###

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

def binsearch(threshold, lst):
    left, right = -1, len(lst)
    while right - left > 1:
        mid = (left + right) // 2
        if lst[mid] < threshold:
            right = mid
        else:
            left = mid
    return right


last=[]
for val in A:
    temp = binsearch(val, last)
    if temp == len(last):
        #last.insert(0, val)
        last.append(val)
    else:
        last[temp] = val
    #print(last)
print(len(last))
### BUGGY CODE ###

import itertools
n,k = map(int,input().split())
p = list(map(int,input().split()))
num = 0
maxnum = 0
for i in range(n-k+1):
    num = sum(p[i:i+k])
    if num > maxnum:
        maxnum = num
print("{:.6f}".format(0.5*(maxnum+k)))

### FIXED CODE ###

n,k = map(int,input().split())
p = list(map(int,input().split()))
wa = sum(p[0:k])
next_wa = wa
for i in range(n-k):
    next_wa = next_wa - p[i] + p[i+k]
    if  next_wa > wa:
        wa = next_wa
print(0.5*(wa+k))
### BUGGY CODE ###

n,k,q=(int(x) for x in input().split())
a=[]
p=[]
for i in range(0,q):
    temp=int(input())
    a.append(temp)
for j in range(0,n):
    p.append(a.count(j+1))
for m in range(0,n):
    c=k
    for l in range(0,n):
        if l!=m:
            c +=-1*p[l]
    #print('No %d point is %d'% (m,c))
    if c >0:
        print('Yes')
    else:
        print('No')
#print(p)


### FIXED CODE ###

n,k,q=(int(x) for x in input().split())
a=[]
p=[0]*n
for i in range(0,q):
    temp=int(input())
    p[temp-1]+=1
border=-k+q

res = '\n'.join('Yes' if p[j]> border else 'No' for j in range(0,n))

print(res)
### BUGGY CODE ###

import sys

if __name__ == '__main__':
    n = int(sys.stdin.readline())
    a = list(map(lambda x: int(x), sys.stdin.readline().split()))
    for i in range(len(a)):
        ans = 0
        for j in range(len(a)):
            if i == j:
                continue
            else:
                ans ^= a[j]
        print(ans, end=' ')
    print()

# スヌケ君dの値が知りたい：d以外の人の計算結果を全部xorする

### FIXED CODE ###

import sys

if __name__ == '__main__':
    n = int(sys.stdin.readline())
    A = list(map(lambda x: int(x), sys.stdin.readline().split()))
    allxor = 0
    for a in A:
        allxor ^= a
    for a in A:
        print(allxor^a, end=' ')
    print()

# スヌケ君dの値が知りたい：d以外の人の計算結果を全部xorする
### BUGGY CODE ###

s = input()

ans = []
while s.find("LR")!=-1:
    k = s.find("LR")
    t = s[:k+1]
    a = [0]*len(s[:k+1])
    l = t.find("RL")
    numR = t.count("R")
    numL = t.count("L")
    a[l] = (numR+1)//2 + (numL)//2
    a[l+1] = (numR)//2 + (numL+1)//2
    ans = ans + a
    s = s[k+1:]

a = [0]*len(s)
l = s.find("RL")
numR = s.count("R")
numL = s.count("L")
a[l] = (numR+1)//2 + (numL)//2
a[l+1] = (numR)//2 + (numL+1)//2
ans = ans + a
print(" ".join(list(map(str, ans))))

### FIXED CODE ###

s = input()
l = len(s)
ans = [0]*l
count = 0
for i in range(l):
    if s[i]=="R" and s[i+1]=="R":
        count += 1
    elif s[i]=="R" and s[i+1]=="L":
        count += 1
        ans[i] += (count+1)//2
        ans[i+1] += count//2
        count = 0
for i in reversed(range(l)):
    # print(i)
    # print(s[i])
    if s[i]=="L" and s[i-1]=="L":
        count += 1
    elif s[i]=="L" and s[i-1]=="R":
        count += 1
        ans[i] += (count+1)//2
        ans[i-1] += count//2
        count = 0
print(" ".join(map(str, ans)))
### BUGGY CODE ###

import sys
input = sys.stdin.buffer.readline

h, w = map(int, input().split())
grid = [None for _ in range(h)]
poss = [[set() for x in range(w)] for y in range(h)]
tmp = [map(int, input().split()) for _ in range(h * 2)]
for i, (l1, l2) in enumerate(zip(tmp, tmp[h:])):
	grid[i] = [abs(x - y) for x, y in zip(l1, l2)]
poss[0][0].add(-grid[0][0])
poss[0][0].add(grid[0][0])
for i in range(h):
	for j in range(w - 1):
		for c in poss[i][j]:
			m = grid[i][j + 1]
			poss[i][j + 1].add(c - m)
			poss[i][j + 1].add(c + m)
	if i == h - 1:
		break
	for j in range(w):
		for c in poss[i][j]:
			m = grid[i + 1][j]
			poss[i + 1][j].add(c - m)
			poss[i + 1][j].add(c + m)
print(min(abs(x) for x in poss[-1][-1]))

### FIXED CODE ###

import sys
input = sys.stdin.buffer.readline

h, w = map(int, input().split())
a = [map(int, input().split()) for _ in range(h)]
b = [map(int, input().split()) for _ in range(h)]
g = [list(abs(x - y) for x, y in zip(l1, l2)) for l1, l2 in zip(a, b)]
poss = [[0] * w for _ in range(h)]
poss[0][0] |= 1 << 6400 + g[0][0]
poss[0][0] |= 1 << 6400 - g[0][0]
for i in range(h):
	for j in range(w - 1):
		poss[i][j + 1] |= poss[i][j] << g[i][j + 1]
		poss[i][j + 1] |= poss[i][j] >> g[i][j + 1]
	if i != h - 1:
		for j in range(w):
			poss[i + 1][j] |= poss[i][j] << g[i + 1][j]
			poss[i + 1][j] |= poss[i][j] >> g[i + 1][j]
res = poss[-1][-1]
for i in range(6400):
	if res & (1 << 6400 + i) or res & (1 << 6400 - i):
		print(i)
		exit()
### BUGGY CODE ###

from collections import Counter,defaultdict,deque
import sys
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
    
def inp(): # n=1
    return int(input())
def inpm(): # x=1,y=2
    return map(int,input().split())
def inpl(): # a=[1,2,3,4,5,...,n]
    return list(map(int, input().split()))
def inpls(): # a=['1','2','3',...,'n']
    return list(input().split())
def inplm(n): # x=[] 複数行
    return list(int(input()) for _ in range(n))
def inpll(n): # [[1,1,1,1],[2,2,2,2],[3,3,3,3]]
    return sorted([list(map(int, input().split())) for _ in range(n)])


def main():
    n,k = inpm()
    s = list(input())
    cnt = []
    be = ''
    c = 0
    for i in range(n):
        if i == 0:
            be = s[i]
            c = 1                        
        elif s[i] != be:
            if be == '0':
                cnt.append((c,0))
            else:
                cnt.append((c,1))
            be = s[i]
            c = 1
        else:
            c += 1
    cnt.append((c,int(be)))
    ans = []
    length = len(cnt)
    if length//2 + (1-cnt[0][1]) <= k:
        print(n)
        return
    for i in range(length):
        s = 0
        for j in range(min(2*k+cnt[i][1], length-i)):
            s += cnt[i+j][0]
        ans.append(s)
    print(max(ans))


if __name__ == "__main__":
    main()

### FIXED CODE ###

import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input()) # n=1
def inpm(): return map(int,input().split()) # x=1,y=2
def inpl(): return list(map(int, input().split())) # a=[1,2,3,4,5,...,n]
def inpls(): return list(input().split())  # a=['1','2','3',...,'n']
def inplm(n): return list(int(input()) for _ in range(n)) # x=[] 複数行
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)] # [[1,1,1,1],[2,2,2,2],[3,3,3,3]] 
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)]) # [[1,1,1,1],[2,2,2,2],[3,3,3,3]] 
def graph():
    n=inp()
    g=[[] for _ in range(n)]
    for i in range(n):
        a = inp()
        a -= 1
        g[i].append(a)
        g[a].append(i)
    return n,g

def main():
    n,k = inpm()
    s = list(input())
    t = [0]
    for i in range(n-1):
        if s[i] != s[i+1]:
            t.append(i+1)
    a = len(t)
    if len(t)<2*k-1:
        print(n)
        return
    for i in range(2*a+4):
        t.append(n)
    ans = 0
    if s[0]=='1':
        for i in range(a):
            if 2*k+2*i+1 >= len(t):
                break
            ans = max(ans,t[2*k+2*i+1]-t[2*i])
    else:
        ans = t[2*k]
        for i in range(a):
            if 2*k+2*i+2 >= len(t):
                break
            ans = max(ans,t[2*k+2*i+2]-t[2*i+1])
    print(ans)

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

N=int(input())
alist=list(map(int,input().split()))
#print(alist)

dic_a={}
for a in alist:
  if not a in dic_a:
    dic_a[a]=1
  else:
    dic_a[a]+=1
    
dic2_a={}
for key in dic_a:
  if dic_a[key]>=2:
    dic2_a[key]=dic_a[key]
    
#print(dic2_a)
for a in alist:
  dic2_a_copy=dic2_a.copy()
  if a in dic2_a_copy:
    dic2_a_copy[a]-=1
  
  #print(dic_a_copy)
  answer=0
  for val in dic2_a_copy.values():
    answer+=val*(val-1)//2
    
  print(answer)

### FIXED CODE ###

N=int(input())
alist=list(map(int,input().split()))
#print(alist)

dic_a={}
for a in alist:
  if not a in dic_a:
    dic_a[a]=1
  else:
    dic_a[a]+=1
    
all_pair=0
for val in dic_a.values():
  all_pair+=val*(val-1)//2

#print(dic_a,all_pair)
dic_answer={}
for a in alist:
  if a in dic_answer:
    print(dic_answer[a])
    continue
  
  now=dic_a[a]
  kill=now*(now-1)//2-(now-1)*(now-2)//2
  answer=all_pair-kill
  
  print(answer)
  dic_answer[a]=answer
### BUGGY CODE ###

n=int(input())
a=list(map(int,input().split()))
ans=[0]*n
for i in a:
    ans[i-1]=a.index(i)+1
print(*ans)

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
ans=[0]*n
for i,j in enumerate(a):
    ans[j-1]=i+1
print(*ans)
### BUGGY CODE ###

from itertools import combinations
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

def factorize(n):
    retlist = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            while temp%i==0:
                temp //= i
                retlist.append(i)
    if temp!=1:
        retlist.append(temp)

    if retlist==[]:
        retlist.append(n)

    return retlist

N = ni()

ans = 0
L = []
L = factorize(N)

ans = 10**13

for i in range(1,len(L)+1):
    C = []
    C = list(combinations(L,i))
    for c in C:
        a,b = 1,0
        for j in range(len(c)):
            a *= c[j]
            b = N//a
            ans = min(ans,a-1+b-1)

print(ans)


### FIXED CODE ###

# ABC144 C - Walk on Multiplication Table
import math
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
n = ni()
sqrtn = int(math.sqrt(n))
for i in range(sqrtn, 0, -1):
    if n%i == 0:
        j = n // i
        print(i+j-2)
        break