func_code_string: #include <bits/stdc++.h>   using namespace std;   set<long long> myset;   int base;   int N;   long long A[100005];   map<long long, int> Map;   int ANS[600000];   int T[1200000];   int Lo[300000];   int ql, qu;   int P[300000];   void update(int ind) {     ind += base;     T[ind] = ind - base;     while (1) {       ind /= 2;       if (ind < 1) break;       T[ind] = T[2 * ind];       if (ANS[T[2 * ind + 1]] > ANS[T[ind]]) T[ind] = T[2 * ind + 1];     }   }   int query(int ind, int cl, int cu) {     if (cu < ql || cl > qu) return -1;     if (cl >= ql && cu <= qu) return T[ind];     int ansl = query(2 * ind, cl, (cl + cu) / 2);     int ansr = query(1 + 2 * ind, 1 + (cl + cu) / 2, cu);     if (ansl == -1 || ansr == -1) return (ansl + ansr + 1);     if (ANS[ansl] >= ANS[ansr]) return ansl;     return ansr;   }   int main() {     int n;     int d;     cin >> n >> d;     for (__typeof((__typeof(n))0) i((__typeof(n))0); i < n; i++) {       scanf( %lld , &A[i]);       myset.insert(A[i]);       myset.insert(A[i] - d);       myset.insert(A[i] + d);     }     int c = 0;     for (__typeof(myset.begin()) it(myset.begin()); it != myset.end(); it++)       Map[*it] = c++;     N = c;     base = 1;     while (base < N) base *= 2;     for (int i = base; i < 2 * base; i++) T[i] = i - base;     for (int i = base - 1; i > 0; i--) {       T[i] = T[2 * i];       if (ANS[T[2 * i + 1]] > ANS[T[i]]) T[i] = T[2 * i + 1];     }     for (int i = 0; i < n; i++) {       long long h = A[i];       int x = Map[h];       int ans = -1;       qu = Map[h - d];       ql = 0;       ans = query(1, 0, base - 1);       ql = Map[h + d];       qu = N - 1;       int ans2 = query(1, 0, base - 1);       if (ans == -1 || ANS[ans] < ANS[ans2]) ans = ans2;       if (ans == -1 || ANS[ans] == 0) {         ANS[x] = 1;         P[i] = -1;       } else {         ANS[x] = 1 + ANS[ans];         P[i] = Lo[ans];       }       update(x);       Lo[x] = i;     }     int p = 0;     for (int i = 0; i < N; i++)       if (ANS[i] > ANS[p]) p = i;     p = Lo[p];     vector<int> TP;     while (p >= 0) {       TP.push_back(p + 1);       p = P[p];     }     reverse(TP.begin(), TP.end());     cout << (int)(TP.size()) << endl;     for (__typeof(TP.begin()) i(TP.begin()); i != TP.end(); i++)       cout << *i <<    ;     cout << endl;     return 0;   }   