atcoder#ARC126A. [ARC126A] Make 10

[ARC126A] Make 10

Score : 300300 points

Problem Statement

We have N2N_2 sticks of length 22 each, N3N_3 sticks of length 33 each, and N4N_4 sticks of length 44 each. You can do the following operation any number of times.

  • Choose two sticks.
  • Let xx and yy be the lengths of these sticks. Bond them to form a stick of length x+yx+y.

Find the maximum number of sticks that can be made whose lengths are exactly 1010.

Given TT test cases, solve each of them.

Constraints

  • 1T1001\leq T\leq 100
  • 0N2,N3,N410150\leq N_2, N_3, N_4\leq 10^{15}

Input

Input is given from Standard Input in the following format:

TT

case1\text{case}_1

case2\text{case}_2

\vdots

caseT\text{case}_T

Each case is in the following format:

N2N_2 N3N_3 N4N_4

Output

Print TT lines; the ii-th line should contain the answer for casei\text{case}_i.

5
3 4 1
7 0 0
0 0 7
0 0 0
1000000000000000 1000000000000000 1000000000000000
2
1
0
0
900000000000000

Let us describe the first case. We have three sticks of length 22, four sticks of length 33, and one stick of length 44.

One way to make two sticks of length exactly 1010 is as follows.

  • Bond four sticks of length 22, 22, 33, 33 in some order to make one stick of length 1010.
  • Bond three sticks of length 33, 33, 44 in some order to make one stick of length 1010.
  • Now we have three sticks of length 22, 1010, 1010.