#include<bits/stdc++.h>
using namespace std;
const int mod = 1e9+7;
const int maxn = 3e5+5;
bool cmp(pair<int, int> a, pair<int, int> b){
return a.first != b.first ? a < b : a.second > b.second;
}
pair<int, vector<int> > complaint(int N, vector<int> L, vector<int> R){
vector<pair<int, int>> vec;
for(int i = 0; i < L.size(); i++){
vec.push_back({R[i], L[i]});
}
sort(vec.begin(), vec.end());
int crr = -1, l = 0, last = -1;
int ans = 0;
vector<int> re;
for(auto v: vec){
if(v.second > crr){
for(int j = l; j <= crr; j++)re.push_back(j);
ans++;
last = crr;
crr = v.first;
l = v.second;
}
else {
if(v.second <= last)continue;
l = max(l, v.second);
}
}
for(int j = l; j <= crr; j++)re.push_back(j);
return make_pair(ans, re);
}
// int main() {
// auto ans = complaint(10, {1, 4, 8, 2}, {4, 7, 9, 6});
// cout << ans.first << endl;
// for(auto v: ans.second)cout << v << " ";
// }
// int main(){
// cout << maintenance_costs_sum({0, 2, 2, 0}, {2, 1, 4, 3}, {2, 3, 6, 5}) << endl;;
// }