#include #include #include #include using namespace std; using uint = unsigned int; #define CIN( LL , A ) LL A; cin >> A #define RETURN( ANSWER ) cout << ( ANSWER ) << endl; return 0 #include const string& EnumerateHereditarilyFiniteSets( const uint& n ) { static string s[1000001] = {}; string& sn = s[n]; if( sn != "" ){ return sn; } uint n_copy = n; uint i = 0; while( n_copy != 0 ){ if( n_copy % 2 == 1 ){ sn += "," + EnumerateHereditarilyFiniteSets( i ); } n_copy /= 2; i++; } sn = "{" + ( sn == "" ? sn : sn.substr( 1 ) ) + "}"; return sn; } int main() { CIN( uint , N ); assert( N <= 1000000 ); RETURN( EnumerateHereditarilyFiniteSets( N ) ); }