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

using namespace std;

typedef long long ll;

int main(){

	int n,d; cin>>n>>d;

	float ans = (n*1.0)/((d*2.0)+1.0);

	cout<<ceil(ans)<<endl;

}


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

int main()

{

	int N, D;

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

	int fanwei;

	fanwei = D*2+1;

	int i;

	for( i = 0; N>0; i++)

	{

		N = N-fanwei;

	}

	printf("%d",i);

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

using namespace std;



#define REP(i,n) for(ll i=0; i<(ll)(n); i++)

#define FOR(i,n,m) for (ll i=n; i<(ll)(m); i++)

#define pb push_back

#define INF 1000000007LL

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

#define chmin(a,b) a=min(a,b)

#define chmax(a,b) a=max(a,b)



typedef long long ll;

typedef pair<int,int> p;



int dy[4]={-1,1,0,0};

int dx[4]={0,0,1,-1};



int N, Z, W;

int a[2010];



map<int, int> dp[2][2010];

int main(){

    ios::sync_with_stdio(false);

    cin >> N >> Z >> W;

    REP(i, N) cin >> a[i];

    function<int(int, bool, int, int)> score = [&](int used, int turn, int x, int y) {

        if (used == N) return abs(x - y);

        if (turn) {

            if (dp[turn][used].count(x)) return dp[turn][used][x];

            int res = INF;

            FOR(i, used + 1, N+1) {

                res = min(res, score(i, turn^1, x, a[i-1]));

            }

            return dp[turn][used][x] = res;

        } else {

            if (dp[turn][used].count(y)) return dp[turn][used][y];

            int res = 0;

            FOR(i, used + 1, N+1) {

                res = max(res, score(i, turn^1, a[i-1], y));

            }

            return dp[turn][used][y] = res;

        }

    };

    cout << score(0, 0, Z, W) << endl;;

    

    return 0;

}




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

using namespace std;



#define REP(i,n) for(ll i=0; i<(ll)(n); i++)

#define FOR(i,n,m) for (ll i=n; i<(ll)(m); i++)

#define pb push_back

#define INF 1000000007LL

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

#define chmin(a,b) a=min(a,b)

#define chmax(a,b) a=max(a,b)



typedef long long ll;

typedef pair<int,int> p;



int dy[4]={-1,1,0,0};

int dx[4]={0,0,1,-1};



int N, Z, W;

int a[2010];



int dp[2][2010];

int main(){

    ios::sync_with_stdio(false);

    cin >> N >> Z >> W;

    REP(i, N) cin >> a[i];

    function<int(int, bool, int, int)> score = [&](int used, int turn, int x, int y) {

        if (used == N) return abs(x - y);

        if (turn) {

            if (dp[turn][used] != -1) return dp[turn][used];

            int res = INF;

            FOR(i, used + 1, N+1) {

                res = min(res, score(i, turn^1, x, a[i-1]));

            }

            return dp[turn][used] = res;

        } else {

            if (dp[turn][used] != -1) return dp[turn][used];

            int res = 0;

            FOR(i, used + 1, N+1) {

                res = max(res, score(i, turn^1, a[i-1], y));

            }

            return dp[turn][used] = res;

        }

    };

    REP(i, 2010) {dp[0][i] = -1; dp[1][i] = -1;}

    cout << score(0, 0, Z, W) << endl;;

    

    return 0;

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

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

using namespace std;

typedef long long ll;

int INF = (1LL << 30) - 1;

int MOD = 1e9+7;

main(){

    int N,C;

    cin >> N >> C;

    int cnt[C][100010] = {};

    vector<int> S(N),T(N),P(N);

    rep(i,0,N){

        cin >> S[i] >> T[i] >> P[i];

        cnt[P[i]-1][S[i]-1]++;

        cnt[P[i]-1][T[i]]--;

    }

    rep(i,1,100000)rep(j,0,C){

        cnt[j][i] += cnt[j][i-1];

    }

    int maxi = 0;

    rep(i,0,100000){

        int c = 0;

        rep(j,0,C){

            c += (cnt[j][i] > 0);

        }

        maxi = max(maxi, c);

    }

    cout << maxi << endl;

}

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

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

using namespace std;

typedef long long ll;

int INF = (1LL << 30) - 1;

int MOD = 1e9+7;

int imos[30][100010];

main(){

    int N,C;

    cin >> N >> C;

    vector<int> S(N),T(N),R(N);

    rep(i,0,N)cin >> S[i] >> T[i] >> R[i];

    rep(i,0,N){

        imos[R[i]-1][S[i]]++;

        imos[R[i]-1][T[i]+1]--;

    }

    rep(i,0,C)rep(j,0,100001)imos[i][j+1] += imos[i][j];

    int maxi = 0;

    //rep(i,0,C)rep(j,0,20)cout << imos[i][j] << " \n"[j==19];

    rep(i,0,100002){

        int cnt = 0;

        rep(j,0,C)if(imos[j][i])cnt++;

        maxi = max(maxi, cnt);

    }

    cout << maxi << endl;

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

using namespace std;

typedef long long ll;

#define inf 1LL<<62





ll a[100010],cha[32][100010];

int main() {

	ll n ,C;

	cin>>n>>C;

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

		int l,r,c;

		cin>>l>>r>>c;

		c--;

		for(int j=l;j<=r;j++){

			cha[c][j]=1;

		}

	}

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

		for(int j=0;j<100010;j++){

			if(cha[i][j]==1){

				a[j]++;

			}

		}

	}

	ll ans=0;

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

		ans=max(ans,a[i]);

	}

	cout <<ans;

	return 0;

}

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

