318. Total Hamming Distance
MediumBitsCounting
Print the sum of Hamming distances over all pairs of the given numbers.
Input format
Line 1: n Line 2: n integers
Output format
The total.
Example 1
Input
3 4 14 2
Output
6
Example 2
Input
2 4 14
Output
2
Constraints
1 ≤ n ≤ 10⁵ 0 ≤ values < 2³⁰
Read input from standard input and print the answer to standard output. Your code is judged against 5 test cases, most of them hidden.
Loading the MyLoginn IDE…