func_code_string: #include <bits/stdc++.h>   using namespace std;   const int MAXN = 100005;   const long long INF = 1e18;   const long long MOD = 1000000007;   long double A[100005], B[100005];   int main() {     int n, p;     cin >> n >> p;     for (int i = 0; i < n; i++) {       int x, y;       cin >> x >> y;       A[i] = y / p;       A[i] -= (x - 1) / p;       B[i] = (y - x + 1);     }     long double res;     long double ans = 0;     for (int i = 1; i < n; i++) {       res = (A[i] * A[i - 1]) + (A[i] * (B[i - 1] - A[i - 1])) +             (A[i - 1] * (B[i] - A[i]));       long double d = B[i] * B[i - 1];       res = res / d;       res = res * 2000;       ans += res;     }     res = (A[0] * A[n - 1]) + (A[0] * (B[n - 1] - A[n - 1])) +           (A[n - 1] * (B[0] - A[0]));     long double d = B[0] * B[n - 1];     res = res / d;     res = res * 2000;     ans += res;     cout << setprecision(10) << ans;     return 0;   }   