func_code_string: #include <bits/stdc++.h>   using namespace std;   pair<pair<long long, long long>, long long> merge_p(       pair<long long, long long> a, pair<long long, long long> b) {     if (a.first > b.first) swap(a, b);     if (b.first <= a.second) {       if (b.second <= a.second)         return make_pair(b, 0);       else         return make_pair(make_pair(b.first, a.second), 0);     } else {       return make_pair(make_pair(a.second, b.first), b.first - a.second);     }   }   void solve() {     int n, x;     cin >> n >> x;     pair<long long, long long> opt = make_pair(x, x);     long long ans = 0;     pair<long long, long long> tmp;     for (int i = 0; i < n; ++i) {       cin >> tmp.first >> tmp.second;       pair<pair<long long, long long>, long long> f = merge_p(opt, tmp);       opt = f.first;       ans += f.second;     }     cout << ans << endl;   }   int main() {     time_t t1 = clock();     solve();     time_t t2 = clock();   }   