using namespace std;

typedef long long ll;

#define INF 1LL<<62

#define inf 1000000007



ll ch[100010];

ll same[32][100010];

int main() {

	ll n,c;

	cin>>n>>c;

	ll sum=0;

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

		ll l,r,z;

		cin>>l>>r>>z;

		ch[l]++;

		ch[r+1]--;

		same[z][l]++;

		same[z][r]++;

		if(same[z][l]==2){

			ch[l]--;

			ch[l+1]++;

		}

		if(same[z][r]==2){

			ch[r]--;

			ch[r+1]++;

		}

	}

	ll ans=ch[0];

	for(ll i=1;i<100010;i++){

		ch[i]=ch[i-1]+ch[i];

		ans=max(ans,ch[i]);

	}

	cout <<ans-sum;

	// your code goes here

	return 0;

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

using namespace std;

typedef long long ll;

#define INF 1LL<<62

#define inf 1000000007 



ll a[32][100010];

ll b[100010];

int main() {

	ll n,c;

	cin>>n>>c;

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

		ll x,y,z;

		cin>>x>>y>>z;

		z--;

		a[z][x]++;

		a[z][y]--;

	}

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

		for(int j=0;j<100010;j++){

			a[i][j+1]=a[i][j]+a[i][j+1];

		}

	}

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

		ll now=0;

		for(int j=0;j<c;j++){

			if(a[j][i]==0&&a[j][i+1]==1){

				now++;

				continue;

			}

			now+=a[j][i];

		}

		b[i]=now;

	}

	ll ans=0;

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

		ans=max(ans,b[i]);

	}

	cout <<ans;

	// your code goes here

	return 0;

}

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

using namespace std;

typedef long long ll;

#define INF 1LL<<62

#define inf 1000000007



ll ch[100010];

ll same[32][100010];

int main() {

	ll n,c;

	cin>>n>>c;

	ll sum=0;

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

		ll l,r,z;

		cin>>l>>r>>z;

		ch[l]++;

		ch[r+1]--;

		same[z][l]++;

		same[z][r]++;

		if(same[z][l]==2){

			ch[l]--;

			ch[l+1]++;

		}

		if(same[z][r]==2){

			ch[r]--;

			ch[r+1]++;

		}

	}

	ll ans=ch[0];

	for(ll i=1;i<100010;i++){

		ch[i]=ch[i-1]+ch[i];

		ans=max(ans,ch[i]);

	}

	cout <<ans-sum;

	// your code goes here

	return 0;

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

#include <vector>

#include <string>

#include <algorithm>

#include <cstdio>

#include <cstring>

#include <cmath>

using namespace std;



