P10696 [SNCPC2024] Since You Wrote It, Just Submit One
Description
MCPlayer542 is solving a problem.
Since the problem is too hard, he cannot write the correct solution directly, so he wrote $n$ different pieces of code. The $i$-th piece of code can get a score of $g_i$.
Time is running out, so MCPlayer542 plans to submit code randomly. However, he then realizes that due to the special rules of this contest, he must submit code twice, and his total score will be the bitwise AND of the scores from the two submissions. Similar to the contest you are taking part in, the code submitted in the two submissions may be the same piece, or two different pieces.
Formally, if he submits the $i$-th and the $j$-th pieces of code in the two submissions, then the score is $g_i \& g_j$, where $\&$ denotes the bitwise AND operation.
He wants to know the maximum score he can get.
Input Format
The input contains multiple test cases. The first line contains an integer $t$ ($1\le t\le 2\times 10^5$), indicating the number of test cases.
For each test case, the first line contains an integer $n$ ($1\le n \le 2\times 10^5$), indicating the number of pieces of code.
The next line contains $n$ integers $g_1,\ g_2,\ \ldots,\ g_n$ ($0 \le g_i
Output Format
For each test case, output one integer per line, which is the answer.
Explanation/Hint
For the first test case, just submit the third piece of code twice.
For the second test case, submit the first two pieces of code.
Translated by ChatGPT 5