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

Submission status: Accepted

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

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)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

if n > m // 2:
    print(m // 2)
else:
    ans = n
    m -= n * 2
    ans += m // 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 * n) // 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=map(int,input().split())
print(min(n,m//2)+max(0,(m-n*2)//4))

Submission status: Accepted

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

Submission status: Accepted

Solution code:

import sys
input = sys.stdin.readline
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
# A = [ int(input()) for _ in range(N) ]
##############################

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)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

ans = min(N, M // 2)

if (ans == N):
  ans += (M // 2 - N) // 2

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*n)//4)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys


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


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    solve(N, M)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

print(S + i)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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:
# https://atcoder.jp/contests/abc055/tasks/arc069_a
# C - Scc Puzzle
import math
N, M = list(map(int, input().split()))

c = 0
# 使えるSを全部使えるか
# CがM * 2個いる
if M >= N * 2:
    # Sを全部使う
    c += N
    # 残っているcだけでSccを作れるだけ作る
    c += math.floor((M - N * 2) / 4)
else:
    # Sを使えるだけ使う
    max_pair = math.floor(M / 2)
    c += max_pair

c = int(c)
print(c)

Submission status: Accepted

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

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

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())
M2 = M + N*2
print(min(M2//4, M//2))

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(scc)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
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))  # type: int
    M = int(next(tokens))  # type: int
    solve(N, M)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

ans += M // 4

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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

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, input().split())    # N:Sの数, M:cの数

if M > N * 2:
    tmp = (M - N * 2) // 4   # tmp:Sをcから作る数
else:
    tmp = 0
ans = min(N, M//2) + tmp
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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


# if S < c//2: c が多い
# if S > c//2: c が足りない

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
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


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    solve(N, M)

if __name__ == '__main__':
    main()

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

if __name__ == '__main__':
    main()

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:
#!/usr/bin/env python3
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))  # type: int
    M = int(next(tokens))  # type: int
    solve(N, M)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

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

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:

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

Submission status: Accepted

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

ret = 0

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

print(ret)

Submission status: Accepted

Solution code:
from math import ceil, floor
n, m = map(int, raw_input().split())
scc = 0
while n > 0 and m >= 2:
	if m >= 2*n:
		scc += n
		m -= 2*n
		n = 0
	elif n > 0 and m >= 2 and m < 2*n:
		scc += m/2
		n -= m/2
		m = m%2 
	if n == 0 and m >= 4:
		n += m/4
		m = int(ceil(float(m)/2))
print scc

Submission status: Accepted

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

Submission status: Accepted

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

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

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

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

Submission status: Accepted

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

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

print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

count = 0

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

else:
    count = (c - 1) // 2 if c % 2 == 1 else c // 2
    print(count)

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

Submission status: Accepted

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

Submission status: Accepted

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

def main(N, M):
    if(N>0 and M>2*N):
        print(N+(M-2*N)//4)
    elif(N>0 and M<2*N):
        print(M//2)
    elif(N==0 and M>3):
        print(M//4)
    else:
        print(0)

if __name__ == '__main__':
    N, M = map(int, input().split())

    main(N, M)

Submission status: Accepted

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

Submission status: Accepted

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

        x=(M-2*N+1)//2
        ans=max(min(N+x//2,(M-x)//2),ans)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# ABC055C - Scc Puzzle (ARC069C)
def main():
    n, m = list(map(int, input().rstrip().split()))
    ans = min(n, m // 2)  # S + CC
    ans += (m - ans * 2) // 4  # CCCC -> SCC
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

# まずsを使い切る
# sが余るならもう無理
# sがなしでcが余るならc4つをscc

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

Submission status: Accepted

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

def check(i): #i個のSccが作れるかどうか
    S = i
    c = 2 * i
    S -= N #Sはとりあえず使えるもので処理
    S = max(S, 0)
    return M >= (2 * S + c)


la = -1
ua = 10 ** 12
while ua - la > 1:
    mid = (la + ua)//2
    if check(mid):
        la = mid
    else:
        ua = mid

print (la)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
s=input().split();a,b=int(s[0]),int(s[1]);ans=0
if 2*a<b:
    ans+=a
    b-=a*2
    ans+=b//4
else:
    ans+=b//2
print(ans)

Submission status: Accepted

Solution code:
def main():
    #N = S parts / M = c parts
    N,M = map(int,input().split())
    if M >= 2*N:
        #c parts 
        M -= 2*N
        reN = M//4
        ans = N + reN
    else:
        ans = M//2
    print(ans)
main()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# sはありったけ使うほうがいい（cから作るとコストがかかる）
# ありったけ = m//2
# 残ったcからsccを作るには4つ必要

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

Submission status: Accepted

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

if 2*N >= M:
  print(M // 2)
  exit()
  
## だいたい(M-2*N)/4 個追加でSを作ると良い
var1 = (M - 2*N) // 4 - 1
ans1 = min(N + var1, M - 2*var1)
var2 = (M - 2*N) // 4
ans2 = min(N + var2, M - 2*var2)
var3 = (M - 2*N) // 4 + 1
ans3 = min(N + var3, (M - 2*var3)//2)
ans = max(ans1, ans2, ans3)
print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
from decimal import Decimal

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

base_pair = Decimal(min([n,m//2]))
c_left = Decimal(m)-base_pair*2
additional_pair = c_left//4
print(base_pair+additional_pair)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

if (N >= M):
    print(M)
    exit()

sub = (M - N) // 2
print(N+sub)

Submission status: Accepted

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

ans = 0
buff1 = M - N * 2
buff2 = M // 2
buff3 = min(buff2, N)
if buff2 < N:
    print(buff3)
    exit()
count = buff1 // 4

ans = buff3 + count
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

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

def main():
  n,m=LI()
  if n*2>m:
    return m//2
  return n+(m-2*n)//4

print(main())