mt19937 gen(time(NULL)); unordered_map<int, int> cnt; // store up to n elements cnt.rehash(n + gen() % n);