peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
D = int(input())

ans = "Christmas"
for i in range(25-D):
    ans += " Eve"

print(ans)
# Judge status: Accepted
MOD = 998244353
n = int(input())
d = list(map(int, input().split()))
dist_map = [0]*n
for dist in d:
    dist_map[dist] += 1
ans = 1

if d[0] != 0 or dist_map[0] > 1:
    print(0)
    exit()

for i in range(1, n):
    ans *= pow(dist_map[i-1], dist_map[i], MOD)
    ans %= MOD
print(ans)
# Judge status: Accepted
n,x,y = map(int,input().split())
a = [0]*(n-1)
for i in range(n-1):
    for j in range(i+1,n):
        dist = min(j-i, abs(i-x+1)+1+abs(j-y+1))
        a[dist-1] += 1
for ans in a:
    print(ans)
# Judge status: Accepted
import bisect
N,M,K=[int(s) for s in input().split()]
A=[int(s) for s in input().split()]
B=[int(s) for s in input().split()]
Asum=[0 for i in range(N+1)]
Bsum=[0 for i in range(M+1)]
for i in range(N):
  Asum[i+1]=Asum[i]+A[i]
for i in range(M):
  Bsum[i+1]=Bsum[i]+B[i]
ans=[0 for i in range(N+1)]
t=bisect.bisect_right(Bsum,K)-1
ans[0]=t
for i in range(1,N+1):
  if Asum[i]>K:
    break
  while Bsum[t]+Asum[i]>K:
    t-=1
  ans[i]=i+t
print(max(ans))
# Judge status: Accepted
N,M=map(int,input().split())
N,M=sorted([N,M])
if N==1:
  if M>=3:print(M-2)
  else:print(2-M)
elif N==2:print(0)
else:print((N-2)*(M-2))
# Judge status: Accepted
n = int(input())
ll = [int(input()) for i in range(n)]
llc = ll.copy()
llc.sort()
m1 = llc[n-1]
m2 = llc[n-2]

for l in ll:
    if l == m1:
        print(m2)
    else:
        print(m1)
# Judge status: Wrong Answer
n=int(input())
s=str(input())
s=list(s)
tempw=s.count("W")
ans=n-tempw
cnt=n-tempw
for i in range(1,n):
  if s[i-1]=="W":
    cnt=cnt+1
  if s[i]=="E":
    cnt=cnt-1
  ans=min(ans,cnt)
print(ans)
# Judge status: Accepted
a = [chr(i) for i in range(97, 97+26)]
alpha = input()
if alpha in a:
    print('a')
else:
    print('A')
# Judge status: Accepted
A,B,C=map(int,input().split())
if (C>A and C<B) or (C<A and C>B):
    print("Yes")
else:
    print("No")
# Judge status: Accepted
N,X,Y = list(map(int, input().split()))
X,Y = X-1,Y-1
ans = [0] * (N-1)
for i in range(N):
  for j in range(i+1,N):
    d = min(j-i, abs(j-X) + 1 + abs(i-Y), abs(j-Y) + 1 + abs(i-X))
    ans[d-1] += 1
    
for a in ans:
  print(a)
  
#print(ans)
# Judge status: Wrong Answer
a,b,c= input().split()
if len(a) == 7:
  if len (b) ==5 and len(c) == 5:
    print ("YES")
  else:
    print ("NO")
else:
  if len(b) != 7 and len(c)!=7:
    print ("NO")
  else:
    if len(b) ==7 and len (c) ==5:
      print ("YES")
    else:
      if len(b) ==5 and len(c) ==7:
        print ("YES")
      else:
        print ("NO")
# Judge status: Accepted
import sys
import math
import bisect

n,h = map(int,input().split())
a = [0 for i in range(n)]
b = [0 for i in range(n)]
for i in range(n) :
  a[i],b[i] = map(int,input().split())
  
b.sort(reverse=True)

c = 0
bs = [b[0]]
am = max(a)
for i in range(1,n) :
  if b[i] < am :
    break
  bs.append(bs[i-1]+b[i])
  
if b[0] < am :
  print(math.ceil(h/am))
  sys.exit()

if bs[-1] <= h :
  print(len(bs) + math.ceil((h-bs[-1])/am))
