#include <iostream>
#include <bitset>
#include <climits>
void print_bin(int num)
{
std::string bin = std::bitset<CHAR_BIT * sizeof num>(num).to_string();
// trim leading zeroes
bin = num ? bin.substr(bin.find('1')) : "0";
std::cout << num << ": [0B" << bin << ']' << '\n';
}
int main()
{
print_bin(5);
print_bin(42);
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8Yml0c2V0PgojaW5jbHVkZSA8Y2xpbWl0cz4Kdm9pZCBwcmludF9iaW4oaW50IG51bSkKewogICAgc3RkOjpzdHJpbmcgYmluID0gc3RkOjpiaXRzZXQ8Q0hBUl9CSVQgKiBzaXplb2YgbnVtPihudW0pLnRvX3N0cmluZygpOwogICAgLy8gdHJpbSBsZWFkaW5nIHplcm9lcwogICAgYmluID0gbnVtID8gYmluLnN1YnN0cihiaW4uZmluZCgnMScpKSA6ICIwIjsKICAgIHN0ZDo6Y291dCA8PCBudW0gPDwgIjogWzBCIiA8PCBiaW4gPDwgJ10nIDw8ICdcbic7Cn0KaW50IG1haW4oKQp7CiAgICBwcmludF9iaW4oNSk7CiAgICBwcmludF9iaW4oNDIpOwp9Cg==