Bitwise operator and their properties.
Find X and Y for which (B&X)&(G&X), (B&Y)|(G&Y) is maximum and X+Y is minimum.
We have to just minimize the expression (B&X)&(G&X), (B&Y)|(G&Y) using distributive law.
(B&X)&(G&X) = (B&G)&X
(B&Y)|(G&Y) = (B|G)&Y
Now maximum value of (A&B) where A is fixed and B is variable equals A and minimum value of B for which (A&B) = A is A
Similarly minimum value of X for which (B&G)&X is maximum is (B&G)
With the same analogy minimum value of Y for which (B|G)&Y is maximum is (B|G).
So X+Y = (B&G)+(B|G)
The time complexity is O(1) .
long long int test_case;
long long int a,b;