Harryxun/stf_run huggingface dataset:
import sys
# Xはもっとも近い整数，Nは与えられるP
X,N = map(int, input().split())

if N == 0:
  print(X)
  sys.exit()

arr = list(map(int, input().split()))

def saiki():
  mainasu = X - 1
  purasu = X + 1
  if X in arr:
    if mainasu in arr:
      if purasu in arr:
        saiki()
      else:
        print(purasu)
    else:
      print(mainasu)
  else:
    print(X)

saiki()

### FIXED CODE ###

import sys

def saiki(l,r,lst):
  if (l - 1) not in lst:
      return (l - 1)
  
  if (r + 1) not in lst:
      return (r + 1)
  
  return saiki(l - 1, r + 1, lst)

def main():
  # Xはもっとも近い整数，Nは与えられるP
  X,N = map(int, input().split())

  arr = list(map(int, input().split()))

  if N == 0:
    print(X)
    sys.exit()

  if X not in arr:
    print(X)
    sys.exit()

  print(saiki(X,X,arr))

if __name__ == '__main__':
    main()
x=input()
x1=len(x)
if x1 %2 == 0
	print("yes")
else
	print("no")



### FIXED CODE ###

x=input()
if x == 'hi':
	print('Yes')
elif x == 'hihi':
	print('Yes')
elif x == 'hihihi':
	print('Yes')
elif x == 'hihihihi':
	print('Yes')
elif x == 'hihihihihi':
	print('Yes')
else:
	print('No')
N=int(input())
ans=0
M=math.ceil(N**0.5+2)
for i in range(1,M):
    if N%i==0 and N//i-i>1: ans+=N//i-1

print(ans)

### FIXED CODE ###

import math

N=int(input())
ans=0
M=math.ceil(N**0.5+2)
for i in range(1,M):
    if N%i==0 and N//i-i>1: ans+=N//i-1

print(ans)
import sys

def binary_search(array, num, left, right):
    if right < left:
        return False
    center = (right + left) / 2
    if array[center] == num:
        return True
    elif array[center] < num:
        return binary_search(array, num, center + 1, right)
    elif array[center] > num:
        return binary_search(array, num, left, center)

n = int(sys.stdin.readline().strip())
S = map(lambda x: int(x), sys.stdin.readline().strip().split(" "))
n = int(sys.stdin.readline().strip())
T = map(lambda x: int(x), sys.stdin.readline().strip().split(" "))

res = 0

for t in T:
    if binary_search(S, t, 0, len(S)):
        res += 1

print res
        

### FIXED CODE ###

import sys

def binary_search(array, num, left, right):
    if right < left + 1:
        return False
    center = (right + left) / 2
    if array[center] == num:
        return True
    elif array[center] < num:
        return binary_search(array, num, center + 1, right)
    elif array[center] > num:
        return binary_search(array, num, left, center)

n = int(sys.stdin.readline().strip())
S = map(lambda x: int(x), sys.stdin.readline().strip().split(" "))
n = int(sys.stdin.readline().strip())
T = map(lambda x: int(x), sys.stdin.readline().strip().split(" "))

res = 0

for t in T:
    if binary_search(S, t, 0, len(S)):
        res += 1

print res
N = int(input())
s = []
for i in range(N):
    val = sorted(input())
    s.append(val)

an = 0
for i in range(N):
    if len(s[an]) <= len(s[i]):
        continue
    else:
        an = i

a = s[an]
n = 0

for i in range(N):
    n = 0
    while len(s[i]) > len(a) and n < len(a):
        if a[n] == s[i][n]:
            n += 1
        else:
            if n == 0:
                a.pop(0)
                s[i].pop(0)
            else:
                if ord(a[n]) > ord(s[i][n]):
                    s[i].pop(n)
                else:
                    a.pop(n)
    if a[n-1] == s[i][n-1]:
        continue
    else:
        a.pop(-1)

print(''.join(a))


### FIXED CODE ###

N = int(input())
s = []
for i in range(N):
    val = sorted(input())
    s.append(val)

