P6218 [USACO06NOV] Round Numbers S

Description

If the binary representation of a positive integer contains at least as many $0$'s as $1$'s, then it is called a "round number". For example, the binary representation of $9$ is $1001$, which has $2$ zeros and $2$ ones. Therefore, $9$ is a "round number". Please calculate how many "round numbers" are in the interval $[l, r]$.

Input Format

One line containing two integers $l, r$.

Output Format

One line containing one integer, the number of "round numbers" in the interval $[l, r]$.

Explanation/Hint

**Constraints** For $100\%$ of the testdata, $1 \le l, r \le 2 \times 10^9$. ------------ **Sample Explanation** There are $6$ "round numbers" in the interval $[2, 12]$: $2, 4, 8, 9, 10, 12$. Translated by ChatGPT 5