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 = [int(e) for e in input().split()]


def main(s, c):
    ret = 0
   
    while s < c * 2 and 0 < s:
        ret += 1
        s -= 1
        c -= 2
    
    ret += c // 4

    return ret


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

Submission status: Wrong Answer

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


def main(s, c):
    ret = 0

    ret += s
    c   -= ret * 2
    
    ret += c // 4

    return ret


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

Submission status: Wrong Answer

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


def main(s, c):
    ret = 0

    for i in range(s):
        ret += 1
        c   -= 2
    ret += c // 4
    
    return ret


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

Submission status: Wrong Answer

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: Wrong Answer

Solution code:
MOD = 1000000007

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

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

print(ans)

Submission status: Wrong Answer

Solution code:
MOD = 1000000007

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

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

print(ans)

Submission status: Wrong Answer

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

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

print(str(Scc))

Submission status: Wrong Answer

Solution code:
import sys
import math

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

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

Submission status: Wrong Answer

Solution code:
import sys
import math

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

if n >= int(m / 2):
    print(m/2)
    sys.exit(0)

num = n
m = m - 2*n    
num += int(m / 4)

print(num)

Submission status: Wrong Answer

Solution code:
import sys
import math

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

if n > int(m / 2):
    print(m/2)
    sys.exit(0)

num = n
m = m - 2*n    
num += int(m / 4)

print(num)

Submission status: Wrong Answer

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

if n <= 2 * m: #on utilise tous les s
    r1 = n
else:
    r1 = m // 2
m -= 2 * r1

r2 = m // 4

print(r1 + r2)

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split());a=0
while n and m<2:
    n-=1;m-=2
    a+=1
