#include <bits/stdc++.h>
using namespace std;
class custom_hash_t
{
inline static uint64_t xor_shift( const uint64_t x, const int k )
{
return x ^ ( x >> k ) ;
}
inline static uint64_t xor_shift_multiply( const uint64_t x, const int k, const uint64_t y )
{
return xor_shift( x, k ) * y;
}
inline static uint64_t splitmix64( uint64_t x )
{
/// http://x...content-available-to-author-only...i.it/splitmix64.c
x + = 0x9e3779b97f4a7c15 ,
x = xor_shift_multiply( x, 30 , 0xbf58476d1ce4e5b9 ) ,
x = xor_shift_multiply( x, 27 , 0x94d049bb133111eb ) ;
return xor_shift( x, 31 ) ;
}
public :
size_t operator( ) ( uint64_t x ) const
{
static const uint64_t FIXED_RANDOM = chrono:: steady_clock :: now ( ) .time_since_epoch ( ) .count ( ) ;
return splitmix64( x + FIXED_RANDOM ) ;
}
} ;
#define SAFE_SET( STL, KEY ) typedef unordered_##STL< KEY, custom_hash_t > safe_##STL
#define SAFE_MAP( STL, KEY, Mapped ) typedef unordered_##STL< KEY, Mapped, custom_hash_t > safe_##STL
typedef long long ll;
SAFE_SET( set, ll ) ;
SAFE_SET( multiset, ll ) ;
SAFE_MAP( map, ll, int ) ;
SAFE_MAP( multimap, ll, int ) ;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
gp_hash_table< ll, int , custom_hash_t > safe_gp_hash_table;
#ifdef ONLINE_JUDGE
#undef ONLINE_JUDGE
#endif // ONLINE_JUDGE
/// The time_mointor() code starts here
inline void time_monitor( const string& s, const function< void ( ) > & procedure )
{
#ifndef ONLINE_JUDGE
typedef chrono:: high_resolution_clock clock_t ;
auto start_time = clock_t :: now ( ) ;
#endif // ONLINE_JUDGE
procedure( ) ;
#ifndef ONLINE_JUDGE
auto duration = clock_t :: now ( ) - start_time;
typedef chrono:: milliseconds time_scale;
auto elapsed_time = chrono:: duration_cast < time_scale > ( duration ) .count ( ) ;
cout << "void " << s << "() used " << elapsed_time << " ms\n " ;
#endif // ONLINE_JUDGE
}
#define time__( procedure ) time_monitor( #procedure, procedure )
/// The time_mointor() code ends here
template < class T >
void insert_numbers( const ll x )
{
T numbers; ll w = x, sum = 0 ;
for ( size_t i = 1 , N = 2e5 ; i <= N; i++ )
numbers[ w ] = i, w + = x;
for ( auto p : numbers )
sum + = ( p.first / x ) * p.second ;
cout << "x = " << x << ": sum = " << sum << endl;
}
typedef unordered_map< ll, int > unsafe_map;
int main( )
{
ios_base:: sync_with_stdio ( false ) , cin .tie ( nullptr ) , cout .tie ( nullptr ) ;
int safe; cin >> safe;
if ( safe )
time__( [ ] ( ) { insert_numbers< safe_map > ( 107897 ) ; } ) ,
time__( [ ] ( ) { insert_numbers< safe_map > ( 126271 ) ; } ) ;
else
time__( [ ] ( ) { insert_numbers< unsafe_map > ( 107897 ) ; } ) ,
time__( [ ] ( ) { insert_numbers< unsafe_map > ( 126271 ) ; } ) ;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKY2xhc3MgY3VzdG9tX2hhc2hfdAp7CiAgICBpbmxpbmUgc3RhdGljIHVpbnQ2NF90IHhvcl9zaGlmdCggY29uc3QgdWludDY0X3QgeCwgY29uc3QgaW50IGsgKQogICAgewogICAgICAgIHJldHVybiB4IF4gKCB4ID4+IGsgKTsKICAgIH0KCiAgICBpbmxpbmUgc3RhdGljIHVpbnQ2NF90IHhvcl9zaGlmdF9tdWx0aXBseSggY29uc3QgdWludDY0X3QgeCwgY29uc3QgaW50IGssIGNvbnN0IHVpbnQ2NF90IHkgKQogICAgewogICAgICAgIHJldHVybiB4b3Jfc2hpZnQoIHgsIGsgKSAqIHk7CiAgICB9CgogICAgaW5saW5lIHN0YXRpYyB1aW50NjRfdCBzcGxpdG1peDY0KCB1aW50NjRfdCB4ICkKICAgIHsKICAgICAgICAvLy8gaHR0cDovL3guLi5jb250ZW50LWF2YWlsYWJsZS10by1hdXRob3Itb25seS4uLmkuaXQvc3BsaXRtaXg2NC5jCgogICAgICAgIHggKz0gMHg5ZT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