classSolution{public:
vector<vector<int>>merge(vector<vector<int>>& intervals){
ranges::sort(intervals,[&](auto&a,auto&b)->bool{return a[0]< b[0];});int n = intervals.size();int start = intervals[0][0], end = intervals[0][1];
vector<vector<int>> ans;for(int i =1; i < n; i++){int a = intervals[i][0], b = intervals[i][1];if(a <= end){
end = end < b ? b : end;}else{
ans.push_back({start, end});
start = a;
end = b;}}
ans.push_back({start, end});return ans;}};
classSolution{public:intmonotoneIncreasingDigits(int n){auto str =to_string(n);int sz = str.size();// char pre = str[0];// int same = 1;// for(int i = 1; i < sz; i++){// int idx = i - same + 1;// same = str[i] == pre ? same + 1 : 1;// if(str[i] < pre){// str[idx - 1] -= 1;// return stoi(str.substr(0, idx) + string(sz - idx, '9'));// }// pre = str[i];// }int end = sz -1;char back = str[end];for(int i = sz -2; i >=0; i--){if(str[i]> back){
end = i;}
back = str[i];}if(end == sz -1){return n;}int same =1;for(int i = end; i >=1; i--){if(str[i]== str[i -1]){
same++;}else{break;}}
str[end +1- same]-=1;returnstoi(str.substr(0, end +2- same)+string(sz - end + same -2,'9'));}};