#include int sum1(unsigned long long x) { return 1 & x; } int sum2(unsigned long long x) { return sum1(x) + sum1(x >> 1); } int sum4(unsigned long long x) { return sum2(x) + sum2(x >> 2); } int sum8(unsigned long long x) { return sum4(x) + sum4(x >> 4); } int sum16(unsigned long long x) { return sum8(x) + sum8(x >> 8); } int sum32(unsigned long long x) { return sum16(x) + sum16(x >> 16); } int sum64(unsigned long long x) { return sum32(x) + sum32(x >> 32); } int int64_ones_num(int64_t x) { uint64_t y = x; return sum64(y); }