func_code_string: #include <bits/stdc++.h>   using namespace std;   int L[100000 + 10], dp1[100000 + 10], dp2[100000 + 10];   int lis(int *seq, int *ls, int N) {     int len = 0;     for (int i = 1; i <= N; ++i) {       int lo = 1, hi = len;       while (lo <= hi) {         int m = (lo + hi) / 2;         if (L[m] <= seq[i])           lo = m + 1;         else           hi = m - 1;       }       L[lo] = seq[i], ls[i] = lo;       if (len < lo) len = lo;     }     return len;   }   int A[100000 + 10], Rev[100000 + 10];   int solve(int n) {     lis(A, dp1, n);     lis(Rev, dp2, n);     int ans = 0;     for (int i = 1, j = n; i <= n; i++, j--) {       ans = max(ans, dp1[i] + dp2[j] - 1);     }     return ans;   }   int go(vector<int> &arr, int n) {     for (int i = 1, j = n; i <= n; i++, j--) A[i] = arr[i - 1], Rev[j] = A[i];     return solve(n);   }   vector<int> V;   int arr[100000 + 5];   int main() {     int n, m, i, l, r, ans = 0;     scanf( %d %d , &n, &m);     for (i = 1; i <= n; i++) {       scanf( %d %d , &l, &r);       arr[l]++;       arr[r + 1]--;     }     for (i = 1; i <= m; i++) arr[i] += arr[i - 1];     for (int i = 1; i <= m; i++) {       V.push_back(arr[i]);     }     cout << go(V, V.size()) << endl;   }   