an = 0
for i in range(N):
    if len(s[an]) <= len(s[i]):
        continue
    else:
        an = i

a = s[an]

for i in range(N):
    n = 0
    while a != s[i] and n < len(a) and n < len(s[i]):
        if a[n] == s[i][n]:
            n += 1
        else:
            if a[n] > s[i][n]:
                s[i].pop(n)
            else:
                a.pop(n)
    if len(a) > len(s[i]):
        a = s[i]

print(''.join(a))
N, K = map(int, input().split())
dic = {}
ans = []
uniq = []
etc = []
def calc_ans(ans):
    x = 0
    tmp = 0
    for i in range(K):
      tmp += ans[i][0]
      x += ans[i][1]
    return tmp + (x * x)

for i in range(N):
    l = list(map(int, input().split()))
    if dic.get(l[0]):
        dic[l[0]].append(l[1])
    else:
        dic[l[0]] = [l[1]]
if N <= K:
    ans = 0
    for i in dic.keys():
        ans += sum(dic[i])
    ans += len(dic.keys()) * len(dic.keys())
    print(ans)
    exit()
for t in dic.keys():
    dic[t].sort(reverse=True)
    uniq.append((dic[t][0], t))
uniq.sort(reverse=True)
for i in range(K):
  ans.append((uniq[i][0], 1))
  for n in dic[uniq[i][1]][1:]:
      if n <= uniq[K-1][0]:
          break
      etc.append((n, 0))
ans_res = calc_ans(ans)
all_ans = ans_res
for i, n in enumerate(etc):
    i+=1
    ans[-1*i] = n
    tmp_res = calc_ans(ans)
    if all_ans < tmp_res:
        all_ans = tmp_res
    ans_res = tmp_res
print(all_ans)

### FIXED CODE ###

N,K = map(int,input().split())
td = [[int(i) for i in input().split()] for _ in range(N)]
td.sort(key=lambda x:x[1],reverse=True)
ans = 0
ls = set()
dl = []
for i in range(K):
    ans += td[i][1]
    if not td[i][0] in ls:
        ls.add(td[i][0])
    else:
        dl.append(td[i][1])
ans = ans + len(ls)**2
res = ans
for i in range(K,N):
    if not dl:
        break
    if td[i][0] in ls:
        continue
    ans += len(ls)*2+1
    ans += td[i][1]
    ans -= dl[-1]
    del dl[-1]
    res = max(res,ans)
    ls.add(td[i][0])
print(res)
X, A = int(input()).split()

if X > A:
  print 0
elif !(X<A):
  print 10

### FIXED CODE ###

x,a = map(int,input().split())
if x<a:
    print('0')
else:
    print('10')
n = int(input())
a = list(map(int, input().split()))
a.append("#")
start = 0
end = 0

ans = 0

while a[start] != "#" :
  if a[start] != a[end]:
    x = end - start
    if x % 2 == 0:
      ans += x // 2
    else:
      ans += math.floor(x / 2)
  
    start = end

  else:
    end += 1


print(ans)

### FIXED CODE ###

import math

n = int(input())
a = list(map(int, input().split()))
a.append("#")
start = 0
end = 0

ans = 0

while a[start] != "#" :
  if a[start] != a[end]:
    x = end - start
    if x % 2 == 0:
      ans += x // 2
    else:
      ans += math.floor(x / 2)
  
    start = end

  else:
    end += 1


print(ans)
import itertools
n,m,q = map(int,input().split())
a = []
b = []
c = []
d = []
for i in range(1,q+1):
    ai,bi,ci,di = map(int,input().split())
    a.append(ai)
    b.append(bi)
    c.append(ci)
    d.append(di)
AList =  list(itertools.combinations(range(1,m+1), n))
PointList = []
for array in AList:
    point = 0
    for j in range(q):
        if array[b[j]-1] - array[a[j]-1] == c[j]:
            point = point + d[j]
    PointList.append(point)
print(max(PointList))


### FIXED CODE ###