int main() {

    ios::sync_with_stdio(false);

    cin.tie(0);



    int n, c;

    cin >> n >> c;



    const int T = (int)1e5 + 1;



    vector<int> a[30];

    for (int k = 0; k < c; k++) {

        a[k] = vector<int>(T);

    }

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

        int s, t, c;

        cin >> s >> t >> c;

        c--;



        for (int j = s; j < t; j++) {

            a[c][j] = 1;

        }

    }

    for (int k = 0; k < c; k++) {

        for (int j = 1; j < T; j++) {

            if (a[k][j] == 1 && a[k][j - 1] == 0) a[k][j - 1] = 1;

        }

    }

    int r = 0;

    for (int j = 0; j < T; j++) {

        int s = 0;

        for (int k = 0; k < c; k++) {

            s += a[k][j];

        }

        r = max(r, s);

    }



    cout << r << endl;



    return 0;

}

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

#include <vector>

#include <string>

#include <algorithm>

#include <cstdio>

#include <cstring>

#include <cmath>

using namespace std;



int main() {

    ios::sync_with_stdio(false);

    cin.tie(0);



    int n, c;

    cin >> n >> c;



    const int T = (int)1e5;



    vector<int> a(T);

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

        int s, t, c;

        cin >> s >> t >> c;

        c--;



        for (int j = s; j < t; j++) {

            a[j] ^= 1 << c;

        }

    }



    for (int j = 0; j < T - 1; j++) {

        a[j] ^= ~a[j] & a[j + 1];

    }



    int r = 0;

    for (int j = 0; j < T; j++) {

        int s = a[j];

        s = (s & 0x55555555) + (s >> 1 & 0x55555555);

        s = (s & 0x33333333) + (s >> 2 & 0x33333333);

        s = (s & 0x0f0f0f0f) + (s >> 4 & 0x0f0f0f0f);

        s = (s & 0x00ff00ff) + (s >> 8 & 0x00ff00ff);

        s = (s & 0x0000ffff) + (s >> 16);

        r = max(r, s);

    }



    cout << r << endl;



    return 0;

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

#include<iostream>

#include<deque>

#include<algorithm>

#include<string>

#include<cctype>

#include<iomanip>

#include<vector>

#include<queue>

 

using namespace std;

#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)

#define rep0(i,n) REP(i,0ll,n)

#define rep1(i,n) REP(i,1ll,n+1)

 

#define shosu setprecision(10)

 

typedef long long ll;

typedef pair<int,int> P;

ll longinf=1ll<<60;

int inf=1<<29;

int dx[4]={1,-1,0,0};

int dy[4]={0,0,1,-1};



int hoge[30][100001];

int used[30][100001];

int anss[100001];

int main (){

      int N,C;

      cin>>N>>C;

      int s[N],t[N],c[N];

      rep0(i,N){

            cin>>s[i]>>t[i]>>c[i];

            --c[i];

      }

      rep0(ch,C){

            rep0(i,N){

                  if(c[i]==ch){

                        hoge[ch][s[i]-1]++;

                        hoge[ch][t[i]]--;

                  }

            }

      }

      rep0(ch,C){

            rep0(t,100001){

                  if(t==0) used[ch][t]=hoge[ch][t];

                  else used[ch][t]=used[ch][t-1]+hoge[ch][t];

            }

      }

      rep0(ch,C)rep0(t,100001){

            if(used[ch][t]>0) used[ch][t]=1;

      }

      rep0(t,100001)rep0(ch,C){

            anss[t]+=used[ch][t];

      }

      int ans=0;

      rep0(t,100001){

            ans=max(ans,anss[t]);

      }

      cout<<ans<<endl;



      

      return 0;

}


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

#include<iostream>

#include<deque>

#include<algorithm>

#include<string>

#include<cctype>

#include<iomanip>

#include<vector>

#include<queue>

 

using namespace std;

#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)

#define rep0(i,n) REP(i,0ll,n)

#define rep1(i,n) REP(i,1ll,n+1)

 

#define shosu setprecision(10)

 

typedef long long ll;

typedef pair<int,int> P;

ll longinf=1ll<<60;

int inf=1<<29;

int dx[4]={1,-1,0,0};

int dy[4]={0,0,1,-1};

