func_code_string: #include <bits/stdc++.h>   using namespace std;   int n, m;   int l[200000], r[200000], p[200001];   vector<int> beg[200001], ed[200001];   map<unsigned long long, unsigned long long> cnt, sum;   unsigned long long h[200000], all;   mt19937_64 mt(time(0));   int main() {     scanf( %d%d , &n, &m);     all = 0;     for (int i = 0; i < (int)(n); ++i) {       scanf( %d%d , l + i, r + i);       --l[i], --r[i];       ++p[l[i]];       --p[r[i] + 1];       beg[l[i]].push_back(i);       ed[r[i] + 1].push_back(i);       h[i] = mt();       all ^= h[i];     }     unsigned long long mask = 0, bmask = all, emask = 0, change = 0, ans = 0;     for (int i = 0; i < (int)(m + 1); ++i) {       for (int x : ed[i]) {         emask ^= h[x];       }       mask ^= change;       ans += cnt[mask ^ all ^ bmask] * i - sum[mask ^ all ^ bmask];       ++cnt[mask ^ emask];       sum[mask ^ emask] += i;       for (int x : beg[i]) {         change ^= h[x];         bmask ^= h[x];       }       for (int x : ed[i]) {         change ^= h[x];       }     }     int t = 0, c = 0;     for (int i = 0; i < (int)(m); ++i) {       t += p[i];       if (t > 0) {         c = 0;       } else {         ++c;         ans -= (unsigned long long)c * (c + 1) / 2;       }     }     cout << ans << endl;     return 0;   }   