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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

if m < 2:
  print(0)
elif m == 2:
  print(1)
else:
  ans = n
  m = m - 2*n
  ans += math.floor(m/4)
  print(ans)

Submission status: Wrong Answer

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

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

n = N
m = M // 2

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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


ans = 0

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
n, m = map(int, raw_input().split())
def f(n,m): 
	x = min(n,(n + m) / 3)
	return x + max((m - 2*x)/4,0)
print f(n,m)

Submission status: Wrong Answer

Solution code:
n, m = map(int, raw_input().split())
def f(n,m): 
	x = min(n,(n + m) / 3)
	return x + (m - 2*x)/4
print f(n,m)

Submission status: Wrong Answer

Solution code:
n, m = map(int, raw_input().split())
def f(n,m): return ((n<<1) + m) >> 2
print f(n,m)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,M=list(map(int, input().split()))
K=N-2*M
print(max(N+K//3,N))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
remaining = abs(m- n*2)

ans = remaining//4 + n
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

# N + x : M - 2x = 1 : 2
# M - 2x = 2N + 2x
# x = (M - 2N) / 4

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

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

t = n*2 + m

print(t//4)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

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

possible_c = m
possible_s = n * 2

one_valid = 4 # c

result = (possible_c + possible_s) // one_valid
print (result)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

# 初期のSで可能な限りSCCを作る
if S*2 <= C:
    C = C - S*2
    print(C, S, C//4)
    ans += S
    ans += C // 4
else:
    print(C//2)
    ans += C // 2

print(int(ans))

Submission status: Wrong Answer

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

# 初期のSで可能な限りSCCを作る
if S*2 <= C:
    C = C - S*2
    print(C, S, C//4)
    ans += S
    ans += C // 4
else:
    print(C//2)
    ans += C // 2

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

while m > 2*n+1:
  n += 1
  m -= 2
  
print(n)

Submission status: Wrong Answer

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

while m > 2*n:
  n += 1
  m -= 2
  
print(n)

Submission status: Wrong Answer

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

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

if m >= 4:
  ans += m // 4
  
print(ans)

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
s_map = [1 for _ in range(N)]
c_map = [1 for _ in range(M//2)]
print(len(s_map+c_map)//2)

Submission status: Wrong Answer

Solution code:
import math

N,M = map(int, open(0).read().split())
X = math.floor((M-2*N)/2)
print(math.floor((2*N+X)/2))

Submission status: Wrong Answer

Solution code:
N,M = map(int, open(0).read().split())
X = int((M-2*N)/2)
print(int((2*N+X)/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:
S,C=map(int,input().split())
count=0
if S<=2*C:
    C-=S*2
    count+=S
    
    count+=C//4
    
else:
    count+=C//2
print(count)

Submission status: Wrong Answer

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


def calculate(n, m):

    if M < 2*N:
        print(0)
        return;
    res = ((m - n * 2) // 4) + n
    print(res)

calculate(N, M)

Submission status: Wrong Answer

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


def calculate(n, m):
    res = ((m - n * 2) // 4) + n
    print(res)

calculate(N, M)

Submission status: Wrong Answer

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

if 2*n < m:
  count += n
  m = m - 2*n
  n = 0  
  count += m//4
else:
  while m >= 2*n:
    count += 1
    m -= 2
    n -= 1

print(count)

Submission status: Wrong Answer

Solution code:
n,m = list(map(int,input().split()))
count = 0
if 2*n < m:
  count += n
  m = m - 2*n
  n = 0

count += m//4

print(count)

Submission status: Wrong Answer

Solution code:
n,m = list(map(int,input().split()))
count = 0
if 2*n <= m:
  count += n
  m = m - 2*n
  n = 0

count += m//4

print(count)

Submission status: Wrong Answer

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

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

print(N)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,m=[int(x) for x in input().rstrip().split()]
ans=0
m-=n*2
ans+=n
ans+=m//4
print(ans)

Submission status: Wrong Answer

Solution code:
n,m=[int(x) for x in input().rstrip().split()]
mm=m//2
ave=(n+mm)//2
print(ave)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

tmp = M - N*2
print(tmp//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 = list(map(int,input().strip().split()))

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

print(res)

Submission status: Wrong Answer

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

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

print(res)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

n,m=MI()
a,b=n,m//2
ans=(a+b)//2
print(ans)

Submission status: Wrong Answer

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

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

cnt = n * 2 + m * 1
print(cnt // 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:
    print(N)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

cnt = 0
while N > 0 and M > 0:
    cnt += 1
    N -= 1
    M -= 2

while M >= 4:
    cnt += 1
    M -= 4

print(cnt)

Submission status: Wrong Answer

Solution code:
# 二分探索で行いたい
N, M = [int(i) for i in input().split()]

low = 0
high =  M // 2

while abs(low-high) > 1:
    mid = (low+high) // 2
    guess_n = N + mid
    guess_m = M-(2 * mid)
    if guess_n > guess_m // 2 :
        high = mid
    else :
        low = mid

output = low + N
    
print(output)

Submission status: Wrong Answer

Solution code:
# 二分探索で行いたい
N, M = [int(i) for i in input().split()]

low = 0
high =  M // 2

if N * 2 > M / 2:
    output = N
else :
    while abs(low-high) > 1:
        mid = (low+high) // 2
        guess_n = N + mid
        guess_m = M-(2 * mid)
        if guess_n >= guess_m // 2 :
            high = mid
        else :
            low = mid

    output = low + N
    
print(output)

Submission status: Wrong Answer

Solution code:
# 二分探索で行いたい
N, M = [int(i) for i in input().split()]

low = 0
high =  M // 2

if N * 2 > M / 2:
    output = N
else :
    while abs(low-high) > 1:
        mid = (low+high) // 2
        guess_n = N + mid
        guess_m = M-(2 * mid)
        if guess_n > guess_m // 2 :
            high = mid
        else :
            low = mid

    output = low + N
    
print(output)

Submission status: Wrong Answer

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

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

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())
print(S if S*2 >= C else (S*2+C)//4)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

print(S)

Submission status: Wrong Answer

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

M += 2*N

S = M // 4

print(S)

Submission status: Wrong Answer

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

M -= 2*N

S = N + M // 4

print(S)

Submission status: Wrong Answer

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

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

print(S)

Submission status: Wrong Answer

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

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

print(S)

Submission status: Wrong Answer

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

if '__main__' == __name__:
    resolve()

Submission status: Wrong Answer

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

if '__main__' == __name__:
    resolve()

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

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

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

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

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

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

print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, k = list(map(int, input().split()))
#from collections import deque
c = k//2
# print(c)
# print(c-n)
# print((c-n)//2)
print(n+(c-n)//2)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
def slove(n, m):
    if (m - n*2) >= 0:
        tmp = (m - n * 2) // 4 + n
    else:
        tmp = 0
    return tmp

if __name__ == "__main__":
    n, m = [int(i) for i in input().split()]
    print(slove(n, m))

Submission status: Wrong Answer

Solution code:
def slove(n, m):
    if m >= 2:
        tmp = (m - n * 2) // 4 + n
    else:
        tmp = 0
    return tmp

if __name__ == "__main__":
    n, m = [int(i) for i in input().split()]
    print(slove(n, m))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans = 0

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

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

print(ans)

Submission status: Wrong Answer

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

ans = 0

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

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

print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


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

    if M >= N * 2:
        result = N
        M -= N * 2
    else:
        result = 0

    print(M // 4 + result)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#coding: utf-8
import math
import heapq
import bisect
import numpy as np
from collections import Counter, deque
#from scipy.misc import comb

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

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

print(ans)

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

Solution code:
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

n, m = na()

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import math

s,c=map(int,input().split())
count=0

count=s
c-=s*2
count+=math.floor(c/4)
print(count)

Submission status: Wrong Answer

Solution code:
import numpy as np
n,m=map(int, input().split())

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

Submission status: Wrong Answer

Solution code:
print(eval(input().replace(' ','*2+'))//4)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
S = list(map(int,input().split()))
N=S[0]
M=S[1]
N1=0
M1=0
count = 0
if N<2*M:
    count = N
    N1=0
    M1=M-2*N
    count+=M1//4
else:
    count += M//2
print(count)

Submission status: Wrong Answer

Solution code:
S = list(map(int,input().split()))
N=S[0]
M=S[1]
N1=0
M1=0
count = 0
if N<2*M:
    count += N
    N1=0
    M1=M-2*N
else:
    count += M//2
    N1 =N-M//2
    M1 =M-(M//2)*2
    
for i in range(N1):
    if N1 ==0 or M1<=1:
        break
    N1=N1-1
    M1=M1-2
    count += 1
if N1==0:
    for i in range(M1):
        if M1>=4:
            M1 -= 4
            count += 1
        if M1<4:
            break
print(count)

Submission status: Wrong Answer

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

if N>=O:
    print(O)
else:
    print((N+2)//2)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

    print(ans)

if __name__ == '__main__':
    resolve()

Submission status: Wrong Answer

Solution code:
def resolve():
    n, m = map(int, input().split())
    ans = n
    if m < 2:
        return print(0)
    if m <= 2*n:
        return print(n//2)
    diff = m - 2*n
    s = 0
    while diff >= 2:
        s += 1
        diff -= 2
        if s > 0 and diff >= 2:
            diff -= 2
            ans += 1

    print(ans)

if __name__ == '__main__':
    resolve()

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
for i in range(m-n):
    a = n + i
    b = m - i*2
    if 2*a > b:
        print (a-1)
        exit ()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

def main():
    mod=10**9+7
    N,M=MI()
    M+=N*2
    print(M//4)

main()

Submission status: Wrong Answer

Solution code:
#ABC055

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

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
S, c = list(map(int, input().split()))
chalf = c/2
b = 0
if S < chalf:
    b = chalf - (S+chalf)/2

print(int(S+b))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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