peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Wrong Answer
A, B = map(int, input().split())


def prime_numbers(N):
    n = N
    res = []
    for i in range(2, n):
        if i * i >= n: break
        if N % i != 0: continue
        while N % i == 0:
            N //= i
        res.append(i)
    res.append(N)
    return res


a = prime_numbers(A)
b = prime_numbers(B)
ans = min(len(a), len(b))
print(ans)
# Judge status: Accepted
number=[int(i) for i in input().split()]
number.sort()
a,b,c=number

#aを何回操作すればｃかc-1にできるか
anum=(c-a)//2
amari=(c-a)%2

bnum=(c-b)//2
bamari=(c-b)%2
c=amari+bamari

if c==0:
    plus=0
elif c==1:
    plus=2
else:
    plus=1
print(anum+bnum+plus)
# Judge status: Wrong Answer
L,R,d = map(int,input().split())
c =0
for i in (L,R+1):
  if i % d ==0:
    c+=1
print(c)
# Judge status: Accepted
n=int(input())
p=list(map(int,input().split()))
ans=0
for i in range(1,n-1):
    if p[i-1]<p[i] and p[i]<p[i+1]:
        ans+=1
    if p[i-1]>p[i] and p[i]>p[i+1]:
        ans+=1  
        
print(ans)
# Judge status: Wrong Answer
from collections import Counter

N, K = list(map(int,input().split()))
H = []
for i in range(N):
    H.append(int(input()))
H = sorted(H,reverse = False)
C = Counter(H)
CH = list(C.values()) 

cnt = 0
for i in range(len(CH)):
    if CH[i] >= K:
        cnt += 1
        break
if cnt != 0:
    print('0')
else:
    print(H[K-1] - H[0])
# Judge status: Accepted
from collections import Counter
inputs = open(0).readlines()

n = int(inputs[0])
*D, = map(int, inputs[1].split())
mod = 998244353

nbs = [0] * (max(D)+1)
for k, v in Counter(D).items():
    nbs[k] = v

if D[0] != 0 or nbs[0] != 1:
    print(0)
else:
    ans = 1
    for n0, n1 in zip(nbs, nbs[1:]):
        ans = ans * pow(n0, n1, mod) % mod
    print(ans)
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
count=0
ans=[]
for i in range(n):
  ans.append(abs(a[i]))
  if a[i]<0:
    count+=1

if count%2==0:
  print(sum(ans))
else:
  print(sum(ans)-2*min(ans))
# Judge status: Accepted
import sys
input = sys.stdin.readline

X, Y = map(int, input().split())

for i in range(101):
    n = i
    k = X - i
    if 0 > k or k > 100:
        continue
    if Y == n * 2 + k * 4:
        print('Yes')
        exit()
print('No')
# Judge status: Wrong Answer
N = int(input())
S = input()

l = 0
r = len(S) - 1

W = 'W'
R = 'R'

cnt = 0
while l < r:
    if S[l] == R:
        l += 1
        continue
    else:
        while l < r:
            if S[r] == W:
                r -= 1
                continue
            else:
                cnt += 1
                l += 1
                r -= 1

print(cnt)
# Judge status: Accepted
a = int(input())
b = int(input())
c = int(input())
x = int(input())
cnt = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if i * 500 + j * 100 + 50 * k == x:
                cnt += 1
print(cnt)
# Judge status: Accepted
n = int(input())
num_list = list(map(int, input().split()))
a = int(num_list[0])
p = 0

for i in range(n):
  if num_list[i] < a:
    p = p + (a - num_list[i])
  elif num_list[i] > a:
    a = num_list[i]
  
print(p)
# Judge status: Accepted
_,A,B = map(int,input().split())
s = list(input())

ab = 0
b = 0

for i in s:
    res = "No"
    
    if i == "a":
        if ab < A+B:
            ab += 1
            res = "Yes"
            
    if i == "b":
        if ab < A+B and b < B:
            ab += 1
            b += 1
            res = "Yes"
            
    print(res)