import itertools
n,m,q = map(int,input().split())
inputList = []
for i in range(1,q+1):
    abcd = list(map(int,input().split()))
    inputList.append(abcd)
AList =  list(itertools.combinations_with_replacement(range(1,m+1), n))
PointList = []
for array in AList:
    point = 0
    for iList in inputList:
        if array[iList[1]-1] - array[iList[0]-1] == iList[2]:
            point = point + iList[3]
    PointList.append(point)
print(max(PointList))
def is_prime(n):
  if n in [2, 3, 5, 7]:
    return True
  elif 0 in [n%2, n%3, n%5, n%7]:
    return False
  else:
    check_max = math.floor(math.sqrl(n))
    for i in range(2, check_max):
      if n % i == 0:
        return False
    else:
      return True

def main():
  primes = []
  length = int(input())
  for _ in range(0, length):
    n = int(input())
    if is_prime(n):
      primes.append(n)

  print(len(primes))
  return 0


if __name__ == '__main__':
  main()

### FIXED CODE ###

import math


def is_prime(n):
  if n in [2, 3, 5, 7]:
    return True
  elif 0 in [n%2, n%3, n%5, n%7]:
    return False
  else:
    check_max = math.ceil(math.sqrt(n))
    for i in range(2, check_max + 1):
      if n % i == 0:
        return False
    else:
      return True

def main():
  primes = set([])
  length = int(input())
  for _ in range(0, length):
    n = int(input())
    if is_prime(n):
      primes.add(n)

  print(len(primes))
  return 0


if __name__ == '__main__':
  main()
