peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
import string

n = int(input())

d = dict()
for c in string.ascii_lowercase:
    d[c] = []

for _ in range(n):
    s = input()
    for c in string.ascii_lowercase:
        if s.count(c) != 0:
            d[c].append(s.count(c))

ans = ""
for k, v in d.items():
    if len(v) == n:
        ans += k * min(v)

print(ans)
# Judge status: Accepted
n = int(input())
ans = 0
for i in range(1,n+1) :
  ans += i
print(ans)
# Judge status: Wrong Answer
A, B, K = map(int, input().split())
if 0<=K<=A:print(A-K,B)
elif A<K<=B:print(0,B-K+A)
elif B<K:print(0,0)
# Judge status: Accepted
# A - キャンディーと2人の子供
# https://atcoder.jp/contests/abc047/tasks/abc047_a

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

result = 'No'

if a + b == c or a + c == b or a == b + c:
    result = 'Yes'

print(result)
# Judge status: Accepted
N = int(input())

if N % 2 == 0:
    tmp = 10
    ans = 0
    while tmp <= N:
        ans += N // tmp
        tmp = 5 * tmp

    print(ans)
 
else:
    print(0)
# Judge status: Wrong Answer
import numpy as np

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

LR = np.ones([M,2])

for i in range(M):
    LR[i][0],LR[i][1] = [int(i) for i in input().split()]
    
max_L = max(LR[:,0])
min_R = min(LR[:,1])
if max_L < min_R:
    ans = int(min_R - max_L)
else:
    ans =0
    
print(ans)
# Judge status: Accepted
S = list(input())
if len(set(S)) == len(S):
    print("yes")
else:
    print('no')
# Judge status: Accepted
a = int(input())
s = list(map(int, input().split()))
min_val = 3 * 10 ** 5
count = 0
for i in s:
  if min_val >= i:
    count += 1
  min_val = min(min_val, i)
print(count)
# Judge status: Accepted
N,K = map(int,input().split())
R,S,P = map(int,input().split())
T = list(input())

graph = {"r":P,"s":R,"p":S,"*":0}

for i,t in enumerate(T):
  if len(T)-i-K > 0:
    if t == T[i+K]:
      T[i+K] = "*"

ans = 0
for t in T:
  ans += graph[t]
