func_code_string: #include <bits/stdc++.h>   using namespace std;   template <typename T>   T gcd(T m, T n) {     while (n) {       T t = m % n;       m = n;       n = t;     };     return m;   }   template <typename T>   T exgcd(T a, T b, T& sa, T& ta) {     T q, r, sb = 0, tb = 1, sc, tc;     sa = 1, ta = 0;     if (b) do         q = a / b, r = a - q * b, a = b, b = r, sc = sa - q * sb, sa = sb,         sb = sc, tc = ta - q * tb, ta = tb, tb = tc;       while (b);     return a;   }   template <typename T>   T mul_inv(T a, T b) {     T t1 = a, t2 = b, t3;     T v1 = 1, v2 = 0, v3;     T x;     while (t2 != 1)       x = t1 / t2, t3 = t1 - x * t2, v3 = v1 - x * v2, t1 = t2, t2 = t3, v1 = v2,       v2 = v3;     return (v2 + b) % b;   }   template <typename T>   T powmod(T a, T b, T MOD) {     if (b < 0) return 0;     T rv = 1;     while (b) (b % 2) && (rv = (rv * a) % MOD), a = a * a % MOD, b /= 2;     return rv;   }   const int maxn = 2e5 + 7;   int n;   int L;   int a[maxn];   int b[maxn];   vector<int> to_remove[maxn];   vector<int> to_add[maxn];   int dist_tbl[maxn];   bool explored[maxn];   int dis(int x, int y) { return min(abs(x - y), L - abs(x - y)); }   int calc(int k) {     int& r = dist_tbl[k];     if (r >= 0) return r;     r = 0;     for (int i = 0; i < n; i++) r = max(r, dis(a[i], b[(i + k) % n]));     return r;   }   int main(int argc, char* argv[]) {     std::cin.sync_with_stdio(false);     std::cin.tie(nullptr);     cin >> n >> L;     {       clock_t time_start = clock();       clock_t time_end = time_start + CLOCKS_PER_SEC * 0.8;       for (int i = 0; i < n; i++) cin >> a[i];       for (int i = 0; i < n; i++) cin >> b[i];       sort(a, a + n);       sort(b, b + n);       memset(dist_tbl, -1, sizeof(dist_tbl));       memset(explored, 0, sizeof(explored));       map<int, set<int> > values;       for (int i = 0, ij = max(1, n / 64); i < n; i += ij) {         values[calc(i)].insert(i);       }       int explore_values[] = {-4, -2, -1, 1, 2, 4, 0};       while (clock() < time_end && values.size() < n) {         vector<int> toExplore;         int nmin = 64;         for (auto it : values) {           if (it.second.empty()) --nmin;           for (int k : it.second) {             if (--nmin < 0) break;             if (!explored[k]) {               toExplore.push_back(k);               explored[k] = true;             }           }           if (nmin < 0) break;         }         if (toExplore.size() == 0) break;         int new_explore = 0;         for (int k : toExplore) {           values[calc(k)].erase(k);           for (int ei = 0; explore_values[ei]; ei++) {             int k2 = (k + n + explore_values[ei]) % n;             k2 = (k2 + n) % n;             if (dist_tbl[k2] < 0) {               new_explore++;               values[calc(k2)].insert(k2);             }           }         }         if (!new_explore) break;       }       cout << values.begin()->first << endl;     }     return 0;   }   