stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include<bits/stdc++.h>

#define st first

#define nd second

#define pb push_back

#define pf push_front

#define ppb pop_back

#define ppf pop_front

#define umax(x,y) x=max(x,y)

#define umin(x,y) x=min(x,y)

#define ll long long

#define ii pair<int,int>

#define iii pair<int,ii>

#define iiii pair<ii,ii>

#define sz(x) ((int) x.size())

#define orta ((bas+son)/2)

#define all(x) x.begin(),x.end()

#define inf 1000000000

#define MOD 1000000007 

#define N 100005

#define M 1000000

#define LOG 20

#define KOK 300

#define EPS 0.0000001

using namespace std;



int n,m;

int ans[N];

int f[N<<1];

vector<ii> v[N<<1];



int get(int x) {



	int res=0;



	for(int i=x;i>=1;i-=i&-i) res+=f[i];



	return res;



}



void up(int x) {



	for(int i=x;i<=m+m;i+=i&-i) f[i]++;



}



int main() {



	scanf("%d %d",&n,&m);



	for(int i=1;i<=n;i++) {



		int l,r;



		scanf("%d %d",&l,&r);



		v[r].pb({l,1});



	}



	for(int i=1;i<=m;i++) {



		for(int j=i;j<=m+m;j+=i) {



			v[j].pb({j-i,0});



		}



	}



	for(int i=1;i<=m+m;i++) {



		sort(all(v[i]),[](ii a,ii b){return a.nd<b.nd;});



		for(auto x:v[i]) {



			if(x.nd) {



				up(x.st);



			}

			else {



				ans[i-x.st]+=get(i-1)-get(x.st);



			}



		}



	}



	for(int i=1;i<=m;i++) printf("%d\n",n-ans[i]);



}	

// Faster C++ solution for the same problem (measured speedup: 6.444140089030294x):
/*ILTH      ILTH            ILTHILTHILTH    ILTH        ILTH

  ILTH      ILTH                ILTH        ILTH        ILTH

  ILTH      ILTH                ILTH        ILTHILTHILTHILTH

  ILTH      ILTH                ILTH        ILTH        ILTH

  ILTH      ILTHILTHILTH        ILTH        ILTH        ILTH



  */

#include <bits/stdc++.h>

#define fi first

#define se second

#define pb push_back



using namespace std;

typedef long long ll;

typedef pair<int,int> pii;

const int maxN=300009;

pii a[maxN];

int n,m,bt[maxN];

bool comp(pii a, pii b){

    return a.se-a.fi<b.se-b.fi;

}

void up(int x, int y){

    for (;x<=m; x+=x&-x) bt[x]+=y;

}

int get(int x){

    int res=0;

    for (;x;x-=x&-x) res+=bt[x];

    return res;

}

int main()

{

    cin >> n >> m;

    for (int i=1; i<=n; ++i){

        int l,r;

        cin >> l >> r;

        a[i]={l,r};

    }

    sort(a+1, a+n+1, comp);



    int j=1;

    for (int i=1; i<=m; ++i){

        int res=0;

        while (a[j].se-a[j].fi+1<i && j<=n){

            up(a[j].fi,1);

            up(a[j].se+1,-1);

            ++j;

        }

        res+=n-j+1;

        for (int k=1; k*i<=m; ++k) res+=get(k*i);

        cout << res << "\n";

    }



    return 0;

}
// Slower C++ solution:
#include<iostream>

#include<cstdio>

#include<cstring>

#include<algorithm>

#include<vector>

#define pii pair<int,int>

#define fi first

#define se second

#define pb push_back

#define mp make_pair

using namespace std;

inline int read(){

	int f=1,ans=0;char c=getchar();

	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}

	while(c>='0'&&c<='9'){ans=ans*10+c-'0';c=getchar();}

	return ans*f;

}

const int MAXN=300001;

int N,M,tot;

struct BIT{

	int Ans[MAXN];

