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):
s,c = map(int,input().split())

ans = min(s,c//2)
c -= ans*2
print(ans + c//4)

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

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

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

Solution (Python):
import math


def main():
    N, M = list(map(int, input().split(' ')))
    if N >= M // 2:
        print(M // 2)
    else:
        t = math.ceil(((M // 2) - N) / 2)
        print((M - 2 * t) // 2)



if __name__ == '__main__':
    main()

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n,m=MI()
a,b=n,m//2
if a>b:
    ans=b
else:
    ans=(a+b)//2
print(ans)

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

if __name__ == '__main__':
    main()

Solution (Python):

import sys
input = sys.stdin.readline









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

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

print(ans)

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

Solution (Python):
n,m = 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())
if n >= m:
    print(m//2)
else:
    s = (m-n*2)//4
    print(s+n)

Solution (Python):

def main():
    n,m = map(int,input().split())
    s = n
    c = m
    scc = 0

    
    take = min(s,c//2) 
    scc += take
    s -= take
    c -= take * 2

    
    take = c // 4
    scc += take

    print(scc)


if __name__ == '__main__':
    main()

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

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

print(ans)

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

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

Solution (Python):


import sys






























def main():
    mod = 1000000007                
    inf = float('inf')              
    
    sys.setrecursionlimit(10**6)    
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())
    
    
    n, m = mi()
    if m <= n * 2:
        print(m // 2)
    else:
        
        print(n + (m - 2 * n) // 4)


if __name__ == "__main__":
    main()

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

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

print(ans)

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

Solution (Python):






import sys
input = sys.stdin.readline

import math

import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache






MOD = 10**9+7
INF = float('inf')






def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]


def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()


def DD(arg): return defaultdict(arg)



def inv(n): return pow(n, MOD-2, MOD)


kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret


def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr


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)
  return divisors


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


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


def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count


def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i])*n**i for i in range(len(str(X))))


def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count




N,M = IL()
if 2*N >= M:
  PE(M//2)
R = M-2*N
P(N+(R//4))

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

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

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

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

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

def Main(N, M):
    if N+3 >= M:
        return M//2
    else:
        c_remain = M-N*2
        return N+c_remain//4
    
print(Main(N, M))

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

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

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


if __name__ == '__main__':
    main()

Solution (Python):

import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

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

if __name__ == '__main__':
    main()

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 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:
    cnt = M//2
else:
    cnt = N
    M -= 2*cnt
    cnt += M//4
print(cnt)

Solution (Python):
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()

from collections import defaultdict, deque, Counter
from sys import exit
import heapq
import math
import copy
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

N, M = getNM()
if N >= M // 2:
    print(M // 2)
else:
    left = M - (2 * N)
    print(N + (left // 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 = map(int,input().split())
if n*2 >= m:
    print(m//2)
else:
    print(n + (m-n*2)//4)

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

if ans < m_2:
    make_s = m - ans*2
    ans += make_s // 4
    
print(ans)

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

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

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


if __name__ == '__main__':
    main()

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

scc = min(S, C // 2)

C -= scc * 2

print(scc + C // 4)

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

cnt = 0

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

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

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

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

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

print(ans)

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

m = int(M/2)

if N >= m:
    cnt = m
elif m > N:
    cnt = N
    M -= 2*N
    cnt += int(M/4)

print(cnt)

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

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

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

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

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

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

Solution (Python):
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
MOD = 10**9 + 7

n,m = map(int,input().split())
scc = min(n,m//2)
n -= scc
m -= scc*2

print(scc + m//4)

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

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

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

print(answer)

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

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

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
ans += min(n,m//2)
if m-2*n>0:
    ans+=(m-2*n)//4
print(ans)

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

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

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

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

    cnt = 0
    cnt = min(N, M//2)
    M -= 2*cnt
    if M > 0:
        cnt += M//4
    print(cnt)
        
if __name__ == "__main__":
    main()

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

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

print(count)

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

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

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

print(S)

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

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

print(ans)

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

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

if '__main__' == __name__:
    resolve()

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

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

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

m = m//2

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

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

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

Solution (Python):

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

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

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

def main():
    N, M = map(int, readline().rstrip().split())
    ans = min(N, M//2)
    M -= ans * 2
    ans += M//4
    print(ans)


if __name__ == '__main__':
    main()

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

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



if n == 0: 
    ans = m//4 

elif m == 0: 
    ans = 0 

elif n*2 <= m: 
    ans = n + (m-2*n)//4 

elif n*2 > m: 
    ans = m//2

print(ans)

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

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

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

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

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

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

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

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

print(ans)

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

if n < k:
    c = k//2  
    
    
    
    print(n+(c-n)//2)
else:
    c = k//2
    print(c)

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

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

print(ans)

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


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

Solution (Python):
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

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

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

Solution (Python):
def main():
  N, M = (int(_) for _ in input().split())
  ret = min(M // 2, N)
  M = M - 2 * ret
  ret += M // 4
  print(ret)

if __name__ == '__main__':
  main()

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

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

print(ans)

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

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

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

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

print(ans)

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

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

ans = 0

ans += min(N, M//2)

N -= ans
M -= ans * 2

ans += M // 4

print(ans)

Solution (Python):


nim, mike= map(int, input().split())
if 2*nim>=mike:
  data=mike//2
else:
  data=nim+(mike-2*nim)//4
print(data)

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

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

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


if __name__ == "__main__":
    main()

Solution (Python):
def slove(n, m):
    tmp = n if n < m // 2 else m // 2
    tmp2 = (m - tmp * 2) // 4
    return tmp + tmp2
    
if __name__ == "__main__":
    n, m = [int(i) for i in input().split()]
    print(slove(n, m))

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

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

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

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

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

ans = 0

if s == 1 and c == 1:
    print(ans)
    exit()

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

print(ans)

Solution (Python):
import sys

n, m = map(int, sys.stdin.readline().split())

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

if __name__ ==  '__main__':
    main()

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

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

Solution (Python):
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 

def ii(): return int(sys.stdin.readline().rstrip()) 
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) 
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]

def ss(): return sys.stdin.readline().rstrip() 
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) 
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]





n,m=mii()

c=m-n*2

if c>=0:
    print(n+c//4)
else:
    print(min(m//2,n))

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

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

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

print(ans)

Solution (Python):




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

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


if __name__ == "__main__":
    main()

Solution (Python):










"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""

""" n! mod m 階乗
mod = 1e9 + 7
N = 10000000
fac = [0] * N
def ini():
  fac[0] = 1 % mod
  for i in range(1,N):
    fac[i] = fac[i-1] * i % mod"""

"""mod = 1e9+7
N = 10000000
pw = [0] * N
def ini(c):
  pw[0] = 1 % mod
  for i in range(1,N):
    pw[i] = pw[i-1] * c % mod"""

"""
def YEILD():
  yield 'one'
  yield 'two'
  yield 'three'
generator = YEILD()
print(next(generator))
print(next(generator))
print(next(generator))
"""
"""def gcd_(a,b):
  if b == 0:
    return a
  return gcd_(a,a % b) 
"""def extgcd(a,b,x,y):
  d = a
  if b!=0:
    d = extgcd(b,a%b,y,x)
    y -= (a//b) * x
    print(x,y)
  else:
    x = 1
    y = 0
  return d"""


def readInts():
  return list(map(int,input().split()))
mod = 10**9 + 7
def main():
  n,m = readInts()
  print(min(m//2,(2*n+m)//4))
  
if __name__ == '__main__':
  main()

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

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

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

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

print(ans)

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

Solution (Python):
N,M=map(int,input().split())
if 2*N>M: print(M//2)
else: print((2*N+M)//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= list(map(int, input().split()))
if n*2>=m:
    print(m//2)
else:
    print(n+(m-n*2)//4)

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


dif = m - 2 * n


if dif < 0:
    ans = m // 2

else:
    ans = n + dif // 4

print(ans)

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

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

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

Solution (Python):

import math
import heapq
import bisect
import numpy as np
from collections import Counter, deque


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

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

print(ans)

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

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

print(ans)

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

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

cnt = 0
if s <= c // 2: 
    cnt += s
    c -= 2 * s
    s = 0
else:
    cnt += c // 2
    s -= c // 2
    c = 0

cnt += c // 4

print(cnt)

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

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

Solution (Python):

n,m=map(int,input().split())
first=min(n,m//2)
n -=first
m-=first*2
second = m//4
print(second+first)

Solution (Python):
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

n, m = na()

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

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

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

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

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

a = c //2
if s >= a:
    ans = a
else:
    b = c - 2 * s
    ans = s + b//4
print(ans)

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

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

Solution (Python):
import math

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

if s*2>c:
  print(int(c/2))

else:
  count=s
  c-=s*2
  count+=math.floor(c/4)
  print(count)

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

Solution (Python):



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


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

Solution (Python):

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

ans = 0


made_scc = min(N,int(M/2))
ans += made_scc

M -= 2 * made_scc

ans += int(M/4)

print(ans)

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

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

n-=val
m-=2*val
ans=val

ans+=m//4
print(ans)

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

if __name__ == '__main__':
    solve()

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

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

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

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

Solution (Python):
S = list(map(int,input().split()))
N=S[0]
M=S[1]
N1=0
M1=0
count = 0

if 2*N<=M:
    count = N
    N1=0
    M1=M-2*N
    count+=M1//4
elif M<2*N:
    count += M//2
print(count)

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

if s >= c:
    
    scc = int(c/2)
    print(scc)
    exit()

if s < c:
    
    scc = s
    cc = c-s*2
    scc += int(cc/4)
    print(scc)
    exit()

Solution (Python):

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

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

if N>=O:
  print(O)
else:
  P = (N+O)//2
  print(P)

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





if n * 2 <= m:
    l = (m - 2 * n) // 4
    ans1 = min(n+l, (m-l*2)//2)
    ans2 = min(n+l+1, (m - (l+1)*2)//2)
    print(max(ans1, ans2))

else:
    print(m//2)

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 = map(int, input().split())

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

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

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


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

print(ans)

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

if 2*n == m:
    print(n)

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

else:
    ans = m//2
    print(ans)

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

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

    print(ans)

if __name__ == '__main__':
    resolve()

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

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

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 = [int(i) for i in input().split()]


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

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

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
if N >= M // 2:
    ans += M // 2
    N -= M // 2
    M = 0
else:
    ans += N
    M -= 2 * N
    N = 0
    ans += M // 4

print(ans)

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

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N,M=MI()
    
    if M>2*N:
        M+=N*2
        print(M//4)
    else:
        print(min(N,M//2))

main()

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

Solution (Python):


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

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

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

Solution (Python):
n,m = map(int,input().split())
print(min(n, m//2) + max(0, (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)