#include <iostream>
using namespace std;

class BitArr
{
	public:
	unsigned char * data;
	BitArr(int);
	bool getValue(int);
	void setValue(int, bool);
	~BitArr();
};

BitArr::BitArr(int s)
{
	int size = s/8;
	if(s%8!=0)
		size++;
		
	this->data = (unsigned char*)calloc(size, sizeof(unsigned char));
}

BitArr::~BitArr()
{
	free(this->data);
}

bool BitArr::getValue(int pos)
{
	return (*(this->data+pos/8) & (1<<(8-pos%8)));
}

void BitArr::setValue(int pos, bool val)
{
	if(val == true)
		*(this->data+pos/8) |= (1<<(8-pos%8));
	else
		*(this->data+pos/8) &= ~(1<<(8-pos%8));
	return;
}

int main() {
	BitArr a(20);
	a.setValue(3, true);
	a.setValue(7, true);
	a.setValue(18, true);
	for(int i = 0 ; i<20; i++)
		cout << a.getValue(i);
	return 0;
}