Problem:
Score : 700 points

Problem Statement

Snuke has decided to play a game, where the player runs a railway company.
There are M+1 stations on Snuke Line, numbered 0 through M.
A train on Snuke Line stops at station 0 and every d-th station thereafter, where d is a predetermined constant for each train.
For example, if d = 3, the train stops at station 0, 3, 6, 9, and so forth.

There are N kinds of souvenirs sold in areas around Snuke Line. The i-th kind of souvenirs can be purchased when the train stops at one of the following stations: stations l_i, l_i+1, l_i+2, ..., r_i.

There are M values of d, the interval between two stops, for trains on Snuke Line: 1, 2, 3, ..., M.
For each of these M values, find the number of the kinds of souvenirs that can be purchased if one takes a train with that value of d at station 0.
Here, assume that it is not allowed to change trains.

Constraints

1 ≦ N ≦ 3 × 10^{5}

1 ≦ M ≦ 10^{5}

1 ≦ l_i ≦ r_i ≦ M

Input

The input is given from Standard Input in the following format:

N M
l_1 r_1
:
l_{N} r_{N}

Output

Print the answer in M lines. The i-th line should contain the maximum number of the kinds of souvenirs that can be purchased if one takes a train stopping every i-th station.

Sample Input 1

3 3
1 2
2 3
3 3

Sample Output 1

3
2
2

If one takes a train stopping every station, three kinds of souvenirs can be purchased: kind 1, 2 and 3.

If one takes a train stopping every second station, two kinds of souvenirs can be purchased: kind 1 and 2.

If one takes a train stopping every third station, two kinds of souvenirs can be purchased: kind 2 and 3.

Sample Input 2

7 9
1 7
5 9
5 7
5 9
1 1
6 8
3 4

Sample Output 2

7
6
6
5
4
5
5
3
2

Solution in C++14 (GCC 5.4.1) (judge verdict: Accepted)

#include <bits/stdc++.h>
using namespace std;

#define rep_0(i, end) for(int i = 0; i < (end); ++i)
#define rep_1(i, fr, ba) for(int i = (fr); i <= (ba); ++i)
#define rep(...) overload_rep(__VA_ARGS__, rep_1, rep_0)(__VA_ARGS__)
#define overload_rep(arg_0, arg_1, arg_2, name, ...) name
#define all(box) box.begin(), box.end()

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<class Monoid, class Effector>
struct LazySegmentTree {
private:

    int sz, height;
    vector<Monoid> node;
    vector<Effector> lazy;
    using Func_M = function<Monoid(Monoid, Monoid)>;
    using Func_E = function<Effector(Effector, Effector)>;
    using Merge = function<Monoid(Monoid, Effector, int)>;
    const Func_M operate_m;
    const Func_E operate_e;
    const Merge merge;
    const Monoid unit_m;
    const Effector unit_e;

    Monoid reflect(const int& i, const int& len) const {
        return lazy[i] == unit_e ? node[i] : merge(node[i], lazy[i], len);
    }

    void propagate(const int& i, const int& len) {
        if(lazy[i] == unit_e)return;
        if(i < sz){
            lazy[i << 1] = operate_e(lazy[i << 1], lazy[i]);
            lazy[i << 1 | 1] = operate_e(lazy[i << 1 | 1], lazy[i]);
        }
        node[i] = merge(node[i], lazy[i], len);
        lazy[i] = unit_e;
    }

public:

    LazySegmentTree() { }
    LazySegmentTree(const Monoid& m, const Effector& e, const Func_M& f1, const Func_E& f2, const Merge& f3) 
        : unit_m(m), unit_e(e), operate_m(f1), operate_e(f2), merge(f3) { }
    LazySegmentTree(const vector<Monoid>& vec, const Monoid& m, const Effector& e, const Func_M& f1, const Func_E& f2, const Merge& f3) 
        : unit_m(m), unit_e(e), operate_m(f1), operate_e(f2), merge(f3) { bulid(vec); }
    ~LazySegmentTree(){}

    void init() {
        fill(node.begin(), node.end(), unit_m);
        fill(lazy.begin(), lazy.end(), unit_e);
    }

    void bulid(const vector<Monoid>& vec) {
        for(sz = 1, height = 0; sz < (int)vec.size(); sz <<= 1, ++height);
        node.assign(sz + sz, unit_m);
        lazy.assign(sz + sz, unit_e);
        for(int i = 0; i < (int)vec.size(); ++i)
            node[i + sz] = vec[i];
        for(int i = sz - 1; i > 0; --i)
            node[i] = operate_m(node[i << 1], node[i << 1 | 1]);
    }

    void effect(const int& l, const int& r, const Effector& value) {
        int tl = l + sz, tr = r + sz - 1;
        for(int i = height; i >= 0; --i){
            propagate(tl >> i, 1 << i);
            propagate(tr >> i, 1 << i);
        }
        tl = l + sz; tr  = r + sz;
        for(int i = 1; tl < tr; tl >>= 1, tr >>= 1, i <<= 1){
            if(tl & 1)propagate(tl, i), lazy[tl] = operate_e(lazy[tl], value), propagate(tl++, i);
            if(tr & 1)propagate(--tr, i), lazy[tr] = operate_e(lazy[tr], value), propagate(tr, i);
        }
        tl = (l + sz) >> 1; tr = (r + sz - 1) >> 1;
        for(int i = 0; tl > 0; tl >>= 1, tr >>= 1, ++i){
            node[tl] = operate_m(reflect(tl << 1, 1 << i), reflect(tl << 1 | 1, 1 << i));
            node[tr] = operate_m(reflect(tr << 1, 1 << i), reflect(tr << 1 | 1, 1 << i));
        }
    }

    Monoid fold(const int& l, const int& r){
        Monoid vl = unit_m, vr = unit_m;
        int tl = l + sz, tr = r + sz - 1;
        for(int i = height; i >= 0; --i) {
            propagate(tl >> i, 1 << i);
            propagate(tr >> i, 1 << i);
        }
        tl = l + sz; tr = r + sz;
        for(int i = 1; tl < tr; tl >>= 1, tr >>= 1, i <<= 1) {
            if(tl & 1)vl = operate_m(vl, reflect(tl++, i));
            if(tr & 1)vr = operate_m(reflect(--tr, i), vr);
        }
        return operate_m(vl, vr);
    }

    Monoid operator [] (const int& i) {
        return fold(i, i + 1);
    }

    Monoid operator () (const int& l, const int& r) {
        return fold(l, r);
    }

};

int main() {

    int N, M;
    cin >> N >> M;
    vector<vector<pair<int, int>>> Q(M);
    rep(i, N) {
        int l, r;
        cin >> l >> r;
        Q[r - l].emplace_back(l - 1, r);
    }

    const int unit = 0;
    const auto f1 = [](int i, int j) { return i + j; };
    const auto f2 = [](int i, int j, int l) { return i + j * l; };
    const vector<int> initial(M, unit);
    vector<int> ans1(M, unit);
    LazySegmentTree<int, int> sum(initial, unit, unit, f1, f1, f2);
    LazySegmentTree<int, int> ans2(initial, unit, unit, f1, f1, f2);

    rep(i, M) {
        for(int j = i; j < M; j += i + 1) {
            ans1[i] += sum[j];
        }
        for(const auto& query : Q[i]) {
            int l, r;
            tie(l, r) = query;
            ans2.effect(0, i + 1, 1);
            sum.effect(l, r, 1);
        }
    }

    rep(i, M) cout << ans1[i] + ans2[i] << '\n';
    return 0;

}