func_code_string: #include <bits/stdc++.h>   using namespace std;   const long long M = 3e4 + 1;   long long n, m, d;   const long long K = 3e4 + 5;   const long long huge = 1e15;   long long dp[K][500];   long long a[K], ps[K];   long long solve(long long i, long long j) {     if (i >= M) return 0;     long long jj = j - (d - 250);     if (dp[i][jj] != -1) return dp[i][jj];     long long ans = 0;     if (j != 1)       ans = a[i] + max(solve(i + j, j),                        max(solve(i + j + 1, j + 1), solve(i + j - 1, j - 1)));     else       ans = a[i] + max(solve(i + j, j), solve(i + j + 1, j + 1));     return dp[i][jj] = ans;   }   signed main() {     ios::sync_with_stdio(0);     cin.tie(0);     ;     cin >> n;     cin >> d;     while (n--) {       cin >> m;       a[m]++;     }     memset(dp, -1, sizeof dp);     cout << a[0] + solve(d, d);   }   