#include #include using namespace std; using ll=long long; #define all(v) v.begin(),v.end() #define rall(v) v.rbegin(),v.rend() template bool chmax(T &a, T b){if (a < b){a = b;return true;} else return false;} template bool chmin(T &a, T b){if (a > b){a = b;return true;} else return false;} int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int N; ll M; cin>>N>>M; vectorX(N),Y(N); vectorV; for(int i=0;i>X[i]>>Y[i]; V.push_back(X[i]); V.push_back(Y[i]); } sort(all(V)); V.erase(unique(all(V)),V.end()); int L=V.size(); mapmp; for(int i=0;iP; for(int i=0;iflag(L); vectorW(L); for(int i=0;i0){ if(flag[i])ans+=W[i]; else ans+=W[i]-1; } } cout<