#include <bits/stdc++.h>
using namespace std;
int main() {
bitset<8> bit1;
bitset<8> bit3(15);
bitset<8> bit4(string("10010011"));
bitset<8> bit5("10010111");
cout << bit1 << " " << bit3 << " " << bit4 << " " << bit5 << endl;
bit1.set(7); // indexing is done from right to left. (7 6 5 4 3 2 1 0)
cout << "set() : " << bit1 << endl;
bit3.reset(1);
cout << "set() : " << bit3 << endl;
bit3.set(1);//going back to initial.
bit4.flip(2);
cout << "set() : " << bit4 << endl;
bit4.flip(2);//going back to initial.
cout << bit5.count() << endl;
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgppbnQgbWFpbigpIHsKCWJpdHNldDw4PiBiaXQxOwoJYml0c2V0PDg+IGJpdDMoMTUpOwoJYml0c2V0PDg+IGJpdDQoc3RyaW5nKCIxMDAxMDAxMSIpKTsKCWJpdHNldDw4PiBiaXQ1KCIxMDAxMDExMSIpOwoJCgljb3V0IDw8IGJpdDEgPDwgIiAiIDw8IGJpdDMgPDwgIiAiIDw8IGJpdDQgPDwgIiAiIDw8IGJpdDUgPDwgZW5kbDsKCQoJYml0MS5zZXQoNyk7IC8vIGluZGV4aW5nIGlzIGRvbmUgZnJvbSByaWdodCB0byBsZWZ0LiAoNyA2IDUgNCAzIDIgMSAwKQoJY291dCA8PCAic2V0KCkgOiAiIDw8IGJpdDEgPDwgZW5kbDsKCQoJYml0My5yZXNldCgxKTsKCWNvdXQgPDwgInNldCgpIDogIiA8PCBiaXQzIDw8IGVuZGw7CgliaXQzLnNldCgxKTsvL2dvaW5nIGJhY2sgdG8gaW5pdGlhbC4KCQoJYml0NC5mbGlwKDIpOwoJY291dCA8PCAic2V0KCkgOiAiIDw8IGJpdDQgPDwgZW5kbDsKCWJpdDQuZmxpcCgyKTsvL2dvaW5nIGJhY2sgdG8gaW5pdGlhbC4KCQoJY291dCA8PCBiaXQ1LmNvdW50KCkgPDwgZW5kbDsKCXJldHVybiAwOwp9