print(ans)
# Judge status: Accepted
n,m=map(int,input().split())
print(min(n,m//2)+(m//2-min(n,m//2))//2)
# Judge status: Accepted
import math

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

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

cnt = 0
for i in range(n):
    if math.sqrt(points[i][0] ** 2 + points[i][1] ** 2) <= d:
        cnt += 1

print(cnt)
# Judge status: Accepted
from collections import Counter
import sys
n = int(input())
a = list(map(int, input().split()))
count_a = list(Counter(a).items())
count_a = sorted(count_a, reverse=True)
result = 1
c = 0
for x, y in count_a:
    if y>=2:
        result *= x
        c += 1
        if y>=4 and c == 1:
            result *= x
            c += 1
        if c == 2:
            print(result)
            sys.exit()
print(0)
# Judge status: Accepted
A, B = map(int, input().split())
def function(A, B):
    return (B-1+A-2)//(A-1)
  
print(function(A,B))
# Judge status: Wrong Answer
N, A, B, C, D = map(int, input().split())
S = input()
print('No' if '##' in S or C == D or C > D and '...' not in S[B-2:] else 'Yes')
# Judge status: Accepted
S=input()
T=input()
n=len(T)
l=len(S)-n
p=0
for i in range(l+1):
    j=0
    m=S[i:i+n]
    
    for k in range(n):
        if(m[k]==T[k]):
            j+=1

    if(p<j):
        p=j
print(n-p)
# Judge status: Wrong Answer
args = input().split()
args2 = input().split()
args2.sort()
N = int(args[0])
K = int(args[1])
S = 0

for i in range(N-K):
	S += int(args2[i])

print(S)
# Judge status: Accepted
a, b, c = list(map(int, input().split()))
m = max(a, b, c)
if (3*m - (a+b+c)) % 2 == 1:
    m += 1
print((3*m-(a+b+c))//2)
# Judge status: Wrong Answer
import sys
input = sys.stdin.readline
li = [int(i) for i in input().split()]
li.sort()
a = "No"
if li[0] == 5 and li[1] == 5 and li[2] == 7 :
    a = "Yes"
print(a)
# Judge status: Accepted
s = input();    l = len(s)
if l%2==0:
    a = 'hi'*(l//2)
    if a== s:    print('Yes')
    else:    print('No')
else:    print('No')
# Judge status: Accepted
# ABC111

N = int(input())

zorome_contest = [111*i for i in range(1, 10)]
diff_min = 10**10
ans = 0

for contest in zorome_contest:
    if contest - N >= 0 and contest - N < diff_min:
        diff_min = contest - N
        ans = contest
print(ans)
# Judge status: Accepted
n=int(input())
a=[*map(int,input().split())]
l=[*map(abs,a)]
print(sum(l)-sum(i<0 for i in a)%2*min(l)*2)
# Judge status: Wrong Answer
a,b,c = list(str(input()) for _ in range(3))
s = a.count("a")
t = b.count("b")
u = c.count("c")
z = max(s,t,u)
print("A" if s==z else "B" if t==z else "C")
# Judge status: Wrong Answer
def func(a, b, c):
  if (a <= c <= b):
    return "Yes"
  else:
    return "No"
# Judge status: Accepted
x = int(input())
n = 0
if x % 11 > 6:
    n += 2
elif x % 11 > 0:
    n += 1
print(x//11*2+n)
# Judge status: Accepted
s = input()
t = input()

init_s = s

found = False
while True:
    s = s[-1] + s[:-1]
    if s == t:
        found = True
        break
    if s == init_s:
        break

print('Yes' if found else 'No')
# Judge status: Accepted
n,k = map(int,input().split())
hl = []
for _ in range(n):
    hl.append(int(input()))
hl.sort()

ans = 10**9
for i in range(n-k+1):
    diff = hl[i+k-1] - hl[i]
    ans = min(ans,diff)
print(ans)
# Judge status: Accepted
n, k = map(int, input().split())
p = list(map(int, input().split()))

pd = sorted(p)
total = 0

for i in range(k):
    total += pd[i]

print(total)
# Judge status: Accepted
n, a, b = map(int, input().split())
mod = 10**9 + 7


def nCr(n, r, mod):
    r = min(r, n-r)
    x = y = 1
    for i in range(r):
        x = (x * (n - i)) % mod
        y = (y * (i + 1)) % mod

    return (x * pow(y, mod - 2, mod)) % mod


ans = pow(2, n, mod) - nCr(n, a, mod) - nCr(n, b, mod) - 1
ans += mod if ans < 0 else 0
ans += mod if ans < 0 else 0
print(ans)
# Judge status: Accepted
s = input()
for i in range(len(s)):
    for j in range(i, len(s)+1):
        if s[:i] + s[j:] == "keyence":
            print("YES")
            exit()
print("NO")
# Judge status: Accepted
N=int(input())
c=[[0 for i in range(10)] for j in range(10)]

for n in range(1,N+1):
  i=int(str(n)[0])
  j=int(str(n)[-1])
  c[i][j]+=1

ans=0
for i in range(10):
  for j in range(10):
    ans+=c[i][j]*c[j][i]
print(ans)
# Judge status: Wrong Answer
n,x,t=map(int,input().split())
print(t*(n+(x-1)//t))
# Judge status: Accepted
import math

X = int(input())

while 1:
    for i in range(2,math.floor(math.sqrt(X))):
        if X%i == 0:
            break
    else:
        print(X)
        break
    X += 1
# Judge status: Accepted
n = int(input())
a = list(map(int,input().split()))
dp = [[0]*2 for i in range(n+1)]
dp[0][1] = -float('inf')
for i in range(n):
    dp[i+1][0] = max(dp[i][0]+a[i],dp[i][1]-a[i])
    dp[i+1][1] = max(dp[i][0]-a[i],dp[i][1]+a[i])
print(dp[n][0])
# Judge status: Accepted
n = int(input())

if str(n)[0] == "7" or str(n)[1] == "7" or str(n)[2] == "7":
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
n,m=map(int,input().split())
x=[[] for _ in range(n+1)]
ans=[-1]*m
for i in range(m):
    p,y=map(int,input().split())
    x[p].append([y,i])

for p in range(1,n+1):
    tmp=sorted(x[p])
    print(p,tmp)
    for j in range(len(tmp)):
        ans[tmp[j][1]]=str(p).zfill(6)+str(j+1).zfill(6)

for i in range(m):
    print(ans[i])
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))

ans = 0
for i, a in enumerate(A):
    if i%2 == 0 and a%2 == 1:
        ans += 1
print(ans)
# Judge status: Wrong Answer
s, w = map(int, input().split())
print(w>=s)
# Judge status: Accepted
# https://atcoder.jp/contests/abc094/tasks/arc095_a
from copy import deepcopy
n = int(input())
nums = [int(i) for i in input().split()]
c = deepcopy(nums)
c.sort()
left = c[n // 2 - 1]
right = c[n // 2]

for num in nums:
    if num <= left:
        print(right)
    else:
        print(left)
# Judge status: Accepted
x = int(input())

if x % 11 == 0:
    print((x // 11) * 2)
elif x % 11 <= 6:
    print((x // 11) * 2 + 1)
else:
    print((x // 11) * 2 + 2)
# Judge status: Accepted
s = str(input())
sl = list(s)
ans = 0
del sl[-1]
for i in range(1,len(sl)):
  if(len(sl)%2==0):
    if(sl[:len(sl)//2]==sl[len(sl)//2:]):
      ans = len(sl)
      break
  del sl[-1] 
print(ans)
# Judge status: Accepted
n,m,k = map(int, input().split())
for i in range(n+1):
	for j in range(m+1):
		if i*m-i*j+j*n-i*j==k:
			print('Yes')
			exit()
print('No')
# Judge status: Accepted
import sys
input = sys.stdin.readline

INF = float("inf")


def main():
    n, k = map(int, input().split())
    h = [int(input()) for _ in range(n)]
    h.sort()
    ans = INF
    for i in range(n - k + 1):
        ans = min(ans, h[i+k-1] - h[i])
    print(ans)

if __name__ == '__main__':
    main()
# Judge status: Accepted
n, m = map(int, input().split())
a = list(int(input()) for _ in range(m))

MOD = 10**9 + 7
is_broken = [0] * (n+1)
dp = [0] * (n+1)
dp[0] = 1

for x in a:
    is_broken[x] = 1

for i in range(n):
    for j in range(i+1, min(n, i+2) + 1):
        if not is_broken[j]:
            dp[j] += dp[i]
            dp[j] %= MOD

print(dp[n])
# Judge status: Accepted
x,y,z = map(int, input().split())
print("{} {} {}".format(z,x,y))
# Judge status: Accepted
N = int(input())

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

i = 0
res = 0
while  i < N:
    while i+1 < N and A[i] == A[i+1]: i += 1

    if i+1 < N and A[i] <= A[i+1]:
        while i+1 < N and A[i] <= A[i+1]: i += 1
    elif i+1 < N and A[i] >= A[i+1]:
        while i+1 < N and A[i] >= A[i+1]: i += 1
    res += 1
    i += 1
print(res)
# Judge status: Accepted
n,k,s=map(int,input().split())
ans=[0]*n
if s!=10**9:
    for i in range(k):
        ans[i]=s
    for i in range(k,n):
        ans[i]=10**9
else:
    for i in range(k):
        ans[i]=s
    for i in range(k,n):
        ans[i]=1
print(*ans)
# Judge status: Accepted
n = int(input())


def f(s, max_i):
    if len(s) >= n:
        print(s)
    else:
        for i in range(max_i+2):
            f(s + chr(ord('a') + i), max(max_i, i))


f('a', 0)
# Judge status: Accepted
N,M=map(int,input().split())
A=[0]*N
B=[0]*M
for i in range(N):
  A[i]=str(input())
for i in range(M):
  B[i]=str(input())
k=N//M + N%M

def macthing(y,x):
  flag=0
  for p in range(M):
    if A[y+p][x:x+M]!=B[p]:
      flag=1
      break
  if flag==0:
    return True
  else:
    return False

for i in range(k):
  for j in range(k):
    if macthing(i,j):
      print('Yes')
      exit()
print('No')
# Judge status: Wrong Answer
s,t = input().split()
a,b = map(int,input().split())
u = input()
print(a,b-1 if u == t else a-1,b)
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
count = 0
for i in range(n):
    count ^= a[i]


for i in range(n):
    print(count ^ a[i], end=" ")
# Judge status: Wrong Answer
X, Y = map(int, input().split())
l = 10**18
while X <= l:
    if X % Y == 0:
        print(X)
    X += X
else:
    print(-1)
# Judge status: Accepted
S = list(input())

pair = 0
stack = [-1]
for s in S:
    tmp = int(s)
    if 1 - tmp == stack[-1]:
        pair += 1
        stack.pop()
    else:
        stack.append(tmp)

ans = 2 * pair
print (ans)
# Judge status: Accepted
import sys
input = lambda: sys.stdin.readline().rstrip()

S = input()

print(S[:3])
# Judge status: Accepted
import bisect
N,M = map(int, input().split())
q = [[int(j) for j in input().split()] for i in range(M)]
li = [[] for k in range(N+1)]

for i,j in sorted(q):
    li[i].append(j)

for p,y in q:
    z = bisect.bisect(li[p],y)
    print("{:0=6}".format(p) + "{:0=6}".format(z))
# Judge status: Wrong Answer
S=input()
count={'a':0,'b':0,'c':0,'d':0,'e':0,'f':0,'g':0,'h':0,'i':0,'j':0,'k':0,'l':0,'m':0,'n':0,'o':0,'p':0,'q':0,'r':0,'s':0,'t':0,'u':0,'v':0,'w':0,'x':0,'y':0,'z':0}
for i in range(len(S)):
    count[S[i]]+=1

ans=[]
for key, value in count.items():
    if value==0:
        ans.append(key)

if len(ans)==0:
    print('None')
else:
    print(ans[0])
# Judge status: Wrong Answer
N=int(input())

print((1+N//1000)*1000-N)
# Judge status: Wrong Answer
C = [input() for _ in range(2)]
tmp = C[0] + C[1]
if tmp == tmp[::-1]:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
consonant = ['a', 'i', 'u', 'e', 'o']
c = input()
if c in consonant:
  print('vowel')
else:
  print('consonant')
# Judge status: Wrong Answer
n = int(input())
p = list(map(int, input().split()))
ans = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        for k in range(j+1, n):
            if p[i]<p[j]<p[k] or p[k]<p[j]<p[i]:
                ans += 1
print(ans)
# Judge status: Accepted
a = input()
print(chr(ord(a)+1))
# Judge status: Wrong Answer
n = int(input())
a = list(map(int, input().split()))
q = int(input())
d = {}
total = 0
for i in a:
  total += i
  d[i] = d.get(i, 0) + 1

#クエリによって、それぞれの数値の個数を変更し、
#対象となる個数×差分で合計を修正し出力する

for i in range(q):
  b, c = map(int, input().split())
  b_cnt = d.get(b, 0)
  c_cnt = d.get(c, 0)
  total = total + b_cnt * (c - b)
  print(total)
  d[c] = d.get(c, 0) + d.get(b, 0)
# Judge status: Accepted
def make_divisors(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)
    divisors.sort()
    return divisors

n,m = map(int,input().split())
ans = 1
for i in make_divisors(m):
    if m // i >= n:
        ans = i
    else:
        break
print(ans)
# Judge status: Accepted
n, k = map(int, input().split())
len_k = len(bin(k))
prob = 0.
for i in range(1, n+1):
  tmp = 1.
  while i < k:
    tmp /= 2.
    i *= 2
  prob += tmp
print(prob / n)
# Judge status: Wrong Answer
import sys
input = lambda: sys.stdin.readline().rstrip()

n = int(input())
a = []
b = []
for _ in range(n):
    a_, b_ = map(int, input().split())
    a.append(a_)
    b.append(b_)
a.sort()
b.sort()
if n % 2 == 1:
    a_m = a[n // 2]
    b_m = b[n // 2]
    print(b_m - a_m + 1)
else:
    a_m = (a[n // 2 - 1] + a[n // 2]) / 2
    b_m = (b[n // 2 - 1] + b[n // 2]) / 2
    print(int(b_m - a_m) * 2 + 1)
# Judge status: Wrong Answer
n = int(input())
a = {}
for i in range(n):
    s = int(input())
    if s not in a.keys():
        a[s] = 1
    else:
        a[s] = 0
print(sum(a.values()))
# Judge status: Accepted
import math

N = int(input())
Z = [int(input()) for _ in range(5)]

MIN = min(Z)
ans = math.ceil(N/MIN) + 4
print(ans)
# Judge status: Accepted
a, b = input().split()
c = int(a+b)
for i in range(1000):
  if i**2 == c:
    print("Yes")
    break
else:
  print("No")
# Judge status: Wrong Answer
list_n=[0]+list(map(int,input()))
l = len(list_n)

pay=0
back=0
for i in range(l-1,-1,-1):
    #l-1から0まで
    now = list_n[i]
    if now <=5:
        pay+=now
        list_n[i]=0
    elif now==10:
        list_n[i]=0
        list_n[i-1] +=1
    else:
        back+=10-now
        list_n[i]=0
        list_n[i-1] +=1
    print(i,list_n,pay,back)
print(pay+back)
# Judge status: Wrong Answer
X=int(input())
for j in range(X,10**5+1):
    for i in range(X-1,0,-1):
        if j%i==0:
            break
        elif i==1:
            print(j)
            exit()
# Judge status: Wrong Answer
s = int(input())
count_4 = 0
num_list = [0,0]
while True:
  num_list.append(s)
  length_num_list = len(num_list)
  if num_list[length_num_list - 3] == 4 and num_list[length_num_list - 2] == 2 and num_list[length_num_list - 1] == 1:
    break

  if s % 2 == 0:
    s = s // 2
  else:
    s = 3 * s + 1

print(len(num_list) - 1 )
# Judge status: Accepted
import math
n,k=map(int,input().split())
s=0
for i in range(1,n+1):
    if i<k:
        s+=0.5**(-(-math.log(k/i,2)//1))
    else:
        s+=1
print(s/n)
# Judge status: Accepted
l, r, d = map(int, input().split())
print(r//d-(l-1)//d)
# Judge status: Accepted
s=input()

a=["0","1"]

one=0
two=0
for i,tail in enumerate(s):
    if a[i%2]!=tail:
        one+=1
    else:
        two+=1
print(min(one,two))
# Judge status: Accepted
import collections
n, m = map(int, input().split())
a_list = sum([list(map(int, input().split()))[1:] for _ in range(n)], [])
col = collections.Counter(a_list)
print(len([k for k, v in col.items() if v == n]))
# Judge status: Wrong Answer
S,D= map(str,input().split())
print(S+D)
# Judge status: Accepted
#list(map(int,input().split()))
a,b,c,d,e=list(map(int,input().split()))
print(c*60+d-a*60-b-e)
# Judge status: Wrong Answer
K, N = map(int, input().split())
A = list(map(int, input().split()))

dis = []

for i in range(len(A)):
    if i+1 == len(A):
        break
    elif abs(A[i-1] - A[i]) > abs(A[i+1] - A[i]):
        dis.append(abs(A[i+1] - A[i]))
    elif abs(A[i-1] - A[i]) == abs(A[i+1] - A[i]):
        dis.append(abs(A[i-1] - A[i]))
    else:
        dis.append(abs(A[i-1] - A[i]))

        
print(sum(dis))
# Judge status: Accepted
N = int(input())
A = [int(i) for i in input().split()]

max = 0
sum = 0
for a in A:
  if a < max:
    sum += max - a
  if a > max:
    max = a

print(sum)
# Judge status: Accepted
A, B, T = map(int, input().split())

ans = 0
time = 1
while time * A < T + 0.5:
  ans += B
  time += 1

print(ans)
# Judge status: Accepted
N, T = map(int,input().split())
list_c = []
list_t = []
for i in range(N) :
    c, t = map(int, input().split())
    list_c.append(c)
    list_t.append(t)

list_ans = []
for i in range(N) :
    if list_t[i] <= T :
        list_ans.append(list_c[i])

if list_ans :
    print(min(list_ans))
else :
    print("TLE")
# Judge status: Accepted
n = int(raw_input())
his = map(int, raw_input().split(' '))
j = 0
pv = float('inf')
count = 0
m = 0
while(j < len(his)):
	if pv >= his[j]: count +=1
	else: count = 1
	m = max(count-1,m)
	pv = his[j]
	j +=1
print m
# Judge status: Accepted
n = int(input())
ls = list(map(int,input().split()))
sm = 0
for i in range(1,n):
    if ls[i] < ls[i-1]:
        sm += ls[i-1]-ls[i]
        ls[i] = ls[i-1]
print(sm)
# Judge status: Wrong Answer
k = int(input())
s = input()
lists = list(s)
news = list()
if len(lists) <= k:
    print(s)
else:
    for i in range(k):
        news.append(lists[i])
result = "".join(news)
print(result + "...")
# Judge status: Accepted
s = input()

cnt = 0
for i in range( len( s ) // 2 ):
  if s[ i ] != s[ len(s)-1 - i ]:
    cnt += 1
print( cnt )
# Judge status: Accepted
x = int(input())
c = 1
r = x//11
if x%11==0:
    print(r*2)
elif x%11 <= 6:
    print(r*2+1)
else:
    print(r*2+2)
# Judge status: Accepted
import math

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

if B == 1:
    print(0)
else:
    ans = 0
    for i in range(B):
        ans += A
        if ans >= B:
            print(i+1)
            break
        ans -= 1
# Judge status: Wrong Answer
num = 0
ans = 0
n = int(input())
for i in range(n):
	for j in range(n):
		for k in range(n):
			if(((i * j) + k) == n):
				num += 1
print(num)
# Judge status: Accepted
X, Y = map(int, input().split())
import math
mod = 10**9+7

def comb(n,r,mod):
  ans = 1
  for i in range(r):
    ans *= n-i
    ans %= mod
  for i in range(1,r+1):
    ans *= pow(i,mod-2,mod)
    ans %= mod
  return ans
  
if (2*X-Y)%3!=0 or 2*X-Y<0 or (-1)*X+2*Y<0:
  print(0)
else:
  p = (2*X-Y)//3
  q = ((-1)*X+2*Y)//3
  print(comb(p+q,p,mod))
# Judge status: Accepted
S = input()

# count=1 にする
print(S.replace('7', '8', 1))
# Judge status: Accepted
_, A, B, C, D = map(lambda n: int(n) - 1, input().split())
S = input()
if S.count("##", A, D):
    print("No")
elif C < D:
    print("Yes")
elif S.count("...", B - 1, D + 2):
    print("Yes")
else:
    print("No")
# Judge status: Accepted
N, K = map(int, input().split())
R, S, P = map(int, input().split())
d = [[] for _ in range(K)]

for i, s in enumerate(input()):
    d[i%K].append(s)

ans = 0
score = {}
score["s"] = R
score["p"] = S
score["r"] = P

for l in d:
    prev_hand = "a"
    for s in l:
        if s!=prev_hand:
            ans += score[s]
            prev_hand = s
        else:
            prev_hand = "a"
print(ans)
# Judge status: Wrong Answer
import sys
def S(): return sys.stdin.readline().rstrip()
N = S()
if int(N)<=8:
    print(N)
elif all([n=='9' for n in N]):
    print(9*len(N))
else:
    print(int(N[0])-1+9*(len(N)-1))
# Judge status: Accepted
n=int(input())
a=list(map(int, input().split()))
m=max(a)
table=[0]*(m+2)
cnt=0

for num in a:
    if num==0:
        cnt+=1
        table[0]+=1
        table[1]+=1
    else:
        table[num-1]+=1
        table[num]+=1
        table[num+1]+=1

tmp=max(table)
ans=max(tmp, cnt)
print(ans)
# Judge status: Accepted
a, v = [int(i) for i in input().split()]
b, w = [int(i) for i in input().split()]
T = int(input())
if w >= v:
    print("NO")
elif abs(a-b) <= T*(v-w):
    print("YES")
else:
    print("NO")
# Judge status: Wrong Answer
# coding: utf-8
import sys
import numpy as np
from fractions import gcd

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, X0 = lr()
X = np.array(lr())
Xdiff = (X-X0).tolist()
g = Xdiff[0]
for i in range(1, N):
    g = gcd(g, Xdiff[1])

answer = g
print(answer)
# Judge status: Wrong Answer
import sys
input = sys.stdin.buffer.readline
S = input()
ans = 0
for s in S:
    i = int(s)
    ans += min(i, 10-i)
if S[0] == '9' or int(S[1]) >= 6:
    ans += 1
print(ans)
# Judge status: Accepted
import sys
import math
input = lambda: sys.stdin.readline().rstrip()

INF = 100100100100100


def solve():
    N = int(input())
    n_m = int(math.sqrt(N) + 1)

    r = INF
    for i in range(1, n_m + 1):
        if N % i == 0:
            r = min(r, i + N // i)

    print(r - 2)


if __name__ == '__main__':
    solve()
# Judge status: Accepted
n=int(input())

lr=[]

for _ in range(n):
    x,l=map(int,input().split())
    lr.append([x+l,x-l])

lr.sort()

cnt=0
point=lr[0][1]-1

for item in lr:
    if item[1]>=point:
        cnt+=1
        point=item[0]

print(cnt)
# Judge status: Wrong Answer
N = input()
prev = -1
count = 1

for n in N:
    if prev == n:
        count += 1
    else:
        prev = n

if count >= 3:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
N=int(input())
A=map(int,input().split())

T=[0,0,0]
for a in A:
    if a%2:
        T[0]+=1
    elif a%4:
        T[1]+=1
    else:
        T[2]+=1

if T[1]==0:
    if T[0]<=2*T[2]:
        print("Yes")
    else:
        print("No")
else:
    if T[0]<=2*T[2]-1:
        print("Yes")
    else:
        print("No")
# Judge status: Accepted
S=input()
if int(S[5:7])<5:
    print('Heisei')
else:
    print('TBD')
# Judge status: Wrong Answer
list=[ x for x in input() ]
a=list[0]
b=list[1]
c=list[2]
if a!=b and a!=c and b!=c:
	print("3")
elif a==b and a!=c and b==c:
	print("2")
elif a!=b and a==c and b!=c:
	print("2")
elif a==b and a==c and b==c:
	print("1")
elif  a!=b and a!=c and b==c:
	print("2")
elif a==b and a==c and b!=c:
	print("2")
# Judge status: Accepted
N,K=map(int,input().split())
if N%K==0:
    print(0)
else:
    print(1)
# Judge status: Accepted
N,M=map(int,input().split())
P=[input().split() for i in range(M)]

WA=[]
AC=[]
for i in range(N):
    WA.append(0)
    AC.append(0)

for i in range(M):
    if P[i][1]=="WA" and  AC[int(P[i][0])-1]==0:
        WA[int(P[i][0])-1]+=1
    elif P[i][1]=="AC":
        AC[int(P[i][0])-1]=1
for i in range(N):
    if AC[i]==0:
        WA[i]=0

print(sum(AC),sum(WA))
# Judge status: Accepted
from fractions import gcd

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

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

c = set(prime_factorize(g))
print(len(c)+1)
# Judge status: Accepted
X, Y = map(int, input().split())

if X % Y == 0:
  print(-1)
else:
  print(X)
# Judge status: Wrong Answer
s = input()
n = len( s )

def dfs( i : int, total : int, formular : str  ):
    if i == n - 1:
        if total == 7:
            print( formular+"=7" )
            exit
    else:
        next = s[ i + 1]
        dfs( i + 1, total + int( next ), formular + "+" + next )
        dfs( i + 1, total -  int( next ), formular + "-" + next )

dfs( 0, int( s[0]),  s[0] )
# Judge status: Wrong Answer
f=lambda:[*map(int,input().split())]
n,h=f()
A,B=[],[]
for _ in range(n):
  a,b=f()
  A+=[a]
  B+=[b]
m=max(A)
B.sort()
c=0
while h and B and B[-1]>m:
  h-=B.pop()
  c+=1
print(c+max(0--h//m,0))