print(a+m//4)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys

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

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

    return count_Scc

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

Submission status: Wrong Answer

Solution code:
# -*- coding:utf-8 -*-
from decimal import *
N, M = map(int, input().split())
print(Decimal(N+M//2)//2)

Submission status: Wrong Answer

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

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

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


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

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

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

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

    nb_rest_c = int(nb_c) - nb_used_c

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

nb_used_c = 2*nb_s

nb_rest_c = int(nb_c) - nb_used_c

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

Submission status: Wrong Answer

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

nb_used_c = 2*nb_s

nb_rest_c = nb_c - nb_used_c

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, M = list(map(int, input().split()))
c = M
count = 0
for i in range(N):
    c -= 2
    count += 1

count += c//4
print(count)

Submission status: Time Limit Exceeded

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
    while M >= 2:
        if N >= 1 and M >= 2:
            ret += 1
            M -= 2
            N -= 1
        if N == 0 and M >= 2:
            N += 1
            M -= 2
    print(ret)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

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

        while True:
            if 2 * n >= m:
                ans += m // 2
                break
            else:
                n += 1
                m -= 2

    else:
        ans = m // 2

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

ans = 0
for i in range(n, 0, -1):
  if m >= 2*i:
    ans += i
    m -= 2*i
    break

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

Submission status: Time Limit Exceeded

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

counter=0
#まずあるものでsccを作る
while True:
  if (N>=1) and (M>=2):
    N-=1
    M-=2
    counter+=1
  else:
    break

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

Submission status: Time Limit Exceeded

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

while M - 2 * N > 0:
  M -= 2
  N += 1

print(M // 2)

Submission status: Time Limit Exceeded

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

ans = 0
while s>=1 and c>=2:
    s -= 1
    c -= 2
    ans += 1 

print(ans + c//4)

Submission status: Time Limit Exceeded

Solution code:

def main():
    s, c = list(map(int, input().split()))
    count = 0
    while True:
        if c < 2 or (s < 1 and c < 4):
            break
        if s > 1:
            s -= 1
            c -= 2
        else:
            c -= 4
        count += 1
    print(count)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n,m = map(int,input().split())
s = n
c = m
while True:
    if s * 2 < c:
        s += 1
        c -= 2
    else:
        break
ans = min(s, c//2)
print(ans)

Submission status: Time Limit Exceeded

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

ans = 0

while True:
    if N >= 1 and M >= 2:
        N -= 1
        M -= 2
        ans += 1
    elif M >= 4:
        M -= 4
        ans += 1
    else:
        break
print(ans)

Submission status: Time Limit Exceeded

Solution code:
def slove(n, m):
    while True:
        if (m - n*2) >= 0:
            break
        n -= 1

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

if __name__ == "__main__":
    n, m = [int(i) for i in input().split()]
    print(slove(n, m))

Submission status: Time Limit Exceeded

Solution code:
b = list(map(int, input().split()))
N=b[0]
M=b[1]
count=0
while True:
    if N>=1 and M>=2:
        N=N-1
        M=M-2
        count=count+1
    elif N==0 and M>=4:
        M=M-4
        count=count+1
    else:
        break
print(count)

Submission status: Time Limit Exceeded

Solution code:
b = list(map(int, input().split()))
N=b[0]
M=b[1]
count=0
while True:
    if N>=1 and M>=2:
        N=N-1
        M=M-2
        count=count+1
    elif N==0 and M>=4:
        M=M-4
        count=count+1
    else:
        break
print(count)

Submission status: Time Limit Exceeded

Solution code:
n, m = map(int, input().split())
cnt = 0
for i in range(n):
    if m<=2:
        break
    cnt+=1
    m-=2
print(int(m//4)+cnt)

Submission status: Time Limit Exceeded

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

while s>=1 and c>=2:
  count+=1
  s-=1
  c-=2

while c>=4:
  count+=1
  c-=4
  
print(count)

Submission status: Time Limit Exceeded

Solution code:
S = list(map(int,input().split()))
N=S[0]
M=S[1]
count = 0
for i in range(N):
    if N ==0 or M<=1:
        break
    N=N-1
    M=M-2
    count += 1
if N==0:
    for i in range(M):
        if M>=4:
            M -= 4
            count += 1
print(count)

Submission status: Time Limit Exceeded

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

r = 0

while True :
  if ((s>0)&(c>1)):
    r +=1
    s -=1
    c -=2
  else :
    break
    
while True:
  if c>3:
    r += 1
    c -= 4
  else :
    break
print(r)

Submission status: Time Limit Exceeded

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

ans = 0

for x in range(M+1):
    if x%2 == 0:
        ans = max(ans,min(N+x//2,(M-x)//2))
    
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n,m=map(int,input().split())
ans=0
for i in range(n):
    m-=2
    n-=1
    if m<0 or n<0:
        break
    ans+=1
if n<0 or m<0:
    print(ans)
    exit()
while m>0:
    if n>0:
        m-=2
        n-=1
    else:
        m-=4
    if m<0:
        break
    ans+=1
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N, M = map(int, input().split())
cnt = 0
while N>0 and M>1:
    N -= 1
    M -= 2
    cnt += 1

while M>3:
    M -= 4
    cnt += 1
print(cnt)

Submission status: Time Limit Exceeded

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

while n > 0 and m > 1:
#  print(n,m)
  n -= 1
  m -= 2
  cnt += 1

cnt += m//4

print(cnt)

Submission status: Time Limit Exceeded

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

while n > 0 and m > 1:
#  print(n,m)
  n -= 1
  m -= 2
  cnt += 1

while m > 3:
#  print(m)
  m -= 4
  cnt += 1

print(cnt)

Submission status: Time Limit Exceeded

Solution code:
n, m = map(int, input().split())
c = 0
while n > 0 and m > 2:
    n -= 1
    m -= 2
    c += 1

while m >= 4:
    m -= 4
    c += 1
print(c)

Submission status: Time Limit Exceeded

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

if n >= m//2:
    ans = m//2
else:
    while n <= m//2:
        n += 1
        m -= 2
    else:
        ans = n-1

print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

print(answer)

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin

a,b = [int(x) for x in stdin.readline().rstrip().split()]

if a > b:
    print(b//2)
    exit()

while True:
    if a*2 < b:
        a += 1
        b -= 2
    else:
        break
print(min(a,b//2))

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin
import bisect

a,b = [int(x) for x in stdin.readline().rstrip().split()]

while True:
    if a*2 < b:
        a += 1
        b -= 2
    else:
        break
print(min(a,b//2))

Submission status: Time Limit Exceeded

Solution code:
N, M = map(int,input().split())
ans = 0
while True:
    if 1 <= N and 2 <= M:
        N -= 1
        M -= 2
        ans += 1
        continue
    if N == 0 and 4 <= M:
        M -= 4
        ans += 1
    else:
        break
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N,M = map(int,input().split())
ans = 0
for i in range(0,M+1,2):
  ans = max(ans, min((M-i)//2,N+i//2))
print(ans)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N,M = map(int,input().split())
ans = 0
while N > 0 and M > 0:
  N -= 1
  M -= 2
  ans += 1
print(ans + M // 4)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

while 2 * N + 1 < M:
    N += 1
    M -= 2

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

Submission status: Time Limit Exceeded

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

ans = 0
while N > 0 and M > 0:
    if M < 2:
        break
    N -= 1
    M -= 2
    ans += 1

while M >= 4:
    M -= 4
    ans += 1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
n,m = map(int,input().split())
while n < m//2:
  n += 1
  m -=2

print(min(n,m//2))

Submission status: Time Limit Exceeded

Solution code:
n,m = map(int,input().split())
while n*2 < m:
  n += 1
  m -=2

print(min(n,m//2))

Submission status: Time Limit Exceeded

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

ans=0
while True:
  if n<=0 or m<=2:
    break
  n-=1
  m-=2
  ans+=1
print(ans+m//4)

Submission status: Time Limit Exceeded

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

if c // 2 >= s:
    while c // 2 > s:
        c -= 2
        s += 1
    print(min((c//2),s))
else:
    print(min((c//2),s))

Submission status: Time Limit Exceeded

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

if S * 2 >= C:
    print(C//2)
    exit()

i = 0
while (C - 2*i)/(S + i) >= 2:
    i += 1

print(S + i - 1)

Submission status: Time Limit Exceeded

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

for i in range(s):
    if c > 0:
        c -= 2
        s -= 1
        scc += 1
    if s == 0:
        break
        
scc += c // 4

print(scc)

Submission status: Time Limit Exceeded

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



counter = 0
temp = min(c // 2,s)
counter += temp
s -= temp
c -= temp * 2
temp = 0

while True:

    
    if c >= 2 and s >= 1:
        
        s -= 1
        c -= 2
        counter += 1
        #print("counter:",counter)
        #print("s:",s)
        #print("c:",c)
    if s == 0 and c >= 2:
        c -= 2
        s += 1
    if c <= 1:
        break


print(counter)

Submission status: Time Limit Exceeded

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



counter = 0


while True:
    #print("counter:",counter)
    #print("s:",s)
    #print("c:",c)
    
    if c >= 2 and s >= 1:
        s -= 1
        c -= 2
        counter += 1
    if s == 0 and c >= 2:
        c -= 2
        s += 1
    if c <= 1:
        break


print(counter)

Submission status: Time Limit Exceeded

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



counter = 0


while True:
    if c >= 2 and s >= 1:
        s -= 1
        c -= 2
        counter += 1
    if s == 0 and c >= 2:
        c -= 2
        s += 1
    if s == 0 and c <= 1:
        break


print(counter)

Submission status: Time Limit Exceeded

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

count = 0
while True:
    if n > 0 and m > 1:
        count += 1
        n -= 1
        m -= 2
    elif n == 0 and m > 3:
        count += 1
        m -= 4
    elif n == 0 and m <= 3:
        print(count)
        exit()

Submission status: Time Limit Exceeded

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

import sys

for scc in range(M//2, -1, -1):
    excess_c = M - scc*2
    if excess_c//2 + N >= scc:
        print(scc)
        sys.exit(0)

print(0)

Submission status: Time Limit Exceeded

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

ans = 0

if 2*s >= c:
  ans = c // 2
else:
  while 2*s < c and 2*(s+1) <= c-2:
    c -= 2
    s += 1
  ans = s
  
print(ans)

Submission status: Time Limit Exceeded

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

cnt = 0
while s >= 1 and c >= 2:
    s -= 1
    c -= 2
    cnt += 1
    
if c > 3:
    cnt += c // 4
    
print(cnt)

Submission status: Time Limit Exceeded

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

ans = 0

while True:
    if N == 0 or M == 1 or M == 0:
        break

    N -= 1
    M -= 2
    ans += 1

if N == 0:
    while True:
        M -= 4
        if M >= 0:
            ans += 1
        else:
            break

print(ans)

Submission status: Time Limit Exceeded

Solution code:
n,m=map(int,input().split())
k=n
ans=0
for i in range(k):
    if m>=2:
        n-=1
        m-=2
        ans+=1

k=m
for i in range(k):
    if m>=4:
        m-=4
        ans+=1

print(ans)

Submission status: Time Limit Exceeded

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

flag = True
while flag:
  if S >= 1 and C >= 2:
    S -= 1
    C -= 2
  elif C >= 4:
    C -= 4
  else:
    break
  ans += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N,M=[int(i) for i in input().split()]
ans=0
while True:
    if 2*N<=M and M<=2*N+3:
        print(ans+N)
        break
    M-=4    
    ans+=1

Submission status: Time Limit Exceeded

Solution code:
ans=0
N,M=[int(i) for i in input().split()]
while True:
    if  N==0 and M<=3:
        break
    if M<=1:
        break
    if N>=1:
        N-=1
        M-=2
        ans+=1
    else:
        M-=4
        ans+=1
print(ans)

Submission status: Time Limit Exceeded

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

ass = 0
while True:
    if s > 0 and c > 1:
        ass += 1
        s -= 1
        c -=2
    elif s == 0 and c >= 4:
        ass += 1
        c -= 4
    else:
        break
print(ass)

Submission status: Time Limit Exceeded

Solution code:
N, M = map(int, input().split())
ans = 0
while N>=1 and M>=2 or M>=4:
    if N >=1 and M >= 2:
        N -= 1
        M -= 2
        ans += 1
    elif M >=4:
        M -= 4
        ans += 1
print(ans)

Submission status: Time Limit Exceeded

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

ans = 0
while True:
    if N >= 1 and M >= 2:
        N -= 1
        M -= 2
        ans += 1
    elif M >= 2:
        M -= 2
        N += 1
    else:
        break

print(ans)

Submission status: Time Limit Exceeded

Solution code:
import math
N,M=(int(i) for i in input().split())
Cnum=M//2
Snum=N
if Cnum<=Snum:
    print(Cnum)
else:
    while Cnum>Snum:
        Snum+=1
        M-=2
        Cnum=M//2
       # print("CCC"+str(Cnum))
       # print("Snum"+str(Snum))
    print(Cnum)

Submission status: Time Limit Exceeded

Solution code:
N, M = map(int, input().split())
ans = 0
while N >= 1 and M >= 2:
	N -= 1
	M -= 2
	ans += 1
while M >= 4:
	M -= 4
	ans += 1
print(ans)

Submission status: Time Limit Exceeded

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

num_without_s = m/4
num_with_s = 0
m_tmp = m
n_tmp = n
while m_tmp > 1 and n_tmp > 0:
    num_with_s += 1
    m_tmp = m_tmp - 2
    n_tmp = n_tmp - 1

if m_tmp > 3:
    num_with_s = num_with_s + int(m_tmp / 4)

if num_with_s > num_without_s:
    print(int(num_with_s))
else:
    print(int(num_without_s))

Submission status: Time Limit Exceeded

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

num_without_s = m/4
num_with_s = 0
m_tmp = m
n_tmp = n
while m_tmp > 1 and n_tmp > 0:
    num_with_s += 1
    m_tmp = m_tmp - 2
    n_tmp = n_tmp - 1

while m_tmp > 3:
    num_with_s += 1
    m_tmp = m_tmp - 4

if num_with_s > num_without_s:
    print(int(num_with_s))
else:
    print(int(num_without_s))

Submission status: Time Limit Exceeded

Solution code:
N,M = map(int, input().split())
s = N
c = M
while 2*s<c:
  s = s+1
  c = c-2
print(c//2)

Submission status: Time Limit Exceeded

Solution code:
N,M = map(int, input().split())
s = N
c = M
i = 0
if 2*N>=M:
  print(M//2)
else:
  while 2*s<c:
    s = s+1
    c = c-2
  print(c//2)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

while m >= 2 and n >= 1:
    comb += 1
    m -= 2
    n -= 1

comb += m // 4

print(comb)

Submission status: Time Limit Exceeded

Solution code:
n , m  = list(map(int,input().split()))
count = 0
while n >= 1 and m >= 2:
    count = count + 1
    n = n -1
    m = m -2

while m >= 4:
    count = count + 1
    m = m-4
    
    
print(count)

Submission status: Time Limit Exceeded

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

if n > int(m / 2):
    print(int(m / 2))
    sys.exit(0)

while True:
    if n > (m - 2) / 2:
        break
    else:
        n += 1
        m -= 2
print(int(m / 2))

Submission status: Time Limit Exceeded

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

res = 0
for i in range(n):
    if m-2 > 0:
        m -= 2
        res += 1
    else:
        break

print(res+m//4)

Submission status: Time Limit Exceeded

Solution code:
a = list(map(int, input().split()))
b, c = a[0], a[1]
ans = 0
while c > 0:
    if c > 1 and b > 0:
        ans += 1
        b -= 1
        c -= 2
    elif c > 3:
        c -= 4
        ans += 1
    else:
        break

print(ans)

Submission status: Time Limit Exceeded

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

ct = 0
ans = 0
while m != 0:
        m -= 1
        ct += 1
        if ct == 2 and n > 0:
                n -= 1
                ans += 1
                ct = 0
        elif ct == 4:
                ans += 1
                ct = 0

print ans

Submission status: Time Limit Exceeded

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

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

sum = 0

while N > 0:
    if M >= 2:
        sum += 1
        M -= 2
        N -= 1

while M >= 4:
    sum += 1
    M -= 4

print(sum)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8

numbers=input().rstrip().split(" ")

num=0
s=int(numbers[0])
c=int(numbers[1])

while c>=2:
    if s>=1 and c>=2:
        num+=1
        s-=1
        c-=2
    
    elif  c>=2:
        s+=1
        c-=2

print(num)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n,m=map(int,input().split());a=0
while n and m>1:
    n-=1;m-=2;a+=1
print(a+m//4)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

pair = 0
c_pair = 0

while(0<N and 1<M):
    N -= 1
    M -= 2
    pair +=1

if (M!=0):
    c_pair = M / 4

print pair + c_pair

Submission status: Time Limit Exceeded

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

print(str(Scc))

Submission status: Time Limit Exceeded

Solution code:
import sys

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

    while num_s>=0 and num_c>=0:

        if num_s>=1 and num_c>=2:
            num_s = num_s - 1
            num_c = num_c - 2
            count_Scc = count_Scc + 1
        elif num_c>=4:
            num_c = num_c - 4
            count_Scc = count_Scc + 1
        else:
            break

    return count_Scc

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

Submission status: Time Limit Exceeded

Solution code:


def update_score(n, m):
    return min(n, m // 2)

n, m = map(int, input().split())
s, c = n, m
score = update_score(s, c)

for i in range(1, m+1):
    s += 1
    c -= 2

    if c > 0:
        new_score = update_score(s, c)
        if score > new_score:
            break
        else:
            score = new_score

print(score)

Submission status: Time Limit Exceeded

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

cnt=0
for i in range(N):
    if M>=2:    
        M    -= 2
        cnt  +=1

cnt += int(M/4)

print(cnt)

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
# 整数の入力
s, c = map(int, raw_input().split())
ans = 0
if c > s*2:
    ans += s
    c -= s*2
    ans += (c/4)
else:
    while(0 < s and 1 < c):
        s -= 1
        c -= 2
        ans += 1
    if 0 < c:
        ans += c/4
print ans

Submission status: Accepted

Solution code:
import sys
import math

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

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

Submission status: Accepted

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

Submission status: Accepted

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