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:
s, c = list(map(int, input().split()))
use_s = 0
remain = c
for num in range(0, s):
	remain -= 2
	use_s += 1
	if(remain <= 0):
		break
remain_c = int(remain / 4)
amount = use_s + remain_c
use_c_only = int(c / 4)
if(amount > use_c_only):
	print(amount)
else:
	print(use_c_only)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


main()

Submission status: Wrong Answer

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


main()

Submission status: Wrong Answer

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


main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:


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

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






if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
from math import ceil, floor
n, m = map(int, raw_input().split())
scc = 0
while n > 0 and m >= 2:
	if m >= 2*n:
		scc += n
		m -= 2*n
		n = 0
	elif n > 0 and m >= 2 and m < 2*n:
		n -= m/2
		m = m%2 
		scc += m/2
	if n == 0 and m >= 4:
		n += m/4
		m = int(ceil(float(m)/2))
print scc

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

count = 0

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

else:
    count = (c - 1) / 2 if c % 2 == 1 else c / 2
    print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

if __name__ == '__main__':
    N, M = map(int, input().split())

    main(N, M)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

while 2*n < m:
    n += 1
    m -= 2

if 2*n > m:
    n -= 1
    m += 2

print(n)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# sはありったけ使うほうがいい（cから作るとコストがかかる）
# ありったけ = m//2
# 残ったcからsccを作るには4つ必要

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

Submission status: Wrong Answer

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

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

print(n + x)

Submission status: Wrong Answer

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

ans = 0
buff1 = M - N * 2
if buff1 < 0:
    print(0)
    exit()
count = buff1 // 4

ans = N + count
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

    scc+=int(M/4)
    print(scc)

