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<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = (int)(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = (int)(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define REVERSE(x) reverse((x).begin(), (x).end())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << '\n'

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;
constexpr double EPS = 1e-10;

constexpr int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
constexpr int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

template<typename T>
class LazySegmentTree{
    int n;
    std::vector<T> node;
    std::vector<T> lazy;
    std::vector<int> length;
    int height;

    using F = std::function<T(T, T)>;
    using S = std::function<T(T, int)>;

    F f;
    F g;
    F h;
    S s;
    T id1;
    T id2;

    void evaluate(int k){
        if(lazy[k] == id2){
            return;
        }

        node[k] = g(node[k], s(lazy[k], length[k]));

        if(k < n){
            lazy[k << 1] = h(lazy[k << 1], lazy[k]);
            lazy[(k << 1) | 1] = h(lazy[(k << 1) | 1], lazy[k]);
        }

        lazy[k] = id2;

        return;
    }

    void evaluate(int l, int r){
        for(int i = height ; 0 < i ; --i){
            evaluate(l >> i);
            evaluate(r >> i);
        }

        return;
    }

public:
    LazySegmentTree(int n_, F f_, F g_, F h_, T id1_, T id2_, S s_ = [](T x, int len){ return x; }){
        init(n_, f_, g_, h_, id1_, id2_, s_);
    }

    LazySegmentTree(const std::vector<T>& dat, F f_, F g_, F h_, T id1_, T id2_, S s_ = [](T x, int len){ return x; }){
        build(dat, f_, g_, h_, id1_, id2_, s_);
    }

    void init(int n_, F f_, F g_, F h_, T id1_, T id2_, S s_ = [](T x, int len){ return x; }){
        n = 1;
        height = 0;
        while(n < n_){
            n <<= 1;
            ++height;
        }

        f = f_;
        g = g_;
        h = h_;
        id1 = id1_;
        id2 = id2_;
        s = s_;

        node.assign(n << 1, id1);
        lazy.assign(n << 1, id2);

        length.assign(n << 1, 1);
        fill(length.begin() + n + n_, length.end(), 0);
        for(int i = n - 1 ; 0 < i ; --i){
            length[i] = length[i << 1] + length[(i << 1) | 1];
        }

        return;
    }

    void build(const std::vector<T>& dat, F f_, F g_, F h_, T id1_, T id2_, S s_ = [](T x, int len){ return x; }){
        int n_ = (int)dat.size();

        init(n_, f_, g_, h_, id1_, id2_, s_);

        for(int i = 0 ; i < n_ ; ++i){
            node[i + n] = dat[i];
        }
        for(int i = n - 1 ; 0 < i ; --i){
            node[i] = f(node[i << 1], node[(i << 1) | 1]);
        }

        return;
    }

    void update(int l, int r, T x){
        l += n;
        r += n - 1;

        int L = l;
        int R = r;

        evaluate(l, r);

        ++r;

        while(l < r){
            if(r & 1){
                --r;
                lazy[r] = h(lazy[r], x);
            }
            r >>= 1;

            if(l & 1){
                lazy[l] = h(lazy[l], x);
                ++l;
            }
            l >>= 1;
        }

        while(L >>= 1, R >>= 1, L){
            evaluate(L << 1);
            evaluate((L << 1) | 1);
            node[L] = f(node[L << 1], node[(L << 1) | 1]);

            evaluate(R << 1);
            evaluate((R << 1) | 1);
            node[R] = f(node[R << 1], node[(R << 1) | 1]);
        }

        return;
    }

    T get(int l, int r){
        l += n;
        r += n - 1;

        evaluate(l, r);

        ++r;

        T res = id1;
        while(l < r){
            if(r & 1){
                --r;
                evaluate(r);
                res = f(res, node[r]);
            }
            r >>= 1;

            if(l & 1){
                evaluate(l);
                res = f(res, node[l]);
                ++l;
            }
            l >>= 1;
        }

        return res;
    }
};

template<typename T>
bool chmax(T& a, T b){
    if(a < b){
        a = b;
        return true;
    }
    return false;
}

template<typename T>
bool chmin(T& a, T b){
    if(b < a){
        a = b;
        return true;
    }
    return false;
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    int n, m;
    cin >> n >> m;

    vector< P > v;
    rep(i, n){
        int l, r;
        cin >> l >> r;
        v.emplace_back(l, r + 1);
    }

    sort(v.begin(), v.end(), [](P l, P r){ return l.second - l.first < r.second - r.first; });

    LazySegmentTree<int> seg(m + 1, [](int l, int r){ return l + r; }, [](int l, int r){ return l + r; },
                                [](int l, int r){ return l + r; }, 0, 0, [](int x, int len){ return x * len; });

    int k = 0;
    reps(d, m){
        while(k < n && v[k].second - v[k].first < d){
            seg.update(v[k].first, v[k].second, 1);
            ++k;
        }
        int ans = n - k;
        for(int i = 0 ; i <= m ; i += d){
            ans += seg.get(i, i + 1);
        }
        cout << ans << '\n';
    }

    cout << flush;

    return 0;
}