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

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

print(res)

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
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()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
from decimal import *

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
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()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
#from decimal import *
 
N, M = MAP()

print(M//2 if N > M//2 else 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, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
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()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
from decimal import *

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
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()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
#from decimal import *
 
N, M = MAP()

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
#Sをすべて使うとき必要なCの数は2N
if M<2*N:
    print(M//2)
else:
    ans=N#現時点で作ったScc
    m=M-2*N#残りのc
    #Sccを１こ作るのにcは4つ必要
    ans+=m//4
    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:
import math


def main():
    N, M = list(map(int, input().split(' ')))
    if N >= M // 2:
        print(M // 2)
    else:
        t = math.ceil(((M // 2) - N) / 2)
        print((M - 2 * t) // 2)



if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n,m=MI()
a,b=n,m//2
if a>b:
    ans=b
else:
    ans=(a+b)//2
print(ans)

Submission status: Accepted

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

def main():
    n,m = map(int,input().split())
    s = n
    c = m
    scc = 0

    #sを全部使い切る
    take = min(s,c//2) #Sの個数とcを2で割った個数。小さい方を選んでSを使い切る
    scc += take
    s -= take
    c -= take * 2

    #残ったCでsccを作る（s=cが2個　cc=cが2個　合計4個必要）
    take = c // 4
    scc += take

    print(scc)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

import sys
# import time
# import math
# import numpy as np
# import scipy.sparse.csgraph as cs            # csgraph_from_dense(ndarray, null_value=inf), bellman_ford(G, return_predecessors=True), dijkstra, floyd_warshall
# import random                                # random, uniform, randint, randrange, shuffle, sample
# import string                                # ascii_lowercase, ascii_uppercase, ascii_letters, digits, hexdigits
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from datetime import date, datetime          # date.today(), date(year,month,day) => date obj; datetime.now(), datetime(year,month,day,hour,second,microsecond) => datetime obj; subtraction => timedelta obj
# from datetime.datetime import strptime       # strptime('2019/01/01 10:05:20', '%Y/%m/%d/ %H:%M:%S') returns datetime obj
# from datetime import timedelta               # td.days, td.seconds, td.microseconds, td.total_seconds(). abs function is also available.
# from copy import copy, deepcopy              # use deepcopy to copy multi-dimentional matrix without reference
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product, permutations  # product(iter, repeat=n), permutations(iter[,r])
# from itertools import combinations, combinations_with_replacement
# from itertools import accumulate             # accumulate(iter[, f])
# from operator import itemgetter              # itemgetter(1), itemgetter('key')
# from fractions import gcd                    # for Python 3.4 (previous contest @AtCoder)



def main():
    mod = 1000000007                # 10^9+7
    inf = float('inf')              # sys.float_info.max = 1.79...e+308
    # inf = 2 ** 64 - 1             # (for fast JIT compile in PyPy) 1.84...e+19
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())
    
    
    n, m = mi()
    if m <= n * 2:
        print(m // 2)
    else:
        # c の方が余分にある場合
        print(n + (m - 2 * n) // 4)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache


#############
# Constants #
#############

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

#############
# Functions #
#############

######INPUT######
def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()

#####Shorten#####
def DD(arg): return defaultdict(arg)


#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####GCD#####
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#####ChangeBase#####
def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i])*n**i for i in range(len(str(X))))

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count

#############
# Main Code #
#############
N,M = IL()
if 2*N >= M:
  PE(M//2)
R = M-2*N
P(N+(R//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())

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

Submission status: Accepted

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

def Main(N, M):
    if N+3 >= M:
        return M//2
    else:
        c_remain = M-N*2
        return N+c_remain//4
    
print(Main(N, M))

Submission status: Accepted

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

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

Submission status: Accepted

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

#Sが全部使える場合
if 2*N <= M:
    ans += N
    M -= 2*N
    #余ったCの取り扱い。Mが4個でSccを一個作れる。
    ans += M//4

#Cが足りないのでSを全部使えない場合
else:
    ans += M//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 2*N > M:
    cnt = M//2
else:
    cnt = N
    M -= 2*cnt
    cnt += M//4
print(cnt)

Submission status: Accepted

Solution code:
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()

from collections import defaultdict, deque, Counter
from sys import exit
import heapq
import math
import copy
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

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

Submission status: Accepted

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

Submission status: Accepted

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

if ans < m_2:
    make_s = m - ans*2
    ans += make_s // 4
    
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

scc = min(S, C // 2)

C -= scc * 2

print(scc + C // 4)

Submission status: Accepted

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

cnt = 0

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

m = int(M/2)

if N >= m:
    cnt = m
elif m > N:
    cnt = N
    M -= 2*N
    cnt += int(M/4)

print(cnt)

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
MOD = 10**9 + 7

n,m = map(int,input().split())
scc = min(n,m//2)
n -= scc
m -= scc*2

print(scc + m//4)

Submission status: Accepted

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

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

Submission status: Accepted

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

print(answer)

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

print(count)

Submission status: Accepted

Solution code:
N = [int(e) for e in input().split()]
if(N[0]*2>=N[1]):
    ans = N[1]//2
    print(ans)
else:
    ans = N[0] + (N[1] - N[0]*2)//4
    print(ans)

Submission status: Accepted

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

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

print(S)

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

if '__main__' == __name__:
    resolve()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

m = m//2

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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

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

Submission status: Accepted

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

def main():
    N, M = map(int, readline().rstrip().split())
    ans = min(N, M//2)
    M -= ans * 2
    ans += M//4
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

#sがあればcを可能な限り使う

if n == 0: #sが無かったら
    ans = m//4 #c4個につき1個作れる

elif m == 0: #cが無かったら
    ans = 0 #1個も作れない

elif n*2 <= m: #cを全部使ってもcが余るもしくはぴったりの場合
    ans = n + (m-2*n)//4 #sを使い切り、余ったcで何個か作る

elif n*2 > m: #Sが余る場合
    ans = m//2

print(ans)

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:
n, m = map(int, input().split()) # 'S':n 'c':m

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
n, k = list(map(int, input().split()))
#from collections import deque
if n < k:
    c = k//2  # 作れるccとsの数
    # print(c)
    # print(c-n)　#nコScc c-nがあまりの分
    # print((c-n)//2)
    print(n+(c-n)//2)
else:
    c = k//2
    print(c)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

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

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

Submission status: Accepted

Solution code:
def main():
  N, M = (int(_) for _ in input().split())
  ret = min(M // 2, N)
  M = M - 2 * ret
  ret += M // 4
  print(ret)

if __name__ == '__main__':
  main()

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0

ans += min(N, M//2)

N -= ans
M -= ans * 2

ans += M // 4

print(ans)

Submission status: Accepted

Solution code:
# solution

nim, mike= map(int, input().split())
if 2*nim>=mike:
  data=mike//2
else:
  data=nim+(mike-2*nim)//4
print(data)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    # import sys
    # readline = sys.stdin.buffer.readline
    # readlines = sys.stdin.buffer.readlines
    N, M = map(int, input().split())
    cnt = 0

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


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
def slove(n, m):
    tmp = n if n < m // 2 else m // 2
    tmp2 = (m - tmp * 2) // 4
    return tmp + tmp2
    
if __name__ == "__main__":
    n, m = [int(i) for i in input().split()]
    print(slove(n, m))

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, m = map(int, read().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())
ans = min(n, m//2)
n -= ans
m -= (ans * 2)
ans += (m // 4)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0

if s == 1 and c == 1:
    print(ans)
    exit()

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

print(ans)

Submission status: Accepted

Solution code:
import sys

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

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

if __name__ ==  '__main__':
    main()

Submission status: Accepted

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

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