#include using namespace std; /*{{{*/ //template #define REP(i,n) for(int i=0;i ostream& operator<<(ostream& os,const vector& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; } template ostream& operator<<(ostream& os,const pair& p){ os << "(" << p.first << ","<< p.second <<")"; return os; } typedef long long ll; typedef unsigned long long ull; typedef pair pii; typedef vector vi; typedef vector vvi; ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); } constexpr ll mod = 1e9+7; const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1}; /*}}}*/ int main(){ ll N,K; cin>>N>>K; vector> vp; // (cost,time) rep(i,N){ ll a,b; cin>>a>>b; vp.push_back(MP(b,a)); } sort(all(vp)); reverse(all(vp)); vector u(N+10,true); set st; for(int i=0;i=K){ u[i] = false; st.insert(t); } } ll mxv=0; ll sum=0; for(int i=0;i