func_code_string: #include <bits/stdc++.h>   using namespace std;   int n, h;   double p;   double memexpected[2001][2001][2][2];   int calculado[2001][2001][2][2];   int ri[2001], le[2001];   int v[2001];   double expected(int i1, int i2, int l1, int l2) {     if (i1 > i2) return 0;     double &mem = memexpected[i1][i2][l1][l2];     if (calculado[i1][i2][l1][l2]) return mem;     calculado[i1][i2][l1][l2] = 1;     mem = 0;     int distle = h;     if (i1 > 0)       distle =           (l1 == 0) ? min(v[i1] - v[i1 - 1], h) : min(v[i1] - (v[i1 - 1] + h), h);     int distri = h;     if (i2 < n - 1)       distri =           (l2 == 1) ? min(v[i2 + 1] - v[i2], h) : min(v[i2 + 1] - h - v[i2], h);     int RI = min(ri[i1], i2);     int lenri = min(v[RI] + h - v[i1], v[i2] - v[i1] + distri);     int LE = max(le[i2], i1);     int lenle = min(v[i2] - v[LE] + h, v[i2] - v[i1] + distle);     double mem1 = 0.5 * (p * (distle + expected(i1 + 1, i2, 0, l2)) +                          (1 - p) * (lenri + expected(RI + 1, i2, 1, l2)));     double mem2 = 0.5 * ((1 - p) * (distri + expected(i1, i2 - 1, l1, 1)) +                          p * (lenle + expected(i1, LE - 1, l1, 0)));     mem = mem1 + mem2;     return mem;   }   int main() {     cout.setf(ios::fixed);     cout.precision(10);     cin >> n >> h >> p;     for (int i = 0; i < n; i++) cin >> v[i];     sort(v, v + n);     le[0] = 0;     for (int i = 1; i < n; i++) le[i] = (v[i] - v[i - 1] < h) ? le[i - 1] : i;     ri[n - 1] = n - 1;     for (int i = n - 2; i >= 0; i--)       ri[i] = (v[i + 1] - v[i] < h) ? ri[i + 1] : i;     cout << expected(0, n - 1, 0, 1) << endl;   }   