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:
# -*- coding: utf-8 -*-
"""
Created on Wed Sep 30 00:56:12 2020

@author: liang
"""

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

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

Submission status: Accepted

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

if m >= 2 and n > 0:
  ans += min(n, m // 2)
  m -= 2*ans

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import math
from math import gcd,pi,sqrt
INF = float("inf")
MOD = 10**9 + 7

import sys
sys.setrecursionlimit(10**6)
import itertools
import bisect
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]


def main():
    N,M = i_map()
    if M <= 2*N:
        print(M//2)
        exit()

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

if __name__=="__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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())
if 2*n>=m:
    print(m//2)
else:
    x=(m-2*n)//4
    ans=min(n+x,(m-2*x)//2)
    x+=1
    anser=min(n+x,(m-2*x)//2)
    print(max(ans,anser))

Submission status: Accepted

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

Submission status: Accepted

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

n = N
m = M // 2

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

Submission status: Accepted

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

Submission status: Accepted

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

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:
import sys, os, math, bisect, itertools, collections, heapq, queue, copy, array

# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
# from decimal import Decimal
# from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7
INF = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, M = il()

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

    if m - 2 * n >= 0:
        m -= 2 * n
        ans = n
        n = 0

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

        ans += (m - 2 * tmp) // 2

    else:
        ans = m // 2

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

cnt += c//4
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

l = 0
r = 10**12+1

while r-l>1:
    s = (r+l)//2#作るべきsとc
    c = 2*s
    t = s

    S,C = N,M
    s-=S#Sは全部使った
    if s > 0:
        C-=2*s
    if C < c:
        r = t
    else:
        l = t
    
print(l)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
#
# abc055 c
#

import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """1 6"""
        output = """2"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """12345 678901"""
        output = """175897"""
        self.assertIO(input, output)


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

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


if __name__ == "__main__":
    # unittest.main()
    resolve()

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# C - Scc Puzzle
def main():
    n, m = map(int, input().split())


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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

if s == c:
    print(s)
elif s > c:
    print(c)
elif s < c:
    t = c - s
    print(s + t//2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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




if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

cc = m//2
ans = min(n, cc) 
res = cc-min(n, cc) 
if res > 0:
    ans += res//2
print(ans)

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
a,b=map(int, input().split())

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

Submission status: Accepted

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

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

Submission status: Accepted

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

def main():
    N, M = map(int, input().split())
    if M <= 2 * N:
        print(M // 2)
    else:
        k = (M - 2 * N) // 4
        ans= 0
        for i in range(max(0, k - 4), min(M // 2, k + 4)):
            if (M - 2 * i) <= 2 * (N + i):
                ans = max(ans, (M - 2 * i) // 2)
            else:
                ans = max(ans, N + i)
        print(ans)
    
    

if __name__ == "__main__":
    main()

Submission status: Accepted

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

print f(n,m)

Submission status: Accepted

Solution code:
n, m = map(int, raw_input().split())
def f(n,m): 
	if n == 0:
		return m /4


	x = min(n, m/2)
	if x:
		return x + f(n - x,m - 2*x)
	else:
		return 0
print f(n,m)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
N,M = (int(T) for T in input().split())
if M-2*N>0:
    Convert = int(math.floor((M-2*N)/4))
    N += Convert
    M -= 2*Convert
    print(N)
else:
    print(M//2)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

if 2 * S >= C:
  print(min([S, int(C/2)]))
else:
  print(S + int((C - 2 * S) / 4))

Submission status: Accepted

Solution code:
n, m = list(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())
if 2*N < M:
    extra = (M - 2*N) // 4
    ans = N + extra
else:
    ans = M // 2
print(ans)

Submission status: Accepted

Solution code:
n, m = map(int, input().split())
m = (m//2) * 2
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())

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

Submission status: Accepted

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

Submission status: Accepted

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

if (2 * s == c):
    ans = s

elif (2 * s > c):
    ans = c // 2

else:
    ans = s
    tar = c - 2 * s

    ans += tar // 4


print(int(ans))

Submission status: Accepted

Solution code:
def cin():
    in_ = list(map(int,input().split()))
    if len(in_) == 1:  return in_[0]
    else:  return in_

N, M = cin()
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:
n, m = list(map(int, input().split()))
res = 0
if n > m // 2:
    res = m // 2
    print(res)
else:
    res = n
    n -= res
    m -= res * 2
    # ここでnは0
    res += m // 4
    print(res)

Submission status: Accepted

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

if N >= 2*M:
  print(M//2)
  exit()
  
def f(x):
  return max(min(N+x, (M-2*x)//2),0)
  
delta = [-3,-2,-1,0,1,2,3]
x = (M-2*N)//4

ans = 0
for i in range(7):
  x_ = max(0,x+delta[i])
  ans = max(ans,f(x_))

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
N,M = map(int,input().split())
if not ( 1 <= N <= 10**12 and 1 <= M <= 10**12 ): sys.exit()

count_SCC=0
if M > 2*N : #Mがあまる
    M = M - 2*N
    count_SCC = N + M//4
elif M < 2*N : #Nがあまる
    count_SCC = M//2
print(count_SCC)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N,M=map(int,input().split())
print(min(N,M//2)+max(M-N*2,0)//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 n*2 <= m:
  ans += n
  m -= n*2
else:
  ans += m//2
  print(ans)
  exit()
  
if 4 <= m: ans += m//4
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, m = list(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())

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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:
import sys, math
from collections import defaultdict
from itertools import product
sys.setrecursionlimit(500000)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

class Graph:
    #グラフを表す

    # 頂点につけるlabelの初期値（ラベリングされていないことを示す値）
    no_labeling_num = -1

    class Vertex:
        # 頂点を表す

        def __init__(self, g, no, label):
            """

            :param g: グラフを表す。またVertexを所有するオブジェクトでもある
            :param no: 頂点にグラフのなかで一意に割り振られた識別用の番号
            :param label: 探索された順番を表す番号。ラベル。
            """
            self.no = no
            self.g = g
            self.label = label

        def __str__(self):
            """
            　
            """
            return "no:{0},label:{1}".format(self.no,self.label)

        def adjacentVs(self):
            """ selfと隣接している頂点のリストを返す

            :return:
            """
            result = []
            for c in range(self.g.order):
                if self.g.aDJM[self.no][c] == 1:
                    result.append((self.g.vs[c]))
            return result

        def back_to_previous(self):
            """ 前に探索した頂点を返す（厳密な表現ではない）
            詳細
            ・この頂点に隣接する頂点において、ラベル付けされていない（未探索）なものがないときに、
            次に探索する頂点を返す関数
            ・自身のラベル番号より小さい頂点の中で一番近いものを返す
            ・存在しないときは「None」を返す

            :return:
            """
            result = None
            vs = list(filter(lambda x: self.label > x.label, self.adjacentVs()))
            if vs != []:
                result = vs[0]
                key0 = self.label - result.label
                for v in vs:
                    key1 = self.label - v.label
                    if (key1 < key0):
                        key0 = key1
                        result = v

            return result

    def __init__(self, aDJM):
        """
        
        :param aDJM:隣接行列
        """
        self.aDJM = aDJM
        self.order = len(aDJM)
        self.vs = [Graph.Vertex(self, i, self.no_labeling_num) for i in range(self.order)]

    def no_labelingVs(self, vs):
        """ 渡された頂点リストにおいてlabelingされていない頂点のリストを返す

        :return:
        """
        result = []
        for v in vs:
            if v.label == self.no_labeling_num:
                result.append(v)
        return result

    def isconnected(self):
        """ このグラフが連結グラフであるかどうかを判定する
        
        :return:
        """
        label = 0
        v = self.vs[0]
        v.label = label
        # 最初に探索した頂点が孤立点である場合に対処するための条件
        if v.adjacentVs()==[]:
            v=None
        else:
            v = v.adjacentVs()[0]
            label += 1
            v.label = label
        while (v != None):  # 現在探索中の頂点のラベルが0かつその点に隣接する頂点すべてが探索ずみだったら終了するようにする
            vs = self.no_labelingVs(v.adjacentVs())
            if vs == []:
                v = v.back_to_previous()
            else:
                v = vs[0]
                label += 1
                v.label = label

        return not(self.no_labeling_num in list(map(lambda x:x.label,self.vs)))


def main():
    N, M = mi()
    k = max((M//2-N)//2, 0)
    print(min(N+k, (M-2*k)//2))

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


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

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

    print(ans)
    return


if __name__ == '__main__':
    main()

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


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys

N, M=map(int,input().split())
Mh=M//2

if N>Mh:
  print(Mh)
  sys.exit()
else:
  rem=M-2*N
  print(rem//4+N)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import math
import itertools
import bisect
from copy import copy,deepcopy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(map(int,input().split()))
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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())
M//=2
print(min(M,(N+M)//2))

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

print(int(ans))

Submission status: Accepted

Solution code:
import sys;input = lambda : sys.stdin.readline()
n,m = map(int,input().split())
if m-2*n>=0:
    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:
    ans=n+(m-(2*n))//4
else:
    ans=m//2

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n, m = map(int, readline().split())
    if 2 * n > m:
        ans = min(n, m // 2)
    else:
        c = m - 2 * n
        ans = n + c // 4

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,m = map(int,input().split())
count = 0
if m >= 2*n: #ex)3,6 4,15
    m -= 2*n
    count = n+(m//4)
#elif n <= m:  #ex)3,3 3,4 ,5 8
#    count = m//2
else:
    count = m//2
print(count)

Submission status: Accepted

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

Submission status: Accepted

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

real = M - 2*N

if real < 0:
    ans = M // 2
elif real == 0:
    ans = real
else:
    a = real // 4
    ans = a + N

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!python3

LI = lambda: list(map(int, input().split()))

# input
N, M = LI()


def main():
    s = N
    c = M
    x = min(s, c // 2)
    c -= 2 * x
    y = c // 4
    ans = x + y
    print(ans)
    


if __name__ == "__main__":
    main()

Submission status: Accepted

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

x = min(N, M//2)

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

Submission status: Accepted

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


def calculate(n, m):

    if (m // 2) < n:
        print(m // 2)
        return

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

calculate(N, M)

Submission status: Accepted

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

m //= 2

ans = 0

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

Submission status: Accepted

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:
  count += m//2


print(count)

Submission status: Accepted

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

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

print(min(N, M // 2))

Submission status: Accepted

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

counter=0
#まずあるものでsccを作る
raw_scc=min(N//1,M//2)
N-=raw_scc
M-=raw_scc*2
counter+=raw_scc

#のこったcだけで作る
counter+=M//4
print(counter)

Submission status: Accepted

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

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

print(count)

Submission status: Accepted

Solution code:
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    n,m=map(int,readline().split())

    ans=0
    t=min(n,m//2)
    ans+=t
    n-=t
    m-=2*t
    ans+=m//4
    print(ans)
    
if __name__=="__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,M = list(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:
    print(M//2)
else:
    tmp = M - N*2
    print(tmp//4+N)

Submission status: Accepted

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