malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int n, m, a[100005], b[100005];   vector<int> g[100005];   int next_id, from[100005], to[100005];   bitset<1000> tree[4 * 100005], primes;   int lazy[4 * 100005];   void dfs(int u) {     from[u] = next_id++;     b[from[u]] = a[u] % m;     for (int i = 0; i < g[u].size(); i++)       if (from[g[u][i]] == -1) dfs(g[u][i]);     to[u] = next_id;   }   void rot(bitset<1000> &b, int k) {     b = (b << k) | (b >> (m - k));     b ^= (b >> m) << m;   }   void init(int no, int l, int r) {     if (r - l == 1) {       tree[no].set(b[l]);       return;     }     int m = (l + r) / 2;     init(2 * no, l, m);     init(2 * no + 1, m, r);     tree[no] = tree[2 * no] | tree[2 * no + 1];   }   void prop(int no, int l, int r) {     lazy[no] %= m;     if (lazy[no] > 0) {       rot(tree[no], lazy[no]);       if (r - l > 1) {         lazy[2 * no] += lazy[no];         lazy[2 * no + 1] += lazy[no];       }       lazy[no] = 0;     }   }   void update(int no, int l, int r, int a, int b, int x) {     if (a <= l && r <= b) {       lazy[no] += x;       return;     }     prop(no, l, r);     int m = (l + r) / 2;     if (a < m) update(2 * no, l, m, a, b, x);     if (m < b) update(2 * no + 1, m, r, a, b, x);     prop(2 * no, l, m);     prop(2 * no + 1, m, r);     tree[no] = tree[2 * no] | tree[2 * no + 1];   }   bitset<1000> query(int no, int l, int r, int a, int b) {     prop(no, l, r);     if (a <= l && r <= b) return tree[no];     int m = (l + r) / 2;     bitset<1000> ret;     if (a < m) ret = query(2 * no, l, m, a, b);     if (m < b) ret |= query(2 * no + 1, m, r, a, b);     return ret;   }   int main() {     scanf( %d %d , &n, &m);     for (int i = 0; i < n; i++) scanf( %d , &a[i]);     for (int i = 1; i < n; i++) {       int u, v;       scanf( %d %d , &u, &v);       u--, v--;       g[u].push_back(v);       g[v].push_back(u);     }     memset(from, -1, sizeof(from));     next_id = 0;     dfs(0);     memset(lazy, 0, sizeof(lazy));     init(1, 0, n);     primes[2].flip();     for (int i = 3; i < m; i += 2) primes.set(i);     for (int i = 3; i * i < m; i += 2)       if (primes[i])         for (int j = i * i; j < m; j += i) primes.reset(j);     int q, op, v, x;     scanf( %d , &q);     while (q--) {       scanf( %d %d , &op, &v);       v--;       if (op == 1) {         scanf( %d , &x);         update(1, 0, n, from[v], to[v], x % m);       } else {         bitset<1000> bs = query(1, 0, n, from[v], to[v]) & primes;         printf( %d n , (int)bs.count());       }     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t > 0) {       int x, m, n;       cin >> x;       m = x / 7;       n = x % 7;       if (n == 0)         cout << m << endl;       else         cout << m + 1 << endl;       t--;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, u, v;   vector<int> g[100005], gr[100005];   vector<int> order;   bool used[100005];   int G[100005], C[100005], k = 0;   void dfs1(int x) {     used[x] = 1;     for (int(i) = (0); (i) < (g[x].size()); (i)++) {       int nn = g[x][i];       if (!used[nn]) dfs1(nn);     }     order.push_back(x);   }   int dfs2(int x) {     used[x] = 1;     G[x] = k;     int ans = 1, nn;     for (int(i) = (0); (i) < (gr[x].size()); (i)++) {       nn = gr[x][i];       if (!used[nn]) ans += dfs2(nn);     }     return ans;   }   int dfs3(int x) {     used[x] = 1;     int ans = (C[G[x]] == 1), nn;     for (int(i) = (0); (i) < (g[x].size()); (i)++) {       nn = g[x][i];       if (!used[nn]) ans &= dfs3(nn);     }     for (int(i) = (0); (i) < (gr[x].size()); (i)++) {       nn = gr[x][i];       if (!used[nn]) ans &= dfs3(nn);     }     return ans;   }   int main() {     scanf( %d%d , &(n), &(m));     for (int(i) = (0); (i) < (m); (i)++) {       scanf( %d%d , &(u), &(v));       g[u].push_back(v);       gr[v].push_back(u);     }     for (int i = 1; i <= n; i++)       if (!used[i]) dfs1(i);     reverse(order.begin(), order.end());     memset((used), (0), sizeof(used));     for (int(i) = (0); (i) < (n); (i)++)       if (!used[order[i]]) {         C[k] = dfs2(order[i]);         k++;       }     memset((used), (0), sizeof(used));     int ans = n;     for (int i = 0; i < n; i++)       if (!used[order[i]]) ans -= dfs3(order[i]);     printf( %d n , ans);   }
#include <bits/stdc++.h>   int ways[37 * 2 + 1][37 * 2 + 1], k;   void init() {     int i, j;     ways[0][0] = 1;     for (i = 0; i <= k * 2; i++)       for (j = 0; j <= k * 2; j++)         ways[i][j] =             i == 0 || j == 0 ? 1 : (ways[i - 1][j] + ways[i][j - 1]) % 998244353;   }   int oo[1 + (4000 - 1) * 4], oj[1 + (4000 - 1) * 4];   int link(int o, int j) {     static int _ = 1;     oo[_] = o, oj[_] = j;     return _++;   }   int *ae, *xx, dp[4000][37 + 1], dq[4000][37 + 1];   void dfs(int p, int i) {     int o, l, c;     memset(dq[i], 0, (k + 1) * sizeof *dq[i]);     for (o = ae[i]; o; o = oo[o]) {       int j = oj[o];       if (j != p) {         dfs(i, j);         for (l = 0; l <= k; l++) dq[i][l] = (dq[i][l] + dp[j][l]) % 998244353;       }     }     xx[0] = (xx[0] + 1) % 998244353;     memset(dp[i], 0, (k + 1) * sizeof *dp[i]), dp[i][0] = 1;     for (l = 1; l <= k; l++)       for (c = 1; c <= l; c++) {         int x = (long long)dq[i][c - 1] * dp[i][l - c] % 998244353;         dp[i][l] = (dp[i][l] + x) % 998244353;         xx[l] = (xx[l] + (long long)x * c * 2) % 998244353;       }   }   int main() {     static int ae1[4000], xx1[37 + 1], ae2[4000], xx2[37 + 1];     int n1, n2, h, i, j, l, ans;     scanf( %d%d%d , &n1, &n2, &k);     if (k % 2 != 0) {       printf( 0 n );       return 0;     }     k /= 2;     init();     for (h = 0; h < n1 - 1; h++) {       scanf( %d%d , &i, &j), i--, j--;       ae1[i] = link(ae1[i], j), ae1[j] = link(ae1[j], i);     }     for (h = 0; h < n2 - 1; h++) {       scanf( %d%d , &i, &j), i--, j--;       ae2[i] = link(ae2[i], j), ae2[j] = link(ae2[j], i);     }     ae = ae1, xx = xx1, dfs(-1, 0);     ae = ae2, xx = xx2, dfs(-1, 0);     ans = 0;     for (l = 0; l <= k; l++) {       assert(xx1[l] > 0);       ans = (ans + (long long)xx1[l] * xx2[k - l] % 998244353 *                        ways[l * 2][(k - l) * 2]) %             998244353;     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int a[100001], b[100001];     int n, i, x, y;     cin >> n;     for (i = 0; i < n; i++) {       cin >> a[i];       b[i] = a[i];     }     sort(b, b + n);     x = 0;     while (a[x] == b[x] && x < n - 1) {       x++;     }     y = n - 1;     while (a[y] == b[y] && y > 0) {       y--;     }     if (x > y) {       x = 0;       y = 0;     }     for (i = 0; i <= (y - x) / 2; i++) {       swap(a[x + i], a[y - i]);     }     for (i = 0; i < n; i++)       if (a[i] != b[i]) {         i = n + 10;       }     if (i < n + 10) {       cout <<  yes  << endl;       cout << x + 1 <<     << y + 1;     } else {       cout <<  no  << endl;     }   }
#include <bits/stdc++.h>   using int64 = long long;   constexpr int Maxn = 200000;   constexpr int p = 1000000007;   template <class _Tp1, class _Tp2>   inline void inc(_Tp1& x, const _Tp2& y) {     x += y;     (p <= x) && (x -= p);   }   template <class _Tp1, class _Tp2>   inline void dec(_Tp1& x, const _Tp2& y) {     x -= y;     (x < 0) && (x += p);   }   template <class _Tp>   inline int md(const _Tp& v) {     return v < 0 ? ((0 <= p + v) ? (p + v) : (v % p + p)) : (v < p) ? v : (v % p);   }   namespace IOManager {   constexpr int FILESZ(131072);   unsigned char buf[FILESZ];   const unsigned char *ibuf = buf, *tbuf = buf;   struct IOManager {     inline unsigned char gc() {       return (ibuf == tbuf) &&                      (tbuf = (ibuf = buf) + fread(buf, 1, FILESZ, stdin),                       ibuf == tbuf)                  ? EOF                  : *ibuf++;     }     template <class _Tp>     inline operator _Tp() {       _Tp s = 0u;       unsigned char c = gc(), w = 0;       for (; c < 48; c = gc()) (c == 45) && (w = 1);       for (; c > 47; c = gc()) s = (_Tp)(s * 10u + c - 48u);       return w ? -s : s;     }   };   }  // namespace IOManager   IOManager::IOManager io;   const int n = io;   int64 bit[Maxn + 1];   inline void update(const int& x, const int& d) {     for (int i = x; i <= n; i += i & -i) bit[i] += d;   }   inline int64 sum(const int& x) {     int64 s = 0;     for (int i = x; i; i -= i & -i) s += bit[i];     return s;   }   int bitp[Maxn + 1];   inline void updatep(const int& x, const int& d) {     for (int i = x; i <= n; i += i & -i) inc(bitp[i], d);   }   inline int sump(const int& x) {     int64 s = 0;     for (int i = x; i; i -= i & -i) s += bitp[i];     return s % p;   }   int a[Maxn + 1], w[Maxn + 1];   int main() {     int q = io;     for (int i = 1; i <= n; ++i) a[i] = (int)io - i;     for (int i = 1; i <= n; ++i)       w[i] = io, update(i, w[i]), updatep(i, (int64)w[i] * a[i] % p);     int64 sl, sm, sr;     for (int x, y, l, m, r; q; --q)       if (x = io, y = io, x < 0) {         int d = y - w[x = -x];         w[x] = y;         update(x, d);         updatep(x, md((int64)d * a[x]));       } else {         l = x;         r = y;         sl = sum(l - 1);         sr = sum(r) - sl;         for (; l < r;)           ((sum(m = (l + r) >> 1) - sl) * 2 < sr) ? (l = m + 1) : (r = m);         sm = sum(m = l);         sr += sl;         printf( %d n , md((int64)(sump(y) - sump(m) * 2ll +                                   (int64)(sm - sr + sm - sl) % p * a[m] % p +                                   sump(x - 1))));       }     return 0;   }
#include <bits/stdc++.h>   const int INF = 0x3f3f3f3f;   const int MAXN = 1e3 + 10;   using namespace std;   char str[MAXN][MAXN];   int data[MAXN];   int main() {     int n, m;     cin >> n >> m;     for (int i = 0; i < n; i++) cin >> str[i];     for (int i = 0; i < m; i++) cin >> data[i];     long long ans = 0;     for (int i = 0; i < m; i++) {       int temp[10] = {0}, tmp = -1;       for (int j = 0; j < n; j++) temp[str[j][i] -  A ]++;       for (int j = 0; j < 5; j++) tmp = max(tmp, temp[j]);       ans += (long long)tmp * data[i];     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long ans = 0;   void solve1(vector<int> &ar, bool yeah) {     int sz = ar.size();     int mid = sz / 2 + yeah * (sz % 2) - 1;     int L = mid;     int minL = ar[mid];     int maxL = ar[mid];     int minR = (1 << 30);     int maxR = 0;     for (int R = mid + 1; R < sz; ++R) {       minR = min(minR, ar[R]);       maxR = max(maxR, ar[R]);       while (L > 0 && ar[L - 1] < maxR && ar[L - 1] > minR) {         minL = min(minL, ar[L - 1]);         maxL = max(maxL, ar[--L]);       }       if (maxR > maxL && minR < minL) ans += (L <= (R - maxR + minR));     }   }   void solve2(vector<int> ar, bool yeah) {     int sz = ar.size();     int mid = sz / 2 + yeah * (sz % 2) - 1;     int L = mid;     int minL = ar[mid];     int maxL = ar[mid];     int minR = (1 << 30);     int maxR = 0;     map<int, int> m;     m[minL - L]++;     int dL = L;     for (int R = mid + 1; R < sz; ++R) {       minR = min(minR, ar[R]);       maxR = max(maxR, ar[R]);       while (L > 0 && ar[L - 1] < maxR) {         minL = min(minL, ar[L - 1]);         maxL = max(maxL, ar[--L]);         ar[L] = minL;         m[ar[L] - L]++;       }       while (dL >= L && ar[dL] > minR) {         m[ar[dL] - dL]--;         --dL;       }       if (maxR > maxL) {         ans += m[maxR - R];         int pmr = 0;       }     }   }   int ar[300005];   void go(int a, int b) {     if (a == b) {       ans++;       return;     }     vector<int> V;     for (int i = a; i <= b; ++i) V.push_back(ar[i]);     solve1(V, 1);     reverse(V.begin(), V.end());     solve1(V, 0);     reverse(V.begin(), V.end());     solve2(V, 1);     reverse(V.begin(), V.end());     solve2(V, 0);     go(a, (a + b) / 2);     go((a + b) / 2 + 1, b);   }   int main() {     int n;     scanf( %d , &n);     for (int i = 1; i <= n; ++i) {       int a, b;       scanf( %d%d , &a, &b);       ar[a] = b;     }     go(1, n);     cout << ans << endl;   }
#include <bits/stdc++.h>   char data[41][41];   int t[41][41][41][41];   int chk[41][41][41][41];   int main() {     int a, b, c, d, i, j, k, l, p, q, sum = 0;     scanf( %d %d %d , &a, &b, &q);     for (i = 0; i < a; ++i) {       scanf( %s , data[i]);       for (j = 0; j < b; ++j) {         if (data[i][j] ==  0 ) {           chk[i][j][i][j] = 1;           for (k = i; k >= 0; --k) {             for (l = j; l >= 0; --l) {               if (l == j && k == i)                 t[k][l][i][j] = chk[k][l][i][j];               else if (l == j) {                 chk[k][l][i][j] = ( 1  - data[k][l]) && (chk[k + 1][l][i][j]);                 t[k][l][i][j] = t[k + 1][l][i][j] + chk[k][l][i][j];               } else if (k == i) {                 chk[k][l][i][j] = ( 1  - data[k][l]) && (chk[k][l + 1][i][j]);                 t[k][l][i][j] = t[k][l + 1][i][j] + chk[k][l][i][j];               } else {                 chk[k][l][i][j] = ( 1  - data[k][l]) && (chk[k + 1][l][i][j]) &&                                   (chk[k][l + 1][i][j]);                 t[k][l][i][j] = t[k + 1][l][i][j] + t[k][l + 1][i][j] -                                 t[k + 1][l + 1][i][j] + chk[k][l][i][j];               }             }           }         }       }     }     for (p = 0; p < q; ++p) {       scanf( %d %d %d %d , &a, &b, &c, &d);       for (i = a - 1; i <= c - 1; ++i) {         for (j = b - 1; j <= d - 1; ++j) {           sum += t[a - 1][b - 1][i][j];         }       }       printf( %d n , sum);       sum = 0;     }   }
#include <bits/stdc++.h>   using namespace std;   long long ax, ay, bx, by, cx, cy, flag = 0;   long long f(long long x1, long long y1, long long x2, long long y2) {     long long res = (x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1);     return res;   }   bool isColinear() {     long long res1 = (by - ay) * (cx - bx);     long long res2 = (cy - by) * (bx - ax);     if (res1 == res2)       return true;     else       return false;   }   int main() {     cin >> ax >> ay >> bx >> by >> cx >> cy;     if (isColinear() == true)       flag = 0;     else {       long long dis1 = f(ax, ay, bx, by);       long long dis2 = f(bx, by, cx, cy);       if (dis1 == dis2)         flag = 1;       else         flag = 0;     }     if (flag == 1)       printf( Yes n );     else       printf( No n );   }
#include <bits/stdc++.h>   using namespace std;   const long long INF = LLONG_MAX / 2;   int extractMin(set<int> &mySet) {     set<int>::iterator it = mySet.begin();     int ans = *(it);     mySet.erase(it);     return ans;   }   int search(set<int> &mySet, int index) {     set<int>::iterator it = mySet.lower_bound(index);     if (it == mySet.end()) {       return -1;     }     int ans = *(it);     return ans;   }   void eliminate(set<int> &mySet, int index) {     set<int>::iterator it = mySet.lower_bound(index);     if (it == mySet.end()) {       assert(false);     }     mySet.erase(it);   }   void notFound() { cout << -1 <<   n ; }   void impr(vector<vector<int> > ans) {     printf( %d n , ((int)(ans).size()));     for (int i = 0; i < ((int)(ans).size()); i++) {       printf( %d , ((int)(ans[i]).size()));       for (int j = 0; j < ((int)(ans[i]).size()); j++) {         printf(  %d , ans[i][j] + 1);       }       puts(  );     }   }   void solve(string str) {     int n = ((int)(str).size());     set<int> zeroes, ones;     for (int i = 0; i < n; i++) {       if (str[i] ==  0 ) {         zeroes.insert(i);       } else {         ones.insert(i);       }     }     vector<vector<int> > ans;     while (true) {       if (zeroes.empty() && ones.empty()) {         break;       }       if (zeroes.empty()) {         notFound();         return;       }       int curZero = extractMin(zeroes);       vector<int> seq(1, curZero);       while (true) {         int curOne = search(ones, curZero + 1);         curZero = search(zeroes, curOne + 1);         if (curOne == -1 || curZero == -1) {           break;         }         seq.push_back(curOne);         seq.push_back(curZero);         eliminate(ones, curOne);         eliminate(zeroes, curZero);       }       ans.push_back(seq);     }     impr(ans);   }   int main() {     string str;     while (cin >> str) {       solve(str);     }   }
#include <bits/stdc++.h>   using namespace std;   int anc[200007];   int sz[200007];   int x[200005], y[200005];   vector<int> g[200005];   int get_set(int v) {     if (v == anc[v]) {       return v;     }     return anc[v] = get_set(anc[v]);   }   void unite_sets(int u, int v) {     u = get_set(u);     v = get_set(v);     if (u == v) {       return;     }     if (sz[u] < sz[v]) {       swap(u, v);     }     sz[u] = sz[u] + sz[v];     anc[v] = u;   }   int main() {     int n, m;     cin >> n >> m;     for (int i = 0; i < m; i++) {       cin >> x[i] >> y[i];       g[x[i]].push_back(y[i]);       g[y[i]].push_back(x[i]);     }     for (int i = 0; i <= n; i++) {       sz[i] = 1;       anc[i] = i;     }     int mx = 0;     int z = 1;     for (int i = 1; i <= n; i++) {       if (g[i].size() > mx) {         mx = g[i].size();         z = i;       }     }     for (int i = 0; i < g[z].size(); i++) {       if (get_set(z) != get_set(g[z][i])) {         unite_sets(z, g[z][i]);         cout << z <<     << g[z][i] << endl;       }     }     for (int i = 0; i < m; i++) {       if (get_set(x[i]) != get_set(y[i])) {         unite_sets(x[i], y[i]);         cout << x[i] <<     << y[i] << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int n;     cin >> n;     vector<long long> vec(n + 1);     for (int i = 1; i <= n; i++) cin >> vec[i];     vector<long long> a;     for (int i = 1; i < n; i++) {       if (i & 1)         a.push_back(abs(vec[i] - vec[i + 1]));       else         a.push_back(-1 * abs(vec[i] - vec[i + 1]));     }     vector<long long> dp((int)a.size());     dp[0] = a[0];     long long res = dp[0];     for (int i = 1; i < dp.size(); i++) {       dp[i] = max(a[i], dp[i - 1] + a[i]);       res = max(res, dp[i]);     }     dp.clear();     a.clear();     for (int i = 1; i < n; i++) {       if (!(i & 1))         a.push_back(abs(vec[i] - vec[i + 1]));       else         a.push_back(-1 * abs(vec[i] - vec[i + 1]));     }     dp = vector<long long>((int)a.size());     dp[0] = a[0];     long long res2 = dp[0];     for (int i = 1; i < dp.size(); i++) {       dp[i] = max(a[i], dp[i - 1] + a[i]);       res2 = max(res2, dp[i]);     }     cout << max(res, res2) <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   long long x[100010];   long long y[100010];   long long dispoint(long long x1, long long y1, long long x2, long long y2) {     return (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);   }   bool issame(long long x1, long long y1, long long x2, long long y2,               long long x3, long long y3) {     long long xa = x2 - x1;     long long ya = y2 - y1;     long long xb = x3 - x1;     long long yb = y3 - y1;     if (xa * yb == xb * ya)       return 1;     else       return 0;   }   double disline(long long x1, long long y1, long long x2, long long y2,                  long long x3, long long y3) {     double xa = x1 - x3;     double ya = y1 - y3;     double xb = x2 - x3;     double yb = y2 - y3;     double l = sqrt((xa - xb) * (xa - xb) + (ya - yb) * (ya - yb));     double s = abs(xa * yb - xb * ya);     double h = s / l;     return h;   }   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) scanf( %I64d%I64d , &x[i], &y[i]);     int pos1 = 2;     long long mindis = dispoint(x[1], y[1], x[2], y[2]);     for (int i = 3; i <= n; i++) {       long long tmpdis = dispoint(x[1], y[1], x[i], y[i]);       if (tmpdis < mindis) {         mindis = tmpdis;         pos1 = i;       }     }     int pos2 = 0;     double mindis2 = 1e18;     for (int i = 2; i <= n; i++) {       if (i == pos1) continue;       if (issame(x[1], y[1], x[pos1], y[pos1], x[i], y[i])) continue;       double tmpdis = disline(x[1], y[1], x[pos1], y[pos1], x[i], y[i]);       if (tmpdis < mindis2) {         mindis2 = tmpdis;         pos2 = i;       }     }     printf( 1 %d %d n , pos1, pos2);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     ;     long long t;     cin >> t;     while (t--) {       long long n;       cin >> n;       vector<int> ans;       for (int i = 0; i <= 400; i++) {         for (int j = 0; j <= 200; j++) {           long long x = 3 * i, y = 5 * j;           long long z = n - x - y;           if (z >= 0) {             if (z % 7 == 0) {               z = z / 7;               ans.push_back(x), ans.push_back(y), ans.push_back(7 * z);               break;             }           }         }         if (ans.size() == 3) break;       }       if (ans.size() != 3)         cout << -1 <<   n ;       else         cout << ans[0] / 3 <<     << ans[1] / 5 <<     << ans[2] / 7 <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     std::ios::sync_with_stdio(false);     int T;     cin >> T;     while (T--) {       long long int n;       string second;       cin >> n;       cin >> second;       vector<char> v, v1;       int first = 0;       int f1 = 0;       int f2 = 0;       for (int i = n - 1; i >= 0; i--) {         if (first == 0 && second[i] ==  1 ) {           v.emplace_back(second[i]);         }         if (first == 0 && second[i] ==  0 ) {           v.emplace_back(second[i]);           first = 1;           f1 = i;           break;         }       }       for (int i = 0; i < n; i++) {         if (second[i] ==  0  && i < f1) {           v.emplace_back(second[i]);         }         if (second[i] ==  1 ) {           break;         }       }       reverse(v.begin(), v.end());       for (int i = 0; i < v.size(); i++) {         cout << v[i];       }       cout <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool debug = 0;   int n, m, k;   int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};   string direc =  RDLU ;   long long ln, lk, lm;   void etp(bool f = 0) {     puts(f ?  YES  :  NO );     exit(0);   }   void addmod(int &x, int y, int mod = 1000000007) {     x += y;     if (x >= mod) x -= mod;   }   void et() {     puts( -1 );     exit(0);   }   long long a[100005], b[100005];   bool ck(long long r) {     for (int(i) = 1; (i) <= (int)(n); (i)++) {       long long L = a[i] - r, R = a[i] + r;       int p = upper_bound(b + 1, b + 1 + m, R) - (b + 1);       p--;       int q = lower_bound(b + 1, b + 1 + m, L) - (b + 1);       q--;       if (q >= p) return 0;     }     return 1;   }   void fmain() {     scanf( %d%d , &n, &m);     for (int(i) = 1; (i) <= (int)(n); (i)++) {       scanf( %lld , a + i);     }     for (int(i) = 1; (i) <= (int)(m); (i)++) scanf( %lld , b + i);     long long l = -1, r = 2e9;     while (l + 1 < r) {       long long mid = (l + r) / 2;       if (ck(mid))         r = mid;       else         l = mid;     }     printf( %lld n , r);   }   int main() {     fmain();     return 0;   }