func_code_string: #include <bits/stdc++.h>   using namespace std;   int main() {     long long n, m, k, i, x, y, s, p;     cin >> n >> m;     s = 0;     k = 1;     for (i = 1; i <= n; i++) {       cin >> x >> y;       k = x - k;       p = k % m;       x -= p;       s += y - x + 1;       k = y + 1;     }     cout << s << endl;   }   