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 math
import string
import collections
from collections import Counter


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
n, m = map(int, input().split())
if m <= 2*n:
    print(m//2)
else:
    print(n+math.ceil((m-2*n)//4))

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:
import math
n, m = map(int, input().split())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0
M = m//2
ans += min(n,M)
if min(n,M) == n:
  m -= n*2
  ans += m//4
print(ans)

Submission status: Accepted

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

if N*2 >= M: #cが足りない
  print(M//2)
  sys.exit()

#Sが足りない  
ans = N
M = M -2*N
ans += M//4
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

def f(x):
    if M >= 2*x and N+(M-2*x)//2 >= x:
        return True
    return False

l = 0
r = 10**12
while r-l > 1:
    m = (l+r)//2
    if f(m):
        l = m
    else:
        r = m

if f(r):
    print(r)
else:
    print(l)

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


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

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

    print(res)


if __name__ == '__main__':
    resolve()

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
#%%code
def resolve():
    N,M=pin()
    
    t=M//2
    if t<N:
        print(t)
        return
    M-=N*2
    ans=N
    ans+=M//4
    print(ans)
#%%submit!
resolve()

Submission status: Accepted

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

Submission status: Accepted

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

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:
def main():
    N, M = map(int, input().split())
    if M <= N * 2:
        print(M//2)
        return
    remain = M - N*2
    ans = N
    ans += remain // 4
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

ans=min(n,m//2)

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

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

S = N
c = M // 2

print(min((S + c) // 2, c))

Submission status: Accepted

Solution code:
import sys

N, M = map(int, sys.stdin.readline().strip().split())

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

Submission status: Accepted

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

Submission status: Accepted

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

q = m // 2

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import os

def file_input():
    f = open('ARC069/input.txt', 'r')
    sys.stdin = f

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

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
N, M = map(int, input().split()) 

def detection(R, L):
    # print(R,L)
    if R-L <= 1:
        return L
    mid = (R+L)//2
    if mid > N:
        num_s = mid - N
        num_c = M - num_s*2
    else:
        num_s = mid
        num_c = M
    if num_c < mid*2:
        R = mid
    else:
        L = mid
    return detection(R,L)

def main():
   right = N+M
   left = -1
   ans = detection(right, left)
   print(ans)


if __name__ == '__main__':
    main()

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:
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

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

Submission status: Accepted

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

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

    

print(solve())

Submission status: Accepted

Solution code:
import fractions
import sys
from functools import reduce

input = sys.stdin.readline


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


def input_list():
    return list(map(int, input().split()))


def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)


def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


def gcd(*numbers):
    return reduce(fractions.gcd, numbers)


def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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

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:
import sys


def input(): return sys.stdin.readline().strip()


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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

#print(n,m)
cnt += m//4

print(cnt)

Submission status: Accepted

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

ans1=min(N, M//2)
resN=N-ans1
resM=M-ans1*2
if resM<2:
    print(ans1)
else:
    #Nもうない
    ans2=resM//4
    print(ans1+ans2)
#print(resN, resM)

Submission status: Accepted

Solution code:
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right
# from math import gcd,ceil,floor,factorial
# from fractions import gcd
from functools import reduce
from pprint import pprint

INF = float("inf")

def myinput():
    return map(int,input().split())

def mylistinput(n):
    return [ list(myinput()) for _ in range(n) ]

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    # lsはソート済みであること
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

def I():
    return int(input())

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

def RI():
    return list(map(int,input().split()))

def CI(n):
    return [ int(input()) for _ in range(n) ]

def LI(n):
    return [ list(map(int,input().split())) for _ in range(n) ]

def S():
    return input()

def MS():
    return input().split()

def RS():
    return list(input().split())

def CS(n):
    return [ input() for _ in range(n) ]

def LS(n):
    return [ list(input().split()) for _ in range(n) ]

n,m = RI()

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

Submission status: Accepted

Solution code:
from sys import exit
n,m=map(int, input().split())
c_rem=0
if m//2 <= n:
    print(m//2)
else:
    c_rem = m//2 - n
    print(n+c_rem//2)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
from itertools import permutations

def solve():
    input = sys.stdin.readline
    N, M = map(int, input().split())
    if N >= M // 2: print(M // 2)
    else:
        leftC = M - N * 2
        print(N + leftC // 4)

    return 0

if __name__ == "__main__":
    solve()

Submission status: Accepted

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

n, m = [int(x) for x in 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:
    print(M//2)
else:
    M -= 2*N
    print(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:
s,c=map(int,input().split())
if s > c//2:
   print(c//2)
   exit()
else:
   c-=s*2
s+=c//4
print(s)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Wed May 13 12:32:15 2020

@author: shinba
"""
import sys

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import re
import math
import collections
import decimal
import bisect
import itertools
import fractions
import functools
import copy
import heapq
import decimal

sys.setrecursionlimit(10000001)
INF = sys.maxsize
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===
def main():
    s, c = ns()

    if c % 2:
        c -= 1

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

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/arc069/tasks/arc069_a

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

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

print(ans)

Submission status: Accepted

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

if c:
    ans+=c//4
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7



def main():
    N, M = map(int, readline().split())
    if M//2<=N:
        ans = M//2
    else:
        ans = N + (M-N*2)//4
    print(ans)
if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

ans = 0

# 最初からある「S」を使って作れるだけ「Scc」を作る
# 「c」の1/2より「S」の方が多い場合、作れるだけ「Scc」を作って終わり
if N > M/2:
    ans += M//2
    N -= M//2
    M = M % 2
    print(ans)
    exit(0)

# 「c」の方が多い時
# 「S」を使い切る
ans += N
M -= N*2
N = 0

# 残った「c」から作れるだけ「Scc」を作る
ans += M//4
print(ans)

Submission status: Accepted

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

ans = 0

tmp = n * 2

if m <= tmp:
    print(m//2)
    exit()
    
ans += n

m -= tmp

ans += m//4

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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


def readstr():
    return input().strip()


def readint():
    return int(input())


def readnums():
    return map(int, input().split())


def readstrs():
    return input().split()


N, M = readnums()

'''
N:M = 1:2が理想
N + x: M -2x = 1:2
2N+2x = M-2x
M-2N=4x
'''

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

Submission status: Accepted

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# 2020/05/01
# AtCoder Regular Contest 069 - C

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

# c is c
if n >= 2 * m:
    ans = int(m / 2)
else:
    if n < m:
        ans = n + int(max(0, (m - n * 2)) / 4)
    else:
        ans = int(m / 2)

# Output
print(ans)

Submission status: Accepted

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def myAnswer(N:int,M:int) -> int:
   if(2 * N <= M):
      counter = N
      M -= 2*N
      counter += M//4
   else:
      counter = M//2
   return counter

def modelAnswer():
   return
def main():
   N,M = map(int,input().split())
   print(myAnswer(N,M))

if __name__ == '__main__':
   main()

Submission status: Accepted

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

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

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

Submission status: Accepted

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

ans = 0
res = 0

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

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

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

print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

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

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())
def solve():
    ans = min((N*2+M)//4, M//2)
    return ans
print(solve())

Submission status: Accepted

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

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

else:
    print(int(c/2))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
if n==m//2:
  print(m//2)
  exit()
if n>m//2:
  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())

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

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

Submission status: Accepted

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

def main():
    s,c = map(int,input().split())

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

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
# import fractions
# import sys
from sys import stdin

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

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def resolve():

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


resolve()

Submission status: Accepted

Solution code:
def main(n: int, m: int):
    ans = 0
    
    ans += min(n, m // 2)
    m -= ans * 2

    ans += m // 4

    print(ans)


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

    main(n, m)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

# Sの数が初期のcの必要数より少ない場合はcの数で総数が決まる
if m - (n*2) < 0:
    ans = m // 2
else:
    # 初期段階で作れるSccの数
    tmp_Scc = n

    # 初期のSのみでSccを作ったときのcのあまり
    tmp_amari = m - (n*2)

    # 余りを用いるとc 4つでSccが一つ作れる
    tmp_Scc_2 = tmp_amari // 4

    ans = tmp_Scc + tmp_Scc_2

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# coding: utf-8
n, m = map(int, input().split())

ans = 0
# 最初のs使いきれるか
if 2 * n >= m:
    print(min(n, m // 2))
else:
    ans += n
    m -= 2 * n
    ans += m // 4
    print(ans)

Submission status: Accepted

Solution code:
base = input().split()
s = int(base[0])
c = int(base[1])
cnt = 0
if (s*2)<c:
    cnt+=s
    c-=s*2
    cnt+=c//4
else:
    cnt+=c//2
print(cnt)

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
if n<m:
            ans=n+(m-n*2)//4
            print(ans)
elif 2*n>=m:
            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, acos, atan, asin
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 STR(): return input()
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 = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]

n, m = MAP()
ans = (n * 2 + m) // 4
if ans > m // 2:
    ans = m // 2
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())
# N : Sの数
# M : Cの数

if M <= 2*N: #Cの数が少ない
    print(M//2)
else:
    cnt = N
    M -= 2*N
    print(cnt+M//4)

Submission status: Accepted

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

ans = 0
if N >= M:
    ans = M // 2
else:
    ans += N
    M -= N * 2
    #余りで作るだけ作る
    ans += M // 4

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x,y=list(map(int, input().split()))
ans=0

if x*2>=y:
	ans=ans+(y//2)
	x=x-(y//2)
	y=y%2
else:
	ans=ans+x
	y=y-(x*2)
	x=0

print(ans+(y//4))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

print(min((N *2+M)//4,M//2))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
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:
sc, cc = map(int, input().split())

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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