func_code_string: #include <bits/stdc++.h>   using namespace std;   const int maxt = 300001;   typedef int mang[maxt + 10];   struct mystr {     int val[4];   };   mang bit1, bit2;   mystr a[100010];   int n, dem, vt = 1;   long long d, m;   vector<pair<long long, pair<int, int>>> b;   int kq[100010];   vector<int> s;   int getbit(int x, mang bit) {     int res = -maxt;     for (; x > 0; x -= x & (-x)) res = max(res, bit[x]);     return res;   }   void updatebit(int x, int val, mang& bit) {     for (; x <= maxt; x += x & (-x)) bit[x] = max(bit[x], val);   }   int main() {     ios::sync_with_stdio(0);     cin >> n >> d;     for (int i = 1; i <= n; i++) {       cin >> m;       b.push_back({m, {i, 1}});       b.push_back({m - d, {i, 2}});       b.push_back({m + d, {i, 3}});     }     b.push_back({(int)-1e18, {0, 0}});     sort(b.begin(), b.end());     for (int i = 1; i < b.size(); i++) {       if (b[i].first != b[i - 1].first) dem++;       a[b[i].second.first].val[b[i].second.second] = dem;     }     for (int i = 1; i <= n; i++) {       int longt =           max(getbit(a[i].val[2], bit1), getbit(maxt - a[i].val[3], bit2)) + 1;       updatebit(a[i].val[1], longt, bit1);       updatebit(maxt - a[i].val[1], longt, bit2);       kq[i] = longt;       if (kq[i] >= kq[vt]) vt = i;     }     cout << kq[vt] <<   n ;     for (int i = vt; i >= 1; i--)       if (kq[vt] == kq[i] + 1 &&           (a[i].val[1] <= a[vt].val[2] || a[i].val[1] >= a[vt].val[3])) {         s.push_back(vt);         vt = i;       }     cout << vt <<    ;     for (int i = s.size() - 1; i >= 0; i--) cout << s[i] <<    ;     return 0;   }   