int main (){

      int N,C;

      cin>>N>>C;

      int s[N],t[N],c[N];

      int maxt=0;

      rep0(i,N){

            cin>>s[i]>>t[i]>>c[i];

            maxt=max(maxt,t[i]);

            --c[i];

      }

      int huu=((maxt+1))*C;

      int hoge[huu];

      int used[huu];

      int anss[maxt+1];

      fill(hoge,hoge+huu,0);

      fill(used,used+huu,0);

      fill(anss,anss+maxt+1,0);



      rep0(ch,C){

            rep0(i,N){

                  if(c[i]==ch){

                        hoge[ch*(maxt+1)+(s[i]-1)]++;

                        hoge[ch*(maxt+1)+(t[i])]--;

                  }

            }

      }

      rep0(ch,C){

            rep0(t,maxt+1){

                  if(t==0) used[ch*(maxt+1)+t]=hoge[ch*(maxt+1)+t];

                  else used[ch*(maxt+1)+t]=used[ch*(maxt+1)+(t-1)]+hoge[ch*(maxt+1)+t];

            }

      }

      rep0(ch,C)rep0(t,(maxt+1)){

            if(used[ch*(maxt+1)+t]>0) used[ch*(maxt+1)+t]=1;

      }

      rep0(t,(maxt+1))rep0(ch,C){

            anss[t]+=used[ch*(maxt+1)+t];

      }

      int ans=0;

      rep0(t,(maxt+1)){

            ans=max(ans,anss[t]);

      }

      cout<<ans<<endl;



      

      return 0;

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

#include<iostream>

#include<deque>

#include<algorithm>

#include<string>

#include<cctype>

#include<iomanip>

#include<vector>

#include<queue>

 

using namespace std;

#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)

#define rep0(i,n) REP(i,0ll,n)

#define rep1(i,n) REP(i,1ll,n+1)

 

#define shosu setprecision(10)

 

typedef long long ll;

typedef pair<int,int> P;

ll longinf=1ll<<60;

int inf=1<<29;

int dx[4]={1,-1,0,0};

int dy[4]={0,0,1,-1};



int hoge[30][100001];

int used[30][100001];

int anss[100001];

int main (){

      int N,C;

      cin>>N>>C;

      int s[N],t[N],c[N];

      rep0(i,N){

            cin>>s[i]>>t[i]>>c[i];

            --c[i];

      }

      rep0(ch,C){

            rep0(i,N){

                  if(c[i]==ch){

                        hoge[ch][s[i]-1]++;

                        hoge[ch][t[i]]--;

                  }

            }

      }

      rep0(ch,C){

            rep0(t,100001){

                  if(t==0) used[ch][t]=hoge[ch][t];

                  else used[ch][t]=used[ch][t-1]+hoge[ch][t];

            }

      }

      rep0(ch,C)rep0(t,100001){

            if(used[ch][t]>0) used[ch][t]=1;

      }

      rep0(t,100001)rep0(ch,C){

            anss[t]+=used[ch][t];

      }

      int ans=0;

      rep0(t,100001){

            ans=max(ans,anss[t]);

      }

      cout<<ans<<endl;



      

      return 0;

}


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

#include<iostream>

#include<deque>

#include<algorithm>

#include<string>

#include<cctype>

#include<iomanip>

#include<vector>

#include<queue>

 

using namespace std;

#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)

#define rep0(i,n) REP(i,0ll,n)

#define rep1(i,n) REP(i,1ll,n+1)

 

#define shosu setprecision(10)

 

typedef long long ll;

typedef pair<int,int> P;

ll longinf=1ll<<60;

int inf=1<<29;

int dx[4]={1,-1,0,0};

int dy[4]={0,0,1,-1};



int16_t hoge[30][100001];

int16_t used[30][100001];

int16_t anss[100001];

int main (){

      int N,C;

      cin>>N>>C;

      int s[N],t[N],c[N];

      rep0(i,N){

            cin>>s[i]>>t[i]>>c[i];

            --c[i];

      }

      rep0(ch,C){

            rep0(i,N){

                  if(c[i]==ch){

                        hoge[ch][s[i]-1]++;

                        hoge[ch][t[i]]--;

                  }

            }

      }

      rep0(ch,C){

            rep0(t,100001){

                  if(t==0) used[ch][t]=hoge[ch][t];

                  else used[ch][t]=used[ch][t-1]+hoge[ch][t];

            }

      }

      rep0(ch,C)rep0(t,100001){

            if(used[ch][t]>0) used[ch][t]=1;

      }

      rep0(t,100001)rep0(ch,C){

            anss[t]+=used[ch][t];

      }

      int16_t ans=0;

      rep0(t,100001){

            ans=max(ans,anss[t]);

      }

      cout<<ans<<endl;

      return 0;

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



using namespace std;



struct segtree

{

	vector<int> t;

	segtree(int n) :t(n * 2 - 1, 0) {}

	void add(int a, int b, int o, int l, int r)

	{

		if (a >= r || b <= l)

			return;

		if (a <= l && b >= r) {

			t[o]++;

			return;

		}

		int m = (l + r) / 2;

		add(a, b, o + 1, l, m);

		add(a, b, o + (m - l) * 2, m, r);

	}

	int min(int o, int l, int r)

	{

		if (l + 1 == r)

			return t[o];

		int m = (l + r) / 2;

		int p = min(o + 1, l, m);

		int q = min(o + (m - l) * 2, m, r);

		return max(p, q) + t[o];

	}

};



pair<int, pair<int, int>> p[111111];

int main()

{

	int N, C;

	cin >> N >> C;

	for (int i = 0; i < N; i++)

		scanf("%d%d%d", &p[i].second.first, &p[i].second.second, &p[i].first);

	sort(p, p + N);

	segtree s(111000);

	int c = 0, d = 0;

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

		if (p[i].first != c || p[i].second.first != d) {

			c = p[i].first;

			s.add(p[i].second.first - 1, p[i].second.first, 0, 0, 111000);

		}

		d = p[i].second.second;

		s.add(p[i].second.first, p[i].second.second, 0, 0, 111000);

	}

	cout << s.min(0, 0, 111000) << endl;

	return 0;

}


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



using namespace std;



int p[111111], q[30][111111];

int main()

{

	int N, m, n = 0;

	cin >> N >> m;

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

		int s, t, c;

		scanf("%d%d%d", &s, &t, &c);

		n = max(n, t);

		if (!q[--c][s])

			q[c][s--] = 1;

		if (q[c][t]) t--;

		else q[c][t] = 1;

		while (s < t) p[s++]++;

	}

	m = 0;

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

		m = max(m, p[i]);

	cout << m << endl;

	return 0;

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

using namespace std;

typedef signed long long ll;



#undef _P

#define _P(...) (void)printf(__VA_ARGS__)

#define FOR(x,to) for(x=0;x<(to);x++)

#define FORR(x,arr) for(auto& x:arr)

#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)

#define ALL(a) (a.begin()),(a.end())

#define ZERO(a) memset(a,0,sizeof(a))

#define MINUS(a) memset(a,0xff,sizeof(a))

//-------------------------------------------------------



int N,CC;

int S[101010],T[101010],C[101010],did[101010];

vector<int> st[201010];



int pre[101010];



void solve() {

	int i,j,k,l,r,x,y; string s;

	

	cin>>N>>CC;

	FOR(i,N) {

		cin>>S[i]>>T[i]>>C[i];

		S[i]*=2;

		T[i]*=2;

		C[i]--;

		st[S[i]].push_back(i);

	}

	

	int num=0;

	MINUS(pre);

	FOR(i,201000) {

		

		FORR(e,st[i]) {

			if(pre[C[e]]!=-1) {

				pre[C[e]]=T[e];

				did[e]++;

			}

		}

		FORR(e,st[i]) if(did[e]==0) {

			FOR(j,CC) {

				if(pre[j]!=-1 && pre[j]<S[e]-1) {

					pre[j]=-1;

					pre[C[e]]=T[e];

					break;

				}

			}

			if(j==CC) {

				pre[C[e]]=T[e];

				num++;

			}

		}

	}

	

	

	

	cout<<num<<endl;

	

	

}





int main(int argc,char** argv){

	string s;int i;

	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);

	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);

	cout.tie(0); solve(); return 0;

}


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

