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=map(int,input().split())
if 2*n>=m:
    print(m//2)
else:
    k1 = (m-n*2)//4
    k2 = k1+1
    k3 = max(k1-1,0)
    r1 = min(n+k1,(m-k1*2)//2)
    r2 = min(n+k2,(m-k2*2)//2)
    r3 = min(n+k3,(m-k3*2)//2)
    print(max(r1,r2,r3))

Submission status: Accepted

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

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

Submission status: Accepted

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

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

print(n + (m // 4))

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
n,m=map(int,input().split())
print(min(m//2,(n+m//2)//2))

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

if N < M // 2:
    print((N + M // 2) // 2)
else:
    print(M//2)

Submission status: Accepted

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

if m // 2 < n:
    # S が余っている
    ans = m // 2
else:
    # c が余っている
    ans = n
    # 余った c は 4つずつで Scc にできる
    ans += (m - 2 * n) // 4

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N, M = map(int,input().split())
ans = 0
if N >= M//2:
    ans = M//2
else:
    for i in range(max(0,M//2-N-10), max(0, M//2-N+10)):
        ans = max(ans,min(N+i//2,(M-i)//2))
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0

#Sとccだけで作る(SとCが足りている)
if S <= C//2:
    ans += S
    C -= S*2

    if C > 0:
        # 残りのCでSccを作る
        ans += C//4
else:
    ans += (C//2)
        
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
from io import StringIO
import unittest
import math

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

    if s>=c/2:
        print(str(math.floor(c/2)))
    else:
        zanc = c - (s * 2)
        print(str(s + math.floor(zanc/4)))
        
resolve()

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#n = int(input())
#da = list(map(int,input().split()))
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:
S, C = map(int, input().split())

ans = min(S, C//2)
C -= 2*ans # Sとcc(S)

if C: # Cが残っていたらc4個でSccを作成
  ans += C//4
  
print(ans)

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#ABC 055C Scc Puzzle
import sys
N, M = map(int, sys.stdin.readline().split())

#print(N, M)

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

cnt +=M//4
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

if n < 1 or m < 2:
    print(0)
    quit()

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

Submission status: Accepted

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

if n < 1 or m < 2:
    print(0)
    quit()

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
N, M = [int(x) for x in input().split()]
c_2 = M //2
if c_2 <= N:
    print(min(N, c_2))
    sys.exit()
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*N:
    ans = M // 2
else:
    ans = N
    M = M - 2*N
    ans += M // 4

print(ans)

Submission status: Accepted

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

print(answer)

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:
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf')
ans = 0 ;count = 0 ;pro = 1

n,m=map(int,input().split())
k=min(m//2,n)
m-=2*k;n-=k
count+=k
# print(n,m,k)
count+=m//4
print(count)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
from pprint import pprint
from copy import deepcopy
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
from pprint import pprint


sys.setrecursionlimit(2147483647)
INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 100000000


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

Submission status: Accepted

Solution code:
import sys

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

def main():
    s = n
    c = m
    res = 0
    if c < 2 * s:
        return m // 2
    
    res += s
    c -= 2 * s 
    res += c // 4
    return res

if __name__ == '__main__':
    ans = main()
    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())
if m // 2 < n:
  print(m//2)
else:
  ans = n
  m -= n*2
  ans += m//4
  print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

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

print(ans)

Submission status: Accepted

Solution code:
import sys
if sys.platform in ['ios', 'win32', 'darwin']:
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(x) for x in input().split()]

S, C = MAP()

ans = 0

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

if C >=4: ans += C//4

print(ans)

Submission status: Accepted

Solution code:


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

ans = 0

if 2*S <= C:
    ans += S
    C -= 2*S
    ans += max(0,C//4)
else:
    ans += min(S,C//2)

print(ans)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
print(N + (M - 2 * N) // 4 if N * 2 <= M else 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:
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
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
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    S,C = MI()
    ans = min(S,C//2)
    S-=ans
    C-=2*ans
    if C:
        ans += C//4
    print(ans)
if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin

a,b = [int(x) for x in stdin.readline().rstrip().split()]

if a > b//2:
    print(b//2)
else:
    print((b+2*a)//4)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    n,m=map(int,input().split())
    if(m-2*n<=0):
        print(m//2)
        return

    ans=n
    m=m-2*n
    print(ans+m//4)
resolve()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

    print(cnt)


main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

if n >= c:
    res = c
else:
    res = (n + c) // 2

print(res)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
ans = 0
if n > m // 2:
    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())
l = 0
r = 10 ** 13
while r - l > 1:
    m = (l+r) // 2
    a = max(m - N, 0)
    if M - 2 * a >= 2 * m:
        l = m
    else:
        r = m
print(l)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
from functools import reduce
import copy
import math
from pprint import pprint
import collections
import bisect


sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def int_inputs(num_of_input):
    ins = [int(input()) for i in range(num_of_input)]
    return ins


def solve(inputs):
    [s_num, c_num] = string_to_int(inputs[0])

    scc_num = 0

    if s_num * 2 <= c_num:
        scc_num += s_num
        c_num -= (s_num * 2)
        scc_num += c_num // 4
    else:
        scc_num += c_num // 2
        c_num -= c_num // 2
        # scc_num += c_num // 4
    return scc_num


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    ret = solve(inputs(1))
    print(ret)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

s_num, c_num = map(int, input().split())

if c_num <= 2 * s_num:
    # Sを使い切る前にCを使い切る
    scc_num = math.floor(c_num / 2)
    print(scc_num)
else:
    # Sを使い切り、余ったCでSを作りつつSCCを作る
    scc_num = math.floor(s_num + ((c_num - 2 * s_num) / 4))
    print(scc_num)

Submission status: Accepted

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

tmp_cnt = M // 2

cnt = min(N, tmp_cnt)

M -= (cnt*2)

cnt += M // 4

print(cnt)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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:
def examC():
    N, M = LI()
    cur = int(0)
    remain = M - N*2
    if remain>=0:
        cur += N
        cur += remain//4
    else:
        cur += M//2
    print(cur)

import sys
import copy
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examC()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

c = min(n, m // 2)
amari = m - (c * 2)
scc = math.floor(amari / 4)
print(int(scc + c))

Submission status: Accepted

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

Submission status: Accepted

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def main():
    N, M = map(int, input().split())
    
    # S余り
    if N >= M//2:
        ans = M // 2
    # C余り
    else:
        p = (M - 2 * N) // 4
        ans = N + p

    print(ans)

if __name__ == "__main__":
    main()

Submission status: Accepted

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

    print(ans)

if __name__ == "__main__":
    main()

Submission status: Accepted

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

res = 0

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

Submission status: Accepted

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

Submission status: Accepted

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

#N  -> num of S piece
#M  -> num of c piece

num=0

if(2*N < M):
    #print("a")
    dif = M - 2 * N #何個cが余ってるか
    num = N + (dif // 4)
else:
    num = M // 2

print(num)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(res)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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


def solve(N: int, M: int):
    ## Sccをいきなり作る
    answer =0 
    if N>=M//2:
        answer = M//2
    else:
        answer = N+(M-N*2)//4
    print(answer)


    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    solve(N, M)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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


main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n,m=map(int,input().split())
#2c=s  
#n s m c  
def check(k):
    n1=n 
    m1=m 
    if k>=n:
        req=(k-n1)*2+2*k 
    else:
        req=2*k 
    return req<=m  
lo=0 
hi=10**30 
ans=0 
while lo<=hi:
    mi=(lo+hi)>>1 
    if check(mi):
        ans=mi 
        lo=mi+1 
    else:
        hi=mi-1 
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# C - Scc Puzzle

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

if 2*N > M: # S余り
    print(min(N, M//2))
else: # c余り
    n_extra_c = M - 2*N
    print(N + n_extra_c//4)

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

count=0
temp=min(N,M//2)
count+=temp
N-=temp
M-=2*temp

if M>0:
    count+=M//4

print(count)

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

Submission status: Accepted

Solution code:
import sys

stdin = sys.stdin

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

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

main()

Submission status: Accepted

Solution code:
#ABC055 B - Scc Puzzle
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())

c = m - (n*2)
s = c // 4

if c >= 1:
    print(s + n)
else:
    print(m // 2)

Submission status: Accepted

Solution code:

s, c = map(int, input().split( ))
if s>= c//2:
    print(c//2)

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

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:
import sys
N, M = map(int, input().split())

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

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

Submission status: Accepted

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

Submission status: Accepted

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

cnt = 0

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

print(cnt)

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())
#N = count(S),M = count(c)
Max_count=0
if M>=2*N:
  Max_count+=N
  M-=2*N
  if M>0:
    Max_count+=M//4
elif M>N:
  Max_count+=(M-N)
else:
  Max_count+=M//2
print(Max_count)

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

print(min(N, M // 2))

Submission status: Accepted

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

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

Submission status: Accepted

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

n = N
m = M // 2
ans = min(n, m)
ans += max((m - ans)//2, 0)
print(ans)

Submission status: Accepted

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