[Solution] Team Composition: Programmers and Mathematicians solution codeforces

Team Composition: Programmers and Mathematicians solution codechef

The All-Berland Team Programming Contest will take place very soon. This year, teams of four are allowed to participate.

There are 𝑎a programmers and 𝑏b mathematicians at Berland State University. How many maximum teams can be made if:

  • each team must consist of exactly 44 students,
  • teams of 44 mathematicians or 44 programmers are unlikely to perform well, so the decision was made not to compose such teams.

Thus, each team must have at least one programmer and at least one mathematician.

Print the required maximum number of teams. Each person can be a member of no more than one team.

Also read: ATM and Students solution codeforces
Input Team Composition: Programmers and Mathematicians solution codechef

The first line contains an integer 𝑡t (1≤𝑡≤1041≤t≤104) —the number of test cases.

This is followed by descriptions of 𝑡t sets, one per line. Each set is given by two integers 𝑎a and 𝑏b (0≤𝑎,𝑏≤1090≤a,b≤109).

Output

Print 𝑡t lines. Each line must contain the answer to the corresponding set of input data — the required maximum number of teams.

Example Team Composition: Programmers and Mathematicians solution codechef

input

Copy
6
5 5
10 1
2 3
0 0
17 2
1000000000 1000000000

output

Also read: Make Even solution codeforces
Copy Team Composition: Programmers and Mathematicians solution codechef
2
1
1
0
2
500000000
Note

In the first test case of the example, two teams can be composed. One way to compose two teams is to compose two teams of 22 programmers and 22 mathematicians.

In the second test case of the example, only one team can be composed: 33 programmers and 11 mathematician in the team.

Team Composition: Programmers and Mathematicians solution codechefMaximum Number of Tasks You Can Assign solution leetcodeMaximum Number of Tasks You Can Assign solution leetcodeMaximum Number of Tasks You Can Assign solution leetcode

Leave a Comment

Your email address will not be published. Required fields are marked *