#K1731. Count Total Bits

    ID: 24580 Type: Default 1000ms 256MiB

Count Total Bits

Count Total Bits

Given a non-negative integer n, count the total number of bits set to 1 in the binary representations of all integers from 0 to n (inclusive). For each integer i, let f(i) be the number of set bits in its binary representation. Your task is to compute the sum

\[ S = \sum_{i=0}^{n} f(i) \]

This problem requires you to read an integer from the standard input and output the computed sum to the standard output.

inputFormat

The input consists of a single line that contains one non-negative integer n (where 0 ≤ n ≤ 10^9, though the provided test cases use smaller values).

outputFormat

Output a single integer which is the total number of 1 bits in the binary representations of all integers from 0 to n.

## sample
0
0