func_code_string: #include <bits/stdc++.h>   using namespace std;   const int MAX = 100100;   int n, m;   long long h[MAX], t[MAX];   bool can(int cur, int last, int nxt, long long val) {     if (t[last] >= h[cur]) return val >= t[nxt] - h[cur];     if (t[nxt] <= h[cur]) return val >= h[cur] - t[last];     return val >= min((h[cur] - t[last]) + (t[nxt] - t[last]),                       (t[nxt] - h[cur]) + (t[nxt] - t[last]));   }   bool check(long long val) {     int last = 1;     for (int i = 1; i <= n; ++i) {       int j = last;       while (j <= m && can(i, last, j, val)) ++j;       last = j;     }     return last == m + 1;   }   int main() {     scanf( %d%d , &n, &m);     for (int i = 1; i <= n; ++i) scanf( %I64d , h + i);     for (int i = 1; i <= m; ++i) scanf( %I64d , t + i);     long long low = 0, high = 20000000000LL, mid;     while (low <= high) {       mid = (low + high) >> 1;       if (check(mid))         high = mid - 1;       else         low = mid + 1;     }     printf( %I64d n , high + 1);     return 0;   }   