func_code_string: #include <bits/stdc++.h>   using namespace std;   const int INF = 0x3f3f3f3f, N = 2e5 + 5;   const long long inf = 1e18;   inline int read() {     int sum = 0, f = 1;     char c = getchar();     while (c >  9  || c <  0 ) {       if (c ==  - ) f = -f;       c = getchar();     }     while (c >=  0  && c <=  9 ) sum = sum * 10 + c - 48, c = getchar();     return sum * f;   }   int n, m, k, q, t[N][2], safe[N];   long long dp[N][2];   long long cost(int a, int b, int c, int d) {     int pos = lower_bound(safe + 1, safe + q + 1, t[a][b]) - safe;     long long ans = inf;     if (pos <= q)       ans = abs(t[a][b] - safe[pos]) + abs(t[c][d ^ 1] - safe[pos]) +             abs(t[c][d] - t[c][d ^ 1]);     pos = upper_bound(safe + 1, safe + q + 1, t[a][b]) - safe - 1;     if (pos >= 1)       ans =           min(ans, (long long)abs(t[a][b] - safe[pos]) +                        abs(t[c][d ^ 1] - safe[pos]) + abs(t[c][d] - t[c][d ^ 1]));     return ans;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cin >> n >> m >> k >> q;     for (int i = 1; i <= k; i++) {       int r, c;       cin >> r >> c;       if (t[r][0] == 0)         t[r][0] = c;       else         t[r][0] = min(t[r][0], c);       t[r][1] = max(t[r][1], c);     }     t[1][0] = 1, t[1][1] = max(t[1][1], 1);     for (int i = 1; i <= q; i++) cin >> safe[i];     sort(safe + 1, safe + q + 1);     for (int i = 2; i <= n; i++) dp[i][0] = dp[i][1] = inf;     dp[1][0] = abs(t[1][1] - 1) * 2;     dp[1][1] = abs(t[1][1] - 1);     int pre = 1;     for (int i = 2; i <= n; i++) {       if (t[i][0] == 0) continue;       for (int j = 0; j < 2; j++) {         for (int k = 0; k < 2; k++) {           dp[i][j] = min(dp[i][j], dp[pre][k] + i - pre + cost(pre, k, i, j));         }       }       pre = i;     }     long long ans = min(dp[pre][0], dp[pre][1]);     cout << ans <<   n ;     return 0;   }   