	int lowbit(int x){return x&-x;}

	void Modify(int x,int w){for(;x<=N;x+=lowbit(x)) Ans[x]+=w;}

	int Query(int x){int res=0;for(;x;x-=lowbit(x)) res+=Ans[x];return res;}

	void Add(int l,int r,int w){tot++;Modify(l,w),Modify(r+1,-w);return;}

}T;

vector<pii> vec[MAXN];

int main(){

	M=read(),N=read();

	for(int i=1;i<=M;i++){int l=read(),r=read();vec[r-l+1].pb(mp(l,r));}

	for(int i=1;i<=N;i++){

		int cur=i-1;for(int j=0;j<vec[cur].size();j++) T.Add(vec[cur][j].fi,vec[cur][j].se,1);

		int Ans=M-tot;for(int j=i;j<=N;j+=i) Ans+=T.Query(j);printf("%d\n",Ans);

	}return 0;

}


// Faster C++ solution for the same problem (measured speedup: 9.362953152879818x):
/*ILTH      ILTH            ILTHILTHILTH    ILTH        ILTH

  ILTH      ILTH                ILTH        ILTH        ILTH

  ILTH      ILTH                ILTH        ILTHILTHILTHILTH

  ILTH      ILTH                ILTH        ILTH        ILTH

  ILTH      ILTHILTHILTH        ILTH        ILTH        ILTH



  */

#include <bits/stdc++.h>

#define fi first

#define se second

#define pb push_back



using namespace std;

typedef long long ll;

typedef pair<int,int> pii;

const int maxN=300009;

pii a[maxN];

int n,m,bt[maxN];

bool comp(pii a, pii b){

    return a.se-a.fi<b.se-b.fi;

}

void up(int x, int y){

    for (;x<=m; x+=x&-x) bt[x]+=y;

}

int get(int x){

    int res=0;

    for (;x;x-=x&-x) res+=bt[x];

    return res;

}

int main()

