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:
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

n,m=mii()

c=m-n*2

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

Submission status: Accepted

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

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:
#!/usr/bin/env pytHon3
# -*- coding: utf-8 -*-


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

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


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
#
# Written by NoKnowledgeGG @YlePhan
# ('ω')
#
#import math
#mod = 10**9+7
#import itertools
#import fractions
#import numpy as np
#mod = 10**4 + 7
"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""

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

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

"""
def YEILD():
  yield 'one'
  yield 'two'
  yield 'three'
generator = YEILD()
print(next(generator))
print(next(generator))
print(next(generator))
"""
"""def gcd_(a,b):
  if b == 0:#結局はc,0の最大公約数はcなのに
    return a
  return gcd_(a,a % b) # a = p * b + q"""
"""def extgcd(a,b,x,y):
  d = a
  if b!=0:
    d = extgcd(b,a%b,y,x)
    y -= (a//b) * x
    print(x,y)
  else:
    x = 1
    y = 0
  return d"""


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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
ans = min(n,m//2) + max(0,(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((2*N+M)//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= list(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())

# 余ってる c の数
dif = m - 2 * n

# すでにある s に対して、 c の数が足りない時
if dif < 0:
    ans = m // 2

else:
    ans = n + dif // 4

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#coding: utf-8
import math
import heapq
import bisect
import numpy as np
from collections import Counter, deque
#from scipy.misc import comb

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

cnt += c // 4

print(cnt)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:

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

Submission status: Accepted

Solution code:
import sys

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

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

n, m = na()

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import math

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

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
# C - Scc Puzzle
# 標準入力の取得
N,M = list(map(int, input().split()))

# 求解
if N >= M//2:
    # cc⇒Sを行わず、"Scc"を作成した際に、Sがちょうどまたは余る
    print(M//2)
else:
    # cc⇒Sを行わず、"Scc"を作成した際に、cが余る
    print(N + (M-2*N)//4)

Submission status: Accepted

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

ans = 0

#まずSのピースを使い果たす。
made_scc = min(N,int(M/2))
ans += made_scc
#N -= made_scc
M -= 2 * made_scc
#cのピースを使い果たす。
ans += int(M/4)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
val=min(n,m//2)
#print(val,end=' val\n')
n-=val
m-=2*val
ans=val
#print(m,end=' m\n')
ans+=m//4
print(ans)

Submission status: Accepted

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

if __name__ == '__main__':
    solve()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
#055_C
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())
O = M//2

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

Submission status: Accepted

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

# n + x : m - 2 * x = 1 : 2
# 2n+2x = m - 2x
# 4x = m-2n

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

else:
    print(m//2)

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

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

Submission status: Accepted

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

Submission status: Accepted

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


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

print(ans)

Submission status: Accepted

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

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

    print(ans)

if __name__ == '__main__':
    resolve()

Submission status: Accepted

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

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

Submission status: Accepted

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

# S used all C
if 2*N >= M:
    ans = int(M//2)
else:
    ans = N
    M = M - 2*N
    ans += int(M//4)
print(ans)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

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

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

main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#ABC055

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

def check(i):
    if M<i*2:
        return False
    if N+(M-i*2)//2<i:
        return False
    return True

r=M//2+1
l=0
while r-l>1:
    mid=(r+l)//2
    #print(mid,check(mid))
    if check(mid):
        l=mid
    else:
        r=mid
print(l)

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S, c = list(map(int, input().split()))
chalf = c//2
b = 0
if S < chalf:
    b = chalf - -(-(S+chalf)//2)
    print(int(S+b))
elif c < 2:
    print(0)
else:
    print(min(S,chalf))

Submission status: Accepted

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

Submission status: Accepted

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

if m < 2:
    print(ans)
    sys.exit()

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

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:
S,c=map(int,input().split())
ans=0
if(c<=S*2):
    ans=c//2
elif(c>S*2):
    if(c-(2*S)<4):
        ans=S
    elif(c-(2*S)>=4):
        ans=S+((c-(S*2))//4)
print(ans)

Submission status: Accepted

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

if n == m/2:
    print(n)
elif n < m/2:  # cが余る（c4つでscc1つ）
    print(n + (m-2*n)//4)
elif n > m/2:  # cが足りない
    print(m//2)

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:
#scc puzzle
n,m=map(int,input().split())
#nがs,mがｃである
if 2*n>m:
    print(m//2)
else:

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

Submission status: Accepted

Solution code:
import sys
import bisect
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

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

ans = n
m -= n*2

ans += m//4
print(ans)

Submission status: Accepted

Solution code:
def main():
    s_shaped_piece, c_shaped_piece = map(int, input().split())
    answer = min(s_shaped_piece, c_shaped_piece // 2)
    c_shaped_piece -= answer * 2
    answer += c_shaped_piece // 4
    print(answer)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    s,c=MI()
    ans=min(s,c//2)
    s-=ans
    c-=ans*2
    ans+=c//4
    print(ans)

main()

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0

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

print(ans)

Submission status: Accepted

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


print(r)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import exit

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

n, m = MAP()

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

Submission status: Accepted

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

n, m = MAP()

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def scc(N , M):
    ans = 0
    if N * 2 >= M:
        ans += M // 2
        return ans
    else:
        ans += N
        M -= N*2
        ans += M//4
        return ans

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

if 2 * n >= m:
  cnt += m // 2

else:
  cnt += n
  m -= 2 * n
  cnt += m//4

print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
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())
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 m>=2*n:
    k=(m-2*n)//4
    print(n+k)
else:
    print(m//2)

Submission status: Accepted

Solution code:

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

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

Submission status: Accepted

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

_n, _m = map(int, input().split())
print(solve(_n, _m))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect
from heapq import heappush, heappop

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M = MAP()

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

Submission status: Accepted

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

Submission status: Accepted

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

    remain_c = M - N * 2

    if remain_c <= 0:
        return M // 2
    else:
        return N + (remain_c // 4)


if __name__ == '__main__':
    res = solve()
    print(res)

Submission status: Accepted

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

count = 0

if c / 2 >= s:
    count += s
else:
    count += c // 2

c -= 2 * count

count += c // 4

print(count)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

if s[0] > s[1] // 2:
    print(s[1] // 2)
else:
    print(s[0] + (s[1] - 2 * s[0]) // 4)

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline


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

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.buffer.readline

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

if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

DR = [1, -1, 0, 0]
DC = [0, 0, 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 S(): return input()
     
def main():
    N, M = LI()
    cnt = 0
    if 2 * N < M:
        cnt += N
        cnt += (M - 2 * N) // 4
    else:
        cnt += M // 2
    print(cnt)

main()

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)