func_code_string: #include <bits/stdc++.h>   using namespace std;   int digit[32];   long long dp[32][32][2];   long long dfs(int p, int k, bool tag) {     int i;     long long ret = 0;     if (p == -1) return 1;     if (~dp[p][k][tag]) return dp[p][k][tag];     if (!k)       ret = (ret + dfs(p - 1, k, tag && !digit[p])) % 1000000007;     else {       ret = (ret + (dfs(p - 1, k, tag && !digit[p]) << (k - 1)) % 1000000007) %             1000000007;       if (!tag || digit[p])         ret = (ret + (dfs(p - 1, k, tag) << (k - 1)) % 1000000007) % 1000000007;     }     if (!tag || digit[p])       ret = (ret + dfs(p - 1, k + 1, tag && digit[p])) % 1000000007;     return dp[p][k][tag] = ret;   }   int main() {     int k, p;     while (cin >> k) {       memset(dp, -1, sizeof(dp));       for (p = 0; k; k >>= 1) digit[p++] = (k & 1);       cout << dfs(p - 1, 0, true) << endl;     }     return 0;   }   