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: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#scc puzzle
n,m=map(int,input().split())
#nがs,mがｃである
if n>2*m:
    print(m)
else:
    #n<=2*m
    print(n+((m-2*n)//4))

Submission status: Wrong Answer

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

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

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

ans = n
m -= n*2

ans += m//4
print(ans)

Submission status: Wrong Answer

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if 2*n>=m:
    print(n)
else:
    res = n    #元の状態で作れる総数
    tmp = m-2*n  #残り
    res += tmp//4
    print(res)

Submission status: Wrong Answer

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

if n>=2*m:
    print(n)
else:#2m>n
    res = n    #元の状態で作れる総数
    tmp = m-2*n  #残り
    res += tmp//4
    print(res)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
while N + 1 < M // 2:
    N += 1
    M -= 2
print(N)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

n, m = MAP()

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

N, M = MAP()

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

Submission status: Wrong Answer

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

def main():
    N,M = map(int,input().split())
    left,right = 0,10**12
    while right-left > 1:
        mid = (left+right)//2
        if ((N+mid)*2 >= M-2*mid):
            right = mid
        else:
            left = mid
            
    if (N+right)*2 == M-2*right:
        print(min(N+right,M-2*right))
    else:
        print(min(N+left,M-2*left))

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

s = N
c = M
ans = 0

if s * 2 <= c:
    ans += s

if s < c:
    c -= s * 2
    ans += c // 4

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

print(n + (m // 4))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print((N + M // 2) // 2)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
def check(mid,N,M):
    if N >= mid and M >= 2*mid:
        return True
    else:
        require = mid-N
        M -= require*2
        N = mid
        if N >= mid and M >= 2*mid:
            return True
        else:
            return False
left = 0
right = 10**18
while right-left > 1:
    mid = (left+right)//2
    if check(mid,N,M):
        left = mid
    else:
        right = mid
if check(right,N,M):
    print(right)
else:
    print(left)

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
def check(mid,N,M):
    if N >= mid and M >= 2*mid:
        return True
    else:
        M -= (mid-N)*2
        N += (mid-N)
        if N >= mid and M >= 2* mid:
            return True
        else:
            return False
left = 0
right = 10**18
while right-left > 1:
    mid = (left+right)//2
    if check(mid,N,M):
        left = mid
    else:
        right = mid
if check(right,N,M):
    print(right)
else:
    print(left)

Submission status: Wrong Answer

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

ans = 0

#Sとccだけで作る
ans += S
C -= S*2

if C > 0:
    # 残りのCでSccを作る
    ans += C//4

print(ans)

Submission status: Wrong Answer

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

ans = 0

#Sとccだけで作る
ans += S
C -= S*2

# 残りのCでSccを作る
ans += C//4

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if 2*n >= m:
    ans = n
else:
    while 2*n <= m:
        n += 1
        m -= 2
    else:
        ans = n-1

print(ans)

Submission status: Wrong Answer

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:
  print("n = {}, m = {}".format(n, m))
  ans += n
  m -= n*2
  print("n = {}, m = {}".format(n, m))
  ans += m//4
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

sum_c = 2 * N + M
print(sum_c // 4)

Submission status: Wrong Answer

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

ans = 0

#まず最初からあるSを使う
if 2*N <= M:
    ans += N
    M -= 2*N
    N = 0
else:
    ans += M//2
    N -= M//2
    M -= M//2
    
#残ったcを使ってSccを作る。
ans += M//4
    
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

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

ans = 0

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

print(ans)

Submission status: Wrong Answer

Solution code:


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

ans = 0

if S <= 2*C:
    ans += S
    C -= 2*S
    ans += C//4
else:
    ans += C//2

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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
    else:
        if M >= 2:
            N += 1
            M -= 2
        else:
            break
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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 <= (c_num // 2):
        scc_num += s_num
        c_num -= (s_num * 2)
        s_num = 0

        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: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
while 2*n<m:
  n+=1
  m-=2
  
print(n)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

c = min(n, m // 2)
amari = m - (n * 2)
if amari < 0:
  print(0)
  exit(0)

scc = math.floor(amari / 4)
print(scc + c)

Submission status: Wrong Answer

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

amari = m - (n * 2)
if amari < 0:
  print(0)
  exit(0)

scc = math.floor(amari / 4)
print(scc + n)

Submission status: Wrong Answer

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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 += N
print(ans)

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
#2c=s  
#n s m c  
def check(k):
    n1=n 
    m1=m 
    req=(k-n1)*2+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: Wrong Answer

Solution code:
n,m=map(int,input().split())
#2c=s  
#n s m c  
def check(k):
    n1=n 
    m1=m 
    req=(k-n1)*2+2*k 
    return req<=m  
lo=0 
hi=10**17 
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: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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: Wrong Answer

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

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

print(s + n)

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

K=(C-2*S)//4-1
tmp=10**10
ans=0

for i in range(3):
  if tmp>(C-2*K)//2-(S+K):
    ans=min((C-2*K)//2,S+K)
    K=K+1
    tmp=(C-2*K)//2-(S+K)
print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

if c >= 2 * s:
    answer += s
    c -= 2 * s
else:
    answer += c // 2

answer += c // 4
print(answer)

Submission status: Wrong Answer

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

s = N + M // 2
print(s // 2)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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


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


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

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

c = N*2 + M

print(c//4)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/abc055/tasks/arc069_a
# C - Scc Puzzle
import math
N, M = list(map(int, input().split()))

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

c = int(c)
print(c)

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/abc055/tasks/arc069_a
# C - Scc Puzzle
import math
N, M = list(map(int, input().split()))

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

c = int(c)
print(c)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
""" abc055_a """

import sys

H = pow(10, 9) + 7

def _main():
    n_s, n_c = map(int, sys.stdin.readline().split(' '))

    print(int((n_s * 2 + n_c) / 4))

if __name__ == '__main__':
    _main()

Submission status: Wrong Answer

Solution code:

import collections
import itertools
import sys

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

n,m=getints()

res = min(n,m*2)

m=m-res*2

res = res + m // 4

print(res)

Submission status: Wrong Answer

Solution code:

import collections
import itertools
import sys

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

n,m=getints()

res = min(n,m*2)

m=m-res*2

res = res + m // 3

print(res)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

m += (2 * n)

print(m // 4)

Submission status: Wrong Answer

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

m -= 2 * n

if m < 4:
  print(n)

else:
  print(n + (m // 4))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def solve(S, c):
    if S > c//2:
        return c//2
    elif S == c//2:
        return c//2
    if S < c//2:
        cnt = S
        c -= S * 2
        S -= S
        assert S == 0
        assert c > 0
        return cnt + c//4

S, c = [int(x) for x in input().split()]


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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys, math, fractions, itertools


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


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

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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



counter = 0
temp = min(c // 2,s)
counter += temp
s -= temp
c -= temp * 2
temp = 0

while True:

    
    if c >= 2 and s >= 1:
        temp = min(c // 2,s)
        counter += temp
        s -= temp
        c -= temp * 2
        #print("counter:",counter)
        #print("s:",s)
        #print("c:",c)
    if s == 0 and c >= 2:
        temp = c // 3
        s += temp
        c -= temp * 2
    if c <= 1:
        break


print(counter)

Submission status: Wrong Answer

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



counter = 0


for i in range(s):
    if c >= 2 and s >= 1:
        s -= 1
        c -= 2
        counter += 1
    if s == 0 and c >= 2:
        c -= 2
        s += 1
    if s == 0 and c <= 1:
        break


print(counter)

Submission status: Wrong Answer

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



counter = 0


for i in range(s):
    if c >= 2 and s >= 1:
        s -= 1
        c -= 2
        counter += 1
	
    elif s <= 0 and c >= 2:
      s += 1
      c -= 2
      
    else:
        break



print(counter)

Submission status: Wrong Answer

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



counter = 0


for i in range(s):
    if c >= 2 and s >= 1:
        s -= 1
        c -= 2
        counter += 1
    elif s == 0 and c >= 2:
        c -= 2
        s += 1
    elif s == 0 and c <= 1:
        break


print(counter)

Submission status: Wrong Answer

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



counter = 0


for i in range(s):
    if c >= 2 and s >= 1:
        s -= 1
        c -= 2
        counter += 1
    if s == 0 and c >= 2:
        c -= 2
        s += 1
    if s == 0 and c <= 1:
        break


print(counter)