{

    cin >> n >> m;

    for (int i=1; i<=n; ++i){

        int l,r;

        cin >> l >> r;

        a[i]={l,r};

    }

    sort(a+1, a+n+1, comp);



    int j=1;

    for (int i=1; i<=m; ++i){

        int res=0;

        while (a[j].se-a[j].fi+1<i && j<=n){

            up(a[j].fi,1);

            up(a[j].se+1,-1);

            ++j;

        }

        res+=n-j+1;

        for (int k=1; k*i<=m; ++k) res+=get(k*i);

        cout << res << "\n";

    }



    return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

#define ll long long

#define INF 999999999

#define MOD 1000000007

#define rep(i,n) for(int i=0;i<n;i++)



using namespace std;



typedef pair<int,int>P;



const int MAX_N = 125252;



vector<P> lens[125252];



int bit[MAX_N+1],n,m;

//i番目までの和を計算する

int sum(int i)

{

	int s = 0;

	while(i>0){

		s += bit[i];

		i -= i & -i;

	}

	return s;

}

//i番目の値にxを加える

void add(int i,int x)

{

	while(i <= MAX_N){

		bit[i] += x;

		i += i & -i;

	}

}



int main()

{

	scanf("%d%d",&n,&m);

	rep(i,n){

		int l,r;

		scanf("%d%d",&l,&r);

		r++;

		lens[r-l].push_back(P(l,r));	//rはr+1を指すようにする

	}

	printf("%d\n",n);

	int rest = n;

	for(int i=2;i<m+1;i++){	//iは間隔dのこと

		rep(j,lens[i-1].size()){

			add(lens[i-1][j].first,1);

			add(lens[i-1][j].second,-1);

			rest--;

		}

		int ans = rest;	//間隔がm以上の区間

		int it = i;

		while(it<=m){

			ans += sum(it);

			it += i;

		}

		printf("%d\n",ans);

	}

}

// Faster C++ solution for the same problem (measured speedup: 1.1799823484564094x):
#include <bits/stdc++.h>

#define ll long long

#define INF 999999999

#define MOD 1000000007

#define rep(i,n) for(int i=0;i<n;i++)



using namespace std;



typedef pair<int,int>P;



const int MAX_N = 100005;



vector<P> lens[100005];



int bit[MAX_N+1],n,m;

//i番目までの和を計算する

int sum(int i)

{

	int s = 0;

	while(i>0){

		s += bit[i];

		i -= i & -i;

	}

	return s;

}

//i番目の値にxを加える

void add(int i,int x)

{

	while(i <= MAX_N){

		bit[i] += x;

		i += i & -i;

	}

}



int main()

{

	scanf("%d%d",&n,&m);

	rep(i,n){

		int l,r;

		scanf("%d%d",&l,&r);

		r++;

		lens[r-l].push_back(P(l,r));	//rはr+1を指すようにする

	}

	printf("%d\n",n);

	int rest = n;

	for(int i=2;i<m+1;i++){	//iは間隔dのこと

		rep(j,lens[i-1].size()){

			add(lens[i-1][j].first,1);

			add(lens[i-1][j].second,-1);

			rest--;

		}

		int ans = rest;	//間隔がm以上の区間

		int it = i;

		while(it<=m){

			ans += sum(it);

			it += i;

		}

		printf("%d\n",ans);

	}

}
// Slower C++ solution:
#include<iostream>

#include<cstdio>

#include<algorithm>

#include<cstring>

#include<vector>

using namespace std;

const int maxn=300050;

int sum[maxn<<3],lazy[maxn<<3],l[maxn],r[maxn];

int n,M;

vector<int>q[maxn];

inline void push_down(int ID,int l,int r){

	int m=(l+r)>>1;

	sum[ID<<1]+=(m-l+1)*lazy[ID],sum[ID<<1|1]+=(r-m)*lazy[ID];

	lazy[ID<<1]+=lazy[ID],lazy[ID<<1|1]+=lazy[ID],lazy[ID]=0;

}

inline void ins(int ID,int l,int r,int L,int R){

	if(lazy[ID])push_down(ID,l,r);

	if(l>=L&&r<=R){

		sum[ID]+=(r-l+1);

		lazy[ID]++;

		return;

	}

	int m=(l+r)>>1;

	if(m>=L)ins(ID<<1,l,m,L,R);

	if(m<R)ins(ID<<1|1,m+1,r,L,R);

	sum[ID]=sum[ID<<1]+sum[ID<<1|1];

}

inline int query(int ID,int x,int l,int r){

	if(lazy[ID])push_down(ID,l,r);

	if(sum[ID]==0)return 0;

	if(l==r)return sum[ID];

	int m=(l+r)>>1;

	if(m>=x)return query(ID<<1,x,l,m);

	else return query(ID<<1|1,x,m+1,r);

}

int main(){

	scanf("%d%d",&n,&M);

	for(register int i=1;i<=n;i++){

		scanf("%d%d",&l[i],&r[i]);

		q[r[i]-l[i]+1].push_back(i);

	}

	int remain=n;

	for(register int i=1;i<=M;i++){

		int ans=remain;

		remain-=q[i].size();

		if(i!=1)

		for(register int j=1;j*i<=M;j++)ans+=query(1,i*j,1,300000);

		for(register int j=0;j<q[i].size();j++)ins(1,1,300000,l[q[i][j]],r[q[i][j]]);

		printf("%d\n",ans);

	}

}

// Faster C++ solution for the same problem (measured speedup: 9.47932791250106x):
#include<stdio.h>

#include<cstring>

#include<iostream>

#include<algorithm>

#include<bitset>

#include<vector>

#include<math.h>

#define ls(x) (x<<1)

#define rs(x) ((x<<1)|1)

using namespace std;

int n,m;

struct nod

{

    int l,r,len;

    bool operator<(const nod &b)const

    {

        return len<b.len;

    }

}a[300005];

int lazy[1200005];

void pushdown(int now)

{

    lazy[ls(now)]+=lazy[now];

    lazy[rs(now)]+=lazy[now];

    lazy[now]=0;

}

void jia(int now,int l,int r,int st,int ed)

{

    if(l==r)

    {

        lazy[now]++;

        return;

    }

    if(st<=l&&ed>=r)

    {

        lazy[now]++;

        return;

    }

    if(lazy[now])pushdown(now);

    int mid=(l+r)>>1;

    if(st<=mid)jia(ls(now),l,mid,st,ed);

    if(ed>=mid+1)jia(rs(now),mid+1,r,st,ed);

}

int query(int now,int l,int r,int pos)

{

    if(l==r)return lazy[now];

    if(lazy[now])pushdown(now);

    int mid=(l+r)>>1;

    if(pos<=mid)return query(ls(now),l,mid,pos);

    else return query(rs(now),mid+1,r,pos);

}

int main()

{

    scanf("%d%d",&n,&m);

    for(int i=1;i<=n;i++)

    {

        scanf("%d%d",&a[i].l,&a[i].r);

        a[i].len=a[i].r-a[i].l+1;

    }

    sort(a+1,a+1+n);

    int flag=1,ans;

    printf("%d\n",n);

    for(int i=2;i<=m;i++)

    {

        while(flag<=n&&a[flag].len<=i)

        {

            jia(1,1,m,a[flag].l,a[flag].r);

            //printf("%d %d\n",a[flag].l,a[flag].r);

            flag++;

        }

        ans=0;

        //printf("%d %d\n",i,query(1,1,m,9));

        for(int j=i;j<=m;j+=i)

        {

            ans+=query(1,1,m,j);

            //printf("%d ",ans);

        }

        printf("%d\n",ans+(n-flag+1));

    }

}
// Slower C++ solution:
#include <iostream>

#include <cstdio>

#include <algorithm>

#define IsDigit(x) ((x) >= '0' && (x) <= '9')

#define LowBit(x) ((x) & -(x))

using namespace std;



int n, m;

int tree[100002];

struct Interval{

	int l, r;

	Interval() {}

	Interval(int x, int y)

		: l(x), r(y)

	{}

	bool operator<(const Interval &x) const{ return r - l < x.r - x.l; }

}sou[300000];





int Read(void)

{

	int c, ret(0);

	

	c = getchar();

	while (!IsDigit(c))

		c = getchar();

	do

		ret = ret * 10 + c - '0';

	while ((c = getchar()) && IsDigit(c));

	return ret;

}





void Add(const int val, int pos)

{

	while (pos <= m + 1) {

		tree[pos] += val;

		pos += LowBit(pos);

	}

	return;

}





int Sum(int pos)

{

	int ret(0);

	

	while (pos) {

		ret += tree[pos];

		pos -= LowBit(pos);

	}

	return ret;

}





int main()

{

	int l, r, pos(0), ans;

	

	n = Read();

	m = Read();

	for (int i = 0; i < n; ++i) {

		l = Read();

		r = Read();

		sou[i] = Interval(l, r);

	}

	sort(sou, sou + n);

	for (int step = 1; step <= m; ++step) {

		while (pos < n && sou[pos].r - sou[pos].l + 1 < step) {

			Add(1, sou[pos].l);

			Add(-1, sou[pos].r + 1);

			++pos;

		}

		ans = n - pos;

		for (int i = step; i <= m; i += step)

			ans += Sum(i);

		printf("%d\n", ans);

	}

	return 0;

}




// Faster C++ solution for the same problem (measured speedup: 5.162163680852248x):
#include<cstdio>

#include<cctype>

#include<algorithm>

const int N=300007,M=100007;

int read(){int x=0,c=getchar();while(!isdigit(c))c=getchar();while(isdigit(c))x=x*10+c-48,c=getchar();return x;}

struct node{int l,r;}a[N];

int n,m,ans[M],t[M];

void add(int p,int v){for(;p<=m;p+=p&-p)t[p]+=v;}

void upd(int l,int r){add(l,1);if(r<m)add(r+1,-1);}

int ask(int p){int s=0;for(;p;p^=p&-p)s+=t[p];return s;}

int main()

{

    n=read(),m=read();

    for(int i=1;i<=n;++i) a[i].l=read(),a[i].r=read();

    std::sort(a+1,a+n+1,[](node&a,node&b){return a.r-a.l<b.r-b.l;});

    for(int i=1,p=1,s;i<=m;++i)

    {

	for(s=0;p<=n&&a[p].r-a[p].l<i;++p) upd(a[p].l,a[p].r);

	for(int j=i;j<=m;j+=i) s+=ask(j);

	printf("%d\n",n-p+1+s);

    }

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

#define N 500007

#define ll long long

int sum[N],n,m;

struct str

{

    int l,r,d;

}p[N];

bool operator <(str a,str b)

{

    return a.d<b.d;

}

void add(int x,int d)

{

    if(!x)return;

    for(;x<=m;x+=x&-x)

	sum[x]+=d;

}

void mody(int l,int r,int d)

{

    add(l,d),add(r+1,-d);

}

int query(int x)

{

    int ans=0;

    for(;x;x-=x&-x)

	ans+=sum[x];

    return ans;

}

int main()

{

    scanf("%d%d",&n,&m);

    for(int i=1;i<=n;i++)

	scanf("%d%d",&p[i].l,&p[i].r),p[i].d=p[i].r-p[i].l;

    sort(p+1,p+n+1);

    int j=1;

    for(int d=1;d<=m;d++)

    {

	while(j<=n&&p[j].d<d)mody(p[j].l,p[j].r,1),j++;

	int ans=n-j+1;

	for(int i=d;i<=m;i+=d)

	    ans+=query(i);

	printf("%d\n",ans);

    }

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.184824672129336x):
#include<cstdio>

#include<cctype>

#include<algorithm>

const int N=300007,M=100007;

int read(){int x=0,c=getchar();while(!isdigit(c))c=getchar();while(isdigit(c))x=x*10+c-48,c=getchar();return x;}

struct node{int l,r;}a[N];

int n,m,ans[M],t[M];

void add(int p,int v){for(;p<=m;p+=p&-p)t[p]+=v;}

void upd(int l,int r){add(l,1);if(r<m)add(r+1,-1);}

int ask(int p){int s=0;for(;p;p^=p&-p)s+=t[p];return s;}

int main()

{

    n=read(),m=read();

    for(int i=1;i<=n;++i) a[i].l=read(),a[i].r=read();

    std::sort(a+1,a+n+1,[](node&a,node&b){return a.r-a.l<b.r-b.l;});

    for(int i=1,p=1,s;i<=m;++i)

    {

	for(s=0;p<=n&&a[p].r-a[p].l<i;++p) upd(a[p].l,a[p].r);

	for(int j=i;j<=m;j+=i) s+=ask(j);

	printf("%d\n",n-p+1+s);

    }

}
// Slower C++ solution:
//#include <bits/stdc++.h>

#include <cstdio>

#include <algorithm>

#include <iostream>

#include <cstring>

#include <limits>

#include <map>

#include <vector>

#include <queue> 

#define LL long long

#define ft first

#define sd second

#define mp(x,y) make_pair(x,y)

//#define int LL

using namespace std;

const int N   = 3e5+10;

//const int mod = ;

const int INF =numeric_limits<int >::max();



#define rep(i,x,y) for (int i=x;i<=y;++i)

void read(int &x)

{

	x=0;

	char ch=getchar();

	int f=1;

	while (!isdigit(ch)) (ch=='-'?f=-1:0),ch=getchar();

	while ( isdigit(ch)) x=x*10+ch-'0',ch=getchar();

	x*=f;

}

int buf[30];

void write(int x)

{

    if (x<0) putchar('-'),x=-x;

    buf[0]=0;

    while (x) buf[++buf[0]]=x%10,x/=10;

    if (!buf[0]) buf[0]=1,buf[1]=0;

    while (buf[0]) putchar('0'+buf[buf[0]--]);

}



int n,m,l[N],r[N];

int cnt[N];

void wk(int L,int R)

{

	for (int k=1;k<=m;)

	{

		int b=(L-1)/k;

		int c=L-1-k*b;

		int len=b?(c/b+1):100000;

		++cnt[k];--cnt[min(R/(b+1),k+len-1)+1];

		k+=len;		

	}

	return ;

}



signed main()

{

	

	read(n);read(m);

	rep(i,1,n) read(l[i]),read(r[i]);

	rep(i,1,n) wk(l[i],r[i]);

	rep(i,1,m) cnt[i]+=cnt[i-1];

	rep(i,1,m) write(cnt[i]),putchar('\n');

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.115267685649235x):
#include <cstdio>

#include <algorithm>

using namespace std;

#define N 2000000

#define M 100050

int n,m,i,j,c[M],b[M];

struct lwn{

	int l,r,opt;

	bool operator < (const lwn &jb)const{

		return r<jb.r||r==jb.r&&opt<jb.opt;

	}

} a[N];

inline int rd()

{

	char ch=getchar();int ret=0;

	while (ch<'0' || ch>'9') ch=getchar();

	while (ch>='0' && ch<='9') ret=(ret<<3)+(ret<<1)+ch-'0',ch=getchar();

	return ret;

}

int main()

{

	n=rd();m=rd();int q=n;

	for (i=1;i<=n;i++) a[i].l=rd(),a[i].r=rd();

	for (i=1;i<=m;i++)

	for (j=0;j<=m/i;j++) n++,a[n].l=i*j,a[n].r=min(i*(j+1)-1,m),a[n].opt=i;

	sort(a+1,a+n+1);int psz=0;

	for (i=1;i<=n;i++) if (a[i].opt){

		int tot=0;

		for (j=a[i].l;j>=1;j-=(j&(-j))) tot+=c[j];

		b[a[i].opt]+=psz-tot;

	}else{

		psz++;

		for (j=a[i].l;j<=m;j+=(j&(-j))) c[j]++;

	}

	for (i=1;i<=m;i++) printf("%d\n",q-b[i]);

	return 0;

}
// Slower C++ solution:
//#include <bits/stdc++.h>

#include <cstdio>

#include <algorithm>

#include <iostream>

#include <cstring>

#include <limits>

#include <map>

#include <vector>

#include <queue> 

#define LL long long

#define ft first

#define sd second

#define mp(x,y) make_pair(x,y)

//#define int LL

using namespace std;

const int N   = 3e5+10;

//const int mod = ;

const int INF =numeric_limits<int >::max();



#define rep(i,x,y) for (int i=x;i<=y;++i)

void read(int &x)

{

	x=0;

	char ch=getchar();

	int f=1;

	while (!isdigit(ch)) (ch=='-'?f=-1:0),ch=getchar();

	while ( isdigit(ch)) x=x*10+ch-'0',ch=getchar();

	x*=f;

}

int buf[30];

void write(int x)

{

    if (x<0) putchar('-'),x=-x;

    buf[0]=0;

    while (x) buf[++buf[0]]=x%10,x/=10;

    if (!buf[0]) buf[0]=1,buf[1]=0;

    while (buf[0]) putchar('0'+buf[buf[0]--]);

}



int n,m,l[N],r[N];

int cnt[N];

void wk(int L,int R)

{

	for (int k=1;k<=m;)

	{

		int b=(L-1)/k;

		int c=L-1-k*b;

		int len=b?(c/b+1):100000;

		++cnt[k];--cnt[min(R/(b+1),k+len-1)+1];

		k+=len;		

	}

	return ;

}



signed main()

{

	

	read(n);read(m);

	rep(i,1,n) read(l[i]),read(r[i]);

	rep(i,1,n) wk(l[i],r[i]);

	rep(i,1,m) cnt[i]+=cnt[i-1];

	rep(i,1,m) write(cnt[i]),putchar('\n');

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.085098647865336x):
#include <cstdio>

#include <algorithm>

const int MAXN=3E5+10;

const int mod=1E9+7;

int N,M;

struct pair {

	int l,r;

	bool operator < (const pair&a) const {

		return r-l < a.r-a.l;

	}

	int len() {return r-l+1;}

}rc[MAXN];

struct FWT {

	int f[MAXN];

	void change(int i,int x) {

		for(;i<=M;i+=i&(-i))

			f[i]+=x;

	}

	int query(int i) {

		int ans=0;

		for(;i;i-=i&(-i))

			ans+=f[i];

		return ans;

	}

}fw;

int main() {

	scanf("%d%d",&N,&M);

	for(int i=1;i<=N;++i) {

		scanf("%d%d",&rc[i].l,&rc[i].r);

	}std::sort(rc+1,rc+N+1);

	/*for(int i=1;i<=N;++i) {

		fw.change(rc[i].l,1);

		fw.change(rc[i].r+1,-1);

	}*/

	int tail=1;

	for(int i=1;i<=M;++i) {

		while(tail<=N&&rc[tail].len()<i){

			fw.change(rc[tail].l,1);

			fw.change(rc[tail].r+1,-1);

			++tail;

		}

		int ans=N-tail+1;

		for(int j=0;j<=M;j+=i) {

			ans+=fw.query(j);

		}printf("%d\n",ans);

	}

	return 0;

}
// Slower C++ solution:
#include<iostream>

#include<cstdio>

#include<cstring>

#include<algorithm>

using namespace std;

const int N=300005,M=100005;

int n,m;

struct Node

{

    int l,r,len;

}a[N];

bool cmp(Node x,Node y)

{

    return x.len<y.len;

}

struct Binary_Indexed_Tree

{

    int tree[M];

    Binary_Indexed_Tree()

    {

        memset(tree,0,sizeof(tree));

        return;

    }

    int lowbit(int x)

    {

        return x&-x;

    }

    void add(int x,int y)

    {

        if(x==0) return;

        for(int i=x;i<=m;i+=lowbit(i))

            tree[i]+=y;

        return;

    }

    void add(int a,int b,int val)

    {

        if(a>b) return;

        add(a,val);

        add(b+1,-val);

        return;

    }

    int getsum(int x)

    {

        int res=0;

        for(int i=x;i>0;i-=lowbit(i))

            res+=tree[i];

        return res;

    }

}T;

int main()

{

    scanf("%d%d",&n,&m);

    for(int i=1,l,r;i<=n;++i)

    {

        scanf("%d%d",&a[i].l,&a[i].r);

        a[i].len=a[i].r-a[i].l+1;

    }

    sort(a+1,a+n+1,cmp);

    int j=1;

    for(int i=1;i<=m;i++)

    {

        while(j<=n&&a[j].len<i)

        {

            T.add(a[j].l,a[j].r,1);

            j++;

        }

        int ans=n-j+1;

        for(int k=i;k<=m;k+=i)

            ans+=T.getsum(k);

        printf("%d\n",ans);

    }

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.407455732844317x):
#include<bits/stdc++.h>

using namespace std;



const int N=310000;

int n,m,tr[N],Ans[N];

struct suv 

{

	int l,r;

	bool operator < (const suv& tp) const

	{

		return r-l<tp.r-tp.l;

	}

}p[N];



void Add(int x,int s)

{

	while(x<=m+1) tr[x]+=s, x+=(x&(-x));

}



int Query(int x)

{

	int ret=0;

	while(x) ret+=tr[x], x-=(x&(-x));

	return ret;

}



int main()

{

	scanf("%d%d",&n,&m);

	for(int i=1;i<=n;++i) scanf("%d%d",&p[i].l,&p[i].r), ++p[i].l, ++p[i].r;

	sort(p+1,p+n+1);

	for(int i=1;i<=n;++i) Add(p[i].l,1), Add(p[i].r+1,-1);

	for(int d=m,cur=n;d>=1;--d)

	{

		while(p[cur].r-p[cur].l+1>=d && cur) Add(p[cur].l,-1), Add(p[cur--].r+1,1);

		Ans[d]=n-cur;// cout<<Ans[d]<<endl;

		for(int i=0;i*d<=m;++i)

			Ans[d] += Query(i*d+1);

	}

	for(int i=1;i<=m;++i) printf("%d\n",Ans[i]);

	return 0;

}
// Slower C++ solution:
#include<iostream>

#include<cstdio>

#include<cstring>

#include<algorithm>

using namespace std;

const int N=300005,M=100005;

int n,m;

struct Node

{

    int l,r,len;

}a[N];

bool cmp(Node x,Node y)

{

    return x.len<y.len;

}

struct Binary_Indexed_Tree

{

    int tree[M];

    Binary_Indexed_Tree()

    {

        memset(tree,0,sizeof(tree));

        return;

    }

    int lowbit(int x)

    {

        return x&-x;

    }

    void add(int x,int y)

    {

        if(x==0) return;

        for(int i=x;i<=m;i+=lowbit(i))

            tree[i]+=y;

        return;

    }

    void add(int a,int b,int val)

    {

        if(a>b) return;

        add(a,val);

        add(b+1,-val);

        return;

    }

    int getsum(int x)

    {

        int res=0;

        for(int i=x;i>0;i-=lowbit(i))

            res+=tree[i];

        return res;

    }

}T;

int main()

{

    scanf("%d%d",&n,&m);

    for(int i=1,l,r;i<=n;++i)

    {

        scanf("%d%d",&a[i].l,&a[i].r);

        a[i].len=a[i].r-a[i].l+1;

    }

    sort(a+1,a+n+1,cmp);

    int j=1;

    for(int i=1;i<=m;i++)

    {

        while(j<=n&&a[j].len<i)

        {

            T.add(a[j].l,a[j].r,1);

            j++;

        }

        int ans=n-j+1;

        for(int k=i;k<=m;k+=i)

            ans+=T.getsum(k);

        printf("%d\n",ans);

    }

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.3740471833785628x):
#include <bits/stdc++.h>

#define fto(i,a,b) for(int i=a; i<=b;++i)

#define fdto(i,a,b) for(int i=a; i>=b;--i)

#define fi first

#define se second

#define mp make_pair

#define pb push_back

#define pii pair<ll,ll>

#define ll long long

#define maxn 300009

#define maxm 100009

#define gb(i,j) ((i>>j)&1)

#define name "a"

#define endl '\n'



using namespace std;

int l[maxn],r[maxn];

int t[maxm],m,n;

void add(int x, int y){

    for(;x<=m; x+=x&-x)t[x]+=y;

}



int get(int x){

    int res=0;

    for(;x;x-=x&-x)res+=t[x];

    return res;

}

pii c[maxn];

main()

{

    ios_base::sync_with_stdio(0);

    cin.tie(0);

    cout.tie(0);

    #ifndef ONLINE_JUDGE

    #endif // ONLINE_JUDGE

    cin >> n >> m;

    fto(i,1,n){

        cin >> l[i] >> r[i];

        c[i]=mp(r[i]-l[i]+1,i);

    }

    sort(c+1,c+n+1);

    int j=1;

    for(int i=1; i<=m; ++i){

        while(c[j].fi <i && j<=n){

            int t=c[j].se;

            add(l[t],1);

            add(r[t]+1,-1);

            ++j;

        }

        int res=n-j+1;

        for(int t=0; t<=m; t+=i)res+=get(t);

        cout << res<<endl;

    }

    return 0;

}