#include using namespace std; struct iofast_t { iofast_t() { ios::sync_with_stdio(false); cin.tie(nullptr); } } iofast; struct uns_t {} uns; template auto vec(Element init, Head arg, Args ...args) { if constexpr (sizeof...(Args) == 0) return std::vector(arg, init); else return std::vector(arg, vec(init, args...)); } template auto vec(uns_t, Head arg, Args ...args) { return vec(Element(), arg, args...); } template > T &chmin(T &l, T r, Compare &&f = less()) { return l = min(l, r, f); } template > T &chmax(T &l, T r, Compare &&f = less()) { return l = max(l, r, f); } #include int op(int x, int y) { return x + y; } int elem() { return 0; } using segtree = atcoder::segtree; int main() { int n, d; cin >> n >> d; auto a = vec(uns, n); for (auto &e : a) cin >> e; auto seq = vec(uns, 0); for (auto v : a) { seq.push_back(v); seq.push_back(v - d); } sort(begin(seq), end(seq)); seq.erase(unique(begin(seq), end(seq)), end(seq)); auto comp = [&](int x) -> int { return distance(begin(seq), lower_bound(begin(seq), end(seq), x)); }; segtree seg(size(seq)); for (auto v : a) { v = comp(v); seg.set(v, seg.get(v) + 1); } for (auto v : a) { v = comp(v - d); cout << seg.prod(0, v + 1) << endl; } }