#include <bits/stdc++.h>   using namespace std;   int n, p;   double l[100100], r[100100], s[100100];   long long ans;   double c;   int main() {     cin >> n >> p;     for (int i = 0; i < n; i++) {       cin >> l[i] >> r[i];       s[i] = 1 - (floor(r[i] / p) - ceil(l[i] / p) + 1) / (r[i] - l[i] + 1);     }     for (int i = 0; i < n; i++) {       c += (2000 * (1 - s[(i + 1) % n] * s[i]));       ans += floor(c);       c = c - floor(c);     }     if (c != 0) {       if (ans >= 1000000) {         cout << ans << endl;         return 0;       } else {         cout << ans / 10;         c += (ans % 10);         cout << c << endl;       }     } else {       cout << ans << endl;     }   }   