func_code_string: #include <bits/stdc++.h>   using namespace std;   long long INF = (1e15) + 1;   int n, dp[100004], par[100004];   long long d, arr[100004];   struct Node {     Node *leftNode, *rightNode;     long long leftBound, rightBound;     pair<int, int> mx;     Node() {       leftNode = rightNode = NULL;       leftBound = rightBound = 0LL;       mx = {0, 0};     }   };   void update(Node *par, long long pos, int dpMax, int ind) {     if (par->leftBound == pos && par->rightBound == pos) {       if ((par->mx).first < dpMax) {         par->mx = {dpMax, ind};       }       return;     }     long long mid = (par->leftBound + par->rightBound) >> 1;     if (pos <= mid) {       if (par->leftNode == NULL) par->leftNode = new Node();       par->leftNode->leftBound = par->leftBound;       par->leftNode->rightBound = mid;       update(par->leftNode, pos, dpMax, ind);       if ((par->leftNode->mx).first > (par->mx).first) {         par->mx = par->leftNode->mx;       }     } else {       if (par->rightNode == NULL) par->rightNode = new Node();       par->rightNode->leftBound = mid + 1;       par->rightNode->rightBound = par->rightBound;       update(par->rightNode, pos, dpMax, ind);       if ((par->rightNode->mx).first > (par->mx).first) {         par->mx = par->rightNode->mx;       }     }   }   pair<int, int> query(Node *par, long long l, long long r) {     if (par == NULL || par->leftBound > r || par->rightBound < l) {       return {0, 0};     }     if (par->leftBound >= l && par->rightBound <= r) {       return par->mx;     }     long long mid = (par->leftBound + par->rightBound) >> 1;     pair<int, int> p1 = query(par->leftNode, l, r);     pair<int, int> p2 = query(par->rightNode, l, r);     if (p1.first > p2.first)       return p1;     else       return p2;   }   int main() {     scanf( %d%lld , &n, &d);     for (int i = 1; i <= n; i++) scanf( %lld , &arr[i]);     Node *root = new Node();     root->leftBound = 0LL;     root->rightBound = INF;     int ans = 0, curInd = 0;     for (int i = 1; i <= n; i++) {       long long l = max(0LL, arr[i] - d);       long long r = min(INF, arr[i] + d);       pair<int, int> p1 = query(root, 1LL, l);       pair<int, int> p2 = query(root, r, INF);       pair<int, int> p = p1;       if (p.first < p2.first) p = p2;       dp[i] = p.first + 1;       par[i] = p.second;       update(root, arr[i], dp[i], i);       if (dp[i] > ans) {         ans = dp[i];         curInd = i;       }     }     printf( %d n , ans);     vector<int> inds;     while (curInd != 0) {       inds.push_back(curInd);       curInd = par[curInd];     }     reverse(inds.begin(), inds.end());     for (int i = 0; i <= inds.size() - 1; i++) {       printf( %d  , inds[i]);     }     return 0;   }   