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:
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 6)
mod = 10**9+7
cnt = 0
ans = 0
num = []
inf = float("inf")
al = "abcdefghijklmnopqrstuvwxyz"
AL = al.upper()

n,m = I()

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

Submission status: Wrong Answer

Solution code:
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 6)
mod = 10**9+7
cnt = 0
ans = 0
num = []
inf = float("inf")
al = "abcdefghijklmnopqrstuvwxyz"
AL = al.upper()

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

cnt=0

m=m-2*n
cnt+=n

num=m//4
cnt+=num
  
print(cnt)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

ans += math.floor(m / 4)

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

scc = n*2 + m
ans = math.floor(scc/4)
print(ans)

Submission status: Wrong Answer

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

if m >= 2*n:
    ans += n
    m -= 2*n
ans += math.floor(m/4)

print(ans)

Submission status: Wrong Answer

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

c = n*2+m
print(math.floor(c/4))

Submission status: Wrong Answer

Solution code:
def LI():
    return list(map(int, input().split()))


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

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:
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

m += n * 2

if m <= 3:
    print(0)
else:
    print(m // 4)

Submission status: Wrong Answer

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

m += n * 2

print(m // 4)

Submission status: Wrong Answer

Solution code:
import sys
import heapq
from decimal import Decimal

input = sys.stdin.readline

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

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

Submission status: Wrong Answer

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

print(ans+m//4)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
import heapq
from fractions  import gcd
#input=sys.stdin.readline
#import bisect
n,m=map(int,input().split())
if n>=2*m:
    print(n)
else:
    ans=n+(m-2*n)//4
    print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#45 C - Scc Puzzle
N,M = map(int,input().split())

for i in range(M//2+1):
    if M//N < 2:
        M += 2
        N -= 1
        break   
    M -= 2
    N += 1
if M<2:
    print(0)
else:
    print(N-1)

Submission status: Wrong Answer

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

for i in range(M//2+1):
    if M//N < 2:
        break   
    M -= 2
    N += 1
print(N-1)

Submission status: Wrong Answer

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

for i in range(M//2+1):
    if M//N < 2:
        break   
    M -= 2
    N += 1
if M<2:
    print(0)
else:
    print(N-1)

Submission status: Wrong Answer

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

for i in range(M//2+1):
    M -= 2
    N += 1
    if M//N < 2:
        break
print(N-1)

Submission status: Wrong Answer

Solution code:
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007

#+++++

def main():
	#a = int(input())
	S_num, c_num = tin()
	#s = input()
	if S_num >= c_num * 2:
		return c_num // 2
	return S_num + ((c_num - (S_num * 2)) // 4)
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Submission status: Wrong Answer

Solution code:
'''
Created on 2020/08/28

@author: harurun
'''
def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  
  N,M=map(int,pin().split())
  print((2*N+M)//4)
  return 

main()

Submission status: Wrong Answer

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

ans = 0
restM = M - (N*2)
ans = ans + N

ans = ans + restM//4

print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
S, C = map(int, input().split())
ret = 0
if 2 * S <= C:
    ret += S
    C -= 2 * S
    S = 0

ret += C // 4
print(ret)

Submission status: Wrong Answer

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

ans=0

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
import math


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

n, m = inintm()

ans = 0

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

Submission status: Wrong Answer

Solution code:
import sys
import math


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

n, m = inintm()

ans = 0

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

Submission status: Wrong Answer

Solution code:
import sys
import math


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

n, m = inintm()

ans = 0

if m - n*2 > 0:
    ans += n
    m -= n*2
elif m - n*2 == 0:
    print(n)
    exit()
else:
    if m % 2 == 0:
        print(m)
        exit()
    else:
        print(m-1)
        exit()

ans += m//4

print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
N, M = map(int, input().split())

S = N + M//2
ret = S // 2
print(ret)

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
s,c = readInts()
c += s*2
print(c//4)

Submission status: Wrong Answer

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

import math
#x = math.ceil((m-2*n)/4)
if m >= 2*n:
    x = math.ceil((m-2*n)/4)
    y = math.floor((m-2*n)/4)
    ans = max(n+y, (m-2*x)//2)
    print(ans)
else:
    print(n)

Submission status: Wrong Answer

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

import math
#x = math.ceil((m-2*n)/4)
if m >= 2*n:
    if m%2 == 0:
        x = math.ceil((m-2*n)/4)
    else:
        x = math.ceil((m-2*n)/4)+1
    y = math.floor((m-2*n)/4)
    ans = max(n+y, (m-2*x)//2)
    print(ans)
else:
    print(n)

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
S, C = [ int(v) for v in input().split(" ") ]

total = 0

for i in range(S):
  C -= 2
  total += 1
#print(C)
  
# C: 4->1, 8->2
total += int(C / 4)

print(total)

Submission status: Wrong Answer

Solution code:

import sys
input = sys.stdin.readline
# sys.setrecursionlimit(100000)


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


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:

import sys
input = sys.stdin.readline
# sys.setrecursionlimit(100000)


def main():
    n, m = [int(i) for i in input().strip().split()]
    if n == m * 2:
        print(n)
    elif n > m * 2:
        print(m // 2)
    else:
        print((m // 2 + n) // 2)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:

import sys
input = sys.stdin.readline
# sys.setrecursionlimit(100000)


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


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

ans = 0
if N > M//2:
    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())

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
from collections import deque
import itertools
import math

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

n,m = readInts()

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

print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# coding: utf-8

# In[10]:


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


# In[11]:


s1 = min(N, M-N*2)
s2 = (M-s1*2)//4
print(s1+s2)


# In[ ]:

Submission status: Wrong Answer

Solution code:
def resolve():
    '''
    code here
    '''
    num_S, num_c  = [int(item) for item in input().split()]

    delta = num_c - num_S

    if delta <= num_S:
        scc = num_c//2
    else:
        scc = num_S
        scc += delta//4

    print(scc)

if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
#ARC069-C
n,m = map(int,input().split())

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

Submission status: Wrong Answer

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

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

res += M//4

print(res)

Submission status: Wrong Answer

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

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

#print(res,s,c)

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

Submission status: Wrong Answer

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

print(s+(c-s*2)//4)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

res = c//4

print(res)

Submission status: Wrong Answer

Solution code:
import bisect,copy,heapq,itertools,math,string
from collections import *
import sys
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
n1=min(N,M//2)
N-=n1
M-=2*n1

if N==0:
  ans=n1+M//4
else:
  ans=n1+N//2
print(ans)

Submission status: Wrong Answer

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

if M <= N * 2:
    print(M // 2)

ans = N
M -= N*2

ans += M//4

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
#from fractions import gcd
#from itertools import combinations # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n,m = readInts()
print((n*2+m)//4)

Submission status: Wrong Answer

Solution code:

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

def main(N, M):

    if N //2 <= M: # Sが足りない
        print(int(N + (M - (N*2))//4))
    else:
        print(int(M//2)) # cが足りない

if __name__ == '__main__':
    main(N, M)

Submission status: Wrong Answer

Solution code:

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

def main(N, M):

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

if __name__ == '__main__':
    main(N, M)

Submission status: Wrong Answer

Solution code:

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

def main(N, M):

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

if __name__ == '__main__':
    main(N, M)

Submission status: Wrong Answer

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

ans=0
m+=n*2

ans+=m//4

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

def solve(N,M):
  # 今あるもの
  if M < N * 2:
    return N
  
  M -= N * 2
  
  ans = N + (M // 4)
  return ans

print(solve(N,M))

Submission status: Wrong Answer

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

def solve(N,M):
  # 今あるもの
  if M < N * 2:
    return N
  
  M -= N * 2
  
  ans = N + M // 4
  return ans

print(solve(N,M))

Submission status: Wrong Answer

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

def solve(N,M):
  # 今あるもの
  if M < N * 2:
    return N
  
  M -= N * 2
  
  ans = N + M // 3
  return ans

print(solve(N,M))

Submission status: Wrong Answer

Solution code:
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
# import math
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
# sys.setrecursionlimit(int(pow(10, 2)))
# sys.stdin = open("input.txt", "r")
# sys.stdout = open("output.txt", "w")
mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]





# @lru_cache(None)


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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans = 0
x = (M-2*N) // 4
r = min(10, M//2)
for i in range(max(0, x-r), x+r):
    tmp = min(N+i, (M-2*i)//2)
    ans = max(ans, tmp)

print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
def solve():
  n, m = map(int, input().split())
  if m//2 <= n:
    print(m//2)
  else:
    print("ばーか")
  return 0
 
if __name__ == "__main__":
  solve()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

if n > (m+n)/3:
    print(m//2)
    exit()

ans = n
m -= 2*n
ans += m//4

Submission status: Wrong Answer

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

if n > (m+n)/3:
    print(m//2)
    exit()
if m > 100000000:
    print(m//4)
    exit()

while n <= (n+m)/3:
    n += 1
    m -= 2

print(n-1)

Submission status: Wrong Answer

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

if n > (m+n)/3:
    print(m//2)
    exit()
if m > 100000:
    print(m//4)
    exit()

while n <= (n+m)/3:
    n += 1
    m -= 2

print(n-1)

Submission status: Wrong Answer

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

while n <= (n+m)/3:
    n += 1
    m -= 2

print(n-1)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
from collections import Counter
from collections import deque
import math
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

n,m=mp()
if m<2:
    print(0)
    exit()
if n>=2*m:
    print(m//2)
    exit()
print(n+-(-(m-2*n)//4))

Submission status: Wrong Answer

Solution code:
import sys
from collections import Counter
from collections import deque
import math
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

n,m=mp()
if m<2:
    print(0)
    exit()
if n>=2*m:
    print(m//2)
    exit()
print(n+(m-2*n)//4)

Submission status: Wrong Answer

Solution code:
import sys
from collections import Counter
from collections import deque
import math
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if N >= 2*M:
  print(M//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 N >= 2*M:
  print(N)
  sys.exit()

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

Submission status: Wrong Answer

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//3
  
print(ans)

Submission status: Wrong Answer

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

S = N
c = M // 2

print((S + c) // 2)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

M = M - 1 if M%2==1 else M

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

Submission status: Wrong Answer

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

M = M - 1 if M%2==1 else M

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

M = M - 1 if M%2==1 else M

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

Submission status: Wrong Answer

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

M = M - 1 if M%2==1 else M
mx = 0

for i in range((M-2*N)//4, M//2):
    mx = max(min(N+i, (M-2*i)//2), mx)

print(mx)