#include <iostream>
using namespace std;
template<int N>
struct lookup_table {
int table[N];
constexpr int& operator[](size_t i) {
return table[i];
}
constexpr const int& operator[](size_t i) const {
return table[i];
}
};
constexpr int bit_count(int i) {
int bits = 0;
while (i) { i &= i-1; ++bits; }
return bits;
}
template<int N>
constexpr lookup_table<N> generate() {
lookup_table<N> table = {};
for (int i = 0; i < N; ++i)
table[i] = bit_count(i);
return table;
}
template<int I> struct Check {
Check() {
std::cout << I << "\n";
}
};
constexpr auto table = generate<65536>();
int main() {
// checks that they are evaluated at compile-time
Check<table[5]>();
Check<table[65535]>();
// test
int i;
while (cin >> i) {
cout << table[i] << ' ';
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKdGVtcGxhdGU8aW50IE4+CnN0cnVjdCBsb29rdXBfdGFibGUgewogICAgaW50IHRhYmxlW05dOwogCiAgICBjb25zdGV4cHIgaW50JiBvcGVyYXRvcltdKHNpemVfdCBpKSB7CiAgICAgICAgcmV0dXJuIHRhYmxlW2ldOwogICAgfQogCiAgICBjb25zdGV4cHIgY29uc3QgaW50JiBvcGVyYXRvcltdKHNpemVfdCBpKSBjb25zdCB7CiAgICAgICAgcmV0dXJuIHRhYmxlW2ldOwogICAgfQp9OwoKY29uc3RleHByIGludCBiaXRfY291bnQoaW50IGkpIHsgCglpbnQgYml0cyA9IDA7IAoJd2hpbGUgKGkpIHsgaSAmPSBpLTE7ICsrYml0czsgfSAKCXJldHVybiBiaXRzOwp9Cgp0ZW1wbGF0ZTxpbnQgTj4gCmNvbnN0ZXhwciBsb29rdXBfdGFibGU8Tj4gZ2VuZXJhdGUoKSB7CiAgICBsb29rdXBfdGFibGU8Tj4gdGFibGUgPSB7fTsKIAogICAgZm9yIChpbnQgaSA9IDA7IGkgPCBOOyArK2kpCiAgICAgICAgdGFibGVbaV0gPSBiaXRfY291bnQoaSk7CiAKICAgIHJldHVybiB0YWJsZTsKfQoKdGVtcGxhdGU8aW50I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