func_code_string: #include <bits/stdc++.h>   using namespace std;   int gems[30050], maxi = INT_MIN;   int dp[30005][600], kood;   int solve(int i, int d) {     int change = 300 + (d - kood);     if (i > maxi) return 0;     if (dp[i][change] != -1) return dp[i][change];     if (d == 1) {       return dp[i][change] =                  gems[i] + max(solve(i + d, d), solve(i + d + 1, d + 1));     }     return dp[i][change] =                gems[i] + max(solve(i + d - 1, d - 1),                              max(solve(i + d, d), solve(i + d + 1, d + 1)));   }   int main() {     int n, d, x;     cin >> n >> d;     kood = d;     memset(dp, -1, sizeof(dp));     for (int i = 0; i < n; i++) {       cin >> x;       gems[x]++;       maxi = max(maxi, x);     }     cout << solve(d, d) << endl;   }   