#include <boost/dynamic_bitset.hpp>
#include <utility>
#include <stdint.h>
#include <iostream>
#include <cstring>
#include <math.h>

std::vector<uint64_t> get_primes(uint64_t up_to) {
	unsigned long long i, j;
	uint8_t *bits = new uint8_t[up_to];
	std::memset(bits, 1, up_to - 1);
	std::vector<uint64_t> primes;

	bits[0] = 0;
	bits[1] = 0;

	for (uint32_t i = 2; i * i < up_to; ++i) {
		if (bits[i]) {
			for (uint64_t j = i * i; j < up_to; j += i) {
				bits[j] = 0;
			}
		}
	}

	for (uint32_t i = 0; i < up_to; ++i) {
		if (bits[i])
			primes.push_back(i);
	}

	delete[] bits;
	return primes;
}

int main(int argc, char* argv[]) {
	uint64_t up_to;

	if (argc < 2) {
		up_to = 100;
	} else {
		up_to = atoll(argv[1]);
	}

	std::vector<uint64_t> primes = get_primes(up_to);
	std::cout << (void*)&primes << std::endl;
}
