func_code_string: #include <bits/stdc++.h>   using namespace std;   int n, d;   int stone[30000 + 3];   int f[30000 + 3][2 * 300 + 3];   int p[30000 + 3];   int main(int argc, char* argv[]) {     scanf( %d %d , &n, &d);     for (int i = 0; i < n; i++) {       int tmp;       scanf( %d , &tmp);       stone[tmp]++;       p[i] = tmp;     }     for (int curr = 30000; curr >= 0; curr--) {       for (int add = -300; add <= 300; add++) {         int addfix = 300 + add;         if (curr == 0) {           f[curr][addfix] = f[d][addfix] + stone[d];           continue;         }         int last = d + add;         if (last <= 0) {           continue;         }         if (curr == 29889 && last == 1) {           printf(  );         }         if (curr == 19 && last == 9 || curr == 10 && last == 10) {           printf(  );         }         if (last - 1 > 0 && curr + last - 1 <= 30000 &&             f[curr][addfix] <                 f[curr + last - 1][addfix - 1] + stone[curr + last - 1]) {           f[curr][addfix] =               f[curr + last - 1][addfix - 1] + stone[curr + last - 1];         }         if (last > 0 && curr + last <= 30000 &&             f[curr][addfix] < f[curr + last][addfix] + stone[curr + last]) {           f[curr][addfix] = f[curr + last][addfix] + stone[curr + last];         }         if (curr + last + 1 <= 30000 &&             f[curr][addfix] <                 f[curr + last + 1][addfix + 1] + stone[curr + last + 1]) {           f[curr][addfix] =               f[curr + last + 1][addfix + 1] + stone[curr + last + 1];         }       }     }     printf( %d n , f[0][300 + 0]);     return 0;   }   