Problem:


Score : 300 points

Problem Statement

Snuke loves puzzles.

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

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

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

Constraints

1 ≤ N,M ≤ 10^{12}

Input

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

N M

Output

Print the answer.

Sample Input 1

1 6

Sample Output 1

2

Two Scc groups can be created as follows:

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

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

Sample Input 2

12345 678901

Sample Output 2

175897



Sample input:
1 6


Sample output:
2

Submission status: Wrong Answer

Solution code:
import fractions
import sys
from functools import reduce

input = sys.stdin.readline


def main():
    n, m = input_list()
    if n >= m // 2:
        print("a")
        print(m//2)
    else:
        c = (m-(2*n))//4
        print(n+c)


def input_list():
    return list(map(int, input().split()))


def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)


def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


def gcd(*numbers):
    return reduce(fractions.gcd, numbers)


def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import collections
import fractions
from functools import reduce
import sys
import math
input = sys.stdin.readline


def main():
    n, m = input_list()
    amari = m - (n * 2)
    scc = 0
    if amari >= 4:
        scc = amari // 4
    
    print(n + scc)

def input_list():
    return list(map(int, input().split()))

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import collections
import fractions
from functools import reduce
import sys
import math
input = sys.stdin.readline


def main():
    n, m = input_list()
    amari = m - (n * 2)
    scc = amari // 4
    print(n + scc)

def input_list():
    return list(map(int, input().split()))

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
count = 0
# まず，変換しないで行けるやつをできるだけ
if M >= 2*N:
    count += N
    M -= 2*N
else:
    count += N//2
    print(count)
    exit()

count += M//4
print(count)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right
# from math import gcd,ceil,floor,factorial
# from fractions import gcd
from functools import reduce
from pprint import pprint

INF = float("inf")

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

def mylistinput(n):
    return [ list(myinput()) for _ in range(n) ]

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    # lsはソート済みであること
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

def I():
    return int(input())

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

def RI():
    return list(map(int,input().split()))

def CI(n):
    return [ int(input()) for _ in range(n) ]

def LI(n):
    return [ list(map(int,input().split())) for _ in range(n) ]

def S():
    return input()

def MS():
    return input().split()

def RS():
    return list(input().split())

def CS(n):
    return [ input() for _ in range(n) ]

def LS(n):
    return [ list(input().split()) for _ in range(n) ]

n,m = RI()

ans = 0
if (2*n)<=m:
    ans += n
    ans += ( m - (2*n) )//4
elif n<=m and m<(2*n):
    ans += m//2
else:
    print("E")
    exit()
print(ans)

Submission status: Wrong Answer

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

print(cnt)

Submission status: Wrong Answer

Solution code:
import sys
from itertools import permutations

def solve():
    input = sys.stdin.readline
    N, M = map(int, input().split())
    if N >= M // 2: print(N)
    else:
        leftC = M - N * 2
        print(N + leftC // 4)

    return 0

if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

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

ans=0

if n>=m//2:
    print(n)
else:
    #cが多い場合
    tmp=m-n*2
    print(n+tmp//4)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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


def readstr():
    return input().strip()


def readint():
    return int(input())


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


def readstrs():
    return input().split()


N, M = readnums()

'''
N:M = 1:2が理想
N + x: M -2x = 1:2
2N+2x = M-2x
M-2N=4x
'''

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

Submission status: Wrong Answer

Solution code:
# 2020/05/01
# AtCoder Regular Contest 069 - C

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

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

# Output
print(ans)

Submission status: Wrong Answer

Solution code:
def main():
    ans = 0
    n,m = map(int, input().split())
    if m >= n * 2:
        ans += n
        m -= n * 2
    else:
        for i in range(n):
            if i * 2 > m:
                ans = i - 1
                m = ans * 2
                break
    ans += m // 4
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
# import fractions
# import sys
from sys import stdin

n, m = map(int, stdin.readline().rstrip().split())

m = m // 2
print((n + m) // 2)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def resolve():

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


resolve()

Submission status: Wrong Answer

Solution code:

def resolve():

    N,M=map(int,input().split())
    cnt=0
    while N*2<M:
        N+=1
        M-=2
        cnt+=1
    if N*2>M:
        print(N-1)
    else:
        print(N)


resolve()

Submission status: Wrong Answer

Solution code:
def main(n: int, m: int):
    ans = n

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

    print(ans)


if __name__ == "__main__":
    n, m = map(int, input().split())

    main(n, m)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

O = M//2

print( (N+O)//2 )

Submission status: Wrong Answer

Solution code:
N,M  = map(int, input().split())
# N : Sの数
# M : Cの数

if M <= 2*N: #Cの数が少ない
    print(N)
else:
    cnt = N
    M -= 2*N
    print(cnt+M//4)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
sc, cc = map(int, input().split())

bunkai = sc * 2
total_c = cc + bunkai

print(total_c//4)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if S < C*2:
    #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: Wrong Answer

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

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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(N // 2)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import math

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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


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

Submission status: Wrong Answer

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


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

Submission status: Wrong Answer

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


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

Submission status: Wrong Answer

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


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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

c=2*s+c
scc=c//4

print(scc)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

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

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# 2019/08/09

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

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

ans = 0
N #個のS
2*N #個のC
#  N 個 の S と 2N個の C で SCCを作る

if M >= 2*N:
    ans += N
    M -= 2*N
    N -= N


ans += M//4

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

M = M + N * 2

print(int(M / 4))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

ans += M // 4

print(ans)

Submission status: Wrong Answer

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

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

ans += M // 4

print(ans)

Submission status: Wrong Answer

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

count=0

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

count += M//4

print(count)

Submission status: Wrong Answer

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

s_add = int((int((c-2*s)/2))/2)

print(s_add+count)

Submission status: Wrong Answer

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)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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 = M // 2 + rem // 3
    return ans

print(main())

Submission status: Wrong Answer

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 >= 2 * M:
        return M
    rem = 2 * M - N
    ans = M + rem // 3
    return ans

print(main())

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

k = max(0, (n + m // 2) // 2)
print(k)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

p = (m // 2 - n) // 2
ans = 0
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: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
s = N
cc = M//2
if s > cc :
    ans = 0
else :
    for i in range(1+M//2) :
        if s < cc :
            s += 1
            cc -= 1
        else :
            ans = min(s,cc)
    print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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