#include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; #define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++) #define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--) #define FOREACH(i,Itr) for(auto (i)=(Itr).begin();(i)!=(Itr).end();(i)++) #define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end()) #define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end()) #define LBOUND(Itr,val) lower_bound((Itr).begin(),(Itr).end(),(val)) #define UBOUND(Itr,val) upper_bound((Itr).begin(),(Itr).end(),(val)) ll cntmax(vector< pair > y, ll cap){ sort(y.begin(),y.end()); ll sum=0; ll cnt=0; ll res=0; int j=0; for(int i=0;i>N>>B; vector< pair< pair,ll > > C(N); REP(i,N)cin>>C[i].first.first>>C[i].first.second>>C[i].second; sort(C.begin(),C.end()); ll ans=0; for(int xl=0;xl > t; for(int i=xl;i<=xr;i++){ t.push_back(make_pair(C[i].first.second,C[i].second)); } ans=max(ans,cntmax(t,B)); } } cout<