peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Wrong Answer
a,b=input().split()
a=int(a)
b=int(b)
x=b-a
if x==0:
    f=0
    print(0)
elif x<0:
    a=x*(-1)
    y=b-a
    if y==0:
        f=0
    elif y<x:
        f=y
    else:
        f=x
    print(f)
else:
    a=x
    y=b-a
    if y==0:
        f=0
    elif y<x:
        f=y
    else:
        f=x
    print(f)
# Judge status: Accepted
n=int(input())
s=input()
word=""
for i in range(len(s)):
    if ord(s[i])+n>90:
        word+=chr(ord(s[i])+n-26)
    else:
        word+=chr(ord(s[i])+n)
print(word)
# Judge status: Accepted
N=int(input())
K=int(input())
X=int(input())
Y=int(input())
print(K*X+(N-K)*Y if N>=K else X*N)
# Judge status: Accepted
import sys
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり

N,X = MI()
L = LI()

a = 0
ans = 1
for i in range(N):
    a += L[i]
    if a <= X:
        ans += 1

print(ans)
# Judge status: Accepted
n = int(input())
a=list(map(int,input().split()))
for i in range(n - 1, -1, -1):
    s = sum(a[i ::i + 1])
    if s % 2 != a[i]:
        a[i] = 1 - a[i] # 1 -> 0 , 0 -> 1
print(a.count(1))
print(*[i+1 for i,x in enumerate(a) if x])
# Judge status: Accepted
n=int(input())
a=[]
for i in range(n):
  a.append(str(input()))

a=sorted(a)
b=[]
c=[]

tmp="."
count=0

for i in range(n):
  if tmp != a[i]:
    b.append(tmp)
    c.append(count)
    tmp=a[i]
    count=1
  else:
    count += 1
 
b.append(tmp)
c.append(count)
k=sorted(c)[-1]
for i in range(len(b)):
  if c[i]==k:
    print(b[i])
# Judge status: Accepted
N,K,Q=map(int,input().split())
score=[0]*N
for i in range(Q):
    A=int(input())-1
    score[A]+=1
for i in score:
    if Q-K < i: print('Yes')
    else: print('No')
# Judge status: Wrong Answer
import sys

S = str(sys.stdin.readline())

if S == 'ARC':
    print('ABD')
else:
    print('ARC')
# Judge status: Accepted
N = int(input())
A_list = list(map(int,input().split()))
Q = int(input())
S = sum(A_list)
count_list = [0] * (10 ** 5 + 1)
for A in A_list:
    count_list[A] += 1 
for i in range(Q):
    B,C = map(int,input().split())
    S = S + count_list[B] * (C - B)
    count_list[C] += count_list[B]
    count_list[B] = 0
    print(S)
#    print(sum(A_list))
# Judge status: Wrong Answer
S = input()

l = len(S)
x = [0]*(l+3)
y = [0]*(l+3)
for i in range(l):
    if S[i] == "<":
        x[i+1] = x[i]+1
for i in range(l):
    if S[i] == ">":
        y[l-i+1] = y[l-i+2]+1


res = 0
for i in range(l+1):
    res += max(x[i], y[i+2])
print(res)
# Judge status: Accepted
N=int(input())
K=int(input())
X=int(input())
Y=int(input())
if K>N:
  print(N*X)
else:
  print(K*X+(N-K)*Y)
# Judge status: Accepted
def main():
    a, b, c = map(int, input().split())
    print('Yes' if a < c < b or b < c < a else 'No')

if __name__ == '__main__':
    main()
# Judge status: Accepted
N = [int(n) for n in input()]
 
 
dp = [[0] * 2 for _ in range(len(N) + 1)]
dp[0][1] = 1
 
for i, n in enumerate(N):
    dp[i + 1][0] = min(dp[i][0] + n, dp[i][1] + (10 - n))
    dp[i + 1][1] = min(dp[i][0] + (n + 1), dp[i][1] + (10 - (n + 1)))
    
print(dp[-1][0])
# Judge status: Wrong Answer
n = int(input())
a = []
for i in range(n):
  s, p = input().split()
  a.append([s,-int(p),i])
