#include <bits/stdc++.h>
using namespace std;
/** Begin fast allocation */
const int MAX_MEM = 4e8;
int mpos = 0;
char mem[MAX_MEM];
inline void * operator new ( size_t n ) {
char *res = mem + mpos;
mpos += n;
assert(mpos <= MAX_MEM);
return (void *)res;
}
inline void operator delete ( void * ) { }
inline void * operator new [] ( size_t ) { assert(0); }
inline void operator delete [] ( void * ) { assert(0); }
/** End fast allocation */
static const int M = 1e7 + 3;
static const int STEP = 239239237;
struct HashTable {
vector<unsigned> h;
HashTable() : h(M, 0) { }
int index( unsigned x ) {
int i = x % M;
while (h[i] && h[i] != x)
if (++i == M)
i = 0;
return i;
}
void Add( int x ) { h[index(x)] = x; }
};
double start;
void timeS( const char *s = 0 ) {
fprintf(stderr, "time = %.2f : %s\n", 1. * (clock() - start) / CLOCKS_PER_SEC, s ? s : "");
}
int main() {
start = clock();
{
HashTable h;
timeS("h : built");
for (unsigned i = 0, x = 1; i < M / 2; i++, x += STEP)
h.Add(x);
timeS("h : added");
}
timeS("h : deleted");
start = clock();
{
unordered_set<unsigned> uh(M);
uh.rehash(M);
timeS("uh : built");
for (unsigned i = 0, x = 1; i < M / 2; i++, x += STEP)
uh.insert(x);
timeS("uh : added");
}
timeS("uh : deleted");
}