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())
ans = 0

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

print(ans)

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

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

Solution (Python):
n,m=[int(i) for i in input().split()]
print(min(m//2,(2*n+m)//4))

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

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

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 n > m/2:
    print(m//2)
else:
    print(n + (m-2*n)//4)

Solution (Python):
def examC():
    N, M = LI()
    cur = int(0)
    remain = M - N*2
    if remain>=0:
        cur += N
        cur += remain//4
    else:
        cur += M//2
    print(cur)

import sys
import copy
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examC()

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

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

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

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

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

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

print(ans)

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

c = min(n, m // 2)
amari = m - (c * 2)
scc = math.floor(amari / 4)
print(int(scc + c))

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

Solution (Python):
def main():
    N, M = (int(i) for i in input().split())
    ans = 0
    if N == M // 2:
        ans = N
    elif 2*N <= M:
        M -= 2*N
        ans += N
        if M >= 4:
            ans += M//4
            M //= 4
    elif N >= M//2 and M//2:
        ans += M//2
    print(ans)


if __name__ == '__main__':
    main()

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

    print(ans)

if __name__ == "__main__":
    main()

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

    print(ans)

if __name__ == "__main__":
    main()

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

res = 0

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

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

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




num=0

if(2*N < M):
    
    dif = M - 2 * N 
    num = N + (dif // 4)
else:
    num = M // 2

print(num)

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

Solution (Python):
n, m = list(map(int, input().split()))
if n >= m:
    print(m//2)
else:
    m += n * 2
    print(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 = [int(x) for x in input().split()]

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

print(res)

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

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

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

Solution (Python):

import sys


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


    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    M = int(next(tokens))  
    solve(N, M)

if __name__ == '__main__':
    main()

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

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


main()

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

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

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((M-2*N)//4 + N)

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

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

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

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

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


def check(k):
    n1=n 
    m1=m 
    if k>=n:
        req=(k-n1)*2+2*k 
    else:
        req=2*k 
    return req<=m  
lo=0 
hi=10**30 
ans=0 
while lo<=hi:
    mi=(lo+hi)>>1 
    if check(mi):
        ans=mi 
        lo=mi+1 
    else:
        hi=mi-1 
print(ans)

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

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

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

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

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

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

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

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

Solution (Python):


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

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

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

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

if 2*n>=m:
    print(m//2)
    exit()

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

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

if S*2 < c:
  tot = S
  c = c-S*2
  tot += c//4
else:
  tot = c//2
  
print(tot)

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

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

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

Solution (Python):


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

count=0
temp=min(N,M//2)
count+=temp
N-=temp
M-=2*temp

if M>0:
    count+=M//4

print(count)

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

Solution (Python):
import sys

stdin = sys.stdin

ns = lambda : stdin.readline().rstrip()
ni = lambda : int(ns())
na = lambda : list(map(int, stdin.readline().split()))

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

main()

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())

c = m - (n*2)
s = c // 4

if c >= 1:
    print(s + n)
else:
    print(m // 2)

Solution (Python):

s, c = map(int, input().split( ))
if s>= c//2:
    print(c//2)

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

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

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

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

if 2 * N >= M:
    print(M // 2)
    sys.exit()

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

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(c//2 if 2*s>c else s+(c-2*s)//4)

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

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

cnt = 0

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

print(cnt)

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())

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

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

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

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

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

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

x = max(0, (M - 2 * N) // 4)
N += x
M -= 2 * x

print(min(N, M // 2))

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

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

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

n = N
m = M // 2
ans = min(n, m)
ans += max((m - ans)//2, 0)
print(ans)

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

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

def main():
    a = min(N, M // 2)
    b = (M - a * 2) // 4
    print(a + b)

if __name__ == '__main__':
    main()

Solution (Python):


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

pair = min(n, m // 2)
c_left = m - pair * 2
pair_c = c_left // 4
ans = pair + pair_c
print(ans)

Solution (Python):
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce



sys.setrecursionlimit(2147483647)
INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


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

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

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

s, c = N, M // 2

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

Solution (Python):
from sys import stdin
N,M = [int(x) for x in stdin.readline().rstrip().split()]
if N*2 >= M:
    if M == 1:
      print(0)
    else:
      print(M//2)
else:
    ans = N + ((M-2*N)//4)
    print(ans)

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

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

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

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())
print(min(max(n,n+(m-n*2)//4),m//2))

Solution (Python):

import sys
input = sys.stdin.readline
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7



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

count = 0

if N*2 <= M:
    count += N
    M -= N*2

    count += (M // 4)
else:
    count += (M // 2)

print(count)

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

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


if __name__ == "__main__":
    resolve()

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

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

ans = min(N, M // 2)

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

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

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

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

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

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

print(answer)

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

Solution (Python):
n,m = map(int,input().split())
if n*2 <= m:
  x = (m-2*n)//4
  print(min(n+x,(m-2*x)//2))
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):
import sys
input = sys.stdin.readline

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

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

if __name__ == "__main__":
    main()

Solution (Python):

import sys


def solve(N: int, M: int):
    if(N > M//2):
        print(M//2)
    else:
        print(N+(M-2*N)//4)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    M = int(next(tokens))  
    solve(N, M)

if __name__ == '__main__':
    main()

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

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

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

Solution (Python):
S,c=map(int,input().split())
if S>c//2:print(c//2)
else:Z=(c//2-S)//2;print(S+Z)

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

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

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

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

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

res = 0

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

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

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

print(ans)

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

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

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

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

i = (C - 2 * S) // 4

print(S + i)

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

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

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

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

Solution (Python):
import sys
import copy
import string
import  math
from _bisect import *
from collections import *
from operator import itemgetter
from math import factorial
"""
from fractions import gcd
def lcm(x, y):
    return (x * y) // gcd(x, y)
"""
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

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

Solution (Python):
N,M=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 2 * N >= M:
    ans = M // 2
else:
    ans = (M - 2 * N) // 4 + N

print(ans)

Solution (Python):
N,M = map(int,input().split())
count = 0
while(1):
    if N*2<=M and N!=0:
        count += N
        M -= N*2
        N = 0
        continue
    elif N*2>M and M>1:
        count += M//2
        N += M//2
        M = M%2
        continue
    elif N==0 and M>=4:
        N += M//4
        M -= N*2
        continue
    else:
        break
print(count)

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):
N, M = [int(x) for x in input().split()]
ret = min(N, M // 2)
m = M - 2 * ret
if m:
  ret += m // 4
print(ret)

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

Solution (Python):


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

c = 0


if M >= N * 2:
    
    c += N
    
    c += math.floor((M - N * 2) / 4)
else:
    
    max_pair = math.floor(M / 2)
    c += max_pair

c = int(c)
print(c)

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

ans = 0

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

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

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

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

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

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

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

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

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

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

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



if __name__ == '__main__':
    print(main())

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

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

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

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

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

print(scc)

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

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

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

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

Solution (Python):
import bisect
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

S, C = list(map(int, sys.stdin.readline().split()))
if S * 2 >= C:
    ans = C // 2
    print(ans)
    exit()

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

Solution (Python):

import sys
INF = float("inf")


def solve(N: int, M: int):
    if M//2 < N:
        print(M//2)
    else:
        print(N + (M-N*2)//4)

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    M = int(next(tokens))  
    solve(N, M)


if __name__ == '__main__':
    main()

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

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

print(ans)

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

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

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

ans += M // 4

print(ans)

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

Solution (Python):

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

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

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 > N * 2:
    tmp = (M - N * 2) // 4   
else:
    tmp = 0
ans = min(N, M//2) + tmp
print(ans)

Solution (Python):
import os,re,sys,operator
from collections import Counter,deque
from operator import itemgetter
from itertools import accumulate,combinations,groupby
from sys import stdin,setrecursionlimit
from copy import deepcopy
import heapq

setrecursionlimit(10**6)

n,m=map(int,stdin.readline().rstrip().split())
s=min(n,m//2)
c=max((m-n*2)//4,0)
print(s+c)

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):
""" abc055_a """

import sys

H = pow(10, 9) + 7

def _main():
    n_s, n_c = map(int, sys.stdin.readline().split(' '))

    if 2 * n_s <= n_c:
        result = n_s + int((n_c - n_s * 2) / 4)
    else:
        result = int(n_c / 2)

    print(result)

if __name__ == '__main__':
    _main()

Solution (Python):

import collections
import itertools
import sys

def getint(): return int(input())
def getints(): return list(map(int, input().split()))

n,m=getints()

res = min(n,m//2)

m=m-res*2

res = res + m // 4

print(res)

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

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

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

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

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

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

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

Solution (Python):
def solve(S, c):
    if S > c//2:
        return c//2
    elif S == c//2:
        return c//2
    if S < c//2:
        cnt = S
        c -= S * 2
        S -= S
        assert S == 0
        assert c > 0
        return cnt + c//4


S, c = [int(x) for x in input().split()]
print(solve(S, c))

Solution (Python):
n, m = map(int, input().split())
restC = m - n * 2

print(n + restC // 4 if restC >= 0 else m//2)

Solution (Python):

import sys, math, fractions, itertools


def solve(N: int, M: int):
    if N >= M // 2:
        print(M // 2)
    else:
        print(N + (M - N*2) // 4)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    M = int(next(tokens))  
    solve(N, M)

if __name__ == '__main__':
    main()

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

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

ans = min(s,c//2)
s -= ans
c -= ans * 2
if c > 0:
    ans += c // 4

print(ans)

Solution (Python):
import sys

def resolve():
    N, M = map(int, input().split())
    if N >= M // 2:
        ans = M // 2
        print(ans)
        return

    x = (M - 2*N) // 4

    N += x
    M -= 2 * x

    ans = min(N, M // 2)
    print(ans)
    return



if __name__ == "__main__":
    resolve()

Solution (Python):
s, c = list(map(int, input().split()))
use_s = 0
hoge = int(c / 2)
if(hoge < s):
  use_s = hoge
else:
  use_s = s
remain = c - (2 * use_s)
remain_c = int(remain / 4)
amount = use_s + remain_c
use_c_only = int(c / 4)
if(amount > use_c_only):
	print(amount)
else:
	print(use_c_only)

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

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

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

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

    ans += M // 4
else:
    ans = M // 2

print(ans)

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


main()

Solution (Python):

import itertools
from collections import Counter
from collections import defaultdict
import bisect
from heapq import heappush, heappop

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

if __name__ == '__main__':
    main()

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

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



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

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

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

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

Solution (Python):

def main():
    s, c = map(int, input().split())

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






if __name__ == '__main__':
    main()

Solution (Python):
def smaller(x, y):
	if x < y:
		return x
	return y

N, M = map(int, input().split())
scc = smaller(N, M//2)
N -= scc
M -= 2*scc
cccc = M // 4
print(scc+cccc)

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

if int(m/2)-n>=0:
    ans=n
    m -= ans*2

    if m/4>=1:
        ans += int(m / 4)

else:
    ans=int(m/2)

print(ans)

Solution (Python):
import math
import itertools

INF = 10**9+7
n = 0
def main():
	n,m = map(int,input().split())
	ans = 0
	if(n*2<m):
		ans += n
		m -= 2*n
	else:
		print(int(m/2))
		return
	ans += int(m/4)
	print(ans)

main()

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

if __name__ == '__main__':
    main()

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

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

Solution (Python):

import sys
sys.setrecursionlimit(300000)


def solve(N: int, M: int):
    if N * 2 >= M:
        ret = M // 2
    else:
        left = M - N * 2
        ret = N + left // 4
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    M = int(next(tokens))  
    solve(N, M)

if __name__ == '__main__':
    main()

Solution (Python):
n,m=map(int,input().split())
ans=0
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)
    exit()

print(n+(m-2*n)//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())

ret = 0

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

print(ret)