using namespace std;

typedef signed long long ll;



#undef _P

#define _P(...) (void)printf(__VA_ARGS__)

#define FOR(x,to) for(x=0;x<(to);x++)

#define FORR(x,arr) for(auto& x:arr)

#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)

#define ALL(a) (a.begin()),(a.end())

#define ZERO(a) memset(a,0,sizeof(a))

#define MINUS(a) memset(a,0xff,sizeof(a))

//-------------------------------------------------------



int N,CC;

int S[101010],T[101010],C[101010],did[101010];

vector<int> st[201010];



int pre[101010];



void solve() {

	int i,j,k,l,r,x,y; string s;

	

	cin>>N>>CC;

	FOR(i,N) {

		cin>>S[i]>>T[i]>>C[i];

		C[i]--;

		st[S[i]].push_back(i);

	}

	

	int num=0;

	FOR(i,CC) pre[i]=202020;

	FOR(i,101000) {

		

		FORR(e,st[i]) {

			if(pre[C[e]]<=S[e]) {

				pre[C[e]]=T[e];

				did[e]++;

			}

		}

		FORR(e,st[i]) if(did[e]==0) {

			FOR(j,CC) {

				if(pre[j]<S[e]) {

					pre[j]=202020;

					pre[C[e]]=T[e];

					break;

				}

			}

			if(j==CC) {

				pre[C[e]]=T[e];

				num++;

			}

		}

	}

	

	

	

	cout<<num<<endl;

	

	

}





