func_code_string: #include <bits/stdc++.h>   #pragma warning(disable : 4996)   using namespace std;   bool inBound(int x) { return x >= 0 && x < 30001; }   int main() {     std::ios::sync_with_stdio(0);     std::cin.tie(0);     std::cout.tie(0);     int n, d;     cin >> n >> d;     int mx = 30000;     vector<int> gems(mx + 1, 0);     for (int i = 0; i < n; i++) {       int temp;       cin >> temp;       gems[temp]++;     }     vector<vector<int> > dp;     dp.resize(mx + 1, vector<int>(500, 0));     for (int i = mx; i >= d; i--) {       for (int prev = 0; prev < 500; prev++) {         dp[i][prev] = gems[i];         int prevJump = d + prev - 250;         int nextPos = i + prevJump;         int choice1 =             (inBound(nextPos - 1) && prev - 1 >= 0 && (prevJump - 1) > 0)                 ? dp[nextPos - 1][prev - 1]                 : 0;         int choice2 =             (inBound(nextPos) && (prevJump) > 0) ? dp[nextPos][prev] : 0;         int choice3 =             (inBound(nextPos + 1) && prev + 1 < 500 && (prevJump + 1) > 0)                 ? dp[nextPos + 1][prev + 1]                 : 0;         dp[i][prev] += max(choice1, max(choice2, choice3));       }     }     cout << dp[d][250] <<   n ;   }   