func_code_string: #include <bits/stdc++.h>   using namespace std;   const int maxn = 100007;   int n, m;   long long h[maxn], p[maxn];   bool check(long long time) {     int x = 1, old_x;     for (int i = 1, _c = n; i <= _c; i++) {       if (x > m) return 1;       if (p[x] <= h[i]) {         if (h[i] - p[x] > time) return 0;         old_x = x;         while (x <= m && h[i] >= p[x]) x++;         if (old_x != x) {           while (x <= m &&                  p[x] - p[old_x] + min(p[x] - h[i], h[i] - p[old_x]) <= time)             x++;         }       } else {         while (x <= m && p[x] - h[i] <= time) x++;       }     }     return (x > m);   }   int main() {     scanf( %d%d , &n, &m);     for (int i = 1, _c = n; i <= _c; i++) scanf( %I64d , &h[i]);     for (int i = 1, _c = m; i <= _c; i++) scanf( %I64d , &p[i]);     long long l, r, mid, res;     r = res = 20000000000ll;     l = 0;     while (l <= r) {       mid = (l + r) / 2;       if (check(mid)) {         res = mid;         r = mid - 1;       } else         l = mid + 1;     }     cout << res << endl;     return 0;   }   