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



Sample input:
1 6


Sample output:
2

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-



s,c = map(int, input().split())
ans = min(s,c//2)
print(ans+(c-2*ans)//4)

Submission status: Accepted

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

N, M = map(int, input().split())
ans = 0
s = smaller(N, M//2)
ans += s
M -= 2*s
ctos = M // 4
ans += ctos
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding:utf-8 -*-
"""考え方
・"Scc"という組をできるだけ多く作りたい


"""
def solve():
    sN, cN = list(map(int, input().split()))

    if 2*sN < cN:
        # SSccccc
        # SScccc で二組作れる。
        # 余ったcで、できるだけScc組を作る
        ans = sN
        restC = cN - 2*sN  # 余ったCの数

        # cが4つあれば新たにSccが作れる
        ans += restC//4
    else:
        # SSccc
        # cの数が少ない場合
        ans = cN//2
    print(ans)


if __name__ == "__main__":
    solve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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

if 2*n <= m:
	ans = n
	m -= 2*n

	ans += m//4

else:
	ans = m // 2

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

md = m - 2*n
nd = n - m//2
## s型が無くなるまでsccを作った場合
if md >= 0:
    m = md
    ans = n + m//4
## c型が無くなるまでsccを作った場合
elif nd >= 0:
    ans = m//2

print(ans)

Submission status: Accepted

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

md = m - 2*n
nd = n - m//2
if md >= 0:
    m = md
    ans = n + m//4
elif nd >= 0:
    ans = m//2

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
List=[int(j) for j in input().split()]
a=List[0]
b=List[1]

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

Submission status: Accepted

Solution code:
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    n , m = f()
    cnt = min(n*2, m)
    ans = cnt//2
    remain = m - ans*2


    print(ans + remain//4)

solve()

Submission status: Accepted

Solution code:
import math

ns, nc = map(int, input().split())
if ns >= nc // 2:
    print(nc // 2)
else:
    x = math.ceil((nc - 2 * ns) / 4)
    ns += x
    nc -= 2 * x
    print(min(ns, nc // 2))

Submission status: Accepted

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

num = min(N, M // 2)

print((M - num * 2) // 4 + num)

Submission status: Accepted

Solution code:
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

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

#cが多い
if 2*N < M:
    ans = N
    ans += (M - 2*N)//4
else:
#Sが多い
    ans = M//2
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
if n>=m/2:
  print(m//2)
else:
  x=(m-2*n)//4
  y=x+1
  z1=min(n+x,(m-2*x)//2)
  z2=min(n+y,(m-2*y)//2)
  print(max(z1,z2))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

m //= 2

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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


def submit():
    n, m = read_input()

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

if __name__ == '__main__':
    submit()

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
n,m = map(int,input().split())
Cpiece = m-m%2
ans = 0
if n*2 <= Cpiece:
    ans = math.floor(n+(Cpiece-n*2-(Cpiece-n*2)%4)/4)
else:
    ans = math.floor(Cpiece/2)
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

if N < M//2:
    scc_min = max(1, N)
else:
    scc_min = M//2
scc_max = N + M//2

while scc_min < scc_max:
    scc = (scc_min + scc_max) // 2
    excess_c = M - scc*2
    if scc_min + 1 == scc_max:
        break
    if excess_c > 0 and excess_c//2 + N >= scc:
        scc_min = scc
    else:
        scc_max = scc - 1

excess_c = M - scc_max*2
if excess_c > 0 and excess_c//2 + N >= scc_max:
    print(scc_max)
else:
    print(scc_min)

Submission status: Accepted

Solution code:
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def _I(): return int(sys.stdin.readline())
def _F(): return float(sys.stdin.readline())
def pf(s): return print(s, flush=True)

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

print(ans)

Submission status: Accepted

Solution code:
S, C = map(int, input().split())
if S >= C // 2:
    print(C // 2)
    exit()
C -= 2 * S
print(S + C // 4)

Submission status: Accepted

Solution code:
n, m = [int(item) for item in input().split()]
# Enough s
if n * 2 >= m:
    print(m//2)
# Enough m 
else:
    amari = m - n*2
    print(amari//4 + n)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from math import floor
n,m=map(int,input().split())
a=floor(m/2)
if n>a:
    print(a)
else:
    print(floor((n+a)/2))

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    s_count, c_count = map(int, input().split())
    if s_count > c_count // 2:
        print(c_count // 2)
    else:
        print(s_count + (c_count - s_count * 2) // 4)

Submission status: Accepted

Solution code:
import sys

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

    if N >= M // 2:
        ans = M // 2
        #N -= M // 2

        #ans += N // 2

        return ans

    else:
        ans = N
        M -= 2 * N

        ans += M // 4

        return ans


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

Submission status: Accepted

Solution code:
from functools import reduce
import math

def main():
    # N! を求める
    # f = math.factorial(N)
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    # 1e10

    # 初期値用:十分小さい数(-100億)
    # -1e10
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    N,M = (int(_) for _ in input().split())
    if(M<2):
        print(0)
        exit()
    if N>M//2:
        N = N-(N - M//2)
    ans = (N*2 + M)//4
    # while True:
    #     N = N -1
    #     M = M -2
    #     ans = ans + 1
    #     if(N<=0 or M<=0):
    #         break
    # if(N<=0 and M>0):
    #     ans = ans + M//4
             
    print(ans)
    
if __name__ == '__main__':
    main()

Submission status: Accepted

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

ans = 0
#手持ちのSで作れる分だけSccを作る
if c <= 2*s:
  ans += c // 2
  c = c%2
  s = 0
else:
  ans += s
  c = c - 2*s
  s = 0
  


#print(s)
#print(c)
#print(ans)
#まだcが余ってたらSccを作る
if c >= 4:
  ans += c // 4
  
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
ans1 = 0
import math
if N <= M:
    ans1 = 0
    if 2 * N <= M:
        ans1 = N
        M -= ans1 * 2
        ans2 = math.floor(M / 4)
        print(int(ans1 + ans2))
    else:
        ans1 = math.floor(M / 2)
        print(ans1)
else:
    print(int(math.floor(M / 2)))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

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

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

Submission status: Accepted

Solution code:
def scc_puzzle(N: int, M: int) -> int:
    if 2 * N < M:
        # c が余る場合、余った c が 4 つごとに
        # 1 組みの `Scc` が作れる。
        return N + (M - 2 * N) // 4

    return M // 2


if __name__ == "__main__":
    N, M = map(int, input().split())
    ans = scc_puzzle(N, M)
    print(ans)

Submission status: Accepted

Solution code:
# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)	a=int(input())	a=5
# 1 2	| x,y = s_inpl()   |	x=1,y=2
# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　	li = inpl()	li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']

# INPUT
# 3
# hoge
# foo
# bar
# ANSWER
# n=int(input())
# string_list=[input() for i in range(n)]

import math
import copy
from collections import defaultdict, Counter
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
from bisect import bisect_left, bisect_right
# import numpy as np

def i_inpl(): return int(input())
def s_inpl(): return map(int,input().split())
def l_inpl(): return list(map(int, input().split()))
INF = float("inf")

N, M = s_inpl()

diff = M-N*2
# Sが使え切れる場合
if diff>=0:
    M = M-N*2
    ans = N
    ans += M//4
    print(ans)
else:
    print(M//2)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(count)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S,C=map(int,input().split())
#X回操作をするとS+x,c-2x 2S+2x=c-2x 4x=c-2s xはほぼc-2s//4
if C<=2*S:
    print(C//2)
else:
    ans=S
    for x in range(max(0,(C-2*S)//4-10),(C-2*S)//4+10):
        if C-2*x<2*(S+x):
            break
        ans=S+x
    print(ans)

Submission status: Accepted

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

def f():
    if n*2 > m:
        return m//2
    
    return n + (m-n*2) // 4

print(f())

Submission status: Accepted

Solution code:
N,M=map(int,input().split()) #SがN個、cがM個
Ans=0 #答えを入れる変数
if 2*N<=M: #cc→Sを使わないとcが余る場合
  Ans+=N
  M=M-2*N
  Ans+=M//4
  print(Ans)
elif 2*N>M: #cc→Sを使わないとSが余る場合
  Ans+=M//2
  print(Ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def main():
    N, M = map(int, input().split())
    M //= 2
    print(min(M, (N+M)//2))


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007

#A
def A():
    n = II()
    ans = n * 800
    print(ans-(n//15)*200)
    return

#B
def B():
    n = II()
    print(math.factorial(n)%mod)
    return

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

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    C()

Submission status: Accepted

Solution code:
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A
def A():
    n = I()
    print(n*800-200*(n//15))

#B
def B():
    k = I()
    ans = 0
    for i in range(1,k):
        for j in range(i+1,k+1):
            if (i%2)^(j%2):
                ans += 1
    print(ans)

#C
def C():
    x,t = LI()
    print(max(0,x-t))

#D
def D():
    n = I()
    ans = 1
    for i in range(1,n+1):
        ans *= i
        ans %= mod
    print(ans)

#E
def E():
    x,y,s,t = LI()
    return

#F
def F():
    n = I()
    x = LI()
    a = sorted(x)
    for i in range(n):
        j = bisect.bisect_left(a,x[i])
        if j >= n//2:
            print(a[n//2-1])
        else:
            print(a[n//2])

#G
def G():
    n,m = LI()
    if m <= 2*n:print(m//2)
    else:
        ans = n
        m -= 2*n
        ans += m//4
        print(ans)

#H
def H():
    return

def J():
    return

def K():
    return

#Solve
if __name__ == "__main__":
    G()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, M = map(int, raw_input().split())
ans = min(N, M/2)
M -= ans*2
if M>0:
  ans += M/4
print ans

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#ABC055C
S,C=map(int,input().split())
if S>=C//2:
	print(C//2)
else:
	print(S+(C-2*S)//4)

Submission status: Accepted

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

#(N+x)*2<M-2*x

#N*2+x*2<M-2*x

#4*x<M-N*2

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
#!/usr/bin/python3
# abc055_a
"""
Scc Puzzle
"""

def answer():
    """
    Sが余るときとcが余るときに分けて考える。
    """
    S, c = map(int, input().split())

    if S >= c//2:
        return int(c//2)

    return int(S + (c - S*2) // 4)


def main():
    """
    答えを出力
    """
    print(answer())


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def main():
    n, m = map(int, input().split())
    print(solve(n, m))

def solve(n, m):
    x = n * 2 + m
    return min(x // 4, m // 2)

main()

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys

def main():
	s_num, c_num = map(int, input().split(" "))
	
	counts = 0
	if c_num >= (s_num * 2):
		counts = counts + s_num
		c_num = c_num - (s_num * 2)
		s_num = 0
	elif s_num != 0:
		tmp = c_num // 2
		counts = counts + tmp
		s_num = s_num - tmp
		c_num = c_num - (tmp * 2)
		
	tmp = c_num // 4
	
	print(counts + tmp)
	
if __name__ == "__main__":
	main()

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
#!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A

#B

#C
n,m = LI()
if m <= 2*n:print(m//2)
else:
    ans = n
    m -= 2*n
    ans += m//4
    print(ans)
#D

#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T

Submission status: Accepted

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

x = c // 2
cnt = min(s, x)
c -= cnt * 2
    
if c > 3:
    cnt += c // 4
    
print(cnt)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
N, M = map(int, input().split(" "))
if M - 2*N > 0:
    ans = N + (M - 2*N) // 4
elif M - 2*N == 0:
    ans = N 
else:
    ans = M // 2
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def solve(N, M):
    ans = min(N, M // 2)
    M -= ans * 2
    ans += M // 4
    return ans


if __name__ == "__main__":
    N, M = map(int, input().split(" "))
    print(solve(N, M))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s, c = map(int, input().split())
print(min(s, c//2)+(c//2 -min(s, c//2))//2)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def num(N, M):
    return min(N, M//2)

N, M = map(int, input().split())
if 2*N >= M:
    print(M//2)
else:
    a = (M - 2*N) // 4
    cand = []
    for i in range(a, a+1):
        cand.append(num(N+i, M-2*i))
    print(max(cand))

Submission status: Accepted

Solution code:
def num(N, M):
    return min(N, M//2)

N, M = map(int, input().split())
if 2*N >= M:
    print(M//2)
else:
    a = (M - 2*N) // 4
    cand = []
    for i in range(a, a+4):
        cand.append(num(N+i, M-2*i))
    print(max(cand))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, M = map(int, input().split()) # N: number of S, M: number of c
if N > M/2:
    print(M//2)
else:
    print((N * 2 + M) // 4)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,m = (int(i) for i in input().split())
if n >= m//2 :
  print(m//2)
else:
  ans = n
  m = m - 2*n
  ans += m//4
  print(ans)

Submission status: Accepted

Solution code:
import math
N,M = map(int,input().split())

ans = 0

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

Submission status: Accepted

Solution code:
# coding:utf-8

import sys
# from collections import Counter, defaultdict

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

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


n, m = LI()

scc = min(n, m // 2)
n, m = 0, m - 2 * scc
scc2 = m // 4

print(scc + scc2)

Submission status: Accepted

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

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

Submission status: Accepted

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

ans = min(S,C//2)
if C >= S*2:
    C = C - S*2
    ans += C//4

print(ans)

Submission status: Accepted

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

ans=0
if 2*n<=m:
    ans+=n
    n=0
    m-=2*ans
elif 1<=n and 2<=m:
    ans+=m//2
    n-=m
    m-=(m//2)*2
   

ans+=m//4

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
int_s, int_c = map(int, input().split())


if int_s * 2 == int_c:
    print(int_s)
elif int_s * 2 > int_c:
    print(int_c // 2)
else: # int_s * 2 < int_c
    zan_c = int_c - int_s * 2
    print(int_s + zan_c // 4)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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()

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

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