peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Wrong Answer

import statistics
N = int(input())

nums = list(map(int, input().split()))
nums = [num - (i + 1) for i, num in enumerate(nums)]

# print(nums)


def compute_sour(num, b):
    return abs(num - b)


middle_num = statistics.median(nums)

# print(middle_num)
ans = 0
for num in nums:
    ans += compute_sour(num, middle_num)
print(ans)
# Judge status: Accepted
n, k = map(int, input().split())

m = [0]*n

for i in range(k):
    d = int(input())
    a = list(map(int, input().split()))
    for j in range(d):
        m[a[j]-1] += 1

print(m.count(0))
# Judge status: Wrong Answer
s=str(input())

if s[0] != 7 and s[1] != 7 and s[2] != 7:
    print("No")

else:
    print("Yes")
# Judge status: Wrong Answer
A, B = map(int, input().split())
result = True
for a in range(1, 1001):
    if int(a * 0.08) == A and int(a * 0.1) == B:
        print(a)
        break
        result = False
        exit()
        
if result:
    print(-1)
# Judge status: Accepted
s = input()
k = int(input())

for i, x in enumerate(s):
    if x == '1':
        if k == i + 1:
            print(1)
            exit()
    else:
        print(x)
        exit()
# Judge status: Wrong Answer
abc=str(input())
a=abc[0]
b=abc[1]
c=abc[2]



if a == b and b==c and c==a:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
import math
N, D = map(int, input().split())
ans = math.ceil(N / (D * 2 + 1))
print(ans)
# Judge status: Accepted
N=str(input())
if (N[0]==N[1] and N[1]==N[2]) or (N[1]==N[2] and N[2]==N[3]):
  print("Yes")
else:
  print("No")
# Judge status: Accepted
a,b,c = map(int,input().split())
n1,n2,n3 = sorted([a,b,c],reverse= True)

print(10*n1 + n2 + n3)
# Judge status: Accepted
D, N = map(int,input().split())

if D == 0 and N != 100:
    print(N)
if D == 0 and N == 100:
    print(101)
if D == 1 and N != 100:
    print(N*100)
if D == 1 and N == 100:
    print(10100)
if D == 2 and N != 100:
    print(N*10000)
if D == 2 and N == 100:
    print(1010000)
# Judge status: Accepted
a,b,c,d=map(int,input().split())

