~/algor $ cat problems/bit-birlar-yigindisi
Ones from 1 to n
Medium
1000 ms
128 MB
49%
A positive integer $n$ is given. How many digits $1$ are there in total in the binary representations of the numbers $1, 2, \ldots, n$? For example, for $n = 5$: $1, 10, 11, 100, 101$ — $7$ in total.
Input
One positive integer $n$.
Output
One integer — the number of ones.
Note
$1 \le n \le 10^{17}$
Examples
Input #1
5
Output #1
7
Input #2
1
Output #2
1