a.sort()
for i in a:
  print(i[-1])
# Judge status: Accepted
n = int(input())

ans = float('inf')
for a in range(1, n):
    b = n - a
    dsum = 0
    for i in range(len(str(a))):
        x = int(str(a)[i])
        dsum += x
    for i in range(len(str(b))):
        x = int(str(b)[i])
        dsum += x
    ans = min(ans, dsum)

print(ans)
# Judge status: Accepted
#ABC042

n,k = map(int,input().split())
d = input().split()
c = True

while c:
    if all(str(n)[i] not in d for i in range(len(str(n)))):
        print(n)
        c = False
        break
    else:
        n += 1
# Judge status: Accepted
# 55

N = int(input())

sur = 200 * (N // 15)

print(800 * N - sur)
# Judge status: Accepted
k = int(input())
print((k//2)*(k-k//2))
# Judge status: Accepted
import math
n = int(input())

dp = [math.inf] * (n+1)

for i in range(n+1):
    dp[i] = min(dp[i],i)
    j = 6
    while(i+j<=n):
        dp[i+j] = min(dp[i+j],dp[i]+1)
        j *= 6
    j = 9
    while(i+j<=n):
        dp[i+j] = min(dp[i+j],dp[i]+1)
        j *= 9
#print(dp)
print(dp[n])
# Judge status: Wrong Answer
# Problem C - String Transformation

# input
S = list(input())
T = list(input())

# initialization
t_map = {}
is_ok = True

# mapping
for i in range(len(S)):
    s = S[i]
    t = T[i]
    if not t in t_map:
        t_map[t] = set([s])
    else:
        t_map[t].add(s)

# check
for t in t_map:
    if len(t_map[t])>1 and t in t_map[t]:
        is_ok = False

# output
if is_ok:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
sx, sy, tx, ty = map(int, input().split())

dist_x = tx - sx
dist_y = ty - sy

res = "R" * dist_x + "U" * dist_y + "L" * dist_x + "D" * dist_y + "D" + "R" * (dist_x + 1) + "U" * (dist_y + 1) + "L" + "U" + "L" * (dist_x + 1) + "D" * (dist_y + 1) + "R"
print(res)
# Judge status: Accepted
n = int(input())
AB = []
A = [0]*n
B = [0]*n
for i in range(n):
  A[i],B[i] = map(int,input().split())  

A = sorted(A)  
B = sorted(B)  

if n%2 == 1:
  l = A[n//2]
  r = B[n//2]
  print(r-l + 1)
else:
  l = (A[n//2-1]+A[n//2])/2
  r = (B[n//2-1]+B[n//2])/2
  print(int((r-l)*2+1))
# Judge status: Accepted
if int(input()) >= 30: print("Yes")
else: print("No")
# Judge status: Accepted
a,b = map(int, input().split())
print(a-(a>b))
# Judge status: Accepted
s = input()
t = input()
dic1 = {}
dic2 = {}

for i in range(len(s)):
    if s[i] in dic1.keys():
        if dic1[s[i]]!=t[i]:
            print("No")
            exit()
    else:
        dic1[s[i]] = t[i]

for i in range(len(t)):
    if t[i] in dic2.keys():
        if dic2[t[i]]!=s[i]:
            print("No")
            exit()
    else:
        dic2[t[i]] = s[i]

print("Yes")
# Judge status: Accepted
k, x = map(int, input().split())
if 500 * k >= x:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
N, A, B, C, D = map(int, input().split())
S = input()

from sys import exit

# check
goal = max(C, D)
if "##" in S[A-1:goal]:
    print("No")
    exit()

if C < D:
    # Bから先に動く
    print("Yes")

else:
    # 入れ替わる必要がある

    # cehck : 初期値で入れ替えられる
    # if "..." in S[B-2:D]:
    if ('...' in S[B-1:D]) or ('...' in S[B-2:B+1]) or ('...' in S[D-2:D+1]):
        print("Yes")
    else:
        print("No")
# Judge status: Accepted
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)
MOD = 10**9+7

def nCr(n, r, mod=MOD):
    r = min(r, n-r)
    numer = denom = 1
    for i in range(1, r+1):
        numer = numer * (n+1-i) % mod
        denom = denom * i % mod
    return numer * pow(denom, mod-2, mod) % mod

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

ans = pow(2, n, MOD) - 1 - nCr(n, a) - nCr(n, b)
ans += MOD * 2
ans %= MOD
print(ans)
# Judge status: Wrong Answer
n,k = map(int, input().split())
A = list(map(int, input().split()))

m = min(A)
i = A.index(m)
k -= 1
cnt = 0
left = i
right = n-1-i
cnt += -(-left//k)
cnt += -(-right//k)
print(cnt)
# Judge status: Accepted
S=input()
print(S[:3]+"8"+S[4:])
# Judge status: Accepted
A, B, C = map(int, input().split())

if B // A >= C:
    print(C)
else:
    print(B // A)
# Judge status: Accepted
n, k = map(int, input().split())
ans1 = n%k
ans2 = -(ans1-k)

print(min(ans1, ans2))
# Judge status: Wrong Answer
N = int(input())

answers = []

for i in range(1, 10, 1):
    for j in range(1,10, 1):
        ans = i*j
        answers.append(ans)

if N in answers:
    print("YES")
else:
    print("NO")
# Judge status: Wrong Answer
A,B=map(int,input().split())
if A>=13:
    print(B)
elif A>=6 and A<=12:
    print(B/2)
else:
    print(0)
# Judge status: Accepted
import math

N = int(input())

result = math.ceil(N / 1.08)

comfirm_result = int(result * 1.08)

if comfirm_result == N:
    print(result)
else:
    print(':(')
# Judge status: Accepted
def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a

def lcm(a,b):
  return a*b//gcd(a,b)

INF=10**9+7

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

temp=A[0]
for i in range(1,N):
    temp=lcm(temp,A[i])

ans=0
for a in A:
    ans+=(temp//a)

print(ans%INF)
# Judge status: Accepted
import sys
input = sys.stdin.readline

N, M = map(int, input().split())
graph = [[] for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)


q = [0]
par = [-1]*N
par[0] = 0
while q:
    qq = []
    for p in q:
        for np in graph[p]:
            if par[np] == -1:
                par[np] = p+1
                qq.append(np)
    q = qq

print("Yes")
print(*par[1:], sep="\n")
# Judge status: Wrong Answer
a,b,x=map(int,input().split())
print(b//x-(a-1)//x if a>0 else b//x)
# Judge status: Accepted
n, x, y = map(int, input().split())

result = [0 for _i in range(n)]
for i in range(1, n):
    for j in range(i+1, n+1):
        le = min([j-i, abs(i-x)+1+abs(j-y), abs(i-y)+abs(j-y)])
        result[le] += 1
for i in result[1:]:
    print(i)
# Judge status: Accepted
h,w=map(int,input().split())
masu=h*w
if h==1 or w==1:
  print(1)
elif masu%2==0:
  print(masu//2)
else:
  print((masu//2)+1)
# Judge status: Accepted
n = int(input())
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
ans = 0

for i in range(len(a1)):
    ans = max(sum(a1[:i+1]) + sum(a2[i:]),ans)
print(ans)
# Judge status: Accepted
n = int(input())
a = []
b = []
for i in range(n):
    s,t = map(int,input().split())
    a.append(s)
    b.append(t)
a.sort()
b.sort()
if n%2 == 0:
    am = (a[n//2-1]+a[n//2])/2
    bm = (b[n//2-1]+b[n//2])/2
    print(int((bm-am)*2+1))
else:
    am = a[(n-1)//2]
    bm = b[(n-1)//2]
    print(bm-am+1)
# Judge status: Accepted
N, R = map(int, input().split())
if N >= 10: ans = R
else: ans = R + (100 * (10-N))
print(ans)
# Judge status: Accepted
N = int(input())
X = list(map(int, input().split()))
X_min = min(X)
X_max = max(X)
S = []
if X_min == X_max:
    S.append(0)
for x in range(X_min, X_max):
    s = 0
    for i in range(N):
        s += (X[i]-x)**2
    S.append(s)
print(min(S))
# Judge status: Accepted
N = int(input())
s = input()
t = input()

c = -1
# i文字一致している
for i in range(N):
    sp = s[i:]
    tp = t[:N-i]
    # print(sp, tp)
    if sp == tp:
        c = i
        break

if c == -1:
    print(2*N)
else:
    match = N - c
    ans = 2 * N - match
    # print(':', match)
    print(ans)
# Judge status: Wrong Answer
import sys

input = sys.stdin.readline

def main():
    ans = 0
    n = int(input())
    s = [int(input()) for _ in range(n)]
    for i in range(n**2):
        tmp = 0
        for j in range(n):
            if i>>j&1:
                tmp += s[j]
        if tmp%10 != 0:
            ans = max(ans, tmp)
    print(ans)

if __name__ == '__main__':
    main()
# Judge status: Accepted
K = int(input())
S= list(str(input()))
list=[]
if(len(S)>K):
    for I in range(0,K):
        list.append(S[I])
        b="".join(list)
    print(b+"...")
else:
    x="".join(S)
    print(x)
# Judge status: Accepted
h,n = map(int,input().split())
a = list(map(int,input().split()))
 
if sum(a)>=h: print('Yes')
else: print('No')
# Judge status: Accepted
n,m = map(int,input().split())

A=[-1]*n

ans=0
for i in range(m):
    s,c = map(int,input().split())
    if A[s-1]!=-1 and A[s-1]!=c :
        ans=-1
        break
    else:
        A[s-1]=c

if A[0]==0 and n!=1 :
    ans=-1

if ans==-1 :
    print(ans)
    exit()
    
if A[0]==-1 and n!=1 :
    A[0]=1
for i in range(n):
    ans*=10
    if A[i]==-1 :
        A[i] = 0
    ans += A[i]



print(ans)
# Judge status: Wrong Answer
import sys
import bisect
input = sys.stdin.readline

n, c, k = [int(w) for w in input().split()]
la = [int(input()) for _ in range(n)]
la.sort()
lak = [a + k for a in la]

ind = 0
ans = 0
while ind < n:
    ride = bisect.bisect_left(la, lak[ind]) - ind
    
    ind += min(ride,k)
    ans += 1

print(ans)
# Judge status: Accepted
s = input()
#print(s)

score=0
for i in range(len(s)):
	if s[i]=="0":
		score = score +1
	else:
		score = score -1
#	print(s[i])
print(len(s)-abs(score))
# Judge status: Accepted
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, *A = map(int, read().split())

    ans = INF
    for x in range(-100, 101):
        tmp = 0
        for a in A:
            tmp += (x - a) ** 2
        if ans > tmp:
            ans = tmp

    print(ans)
    return


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
from bisect import bisect_left

n = int(input())
l = list(map(int, input().split()))

l.sort()

ans = 0

for i in range(n-2):
    for j in range(n-1):
        ans += bisect_left(l, l[i]+l[j]) - j - 1

print(ans)
# Judge status: Accepted
from bisect import bisect_right
def LIS(l):
    length = [l[0]]
    for i in range(1, len(l)):
        if l[i] >= length[-1]:
            length.append(l[i])
        else:
            pos = bisect_right(length, l[i])
            length[pos] = l[i]
    return len(length)

n = int(input())
a = [int(input()) for i in range(n)]
a = a[::-1]
print(LIS(a))
# Judge status: Accepted
a, b, c = map(int, input().split())
k = int(input())
al = [a, b, c]
bl = [a, b, c]
cl = [a, b, c]

for i in range(k):
    al[0] = al[0] * 2
    bl[1] = bl[1] * 2
    cl[2] = cl[2] * 2

sm = [sum(al), sum(bl), sum(cl)]
print(max(sm))
# Judge status: Wrong Answer
a, b, c = map(int, input().split())
if a == b == c:
  if a % 2 == 0:
    print(-1)
  else:
    print(1)
else:
  ans = 0
  while a % 2 != 0 or b % 2 != 0:
    a1 = a
    b1 = b
    c1 = c
    a = (b1+c1)/2
    b = (a1+c1)/2
    c = (a1+b1)/2
    ans += 1
  print(ans)
# Judge status: Wrong Answer
info = [int(i) for i in input().split(' ')]
K = info[0]
S = info[1]

count = 0
for x in range(K+1):
  tmp = x
  if tmp > S:
    continue
    for y in range(K+1):
      tmp = x+y
      if tmp > S:
        continue
        for z in range(K+1):
            ans = x+y+z
            if ans == S:
                count += 1
                
print(count)
# Judge status: Accepted
a,b,c,d = map(int,input().split())
print(max(a*c,a*d,b*c,b*d))
# Judge status: Accepted
n = int(input())
a = [int(input()) for _ in range(n)]
b = sorted(a)
M,m = b[n-1],b[n-2]
for i in range(n):
  if a[i] == M:
    print(m)
  else:
    print(M)
# Judge status: Accepted
import sys

read = sys.stdin.read

H, N, *AB = map(int, read().split())

INF = 10 ** 10
dp = [INF] * (H + 1)
r = INF
dp[0] = 0

for a, b in zip(*[iter(AB)] * 2):
    for i in range(a, H + 1):
        dp[i] = min(dp[i], dp[i - a] + b)
    r = min(r, min(dp[-a:]) + b)

print(min(r, dp[-1]))
# Judge status: Accepted
group = [0] * 13
for i in [1, 3, 5, 7, 8, 10, 12]:
	group[i] = 1
for i in [4, 6, 9, 11]:
	group[i] = 2
group[2] = 3
x, y = map(int, input().split())
print("Yes" if group[x] == group[y] else "No")
# Judge status: Accepted
a = int(input())
b = int(input())

print(6-a-b)
# Judge status: Accepted
import sys
import time
import math
def inpl():
    return list(map(int, input().split()))
st = time.perf_counter()
# ------------------------------

A, B, K = map(int, input().split())
ans = []
for i in range(1, min(A, B)+1):
	if A%i == 0 and B%i == 0:
		ans.append(i)
print(ans[len(ans)-K])

# ------------------------------
ed = time.perf_counter()
print('time:', ed-st, file=sys.stderr)
# Judge status: Wrong Answer
A, B, C = map(int, input().split())

if A == B or A == C:
    if B == C:
        print('No')
    else:
        print('Yes')
else:
    print('No')
# Judge status: Accepted
r,g,b = map(str,input().split())
print("YES" if int(r+g+b)%4 == 0 else "NO")
# Judge status: Accepted
n = int(input())
a = list(map(int,input().split()))
c = 0
for i in range(n):
	if i%2 == 0 and a[i]%2 != 0:
		c += 1
print(c)
# Judge status: Wrong Answer
n=int(input())
a=list(map(int,input().split()))
a.sort()
cnt,ans=0,0
p=0
for x in a:
  print(ans,cnt,x)
  if p==x:
    cnt+=1
  else:
    if cnt>p:
      ans+=cnt-p
    elif cnt<p:
      ans+=cnt
    p=x
    cnt=1
if cnt>p:
  ans+=cnt-p
elif cnt<p:
  ans+=cnt
print(ans)
# Judge status: Accepted
def main():
    n, m = map(int, input().split())
    py = [list(map(int, input().split())) for _ in range(m)]
    x = sorted(py, key=lambda x:x[1])
    d = {}
    for p, y in x:
        if type(d.get(p)) != dict:
            d[p]  = {}
        d[p][y] = len(d[p]) + 1
    for p, y in py:
        print('{:0=6}{:0=6}'.format(p, d[p][y]))
         
    
if __name__ == '__main__':
    main()
# Judge status: Accepted
import random
D = int(input())
c = list(map(int, input().split()))
s = []
for i in range(D):
  S = list(map(int, input().split()))
  s.append(S)
  
for i in range(365):
  ans = random.randint(1, 26)
  print(ans)
# Judge status: Wrong Answer
N,M = map(int,input().split())

a = [0]*N
b = [0]*N

for i in range(N):
    a[i],b[i] = map(int,input().split())

x = [0]*M
y = [0]*M

for  i in range(M):
    x[i],y[i]= map(int,input().split())

for i in range(N):
    dis = 10000000000000000
    for j in range(M):
        dis = min(dis,(abs(a[i]-x[j])+abs(b[i]-y[j])))
        res = i

    print(res+1)
# Judge status: Accepted
n,k = map(int,input().split())
ab = sorted([list(map(int,input().split())) for _ in range(n)])
i = 0
while(k>0):
  if ab[i][1] < k:
    k -= ab[i][1]
  else:
    print(ab[i][0])
    break
  i += 1
# Judge status: Wrong Answer
from bisect import bisect_left
import heapq

def solve():
    N,M = map(int, input().split())
    cities_in_prefecture = [[] for _ in range(N)]
    city_ids = []
    PYs = []
    for _ in range(M):
        P,Y = map(int, input().split())
        PYs.append((P,Y))
        heapq.heappush(cities_in_prefecture[P-1], Y)
    for P, Y in PYs:
        x = bisect_left(cities_in_prefecture[P-1], Y)
        print('{0:06d}{1:06d}'.format(P, x+1), flush=True)
        
solve()
# Judge status: Accepted
x, a, b = map(int, input().split())
if abs(x-a) < abs(x-b):
  print('A')
else:
  print('B')
# Judge status: Accepted
N, A, B = map(int, input().split())
S = input()

for s in S:
  if s == "c":
    print("No")
  elif s == "a":
    if A + B == 0:
   	  print("No")
    else:
      A -= 1
      print("Yes")
  elif s == "b":
    if A + B == 0 or B == 0:
      print("No")
    else:
      B -= 1
      print("Yes")
# Judge status: Wrong Answer
n,m = map(int, input().split())
l = list(map(int, input().split()))
for i in l:
    n -= i
if n > 0:
    print(n)
else:
    print('-1')
# Judge status: Wrong Answer
N = int(input())

yendama = [1,6,36,216,1296,7776,46656,9,81,729,6561,59049]

def calc_dp(n):
    initial = 10**7
    dp=[initial for _ in range(100010)]#dp用の配列はすこし大きめに作る
    dp[0] = 0

    for i in range(100000):
        for y in range(len(yendama)):
            if i-yendama[y]>=0:
                dp[i] = min(dp[i],1 + dp[i-yendama[y]])
    return dp[N]

print(calc_dp(N))
# Judge status: Accepted
# ==================================================-
# 最大公約数n個
def euclid(a, b):
    if b == 0:
        return a
    else:
        return euclid(b, a % b)


def multiple(a, b):
    return a * b // euclid(a, b)


import functools


# ------メイン関数-------
# numsは整数のリスト
def lcm(nums):
    return functools.reduce(multiple, nums)

a=[]

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

print(lcm(a))
# Judge status: Wrong Answer
N=20; X=12; T=6
import math
T_total = ( math.ceil( N / X )*T )

print (T_total)
# Judge status: Wrong Answer
n=int(input())
a=list(map(int,input().split()))

c=0

for i in range(0,n):
  if i%2!=0 and a[i]%2!=0:
    c+=1
print(c)
# Judge status: Accepted
N=int(input())
D=sorted(list(map(int, input().split())))
print(D[N//2]-D[N//2-1])
# Judge status: Accepted
from collections import Counter

n = int(input())
L = [Counter(str(input())) for _ in range(n)]
C = sorted(L[0])
ans = ''
for k in C:
    m = L[0][k]
    for i in range(n):
        m = min(m, L[i][k])
    ans += k * m
print(ans)
# Judge status: Accepted
import sys
import math
import itertools
import bisect
from copy import copy,deepcopy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(map(int,input().split()))
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

N,M = I()
if M <= N*2:
    print(M//2)
else:
    print(N+(M-N*2)//4)
# Judge status: Accepted
s= input().strip()
f="Yes"
if (s.count('N')!=s.count('S') and s.count('N')*s.count('S')==0):
    f="No"
elif(s.count('E')*s.count('W')==0 and s.count('E')!=s.count('W')):
    f="No"
print(f)
# Judge status: Accepted
W, a, b = map(int, input().split())
a, b = sorted([a, b])
print(max(0, b-(a+W)))
# Judge status: Accepted
N = int(input())
H = list(map(int,input().split()))

for i in range(N-1,0,-1):
    if H[i] + 1 == H[i-1]:
        H[i-1] -= 1
    elif H[i] < H[i-1]:
        print("No")
        exit()
print("Yes")
# Judge status: Accepted
import sys
import collections
input = sys.stdin.readline

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

countL = []
countR = []
for i in range(N):
  countL.append(i - A[i])
  countR.append(i + A[i])

countL = collections.Counter(countL)
countR = collections.Counter(countR)

ans = sum([countL[i] * countR[i] for i in countL.keys()])
print(ans)
# Judge status: Accepted
x = input()

for i in ["+","-"]:
    for j in ["+","-"]:
        for k in ["+","-"]:
            y = x[0]+i+x[1]+j+x[2]+k+x[3]
            if eval(y) == 7:
                ans = y
                
print(ans+"=7")
# Judge status: Wrong Answer
L,R,d=list(map(int,input().split()))
I=R-L+1
if 1<=L<=R<=100:
    print(I//d)
# Judge status: Accepted
l=list(map(int,input().split()))
print('YES'if l.count(5)==2 and l.count(7)==1 else'NO')
# Judge status: Wrong Answer
S=input()
s=0
t=0
for i in range(len(S)):
  if i%2==0:
    if S[i]!=0:
      s+=1
    else:
      s=s
  if i%2==1:
    if S[i]!=1:
      s+=1
    else:
      s=s
for i in range(len(S)):
  if i%2==0:
    if S[i]!=1:
      t+=1
    else:
      t=t
  if i%2==1:
    if S[i]!=0:
      t+=1
    else:
      t=t
print(min(s,t))
# Judge status: Wrong Answer
#def main(S, b):
if __name__ == '__main__':
    n, m = map(int, input().split())

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

    s = sum(a)
    cnt = 0
    for i in range(n):
        if (a[i] > s / 4 / m):
            cnt += 1
    #print(cnt)
    if (cnt >= m):
        print("Yes")
    else:
        print("No")
# Judge status: Wrong Answer
x = input()
if x == 1:
  print(0)
else:
  print(1)
# Judge status: Accepted
K, X = map(int, input().split())

print("Yes" if K*500 >= X else "No")
# Judge status: Accepted
H,A=map(int,input().split())
count=0
while H>0:
    H=H-A
    count=count+1
print(count)
# Judge status: Accepted
def solve(x, y, a, b, c, p, q, r):
    p = sorted(p)[::-1]
    q = sorted(q)[::-1]
    r = sorted(r)[::-1]
    v = sorted(p[:x] + q[:y])
    n = len(v)
    t = sum(v)
    for i in range(min(n,c)):
        if v[i] < r[i]:
            t += r[i] - v[i]
    return t

x, y, a, b, c = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
print(solve(x, y, a, b, c, p, q, r))
# Judge status: Accepted
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from collections import Counter
def main():
    s = input()
    n = len(s)

    amari = [0] * n
    ketaamari = 1
    t = 0
    for i1 in range(n):
        t = (t + ketaamari * int(s[-i1 -1])) % 2019
        amari[-i1-1] = t
        ketaamari = (ketaamari * 10) % 2019
    amari.append(0)
    ac = Counter(amari)
    r = 0
    for v in ac.values():
        r += v * (v - 1) // 2
    print(r)

if __name__ == '__main__':
    main()
# Judge status: Accepted
N = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
A = a[1:len(a):2]
ans = 0
for i in range(N):
    ans += A[i]
print(ans)
# Judge status: Accepted
#input
S = input()
S = S.replace('eraser','') # 文字列の置き換えeraser を空文字に
S = S.replace('erase','')
S = S.replace('dreamer','')
S = S.replace('dream','')

#
if S:
    print('NO')
else:
    print('YES')
# Judge status: Accepted
N, A, B = map(int, input().split())
ans = (N // (A+B)) * A
T = N % (A+B)
if T >= A:
    print(ans + A)
else:
    print(ans + T)