#include #include #include #include #include #include #include #include #include #include #include #include using namespace std; vector> comb; void combinations(long long n, long long modc=1e18){ comb.resize(n+1); for (long long i=0; i<=n; i++){ comb[i].resize(n+1); comb[i][0] = 1; } for (long long i=1; i <= n; i++){ for (long long j=1; j <= i; j++){ comb[i][j] = (comb[i-1][j-1] + comb[i-1][j]) % modc; } } } int main(){ long long N, K, S, use; cin >> N; combinations(30); for (int i=3; i<100; i++){ S = 0; for (int j=1; j<=i/3; j++) S += comb[i-1][3*j-1]; use = min(N, S); N -= use; if (N == 0){ K = i; break; } } int mx = 1<<(K-1); for (int i=0; i1){ use--; continue; } for (int j=K-2; j>=0; j--){ if (i & 1<