func_code_string: #include <bits/stdc++.h>   using namespace std;   long long fat[200005];   void gerafat() {     fat[0] = 1;     for (long long i = 1; i < 200005; i++) {       fat[i] = (fat[i - 1] * i) % 1000000007;     }   }   long long modInv(long long a) {     long long v = 1;     long long e = 1000000007 - 2;     while (e) {       if (e % 2) {         v *= a;         v %= 1000000007;       }       e /= 2;       a *= a;       a %= 1000000007;     }     return v;   }   long long comb(int a, int b) {     if (a < b) return 0;     long long res =         ((fat[a] * modInv(fat[b])) % 1000000007 * modInv(fat[a - b])) %         1000000007;     return res;   }   int main() {     long long n, k;     cin >> n >> k;     gerafat();     vector<long long> num(0);     set<long long> sete;     vector<pair<long long, long long> > v(n, {0, 0});     for (long long i = 0; i < n; i++) {       long long a, b;       cin >> a >> b;       v[i] = {a, b};       if (!sete.count(a)) {         num.push_back(a);         sete.insert(a);       }       if (!sete.count(b)) {         num.push_back(b);         sete.insert(b);       }       if (!sete.count(b + 1)) {         num.push_back(b + 1);         sete.insert(b + 1);       }     }     sort(num.begin(), num.end());     long long tam = num.size();     map<long long, long long> mapa;     for (long long i = 0; i < tam; i++) mapa[num[i]] = i;     vector<long long> pref(tam, 0);     for (int i = 0; i < n; i++) {       pref[mapa[v[i].first]]++;       pref[mapa[v[i].second + 1]]--;     }     for (int i = 1; i < tam; i++) pref[i] += pref[i - 1];     long long res = comb(pref[0], k) % 1000000007;     for (long long i = 1; i < tam; i++) {       res = (res + comb(pref[i], k)) % 1000000007;       res = (res + ((long long)(num[i] - num[i - 1] - 1) *                     comb(min(pref[i], pref[i - 1]), k)) %                        1000000007) %             1000000007;     }     cout << res << endl;   }   