func_code_string: #include <bits/stdc++.h>   using namespace std;   const int mod = 1e9 + 7;   const int maxn = 2e5 + 10;   int n, k;   long long fac[maxn + 10], afac[maxn + 10];   long long qpow(long long a, long long b) {     long long ret = 1LL;     while (b) {       if (b & 1) ret = ret * a % mod;       a = a * a % mod;       b >>= 1;     }     return ret;   }   long long inv(long long x) { return qpow(x, mod - 2); }   void Pre() {     fac[0] = 1LL;     for (int i = 1; i <= maxn; i++) fac[i] = fac[i - 1] * (long long)i % mod;     afac[maxn] = inv(fac[maxn]);     for (int i = maxn; i >= 1; --i) afac[i - 1] = afac[i] * i % mod;   }   long long C(long long n, long long m) {     if (m > n) return 0;     return fac[n] * afac[n - m] % mod * afac[m] % mod;   }   void solve() {     vector<pair<int, int> > h;     int l, r;     for (int i = 1; i <= n; i++) {       scanf( %d %d , &l, &r);       h.push_back(make_pair(l - 1, 1));       h.push_back(make_pair(r, -1));     }     sort(h.begin(), h.end());     long long cnt = 0LL, ans = 0LL;     int pos = h[0].first;     for (int i = 0; i < h.size(); i++) {       long long tmp = C(cnt, k) * (h[i].first - pos) % mod;       ans = (ans + tmp) % mod;       cnt += 1LL * h[i].second;       pos = h[i].first;     }     printf( %I64d n , ans);   }   int main() {     Pre();     while (scanf( %d %d , &n, &k) != EOF) {       solve();     }     return 0;   }   