#include using namespace std; #define int long long signed main(){ int N; cin>>N; vector> S(N); for(int i=0;i>S[i].first>>S[i].second; sort(S.begin(),S.end()); int ind = 0; priority_queue,greater> pq; for(int i=S[0].first;i=0;z--){ while(pq.size()) pq.pop(); ind = 0; l += (1ll<