func_code_string: #include <bits/stdc++.h>   #pragma comment(linker,  /STACK:100000000 )   using namespace std;   const long double pi = acos(-1.0);   const long long inf = (long long)1e18;   const int N = (int)1e6;   int n, m;   long long need[N], start[N];   bool check(long long x) {     int lowest = 0;     for (int i = 0; (i < n) && (lowest < m); ++i) {       long long pos = start[i], can = x;       if (need[lowest] <= pos) {         if (pos - need[lowest] > can)           return false;         else           can = max(can - 2 * (pos - need[lowest]),                     (can - (pos - need[lowest])) / 2);       }       while ((lowest < m) && (need[lowest] - pos <= can)) ++lowest;     }     return (lowest == m);   }   int main() {     scanf( %d%d , &n, &m);     for (int i = 0; i < n; ++i) scanf( %I64d , &start[i]);     for (int i = 0; i < m; ++i) scanf( %I64d , &need[i]);     if (check(0)) {       printf( 0 n );       return 0;     }     long long l = 0, r = inf;     while (l < r - 1) {       long long m = (l + r) / 2;       if (check(m))         r = m;       else         l = m;     }     printf( %I64d n , r);     return 0;   }   