Problem:
 Score : 300 points    Problem Statement Snuke loves puzzles.  Today, he is working on a puzzle using S - and c -shaped pieces.
In this puzzle, you can combine two c -shaped pieces into one S -shaped piece, as shown in the figure below:     Snuke decided to create as many Scc groups as possible by putting together one S -shaped piece and two c -shaped pieces.  Find the maximum number of Scc groups that can be created when Snuke has N  S -shaped pieces and M  c -shaped pieces.      Constraints  1 ≤ N,M ≤ 10^{12}         Input The input is given from Standard Input in the following format:  N  M       Output Print the answer.        Sample Input 1 1 6      Sample Output 1 2  Two Scc groups can be created as follows:   Combine two c -shaped pieces into one S -shaped piece  Create two Scc groups, each from one S -shaped piece and two c -shaped pieces        Sample Input 2 12345 678901      Sample Output 2 175897

Solution (Python):
n, m = map(int, input().split())
print(min(n, m//2)+max(0, (m-n*2)//4))

Solution (Python):
def main():
    s, c = map(int, input().split())
    res = min(s, c // 2)
    s -= res
    c -= res * 2
    if s == 0:
        res += c // 4
    print(res)


if __name__ == '__main__':
    main()

Solution (Python):
n,m=map(int,input().split())
if m<2*n:print(m//2)
else:print(n+(m-2*n)//4)

Solution (Python):
n, m = map(int, input().split())
d = m//2

if d <= n:
    print(d)
    exit()

print(n + (d-n)//2)

Solution (Python):
N, M = list(map(int, input().split()))
ans = 0
if 2*N >= M:
	ans = M // 2
else:
	ans = N + (M-(2*N))//4
print(ans)

Solution (Python):
n,m = map(int, input().split())
if 2 * n >= m :
    print(m//2)
else:
    print((n+m//2)//2)

Solution (Python):

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

N_tmp = N
M_tmp = M

ans = 0
if 2 * N < M:
    ans += N
    N_tmp -= N
    M_tmp -= 2 * N
    
    print(ans + M_tmp // 4)
else:
    ans += M // 2
    N_tmp -= M // 2
    M_tmp -= M
    
    print(ans)

Solution (Python):
N, M = map(int, input().split())
c = M // 2

ans = 0
if N >= c:
    ans += c
else:
    ans += N
    c -= N
    ans += c // 2

print(ans)

Solution (Python):
n, m = map(int, input().split())
p = m // 2
if p <= n:
    print(p)
else:
    print(n + (m - n * 2) // 4)

Solution (Python):
N, M = map(int, input().split())
ans = 0

if 2*N >= M: 
    ans = M //2
else: 
    ans = (2*N + M)//4
    
print(ans)

Solution (Python):
N, M = map(int, input().split())

if N * 2 < M:
    x = M // 2 - N
    print(N + x // 2)

else:
    print(M // 2)

Solution (Python):
N, M = map(int, input().split())
ans = 0
if N * 2 >= M:
  print(M // 2)
else:
  ans += N
  M -= N * 2
  print(ans + M // 4)

Solution (Python):
N, M = [int(_) for _ in input().split()]
if N >= M//2:
    print(M//2)
else:
    M -= 2*N
    print(N+M//4)

Solution (Python):
s1, c1 = map(int, raw_input().split())
c2 = c1 // 2
r = min(s1, c2)
s1 -= r
c2 -= r
if c2>0:
  r += c2 // 2
print r

Solution (Python):
import math

n, m = [int(i) for i in input().split()]

count = 0

if m - 2*n > 0:
    count = max(count, min(n + int((m - 2 * n) / 4),
                           int(m / 2 - (m - 2 * n) / 4)))
    
    
    count = max(count, min(n + math.ceil((m - 2 * n) / 4),
                           int(m / 2) - math.ceil((m - 2 * n) / 4)))
    
count = max(count, min(n, int(m / 2)))
print(count)

Solution (Python):
S, C = map(int, input().split())
ans = 0

if S*2 <= C:
    ans += S
    C -= S*2
    ans += C//4
    
else:
    ans += C//2
    
print(ans)

Solution (Python):
s,c=map(int,input().split())
if c<=2*s:
    print(c//2)
else:
    print(s+(c-2*s)//4)

Solution (Python):
N, M = map(int, input().split())

ans = 0
m = M
if M >= N*2:
    ans += N
    m -= N*2
else:
    print(M//2)
    exit()

ans += m//4
print(ans)

Solution (Python):
a=list(map(int,input().split()))
if a[0]*2 == a[1]:
    print(str(a[0]))
elif a[0]*2 < a[1]:
    a[1]-=a[0]*2
    print(str(a[0]+int(a[1]/4)))
else:
    print(str(int(a[1]/2)))

Solution (Python):
N,M=map(int,input().split())
if 2*N>=M:
    print(M//2)
else:
    print((M-2*N)//4+N)

Solution (Python):
n,m = map(int,input().split())
num = 0
if n * 2 >= m:
  print(m//2)
else:
  num += n
  m -= n*2
  n = 0
  print(num + m//4)

Solution (Python):
n, m = map(int, input().split())
if m >= n*2:
    leave_c = m - n*2
    available = leave_c // 4
    print(n + available)
else:
    available_c = m // 2
    print(available_c)

Solution (Python):
N,M=map(int,input().split())
if 2*N<M:
    x=M-2*N
    y=x//4
    print(N+y)
if 2*N==M:
    print(N)
if 2*N>M:
    print(M//2)

Solution (Python):
n, m = map(int, input().split())
ans = 0
if n < m//2:
    ans += n
    m -= 2*n
else:
    ans += m//2
    m = 0
    
ans += m//4
print(ans)

Solution (Python):
import sys
import math
import collections
import itertools
import array
import inspect


sys.setrecursionlimit(1000000)



def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))



def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in input().split()]


def gcd(n, m):
    if n % m == 0:
        return m
    else:
        return gcd(m, n % m)


def gcd_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = gcd(v, L[i])

    return v


def lcm(n, m):
    return (n * m) // gcd(n, m)


def lcm_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = lcm(v, L[i])

    return v



def wfs_d(D, N, K):
    """
    D: 隣接行列(距離付き)
    N: ノード数
    K: 始点ノード
    """

    dfk = [-1] * (N + 1)
    dfk[K] = 0

    cps = [(K, 0)]
    r = [False] * (N + 1)
    r[K] = True
    while len(cps) != 0:
        n_cps = []
        for cp, cd in cps:
            for i, dfcp in enumerate(D[cp]):
                if dfcp != -1 and not r[i]:
                    dfk[i] = cd + dfcp
                    n_cps.append((i, cd + dfcp))
                    r[i] = True

        cps = n_cps[:]

    return dfk



def dfs_d(v, pre, dist):
    """
    v:  現在のノード
    pre: １つ前のノード
    dist: 現在の距離

    以下は別途用意する
    D: 隣接リスト(行列ではない)
    D_dfs_d: dfs_d関数で用いる，始点ノードから見た距離リスト
    """

    global D
    global D_dfs_d

    D_dfs_d[v] = dist

    for next_v, d in D[v]:
        if next_v != pre:
            dfs_d(next_v, v, dist + d)

    return


def sigma(N):
    ans = 0
    for i in range(1, N + 1):
        ans += i
    return ans


def comb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2, r + 1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p - 1, r, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def bisearch(L, target):
    low = 0
    high = len(L) - 1
    
    while low <= high:
        mid = (low + high) // 2
        guess = L[mid]
        if guess == target:
            return True
        elif guess < target:
            low = mid + 1
        elif guess > target:
            high = mid - 1
    if guess != target:
        return False



dp = None


def main():
    S, C = li_input()

    
    if S * 2 >= C:
        print(C // 2)
        return

    ans = S
    C -= S * 2
    ans += (C // 4)

    print(ans)


main()

Solution (Python):
N, M = map( int, input().split())
if N*2 <= M:
    print(N+(M-N*2)//4)
else:
    print(M//2)

Solution (Python):
(n, m) = list(map(int, input().split()))

count = min(n, m // 2)

if m > n * 2:
    count += (m - n * 2) // 4
print(count)

Solution (Python):

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

if N == M//2:
    print(N)

elif N > M//2:
    
    print(M//2)

else:
    print(N + (M - N*2 )//4)

Solution (Python):
N, M = map(int, input().split())
res = 0
if 2*N <= M:
    res += N
    M = M - 2*N
    res += int(M/4)
    
else:
    res = int(M/2)
print(res)

Solution (Python):
s,c=map(int,input().split())
d = 0
if c < 2*s:
    d = c//2
else:
    d = s + (c-2*s)//4
print(d)

Solution (Python):
s,c = map(int,input().split())
if s > c//2:
    print(c//2)
else:
    print((2*s + c)//4)

Solution (Python):
N,M=map(int,input().split())
if N > M//2:
    print(M//2)
else:
    print((N*2+M)//4)

Solution (Python):
iN,iM=[int(_) for _ in input().split()]

if 2*iN > iM:
    print( iM // 2 )
else:
    print( iN + (iM -2*iN) // 4)

Solution (Python):
N, M = map(int, input().split())
ans = 0
if 2 * N >= M:
    ans = int(M/2)
else:
    ans = int((M-2*N)/4) + N
print(ans)

Solution (Python):
a = input().split(" ")
S = int(a[0])
c = int(a[1])
count = 0
if S * 2 <= c:
    count += S
    d = c - S * 2 
    count += d // 4
else:
    S = c // 2
    count += S
print(count)

Solution (Python):
N,M = map(int, input().split())
if 2*N > M :
    print(M//2)
else:
    print(N+(M-2*N)//4)

Solution (Python):
N,M=map(int,input().split())
ans=0
a=M-2*N
if a<0:
    ans=M//2
else:
    ans+=N+a//4
print(ans)

Solution (Python):
N, M = map(int,input().split())

if N*2 <= M:
    ans = N
    M -= 2*N

    ans += M//4

else:
    ans = M // 2

print(ans)

Solution (Python):
N, M = map(int, input().split())

if N >= M // 2:
    print(M // 2)
else:
    M -= N * 2
    print(N + M//4)

Solution (Python):
N,M=map(int,input().split())

fi_n=min(N,M//2)
N-=fi_n
M-=fi_n*2
se_n=M//4
print(fi_n+se_n)

Solution (Python):
n, m = map(int, input().split())
if m <= 2*n:
  print(m//2)
else:
  print((m-2*n)//4 + n)

Solution (Python):
s,c = map(int,input().split())

ass = 0
if s >= c//2:
    print(c//2)
else:
    ass += s
    c -= s*2
    
    ass += c//4
    print(ass)

Solution (Python):
def cnt_peice(n,m):
    s = n*2
    ans = 0

    if m > s:
        remain = m-s
        ans = n
        ans += remain // 4
    else:
        ans = m//2
    return ans

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

print(cnt_peice(n,m))

Solution (Python):
n, m = map(int, input().split())

count=0
if 2*n < m:
    count+=n
    count+=(m-2*n)//4
elif 2*n == m and m%2==0:
    count=n
else:
    count=m//2

print(count)

Solution (Python):
N, M = map(int, input().split())
if N > M//2:
    print(M//2)
else:
    rem = M - N * 2
    print(N + (rem // 4))

Solution (Python):
n,m=map(int,input().split())
ans=0
if n>m//2:
    print(m//2)
elif n==m//2:
    print(n)
elif n<m//2:
    ans+=n
    m-=n*2
    ans+=m//4
    print(ans)

Solution (Python):
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def main():
    N, M = map(int, input().split())

    ans = min(N, M // 2)
    N -= ans
    M -= 2 * ans

    ans += M // 4
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
N, M = map(int, input().split())
ans = 0

if M <= 1:
    ans = 0

elif N >= M:
    ans = M//2

elif N < M:
    if N*2 >= M:
        ans = M//2
    else:
        ans += N
        ans += (M-N*2)//4
print(ans)

Solution (Python):
row = input();
n = int(row.split(" ")[0])
m = int(row.split(" ")[1])

if 2 * n ==  m :
	print(n) 
elif 2 * n > m :
	print(int(m / 2))
elif 2 * n < m :
	print( n + int((m - 2*n ) / 4))

Solution (Python):
N, M = map(int, input().split())
if N >= M / 2:
    print(M // 2)
else:
    cnt = N
    M -= 2 * N
    cnt += M // 4
    print(cnt)

Solution (Python):
N, M = map(int, input().split())

ans = 0


if M-2*N >=0:
  ans += N
else:
  ans += M//2

M -= 2*ans


ans += M // 4

print(ans)

Solution (Python):
s,c=map(int,input().split())
count=0
c-=2*s
if c<0:
    print(s+c//2)
    exit()
print(s+c//4)

Solution (Python):
ns,nc=map(int,input().split())
if ns>=2*nc:
    print(nc//2)
    exit()
print(ns+(nc-ns*2)//4 if nc-ns*2>0 else nc//2)

Solution (Python):
S,C = map(int,input().split())
ans = min(S,C//2)
S -= ans
C -= ans*2
if C >= 2:
    assert S == 0
    ans += C//4
print(ans)

Solution (Python):
n, m = map(int, input().split())

if n >= m // 2:
    print(m // 2)
else:
    print(n + (m - 2 * n) // 4)

Solution (Python):
import sys
stdin = sys.stdin

def li(): return [int(x) for x in stdin.readline().split()]
def li_(): return [int(x)-1 for x in stdin.readline().split()]
def lf(): return [float(x) for x in stdin.readline().split()]
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(ns())
def nf(): return float(ns())

n,m = li()

if 2*n >= m:
    print(m//2)
    
else:
    print(n + (m-2*n)//4)

Solution (Python):
n, m = list(map(int, input().split()))
if m <= 2*n:
    print(m//2)
else:
    r = m - 2*n
    print(n+r//4)

Solution (Python):
n,m=map(int, input().split())
print(m//2 if 2*n>=m else n+(m-2*n)//4)

Solution (Python):
N, M=map(int,input().split())
if N>=M//2:
    print(M//2)
else:
    print(N+(M-2*N)//4)

Solution (Python):
N, M = (int(i) for i in input().split())

ans = 0

if M-2*N < 0:
    ans = M // 2
else:
    ans = N + (M-2*N) // 4

print(ans)

Solution (Python):
N,M=(int(i) for i in input().split())
if 2*N >= M:
    print(M//2)
else:
    print(N+((M-2*N)//4))

Solution (Python):
n, m = map(int, input().split())

if 2*n < m:
    pair = n
    m = m - 2*n
    pair = pair + (m//4)
else:
    pair = m//2

print(pair)

Solution (Python):
N, M = map(int,input().split())

S = M - N * 2

if N >= M / 2:
    print(M // 2)
else:
    count = S // 4
    print(count + N)

Solution (Python):
N, M = list(map(int, input().split()))
if 2 * N >= M:
    print(int(M / 2))
else:
    print(N + int((M - 2 * N) / 4))

Solution (Python):
n,m = map(int,input().split())
res = 0
if n*2<=m:
    res += n
    m -= n * 2
elif n>=m//2:
    print(m//2)
    exit()
res += m//4
print(res)

Solution (Python):
s, c = map(int, input().split())
scnt = min(s, c // 2)

print(scnt if s > scnt else scnt + (c - scnt * 2) // 4)

Solution (Python):


def main():
    n, m = map(int, input().split())

    if 2 * n <= m:
        ans = n + (m - 2 * n) // 4
    else:
        ans = m // 2
    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
n, m = map(int, input().split())
if n * 2 <= m:
  print((m - n * 2) // 4 + n)
else:
  print(m // 2)

Solution (Python):
N, M = map(int, input().split())
if M < N * 2:
    print(M // 2)
    exit()

nc = M - N * 2
print(nc // 4 + N)

Solution (Python):
n, m = map(int, input().split())
if n * 2 >= m:
    print(m // 2)
else:
    q = m - n * 2
    print(n + q // 4)

Solution (Python):
n, m = map(int, input().split(" "))

first = min(n, m//2)
second = max(0, m-2*first)//4
print(first + second)

Solution (Python):
def getinputdata():

    
    array_result = []
    
    data = input()

    array_result.append(data.split(" "))

    flg = 1

    try:

        while flg:

            data = input()
            
            if(data != ""):
                
                array_result.append(data.split(" "))

            else:

                flg = 0
    finally:

        return array_result

arr_data = getinputdata()


n = int(arr_data[0][0])

m = int(arr_data[0][1])

num=min(n//1,m//2)

cnt=num

n-=num*1
m-=num*2


cnt+=m//4

print(cnt)

Solution (Python):
n, m = map(int, input().split())
if n > m // 2:    print(m // 2)
else:    print(n + (m - n * 2) // 4)

Solution (Python):
n, m = map(int, input().split())
if n > m // 2:
    print(m // 2)
else:
    print(n + (m - n * 2) // 4)

Solution (Python):
N,M=map(int,input().split())
if 2*N<=M:
  t=(M+2*N)//4
else:
  t=M//2
print(t)

Solution (Python):
n, m = [int(_) for _ in input().split()]

if n >= m // 2:
    print(m // 2)
else:
    print(n + (m - 2 * n) // 4)

Solution (Python):
n, m = list(map(int, input().split()))

if m < 2:
    print(0)
else:
    if m <= 2*n:
        print(m//2)
    else:
        ans = n
        m -= 2*n
        ans += m//4
        print(ans)

Solution (Python):
N, M = map(int, input().split())
n = min(N, M //2)
m = max((M - 2 * N) // 4, 0)
print(n + m)

Solution (Python):
s,c = map(int,input().split())
print((c-2*s)//4+s if s<c/2 else min(s,c//2))

Solution (Python):
s,c = map(int,input().split())
if s<c/2:
    print((c-2*s)//4+s)
else:
    print(min(s,c//2))

Solution (Python):
n, m = map(int, input().split())

ans = 0
if n >= m // 2:
    ans = m // 2
else:
    ans = n + (m - 2 * n) // 4
print(ans)

Solution (Python):
N, M = map(int,input().split())
if (N*2 > M):
    print(M//2)
else:
    tmp = M - 2*N
    print(N+tmp//4)

Solution (Python):


















''' 二次元配列を一列ずつ
for i in ans:
	print(*i)
'''
''' heapq
queue = []
heapq.heapify(queue) 
heapq.heappush(queue,num) 
pop = heapq.heappop(queue) 
pop = heapq.heappushpop(queue,num) 

'''

from collections import defaultdict
import sys,heapq,bisect,math,itertools,string
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7


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

if N*2 > M:
	print(M//2)
else:
	M -= N*2
	print(N + M//4)

Solution (Python):


S,c = map(int, input().split())


if c >= S*2:
    print((S*2 + c) // 4)

else:
    print(c // 2)

Solution (Python):
N,M = map(int,input().split())

if M<2*N:
    print(M//2)
else:
    print(N+(M-2*N)//4)

Solution (Python):
n,m=map(int,input().split())

a=m//2

ans=min([n,a])
m=m-2*ans

print(ans+m//4)

Solution (Python):
import math


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

if 2 * N <= M:
    ans = N + math.floor((M - 2 * N) / 4)
else:
    ans = math.floor(M / 2)

print(ans)

Solution (Python):
n, m = [int(i) for i in input().split()]

if n * 2 >= m:
    print(m // 2)
elif n * 2 >= (m - 3):
    print(n)
else:
    c_rest = m - n * 2
    print(n + c_rest // 4)

Solution (Python):
n, m = map(int, input().split())

if n >= m/2:
  print(m//2)
else:
  rest_c = m - n * 2
  additional_set = rest_c // 4
  print(n + additional_set)

Solution (Python):
N, M = map(int, input().split())

if M < 2 * N :
    print(M // 2)
else :
    print(N + (M - 2*N) // 4)

Solution (Python):
n,m = map(int, input().split())
new_m = m//2
if n >= new_m:
    print(new_m)
else:
    print(n + (new_m-n)//2)

Solution (Python):
n, m = map(int, input().split())
if n * 2 < m:
  print(n + (m - n * 2) // 4)
else:
  print(m // 2)

Solution (Python):
n, m = list(map(int, input().split()))

num_without_s = m/4
num_with_s = 0
m_tmp = m
n_tmp = n
""" while m_tmp > 1 and n_tmp > 0:
    num_with_s += 1
    m_tmp = m_tmp - 2
    n_tmp = n_tmp - 1
 """

if m >= (2 * n):
    num_with_s = n
    if (m_tmp - 2*n) > 3:
        num_with_s = num_with_s + int(((m_tmp - 2*n) / 4))
else:
    num_with_s = int(m/2)

if num_with_s > num_without_s:
    print(int(num_with_s))
else:
    print(int(num_without_s))

Solution (Python):
N, M = map(int, input().split())
n = min(N, M // 2)
x = max((M - 2 * N) // 4, 0)
print(n + x)

Solution (Python):
N, M = map(int, input().split(' '))

if 2 * N >= M:
    print(M // 2)
else:
    print(N + (M - 2 * N) // 4)

Solution (Python):
N, M = map(int, input().split())

if N > M // 2:
    print(M // 2)
else:
    print((N + M // 2) // 2)

Solution (Python):

def main():
    n, m = map(int,input().split())
    ans=0

    if m < n*2:
        ans = m//2
    elif m >= n *2:
        ans += n
        m -= n*2
        ans += m//4

    print(ans)

if __name__ == "__main__":
        main()

Solution (Python):
n,m = map(int, input().split())

if m > 2 * n:
    print(n + (m - 2 * n) // 4)
else:
    print(m // 2)

Solution (Python):
import math
n, m = map(int, input().split())
if n < m:
  print(n + (m - n * 2) // 4)
else:
  print(m // 2)

Solution (Python):
N, M = map(int, input().split())

if N >= M // 2:
    print(M // 2)
else :
    print(N + (M - N * 2) // 4)

Solution (Python):
N,M=map(int,input().split())
ans=0
if 2*N<=M:
    ans+=N
    M-=2*N
    ans+=M//4
else:
    ans=M//2
print(ans)

Solution (Python):
N, M = map(int, input().split())

if M >= 2 * N:
    print((N + (M - N*2) // 4))
else:
    print(M//2)

Solution (Python):
N, M = list(map(int, input().split()))
if M > 2 * N:
    A = M - 2 * N
    print(N + (A // 4))
else:
    print(M//2)

Solution (Python):
N,M = map(int, input().split())
s = N
c = M
if 2*N>=M:
  print(M//2)
else:
  t = 2*s+c
  print(t//4)

Solution (Python):
s, c = [int(i) for i in input().split()]

if s > (c // 2):
    print(c // 2)
else:
    print(s + ((c - s*2) // 4))

Solution (Python):
s,c = map(int,raw_input().split())

t = min(s,c/2)

print t+(c-t*2)/4

Solution (Python):
def m():
    s, c = map(int, input().split())
    if s >= c:
        return c//2
    ans = s
    ans += (c - s*2) // 4
    return ans

print(m())

Solution (Python):
S,C = map(int,input().split())
ans = min(S,C//2)
S -= ans
C -= ans*2
ans += C//4
print(ans)

Solution (Python):





if __name__ == '__main__':
    n, m = list(map(int, input().split()))

    
    
    print(min(m // 2, (2 * n + m) // 4))

Solution (Python):





if __name__ == '__main__':
    n, m = list(map(int, input().split()))
    print(min(m // 2, (2 * n + m) // 4))

Solution (Python):
n, m = map(int,input().split())
print((min(n * 2, m) + m) // 4)

Solution (Python):
N,M = map(int,input().split())

if N*2 >= M:
    print(min(N,M//2))
else:
    print(N + (M-N*2)//4)

Solution (Python):
N, M = map(int, input().split())
ans = min(N, M//2)
M -= N*2
M = max(0, M)
print(ans+M//4)

Solution (Python):
n, m = map(int, input().split())
comb = 0

if 2 * n >= m:
    comb += m // 2
    m -= comb * 2
else:
    comb += n
    m -= 2 * n

comb += m // 4

print(comb)

Solution (Python):
n, m = (int(i) for i in input().split())

if n*2 >= m:
    print(m//2)
else:
    ma = m - n*2
    ans = n + ma//4
    print(ans)

Solution (Python):
N, M = map(int,input().split())

ans = 0
if N*2<=M:
    M -= N*2
    ans += N
    ans += M//4
else:
    ans = M//2
    M//=2

print(ans)

Solution (Python):
n, m = map(int, input().split())

if m // 2 > n:
  print(n+(m-n*2)//4)
else:
  print(min(n, m//2))

Solution (Python):
S, C = map(int, input().split(' '))
if S * 2 >= C:
    print(C // 2)
else:
    resi_C = C - S * 2
    if resi_C < 4:
        print(S)
    else:
        print(S + resi_C // 4)

Solution (Python):
n, m = list(map(int, input().split()))

if n * 2 >= m:
    print(m // 2)
else:
    print((2 * n + m) // 4)

Solution (Python):
n,m=map(int,input().split())
if m<=2*n:
    print(m//2)
else:
    res=m-2*n
    print(n+res//4)

Solution (Python):


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

if N * 2 > M:
    print(int(M / 2))
else:
    print(int((2 * N + M) / 4))

Solution (Python):
n, m = map(int, input().split())
d = m - 2*n
if d >= 0: 
    ans = n    
    ans += d // 4
else:
    k = m // 2
    ans = k
print(ans)

Solution (Python):
def calc(n, m):
	if n > m / 2:
		return m / 2
	else:
		return n + (m - 2 * n) / 4

N, M = map(int, raw_input().split())
print calc(N, M)

Solution (Python):
N,M=map(int,input().split())
if N*2>=M:
    print(M//2)
else:
    print(N+(M-2*N)//4)

Solution (Python):
s,c =list(map(int,input().split()))

if s >= c//2:
    print(c//2)
else:
    print((2*s+c)//4)

Solution (Python):
n,m=map(int,input().split())
ans=0


ans+=min(n,m//2)
m=max(m-n*2,0)

ans+=m//4
print(ans)

Solution (Python):
n , m  = list(map(int,input().split()))
counter = 0
if n <= m // 2:
    counter = n
    m = m - 2* n
    n = 0
else:
    counter = m //2
    n = n - m //2
    m = 0

counter = counter + m //4 

kouho = m //4
print(max(counter,kouho))

Solution (Python):
N,M=map(int,input().split())

if 2*N > M:
  print(M//2)
else:
  M+=(2*N)
  print(M//4)

Solution (Python):
n, m = map(int, input().split())

if m <= n*2:
  print(m//2)
else:
  print(n+(m-2*n)//4)

Solution (Python):
n, m = map(int,input().split())
ans = n if n <= m//2 else m//2
n -= ans
m -= 2*ans
ans += m//4 if (n==0 and m>1) else 0
print(ans)

Solution (Python):
n, m = map(int, input().split())
if n > m // 2: print(m // 2)
else: print((n * 2 + m) // 4)

Solution (Python):
s, c = map(int, input().split())
print(c // 2) if s >= c // 2 else print(s + (c - 2 * s) // 4)

Solution (Python):
def pieces(s, c):
    if s >= c // 2:
        return c // 2
    else:
        return s + (c - 2 * s) // 4


if __name__ == '__main__':
    s, c = map(int, input().split())
    print(pieces(s, c))

Solution (Python):
n,m=map(int,input().split())
if 2*n>m:
    print(m//2)
else:
    print(n+(m-n*2)//4)

Solution (Python):
n,m = (int(i) for i in input().split())
if m<=2*n:
	answer = (m-m%2)//2
else:
	answer = n
	a = m-2*n
	answer += (a-a%4)//4
print(answer)

Solution (Python):
s,c=[int(i) for i in input().split()]

def cul(s,c):
  if s < c // 2:
    x = min(s,c//2)
    x += max(c - s * 2, 0)//4
  else:
    x = min(s,c//2)
  return x
print(cul(s,c))

Solution (Python):
s, c = map(int, input().split())
if 2*s<=c:
    
    print(s+(c-2*s)//4)
else:
    
    print(c//2)

Solution (Python):
n, m = map(int, input().split())
import sys

if n > int(m / 2):
    print(int(m / 2))
    sys.exit(0)

print(n + int((m - n * 2) / 4))

Solution (Python):
n,m=map(int,input().split())
if(m<2):
  print(0)
else:
  num=min(n,m//2)
  n-=num
  m-=2*num
  
  if(m<2):
    print(num)
  else:
    num+=m//4
    print(num)

Solution (Python):
s, c = map(int, input().split())
ac = 2*s + c
ans = 0
if c <= 2*s:
    print(c // 2)
elif ac // 4 > s:
    print((c - s*2) // 4 + s)
else:
    print(s)

Solution (Python):
n,m = map(int,input().split())

c = m // 2
ans = 0

if n >= c:
    ans = c
else:
    ans = n + (m-n*2) // 4
    
print(ans)

Solution (Python):
n,m=map(int,input().split())
if m<=2*n:
    print(m//2)
else:
    v=m-2*n
    print(v//4+(n))

Solution (Python):
N, M = map(int,input().split())
if M > N * 2:
    ans = N
    a = M - N * 2
    ans += a // 4
else:
    ans = M // 2
print(ans)

Solution (Python):
N,M = map(int,input().split(" "))

if M // 2 <= N:
	print(M//2)

else:
	M -= (N*2)
	print(N+M//4)

Solution (Python):
n,m=map(int,input().split())
if m<=2*n:
    print(m//2)
else:
    m=m-2*n
    print(n+m//4)

Solution (Python):
s,c=map(int,input().split())
if c<=s*2:
    print(c//2)
else:
    v=c-2*s
    print(s+v//4)

Solution (Python):
s,c=map(int,input().split())
if c<=s*2:
    print(c//2)
else:
    print(s+(c-2*s)//4)

Solution (Python):
n,m=map(int,input().split())
if m//2<=n:
    print(m//2)
else:
    print(n+(m-2*n)//4)

Solution (Python):
N, M = [int(i) for i in input().split()]
if 2 * N >= M:
    
    ans = M // 2
else:
    
    ans = N + (M - 2 * N) // 4
print(ans)

Solution (Python):
n, m = map(int, input().split())

res = 0
pair_m = m//2
if pair_m >= n:
    print(n + (m-n*2)//4)
else:
    print(pair_m)

Solution (Python):
S,C = list(map(int,input().split()))
ans = 0
ans += min(S,C//2)
if C - ans*2 > 0:
  ans += (C-ans*2)//4
print (ans)

Solution (Python):
def main():
    N, M = map(int, input().split())

    
    n_cc = M // 2
    n_scc = min(N, n_cc)

    
    n_s = N - n_scc
    n_c = M - n_scc * 2
    n_add_scc = n_c // 4
    

    ans = n_scc + n_add_scc

    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):
N,M=map(int,raw_input().split())
if M-2*N<0:
	print min(N,M/2)
else:
	print N+(M-2*N)/4

Solution (Python):
def solve():
    while 1:
        N, M = list(map(int, input().split(" ")))
        if M < 2:
            print(0)
        elif M >= 2 * N:
            print(N + (M - 2 * N) // 4)
        elif M < 2 * N:
            print(M // 2)

        break


solve()

Solution (Python):
A = input().split()
a = int(A[0])
b = int(A[1])
import math
if 2*a <= b:
 a = a
else:
 a = int(b/2)
 a = math.floor(a)
R = (2*a+b)/4
R = math.floor(R)
print(R)

Solution (Python):
N, M = map(int, input().split())
tmp = M // 2
if tmp < N:
    print(tmp)
else:
    x = ((tmp - N) * 2) // 4
    print(N+x)

Solution (Python):
a = list(map(int, input().split()))
b, c = a[0], a[1]
ans = min(b, c // 2)
if b > c // 2:
    c = c % 2
else:
    c -= b * 2
b -= min(b, c // 2)
if c > 3:
    ans += c // 4
print(ans)

Solution (Python):
s, c = map(int, input().split())

if s * 2 < c:
    ans = s + (c - 2 * s) // 4
else:
    ans = c // 2

print(ans)

Solution (Python):
s, c = map(int, input().split())

if s * 2 < c:
    ans = s + (c - 2 * s) // 4
else:
    ans = c // 2

print(ans)

Solution (Python):
N, M = [int(i) for i in input().split()]
if N >= M // 2:
    print(M // 2)
else:
    print(N + (M - 2 * N) // 4)

Solution (Python):
N, M = map(int, input().split())

if M >= 2 * N:
    M_left = M - 2 * N
    print(N + M_left // 4)
else:
    print(M // 2)

Solution (Python):
def main():
    n, m = map(int, input().split())

    x = m//2
    if n <= x:
        sumv = n + (x-n)//2
    else:
        sumv = x
    print(sumv)
    
    
if __name__ == "__main__":
    main()

Solution (Python):
n , m = map(int, raw_input().split())

tmp = m - (2 * n)
if tmp < 0:
        ans = m / 2
else:
        ans = 0
        ans += n
        ans += tmp / 4

print ans

Solution (Python):
nums = input().split()

N = int(nums[0])
M = int(nums[1])

sum = 0

if 2*N <= M:
    sum += N
    M -= 2*N
    if M >= 4:
        sum += M // 4
else:
    sum += M // 2    

print(sum)

Solution (Python):
N,M=map(int,input().split())
ans=0
if N<M:
    ans=N+((M-(N*2))//4)
else:
    ans=M//2
print(ans)

Solution (Python):



import sys
import re
import math
import collections
import itertools
import functools

DEBUG = True
DEBUG = False

def dbg(*args):
    if DEBUG:
        print("DBG: ", file=sys.stderr, end="")
        print(*args, file=sys.stderr)


def possible(N, M, k):
    if N >= k:
        return M >= 2*k
    else:
        M -= 2*(k-N)
        return M >= 2*k

def main():
    N, M = map(int, input().split())

    

    
    
    hi = M // 2 + 1
    lo = M // 4
    while hi - lo > 1:
        mid = (hi + lo) // 2
        if possible(N, M, mid):
            lo = mid
        else:
            hi = mid

    print(lo)

if __name__ == "__main__": main()

Solution (Python):
N,M=map(int, input().split())
if N>=M//2:
 ans=M//2
else:
  ans = N
  M -= 2 * N
  ans += M // 4
print(ans)

Solution (Python):
N, M = list(map(int, input().split(" ")))

if M < 2:
    print(0)
elif N >= M // 2:
    print(M // 2)
else:
    ans = N
    M -= 2*N
    ans += M // 4
    print(ans)

Solution (Python):
from collections import defaultdict


def main():
    N, M = map(int, input().split())
    a = min(N, M // 2)
    r = M - (2 * a)
    print(a + r // 4)


if __name__ == '__main__':
    main()

Solution (Python):
N, M = map(int, input().split())
if N >= M // 2:
  print(M // 2)
else:
  ans = N
  M -= 2 * N
  ans += M // 4
  print(ans)

Solution (Python):
def is_possible(N, M, m):
    if M >= 2 * m:
        r = M - 2 * m
        t = r // 2
        if N + t >= m:
            return True
    return False


def solve(N, M):
    a = 0
    b = 10 ** 20
    while b - a > 1:
        m = (a + b) // 2
        if is_possible(N, M, m):
            a = m
        else:
            b = m
    return a

N, M = map(int, input().split())
res = solve(N, M)
print(res)

Solution (Python):
s,c = map(int, input().split())
if c>=s*2:
    cleft = c-s*2
    print(s+cleft//4)
else:
    print(c//2)

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

scc = 0
if N <= (M/2):
    scc = N
    M -= N * 2
    scc += M // 4
else:
    scc = M // 2
    M -= scc

print(scc)

Solution (Python):
ar = raw_input().split(' ')
s = int(ar[0])
c = int(ar[1])

scc1 = min(s, int(c/2))
s = s - scc1
c = c - 2*scc1

scc2 = int(c/4)

print scc1 + scc2

Solution (Python):
s, c = map(int, input().split())
ans = 0

if s*2 <= c:
    c -= 2*s
    ans = s
    if c >= 4:
        ans = s + c//4
else:
    ans = c//2

print (ans)