int main(int argc,char** argv){

	string s;int i;

	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);

	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);

	cout.tie(0); solve(); return 0;

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



using namespace std;

 

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)

#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)

#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)

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

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



typedef int64_t ll; typedef vector<int> VI; typedef pair<int,int> pii;

const ll mod = 1e9+7;



void dbg(){ cerr << "\n"; }  

template <typename T,typename ...T2>

void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }



int main()

{

 

	//cin.tie(0); ios_base::sync_with_stdio(false);

	const int MX=200001;

	int n, ch;

	cin >>n >>ch;

	vector<vector<pii>> dt(ch);

	//VI s(n), t(n), c(n);

	

	rep(i, n){

		int s,t,c;

		cin >>s >> t >>c;

		dt[c-1].push_back(pii(2*s-1, 2*t));

	}

	rep(i,ch) sort(all(dt[i]));

	vector<int> usd(MX+20);



	rep(i,ch){

		int fr=0, to=0;

		rep(j, sz(dt[i])){

			if(dt[i][j].first > to || to==0){

				if(to >0){

					usd[fr] +=1;

					usd[to] -=1;

					//dbg(i,fr,to);

				}

				tie(fr,to) = dt[i][j];

			}

			if(dt[i][j].first <= to){

				to = max(to, dt[i][j].second);

			}

		}

		usd[fr] +=1;

		usd[to] -=1;

		//dbg(i,fr,to);

	}

	rep(i, MX) usd[i+1] += usd[i];

	//rep(i,100) printf("%d, ",usd[i]); puts("");

	cout << *max_element(all(usd)) <<"\n";

	

	return 0;

}

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





#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)

#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)

#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)

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

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



using namespace std;

typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;

const int MD = (int)1e9 + 7; typedef vector<ll> VL;

void dbg(){ cerr << "\n"; }  template <class T, class ...T2>

void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}



int main()

{

	cin.tie(0); ios_base::sync_with_stdio(false);

	int n, c;

	cin >>n >>c;

	vector<VI> dt(n, VI(4)), dt2; 

	rep(i, n) cin >>dt[i][1] >>dt[i][2] >>dt[i][0];

	sort(all(dt));

	VI ccr = dt[0];

	rep2(i, 1, n){

		if(ccr[0] == dt[i][0] && ccr[2]==dt[i][1]){

			ccr[2] = dt[i][2];

		}else{

			dt2.push_back(ccr);

			ccr = dt[i];

		}

	}

	dt2.push_back(ccr);

	sort(all(dt2), [](auto& l, auto& r){return l[1] < r[1];});

	VI vdr; int ans = 0;

	for(const auto& x: dt2){

		int add = 1;

		for(auto& z: vdr){

			if( z < x[1]){

				z = x[2]; add = 0; break;

			}

		}

		if(add==1){

			vdr.push_back(x[2]);

			ans = max(ans, sz(vdr));

		}

	}

	cout <<ans <<"\n";

	return 0;

}