else :
  print(bisect.bisect_left(bs,h)+1)
# Judge status: Wrong Answer
s=input()
ans=0
pre=""
for i in s:
  if pre!=i:
    pre=i
    ans+=1
  else:pre+=i
print(ans+int(len(pre)==2))
# Judge status: Wrong Answer
N, Y = map(int, input().split())
ans = [-1 -1 -1]
for x in range(N+1):
    for y in range(N+1):
        for z in range(N+1):
            if 10000*x + 5000*y + 1000*z == Y and (x+y+z) == N:
                ans = [x, y, z]
                break
print(*ans)
# Judge status: Wrong Answer
import sys
input = sys.stdin.readline

import math
from functools import reduce

# 最大公約数（リスト引数）
def GCD_list(numbers):
    return reduce(math.gcd, numbers)


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

maxgcd = 1
for a in A:
    B = [x for x in A if x != a]
    if len(B) == 0:
        continue
    gcd = GCD_list(B)
    if gcd > maxgcd:
        maxgcd = gcd

print(maxgcd)
# Judge status: Accepted
num, all_ans = [int(i) for i in input().split(" ")]
d_wa = [0 for _ in range(num)]
d_ac = [0 for _ in range(num)]
ans = 0

for _ in range(all_ans):
    ans_num, ac_wa = [i for i in input().split(" ")]
    if d_ac[int(ans_num) - 1] == 1: continue
    if ac_wa == "AC": 
        d_ac[int(ans_num) - 1] = 1
        continue
    if ac_wa == "WA":
        d_wa[int(ans_num) - 1] += 1
        continue

for num, i in enumerate(d_ac):
    if i:
       ans += d_wa[num]

print(sum(d_ac),ans)
# Judge status: Accepted
a,b,c = map(int,input().split())
if a+b == c or b+c == a or c+a == b:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
A, B, C, D = map(int, input().split())

while C>0 and A>0:
    C -= B
    A -= D

print('Yes' if C<=0 else 'No')
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
money = 1000
for i in range(1, n):
    if a[i] > a[i-1]:
        stocks = money // a[i-1]
        money = money - a[i-1] * stocks + a[i] * stocks
    else:
        continue
print(money)
# Judge status: Accepted
S=input()
count=0
string=""
queue=""
for s in S:
    queue+=s
    if string!=queue:
        count+=1
        string=queue
        queue=""
print(count)
# Judge status: Accepted
from sys import stdin
from math import sin,cos,pi
def main():
    #入力
    readline=stdin.readline
    A,B,H,M=map(int,readline().split())

    s=M*pi/30
    t=(H/6)*pi+(M/360)*pi
    x_A=A*sin(t)
    y_A=A*cos(t)

    x_B=B*sin(s)
    y_B=B*cos(s)

    print(((x_A-x_B)**2+(y_A-y_B)**2)**0.5)
    
if __name__=="__main__":
    main()
# Judge status: Accepted
x = int(input())
ans = 0
for i in range(1000):
    if i * 100 <= x <= i*105:
        ans = 1
        break
print(ans)
# Judge status: Accepted
N = int(input())
S = str(input())

ans = 0
tmp = 0
for i in S:
  if i == 'I':
    tmp += 1
    ans = max(ans, tmp)
  else:
    tmp -= 1
print(ans)
# Judge status: Accepted
N,M=map(int,input().split())
ls=[list(map(int,input().split())) for _ in range(M)]
if N==1:
  b=0
  c=10
else:
  b=10**(N-1)
  c=10**N
  
for i in range(b,c):
  a=str(i)
  for j in range(M):
    if a[ls[j][0]-1]==str(ls[j][1]):
      continue
    else:
      break
  else:
    print(i)
    break
else:
  print(-1)
# Judge status: Accepted
n = int(input())
h = list(map(int,input().split()))
tmp = h[0]
isOK = True
for i in range(1,n):
    #print(tmp,h[i])
    if tmp < h[i]:
        tmp = h[i] - 1
    elif tmp == h[i]:
        tmp = h[i]
    else:
        isOK = False
        break
if isOK:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
s=int(input()[::2])
print('NO' if s%4 else 'YES')
# Judge status: Wrong Answer
a = str(input())

