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

Submission status: Accepted

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


print(ans)

Submission status: Accepted

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

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


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

print(n+s)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

    total = s
    s_req = s * 2

    if c <= s_req:
        print(c // 2)
        return

    c -= s_req
    total += c // 4

    print(total)



if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
n, m = [int(i) for i in sys.stdin.readline().split()]
cnt = 0
if m >= 2 * n:
    cnt += n
    m -= n * 2
else:
    cnt += m // 2
    m = 0
print(cnt + m // 4)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
import string

class cin():
    def int():
        return int(sys.stdin.readline().rstrip())
    def string():
        return sys.stdin.readline().rstrip()
    def mapInt():
        return [int(x) for x in cin.string().split()]
    def stringList(n):
        return [input() for i in range(n)]
    def intListList(n):
        return [cin.mapInt() for i in range(n)]
    def intColsList(n):
        return [int(input()) for i in range(n)]
        
class Math():
    def gcd(a,b):
        if b == 0:
            return a
        return Math.gcd(b,a % b)
    def lcm(a,b):
        return (a * b) // Math.gcd(a,b)
    def roundUp(a,b):
        return -(-a // b)
    def toUpperMultiple(a,x):
        return Math.roundUp(a,x) * x
    def toLowerMultiple(a,x):
        return (a // x) * x
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret
    def isPrime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3,d + 1,2):
            if n % i == 0:
                return False
        return True

MOD = int(1e09) + 7

def main():
    N,M = cin.mapInt()
    ans = min(N,M // 2)
    N -= ans 
    M -= ans * 2
    ans += M // 4
    print(ans)
    return

if __name__ == "__main__":
    main()

Submission status: Accepted

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

if S*2 < C:
    #use all peace

    #1. use all S, and create Scc
    scc_num=S
    C -= S*2

    #2. c->s, and create Scc
    scc_num += int(C/4)

else:
    #Scc is bound by c
    scc_num=int(C/2)

print(scc_num)

Submission status: Accepted

Solution code:
# ARC069c
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6)

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def examC():
    N, M = LI()
    if N-M//2>=0:
        ans = M//2
    else:
        ans = N + (M-N*2)//4
    print(ans)
    return

def examD():
    return

def examE():
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
alphabet = [chr(ord('a') + i) for i in range(26)]

if __name__ == '__main__':
    examC()

"""

"""

Submission status: Accepted

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

ans = 0

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


print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

if 2*S>=C:
    print(C//2)
else:
    print(S+((C-2*S)//4))

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
N, M = map(int, input().split(' '))

#
ans = min(N, M // 2)
M -= ans * 2
N -= ans
ans += M // 4

print(ans)

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
'''
　 ∧_,,∧    究極奥義「WAがACになーれ！！」
　（`・ω・)つ━☆・*。
　⊂　　 ノ 　　　・゜+.
　 し’´Ｊ　　*・ 
'''
import sys
input = sys.stdin.readline
n,m=map(int,input().split())
if 2*n<=m:
    print(n+(m-2*n)//4)
else:
    print(m//2)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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


def main():
    S, c = map(int, input().split())
    if c >= 2 * S:
        print(S + (c-S*2)//4)
    else:
        print(c//2)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def slove():
    import sys
    input = sys.stdin.readline
    n, m = list(map(int, input().rstrip('\n').split()))
    cnt = min(n, m // 2)
    n -= cnt
    m -= (cnt * 2)
    if m != 0:
        cnt += (m // 4)
    print(cnt)


if __name__ == '__main__':
    slove()

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

ans=0

ans+=min(s,c//2)
s-=ans
c-=ans*2
#print(s,c)

ans+=c//4
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
def input():
	return sys.stdin.readline().strip()

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

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

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0

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

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def slove():
    import sys
    input = sys.stdin.readline
    n, m = list(map(int, input().rstrip('\n').split()))
    cnt = min(n, m // 2)
    n -= cnt
    m -= cnt * 2
    if m != 0:
        cnt += (m // 4)
    print(cnt)


if __name__ == '__main__':
    slove()

Submission status: Accepted

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


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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter,defaultdict
import sys,heapq,bisect,math,itertools,string,queue
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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 // 4)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# 2019/08/09

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
#ARC069C
import sys

#n=int(input())
tmp = input().split()
hoge = list(map(lambda a: int(a), tmp))
n=hoge[0]
m=hoge[1]

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

ans = 0
if 2*N <= M:
    ans += N
    M -= 2*N
else:
    ans += M//2
    M %= 2

ans += M//4
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

# S:N, c:M
# c+c = S

if M < 2*N :
    print(M // 2)
else :
    ans = N
    r = M - 2 * N  # 残り個数

    ans += r // 4  # (c + c)cc で一つ

    print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# ARC069C - Scc Puzzle (ABC055C)
def main():
    n, m = map(int, input().rstrip().split())
    ans = min(n, m // 2)
    ans += (m - ans * 2) // 4
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

M -= N * 2

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

Submission status: Accepted

Solution code:
from math import floor
s_num, c_num = tuple(int(i) for i in input().split(" "))
ans = 0
temp = s_num * 2
if c_num <= temp:
    ans += floor(c_num / 2)
else:
    ans += s_num
    ans += floor((c_num - temp) / 4)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:

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

ans = 0
N #個のS
2*N #個のC
#  N 個 の S と 2N個の C で SCCを作る
kosu = min(M//2,N)  #Sを使ってSCCを作れる個数

ans += kosu
M -= 2*kosu
N -= kosu


ans += M//4

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
C - Scc Puzzle
https://atcoder.jp/contests/arc069/tasks/arc069_a

"""
import sys


def solve(s, c):
    ans = min(s, c//2)
    s -= ans
    c -= (ans * 2)
    s += (c // 2)
    c //= 2
    ans += min(s, c//2)
    return ans


def main(args):
    s, c = map(int, input().split())
    ans = solve(s, c)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

Submission status: Accepted

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

Submission status: Accepted

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

count = 0

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

print(count)

Submission status: Accepted

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

Submission status: Accepted

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

basic = min(N,M // 2)
c = M - basic * 2

basic += c // 4;
print(basic)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools
import copy
import collections
from operator import itemgetter
#以下てんぷら
def j(q):
    if q==1: print("Yes")
    else:print("No")
    exit(0)


def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")

def ip():
    return int(input())
def printrow(a):
    for i in range(len(a)):
        print(a[i])
def combinations(n,r):
    if n<r:return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def permutations(n,r):
    if n<r:return 0
    return math.factorial(n) // math.factorial(n - r)
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)
#n = ip()                                     #入力整数1つ
s,c= (int(i) for i in input().split())       #入力整数横2つ以上
#a = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[ip() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#a=[input() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
#こっから本文
ans = 0
if c > s:
    ans+=s
    c-=s*2
    ans+=(c//4)
else:
    ans = c//2
print(ans)

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import exit, stdin
N, M = [int(_) for _ in stdin.readline().rstrip().split()]
r = M-2*N
if r <= 0:
    print(M//2)
else:
    print(N+r//4)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

S,c = map(int, input().split())
scc = 0

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, M = map(int, input().split())
c = 0
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())

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

print(ans)

Submission status: Accepted

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

count = N if N*2<=M else M//2
M -= N*2
count += M//4 if M>0 else 0

print(count)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    n,m = f()
    ans = 0
    if m< n*2:
        print(m//2)
    else:
        ans += n
        m -= 2*n
        print(ans + m//4)

solve()

Submission status: Accepted

Solution code:
s, c = map(int, input().split())
count = s
a1 = int((c-2*s)/2)
a2 = int(a1/2)
#print(a2)
s_add = int((int((c-2*s)/2))/2)
if 2 * s <= c: 
  print(s + s_add)
else:
  print(c // 2)

Submission status: Accepted

Solution code:
import sys
import collections
ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
nm = lambda: map(int, sys.stdin.readline().split())
nl = lambda: list(nm())
nsl = lambda: map(str, sys.stdin.readline().split())

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def POW(x, y):
    if y == 0:
        return 1
    elif y == 1:
        return x
    elif y % 2 == 0:
        return POW(x, y // 2) ** 2 % MOD
    else:
        return POW(x, y // 2) ** 2 * x % MOD
def mod_factorial(x, y): return x * POW(y, MOD - 2) % MOD
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()
from functools import reduce

def main():
    N, M = LI()
    if N >= M // 2:
        return M // 2
    rem = M - 2 * N
    ans = N + rem // 4
    return ans

print(main())

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# S -> S
# c -> c
# cc -> S

# count(S) > count(c)/2 -> count(Scc) = count(c)/2
# count(S) < count(c)/2 -> count(S) + (count(c) - count(S)*2)/4)

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

print(res)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

k = min(m // 2, (n + m // 2) // 2)
print(k)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat Feb  9 10:45:37 2019

@author: shinjisu
"""
# arc 069 Scc puzzle


def getIntList(): return [int(x) for x in input().split()]


def db(x):
    global debug
    if debug:
        print(x)


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


debug = False
N, M = getIntList()
db((N, M))
print(solve())

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

# n+k = m//2-k, 2k = m//2 - n, k = (m//2 - n) // 2

# min(n+k, (m-2k)//2) = min(n+k, m//2 - k)

p = (m // 2 - n) // 2
ans = min(n, m//2)
for k in range(max(0, p-10), p+10):
  v = min(n+k, m//2-k)
  if v >= 0:
    ans = max(ans, v)
  
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,M = map(int,input().split())
s_num = N
cc_num = M // 2
# ccの方が少ない場合はその数が答え
if min(s_num,cc_num) == cc_num:
    print(cc_num)
    exit()
# sの方が少ない場合はいくつかのccをsに変えて補完したものが答え
scc_num = s_num
cc_remains = cc_num - scc_num
sep_2 = cc_remains // 2
scc_num += sep_2
print(scc_num)

Submission status: Accepted

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