func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 1e6 + 1, logN = 21 + 1, mod = 1e9 + 7;   int fl(int n) {     int ans = 0;     while (n /= 2) ++ans;     return ans;   }   int ord2(int n) {     int ans = 0;     while (n % 2 == 0) {       n >>= 1;       ++ans;     }     return ans;   }   long long binpow(long long a, long long s) {     long long ans = 1;     while (s) {       if (s & 1) ans = ans * a % mod;       a = a * a % mod;       s >>= 1;     }     return ans;   }   long long inv(long long a) { return binpow(a, mod - 2); }   long long f[N], finv[N];   void init() {     f[0] = 1;     finv[0] = 1;     for (long long i = 1; i < N; ++i) {       f[i] = f[i - 1] * i % mod;       finv[i] = inv(f[i]);     }   }   int n, logn;   int cnt[logN];   long long solve(int k) {     for (int i = 0; i < logn; ++i) cnt[i] = 0;     for (int i = 1; i <= n; ++i) {       int ord = ord2(i);       if (ord < k)         ++cnt[ord];       else if (ord >= k) {         if (i % 3)           ++cnt[k];         else           ++cnt[ord + 1];       }     }     long long ans = 1;     for (int i = 0; i < logn; ++i) ans = ans * cnt[i] % mod;     ans = ans * f[cnt[0] - 1] % mod;     int sum = cnt[0] - 1;     for (int i = 1; i < logn; ++i) {       ans = ans * (f[sum + cnt[i]] * finv[sum + 1] % mod) % mod;       sum += cnt[i];     }     return ans;   }   int main() {     ios_base::sync_with_stdio(false);     cout.tie(0);     cin.tie(0);     init();     cin >> n;     logn = fl(n) + 1;     long long ans = 0;     for (int i = 0; i < logn; ++i) ans = (ans + solve(i)) % mod;     cout << ans <<   n ;   }   