# Judge status: Accepted
a, b = map(int, input().split())
res = 0
out = 1
while out < b:
  out -= 1
  res += 1
  out += a
print(res)
# Judge status: Wrong Answer
MAX = 1000000000000000000
n = input()
A = list(map(int, input().split()))
total = 1
for a in A:
  total *= a
  if total > MAX:
    total = -1
    break
print(total)
# Judge status: Accepted
ABC = list(map(int, input().split()))
K = int(input())

print(max(ABC)*(2**K - 1) + sum(ABC))
# Judge status: Accepted
a,b,c = map(int,input().split())

if a+b+c <= 21 :
  print('win')
else :
  print('bust')
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
jud = [0] * n
ans = []
for i in range(n//2, n):
    if a[i] == 1:
        jud[i] = 1
        ans.append(i+1)
for i in range(n//2-1, -1, -1):
    cou = 0
    for j in range(2, n//(i+1)+1):
        cou ^= jud[(i+1)*j-1]
    if a[i] != cou:
        jud[i] = 1
        ans.append(i+1)
ans.sort()
print(jud.count(1))
print(*ans)
# Judge status: Accepted
s = input()
t = ''
result = 'NO'

scripts = ['dream', 'dreamer', 'erase', 'eraser']

for i in range(len(scripts)):
    script = scripts[i]
    script = script[::-1]
    scripts[i] = script

s_rev = s[::-1]

while len(s) > 0:
    for script in scripts:
        if s_rev[:len(script)] == script:
            s_rev = s_rev[len(script):]
            break
    else:
        break

if s_rev == '':
    result = 'YES'
print(result)
# Judge status: Accepted
N = int(input())
stone = input()

if(stone == "R" * N):
    print(0)
elif(stone == "W" * N):
    print(0)
else:
    b = stone.count("R")
    c = stone[0:b].count("R")
    print(b-c)
# Judge status: Wrong Answer
S = input()
for i in range(2, len(S), 2):
    if S[:(len(S)-i)//2] == S[(len(S)-i)//2:len(S)-i]:
        print(len(S)-i)
# Judge status: Accepted
n=int(input())
x=n*800
y=(n//15)*200
print(x-y)
# Judge status: Accepted
H1,M1,H2,M2,K=map(int,input().split())
d=H1*60
g=H2*60
f=(g+M2)-(d+M1)-K
print(f)
# Judge status: Accepted
import sys
input = sys.stdin.readline

n = int(input())
a = [int(x) for x in input().split()]

from collections import Counter
c = Counter(a)

ans = 0

possible_e = []

for i in c.keys():
    if c[i] >= 4:
        ans = max(ans, i ** 2)
    if c[i] >= 2:
        possible_e.append(i)

possible_e.sort()

if len(possible_e) > 1:
    ans = max(ans, possible_e[-1] * possible_e[-2])

print(ans)
# Judge status: Accepted
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
#mod = 998244353
INF = 10**18
eps = 10**-7

N = int(readline())
A = list(map(int,readline().split()))
B = list(map(int,readline().split()))
print('Yes' if sum(B)-sum(A) >= sum(max(0,(b-a+1)//2) for a,b in zip(A,B)) else 'No')
# Judge status: Wrong Answer
a = list(map(int, input().split()))
if a[0]==1:
  n=0
else:
  n=a[0]*(a[0]-1)/2

if a[1]==1:
  m=0
else:
  m=a[1]*(a[1]-1)/2
 
print(n+m)
# Judge status: Wrong Answer
a,b=input().split()
a=int(a)
b=int(b)
print(a+b/2)
# Judge status: Accepted
N, A, B = map(int, input().split())

ans = 0

for num in range(N + 1):
    num1 = list(str(num))
    num2 = map(int, num1)
    sums = sum(num2)

    if sums >= A and sums <= B:
        ans += num
    
print(ans)
# Judge status: Accepted
from math import log2

# print(log2(4))
def pow_k(x, n):
    """
    O(log n)
    """
    if n == 0:
        return 1

    K = 1
    while n > 1:
        if n % 2 != 0:
            K *= x
        x *= x
        n //= 2

    return K * x


a = int(input())
if a ==1:
    print(1)
    exit()
a = int(log2(a))
# print(a)

res = 4*(pow_k(2,a-1))-1
print(res)
# Judge status: Wrong Answer
tenki = ["Sunny", "Cloudy", "Rainy"]
s = input()
ans = "Cloudy"
for i in range(2):
    if s == tenki[i]:
        ans = tenki[i + 1]
    
print(ans)
# Judge status: Accepted
A,B=map(int, input().split())


def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(i)
    i += 1
  if n > 1:
    table.append(int(n))
  return table

a=set(prime_decomposition(A))
b=set(prime_decomposition(B))

print(len(a&b)+1)
# Judge status: Accepted
A,B,H,M = map(int,input().split())
import math
# 角度を求める
#長針
m = 6*M
#短針
h = (H * 30) + ((30/60)*M)
#最終角度
kakudo = min(360 - abs(m - h), abs(h - m))
kakudo_a = math.radians(kakudo)
cos_x = math.cos(kakudo_a)
 
c = A**2 + B**2 - 2*A*B*cos_x
print(math.sqrt(c))
# Judge status: Wrong Answer
n=int(input())
c=[list(map(int,input().split())) for _ in range(n)]
a=[i[0] for i in c]
b=[i[1] for i in c]
a.sort()
b.sort()
print(b[n//2]-a[n//2-1]-b[n//2-1]+a[n//2]+1)
# Judge status: Accepted
N, D = list(map(int, input().split()))
import math
ans = math.ceil(N / (D * 2 + 1))
print(ans)
# Judge status: Wrong Answer
import math
N=int(input())
ans,n = 0,N
for i in range(2,int(math.sqrt(N))+1):
  ii=i
  if n%ii==0:
    ans+=1
    n=n//ii
    ii*=i
if n==N:
  ans=1
if N==1:
  ans=0
print(ans)
# Judge status: Accepted
N=int(input())
print(800*N-(N//15)*200)
# Judge status: Accepted
N=int(input())
A=list(map(int,input().split()))

for a in A:
    if a%2==0:
        if a%3==0 or a%5==0:
            continue
        else:
            print("DENIED")
            exit()
print("APPROVED")
# Judge status: Accepted
from collections import Counter
n=int(input())
a=list(map(int,input().split()))

c = Counter(a)
m1=0
m2=0
m3=0
for k,v in c.items():
  if v>1:
    if k>=m1:
      m2=m1
      m1=k
    elif m2<k:
      m2=k
  if v>3 and k>m3:
    m3=k
    
print(max(m1*m2,m3**2))
# Judge status: Accepted
S = input()
ans = 0
tmpl = 0
tmpr = 0
for i in range(len(S) - 1):
  if S[i] == '<':
    tmpl += 1
  else:
    tmpr += 1
    if S[i + 1] == '<':
      x = max(tmpl, tmpr)
      y = min(tmpl, tmpr)
      ans += (1 + x) * x // 2 + y * (y - 1) // 2
      tmpl = 0
      tmpr = 0

if S[-1] == '<':
  tmpl += 1
else:
  tmpr += 1
x = max(tmpl, tmpr)
y = min(tmpl, tmpr)
ans += (1 + x) * x // 2 + y * (y - 1) // 2
print(ans)
# Judge status: Accepted
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
Ds = list(mapint())
if Ds[0]!=0:
    print(0)
    exit(0)
Ds.sort()
mod = 998244353

from collections import Counter
c = Counter(Ds)
dmax = Ds[-1]


if c[0]>1:
    print(0)
else:
    ans = 1
    for i in range(1, dmax+1):
        ans *= pow(c[i-1], c[i], mod)
        ans %= mod
    print(ans)
# Judge status: Accepted
[S, W] = list(map(int, input().split()))
if S > W:
  print("safe")
else:
  print("unsafe")
# Judge status: Accepted
x = int(input())
print(sorted([b ** p if b ** p <= x else 1 for b in range(1, 1001) for p in range(2, 11)])[-1])
# Judge status: Accepted
N = int(input())

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

ans = 1
inc = None
for i in range(N-1):
    if inc is None:
        if A[i] != A[i+1]:
            inc = A[i] < A[i+1]
            continue

    if inc:
        if A[i] > A[i+1]:
            ans += 1
            inc = None
    else:
        if A[i] < A[i+1]:
            ans += 1
            inc = None

print(ans)
# Judge status: Wrong Answer
N = int(input())
A = [int(input()) for i in range(N)]

A.sort()

odd = 0
count = 1
a = A[0]
for i in A[1:]:
  if i == a:
    count += 1
  else:
    a = i
    if count % 2 == 1:
      odd += 1
    count = 1
print(odd)
# Judge status: Wrong Answer
import math

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

if x >= a*a*b/2:
    l = 2*(b - (x/a**2))
    theta = math.atan(l/a)
else:
    l = x / (a*b)
    theta = math.atan(b/l)

print(math.degrees(theta))
# Judge status: Accepted
n = int(input())
a = list(map(int,input().split()))

r = 0
index = 0
ans = 0
for i in range(n) :
  r += 1
  for j in range(n) :
    if index >= n :
      break
    if a[index] == r :
      index += 1
      break
    ans += 1
    index += 1
      
if ans == n :
  print(-1)
else :
  print(ans)
# Judge status: Accepted
s = input()

if s == 'SUN':
    print(7)
elif s == 'MON':
    print(6)
elif s == 'TUE':
    print(5)
elif s == 'WED':
    print(4)
elif s == 'THU':
    print(3)
elif s == 'FRI':
    print(2)
else:
    print(1)
# Judge status: Accepted
a,b,c,d = map(int,input().split())
ac = a*c
bc = b*c
ad = a*d
bd = b*d
print(max([ac,bc,ad,bd]))
# Judge status: Wrong Answer
A,B = map(int,input().split())
x = int((100*A)/8)
y = int((100*B)/10)
while (int((x-1)*0.08) == A)&(int((x-1)*0.1) == B):
    x -= 1
while (int((y-1)*0.08) == A)&(int((y-1)*0.1) == B):
    y -= 1

if(int(x*0.08) == A)&(int(x*0.1) == B):
    print(x)
elif(int(y*0.08) == A)&(int(y*0.1) == B):
    print(y)
else:
    print("-1")
# Judge status: Accepted
import math
from itertools import permutations

def f(i, j):
  return ((XY[i][0] - XY[j][0]) ** 2 + (XY[i][1] - XY[j][1]) ** 2) ** .5

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

ptn = permutations(range(n))

diff = 0
for p in ptn:
  diff += sum([f(i, j) for i, j in zip(p, p[1:])])
ans = diff / math.factorial(n)

print(ans)
# Judge status: Wrong Answer
#! /usr/bin/env python3

from fractions import gcd
# from math import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations, combinations_with_replacement

ans = lambda x : x % 998244353

N = int(input())
D = [int(_) for _ in input().split()]

c = Counter(D)

bef = 1
ret = 1 * (not D[0])

for i in range(len(c)):
    if c[i] == 0:
        ret = 0
    ret *= bef ** c[i]
    ret = ans(ret)
    bef = c[i]

print(ret)
# Judge status: Accepted
N, x = map(int, input().split())
A = sorted(map(int, input().split()))

count = 0
for i in range(len(A)):
    if (x >= 0):
        x = x - A[i]
        count += 1
    else:
        break

if (x > 0):
    print(count - 1)
elif(x == 0):
    print(count)
elif(x < 0):
    print(count - 1)
# Judge status: Accepted
a,b,c=map(int,input().split())
if(a==b and b==c):
    print(1)
else:
    if(a==b and b!=c):
        print(2)
    elif(b==c and c!=a):
        print(2)
    elif(c==a and a!=b):
        print(2)
    else:
        print(3)
# Judge status: Accepted
a,b = map(int, input().split())

def gcd(a, b):
  while b:
      a, b = b, a % b
  return a

def factorization(n):
  arr = {1}
  tmp = n
  for i in range(2,int(tmp**0.5)+1,1):
    while tmp % i == 0:
      tmp //= i
      arr.add(i)
  if tmp != 1:
    arr.add(tmp)
  return arr

g = gcd(a,b)
arr = factorization(g)
print(len(arr))
# Judge status: Accepted
k,n = list(map(int,input().split(" ")))
A = list(map(int,input().split(" ")))
max_dist = 0
for i in range(len(A)-1):
  if A[i+1]-A[i] > max_dist:
    max_dist = A[i+1]-A[i] 
if A[0]+k-A[-1] > max_dist:
  max_dist = A[0]+k-A[-1]
print(k-max_dist)
# Judge status: Wrong Answer
n,k = map(int,input().split())
print(n % k) if n > k else print(1)
# Judge status: Accepted
N = int(input())
A = list(map(int,input().split()))

counts = {}
for a in A:
    for i in [a-1, a, a+1]:
        if not i in counts:
            counts[i] = 0
        counts[i] += 1


counts = sorted(counts.items(), key=lambda x:x[1], reverse=True)

print(counts[0][1])
# Judge status: Accepted
import collections
import math
def C(n):
    return n * (n-1) // 2
N = int(input())
A = list(map(int,input().split()))
c = collections.Counter(A)
d = {}
sm = 0
for k,v in c.most_common():
    d[k] = v
    sm += C(v)
for a in A:
    print (sm - C(d[a]) + C(d[a]-1))
# Judge status: Accepted
A,B,C,D = map(int,input().split())

while True:
  C =C-B
  if C <=0:
    print ('Yes')
    break
  A =A-D
  if A <=0:
    print ('No')
    break
# Judge status: Accepted
from math import ceil


def train(i, t):
    if i == n - 1:
        return t
    c, s, f = d[i]
    tt = f * ceil(t / f) if t > s else s
    return train(i + 1, tt + c)


if __name__ == '__main__':
    n = int(input())
    d = [[int(i) for i in input().split()] for _ in range(n - 1)]
    print(*[train(i, 0) for i in range(n)], sep="\n")
# Judge status: Wrong Answer
def isu(x , y , z):

    ans = x // (y + z)

    return ans if (x % (y + z) * (y + z)) + z <= x else ans - 1
def main():
    x , y , z = map(int , input().split())
    print(isu(x , y , z))


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
import random
s = str(input())
t = random.randint(0, len(s)-2)
print(s[t:t+3])
# Judge status: Accepted
import sys
A, B, C = map(int, input().split())
for i in range(1, B):
    if i * A % B == C:
        print('YES')
        sys.exit()
print('NO')
# Judge status: Accepted
import sys
from collections import defaultdict


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

inter = []
goalable = defaultdict(lambda: False)
for i in range(M):
  start, end = map(int, input().split())
  if start == 1:
    inter.append(end)
  else:
    if end == N: 
      goalable[start] = True
      
for i in inter:
  if goalable[i]:
    print("POSSIBLE")
    sys.exit()
    
print("IMPOSSIBLE")
# Judge status: Accepted
l = [2,1]

for i in range(100):
    l.append(l[-1] + l[-2])

print(l[int(input())])
# Judge status: Accepted
h, a =map(int, input().split())
print(h//a + 1 if h % a != 0 else h//a)
# Judge status: Wrong Answer
N, x = map(int, input().split())
A = list(map(int, input().split()))
A.sort()

# print(N, x)
# print(A)

count = 0
for i in range(N):
    if x >= A[i]:
        count += 1
        x -= A[i]
if count > 0 and x > 0:
    count -= 1

print(count)
# Judge status: Wrong Answer
def main():
  #n = int(input())
  #s = input()
  #s = input().split()
  #a,b = list(map(int,input().split()))
  a = [list(map(int,input().split())) for i in range(6)]
  #a = [int(input()) for i in range(6)]
  ans = 0
  
  for i in range(5):
     if a[i] > a[5]:
        print(":(")
        exit()
        
  print("Yay!")
  
if __name__ == '__main__':
  main()
# Judge status: Wrong Answer
h, a = map(int, input().split())
count = 0
while h > 0:
    h -= a
    count += 1
print(count)
# Judge status: Accepted
n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]

s_set = set(s)
t_set = set(t)
ans = 0
for i in s_set:
    p = s.count(i)
    q = t.count(i)
    ans = max(ans,p-q)
print(ans)
# Judge status: Accepted
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

_, _, x, y = rl()
maxx = max(rm())
miny = min(rm())
if maxx < miny and x<miny and maxx<y:
  print('No War')
else:
  print('War')
# Judge status: Wrong Answer
s=input()
ans=''
for i in range(2):
    if s[i]==s[i+1]:
        ans='Bad'
        break
    
    else:
        ans='Good'
print(ans)
# Judge status: Wrong Answer
import math
a, b = map(int, input().split())
print(math.ceil(b-1)/(a-1))
# Judge status: Accepted
import collections
W=collections.Counter(x for x in input())

for i,v in W.items():
  if v%2!=0:
    print('No')
    break
else:
  print('Yes')
# Judge status: Accepted
A,B,C=map(int,input().split())
print("Yes" if A<=C<=B else "No")
# Judge status: Accepted
N,M = map(int,input().split())
X = list(map(int,input().split()))
X.sort()

D = [abs(X[i] - X[i+1]) for i in range(M-1)]
D.sort(reverse=True)

print(sum(D[N-1:]))
# Judge status: Accepted

s=list(input())
t=list(input())
l=len(s)

henkan1 = {chr(ord("a")+i) : set() for i in range(26) }
henkan2 = {chr(ord("a")+i) : set() for i in range(26) }

for i in range(l):
#    if s[i]!=t[i]:
    henkan1[s[i]].add(t[i])
    henkan2[t[i]].add(s[i])
        
if all(len(h) <=1 for h in henkan1.values()) and all(len(h) <=1 for h in henkan2.values()):
    print("Yes")
else:
    print("No")
# Judge status: Accepted
import itertools
n = int(input())
p = tuple(i for i in input().split())
q = tuple(i for i in input().split())
pi = 0
qi = 0

for i,j in enumerate(itertools.permutations(str(i) for i in range(1,n+1))):
    if p == j:
        pi = i
    if q == j:
        qi = i

print(abs(pi-qi))
# Judge status: Wrong Answer
#D
n = int(input())
#約数の数を求める＞＞倍数であり、n以下であるものの総和を求める   
ans = 0
for i in range(1, n + 1):
    #iの倍数の数を求める
    m = n // i
    #初項i:公差i:m項までの等比数列の和
    ans += n * (2 * i + i * (n - 1)) *0.5
print(int(ans))
# Judge status: Accepted
n = int(input())
s = str(input())
ans = 0

for i in range(1,n):
    l = list(s[0:i])
    r = list(s[i:n])
    dup = len(set(l)&set(r))

    if ans < dup:
        ans = dup
print(ans)
# Judge status: Wrong Answer
import sys

n=input()
cnt=0
for i in range(1,len(n)):
    if n[i]==n[i-1]:
        cnt+=1
        if cnt >=2:
            print("Yes")
            sys.exit

print("No")
# Judge status: Accepted
N = int(input())
R = list(map(int, input().split()))
X = [0]*8
p = 0
for r in R:
  if r >= 3200:
    p += 1
  else:
    X[r//400] = 1

s = sum(X)
if s == 0:
  print(str(1) + " " + str(p))
else:
  print(str(s) + " " + str(s + p))
# Judge status: Wrong Answer
n=input().rstrip().split()
n=[int(x) for x in n]

if abs(n[1]-n[0])>abs(n[2]-n[0]):
  print("A")
else:
  print("B")
# Judge status: Wrong Answer
n,k = map(int, raw_input().split())
ais = map(int, raw_input().split())

def p(m,ais,k):
	t = [ m, ais, k]
	for ai in ais:
		k-= ai / m
	return k >=0

lo,hi = 1, max(ais)
print lo,hi
while(lo < hi):
	med = (lo + hi)/2
	if p(med, ais, k):
		hi = med
	else:
		lo = med + 1

print lo
# Judge status: Accepted
N, M = map(int, input().split())

n = N
m = M // 2

ans = 0
if n >= m:
  ans += m
else:
  ans += n
  m -= n
  ans += m // 2
  
print(ans)
# Judge status: Accepted
n = int(input())

# 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, ...
# 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, ...

A = [0] * (n + 1)
A[1] = 1 
for i in range(1, n):
    A[i + 1] = A[i] + i

from bisect import bisect_left

idx = bisect_left(A, n)

if n == A[idx]:
    for i in range(1, idx + 1):
        if i == idx - 1: continue
        print(i)
else:
    for i in range(1, idx):
        if i == idx - 1 - (n - A[idx - 1] + 1): continue
        print(i)
# Judge status: Accepted
n, m = map(int, input().split())
h = list(map(int, input().split()))

edge = [[] for _ in range(n)]

## 接している各頂点をまとめる
for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    edge[a].append(b)
    edge[b].append(a)

cnt = 0

for node in range(n):
    good = True 
    for neighbor in edge[node]:
        if h[node] <= h[neighbor]:
            good = False
            break;
    if good:
        cnt += 1

print(cnt)
# Judge status: Accepted
N = input()
print("Yes" if N[0]=="9" or N[1]=="9" else "No")
# Judge status: Accepted
N=int(input())
D={}
for i in range(N):
    s=input()
    if s in D:
        D[s]+=1
    else:
        D[s]=1
    

m=max(D.values())
d=list(D.values())
k=list(D.keys())
ans=[]
for i in range(len(D)):
    if m==d[i]:
        ans.append(k[i])

ans=sorted(ans)
for a in ans:
    print(a)
# Judge status: Accepted
import collections

n = int(input())
dic = collections.Counter(input().split())
for i in range(n):
  print(dic[str(i+1)])
# Judge status: Accepted
def inpl(): return list(map(int, input().split()))

N = int(input())
P = inpl()
Q = sorted(P)

for i in range(N):
    for j in range(i, N):
        R = [p for p in P]
        R[i], R[j] = R[j], R[i]
        for k in range(N):
            if R[k] != Q[k]:
                break
        else:
            print("YES")
            exit()
else:
    print("NO")
# Judge status: Wrong Answer
x = input()
if x == 0:
  print(1)
elif x==1:
  print(0)
# Judge status: Wrong Answer
n=int(input())
s=input()
counter=0
for i in range(1,n+1):
    for j in range(i+1,n+1):
        for k in range(j+1,n+1):
            if 2*j==i+k:
                break
            else:
                if s[i-1]!=s[j-1] and s[i-1]!=s[k-1] and s[j-1]!=s[k-1]:
                    counter+=1
print(counter)
# Judge status: Accepted
def solve(N, A, B):
    if A % 2 == B % 2:
        return (B - A) // 2
    return min(A-1, N-B) + 1 + (B - A -1)//2

if __name__ == "__main__":
    n, a, b = map(int, input().split())
    print(solve(n, a, b))
# Judge status: Accepted
s = input()
n = len(s)
ans = 0
l = 0
ll = [0] * (n + 1)
r = 0
rl = [0] * (n + 1)
for i in range(n):
    if s[i] == '<':
        l += 1
        ll[i+1] = l
    else:
        l = 0
    if s[n-1-i] == '>':
        r += 1
        rl[n-i-1] = r
    else:
        r = 0
for i in range(n + 1):
    ans += max(rl[i], ll[i])
print(ans)
# Judge status: Wrong Answer
R = list()
L = list()
N = int(input())
R.append(-1)
for i in range(N):
    k = int(input())
    L.append(k)
    if k == 0:
        R.append(len(L))
R.append(N)
S = sum(L)
for i in range(len(R) - 1):
    if sum(L[R[i] + 1 : R[i + 1]]) % 2 == 1:
        S = S - 1
print(S // 2)
# Judge status: Accepted
X = int(input())

hund = X // 500

X -= (500 * hund)
five = X // 5

print(hund * 1000 + five * 5)