#include <bits/stdc++.h>   using namespace std;   int l[210000], r[210000];   vector<pair<int, int> > v;   int n, m, k;   int mp[1000];   int lbit[1000];   int dp[210000][300];   int msk[210000];   int main() {     for (int i = 0; i < 210000; i++)       for (int j = 0; j < 300; j++) dp[i][j] = -0x3f3f3f3f;     dp[0][0] = 0;     for (int i = 0; i < (1 << 9); i++) {       int cnt = 0;       for (int j = 0; j < 8; j++)         if (i & (1 << j)) {           mp[i]++;         } else if (lbit[i] == 0) {           lbit[i] = (1 << j);         }     }     cin >> n >> m >> k;     for (int i = 1; i <= n; i++) {       scanf( %d%d , &l[i], &r[i]);       v.push_back({l[i] - 1, i});       v.push_back({r[i], -i});     }     sort(v.begin(), v.end());     int tim = 0;     int posmsk = 0;     int ans = 0;     int lst = 0;     for (auto p : v) {       tim++;       if (p.second < 0) {         for (int j = 0; j < (1 << 8); j++)           if (j & msk[-p.second])             dp[tim][j ^ msk[-p.second]] =                 max(dp[tim][j ^ msk[-p.second]],                     dp[tim - 1][j] + max(0, p.first - lst) * (mp[j] & 1));           else {             dp[tim][j] =                 max(dp[tim][j], dp[tim - 1][j] + (p.first - lst) * (mp[j] & 1));           }         posmsk ^= msk[-p.second];       } else {         msk[p.second] = lbit[posmsk];         posmsk ^= msk[p.second];         for (int j = 0; j < (1 << 8); j++)           if ((j & msk[p.second]) == 0) {             dp[tim][j ^ msk[p.second]] =                 max(dp[tim][j ^ msk[p.second]],                     dp[tim - 1][j] + (max(0, p.first - lst)) * (mp[j] & 1));             dp[tim][j] =                 max(dp[tim][j], dp[tim - 1][j] + (p.first - lst) * (mp[j] & 1));           }       }       lst = p.first;     }     cout << dp[2 * n][0];     return ~~(0 ^ 0 ^ 0);   }   