#P6861. [RC-03] 难题

[RC-03] 难题

Description

Find two integers a,ba, b (1a,bn)(1 \le a, b \le n) such that (a or b)+(a xor b)(a\ \mathrm{or}\ b) + (a\ \mathrm{xor}\ b) is maximized. You only need to output this maximum value.

Input Format

A positive integer nn.

Output Format

A positive integer, which is the answer.

5
14

Hint

Sample explanation: (5 or 2)+(5 xor 2)=14(5\ \mathrm{or}\ 2) + (5\ \mathrm{xor}\ 2) = 14.

For 80%80\% of the testdata, n1000n \le 1000.

For 100%100\% of the testdata, 2n10182 \le n \le 10^{18}.

Translated by ChatGPT 5