For this Question: F(1, x) = number of set bits in the binary representation of the number x
F(k, x) = F(k-1, F(1, x)); k > 1
You have to find the number of x for 1 <= x <= N such that the smallest k for which F(k, x) = 1 is C. 
For example,
Smallest k for
x = 1 is 1
x = 2 is 1
x = 3 is 2 
x = 4 is 1
x = 5 is 2The first line contains two space separated numbers N and C. 

1 <= N <= 10^(423)
1 <= C <= 10Output one line the answers modulo 1000000007.Sample input 1
1 1
Sample output 1
1

Sample input 2
13 3
Sample output 2
3

Sample input 3
20 2
Sample output 3
10, I have written this Solution Code: #include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define all(a) (a).begin(),(a).end()
#define UN(a) SORT(a),(a).resize(unique(all(a))-(a).begin())
#define sz(a) ((int) (a).size())
#define pb push_back
#define CL(a,b) memset ((a), (b), sizeof (a))
#define X first
#define Y second

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;

const int mod = 1000000007;
int cnk[1700][1700];
int num[600];

int bc[1700];
int check[11][1700];
int szcheck[11];

void div2() {
	for (int i = num[0]; i; --i) {
		if (i>1)
			num[i-1] += 1000000000 * (num[i] % 2);
		num[i] /= 2;
	}
	while (num[0] && num[num[0]] == 0)
		--num[0];
}

int f[1700];
int m;

char ss[1000][512];

void extract (char ss[512]) {
	m = 0;
	int nn = strlen (ss);
	reverse (ss, ss + nn);
	while (nn && ss[nn-1] == '0') --nn;
	CL (num, 0);
	for (int i = 0; i < nn; i += 9) {
		num[0]++;
		
		for (int j = i+8; j >= i; --j)
			if (j < nn)
				num[num[0]] = num[num[0]] * 10 + ss[j]-'0';
	}

	while (num[0]) {
		f[m++] = num[1]&1;
		div2 ();
	}
}

//int res[1700][11];

int mem[1700][1700];

void gen_test () {
	freopen("input.txt", "w", stdout);
	int T = 1000;
	cout << T << endl;
	REP (i, T) {
		string s;
		REP (j, 500)
			s += char (rand () % 10 + '0');
		//cout << s << ' ' << rand () % 10 + 1 << endl;
		cout << s << ' ' << 5 << endl;
	}		
	cout << endl;
	exit (0);
}

int main() {
	

	REP (i, 1700) {
		cnk[i][0] = cnk[i][i] = 1;
		FOR (j, 1, i) {
			cnk[i][j] = (cnk[i-1][j-1] + cnk[i-1][j]);
			if (cnk[i][j] >= mod)
				cnk[i][j] -= mod;
		}
	}
	
	bc[1] = 1;
	
	check[1][szcheck[1]++] = 1;
	FOR (i, 2, 1700) {		
		int bits = 0;
		for (int x = i; x; x&=x-1, bits++);
		bc[i] = bc[bits] + 1;
		if (bc[i] < 11)
			check[bc[i]][szcheck[bc[i]]++] = i;
	}
	
	int T;
	// scanf ("%d", &T);	
	T=1;
	vector <pii> a (T);
	REP (i, T) {
	   scanf ("%s%d", ss[i], &a[i].X);
	   a[i].Y = i;
    }
    sort (all (a));
    
    vi ans (T);
    REP (tt, T) {
        int k = a[tt].X;
		if (k > 5) break;
		
        if (tt==0 || a[tt].X != a[tt-1].X) {
            CL (mem, 0);
            REP (i, szcheck[k])
                mem[0][check[k][i]] = 1;
            FOR (i, 1, 1700)
                REP (j, 1700-i+1) {
                    mem[i][j] = mem[i-1][j+1] + mem[i-1][j];
                    if (mem[i][j] >= mod) 
                        mem[i][j] -= mod;
                }
        }

        extract (ss[a[tt].Y]);
		int before = 0;
		int res = 0;
		for (int i = m-1; i >= 0; --i) if (f[i] == 1) {
     	    res += mem[i][before];
     	    if (res >= mod)
         	    res -= mod;
     	    before ++;
        }
		res += (bc[before] == k);
		res %= mod;
		ans[a[tt].Y] = res;
    }
    REP (i, T)
        printf ("%d\n", ans[i]);

	return 0;
}, In this Programming Language: C++, Now tell me if this Code is compilable or not?