func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = int(3e5) + 228, mod = int(1e9) + 7;   const long long inf = (long long)(1e16);   int n;   pair<int, int> p[N];   pair<long long, long long> t[2 * N], dp[N];   pair<long long, long long> merg(pair<long long, long long> a,                                   pair<long long, long long> b) {     if (a.first > b.first) return b;     if (a.first < b.first) return a;     a.second += b.second;     if (a.second >= mod) a.second -= mod;     return a;   }   void upd(int v, pair<long long, long long> a) {     v += n - 1;     t[v] = merg(t[v], a);     while (v > 1) {       v >>= 1;       t[v] = merg(t[v + v], t[v + v + 1]);     }   }   pair<long long, long long> get(int l, int r) {     l += n - 1;     r += n - 1;     pair<long long, long long> res = make_pair(inf, 0);     while (l <= r) {       if (l & 1) res = merg(res, t[l]);       if (!(r & 1)) res = merg(res, t[r]);       l = (l + 1) >> 1;       r = (r - 1) >> 1;     }     return res;   }   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       scanf( %d%d , &p[i].first, &p[i].second);     }     for (int i = 1; i <= 2 * n; i++) {       t[i] = make_pair(inf, 0);     }     sort(p + 1, p + n + 1);     for (int i = 1; i <= n; i++) {       int l = 0, r = i;       while (r - l > 1) {         int mid = (l + r) >> 1;         if (p[mid].first <= p[i].second)           l = mid;         else           r = mid;       }       if (l == 0) {         dp[i] = make_pair(p[i].second, 1);       } else {         dp[i] = get(1, l);         dp[i].first += p[i].second;       }       upd(i, make_pair(dp[i].first - p[i].first, dp[i].second));     }     int mx = 0;     pair<long long, long long> ans = make_pair(inf, 0);     for (int i = n; i > 0; i--) {       if (mx < p[i].first) ans = merg(ans, dp[i]);       mx = max(mx, p[i].second);     }     printf( %lld , ans.second);     return 0;   }   