P16779 ⌈Xzy OI R1 T1⌋ Check the Compiler.
Background
He once said he wished to build a tree that never withers, encoding all memories into nodes, arranged in order starting from the day they first met.
Description
There is a complete binary search tree whose node labels range from $a$ to $b$. Given the label $x$ of the root node, you need to find the maximum possible value of $b$.
Here, a **complete binary search tree** is a binary tree that satisfies the following properties:
- For every node, all node labels in its left subtree (if any) are less than the node’s label, and all node labels in its right subtree (if any) are greater than the node’s label.
- Except for the last level, every level is full, and all nodes on the last level are packed to the left.
Input Format
There are $T$ test cases.
Each test case gives two integers $a, x$.
Output Format
For each test case, output one integer $b$.
Explanation/Hint
**Sample Explanation.**
Consider the following tree:

---
**This problem uses bundled tests, meaning you must pass all test points in a subtask to get the score for that subtask.**
::cute-table{tuack}
| Test Point | Score | $T \le$ | $1 \le a \le x \le$ | Special Constraint |
|:-:|:-:|:-:|:-:|:-:|
| $1$ | $20$ | $80$ | $10^5$ | None. |
| $2$ | $30$ | $10^5$ | $10^{18}$ | $x - a = 2^k - 1$($k \ge 0$) | ^ |
| $3$ | $50$ | ^ | ^ | None. | ^ |
Translated by ChatGPT 5