Let be the integer satisfying .
The numbers are all available. Each of them contains exactly one distinct set bit, so we can choose them to set all of the lowest bits. This obtains
Every integer from to is smaller than . Therefore, XORing any selection cannot set a higher bit, and no result can exceed .
Thus, the answer is one less than the smallest power of two greater than . The time complexity is per test case, and the additional space complexity is .
Solution written by GPT6