// custom comparator for set< pair<int,int> >
struct comp {
// operator() overloading
bool operator() (const pair<int, int>&a, const pair<int, int>&b){
if((a.second - a.first) > (b.second - b.first)){
return true;
}
else if(a.second - a.first == b.second - b.first){
return a.first < b.first;
}
return false;
}
};
// declaration of set
set<pair<int, int>, comp> s;