Submission status: Wrong Answer

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

    scc+=int(M/4)
    print(scc)

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:
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()
    cnt = min(n*2, m)
    ans = cnt//2
    remain = m - ans

    print(ans + remain//4)

solve()

Submission status: Wrong Answer

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

num = min(N, M // 2) + M // 4

print(num)

Submission status: Wrong Answer

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

m = M + N * 2

print(m // 4)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

ans = 0
for i in range(N, 0, -1):
    if M - 2*i >= 0:
        ans += N
        M -= 2*N
        break
ans += M//4
print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:


def read_input():
    n, m = map(int, input().split())
    return n, m


def submit():
    n, m = read_input()

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


if __name__ == '__main__':
    submit()

Submission status: Wrong Answer

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

if m >= n * 2:
    res = n + (m-n*2) // 4
elif m < n * 2 and n//2 <= m:
    res = n
else:
    res = m // 2

print(res)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if N < M//2:
    scc_min = max(1, N)
else:
    scc_min = M//2
scc_max = N + M//2

while scc_min < scc_max:
    scc = (scc_min + scc_max) // 2
    excess_c = M - scc*2
    if scc_min + 1 == scc_max:
        break
    if excess_c//2 + N >= scc:
        scc_min = scc
    else:
        scc_max = scc - 1

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

Submission status: Wrong Answer

Solution code:
import sys

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

    if N >= M // 2:
        ans = M // 2
        N -= M // 2

        ans += N // 2

        return ans

    else:
        ans = N
        M -= 2 * N

        ans += M // 4

        return ans


if __name__ == '__main__':
    print(main())

Submission status: Wrong Answer

Solution code:
from functools import reduce
import math

def main():
    # N! を求める
    # f = math.factorial(N)
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    # 1e10

    # 初期値用:十分小さい数(-100億)
    # -1e10
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    N,M = (int(_) for _ in input().split())
    if(M<2):
        print(0)
        exit()
    if N>M//2:
        N = N-(N - M//2)
        print(N,M)
    ans = (N*2 + M)//4
    # while True:
    #     N = N -1
    #     M = M -2
    #     ans = ans + 1
    #     if(N<=0 or M<=0):
    #         break
    # if(N<=0 and M>0):
    #     ans = ans + M//4
             
    print(ans)
    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from functools import reduce
import math

def main():
    # N! を求める
    # f = math.factorial(N)
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    # 1e10

    # 初期値用:十分小さい数(-100億)
    # -1e10
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    N,M = (int(_) for _ in input().split())
    ans = (N*2 + M)//4
    # while True:
    #     N = N -1
    #     M = M -2
    #     ans = ans + 1
    #     if(N<=0 or M<=0):
    #         break
    # if(N<=0 and M>0):
    #     ans = ans + M//4
             
    print(ans)
    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from functools import reduce
import math

def main():
    # N! を求める
    # f = math.factorial(N)
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    # 1e10

    # 初期値用:十分小さい数(-100億)
    # -1e10
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    N,M = (int(_) for _ in input().split())
    ans = 0
    while True:
        N = N -1
        M = M -2
        ans = ans + 1
        if(N<=0 or M<=0):
            break
    if(N<=0 and M>0):
        ans = ans + M//4
             
    print(ans)
    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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())
ans1 = 0
import math
if N <= M:
    ans1 = 0
    if 2 * N <= M:
        ans1 = N
        M -= ans1 * 2
    ans2 = math.floor(M / 4)
    print(int(ans1 + ans2))
else:
    print(int(math.floor(M / 2)))

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
ans1 = 0
if 2 * N <= M:
    ans1 = N
    M -= ans1 * 2
# print(ans1)
# print(M)

import math
ans2 = math.floor(M / 4)
# print(ans2)

print(int(ans1 + ans2))

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
ans1 = 0
if 2 * N <= M:
    ans1 = N
    M -= ans1 * 2
# print(ans1)
# print(M)

ans2 = M // 4
# print(ans2)

print(ans1 + ans2)

Submission status: Wrong Answer

Solution code:
# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)	a=int(input())	a=5
# 1 2	| x,y = s_inpl()   |	x=1,y=2
# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　	li = inpl()	li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']

# INPUT
# 3
# hoge
# foo
# bar
# ANSWER
# n=int(input())
# string_list=[input() for i in range(n)]

import math
import copy
from collections import defaultdict, Counter
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
from bisect import bisect_left, bisect_right
# import numpy as np

def i_inpl(): return int(input())
def s_inpl(): return map(int,input().split())
def l_inpl(): return list(map(int, input().split()))
INF = float("inf")

N, M = s_inpl()

ans = 0
diff = M-N*2
if diff>=0:
    M = M-N*2
    ans += N
else:
    M = 0
    ans += M//2

ans += M//4
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
for i in range(10 ** 6 + 10):
    if N - i >= 0 and M - 2 * i >= 0:
        continue
    elif N - i >= 1:
        N -= 1
    elif M - 2 * i >= 2:
        M -= 2
    else:
        print(i - 1)
        break

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
if 2 * N < M:
    for i in range(10 ** 6):
        if 2 * (N + i) <=  M - 2 * i:
            continue
        print(N + i - 1)
        break
elif 2 * N > M:
    for i in range(10 ** 6):
        if 2 * (N - i) > M + 2 * i:
            continue
        print(N - i)
        break
else:
    print(N)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
if 2 * N < M:
    for i in range(10 ** 6):
        if 2 * (N + i) <=  M - 2 * i:
            continue
        print(N + i - 1)
        break
elif 2 * N > M:
    for i in range(10 ** 6):
        if 2 * (N - i) >= M + 2 * i:
            continue
        print(N - i)
        break
else:
    print(N)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
if 2 * N < M:
    for i in range(10 ** 6):
        if 2 * (N + i) <=  M - 2 * i:
            continue
        print(N + i - 1)
        break
elif 2 * N > M:
    for i in range(10 ** 6):
        if 2 * (N - i) >= M + 2 * i:
            continue
        print(N - (i - 1))
        break
else:
    print(N)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
if 2 * N <= M:
    for i in range(10 ** 6):
        if 2 * (N + i) <=  M - 2 * i:
            continue
        print(N + i - 1)
        break
elif 2 * N > M:
    for i in range(10 ** 6):
        if 2 * (N - i) >= M + 2 * i:
            continue
        print(N - i + 1)
        break

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
if 2 * N <= M:
    for i in range(10 ** 6):
        if 2 * (N + i) <=  M - 2:
            continue
        print(N + i - 1)
        break
elif 2 * N > M:
    for i in range(10 ** 6):
        if 2 * (N - i) >= M + 2:
            continue
        print(N - i + 1)
        break

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
if 2 * N <= M:
    for i in range(10 ** 6):
        if 2 * (N + i) <=  M - 2 * i:
            continue
        print(N + i - 1)
        break
elif 2 * N > M:
    for i in range(10 ** 6):
        if 2 * (N - i) >= M + 2:
            continue
        print(N - i + 1)
        break

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
while True:
    if 2 * (N + 1) <= M - 2:
        N += 1
        M -= 2
    elif 2 * (N - 1) >= M + 2:
        N -= 1
        M += 2
    else:
        print(N)
        break

Submission status: Wrong Answer

Solution code:
S,C=map(int,input().split())
#X回操作をするとS+x,c-2x 2S+2x=c-2x 4x=c-2s xはほぼc-2s//4
if C<=2*S:
    print(S)
else:
    ans=S
    for x in range((C-2*S)//4-10,(C-2*S)//4+10):
        if C-2*x<2*(S+x):
            break
        ans=S+x
    print(ans)

Submission status: Wrong Answer

Solution code:
S,C=map(int,input().split())
#X回操作をするとS+x,c-2x 2S+2x=c-2x 4x=c-2s xはほぼc-2s//4
if C<=2*S:
    print(S)
else:
    ans=S
    for x in range((C-2*S)//4-10,(C-2*S)//4+10):
        if C-2*x<2*(S+x):
            print(x)
            break
        ans=S+x
    print(ans)

Submission status: Wrong Answer

Solution code:
S,C=map(int,input().split())
#X回操作をするとS+x,c-2x 2S+2x=c-2x 4x=c-2s xはほぼc-2s//4
if C<2*S:
    print(S)
else:
    ans=0
    for x in range((C-2*S)//4-1,(C-2*S)//4+1):
        if C-2*x<2*(S+x):
            print(x)
            break
        ans=S+x
    print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A
def A():
    n = I()
    print(n*800-200*(n//15))

#B
def B():
    k = I()
    ans = 0
    for i in range(1,k):
        for j in range(i+1,k+1):
            if (i%2)^(j%2):
                ans += 1
    print(ans)

#C
def C():
    x,t = LI()
    print(max(0,x-t))

#D
def D():
    n = I()
    ans = 1
    for i in range(1,n+1):
        ans *= i
        ans %= mod
    print(ans)

#E
def E():
    x,y,s,t = LI()
    return

#F
def F():
    n = I()
    x = LI()
    a = sorted(x)
    for i in range(n):
        j = bisect.bisect_left(a,x[i])
        if j >= n//2:
            print(a[n//2-1])
        else:
            print(a[n//2])

#G
def G():
    n,m = LI()
    while 2*n < m:
        m -= 2
        n += 1
    ans = n
    if m-2*n < 0:
        ans -= 1
    print(ans)

#H
def H():
    return

def J():
    return

def K():
    return

#Solve
if __name__ == "__main__":
    G()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

#(N+x)*2<M-2*x

#N*2+x*2<M-2*x

#4*x<M-N*2

x=max(0,(M-N*2)//4)

print(N+x)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/python3
# abc055_a
"""
Scc Puzzle
"""

def answer():
    """
    全部解体してcにしてしまう。
    それから作り直す。
    """
    S, c = map(int, input().split())
    c += 2*S
    return c//4



def main():
    """
    答えを出力
    """
    print(answer())


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/python3
# abc055_a
"""
Scc Puzzle
"""

def answer():
    """
    Sが余るときとcが余るときに分けて考える。
    """
    S, c = map(int, input().split())

    if S >= c*2:
        return int(c//2)

    return int(S + (c - S*2) // 4)


def main():
    """
    答えを出力
    """
    print(answer())


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/python3
# abc055_a
"""
Scc Puzzle
"""

def answer():
    """
    Sが余るときとcが余るときに分けて考える。
    """
    S, c = map(int, input().split())

    if S >= c*2:
        return int(c/2)

    return int(S + (c - S*2) // 4)


def main():
    """
    答えを出力
    """
    print(answer())


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

if(a < b / 2):
    print(int(a + (b/2 - a)/2))
else:
    print(a)

Submission status: Wrong Answer

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

print(int((2 * a + b) / 4))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)	a=int(input())	a=5
# 1 2	| x,y = map(int,input().split())   |	x=1,y=2
# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　	li = list(map(int,input().split()))	li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']

# INPUT
# 3
# hoge
# foo
# bar
# ANSWER
# n=int(input())
# string_list=[input() for i in range(n)]

import collections
import math

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

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

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

Submission status: Wrong Answer

Solution code:
# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)	a=int(input())	a=5
# 1 2	| x,y = map(int,input().split())   |	x=1,y=2
# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　	li = list(map(int,input().split()))	li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']

# INPUT
# 3
# hoge
# foo
# bar
# ANSWER
# n=int(input())
# string_list=[input() for i in range(n)]

import collections
import math

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

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

ans += int(M/4)
print(ans)

Submission status: Wrong Answer

Solution code:
# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)	a=int(input())	a=5
# 1 2	| x,y = map(int,input().split())   |	x=1,y=2
# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　	li = list(map(int,input().split()))	li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']

# INPUT
# 3
# hoge
# foo
# bar
# ANSWER
# n=int(input())
# string_list=[input() for i in range(n)]

import collections
import math

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

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

ans += int(M/4)
print(ans)

Submission status: Wrong Answer

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

print(N + max(0, (M-2*N)//4))

Submission status: Wrong Answer

Solution code:
def num(N, M):
    return min(N, M//2)

N, M = map(int, input().split())
if 2*N >= M:
    print(N)
else:
    a = (M - 2*N) // 4
    cand = []
    for i in range(a-10, a+10):
        cand.append(num(N+i, M-2*i))
    print(max(cand))

Submission status: Wrong Answer

Solution code:
def num(N, M):
    return min(N, M//2)

N, M = map(int, input().split())
if 2*N >= M:
    print(N)
else:
    a = (M - 2*N) // 4
    cand = []
    for i in range(a, a+4):
        cand.append(num(N+i, M-2*i))
    print(max(cand))

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
ans = 0 
#S型をN個を使い切る
if 2*N <= M:
	M -= 2*N
ans +=  N

#C型で作る
ans += M//4

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans = 0

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

Submission status: Wrong Answer

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

ans = S
if C >= S*2:
    C = C - S*2
    ans += C//4

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, M = list(map(int, input().split()))
counter = 0
while N > 0 or M > 1:
	M -= 2
	if N > 0:
		N -= 1
	else:
		M -= 2
	counter += 1
if N < 0 or M < 0:
	counter -= 1
print(counter)

Submission status: Wrong Answer

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

N_tmp = N
M_tmp = M

ans = 0
if N_tmp < 2 * M_tmp:
    ans += N
    N_tmp -= N
    M_tmp -= 2 * N
    # print("#", N_tmp, M_tmp)
    print(ans + M_tmp // 4)
else:
    ans += M // 2
    N_tmp -= M // 2
    M_tmp -= M
    # print("#", N_tmp, M_tmp)
    print(ans)

Submission status: Wrong Answer

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

# N + x <= (M - 2 * x) // 2

x = min((max((0, (M - 2 * N) // 4)), M // 2))

print(N + x)

Submission status: Wrong Answer

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

# N + x <= (M - 2 * x) // 2

x = max((0, (M - 2 * N) // 4))

print(N + x)

Submission status: Wrong Answer

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

if 2*N >= M: #"S"が断然多い
    ans = M
else: #"cが余っている"
    ans = (2*N + M)//4
    
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

print(ans)