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:
# encoding: utf-8
N, M = map(int, input().split())

N_tmp = N
M_tmp = M

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

if 2*N >= M: #"S"が断然多い
    ans = M //2
else: #"cが余っている"
    ans = (2*N + M)//4
    
print(ans)

Submission status: Accepted

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

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

else:
    print(M // 2)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

n, m = [int(i) for i in input().split()]
# c:「m-2」とすれば,s:「n+1」と出来る
count = 0
# if int((m-2*n)/4) >= 0:
if m - 2*n > 0:
    count = max(count, min(n + int((m - 2 * n) / 4),
                           int(m / 2 - (m - 2 * n) / 4)))
    # print(count)
    # if math.ceil((m-2*n)/4) >= 0:
    count = max(count, min(n + math.ceil((m - 2 * n) / 4),
                           int(m / 2) - math.ceil((m - 2 * n) / 4)))
    # print(count)
count = max(count, min(n, int(m / 2)))
print(count)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

ans += m//4
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(1000000)


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


# Binary converter
def to_bin(x):
    return bin(x)[2:]


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


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


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

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

    return v


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


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

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

    return v


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

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

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

        cps = n_cps[:]

    return dfk


# Depth First Search (+Distance)
def dfs_d(v, pre, dist):
    """
    v:  現在のノード
    pre: １つ前のノード
    dist: 現在の距離

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

    global D
    global D_dfs_d

    D_dfs_d[v] = dist

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

    return


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


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

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

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

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

    return result

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

# --------------------------------------------

dp = None


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

    # Sを新たに作る必要がない場合
    if S * 2 >= C:
        print(C // 2)
        return

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

    print(ans)


main()

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

count = min(n, m // 2)

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
N, M = map(int, input().split())

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

elif N > M//2:
    # print(M//2 + (N - M//2)//2)
    print(M//2)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

if N*2 <= 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())

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

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

print(cnt_peice(n,m))

Submission status: Accepted

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

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

print(count)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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


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


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


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

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

    ans += M // 4
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

if M <= 1:
    ans = 0

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0

# Sをつかう
if M-2*N >=0:
  ans += N
else:
  ans += M//2

M -= 2*ans

# Cだけ
ans += M // 4

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
stdin = sys.stdin

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

n,m = li()

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, M=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 = (int(i) for i in input().split())

ans = 0

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

print(ans)

Submission status: Accepted

Solution code:
N,M=(int(i) for i in 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:
    pair = n
    m = m - 2*n
    pair = pair + (m//4)
else:
    pair = m//2

print(pair)

Submission status: Accepted

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

S = M - N * 2

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def getinputdata():

    # 配列初期化
    array_result = []
    
    data = input()

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

    flg = 1

    try:

        while flg:

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

            else:

                flg = 0
    finally:

        return array_result

arr_data = getinputdata()

#sの数
n = int(arr_data[0][0])
#cの数
m = int(arr_data[0][1])

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

cnt=num

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

#cnt+=n//3
cnt+=m//4

print(cnt)

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#a = int(input())
#b,c = map(int,input().split())
#s = input()
#list_s = list(input())
#list_int = list(map(int,input().split()))

#list = [0 for i in range(n)]
#dp = [[0 for i in range(A)] for j in range(B)]

#list_int 並べて出力 print (' '.join(map(str,ans_li)))
#list_str 並べて出力 print (' '.join(list))

# 2進数 format(10, 'b') # '1010'

# aa=[int(input()) for i in range(n)]

#for i,name in enumerate(list)

''' 二次元配列を一列ずつ
for i in ans:
	print(*i)
'''
''' heapq
queue = []
heapq.heapify(queue) #heapqの作成
heapq.heappush(queue,num) #numのpush(値の追加)
pop = heapq.heappop(queue) #numのpop(最小値の出力)
pop = heapq.heappushpop(queue,num) #push -> pop

'''

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


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

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

Submission status: Accepted

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

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

# c→Sは変換できるので、合算して考える
if c >= S*2:
    print((S*2 + c) // 4)
# S→cには変換できないので、完全にCの数次第
else:
    print(c // 2)

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

a=m//2

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

print(ans+m//4)

Submission status: Accepted

Solution code:
import math

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

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

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

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

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

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

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:

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

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

    print(ans)

if __name__ == "__main__":
        main()

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:
import math
n, m = map(int, input().split())
if n < m:
  print(n + (m - n * 2) // 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:
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)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

t = min(s,c/2)

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

Submission status: Accepted

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

print(m())

Submission status: Accepted

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

Submission status: Accepted

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

# AtCoder Beginner Contest
# Problem C

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

    # See:
    # https://www.youtube.com/watch?v=hetSRNLGOtk
    print(min(m // 2, (2 * n + m) // 4))

Submission status: Accepted

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

# AtCoder Beginner Contest
# Problem C

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

comb += m // 4

print(comb)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

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

Submission status: Accepted

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


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

ans+=m//4
print(ans)

Submission status: Accepted

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

counter = counter + m //4 

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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


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

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
if 2*n>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 m<=2*n:
	answer = (m-m%2)//2
else:
	answer = n
	a = m-2*n
	answer += (a-a%4)//4
print(answer)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

c = m // 2
ans = 0

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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 = [int(i) for i in input().split()]
if 2 * N >= M:
    # SccをMの値が許す限り作る
    ans = M // 2
else:
    # SccをN個作り、残りのccccからSccを作る
    ans = N + (M - 2 * N) // 4
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

    # Sから作れる数
    n_cc = M // 2
    n_scc = min(N, n_cc)

    # cから作れる数
    n_s = N - n_scc
    n_c = M - n_scc * 2
    n_add_scc = n_c // 4
    # n_c -= n_add_scc * 4

    ans = n_scc + n_add_scc

    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

        break


solve()