func_code_string: #include <bits/stdc++.h>   using namespace std;   const int M = 1e5 + 5;   const int mod = 1e9 + 7;   const double esp = 1e-10;   const long double pi = 4 * atan((long double)1);   int n;   long long d;   struct mido {     long long l, r, val;   } a[M];   vector<pair<long long, int> > v;   pair<int, int> f[12 * M];   int trace[M];   set<long long> s;   void upd(int id, int l, int r, int i, int k, int vt) {     if (l > r) return;     if (r < i || i < l) return;     if (l == r) {       if (f[id].first < k) f[id] = pair<int, int>(k, vt);       return;     }     int mid = (l + r) / 2;     upd(id * 2, l, mid, i, k, vt);     upd(id * 2 + 1, mid + 1, r, i, k, vt);     if (f[id * 2].first > f[id * 2 + 1].first) {       f[id] = f[id * 2];     } else       f[id] = f[id * 2 + 1];   }   pair<int, int> get(int id, int l, int r, int u, int v) {     if (l > r) return pair<int, int>(0, 0);     if (r < u || v < l) return pair<int, int>(0, 0);     if (u <= l && r <= v) {       return f[id];     }     int mid = (l + r) / 2;     pair<int, int> k1 = get(id * 2, l, mid, u, v);     pair<int, int> k2 = get(id * 2 + 1, mid + 1, r, u, v);     if (k1.first > k2.first) return k1;     return k2;   }   int main() {     ios_base::sync_with_stdio(false);     cin >> n >> d;     for (int i = 1; i <= n; i++) {       cin >> a[i].val;       v.push_back(pair<long long, int>(a[i].val, i));       v.push_back(pair<long long, int>(a[i].val - d, i + n));       v.push_back(pair<long long, int>(a[i].val + d, i + 2 * n));     }     sort(v.begin(), v.end());     for (int i = 0; i < 3 * n; i++) {       s.insert(v[i].first);       int vt = v[i].second;       if (vt <= n)         a[vt].val = s.size();       else if (vt <= 2 * n)         a[vt - n].l = s.size();       else         a[vt - 2 * n].r = s.size();     }     int ans = 0, last;     for (int i = 1; i <= n; i++) {       pair<int, int> k1 = get(1, 1, 3 * n, 1, a[i].l);       pair<int, int> k2 = get(1, 1, 3 * n, a[i].r, 3 * n);       if (k1.first > k2.first) {         upd(1, 1, 3 * n, a[i].val, k1.first + 1, i);         trace[i] = k1.second;         if (ans < k1.first + 1) {           ans = k1.first + 1;           last = i;         }       } else {         upd(1, 1, 3 * n, a[i].val, k2.first + 1, i);         trace[i] = k2.second;         if (ans < k2.first + 1) {           ans = k2.first + 1;           last = i;         }       }     }     cout << ans << endl;     vector<int> res;     while (last > 0) {       res.push_back(last);       last = trace[last];     }     for (int i = res.size() - 1; i >= 0; i--) cout << res[i] <<    ;     return 0;   }   