func_code_string: #include <bits/stdc++.h>   inline long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }   inline void sub(long long &a, long long b) {     a -= b;     if (a < 0) a += 1000000007;   }   inline void add(long long &a, long long b) {     a += b;     if (a >= 1000000007) a -= 1000000007;   }   template <typename T>   inline T const &MAX(T const &a, T const &b) {     return a > b ? a : b;   }   template <typename T>   inline T const &MIN(T const &a, T const &b) {     return a < b ? a : b;   }   inline long long qp(long long a, long long b) {     long long ans = 1;     while (b) {       if (b & 1) ans = ans * a % 1000000007;       a = a * a % 1000000007, b >>= 1;     }     return ans;   }   inline long long qp(long long a, long long b, long long c) {     long long ans = 1;     while (b) {       if (b & 1) ans = ans * a % c;       a = a * a % c, b >>= 1;     }     return ans;   }   using namespace std;   const unsigned long long ba = 233;   const double eps = 1e-6;   const long long INF = 0x3f3f3f3f3f3f3f3f;   const int N = 100000 + 10, maxn = 1000000 + 10, inf = 0x3f3f3f3f;   long long h[N], a[N];   int cnt, pre[N];   struct sgt {     pair<int, int> ma[N << 2];     void update(int pos, pair<int, int> v, int l, int r, int rt) {       if (l == r) {         ma[rt] = v;         return;       }       int m = (l + r) >> 1;       if (pos <= m)         update(pos, v, l, m, rt << 1);       else         update(pos, v, m + 1, r, rt << 1 | 1);       ma[rt] = max(ma[rt << 1], ma[rt << 1 | 1]);     }     pair<int, int> query(int L, int R, int l, int r, int rt) {       if (L <= l && r <= R) return ma[rt];       int m = (l + r) >> 1;       pair<int, int> ans = make_pair(0, 0);       if (L <= m) ans = max(ans, query(L, R, l, m, rt << 1));       if (m < R) ans = max(ans, query(L, R, m + 1, r, rt << 1 | 1));       return ans;     }   } sg;   int main() {     int n, d;     scanf( %d%d , &n, &d);     for (int i = 1; i <= n; i++) {       scanf( %lld , &h[i]);       a[cnt++] = h[i];     }     sort(a, a + cnt);     cnt = unique(a, a + cnt) - a;     for (int i = 1; i <= n; i++) {       pair<int, int> x = make_pair(0, 0), y;       int p = upper_bound(a, a + cnt, h[i] - d) - a;       p--;       if (p >= 0) x = max(x, sg.query(1, p + 1, 1, cnt, 1));       p = lower_bound(a, a + cnt, h[i] + d) - a;       if (p < cnt) x = max(x, sg.query(p + 1, cnt, 1, cnt, 1));       p = lower_bound(a, a + cnt, h[i]) - a;       y = sg.query(p + 1, p + 1, 1, cnt, 1);       if (x.first + 1 > y.first) {         sg.update(p + 1, make_pair(x.first + 1, i), 1, cnt, 1);         pre[i] = x.second;       }     }     pair<int, int> x = sg.query(1, cnt, 1, cnt, 1);     printf( %d n , x.first);     stack<int> st;     for (int now = x.second; now != 0; now = pre[now]) st.push(now);     while (!st.empty()) printf( %d  , st.top()), st.pop();     return 0;   }   