func_code_string: #include <bits/stdc++.h>   using namespace std;   int k;   long long int m, lim = 2e18;   long long int dp[70][70][2];   long long int solve(string s, int pos, int k, bool f) {     if (k < 0) return 0;     if (pos == (int)s.size()) {       return (k == 0);     }     if (dp[pos][k][f] != -1) return dp[pos][k][f];     long long int ret = 0;     for (char c =  0 ; c <=  1 ; ++c) {       if (!f and s[pos] < c) continue;       ret += solve(s, pos + 1, k - (c ==  1 ), f | (s[pos] > c));     }     return dp[pos][k][f] = ret;   }   long long int get(string s) {     if (s ==  1 ) {       if (k == 1)         return 1;       else         return 0;     }     memset(dp, -1, sizeof dp);     return solve(s, 0, k, 0);   }   string binary(long long int num) {     string ret =   ;     while (num) {       if (num & 1)         ret +=  1 ;       else         ret +=  0 ;       num >>= 1LL;     }     reverse((ret).begin(), (ret).end());     return ret;   }   long long int search(long long int l, long long int r) {     long long int mid = (l + r) / 2LL;     long long int tot = get(binary(2 * mid)) - get(binary(mid));     if (tot == m)       return mid;     else if (tot < m)       return search(mid + 1, r);     return search(l, mid - 1);   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     while (cin >> m >> k) {       long long int ans = search(1LL, lim);       cout << ans <<   n ;     }   }   