Problem:


陣形

プログラマー養成校であるアカベ高校では、チーム戦の競技プログラマーの役割を以下の３タイプに分けています。

Ｃ：	
コーダー
言語を熟知しており、コーディングを行う。

Ａ：	
アルゴリズマー	
論理的思考が得意であり、アルゴリズムを考える。	

Ｎ：	
ナビゲーター	
読解力に長けており、問題の分析・デバッグをする。	

この高校では以下のいずれかの陣形で３人一組のチームを構成しています。

ＣＣＡ：
バランスがとれている安定型

ＣＣＣ：
スピードを見込めるがリスクの高い速攻型

ＣＡＮ：
正確に問題を解く慎重型

競技プログラミング部のコーチであるあなたは、これらの部員をうまく組み合わせ、できるだけ多くのチームを結成できるよう、毎年気を配っています。そこで、コーダーの人数、アルゴリズマーの人数、ナビゲーターの人数が入力として与えられたとき、最大何チーム作れるかを出力するプログラムを作成してください。

入力

入力は1つのデータセットからなる。入力データは以下の形式で与えられる。

Q
c1 a1 n1
c2 a2 n2
:
cQ aQ nQ

1行目のQ(0 ≤ Q ≤ 100)はチーム数を求めたい年数である。続くQ行に各年の役割別の人数が与えられる。各行にはコーダーの人数ci(0 ≤ ci ≤ 1000)、アルゴリズマーの人数ai(0 ≤ ai ≤ 1000)、ナビゲーターの人数ni(0 ≤ ni ≤ 1000)が与えられる。

出力

年ごとに、作成できる最大のチーム数を1行に出力する。

入力例

4
3 0 0
1 1 1
9 4 1
0 1 2

出力例

1
1
4
0



Sample input:
4
3 0 0
1 1 1
9 4 1
0 1 2


Sample output:
1
1
4
0

Submission status: Wrong Answer

