Problem:


Score : 300 points

Problem Statement

Snuke loves puzzles.

Today, he is working on a puzzle using S- and c-shaped pieces.
In this puzzle, you can combine two c-shaped pieces into one S-shaped piece, as shown in the figure below:

Snuke decided to create as many Scc groups as possible by putting together one S-shaped piece and two c-shaped pieces.

Find the maximum number of Scc groups that can be created when Snuke has N S-shaped pieces and M c-shaped pieces.

Constraints

1 ≤ N,M ≤ 10^{12}

Input

The input is given from Standard Input in the following format:

N M

Output

Print the answer.

Sample Input 1

1 6

Sample Output 1

2

Two Scc groups can be created as follows:

Combine two c-shaped pieces into one S-shaped piece

Create two Scc groups, each from one S-shaped piece and two c-shaped pieces

Sample Input 2

12345 678901

Sample Output 2

175897



Sample input:
1 6


Sample output:
2

Submission status: Accepted

Solution code:
A = input().split()
a = int(A[0])
b = int(A[1])
import math
if 2*a <= b:
 a = a
else:
 a = int(b/2)
 a = math.floor(a)
R = (2*a+b)/4
R = math.floor(R)
print(R)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a = list(map(int, input().split()))
b, c = a[0], a[1]
ans = min(b, c // 2)
if b > c // 2:
    c = c % 2
else:
    c -= b * 2
b -= min(b, c // 2)
if c > 3:
    ans += c // 4
print(ans)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

    x = m//2
    if n <= x:
        sumv = n + (x-n)//2
    else:
        sumv = x
    print(sumv)
    
    
if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

print ans

Submission status: Accepted

Solution code:
nums = input().split()

N = int(nums[0])
M = int(nums[1])

sum = 0

if 2*N <= M:
    sum += N
    M -= 2*N
    if M >= 4:
        sum += M // 4
else:
    sum += M // 2    

print(sum)

Submission status: Accepted

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

Submission status: Accepted

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

import sys
import re
import math
import collections
import itertools
import functools

DEBUG = True
DEBUG = False

def dbg(*args):
    if DEBUG:
        print("DBG: ", file=sys.stderr, end="")
        print(*args, file=sys.stderr)


def possible(N, M, k):
    if N >= k:
        return M >= 2*k
    else:
        M -= 2*(k-N)
        return M >= 2*k

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

    # cc -> S はできるが S -> cc はできない

    # [lo, hi)
    # lo では必ず可能、hiでは必ず不可能
    hi = M // 2 + 1
    lo = M // 4
    while hi - lo > 1:
        mid = (hi + lo) // 2
        if possible(N, M, mid):
            lo = mid
        else:
            hi = mid

    print(lo)

if __name__ == "__main__": main()

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from collections import defaultdict


def main():
    N, M = map(int, input().split())
    a = min(N, M // 2)
    r = M - (2 * a)
    print(a + r // 4)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def is_possible(N, M, m):
    if M >= 2 * m:
        r = M - 2 * m
        t = r // 2
        if N + t >= m:
            return True
    return False


def solve(N, M):
    a = 0
    b = 10 ** 20
    while b - a > 1:
        m = (a + b) // 2
        if is_possible(N, M, m):
            a = m
        else:
            b = m
    return a

N, M = map(int, input().split())
res = solve(N, M)
print(res)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(scc)

Submission status: Accepted

Solution code:
ar = raw_input().split(' ')
s = int(ar[0])
c = int(ar[1])

scc1 = min(s, int(c/2))
s = s - scc1
c = c - 2*scc1

scc2 = int(c/4)

print scc1 + scc2

Submission status: Accepted

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

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

print (ans)

Submission status: Accepted

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

if s*2 <= c:
    add_pair = 0
    if c-s*2 >=3:
        add_pair = int((c-s*2)/4)
    print(s+add_pair)

else:
    print(int(c/2))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def solve(N, M) :
    if 2 * N >= M :
        return M // 2
    return (2 * N + M) // 4


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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

import sys
import os


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

S_num = N
c_num = M

# cが豊富にないとき
if c_num // 2 <= S_num:
    print(c_num // 2)
else:
    # まずS個作れる
    all = S_num
    # cを消費する
    c_num -= (2 * S_num)

    # 残りのcで何個作れるか
    all += c_num // 4

    print(all)

Submission status: Accepted

Solution code:
s_num, c_num = map(int, input().split())

ans = 0

if s_num * 2 >= c_num:
    ans = c_num // 2
else:
    ans += s_num
    c_num -= s_num * 2
    ans += c_num // 4

print(ans)

Submission status: Accepted

Solution code:
s_num, c_num = map(int, input().split())

ans = 0

if s_num * 2 >= c_num:
    ans = min(s_num, c_num // 2)
else:
    ans += s_num
    c_num -= s_num * 2
    ans += c_num // 4

print(ans)

Submission status: Accepted

Solution code:
#! coding:UTF-8
N,M = list(map(int,input().split(" ")))
result = 0
c_need = N * 2
if c_need >= M:
	result += M // 2
	print(result)
else:
	result += (N + (M-c_need)//4)
	print(result)

Submission status: Accepted

Solution code:
S ,c  = map(int, input().split())
# 2cでSになる

X = 0
if c > S*2:
    X += S
    c -= 2*S
    X += int(c/4)
    print(X)
else:
    print(int(c/2))

Submission status: Accepted

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

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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
if __name__ == "__main__":
    inp = [int(i) for i in input().split()]
    N = inp[0]
    M = inp[1]
    if 2*N >= M:
        print(M//2)
    else:
        print(N+(M-2*N)//4)

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

ans += m // 4

print(ans)

Submission status: Accepted

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

sa = M - 2*N
x = 0

if sa <0:
    x = M//2
else:
    x = N + sa//4

print(x)

Submission status: Accepted

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

else:

    s+=m/2
    # s+=(m-(m/2))/
print s

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

print(a)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
# sys.setrecursionlimit(10000)


def main():
    # 入力処理
    N, M = map(int, input().split())

    # アルゴリズム本体
    if (2 * N) >= M:
        K = int(M / 2)
    else:
        K = N + int((M - 2 * N) / 4)

    # 出力
    print(K)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
import numpy as np
from math import *
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, M] = [int(input_raw[0]), int(input_raw[1])]
    T = M - 2 * N
    if T < 0:
        scc_num = int(M/2)
    else:
        scc_num = N + int(T/4)

    print scc_num

if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding:utf-8
#
# atcoder begginger content 55

s, c = map(int, raw_input().split())
ans = 0

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

print ans

Submission status: Accepted

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

Submission status: Accepted

Solution code:
NM = raw_input().split()
cPairs = int(NM[1]) / 2
SCCby1S2C = min([int(NM[0]),cPairs])
NM[0] = int(NM[0]) - SCCby1S2C
cPairs = cPairs - SCCby1S2C
SCCby4C = cPairs / 2
print SCCby1S2C + SCCby4C

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

#cが足りない場合
if s*2>=c:  
    print(int(c/2))
else:
    print(s+int((c-s*2)/4))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,M= [int(x) for x in raw_input().split()]
S = M - N*2
if S > 0:
    print str(int(S//4+N))
else:
    print str(int(M//2))

Submission status: Accepted

Solution code:
N,M=[int(x) for x in input().split()]
if N >= M:
    Scc = M//2
elif N < M and (M - 2*N >=4):
    Scc = N + (M-2*N)//4
else:
    Scc = N
print(Scc)

Submission status: Accepted

Solution code:
N, M = [int(i) for i in input().split()]
a = min(N, M//2)
print((M - a * 2) // 4 + a)

Submission status: Accepted

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


def check(a):
    b = M - 2 * a
    if b < 0:
        return False
    return b // 2 + N >= a

left, right = 0, M
while right - left > 1:
    mid = (left + right) // 2
    if check(mid):
        left = mid
    else:
        right = mid
print(left)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8


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

    result = s - int(c / 2)

    if result < 0:
        r = result * -2
        r = int(r / 4)
        print(s + r)
    else:
        print(s - result)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

print(count)

Submission status: Accepted

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


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

else:
	cnt = M//2

print cnt

Submission status: Accepted

Solution code:
a=input().split()
N=int(a[0])
M=int(a[1])
ans=0

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

print(int(ans))

Submission status: Accepted

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


S,C = map(int, raw_input().split())
SCC = 0
if(C>=2*S):
    SCC += S
    C = C-2*S
    S = 0
    SCC += C/4
else:
    SCC = C/2
print(SCC)

Submission status: Accepted

Solution code:
import math
def input_parser():
    N, M=(int(str) for str in input().split())
    return N, M
N, M=input_parser()
if N*2>M:
    ans=math.floor(M/2)
else:
    remc=M-N*2
    ans=N+math.floor(remc/4)

def output_parser(output):
    print(output)

output_parser(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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


def main():
    n, m = map(int, input().split())
    c_num = n * 2

    if m - c_num < 0:
        result = m / 2
    else:
        result = n + ((m - c_num) / 4)
    print(int(result))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

if(s < c/2):
    s_pair = s
    c_pair = (c - s*2)/4
else:
    s_pair = c/2
    c_pair = 0

print s_pair + c_pair

Submission status: Accepted

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

Submission status: Accepted

Solution code:
data = input().split()
N = int(data[0])
M = int(data[1])

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

print(sum)

Submission status: Accepted

Solution code:
s, c = [int(e) for e in input().split()]


def main(s, c):
    if s >= c // 2:
        return c // 2
    else:
        ret = s
        c -= s * 2
        ret += c // 4
        return ret


ans = main(s, c)
print(ans)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
MOD = 1000000007

l = input().split()
s = int(l[0])
c = int(l[1]) // 2

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


print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
INF=10**10

def main():
    
    n,m=list(map(int,input().split()))
    
    ans=0
    if n>=m//2:
        ans=m//2
        print(ans)
        return 0
    
    ans+=n #n使い切り
    m-=2*n
    ans+=m//4
    print(ans)
    
    
if __name__=="__main__":
    main()

Submission status: Accepted

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

print(str(Scc))

Submission status: Accepted

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

print(str(Scc))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def solve(n, m):
    if 2 * n <= m: #on utilise tous les s
        r1 = n
    else:
        r1 = m // 2
    m -= 2 * r1

    r2 = m // 4

    res = r1 + r2
    return res

n, m = input().split()
n = int(n)
m = int(m)
print(solve(n, m))

Submission status: Accepted

Solution code:
import sys
import math

n, m = [int(x) for x in sys.stdin.readline().split()]

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def compare(a, b): # a also b are both string
	l = max(len(a), len(b))
	a_ = a.rjust(l, '0')
	b_ = b.rjust(l, '0')
	return a_ > b_

def divide(num, den): # den is integer
	quo = ''; resi = 0
	digit = len(num) if int(num[0]) >= den else len(num)-1
	for i in range(len(num)):
		temp = (int(num[i])+resi*10)//den
#		print('dtemp', temp)
		resi = (int(num[i])+resi*10)%den
#		print('dresi', resi)
		quo += str(temp)
	return quo

def multi(a, n):
	s = ''; resi = 0
	for i in range(len(a))[::-1]:
		temp = (int(a[i])*n + resi)%10
#		print('mltemp', temp)
		resi = (int(a[i])*n + resi)//10
#		print('mlresi', resi)
		s = str(temp) + s
	return s


def plus(a, b):
	l = max(len(a), len(b))
	a_ = a.rjust(l, '0')
	b_ = b.rjust(l, '0')

	s = ''; resi = 0
	for i in range(l)[::-1]:
		temp = (int(a_[i]) + int(b_[i]) + resi)%10
#		print('ptemp', temp)
		resi = (int(a_[i]) + int(b_[i]) + resi)//10
#		print('presi', resi)
		s = str(temp) + s
	return s

# a is higher than b
def minus(a, b):
	l = max(len(a), len(b))
	a_ = a.rjust(l, '0')
	b_ = b.rjust(l, '0')

	s = ''; bollow = 0
	for i in range(l)[::-1]:
		temp = int(a_[i]) - int(b_[i]) - bollow
#		print('mitemp', temp)
		bollow = 0
		if temp >= 0:
			s = str(temp) + s
		else:
			bollow = 1
			s = str(temp + 10) + s
	return s


s, c = input().split()
if compare(s, divide(c, 2)) or s == c:
	print(int(divide(c, 2)))
else:
	print(int(plus(s, divide(minus(c, multi(s, 2)), 4))))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

def makePuzzle():
    count_Scc = 0
    tmp = sys.stdin.readlines()
    num_s, num_c = tmp[0].split(" ")
    num_s = int(num_s)
    num_c = int(num_c)

    if num_c-num_s*2>=0:
        count_Scc = num_s
        num_c = num_c - num_s*2
        count_Scc = count_Scc + num_c//4
    else:
        count_Scc = num_c//2

    return count_Scc

if __name__=="__main__":
    print(makePuzzle())

Submission status: Accepted

Solution code:
N, M = map(int, input().split(' '))
def sunuke_f3(n, m) :
    if n >= m :
        return(m//2)
    else :
        if 2*n < m :
            return(n + (m-2*n)//4)
        else :
            return(m//2)
print(sunuke_f3(N, M))

Submission status: Accepted

Solution code:
# -*- coding:utf-8 -*-
N, M = map(int, input().split())
if M > 0:
    if N*2 <= M:
        print((N+M//2)//2)
    else:
        print(M//2)
else:
    print(0)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
#!/usr/bin/python

import sys

def main(argv):
    for line in sys.stdin:
        n, m = map(lambda i: int(i), line.split(' ', 2))

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

if __name__ == "__main__":
    main(sys.argv)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
l=raw_input().split()
M=int(l[0])
N=int(l[1])

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

print(A)

Submission status: Accepted

Solution code:
#coding: UTF-8
N,M=map(int,input().split())
c=M//2
if N>c:
    out=c
else:
    amari=M-N*2
    out=N+amari//4
print(out)

Submission status: Accepted

Solution code:
N,M = input().split()
s0,c0 = int(N),int(M)
c1 = c0 - s0*2 
c2 = int(c1/4) if c1 >= 0 else 0 
s = s0 if s0 < c0 else c0//2
print(s+c2)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
n = list(map(int, input().split()))
s = n[0]
c = n[1]

ans = 0
if s * 2 < c:
    ans = s
    c = c - (s * 2)
else:
    # cが足りない場合、Sが作れないのでccを作れる数がMAX
    ans = int(c / 2)
    print(str(ans))
    quit()
# sは使い切っててcが4個2個でS+cc1増える
ans += int(c / 4)
print(str(ans))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
line = raw_input()
inputs = line.split(" ")
N, M = [int(i) for i in inputs]
assert(1 <= N <= 1e12)
assert(1 <= M <= 1e12)
if M >= 2*N:
    print N + (M - 2*N)/4
else:
    print M/2

Submission status: Accepted

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

NS = N
Nc = M
Ncc = Nc // 2

if NS < Ncc:
    # ccが余ってる
    Nc_single = Nc - NS * 2
    ans = NS + Nc_single // 4
else:
    # Sが余ってる
    ans = Ncc

print(ans)

Submission status: Accepted

Solution code:
nb_s, nb_c = map(int, input().split())

if nb_s*2 > nb_c:
    print(nb_c // 2)
else:
    nb_used_c = 2*nb_s

    nb_rest_c = int(nb_c) - nb_used_c

    print(int(nb_s) + (nb_rest_c // 4))

Submission status: Accepted

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

scc = 0

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

print(scc)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# 整数の入力
N,M = map(int, input().split())
# パターン1
if M <= 2*N:
    ans = M // 2
else:
    ans = N + (M-2*N) // 4    

# 出力
print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
# 整数の入力
s, c = map(int, raw_input().split())
ans = 0
a = min(s,c/2)
s -= a
c -= a*2
ans = a + (c/4) 
print ans

Submission status: Accepted

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

Submission status: Accepted

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

k = m // 2
r = m % 2
if n >= k:
    print(k)
else:
    print(n + (k-n) // 2)

Submission status: Accepted

Solution code:
l = input().split()
n = int(l[0])
m = int(l[1])
a = 0

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

Submission status: Accepted

Solution code:
S, C = [int(i) for i in input().rstrip().split()]
rest_C = C - S * 2
sum = 0
if rest_C < 0:
    print(C // 2)
else:
    print(S + rest_C // 4)

Submission status: Accepted

Solution code:
from sys import stdin

s, c = map(int, stdin.readline().split())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
data = input().split()
N = int(data[0])
M = int(data[1])

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

Submission status: Accepted

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

print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
N, M = [int(n) for n in input().split()]
scc = 0

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# coding: utf-8
def getLnInputs():
    return input().split()


def getLnIntInputs():
    return list(map(int, getLnInputs()))


def main():
    N, M = getLnIntInputs()
    if M <= N * 2:
        print(M // 2)
        return

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

    return


main()

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

min_n = n
min_m = m // 2
ans = min(min_n, min_m)

if min_n < min_m:
    m -= min_n * 2
    ans += m // 4

print(ans)

Submission status: Accepted

Solution code:
from collections import defaultdict


def main():
    N, M = map(int, input().split())
    ans = min(N, M // 2)
    N -= ans
    M -= (ans * 2)

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

def calc(n,m):
  if n>m//2:
    return m//2
  else:
    tcnt = n
    m = m - 2*n
    return tcnt + m//4

print(calc(n,m))

Submission status: Runtime Error

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

Submission status: Runtime Error

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)
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: Runtime Error

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)
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: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

possible_c = m
possible_s = n * 2

one_valid = 4

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

print(ans)

Submission status: Runtime Error

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: Runtime Error

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

Submission status: Runtime Error

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

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

print(ans)

Submission status: Runtime Error

Solution code:
def slove(n, m):
    tmp = n if n < m // 2 else m // 2
    tmp2 = (m - tmp * 2) // 4
    return tmp + tmp2
    
if __name__ == "__main__":
    n, m = [i for i in input().split()]
    print(slove(n, m))