func_code_string: #include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     long long N, P;     cin >> N >> P;     vector<long long> l(N), r(N);     for (long long i = 0; i < N; ++i) cin >> l[i] >> r[i];     double exp_val = 0;     for (long long i = 0; i < N; ++i) {       long long j = (i + 1) % N;       double tot = (r[i] - l[i] + 1) * (r[j] - l[j] + 1);       double a = floor(((double)r[i]) / P);       double b = ceil(((double)l[i]) / P);       double c = a - b + 1;       double e = floor(((double)r[j]) / P);       double f = ceil(((double)l[j]) / P);       double g = e - f + 1;       double good = (c * (r[j] - l[j] + 1)) + (g * (r[i] - l[i] + 1)) - c * g;       exp_val += good * 2000 / tot;     }     cout << fixed << setprecision(9) << exp_val << endl;     return 0;   }   