X, A = list(map(int(input().split()))
print(0) if X<A else print(10)

### FIXED CODE ###

X, A = list(map(int,input().split()))
print(0) if X<A else print(10)
seen = [0,0,0,0,0,0,0,0,0]
seen[0],seen[1],seen[2] = list(map(int,input().split()))
seen[3],seen[4],seen[5] = list(map(int,input().split()))
seen[6],seen[7],seen[8] = list(map(int,input().split()))
over = False
N = int(input())
for x in range(N):
  num = int(input())
  if num in seen:
    seen[x] = "O"
if seen[0] == "O":
  if seen[1] == seen[2] == "O":
    over = True
  elif seen[3] == seen[6] == "O":
    over = True
  elif seen[4] == seen[8] == "O":
    over = True
elif seen[4] == "O":
  if seen[2] == seen[6] == "O":
    over = True
  elif seen[1] == seen[7] == "O":
    over = True
  elif seen[3] == seen[5] == "O":
    over = True
elif seen[8] == "O":
  if seen[6] == seen[7] == "O":
    over = True
  if seen[2] == seen[5] == "O":
    over = True
if not over:
  print("NO")
else:
  print("YES")

### FIXED CODE ###

seen = [0,0,0,0,0,0,0,0,0]
seen[0],seen[1],seen[2] = (map(int,input().split()))
seen[3],seen[4],seen[5] = (map(int,input().split()))
seen[6],seen[7],seen[8] = (map(int,input().split()))
over = "No"
N = int(input())
for x in range(N):
  num = int(input())
  if num in seen:
    seen[seen.index(num)] = "O"
if seen[0] == "O":
  if seen[1] == "O" and seen[2] == "O":
    over = "Yes"
  if seen[3] == "O" and seen[6] == "O":
    over = "Yes"
  if seen[4] == "O" and seen[8] == "O":
    over = "Yes"
if seen[8] == "O":
  if seen[6] == "O" and seen[7] == "O":
    over = "Yes"
  if seen[2] == "O" and seen[5] == "O":
    over = "Yes"
if seen[4] == "O":
  if seen[6] == "O" and seen[2] == "O":
    over = "Yes"
  if seen[1] == "O" and seen[7] == "O":
    over = "Yes"
  if seen[3] == "O" and seen[5] == "O":
    over = "Yes"
print(over)
n, m, l = map(int, input().split())
def warshall_floyd(d):
    #d[i][j]: iからjへの最短距離
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d
inf = 10**12
d = [[inf for i in range(n)] for i in range(n)] 
#d[u][v] : 辺uvのコスト(存在しないときはinf)
for i in range(m):
    x,y,z = map(int,input().split())
    d[x-1][y-1] = z
    d[y-1][x-1] = z
for i in range(n):
    d[i][i] = 0 #自身のところに行くコストは０
dd = warshall_floyd(d)
ddd = [[inf for i in range(n)] for i in range(n)]
for i in range(n):
  for j in range(n):
    if dd[i][j] <= l:
      ddd[i][j] = 1
dddd = warshall_floyd(ddd)
q = int(input())
for i in range(q):
  s, t = map(int, input().split())
  if dddd[s][t] == inf:
    print(-1)
  else
    print(dddd[s-1][t-1]-1)

### FIXED CODE ###

from scipy.sparse.csgraph import floyd_warshall

n, m, l = map(int, input().split())
inf = 10**12
d = [[inf for i in range(n)] for i in range(n)] 
#d[u][v] : 辺uvのコスト(存在しないときはinf)
for i in range(m):
    x,y,z = map(int,input().split())
    d[x-1][y-1] = z
    d[y-1][x-1] = z
for i in range(n):
    d[i][i] = 0 #自身のところに行くコストは０
dd = floyd_warshall(d)
ddd = [[inf for i in range(n)] for i in range(n)]
for i in range(n):
  for j in range(n):
    if dd[i][j] <= l:
      ddd[i][j] = 1
dddd =floyd_warshall(ddd)
q = int(input())
for i in range(q):
  s, t = map(int, input().split())
  if dddd[s-1][t-1] == inf:
    print(-1)
  else:
    print(int(dddd[s-1][t-1]-1))
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cmath>
 
using namespace std;
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define SWAP(a,b) (a += b,b = a - b,a -= b)
#define ll long long

const int MOD = 1e9 + 7;

int main() {
    int map[500][500];
    int a[10000], b[10000], c[10000], d[10000];
    int H, W;
    cin >> H >>W;
    REP(y, H) REP(x, W) {
        cin >> map[y][x];
    }
    
    int dx = 1, x = 0, y = 0, x2, y2;
    int cnt = 0;
    while(1) {
        if(x + dx == W || x + dx == -1) {
            dx *= -1;
            x2 = x;
            y2 = y + 1;
        } else {
            x2 = x + dx;
            y2 = y;
        }

        if(y2 >= H) {
            break;
        }

        if(map[y][x] % 2 == 1) {
            a[cnt] = y+1;
            b[cnt] = x+1;
            c[cnt] = y2+1;
            d[cnt] = x2+1;
            map[y][x]--;
            map[y2][x2]++;
            cnt++;
        }

        x = x2;
        y = y2;
    }
  　cout<<cnt <<endl;
    REP(i, cnt) {
        cout << a[i]<<b[i]<<c[i]<<d[i]<<endl;
    }
}


### FIXED CODE ###

H,W=[int(i) for i in input().split()]
a = [[int(i) for i in input().split()] for j in range(H)]
res = []
for h in range(H):
    for w in range(W-1):
        if a[h][w] % 2 is not 0:
            res += ["{0} {1} {2} {3}".format(h+1,w+1,h+1,w+2)]
            a[h][w+1] += 1
for h in range(H-1):
    w = W - 1
    if a[h][w] % 2 is not 0:
        res += ["{0} {1} {2} {3}".format(h+1,w+1,h+2,w+1)]
        a[h+1][w]+=1

print(len(res))
for t in res:
    print(t)
s = input()
if s == "ABC":
  print("ARC")
else:
  print("ABC"

### FIXED CODE ###

s = input()
if s == "ABC":
  print("ARC")
else:
  print("ABC")
a, b = map(int, raw_input().split())
print '%d %d %f' % (a/b, a%b, (double)a/b)

### FIXED CODE ###

a, b = map(int, raw_input().split())
print '%d %d %f' % (a/b, a%b, float(a)/b)
import numpy as np
 
a1,a2,a3 = map(int,input().split())
a4,a5,a6 = map(int,input().split())
a7,a8,a9 = map(int,input().split())
 
a = np.array([[a1, a2, a3], [a4, a5, a6], [a7, a8, a9]])
 
n = int(input)
for i in range(n):
  b = int(input())
  a[a == b] = 0

if np.sum(a[1,:]) == 0:
  print("Yes")
elif  np.sum(a[2,:]) == 0:
  print("Yes")
elif  np.sum(a[3,:]) == 0:
  print("Yes")
elif  np.sum(a[:,1]) == 0:
  print("Yes")
elif  np.sum(a[:,2]) == 0:
  print("Yes")
elif  np.sum(a[:,3]) == 0:
  print("Yes")
elif a[1,1] + a[2,2] + a[3,3] == 0:
  print("Yes")
elif a[3,1] + a[2,2] + a[1,3] == 0:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

import numpy as np

a1,a2,a3 = map(int,input().split())
a4,a5,a6 = map(int,input().split())
a7,a8,a9 = map(int,input().split())

a = np.array([[a1, a2, a3], [a4, a5, a6], [a7, a8, a9]])

n = int(input())
for i in range(n):
  b = int(input())
  a = np.where(a == b, 0, a)

if a[0,0] + a[0,1] + a[0,2] == 0:
  print("Yes")
elif a[1,0] + a[1,1] + a[1,2] == 0:
  print("Yes")
elif a[2,0] + a[2,1] + a[2,2] == 0:
  print("Yes")
elif a[0,0] + a[1,0] + a[2,0] == 0:
  print("Yes")
elif a[0,1] + a[1,1] + a[2,1] == 0:
  print("Yes")
elif a[0,2] + a[1,2] + a[2,2] == 0:
  print("Yes")
elif a[0,0] + a[1,1] + a[2,2] == 0:
  print("Yes")
elif a[2,0] + a[1,1] + a[0,2] == 0:
  print("Yes")
else:
  print("No")
A = int(input())
    B = int(input())
    C = int(input())
    X = int(input())

    value = 0
    for a in range(0, A+1):
        for b in range(0, B+1):
            for c in range(0, C+1):
                if 500*a + 100*b + 50*c == X:
                    value += 1
    print(value)

### FIXED CODE ###

A = int(input())
B = int(input())
C = int(input())
X = int(input())

value = 0
for a in range(0, A+1):
    for b in range(0, B+1):
        for c in range(0, C+1):
            if 500*a + 100*b + 50*c == X:
                value += 1
print(value)
l = stdin.readline().rstrip().split()
print(l)

### FIXED CODE ###

from sys import stdin

a = stdin.readline().rstrip()
if a == "Sunny":
  print("Cloudy")
elif a== "Cloudy":
   print("Rainy")
else:
   print("Sunny")
n,w=map(int,input().split())
l=[list(map(int,input().split())) for i in range(n)]
dp=[[0 for j in range(w+1)] for i in range(n+1)]
for i in range(n):
  for j in range(w+1):
    dp[i+1][j]=max(dp[i][j],dp[i][j-l[i][o]]+l[i][1])
print(dp[n][w])

### FIXED CODE ###

import numpy as np
n,W=map(int,input().split())
wv=[list(map(int,input().split())) for i in range(n)]
wv=np.array(wv)
dp=[0]*(W+1)
dp=np.array(dp)
for w,v in wv:
  dp[w:]=np.maximum(dp[w:],dp[:-w]+v)
print(dp[W])
def main():
    na, nl = (int(i) for i in input().split())
    nc = (4*na - nl) / 2

    pos = nc == int(nc) and nc >= 0 and nc <= x

    if pos:
        print('Yes')
    else:
        print('No')
      
main()


### FIXED CODE ###

def main():
    na, nl = (int(i) for i in input().split())
    nc = (4*na - nl) / 2

    pos = (nc == int(nc) and nc >= 0 and nc <= na)

    if pos:
        print('Yes')
    else:
        print('No')
      
main()
a = [list(map(int, input().split())) for _ in range(3)]
is_bingo = [[False]*3 for _ in range(3)]
n = int(input())
for _ in range(n):
    b = int(input())
    for i, ai in enumerate(a):
        for j, aii in enumerate(ai):
            if aii == b:
                is_bingo[i][j] = True
is_bingo_flat = [j for i in is_bingo for j in i]
for i in range(3):
    if all(is_bingo[i]) or all(list(zip(*is_bingo))[i]):
        print("Yes")
        break
else:
    if all(is_bingo_flat[::3]) or all(is_bingo_flat[2:7::2]):
        print("Yes")
    print("No")

        

### FIXED CODE ###

def main():
    A = [list(map(int, input().split())) for _ in range(3)]
    n = int(input())
    B = [int(input()) for _ in range(n)]
    ans =  [None]*8
    AT = list(zip(*A))
    ans[0] = set(A[0])
    ans[1] = set(A[1])
    ans[2] = set(A[2])
    ans[3] = set(AT[0])
    ans[4] = set(AT[1])
    ans[5] = set(AT[2])
    ans[6] = set([A[i][i] for i in range(3)])
    ans[7] = set([A[i][2-i] for i in range(3)])

    for b in B:
        for a in ans:
            if b in a:
                a -= {b}
                if not a:
                    print("Yes")
                    return
    print("No")

if __name__ == "__main__":
    main()
S = list(input())
len = len(S)
flag = 1
s = S[0]


for i in range(1, len):
    if S[1] == null:
        break
    if s == 'h':
        if S[i] != 'i':
            flag = 0
            break
    if s == 'i':
        if S[i] != 'h':
            flag = 0
            break
    s = S[i]

if flag == 1:
    print('Yes')
else:
    print('No')


### FIXED CODE ###

S = list(input())
len = len(S)
flag = 1
s = S[0]


for i in range(0, len, 2):
    if len%2 == 1:
        flag = 0
        break

    if S[i] != 'h' or S[i+1] != 'i':
            flag = 0

    """""
    if s == 'h':
        if S[i] == 'i':
            flag = 1
    if s == 'i':
        if S[i] == 'h':
            flag = 1
    s = S[i]
    """

if flag == 1:
    print('Yes')
else:
    print('No')
import math
n, d= (int(c) for c in input().split())

x = []

for i in range(n): 
    x.append(input().split())

sum_ans = 0
count=0
for j in range(0,n):
    for k in range(j+1,n):
        for n in range(d):
            sum_ans = sum_ans+(int(x[j][n]) - int(x[k][n])) **2
        if math.sqrt(sum_ans)%1==0:
            count=count+1
        sum_ans=0
print(count)

### FIXED CODE ###

import math
n, d= (int(c) for c in input().split())

x = []

for i in range(n): 
    x.append(input().split())

sum_ans = 0
count=0
print
for j in range(0,n-1):
    for k in range(j+1,n):
        for l in range(d):
            sum_ans = sum_ans+(int(x[j][l]) - int(x[k][l])) **2
        if math.sqrt(sum_ans)%1==0.0:
            count=count+1
        sum_ans=0
print(count)
n, m = map(int, input().split())
ab = [map(int, input().split()) for _ in range(n)]
#i件目までのアルバイトでj日目までに得られる最大値
dp = [[0]*(m+1) for _ in range(n+1)]
for i in range(n):
    a, b = ab[i]#a日後に報酬bを得られる
    num = m+1-a
    for j in range(num):
        if j-1 >= 0:
            dp[i+1][j] = max(dp[i][j], dp[i][j-1]+b)
        else:
            dp[i+1][j] = max(dp[i][j], b)
    for j in range(a):
        dp[i+1][j+num] = dp[i+1][j+num-1]

print(max(dp[-1]))

### FIXED CODE ###

n, m = map(int, input().split())
jobs = [[] for _ in range(m+1)]
for i in range(n):
    a, b = map(int, input().split())
    if a > m: continue
    jobs[m-a].append(-b)
import heapq
q = []
heapq.heapify(q)
ans = 0
for i in reversed(range(m)):
    [heapq.heappush(q, job) for job in jobs[i]]
    if q: ans -= heapq.heappop(q)
print(ans)
a = int(input())
b = int(input())
c = int(input())

have_money = a + b*2

print( "Yes" if( have_money >= C ) else "No" )



### FIXED CODE ###

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


have_money = a + b

print( "Yes" if( have_money >= c ) else "No" )
n=int(input())
P=[int(input()) for i in range(n)]
sumOfP=sum(P)-P/2
print(sumOfP)

### FIXED CODE ###

n=int(input())
P=[int(input()) for i in range(n)]
sumOfP=int(sum(P)-max(P)/2)
print(sumOfP)
N,T=map(int,input().split())
t=list(map(int,input().split()))

for i in range(0,len(t)-1):
        ans+=min(t[i+1]-t[i],T)
ans+=T
print(ans)

### FIXED CODE ###

N,T=map(int,input().split())
t=list(map(int,input().split()))

ans=0
for i in range(0,len(t)-1):
        ans+=min(t[i+1]-t[i],T)
ans+=T
print(ans)
t_hp, t_ap, a_hp, a_ap = map(int,input().split())

while t_hp > 0 or a_hp > 0:
    a_hp -= t_ap
    if a_hp <= 0:
        return 'Yes'
        break

    t_hp -= a_ap
    if t_hp <= 0:
        return 'No'
        break

### FIXED CODE ###

t_hp, t_ap, a_hp, a_ap = map(int,input().split())

while t_hp > 0 or a_hp > 0:
    a_hp -= t_ap
    if a_hp <= 0:
        print('Yes')
        break

    t_hp -= a_ap
    if t_hp <= 0:
        print('No')
        break
n = int(input())
ans = 0
for i in range(1, n + 1):
    ans += ((n // i) * (2 * i + (n // i)  - 1) * i)) // 2
print(ans)

### FIXED CODE ###

def calc(n, a, d):
    return (n * (2 * a + (n - 1) * d)) // 2


n = int(input())
ans = 0
for i in range(1, n + 1):
    n_ = (n // i)
    d, a = i, i
    sm = calc(n_, a, d)
    ans += sm
print(ans)
s=str(input())
co=int(1)
n=len(s)
A=[]
for i in range(1,n):
    if s[i]!=s[i-1]:
        A.append(co)
        co=1
    else:
        co+=1
A.append(co)
m=len(A)
how=0
if s[0]=='T':
    how=1

for i in range(how,m-how):
    if i%2!=how:
        continue

    if A[i]<A[i+1]:
        n-=2*A[i]
    else:
        n-=2*A[i+1] 
print(n)

### FIXED CODE ###

s=str(input())
co=int(1)
n=len(s)
A=[]
for i in range(1,n):
    if s[i]!=s[i-1]:
        A.append(co)
        co=1
    else:
        co+=1
A.append(co)
m=len(A)
how=0
if s[0]=='T':
    how=1

S=int(0)
T=int(0)
for i in range(how,m-how):
    if i%2==how:##s
        S+=A[i]
    else:##t
        T+=A[i]
        if S<T:
            n-=2*S
            T=0
            S=0
        else:
            n-=2*T
            S-=T
            T=0


print(n)
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
def gcd(*numbers): reduce(math.gcd, numbers)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
count = 0
ans = 0

N = k()
ans = 1000000

for i in range(1,N**0.5+1):
    if n % i == 0:
        b = n // i
        ans = min(ans, b+i-2)

print(ans)


### FIXED CODE ###

import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
def gcd(*numbers): reduce(math.gcd, numbers)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
count = 0
ans = 0

N = k()
ans = N-1

for i in range(1,int(N**0.5)+1):
    if N % i == 0:
        b = N // i
        ans = min(ans, b+i-2)

print(ans)