print(a[3:])
# Judge status: Accepted
# AtCoder Beginner Contest 175
# C - Walking Takahashi

X,K,D =map(int,input().split())

KOE=K%2

A=abs(X)//D
M=abs(X)%D

# print(A)

if K<=A:
    print(abs(X)-K*D)
    exit()

else :
    if A%2==KOE:
        print(M)
    else :
        print(min(abs(M+D),abs(M-D)))
# Judge status: Accepted

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

small = min(a,b)
big = max(a,b)

ans = [str(small)]*big

print(*ans, sep='')
# Judge status: Accepted
S, a = input(), ""
for x in range(len(S)):
    a += "x"
print(a)
# Judge status: Accepted
N = int(input())
W = list(map(int,input().split()))
s = sum(W)
ans = 0
for w in W:
  if abs(s - 2*ans) <= abs(s - 2*(ans + w)):
    break
  else:
    ans += w
print(abs(2*ans-s))
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
total = 0
for a in A:
  total ^= a
result = []
for a in A:
  result.append(total ^ a)
print(*result)
# Judge status: Wrong Answer
import sys
read = sys.stdin.read
from math import sqrt, ceil
def main():
    n, m = map(int, input().split())
    if n == 1:
        print(m)
        sys.exit()
    r = 1
    #for i1 in range(2, ceil(sqrt(m))+1):
    for i1 in range(2, m + 1):
        if m % i1 == 0:
            r = i1
        if n * i1 > m:
            break
    print(r)

if __name__ == '__main__':
    main()
# Judge status: Accepted
a,b,c = map(int, input().split())
if b-a == c-b:
    print("YES")
else:
    print("NO")
# Judge status: Accepted
import math
x, k, d = map(int, input().split())
p = math.floor(abs(x/d))
if x > 0:
    if p >= k: print(abs(x-k*d))
    elif (k-p)%2==1: print(abs(x-(p+1)*d))
    else: print(abs(x-p*d))
else:
    if p >= k: print(abs(x+k*d))
    elif (k-p)%2==1: print(abs(x+(p+1)*d))
    else: print(abs(x+p*d))
# Judge status: Accepted
import sys

def main():

    # sys.stdin = open('input153c.txt')

    n, k = map(int, input().split())
    h = list(map(int, input().split()))

    h.sort(reverse=True)
    ans = 0

    for i in range(k, n):
        ans += h[i]

    print(ans)

if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
a,b=map(int,input().split())

if a-1>b-1:
  print("Alice")
elif a-1<b-1:
  print("Bob")
else:
  print("Draw")
# Judge status: Accepted
amari=0
k=int(input())
for i in range(k+1):
	amari+=7*pow(10,i,k)
	amari%=k
	if amari==0:
		print(i+1)
		exit()
print(-1)
# Judge status: Accepted
N = int(input())
T, A  = map(int, input().split())
H = list(map(int, input().split()))

MIN = 10000
ans = 10000

for i in range(N):
  if MIN > abs((T - H[i]*0.006) - A):
    MIN = abs((T - H[i]*0.006) - A)
    ans = i

print(ans+1)
# Judge status: Wrong Answer
N = list(input())
s = N[0]
n = int(''.join(N))

if int(N[0]*3) > n:
    print(N[0]*3)
else:
    print(str(int(N[0])+1)*3)
# Judge status: Accepted
s=input()
t=input()
num=len(s)

for i in range(num):
    s=s[-1]+s[:-1]
    #print(s)
    if (s==t):
        print("Yes")
        break
else:
    print("No")
# Judge status: Wrong Answer
n = int(input())
a = list(map(int, input().split()))


if a == [i for i in range(1, n+1)]:
    print(0)
    
else:
    b = 0
    number = 1
    for i in range(n):
        if a[i] == number:
            number += 1
        else:
            b += 1
    if b == (n - number + 1):
        print(b)
    else:
        print(-1)
# Judge status: Accepted
import sys
input = sys.stdin.readline
n,m = list(map(int,input().split()))
ab = sorted([list(map(int,input().split())) for _ in range(n)])
dri_cos = 0