if (abs(a-b)<=d and abs(b-c)<=d) or abs(a-c)<=d:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
n = int(input())
a = list(map(int,input().split()))
cnt = [0]*8
free = 0
for i in range(n):
    if a[i] <= 3199:
        cnt[a[i]//400] += 1
    else:
        free += 1
print(min(1,8-cnt.count(0)),8-cnt.count(0)+free)
# Judge status: Accepted
import itertools
n, k = (int(i) for i in input().split())
P = [int(i) for i in input().split()]

probs = list(itertools.accumulate([(1+p)/2 for p in P]))
probs.insert(0,0)

ans = 0

for i in range(n-k+1):
    ans = max(ans, -probs[i]+probs[i+k])

print(ans)
# Judge status: Wrong Answer
S=input()
T="keyence"
for i in range(len(S)-1):
    for j in range(i,len(S)-1):
        if S[:i]+S[j:]==T:
            print("YES")
            exit()
print("No")
# Judge status: Accepted
n=int(input())
ans=n%1000
if(ans==0):
  print(ans)
else:
	print(1000-ans)
# Judge status: Wrong Answer
S = input()
a = [0]*(len(S)+1)

for i in range(len(S)):
    if S[i] is '<':
        a[i+1] = max(a[i+1], a[i]+1)
        print(a)

for i in range(1, len(S)):
    if S[-i] is '>':
        a[-(i+1)] = max(a[-(i+1)], a[-i]+1)
        print(a)
print(sum(a))
# Judge status: Accepted
import numpy as np

W, H, N = map(int, input().split())
l = np.zeros((H,W))

for i in range(N):
  x, y, a = map(int, input().split())
  if a==1:
    l[:,:x] = 1
  elif a==2:
    l[:,x:] = 1
  elif a==3:
    l[:y,:] = 1
  elif a==4:
    l[y:,:] = 1
    
print(H*W-int(l.sum().sum()))
# Judge status: Accepted
n = int(input())
ans = 0
for i in range(1, n+1):
    m = n//i
    ans += (2*i*m + (m-1)*i*m) // 2
print(ans)
# Judge status: Accepted
A,B,C = map(int,input().split())
l = [A*B,B*C,A*C]

l[0] *= abs(C//2-(C-C//2))
l[1] *= abs(A//2-(A-A//2))
l[2] *= abs(B//2-(B-B//2))

print(min(l))
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
count = 0
i = 1
while i < len(a):
    if a[i] < a[i-1]:
        count += a[i-1] - a[i]
        a[i] = a[i-1]
    i += 1
print(count)
# Judge status: Wrong Answer
N=int(input())
a=list(map(int,input().split()))

i=0
count=0

if 1 in a:
    while len(a)>0:
        if i+1 in a[i::]:
            i+=1

        else:
            break
    #print(i)

    print(N-i)
else:
    print(-1)
# Judge status: Wrong Answer

s=input()
count=0
if s != s[::-1]:
    count += 1
print(count//2)
# Judge status: Accepted
n = int(input())
*a, = map(int, input().split())

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

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

ans = float("inf")
for i in range(1, n):
    ans = min(ans, abs(x[i]-y[i]))

print(ans)
# Judge status: Wrong Answer
from copy import copy, deepcopy
from collections import Counter
from math import sqrt, floor, factorial
from itertools import permutations, combinations, combinations_with_replacement
from operator import mul
from functools import reduce
import bisect

MOD = 10**9 + 7
INF = float('inf')

S = input()
T = input()
print(S)
if T[:-1] == S:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
s = (int)(input())
s1 = s//100
s2 = (s%100)//10
s3 = (s%10)

print((str)(s1+s2+s3))
# Judge status: Wrong Answer
N = int(input())
NR = int(N**0.5)
count = 0
if int(N/2)-N/2 == 0:
    for i in range(1,int(N/2)):
        if int(N/i)-N/i == 0:
            count += int(N-1/i)-1
        else:
            count += int(N-1/i)
else:
    for i in range(1,int(N/2)+1):
        if int(N/i)-N/i == 0:
            count += int(N-1/i)-1
        else:
            count += int(N-1/i)

count += int(N/2)
print(count)
# Judge status: Accepted
N=int(input())
A=list(map(int,input().split()))
ans=1
vec=0
for i in range(N-1):
  now=A[i+1]-A[i]
  if vec*now<0:
    ans+=1
    vec=0
  elif vec==0:
    vec=now
print(ans)
# Judge status: Accepted

a = int(input())

print (a + a**2 + a**3)
# Judge status: Accepted
import numpy as np

n, k, q = map(int, input().split())
a = []
for _ in range(q):
    a.append(int(input()))

nn = np.zeros(n)
kk = np.zeros(n) + k
qq = np.zeros(n) + q

for i in a:
    nn[i-1] += 1

_list = (kk-qq+nn).tolist()

for ans in _list:
    if ans > 0:
        print('Yes')
    else:
        print('No')
# Judge status: Accepted
n = int(input())
a = list(map(int,input().split()))
ans = 0
for i in range(1,n):
    dif = a[i] - a[i-1]
    if dif<0:
        a[i] -= dif
        ans -= dif

print(ans)
# Judge status: Wrong Answer
import math

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

x = math.floor(A/0.08)
y = math.floor(B/0.1)

if(math.floor(x*0.1)!=B):
  print("-1")

else:
  while(y<x):
    if(math.floor(y*0.1)==math.floor(y*0.08)):
      if(y<r):
        r=y
    y+=1

  print(r)
# Judge status: Wrong Answer
n = int(input())
tmp = n // 15
tmp2 = n % 15
d = [(15*(tmp) + i) for i in [0,1,2,0,4,0,0,7,8,0,0,11,0,13,14]]
for i in [0,3,5,6,9,10,12]:
    d[i] = 0
(tmp **2 * 60) + sum(d[:(tmp2+1)])
# Judge status: Accepted
N,C,K=map(int,input().split())
T=[int(input()) for i in range(N)]
T.sort()
res=0#乗客
time=0#発車K分前
ans=0

for i in range(len(T)):
    if res!=0 and time+K<T[i]:
        ans+=1
        res=1
        time=T[i]

    else:
        res+=1
        if res==1:
            time=T[i]
        if res==C:
            ans+=1
            res=0

if res>0:
    ans+=1

print(ans)
# Judge status: Accepted
n = int(input())

six = []
s = 6
while s <= n:
    six.append(s)
    s *= 6
s = 9
while s <= n:
    six.append(s)
    s *= 9
six.sort()
dp = [i for i in range(n+13)]
for s in six:
    for i in range(n-s+1):
        if dp[i] + 1 < dp[i+s]:
            dp[i+s] = dp[i] + 1

print(dp[n])
# Judge status: Wrong Answer
a, b, c, k = map(int, input().split())

if k <= a:
  print(a)
elif k <= a+b:
  print(a)
else:
  print(a-(k-a-b))
# Judge status: Wrong Answer
import math
import sys

n=int(input())

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

if d[0]!=0 or 0 in d[1:]:
    print(0)
    sys.exit()

lis=[0 for i in range(n)]

for i in range(n):
    lis[d[i]]+=1

s=1

i=0
while i+1<=n-1 and lis[i+1]!=0:
    s=(s*pow(lis[i],lis[i+1],998244353))%998244353
    i+=1
print(s)
# Judge status: Wrong Answer
s=input()
ans=0
k=0
for i in s:
    if i=='I':
        k+=1
        ans=max(ans,k)
    elif i=='D':
        k-=1
print(ans)
# Judge status: Accepted
from collections import Counter

N = int(input())
S = list(input())

C = Counter(S)
count = 1
mod = 10**9 + 7
for i in C.values():
    count *= i+1
print((count-1)%mod)
# Judge status: Wrong Answer
import bisect

N = int(input())
al = list(map(int, input().split()))
bl = list(map(int, input().split()))
cl = list(map(int, input().split()))
al.sort()
# print(al)
bl.sort()
# print(bl)
cl.sort()
# print(cl)

cnt = 0
for b in range(N):
    idx = bisect.bisect_left(al, bl[b])  # bl[b] = 6 idx= 3
    cnt_ab = idx - 1


    idx2 = bisect.bisect(cl, bl[b])  # bl[b] = 6 idx2= 1
    cnt_bc = len(cl) - idx2

    # print(cnt_ab,cnt_bc)

    cnt += cnt_ab * cnt_bc

print(cnt)
# Judge status: Wrong Answer
n=int(input())
d=list(map(int, input().split()))
#print(d)
sd = sorted(d)
##print(sd[len(d)//2-1])
print(sd[len(d)//2])
print(sd[len(d)//2]  -  sd[len(d)//2-1] +1)
# Judge status: Accepted
import collections
n,m = map(int,input().split())
box = [[1,"white"] for i in range(n)]
box[0][1] = "red"
for i in range(m):
    x,y = map(int,input().split())
    x -= 1
    y -= 1
    if box[x][1] == "red":
        box[y][1] = "red"
    box[y][0] += 1
    box[x][0] -= 1
    if box[x][0] == 0:
        box[x][1] = "white"
ans = 0
for i in range(n):
    if box[i][1] == "red":
        ans += 1
print(ans)
# Judge status: Accepted
n, m = list(map(int, input().split()))
x = list(map(int, input().split()))
x.sort()
diffs = []
for i in range(m - 1):
    diffs.append([i, x[i + 1] - x[i]])
diffs = sorted(diffs, key=lambda x: -x[1])
diffs = list(map(lambda x: [x[0], x[0] + 1], diffs[:(n - 1)]))
diffs = [[0, 0]] + sorted(diffs) + [[(len(x) - 1), (len(x) - 1)]]
ans = 0
for i in range(len(diffs) - 1):
    ans += x[diffs[i + 1][0]] - x[diffs[i][1]]
print(ans)
# Judge status: Wrong Answer
n = int(input())
a = []
for _ in range(n):
    a.append(int(input()))
    
ans = 0
for i in range(n):
    ans += a[i] // 2
    a[i] %= 2
for i in range(n-1):
    if a[i]+a[i+1] == 2:
        ans += 1
        a[i],a[i+1] = 0,0
        
print(ans)
# Judge status: Accepted
n = int(input())
N = 10**9
x1=0
y1=0
x2=N
y2=1
x3=N-n%N
y3=n//N+1
if n==10**18:
    x3=0
    y3=n//N

print(x1,y1,x2,y2,x3,y3)
# Judge status: Wrong Answer
W, H, x, y = map(int, input().split())

S = W * H / 2

print (S, end = ' ')
if W == 2 * x and H == 2 ** y:
    print (1)
else:
    print (0)
# Judge status: Accepted
N = int(input())
A= list(map(int, input().split()))
S = sum(A)
ans = 0
leaf = 1
S_now = 0

if A[0] == 1:
  if N==0:
    print(1)
  else:
    print(-1)
elif A[0] != 0:
  print(-1)
else:
  for i in range(N):
    ans += leaf
    leaf -= A[i]
    S_now += A[i] 
    leaf = min(leaf*2,S-S_now)
  if A[-1] != leaf:
    print(-1)
  else:
    print(ans+A[-1])
# Judge status: Accepted
def need(a):
    if a=="a":
        return 0
    else:
        return 123-ord(a)

s=list(input())
x=int(input())
i=0
while x>0:
    count=need(s[i])
    if x>=count:
        s[i]="a"
        x-=count
    
    if i==len(s)-1:
        s[i]=chr(ord(s[i])+(x%26))
        x=0
    i+=1
print("".join(s))
# Judge status: Accepted
N, L = map(int,input().split())

def taste(i):
  return L + i
m = 1e+10
t = 0
appleN = [taste(i) for i in range(N)]
for n in range(N):
  appleN_1 = [taste(i) for i in range(N) if i != n]
  m = min(m, abs(sum(appleN) - sum(appleN_1)))
  if m == abs(sum(appleN) - sum(appleN_1)):
    t = sum(appleN_1)
print(t)
# Judge status: Accepted
a = [list(map(int, input().split())) for i in range(3)]
n = int(input())
b = [int(input()) for i in range(n)]
flag = False
for i in range(3):
    if all(a[i][j] in b for j in range(3)): #bの中にa[i][j]があるかどうか
        flag = True
    if all(a[j][i] in b for j in range(3)):
        flag = True
if all(a[i][i] in b for i in range(3)) or all(a[i][2-i] in b for i in range(3)):
    flag = True
 
if flag:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
h = int(input())
cnt = 0
if h == 1:
  print(1)
  quit()
while h > 1:
  h = h // 2
  cnt += 1
print(2**(cnt+1)-1)
# Judge status: Wrong Answer
n, m = map(int, input().split())
suki = [0]*(m+1)

for i in range(n):
    ka = list(map(int, input().split()))
    for j in range(ka[0]):
        suki[ka[j]] += 1

ans = 0
for i in range(1, m+1):
    if suki[i] == n:
        ans += 1
print(ans)
# Judge status: Accepted
N, A, B = map(int, input().split())
if N == 1:
    if A == B: print(1)
    else:print(0)
    exit()
if A > B:
    print(0)
    exit()
m = A + (N-2)*A + B
M = A + (N-2)*B + B
print(max(0,M-m+1))
# Judge status: Wrong Answer
s = input()
big = 0
small = 0
n = 0
big2 =0
for i in range(len(s)):
  if s[i]=='<':
    big += 1
    n += big
    small =0
    big2 = big
  else:
    small += 1
    n += small
    if small<=big2:
      n-=1
      big =0
  print(n)
# Judge status: Accepted
N=int(input())
ans=0
for n in range(N):
  n+=1
  if n%5!=0 and n%3!=0:
    ans+=n
print(ans)
# Judge status: Accepted

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

b0,b1,b2 = 0,0,0

for i in range(N):
    if a[i]%2==1:
        b0+=1
    elif a[i]%4==0:
        b2+=1
    else:
        b1+=1
# print('b0,b1,b2:',b0,b1,b2)
if b1==0:
    if b2>=b0-1:
        print('Yes')
    else:
        print('No')

else:
    b0+=1
    if b2>=b0-1:
        print('Yes')
    else:
        print('No')
# Judge status: Accepted
n, m = map(int, input().split())
a, b = [], []
for i in range(n):
    te, mp = map(int, input().split())
    a.append(te)
    b.append(mp)

e, f = [], []
for i, j in sorted(zip(a, b)):
    e.append(i)
    f.append(j)

ans = 0
for i in range(n):
    if m - f[i] <= 0:
        ans += e[i] * m
        print(ans)
        exit()
    else:
        ans += f[i] * e[i]
        m -= f[i]
print(ans)
# Judge status: Wrong Answer
n=int(input())
a=[0]*n
a=map(int,input().split())
    
z=0
p=0
result=0
min=1000000002

for i in a:
    if i<0:
        z+=1
    if i==0:
       p=1 
    result+=abs(i)
    if abs(i)<min:
        min=abs(i)

if p==0 & z%2==1:
    result-=min*2

print(result)
# Judge status: Accepted
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
cnt = Counter(A)
for i in range(N):
    print(cnt[i+1])
# Judge status: Wrong Answer
N = int(input())
S = [input() for _ in range(N)]
M = int(input())
T = [input() for _ in range(M)]
ans = 0
for i in range(N):
    if S.count(S[i]) >= T.count(S[i]):
        ans = S.count(S[i]) - T.count(S[i])
print(ans)
# Judge status: Wrong Answer
X=int(input())
l=[1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 400, 441, 484, 529, 576, 625, 676, 729, 784, 841, 900, 961]
for i in range(len(l)):
    if X<l[i]:
        print(l[i-1])
        exit()
print(l[-1])
# Judge status: Accepted
A = int(input())
B = int(input())
C = int(input())
X = int(input())
count = 0
for i in range(A + 1):
  for j in range(B + 1):
    for k in range(C + 1):
      if X == 500 * i + 100 * j + 50 * k:
        count += 1
print(count)
# Judge status: Wrong Answer
a, b, c = map(int, input().split())

C = sorted(list([a, b, c]))

d1 = C[2] - C[0]
d2 = C[2] - C[1]

if (d2 - d1) % 2 == 0:
    print(d2 + (d1 - d2)//2)
else:
    print(d2 + 2)
# Judge status: Accepted
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

x,y = iim()

if y == 1 or x%y == 0:
    print(-1)
else:
    print(x*(y-1))
# Judge status: Accepted
num = int(input())
mod = 10 ** 9 + 7
ans = 0
if num >= 2:
    temp9 = (9 ** num) % mod
    temp8 = (8 ** num) % mod
    val = (temp9 * 2 - temp8) % mod
    ans = (10 ** num) % mod + mod - val
print(ans % mod)
# Judge status: Accepted
ABCD = input()

def dfs(i, f, sum):
    if i==3:
        if sum==7:
            print(f + '=7')
            exit()
    else:
        dfs(i+1, f + "-" + ABCD[i+1], sum - int(ABCD[i+1]))
        dfs(i+1, f + "+" + ABCD[i+1], sum + int(ABCD[i+1]))

dfs(0, ABCD[0], int(ABCD[0]))
# Judge status: Wrong Answer
a, b = map(int, input().split())
c = 0
for i in range(1,a+1):
  for j in range(1, b+1):
    if i == j:
      c +=1
print(c)
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))

not_in = [0 for i in range(N+1)]
not_in[0] = A[0]
for i in range(1, N+1):
  not_in[i] = not_in[i-1] * 2 + A[i]

if not_in[N] > 2 ** N:
  print(-1)
else:
  in_num = 0
  up = A[N]
  for i in range(N-1,-1,-1):
    in_temp = min(2 ** i - not_in[i], up)
    in_num += in_temp
    up = in_temp + A[i]
  print( in_num + sum(A) )
# Judge status: Accepted
#!/usr/bin/env python
# coding: utf-8

# In[16]:


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


# In[49]:


low = 0
high = max(A)
def ok(x):
    cnt = 0
    for a in A:
        cnt += (a//x)
        if a%x == 0:
            cnt -= 1
    return cnt <= K
 
while high-low > 1:
    mid = (high+low)//2
    if ok(mid):
        high = mid
    else:
        low = mid
print(high)


# In[ ]:
# Judge status: Wrong Answer
n, k = map(int, input().split())
p = list(map(int, input().split()))

total_expects = []
# 1回のサイコロについて
for i in range(0, n):    
    # 1個のサイコロの期待値リスト
    expect = [q * (1 / p[i]) for q in range(1, p[i]+1)]
    total_expects.append(sum(expect))

print(max([sum(total_expects[i:i+k]) for i in range(0, k)]))
# Judge status: Accepted
n,x = map(int,input().split())
a = list(map(int,input().split()))
ans = [[0]*2 for i in range(n)]
ans[0][0] = max(0,a[0] - x)
ans[0][1] = a[0] - ans[0][0]

for i in range(1,n):
    al = max(0,ans[i-1][1] + a[i] - x)
    ans[i][0] = ans[i-1][0] + al
    ans[i][1] = a[i] - al
    
print(ans[n-1][0])
# Judge status: Accepted
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n = int(input())
A = [int(input()) for i in range(n)]
dp = [-inf] * (10**5+10);dp[-1] = inf
for ai in A:
  dp[bisect.bisect_left(dp,ai)-1] = ai
for di in dp:
  if di != -inf:ans += 1
print(ans - 1)
# Judge status: Accepted
import sys
input = sys.stdin.readline
from collections import *
from math import *

N, K = map(int, input().split())
MOD = 10**9+7
ans = 0

for i in range(K, N+2):
    c = ((2*N-i+1)*i)//2-i*(i-1)//2+1
    ans += c
    ans %= MOD

print(ans)
# Judge status: Accepted
[a, b, c, d] = [int(inp) for inp in input().split()]
print(max([a * c, b * d, a * d, b * c]))
# Judge status: Accepted
import sys
n,m=map(int,input().split())
d=dict()
if n==1 and m==0:
  print("0")
  sys.exit()
l=[-1]*n
for _ in range(m):
  s,c=map(int,input().split())
  s-=1
  if (s in d.keys() and d[s]!=c) or s>=n:
    print("-1")
    sys.exit()
  d[s]=c
  l[s]=c
if l[0]==0 and n>1:
  print("-1")
  sys.exit()
for i in range(n):
  if i==0 and l[0]==-1:
    l[0]=1
  else:
    if l[i]!=-1:
      continue
    else:
      l[i]=0
print(*l,sep='')
# Judge status: Accepted
n,k=map(int,input().split())
a=0
while n:
  n=n//k
  a+=1
print(a)
# Judge status: Wrong Answer
S=int(input())    
a=S%(10**9)
b=10**9-a
print(0,0,1,10**9,(S+b)//(10**9),b)
# Judge status: Wrong Answer
r,g,b = input().split()
is_four_multiple = g+b
if int(is_four_multiple) % 4 == 0:
  	print("Yes")
else:
  	print("No")
# Judge status: Wrong Answer
import sys
A, B, N = map(int, input().split())

ans = [int((A*(i+(B-1)))/B) - (A*i) for i in range(N+1) if i % B == 0]
ans.append(0)

print(max(ans))
# Judge status: Accepted
n=int(input())
sums=0
i=1
while i<=n:
    m=n//i
    sums=sums+((m+1)/2*m)*i
    i=i+1
print(int(sums))
# Judge status: Accepted
n = int(input())
ans = 1
i=1
while i*i<=n:
    if n%i==0:
        ans = i
    i+=1

ans += n//ans
ans -= 2
print(ans)
# Judge status: Accepted
L, R = map(int, input().split())

reg = 2018
if R-L >= 3000:
    print(0)
else:
    for l in range(L, R):
        for r in range(l+1, R+1):
            tmp = (l * r) % 2019
            reg = min(reg, tmp)
    print(reg)
# Judge status: Accepted
list = [64,32,16,8,4,2]
O = int(input())
if O == 1:
    print(1)
    exit()

for num in list:
    if O >= num:
        print(num)
        break
# Judge status: Wrong Answer
n,k = map(int,input().split())
a = [int(i) for i in input().split()]
done = []

def ml(a):
	cnt=1
	nxt=a[0]-1
	done.append(0)
	done.append(nxt)
	while(True):
		nxt = a[nxt]-1
		if nxt in done: 
			m = done.index(nxt) - 1
			l = cnt - m
			return (m+1,l)
		else: done.append(nxt)
		cnt+=1

# print(is_1(a))
m,l = ml(a)
num = (k-m)%l

# print(f"m={m},l={l}")
# print(f"done={done}")
# print(f"m+num={m+num}")
print(done[m+num]+1)
# Judge status: Accepted
N = int(input())
A = int(input())

if N%500 <= A:
	print('Yes')
else:
	print('No')
# Judge status: Accepted


def submit():
    l, r, d = map(int, input().split())

    cnt = 0
    for t in range(l, r + 1):
        if t % d == 0:
            cnt += 1

    print(cnt)


submit()
# Judge status: Accepted
N,K=map(int,input().split())
A=list(map(int,input().split()))
A=[A[i]-1 for i in range(N)]

doubling=[[0 for i in range(N)] for i in range(0,70)]
for i in range(N):
    doubling[0][i]=A[i]

for i in range(1,70):
    for j in range(N):
        doubling[i][j]=doubling[i-1][doubling[i-1][j]]

ans=0
for i in range(0,70):
    if K>>i &1==1:
        ans=doubling[i][ans]

print(ans+1)
# Judge status: Wrong Answer
from itertools import accumulate
N, K = map(int, input().split())
A = list(map(int, input().split()))
if all([a == 0 for a in A]):
    print(*A)
    exit()
for k in range(min(50, K)):
    B = [0]*N
    for i in range(N):
        B[max(0, i-A[i])] += 1
        r = i+A[i]+1
        if r < N:
            B[r] -= 1
    A = list(accumulate(B))
print(*A)
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))

while len(A) > 1:
    A.sort()
    x, y = A.pop(0), A.pop(0)
    v = (x + y) / 2
    A.append(v)

print(*A)
# Judge status: Accepted
#!/usr/bin/env python3
s = input()
cnt1 = 0
cnt2 = 0
for i in s:
    if i == "0":
        cnt1 += 1
    else:
        cnt2 += 1
print(2*min(cnt1,cnt2))
# Judge status: Accepted
from collections import Counter
s = input()
n = len(s)
count = [0 for i in range(3)]
for i in range(n):
    count[ord(s[i]) - ord('a')] += 1
count.sort()
if count[2] - count[0] > 1:
    print("NO")
else:
    print("YES")
# Judge status: Accepted
import sys
A, B = map(int, input().split())

if B<=1:
  print(0)
  sys.exit()

for i in range(1,23):
  if i*(A-1)+1 >= B:
    print(i)
    sys.exit()
# Judge status: Accepted
def main():

    n, k = map(int, input().split())
    P = list(map(int, input().split()))
    # print(exp_sum(n, k, P))
    mx = 0
    for i in range(k):
        mx += (P[i] + 1) / 2
    tmp = mx
    for i in range(k, n):
        tmp += (P[i] - P[i - k]) / 2
        mx = max(mx, tmp)
    print(mx)

if __name__ == "__main__":
    main()
# Judge status: Accepted
A,B=map(int,input().split());S=input();print('Yes' if S[:A].isdigit() and S[A]=='-' and S[B+1:].isdigit() else 'No')
# Judge status: Wrong Answer
X,Y,A,B,C = map(int,input().split())
p,q,r = [sorted(map(int,input().split()),reverse=True) for i in range(3)]
rr = [0 for i in range(X+Y)]
for i in range(min(X+Y,C)):
    rr[i] += r[i]
temp = sum(rr)
ans = 0
count = X+Y-1

for i in range(X):
    temp += p[i]
    temp -= rr[count]
    count -= 1
    count_2 = count
    temp_2 = temp
    for j in range(Y):
        temp_2 += q[j]
        temp_2 -= rr[count_2]
        count_2 -= 1
        ans = max(ans,temp_2)

print(ans)
# Judge status: Accepted
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

L = list(map(int, read().decode("utf-8").split()))

last_ = L[0] % 10
last_index = 0
for i, t in enumerate(L):
    if 0 < t % 10 < last_:
        last_ = t % 10
        last_index = i

ans = 0
for i, t in enumerate(L):
    if i != last_index:
        ans += t
        if t % 10:
            ans += 10 - (t % 10)
ans += L[last_index]
print(ans)
# Judge status: Accepted

S = input()

print("No" if "L" in S[::2] or "R" in S[1::2] else "Yes")