func_code_string: #include <bits/stdc++.h>   using namespace std;   const int maxn = 1e5 + 100;   const int maxpow = 1 << 17;   const int inf = 1e9 + 7;   long long h[maxn];   int par[maxn];   struct node {     pair<int, int> a;     node(pair<int, int> _a) : a(_a) {}     node() : a(0, -1) {}     void merge(node x, node y) { a = max(x.a, y.a); }   };   node tree[maxpow * 2];   node query(int i, int ns, int ne, int qs, int qe) {     if (qe <= ns || qs >= ne) {       return node();     }     if (ns >= qs && ne <= qe) {       return tree[i];     }     int mid = (ns + ne) / 2;     node res1 = query(2 * i, ns, mid, qs, qe);     node res2 = query(2 * i + 1, mid, ne, qs, qe);     node res;     res.merge(res1, res2);     return res;   }   void update(int i, int ns, int ne, int qs, pair<int, int> v) {     if (qs + 1 <= ns || qs >= ne) {       return;     }     if (ns + 1 == ne) {       tree[i] = node(v);       return;     }     int mid = (ns + ne) / 2;     update(2 * i, ns, mid, qs, v);     update(2 * i + 1, mid, ne, qs, v);     tree[i].merge(tree[2 * i], tree[2 * i + 1]);   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int n, d;     cin >> n >> d;     vector<long long> a;     for (long long i = 0; i < n; i++) {       cin >> h[i];       a.push_back(h[i]);     }     sort(a.begin(), a.end());     a.erase(unique(a.begin(), a.end()), a.end());     pair<int, int> mx(-1, -1);     for (int i = 0; i < n; i++) {       int left = lower_bound(a.begin(), a.end(), h[i] - d + 1) - a.begin();       int right = lower_bound(a.begin(), a.end(), h[i] + d) - a.begin();       int cur = lower_bound(a.begin(), a.end(), h[i]) - a.begin();       node ans1 = query(1, 0, maxpow, 0, left);       node ans2 = query(1, 0, maxpow, right, n);       pair<int, int> ans = max(ans1.a, ans2.a);       ans.first += 1;       par[i] = ans.second;       ans.second = i;       mx = max(mx, ans);       update(1, 0, maxpow, cur, ans);     }     cout << mx.first << endl;     int ind = mx.second;     vector<int> res;     while (ind != -1) {       res.push_back(ind);       ind = par[ind];     }     reverse(res.begin(), res.end());     for (int i = 0; i < res.size(); i++) {       cout << res[i] + 1 <<    ;     }     cout << endl;   }   