for i in range(n):
    if m >= ab[i][1]:
        dri_cos += ab[i][0]*ab[i][1]
    else:
        dri_cos += ab[i][0]*m
    m -= ab[i][1]
    if m <=0:
        print(dri_cos)
        exit()
# Judge status: Accepted
N=int(input())
div=1
for i in range(7):
    if 2**i<=N:
        div=2**i
print(div)
# Judge status: Accepted
d, n = map(int, input().split())
if n == 100:
    print(100 ** d * 101)
else:
    print(100 ** d * n)
# Judge status: Wrong Answer
A, B =map(int, input().split())
M=int(-1)
for i in range(1000):
    if int(i*0.08)==A:
        if int(i*0.10)==B:
            M=i
            break

print(M)
# Judge status: Wrong Answer
l,r = map(int,input().split())
m = 2018
if r-l>=2019:
  print(0)
else:
  for i in range(l,r):
    for j in range(i+1,r+1):
      a = (i*j)%2019
      m = min(a,m)
print(m)
# Judge status: Accepted
n=int(input())
s=[input() for _ in range(n)]

print("AC x "+str(s.count("AC")))
print("WA x "+str(s.count("WA")))
print("TLE x "+str(s.count("TLE")))
print("RE x "+str(s.count("RE")))
# Judge status: Wrong Answer
c = [input() for _ in range(2)]

if c[0][1] == c[1][1] and sorted(c[0]) == sorted(c[1]):
	print("YES")
	exit()
else:
	print("NO")
# Judge status: Accepted
#!/usr/bin/python3
# -*- coding:utf-8 -*-