Solution code:
for i in range(int(input())):
    res = 0
    c,a,n = list(map(int,input().split()))
    res = min(n,a,c)
    c -= res
    a -= res
    res += min(c//2,a)
    c -= res*2
    if c >=3:
        res += c//3

    print(res)

Submission status: Wrong Answer

Solution code:
for i in range(int(input())):
    res = 0
    c,a,n = list(map(int,input().split()))
    res = min(n,a,c)
    c -= res
    a -= res
    if c >= 2 and a >= 1:
        res += min(c//2,a)
        c -= res*2

    if c >=3:
        res += c//3

    print(res)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0281

"""
import sys
from sys import stdin
input = stdin.readline


def solve(c, a, n):
    CCA, CCC, CAN = 0, 0, 0
    CAN = min(c, a, n)                     #  CAN??????????????°
    if a > 0 and c > 0:
        CCA = min(a - CAN, c - CAN)        #  CCA??????????????°
    if c > 0:
        CCC = (c - CAN - (CCA * 2)) // 3         # CCC??????????????°
    return CAN + CCA + CCC


def main(args):
    Q = int(input())
    for _ in range(Q):
        c, a, n = map(int, input().split())
        ans = solve(c, a, n)
        print(ans)


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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0281

"""
import sys
from sys import stdin
input = stdin.readline


def solve(c, a, n):
    CCA, CCC, CAN = 0, 0, 0
    CAN = min(c, a, n)                     #  CAN??????????????°
    c -= CAN
    a -= CAN
    n -= CAN

    if a > 0 and c > 0:
        CCA = min(a, c)        #  CCA??????????????°
        c -= (CCA * 2)
    if c > 2:
        CCC = c // 3         # CCC??????????????°
    return CAN + CCA + CCC


def main(args):
    Q = int(input())
    for _ in range(Q):
        c, a, n = map(int, input().split())
        ans = solve(c, a, n)
        print(ans)


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

Submission status: Wrong Answer

Solution code:
Q = int(raw_input())
for i in range(Q):
    c, a, n = map(int, raw_input().split())
    cca = min(c / 2, a)
    ccc = c / 3
    can = min(c, a, n)
    print max(cca, ccc, can)

Submission status: Wrong Answer

Solution code:
k,l=1000,1000000
q=input()
for i in [1]*q:
	c,a,n=map(int,raw_input().split())
	if c==0:
		print 0
		continue
	x=c+k*a+l*n
	s=0
	while x>k+l:
		s+=1
		x-=1+k+l
	while x>1+k:
		s+=1
		x-=2+k
	while x>2:
		s+=1
		x-=3
	print s

Submission status: Accepted

Solution code:
for i in range(int(input())):
    res = 0
    c,a,n = list(map(int,input().split()))
    res = min(n,a,c)
    c -= res
    a -= res
    if c >= 2 and a >= 1:
        cca = min(c//2,a)
        c -= cca*2
        res += cca

    if c >=3:
        res += c//3

    print(res)

Submission status: Accepted

Solution code:
import sys
f = sys.stdin

q = int(f.readline())
for line in f:
    c, a, n = map(int, line.split())
    can = min(c,a,n)
    c -= can
    a -= can
    
    cca = min(c // 2, a)
    c -= cca * 2
    ccc = c // 3
    print(can + cca + ccc)

Submission status: Accepted

Solution code:
n = input()
for i in range(n):
    c,a,n = map(int, raw_input().strip().split(" "))
    can = min(c,a,n)
    c -= can; a -= can; n -= can;
    cca = min(c/2, a)
    c -= 2 * cca; a -= cca;
    ccc =  c/3
    print can + cca + ccc

Submission status: Accepted

Solution code:
Q = input()
for i in range(Q):
    #num of c, a, n
    num = map(int, raw_input().split())
    team = 0
    #c a n
    while True:
        if 0 in num:
            break
        else:
            num = map(lambda x: x - 1, num)
            team += 1
    #c c a
    while True:
        if 0 in num[0:2] or num[0] == 1:
            break
        else:
            num[0] -= 2
            num[1] -= 1
            team += 1
    #c c c
    while True:
        if 0 <= num[0] <= 2:
            break
        else:
            num[0] -= 3
            team += 1

    print "%d" % team

Submission status: Accepted

Solution code:
for i in range(int(input())):
	c,a,n = map(int,input().split())
	cnt = 0
	while True:
		if c<1 or a<1 or n<1:
			break
		c -= 1
		a -= 1
		n -= 1
		cnt += 1
	while True:
		if c<2 or a<1:
			break
		c -= 2
		a -= 1
		cnt += 1
	while True:
		if c<3:
			break
		c -= 3
		cnt += 1
	print(cnt)

Submission status: Accepted

Solution code:
for i in range(int(input())):
	c,a,n = map(int,input().split())
	cnt1 = min(c,a,n)
	c -= cnt1
	a -= cnt1
	cnt2 = min(c//2,a)
	c -= cnt2*2
	cnt3 = c//3
	print(cnt1+cnt2+cnt3)

Submission status: Accepted

Solution code:
for i in range(int(input())):
	c,a,n = map(int,input().split())
	cnt1 = min(c,a,n)
	c -= cnt1
	a -= cnt1
	cnt2 = min(c//2,a)
	c -= cnt2*2
	cnt3 = c//3
	print(cnt1+cnt2+cnt3)

#for i in range(int(input())):
#	c,a,n = map(int,input().split())
#	cnt = 0
#	while True:
#		if c<1 or a<1 or n<1:
#			break
#		c -= 1
#		a -= 1
#		n -= 1
#		cnt += 1
#	while True:
#		if c<2 or a<1:
#			break
#		c -= 2
#		a -= 1
#		cnt += 1
#	while True:
#		if c<3:
#			break
#		c -= 3
#		cnt += 1
#	print(cnt)

Submission status: Accepted

Solution code:
for _ in range(int(input())):
    c,a,n=map(int,input().split())
    b=min(c,a,n)
    a,c=a-b,c-b
    d=min(c//2,a)
    c-=d*2
    print(b+d+c//3)

Submission status: Accepted

Solution code:
# Aizu Problem 0281: Formation

import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")



N = int(input())
for __ in range(N):
    c, a, n = [int(_) for _ in input().split()]
    ans = 0
    while min(a, c, n) > 0:
        ans += 1
        c -= 1
        a -= 1
        n -= 1
    while c > 1 and a > 0:
        ans += 1
        c -= 2
        a -= 1
    ans += c // 3
    print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0281

"""
import sys
from sys import stdin
input = stdin.readline


def solve(c, a, n):
    CCA, CCC, CAN = 0, 0, 0
    CAN = min(c, a, n)                     #  CAN??????????????°
    c -= CAN
    a -= CAN

    if a > 0 and c > 0:
        CCA = min(a, c//2)        #  CCA??????????????°
        c -= (CCA * 2)
    if c > 2:
        CCC = c // 3         # CCC??????????????°
    return CAN + CCA + CCC


def main(args):
    Q = int(input())
    for _ in range(Q):
        c, a, n = map(int, input().split())
        ans = solve(c, a, n)
        print(ans)


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

Submission status: Accepted

Solution code:
for _ in range(int(input())):
    c, a, n = map(int, input().split())
    t = min(c, a, n)
    c, a = c - t, a - t
    t += min(a, c // 2)
    c -= 2 * a
    t += max(0, c // 3)
    print(t)

Submission status: Accepted

Solution code:
# AOJ 0281: Formation
# Python3 2018.6.26 bal4u

Q = int(input())
for i in range(Q):
	c, a, n = map(int, input().split())
	if n <= c and n <= a:
		ans = n
		c -= n
		a -= n
		if a <= c:
			if 2*a >= c: ans += (c >> 1)
			else:
				ans += a
				c -= 2 * a
				ans += c // 3
		else: ans += (c >> 1);
	elif a <= c and a <= n: ans = a + (c-a) // 3
	else: ans = c
	print(ans)

Submission status: Accepted

Solution code:
def solve(c, a, n):
  x = min(c, a, n)
  c -= x
  a -= x
  y = min(c // 2, a)
  c -= y * 2
  a -= y
  z = c // 3
  return x + y + z

q = int(input())
for _ in range(q):
  c, a, n = map(int, input().split())
  print(solve(c, a, n))

Submission status: Accepted

Solution code:
Q = int(raw_input())
for i in range(Q):
    c, a, n = map(int, raw_input().split())
    team = 0
    while c>0 and a>0 and n>0:
        c -= 1
        a -= 1
        n -= 1
        team += 1
    while c>=2 and a>0:
        c -= 2
        a -= 1
        team += 1
    while c>=3:
        c -= 3
        team += 1
    print team

Submission status: Accepted

Solution code:
q=input()
for i in [1]*q:
	c,a,n=map(int,raw_input().split())
	s=0
	while c>0 and a>0 and n>0:
		s+=1
		c,a,n=c-1,a-1,n-1
	while c>0 and a>0:
		s+=1
		c,a=c-2,a-1
	print s+c/3

Submission status: Accepted

Solution code:
for i in [1]*input():
	c,a,n=map(int,raw_input().split())
	s=0
	while c>0 and a>0 and n>0:
		s,c,a,n=s+1,c-1,a-1,n-1
	while c>0 and a>0:
		s,c,a=s+1,c-2,a-1
	print s+c/3

Submission status: Accepted

Solution code:
for i in xrange(input()):
    c, a, n = map(int, raw_input().split())
    can = min(c, a, n)
    c -= can; a -= can; n -= can;
    cca = min(c/2, a)
    c -= 2*cca; a -= cca;
    ccc = c/3
    c -= 3*ccc;
    print can+cca+ccc

Submission status: Accepted

Solution code:
Q = int(input())
for i in range(Q) :
    c, a, n = map(int, input().split())
    teams = 0
    
    mini = min(c, a, n)
    teams += mini
    c -= mini
    a -= mini
    n -= mini
    
    mini = min(int(c/2), a)
    teams += mini
    c -= mini * 2
    a -= mini
    
    mini = int(c/3)
    teams += mini
    
    print(teams)

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

Q = int(input())
for l in range(Q):
    c,a,n = [int(i) for i in input().split()]
    ans = 0
    
    while n > 0 and c > 0 and a > 0:
        c = c - 1
        a = a - 1
        n = n - 1
        ans = ans + 1
        
    while a > 0 and c > 1:
        c = c - 2
        a = a - 1
        ans = ans + 1
    
    while c > 2:
        c = c - 3
        ans = ans + 1
        
    print(ans)

Submission status: Accepted

Solution code:
n=int(input())
for i in range(n):
    count=0
    c,a,n=map(int,input().split())
    while n>0 and a>0 and c>0:
        n-=1
        a-=1
        c-=1
        count+=1
    while a>0 and c>1:
        a-=1
        c-=2
        count+=1
    while c>2:
        c-=3
        count+=1
    print(count)

Submission status: Accepted

Solution code:
q = int(input())

for _ in range(q):
    c, a, n = map(int, input().split())

    if n <= c and n <= a:
        cnt = n
        c -= cnt
        a -= cnt

        if a <= c:
            if 2*a >= c:
                cnt += c >> 1
            else:
                cnt += a
                c -= 2 * a
                cnt += c // 3
        else:
            cnt += c >> 1
    elif a <= c and a <= n:
        cnt = a + (c-a) // 3
    else:
        cnt = c

    print(cnt)

Submission status: Runtime Error

Solution code:
for i in range(int(input())):
    res = 0
    c,a,n = list(map(int,input().split()))
    res = min(n,a,c)
    c -= res
    a -= res
    if c >= 2 and a >= 1:
        cca += min(c//2,a)
        c -= cca*2

    if c >=3:
        res += c//3

    print(res)

Submission status: Runtime Error

Solution code:
for i in range(int(input())):
	c,a,n = map(int,input().split())
    cnt1 = min(c,a,n)
    c -= cnt1
    a -= cnt1
    cnt2 = min(c//2,a)
    c -= cnt2*2
    cnt3 = c//3
    print(cnt1+cnt2+cnt3)
    
#for i in range(int(input())):
#	c,a,n = map(int,input().split())
#	cnt = 0
#	while True:
#		if c<1 or a<1 or n<1:
#			break
#		c -= 1
#		a -= 1
#		n -= 1
#		cnt += 1
#	while True:
#		if c<2 or a<1:
#			break
#		c -= 2
#		a -= 1
#		cnt += 1
#	while True:
#		if c<3:
#			break
#		c -= 3
#		cnt += 1
#	print(cnt)