func_code_string: #include <bits/stdc++.h>   using namespace std;   const long long maxn = 1e5 + 10;   struct Seg {     long long mn, id;   };   long long arr[maxn], N, P, ans[maxn];   Seg seg[maxn << 2];   inline Seg pushup(long long cur) {     Seg l = seg[cur << 1], r = seg[cur << 1 | 1];     if (l.mn == r.mn) {       return l;     } else if (l.mn < r.mn) {       Seg mer;       mer.id = l.id, mer.mn = l.mn;       return mer;     } else {       Seg mer;       mer.id = r.id, mer.mn = r.mn;       return mer;     }   }   long long query(long long cur, long long L, long long R, long long l,                   long long r) {     if (L > R) return -1;     if (l >= L && r <= R) {       return seg[cur].id;     }     long long mid = (l + r) >> 1;     long long lid = -1, rid = -1;     if (mid >= L) lid = query(cur << 1, L, R, l, mid);     if (mid < R) rid = query(cur << 1 | 1, L, R, mid + 1, r);     if (lid == -1)       return rid;     else if (rid == -1)       return lid;     else {       return arr[lid] > arr[rid] ? rid : lid;     }   }   long long query2(long long cur, long long l, long long r, const long long x) {     if (l == r) {       return l;     }     long long mid = (l + r) >> 1;     if (seg[cur << 1].mn <= x) {       return query2(cur << 1, l, mid, x);     }     return query2(cur << 1 | 1, mid + 1, r, x);   }   void build(long long l, long long r, long long cur) {     seg[cur].id = l, seg[cur].mn = arr[l];     if (l == r) return;     long long mid = (l + r) >> 1;     build(l, mid, cur << 1);     build(mid + 1, r, cur << 1 | 1);     seg[cur] = pushup(cur);   }   void update(long long pos, long long l, long long r, long long cur,               long long x) {     if (l == r) {       seg[cur].mn = x;       arr[pos] = x;       return;     }     long long mid = (l + r) >> 1;     if (mid >= pos) {       update(pos, l, mid, cur << 1, x);     } else {       update(pos, mid + 1, r, cur << 1 | 1, x);     }     seg[cur] = pushup(cur);   }   signed main() {     ios::sync_with_stdio(false);     cin >> N >> P;     for (register long long i = 1; i <= N; ++i) {       cin >> arr[i];     }     build(1, N, 1);     long long cnt = 0, cur = 0;     while (cnt < N) {       cur = max(cur, seg[1].mn);       long long x = query2(1, 1, N, cur);       ans[x] = cur += P;       ++cnt;       update(x, 1, N, 1, 0x3f3f3f3f3f3f3f3f);       while (cnt < N) {         x = query(1, 1, x - 1, 1, N);         if (x == -1 || arr[x] > cur) break;         ans[x] = cur += P, ++cnt;         update(x, 1, N, 1, 0x3f3f3f3f3f3f3f3f);       }     }     for (register long long i = 1; i <= N; ++i) {       cout << ans[i] <<    ;     }     return 0;   }   