func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 400010;   struct Event {     int x, type, ind;     Event() {}     Event(int x, int type, int ind) : x(x), type(type), ind(ind) {}     bool operator<(const Event &other) const {       return make_pair(x, type) < make_pair(other.x, other.type);     }   };   int n, k;   int l[N], r[N];   Event a[N];   bool del[N];   set<pair<int, int> > q;   vector<int> res;   int main() {     scanf( %d%d , &n, &k);     for (int i = 1; i <= n; i++) {       scanf( %d%d , &l[i], &r[i]);       a[2 * i - 1] = Event(l[i], 0, i);       a[2 * i] = Event(r[i], 1, i);     }     sort(a + 1, a + 2 * n + 1);     int cov = 0;     int ans = 0;     for (int i = 1; i <= n; i++) del[i] = false;     for (int i = 1; i <= 2 * n; i++) {       int j = a[i].ind;       if (a[i].type == 0) {         q.insert(make_pair(-r[j], j));         cov++;         if (cov > k) {           cov--;           ans++;           int ind = (*q.begin()).second;           del[ind] = true;           res.push_back(ind);           q.erase(q.begin());         }       } else if (!del[j]) {         cov--;         q.erase(make_pair(-r[j], j));       }     }     printf( %d n , ans);     for (int x : res) printf( %d  , x);     return 0;   }   