func_code_string: #include <bits/stdc++.h>   using namespace std;   int n, s, e;   long long x[5001];   long long a[5001];   long long b[5001];   long long c[5001];   long long d[5001];   long long pd[5001][5001];   long long func(int at, int comp, int left, int right) {     if (comp <= 0 && at != 0) return 0x3f3f3f3f3f3f3f3fll;     if (at == n) return ((comp == 1) ? 0 : 0x3f3f3f3f3f3f3f3fll);     if (pd[at][comp] != -1) return pd[at][comp];     long long ans = 0x3f3f3f3f3f3f3f3fll;     int onlycomp = (comp - left - right);     if (at != s && at != e) {       ans = func(at + 1, comp + 1, left, right) - 2 * x[at] + d[at] + b[at];       if (left) {         ans = min(ans, func(at + 1, comp, left, right) + a[at] + d[at]);         if (onlycomp)           ans = min(ans, func(at + 1, comp - 1, left, right) + a[at] + c[at] +                              2 * x[at]);       }       if (right) {         ans = min(ans, func(at + 1, comp, left, right) + c[at] + b[at]);         if (onlycomp)           ans = min(ans, func(at + 1, comp - 1, left, right) + c[at] + a[at] +                              2 * x[at]);       }       if (onlycomp) {         ans = min(             ans, func(at + 1, comp - 1, left, right) + c[at] + a[at] + 2 * x[at]);         ans = min(ans, func(at + 1, comp, left, right) + b[at] + c[at]);         ans = min(ans, func(at + 1, comp, left, right) + a[at] + d[at]);       }       if (at == n - 1 && comp == 2)         ans = min(             ans, func(at + 1, comp - 1, left, right) + c[at] + a[at] + 2 * x[at]);     } else if (at == s) {       ans = func(at + 1, comp + 1, 1, right) - x[at] + d[at];       if (onlycomp) ans = min(ans, func(at + 1, comp, 1, right) + x[at] + c[at]);       if (at == n - 1 && comp == 1)         ans = min(ans, func(at + 1, comp, 1, right) + c[at] + x[at]);     } else {       ans = func(at + 1, comp + 1, left, 1) - x[at] + b[at];       if (onlycomp) ans = min(ans, func(at + 1, comp, left, 1) + x[at] + a[at]);       if (at == n - 1 && comp == 1)         ans = min(ans, func(at + 1, comp, left, 1) + a[at] + x[at]);     }     return pd[at][comp] = ans;   }   int main() {     scanf( %d %d %d , &n, &s, &e);     s--;     e--;     for (int i = 0; i < n; i++) scanf( %lld , &x[i]);     for (int i = 0; i < n; i++) scanf( %lld , &a[i]);     for (int i = 0; i < n; i++) scanf( %lld , &b[i]);     for (int i = 0; i < n; i++) scanf( %lld , &c[i]);     for (int i = 0; i < n; i++) scanf( %lld , &d[i]);     memset(pd, -1, sizeof pd);     printf( %lld n , func(0, 0, 0, 0));     return 0;   }   