func_code_string: #include <bits/stdc++.h>   #pragma comment(linker,  /STACK:1024000000,1024000000 )   using namespace std;   const int maxn = 1e5 + 7;   int n, m;   long long h[maxn], p[maxn];   bool ok(long long x) {     long long cnt = 0;     for (int i = 0; i < n; i++) {       if (p[cnt] >= h[i]) {         for (int j = cnt; j < m; j++) {           if (h[i] + x >= p[j])             cnt++;           else             break;         }       } else {         if (h[i] - p[cnt] > x) continue;         long long t = max(x - (h[i] - p[cnt]) * 2, (x - (h[i] - p[cnt])) / 2);         for (int j = cnt; j < m; j++) {           if (h[i] + t >= p[j])             cnt++;           else             break;         }       }     }     if (cnt >= m)       return true;     else       return false;   }   int main() {     cin >> n >> m;     for (int i = 0; i < n; i++) cin >> h[i];     for (int i = 0; i < m; i++) cin >> p[i];     long long l = 0, r = 100000000000 + 7;     ;     while (l + 1 < r) {       long long m = (l + r) >> 1;       if (ok(m))         r = m;       else         l = m;     }     if (ok(l)) r = l;     cout << r << endl;     return 0;   }   