func_code_string: #include <bits/stdc++.h>   using namespace std;   int n, s, e;   long long dp[5005][5005];   vector<int> x, a, b, c, d;   int main() {     cin >> n >> s >> e;     x.resize(n);     a.resize(n);     b.resize(n);     c.resize(n);     d.resize(n);     for (int i = 0; i < n; i++) {       cin >> x[i];     }     for (int i = 0; i < n; i++) {       cin >> a[i];     }     for (int i = 0; i < n; i++) {       cin >> b[i];     }     for (int i = 0; i < n; i++) {       cin >> c[i];     }     for (int i = 0; i < n; i++) {       cin >> d[i];     }     memset(dp, 0x3f, sizeof(dp));     dp[0][0] = 0;     bool iss = 0, ise = 0;     for (int i = 0; i < n; i++) {       if (i == s - 1) {         iss = 1;       }       if (i == e - 1) {         ise = 1;       }       if (i == n - 1) {         long long p = dp[i][0];         if (i == s - 1) {           dp[i + 1][0] = min(dp[i + 1][0], p + x[i] + c[i]);         } else if (i == e - 1) {           dp[i + 1][0] = min(dp[i + 1][0], p + x[i] + a[i]);         } else {           dp[i + 1][0] = min(dp[i + 1][0], p + 2 * x[i] + a[i] + c[i]);         }         continue;       }       for (int j = 0; j <= n - 2; j++) {         long long p = dp[i][j];         if (i == s - 1) {           dp[i + 1][j] = min(dp[i + 1][j], p - x[i] + d[i]);           if (j) dp[i + 1][j - 1] = min(dp[i + 1][j - 1], p + x[i] + c[i]);         } else if (i == e - 1) {           dp[i + 1][j] = min(dp[i + 1][j], p - x[i] + b[i]);           if (j) dp[i + 1][j - 1] = min(dp[i + 1][j - 1], p + x[i] + a[i]);         } else {           dp[i + 1][j + 1] = min(dp[i + 1][j + 1], p - 2 * x[i] + b[i] + d[i]);           if (j) {             dp[i + 1][j] = min(dp[i + 1][j], p - x[i] + b[i] + x[i] + c[i]);             dp[i + 1][j] = min(dp[i + 1][j], p + x[i] + a[i] - x[i] + d[i]);           }           if (iss) {             dp[i + 1][j] = min(dp[i + 1][j], p + x[i] + a[i] - x[i] + d[i]);           }           if (ise) {             dp[i + 1][j] = min(dp[i + 1][j], p - x[i] + b[i] + x[i] + c[i]);           }           if (j + iss + ise > 1) {             dp[i + 1][j - 1] =                 min(dp[i + 1][j - 1], p + x[i] + a[i] + x[i] + c[i]);           }         }       }     }     cout << dp[n][0] << endl;     return 0;   }   