def main():
  n = int(input())
  la = [int(input()) for _ in range(n)]
  cnt = 0
  for i in range(n):
    cnt += (la[i]//2)
    la[i] -= 2*(la[i]//2)
    if i < n-1:
      n_pair = min(la[i], la[i+1])
      cnt += n_pair
      la[i] -= n_pair
      la[i+1] -= n_pair
  print(cnt)
  
if __name__=='__main__':
  main()
# Judge status: Accepted

n = int(input())

alphabet = [chr(i) for i in range(ord('a'), ord('z')+1)]

ans = ''
while n > 0:
    n -= 1
    ans += alphabet[n%26]
    n = n//26

print(ans[::-1])
# Judge status: Wrong Answer
n,k,q = map(int,input().split())
a = [0 for  _ in range(q)]
point = [k for _ in range(n)]
for i in range(q):
    a[i] = int(input())
for i in range(q):
    for j in range(len(point)):
        point[j] -= 1
    point[a[i]-1] += 1
for i in range(n):
    if(point[i] > 0):
        print("Yes")
    else:
        print("No")
print(point)
# Judge status: Accepted
from collections import defaultdict

n, k = map(int, input().split())
ab = sorted(list(map(int, input().split())) for _ in range(n))

for a, b in ab:
    k -= b
    if k <= 0:
        print(a)
        break
# Judge status: Accepted
A,B = map(int,input().split())
if((A%3 == 0) or (B%3 == 0) or ((A+B)%3 == 0)):
    print("Possible")
else:
    print("Impossible")
# Judge status: Accepted
n=int(input())

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

cnt=0
for i in range(1,n+1,2):
  l=divisore(i)
  if len(l)==8:
    cnt+=1
print(cnt)
# Judge status: Wrong Answer
x = int(input())
if x<100:
  print(0)
else:
  n = x//100
  m = x%100
  
  dp = set([1,2,3,4,5])
  
  for i in range(n):
    t = set([])
    for dp_i in dp:
      for j in range(6):
      	t.add((dp_i+j)%100)
    dp = t 
  
  if m in dp:
    print(1)
  else:
    print(0)
# Judge status: Accepted
import math
def I():
  return input()
def II():
  return int(input())
def MII():
  return map(int, input().split())
def LMII():
  return list(map(int, input().split()))

n = II()
x = 0
m = 100
while m < n:
  m = m*101//100
  x += 1
  
print(x)
# Judge status: Accepted
import decimal
a,b = input().split()
A = int(a)
B = decimal.Decimal(b)
c = (A*B).quantize(decimal.Decimal('1'), rounding=decimal.ROUND_FLOOR)
print(c)
# Judge status: Wrong Answer
N = int(input())

if N <= 1000:
    print('ABC')
else:
    print('ABD')
# Judge status: Accepted
number=list(map(int,input().split()))
n,m,q=number[0],number[1],number[2]
nums=[]
for i in range(q):
    tmp=list(map(int,input().split()))
    nums.append(tmp)
answer=0
mid=0
List1=[]
for i in range(m):
  List1.append(i)
import itertools
for i in list(itertools.combinations_with_replacement(List1,n)):
    mid=0
    for j in range(q):
        if i[nums[j][1]-1]-i[nums[j][0]-1]==nums[j][2]:
            mid+=nums[j][3]
    answer=max(mid,answer)
    
print(answer)
# Judge status: Wrong Answer
a,b,c = map(int, input().split())
d,e,f = map(int, input().split())
g,h,i = map(int, input().split())
n = int(input())
num =[]
for j in range(n):
    num.append(int(input()))
if a and b and c in num:
    print('Yes')
elif b and e and h in num:
    print('Yes')
elif c and f and i in num:
    print('Yes')
elif a and b and c in num:
    print('Yes')
elif d and e and f in num:
    print('Yes')
elif g and h and i in num:
    print('Yes')
elif a and e and i in num:
    print('Yes')
elif c and e and g in num:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
n,k = map(int,input().split())
a = list(map(int,input().split()))

idx = a.index(1)
ans = 0

ans += -(-idx // (k-1))
ans += -(-(n - ans * (k-1) - 1) // (k-1))

print(ans)
# Judge status: Accepted
a, b, c, d = map(int, input().split())

# a = 10
# b = 2
# c = 10
# d = 3

while True:
#     print(a)
#     print(c)
    
    c = c - b
    
    if c <= 0:
        print('Yes')
        break
            
    a = a - d
            
    if a <= 0:
        print('No')
        break
# Judge status: Accepted
n = int(input())
div_const = 1000000007

power = 1
for i in range(1, n + 1, 1):
    power *= i
    power = power % div_const

print(power)
# Judge status: Accepted
import collections
N = int(input())
List = [str(input()) for i in range(N)]
c = collections.Counter(List)
#print(c.most_common()[0])
#print(c.most_common()[1])
#print(c.most_common())

most=[]
most_num=c.most_common()[0][1]
for i in c.most_common():
    if i[1]==most_num:
        most.append(i[0])
most.sort()
for i in most:
    print(i)
# Judge status: Wrong Answer
def main():
    N, K = (int(i) for i in input().split())
    H = [int(input()) for i in range(N)]
    ans = 10*12
    H.sort()
    for i in range(N-K+1):
        ans = min(ans, abs(H[i+K-1] - H[i]))
    H = H[::-1]
    for i in range(N-K+1):
        ans = min(ans, abs(H[i+K-1] - H[i]))
    print(ans)


if __name__ == '__main__':
    main()
# Judge status: Accepted
n, r = map(int, input().split())

if n >= 10:
  ans = r
else:
  ans = 100 * (10 - n) + r
  
print(ans)
# Judge status: Accepted
N=int(input())
A=list(map(int,input().split()))
B,C=[],[]
for i in range(N):
  if A[i]>=0:
    B.append(A[i])
  else:
    C.append(-A[i])
if len(C)%2==0:
  ans=sum(B)+sum(C)
else:
  ans=sum(B)+sum(C)
  B.sort()
  C.sort()
  if len(B)==0:
    b=10**12
  else:
    b=B[0]
  a=min(b,C[0])
  ans-=2*a
print(ans)
# Judge status: Wrong Answer
N = int(input())
A = list(map(float, input().split()))

while len(A) > 1:
  x = A[-1]
  A.pop()
  y = A[-1]
  A.pop()
  A.append((x + y) / 2)

print(A[0])
# Judge status: Accepted
def main():
    T = input()
    print(T.replace('?','D'))



if __name__ == "__main__":
    main()
# Judge status: Accepted
from collections import Counter

n = int(input())
a = []

for _ in range(n):
    a.append(int(input()))

ctr = Counter(a)

ans = len([i[0] for i in ctr.items() if i[1] % 2 == 1])

print(ans)
# Judge status: Accepted
from collections import Counter

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

l = []
for i in A:
	l.extend([i-1, i, i+1])

count = Counter(l)
cand = sorted(count.most_common(), key=lambda x: x[1], reverse=True)[:3]
cand = list(filter(lambda x: cand[2][1]<=x[1], count.most_common()))
ans = 0
for tpl in cand:
    n = len(list(filter(lambda x: x == tpl[0] or x+1 == tpl[0] or x-1 == tpl[0], A)))
    ans = max(ans, n)

print(ans)
# Judge status: Accepted
a=list(map(int,input().split()))
b=sorted(a)
print(b[0]+b[1])
# Judge status: Accepted
n, m, *AB = map(int, open(0).read().split())

C, D = set(), set()
for a, b in zip(AB[::2], AB[1::2]):
  if a == 1:
    C.add(b)
  if b == n:
    D.add(a)

if len(C & D):
  print('POSSIBLE')
else:
  print('IMPOSSIBLE')
# Judge status: Accepted
x, y, z = map(int, input().split())
print(int((x + y - 1) / y) * z)
# Judge status: Accepted
import sys
import numpy as np
X = str(input())

d = 0
s = 0
for i in X:
    if i == 'R':
        d += 1
    else:
        if s < d:
            s = d
        d = 0
if s < d:
    s = d

print(s)
# Judge status: Accepted
a, b = map(int, input().split())
if a > 0:
    print('Positive')
elif b >= 0:
    print('Zero')
else:
    cnt = b - a + 1
    if cnt % 2 == 0:
        print('Positive')
    else:
        print('Negative')
# Judge status: Accepted
n = int(input())
print(int(n ** 0.5) ** 2)
# Judge status: Wrong Answer
l=["a","b","c","d","e"]
if input() in l:
  print("vowel")
else:
  print("consonant")
# Judge status: Accepted
n=int(input())
l=["a","b","c","d","e","f","g","h","i","j"]
a="a"
ans=["a"]
for i in range(1,n):
    tt=[]
    for j in ans:
        s=len(set(j))
        for k in range(s+1):
            tt.append(j+l[k])
    ans=tt
ans.sort()
for i in ans:
    print(i)
# Judge status: Wrong Answer
#!/usr/bin/env python3
s = input()
k = int(input())
n = len(s)
ans = ""
# kを減らしていく。もし、aまで戻せるならaまで進めてk をその分減らす。
for i in range(n):
    if ord(s[i]) - 97 + k >= 26:
        ans += "a"
        k -= 123 - ord(s[i])
    else:
        if i < n - 1:
            ans += s[i]
        else:
            ans += chr((ord(s[i]) + k - 97) % 26 + 97)
print(ans)
# Judge status: Accepted
N, = map(int, input().split())
X = list(map(int, input().split()))
mx = sum(X)

c = 1
R = 0
for i in range(N+1):
    x = X[i]
    R += c
    c -= x
    mx -= x
    if c < 0:
        print(-1)
        break
    c = min(c*2, mx)
else:
    print(R)
# Judge status: Wrong Answer
N = int(input())
x = 1
for i in range(N):
  x = x*i
  if x >= 10**9+7:
    x = x-10**9-7
print(x%(10**+7))
# Judge status: Accepted
# C
a,b,c,d = map(int,input().split())

import fractions

f=fractions.gcd(c,d)           #最大公約数
f2=c*d//f                          #最小公倍数

# a未満でcかdで割れるかず
a-=1
x = a//c
y = a//d
z = a//f2
ac = x+y-z

# b以下でcかdで割れるかず
x = b//c
y = b//d
z = b//f2
bc = x+y-z

print(b-a-(bc-ac))
# Judge status: Wrong Answer
import math
N=10000000019
han=999999999999999999999999999999999999999999
b=0



for a in range(1,int(math.sqrt(N))+1):
    if N%a==0:
        A=N/a
        if A>a:
            gou=A-a
        else:
            gou=a-A
        b=a
        if gou<han:
            han=gou
            kot=A+a
if b==A:
    print(int(kot)-1)
else:
    print(int(kot)-2)
# Judge status: Accepted
#coding: utf-8
import math
import heapq
import bisect
import numpy as np
#from scipy.misc import comb

N,M = map(int, input().split())

R = math.ceil(math.sqrt(M))
div = []
for i in range(1,R+1):
    if M % i == 0:
        div.append(M//i)
        div.append(i)

ans = 1
for d in div:
    if M//d >= N:
        ans = max(ans,d)

print(ans)
# Judge status: Accepted
N = input("")
t = N[-1]
pon = ["0", "1", "6" ,"8"] 
bon = "3"
if t == bon:
    print("bon")
elif t in pon:
    print("pon")
else:
    print("hon")
# Judge status: Wrong Answer
abck = input().split()

a = int(abck[0])
b = int(abck[1])
c = int(abck[2])
k = int(abck[3])


if k <= a:
  print(k)
elif k <= a+b:
  print(k)
else:
  print(a - (k-(a+b)))
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
s = 0
for i in range(n):
    a[i] -= (i+1)

a.sort()
for i in range(n):
    s += abs(a[i]-a[n//2])

print(s)
# Judge status: Accepted
w = input()
l = list(w)
wl = sorted(l)

flag = True
for i in range(0, len(wl), 2):
    if len(wl) % 2 == 1:
        print('No')
        flag = False
        break
    else:
        if wl[i] != wl[i + 1]:
            print('No')
            flag = False
            break
if flag:
    print('Yes')
# Judge status: Wrong Answer
N,K=map(int,input().split())
A=list(map(int,input().split()))

dictS={}
dictS[0]=1

p=9007199254740997

for n in range (1,N):
    if n<K:
        # S.append(A[n]*S[-1])
        dictS[n]=(A[n]*dictS[n-1])%p

    else:
        # S.append(A[n]*S[-1]/A[n-K])
        dictS[n]=(A[n]*dictS[n-1]/A[n-K])%p

for i in range (K,N):
    if dictS[i]>dictS[i-1]:
        print('Yes')
    else:
        print('No')
# Judge status: Accepted
import math

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

e = c*d//math.gcd(c,d)

x = b//c-a//c 

x += b//d-a//d

x -= b//e-a//e 

if a%c == 0:
    x += 1
    
if a%d == 0:
    x += 1
    
if a%e == 0:
    x -= 1
    
print(b-a-x+1)
# Judge status: Wrong Answer
A, B, C = [int(i) for i in input().split()]

if A == B == C:
    print("No")
elif A != B != C:
    print("No")
else:
    print("Yes")
# Judge status: Accepted
n,k  = map(int, input().split())
h = list(map(int, input().split()))

dp = [0] * n
for i in range(1, n):
  start = max(0, i - k)
  dp[i] = dp[start] + abs(h[start] - h[i])
  for j in range(start+1, i + 1):
    dp[i] = min(dp[i], dp[j] + abs(h[j]-h[i]))
  
print(dp[n-1])
# Judge status: Accepted
def resolve():
    N, K = map(int, input().split(" "))
    Xs = list(map(int, input().split(" ")))
    ans = 10**9
    for i in range(N-K+1):
        cnt = Xs[i+K-1] - Xs[i] + min(abs(Xs[i+K-1]), abs(Xs[i]))
        ans = min(cnt, ans)
    print(ans)



if '__main__' == __name__:
    resolve()
# Judge status: Accepted
a,b = map(int,input().split())
coin = 0
counter = 0

while counter < 2:
  if a >= b:
    coin += a
    a -= 1
  else:
    coin += b
    b -= 1
  counter += 1
print(coin)
# Judge status: Wrong Answer
N, M = map(int, input().split())
A = list(map(int, input().split()))

A_sum = sum(A)
th = A_sum / (4 * M)
popular_product = 0

for a in A:
    if a >= th:
        popular_product += 1

if popular_product <= M:
    print('No')
else:
    print('Yes')
# Judge status: Wrong Answer
N = int(input())
D = list(map(int, input().split()))
D.sort()
if D.pop(0) != 0:
  ans = 0
else:
  ans = 1
  num = 1
  before = 1
  after = 0
  for i in D:
    if i == num:
      after += 1
    elif i == num+1:
      ans = ans * (before**after) %998244353
      num += 1
      before = after
      after = 1
    else:
      ans = 0
  ans = ans * (before**after) %998244353
print(ans)