malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int L;   int a[100005], n;   int Min[100005 << 2], sub[100005 << 2];   vector<pair<int, int> > ans;   void PushUp(int rt) { Min[rt] = min(Min[rt << 1], Min[rt << 1 | 1]); }   void PushDown(int rt) {     if (sub[rt]) {       sub[rt << 1] += sub[rt];       sub[rt << 1 | 1] += sub[rt];       Min[rt << 1] -= sub[rt];       Min[rt << 1 | 1] -= sub[rt];       sub[rt] = 0;     }   }   void Build(int l, int r, int rt) {     int m;     if (l == r) {       Min[rt] = a[l];       return;     }     m = (l + r) >> 1;     Build(l, m, rt << 1);     Build(m + 1, r, rt << 1 | 1);     PushUp(rt);   }   void Update(int L, int R, int x, int l, int r, int rt) {     int m;     if (L <= l && R >= r) {       sub[rt] += x;       Min[rt] -= x;       return;     }     m = (l + r) >> 1;     PushDown(rt);     if (L <= m) Update(L, R, x, l, m, rt << 1);     if (R > m) Update(L, R, x, m + 1, r, rt << 1 | 1);     PushUp(rt);   }   int Query(int L, int R, int l, int r, int rt) {     int ans = 1 << 30, m;     if (L <= l && R >= r) return Min[rt];     m = (l + r) >> 1;     PushDown(rt);     if (L <= m) ans = min(ans, Query(L, R, l, m, rt << 1));     if (R > m) ans = min(ans, Query(L, R, m + 1, r, rt << 1 | 1));     PushUp(rt);     return ans;   }   pair<int, int> bin() {     while (L <= n && Query(L, L, 1, n, 1) == 0) L++;     if (L == n + 1) return pair<int, int>(n + 1, 0);     int R, l = L, r = n, m;     while (l <= r) {       m = (l + r) >> 1;       if (Query(L, m, 1, n, 1) == 0)         r = m - 1;       else         l = m + 1;     }     R = r;     return pair<int, int>(L, R);   }   int main() {     int i, minv, l, r;     while (scanf( %d , &n) != EOF && n) {       L = 1;       (ans).clear();       for (i = 1; i <= n; i++) scanf( %d , &a[i]);       Build(1, n, 1);       while (1) {         pair<int, int> now = bin();         l = now.first, r = now.second;         if (l == n + 1) break;         ans.push_back(pair<int, int>(l, r));         Update(l, r, 1, 1, n, 1);       }       printf( %d n , ((int)(ans).size()));       for (i = 0; i < ((int)(ans).size()); i++)         printf( %d %d n , ans[i].first, ans[i].second);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char s[10];   int n, h;   double tw[100];   int main() {     cin >> s >> n >> h;     if (s[0] ==  B ) {       printf( %d n , n);       return 0;     }     tw[0] = 1;     for (int i = 1; i <= 2 * h; i++) tw[i] = tw[i - 1] * 2.0;     double r = n;     for (int i = 1; i <= h; i++)       for (int j = 1; j <= n; j++)         r += ((double)n - (double)j) * (1 / tw[2 * i]) *              pow(1 - 1 / tw[i], j - 1) *              (tw[i] - tw[i - 1] * (1 + (j - 1) / (tw[i] - 1)));     printf( %.9lf n , r);   }
#include <bits/stdc++.h>   using namespace std;   const int c = 200002;   int n, m, maxi, pos = c, cnt, id[c], szint[c], kezd;   vector<int> sz[c];   bool v[c], v2[c], jo[c];   void dfs2(int a) {     v2[a] = true;     bool s = jo[a];     for (int x : sz[a]) {       if (!v2[x]) {         dfs2(x);         if (jo[x]) {           s = 1;         }       }     }     jo[a] = s;     cnt += jo[a] * 2;   }   void dfs(int a) {     if (!jo[a]) {       return;     }     v[a] = true;     int x1 = a, x2 = a;     for (int x : sz[a]) {       if (!v[x]) {         szint[x] = szint[a] + 1;         dfs(x);         int aa = szint[x1], bb = szint[x2], cc = szint[id[x]];         if (cc > bb || (cc == bb && id[x] < x2)) {           x2 = id[x];           if (cc > aa || (cc == aa && id[x] < x1)) {             swap(x1, x2);           }         }       }     }     id[a] = x1;     int s = szint[x1] + szint[x2] - 2 * szint[a];     if (s > maxi || (s == maxi && min(x1, x2) < pos)) {       maxi = s;       pos = min(x1, x2);     }   }   int main() {     ios_base::sync_with_stdio(false);     cin >> n >> m;     for (int i = 1; i < n; i++) {       int a, b;       cin >> a >> b;       sz[a].push_back(b), sz[b].push_back(a);     }     for (int i = 1; i <= m; i++) {       int x;       cin >> x;       kezd = x;       jo[x] = 1;     }     dfs2(kezd), cnt -= 2;     szint[kezd] = 1, dfs(kezd);     cout << pos <<   n  << cnt - maxi <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     ;     long long int ans = 1000000000000, n, m, i, d, j, a, fo = 0;     vector<long long int> v;     set<long long int> mset;     cin >> n >> m >> d;     for (i = 0; i < n; i++) {       for (j = 0; j < m; j++) {         cin >> a;         mset.insert(a);         v.emplace_back(a);       }     }     sort(v.begin(), v.end());     for (auto x : mset) {       long long int counter = 0;       for (j = 0; j < v.size(); j++) {         a = abs(x - v[j]);         if (a % d != 0 || counter >= ans) {           counter = 1000000000000;           break;         }         counter += (a / d);       }       if (ans > counter) {         ans = counter;       }     }     if (ans == 1000000000000)       cout <<  -1  << endl;     else       cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 110005;   long long arr[maxn], arr1[maxn], n, m;   int judge(long long x) {     memcpy(arr1, arr, sizeof(arr));     long long i = n, countt = 1, t = 0;     while (i >= 1 && arr1[i] <= 0) --i;     while (countt <= m) {       t = x - i;       while (t > 0) {         if (t >= arr1[i]) {           t = t - arr1[i];           arr1[i] = 0;           i--;           if (i < 1) return 1;         } else {           arr1[i] = arr1[i] - t;           t = 0;         }       }       ++countt;     }     return 0;   }   long long aa(long long x) {     long long i = n, temp;     while (i >= 1 && arr[i] <= 0) --i;     temp = arr[i];     int countt = 1;     while (countt <= m) {       long long t = x - i;       while (t > 0) {         if (t >= temp) {           t -= temp;           i--;           while (i >= 1 && arr[i] <= 0) --i;           if (i < 1) return 1;           temp = arr[i];         } else {           temp -= t;           break;         }       }       countt++;     }     return 0;   }   int main() {     long long left, right, ans, mid;     scanf( %lld%lld , &n, &m);     left = 0;     right = 1e18;     ans = 0;     for (int i = 1; i <= n; i++) {       scanf( %lld , &arr[i]);     }     while (left <= right) {       mid = (left + right) / 2;       if (aa(mid)) {         ans = mid;         right = mid - 1;       } else {         left = mid + 1;       }     }     printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 3e5;   int n, u, v, tp;   int par[2][N], sz[2][N];   long long ans;   int find_set(int v) {     if (par[tp][v] == v) return v;     return par[tp][v] = find_set(par[tp][v]);   }   void union_sets(int a, int b) {     a = find_set(a);     b = find_set(b);     if (sz[tp][a] < sz[tp][b]) swap(a, b);     par[tp][b] = a;     sz[tp][a] += sz[tp][b];   }   int main() {     cin >> n;     for (int i = 0; i < n; ++i) {       par[0][i] = par[1][i] = i;       sz[0][i] = sz[1][i] = 1;     }     for (int i = 1; i < n; ++i) {       cin >> u >> v >> tp;       --u;       --v;       union_sets(u, v);     }     for (int i = 0; i < n; ++i) {       if (par[0][i] == i) ans += (long long)sz[0][i] * (sz[0][i] - 1);       if (par[1][i] == i) ans += (long long)sz[1][i] * (sz[1][i] - 1);       tp = 0;       int v = find_set(i);       tp = 1;       int u = find_set(i);       ans += (long long)(sz[0][v] - 1) * (sz[1][u] - 1);     }     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   struct Tpoint {     double x, y;     Tpoint() {}     Tpoint(double _x, double _y) {       x = _x;       y = _y;     }     inline void read() { scanf( %lf%lf , &x, &y); }     inline void show() { printf( %lf %lf n , x, y); }     inline double norm() { return sqrt(((x) * (x)) + ((y) * (y))); }   };   inline Tpoint operator+(const Tpoint &a, const Tpoint &b) {     return Tpoint(a.x + b.x, a.y + b.y);   }   inline Tpoint operator-(const Tpoint &a, const Tpoint &b) {     return Tpoint(a.x - b.x, a.y - b.y);   }   inline Tpoint operator*(const Tpoint &a, const double &b) {     return Tpoint(a.x * b, a.y * b);   }   inline Tpoint operator/(const Tpoint &a, const double &b) {     return Tpoint(a.x / b, a.y / b);   }   inline double det(const Tpoint &a, const Tpoint &b) {     return a.x * b.y - a.y * b.x;   }   inline double dot(const Tpoint &a, const Tpoint &b) {     return a.x * b.x + a.y * b.y;   }   const int maxn = 100005;   bool mark[(1 << 20) + 10];   int n, a[maxn], last[maxn][20];   int main() {     scanf( %d , &n);     for (int i = 0; i < n; ++i) {       scanf( %d , &a[i]);     }     for (int i = 0; i < 20; ++i) {       last[n][i] = n;     }     for (int i = n - 1; i >= 0; --i) {       memcpy(last[i], last[i + 1], sizeof(last[i]));       for (int j = 0; j < 20; ++j) {         if (a[i] >> j & 1) {           last[i][j] = i;         }       }     }     for (int i = 0; i < n; ++i) {       int x = a[i], pos = i + 1;       mark[x] = true;       while (1) {         int u = -1;         for (int j = 0; j < 20; ++j) {           if (x >> j & 1) {             continue;           }           if (u == -1 || last[pos][j] < last[pos][u]) {             u = j;           }         }         if (u == -1 || last[pos][u] >= n) {           break;         }         pos = last[pos][u];         x |= a[pos];         mark[x] = true;         pos++;       }     }     int res = 0;     for (int i = 0; i < 1 << 20; ++i) {       res += mark[i];     }     printf( %d n , res);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 2e5 + 7;   map<long long, int> G;   map<long long, map<long long, int> > multiMap;   int main() {     long long i, j, k, f1, f2, f3, f4, t1, t2, t3, t4;     long long n, m, T;     long long a, b;     cin >> n >> a >> b;     m = 0;     for (i = 1; i <= n; i++) {       cin >> t1 >> t2 >> t3;       f1 = a * t2 - t3;       m += G[f1] * 2;       m -= 2 * multiMap[t2][t3];       multiMap[t2][t3]++;       G[f1]++;     }     cout << m << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   using vll = vector<ll>;   using vii = vector<int>;   using pii = pair<int, int>;   template <typename T = vii>   using vec = vector<T>;   const ll INF = 1e18, MOD = 1e9 + 7;   const int MAX = 1e6;   int main() {     cin.tie(NULL);     ios_base::sync_with_stdio(false);     int n, m;     cin >> n >> m;     map<int, vec<pii> > d;     for (int i = 0; i < m; i++) {       int u, v, w;       cin >> u >> v >> w;       d[w].emplace_back(--u, --v);     }     vii dp(n);     for (auto [_, V] : d) {       map<int, int> new_dp;       for (auto [u, v] : V) {         new_dp[v] = max({new_dp[v], dp[v], dp[u] + 1});       }       for (auto [i, x] : new_dp) {         dp[i] = x;       }     }     cout << *max_element(dp.begin(), dp.end()) <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     int a[1000000];     for (int i = 0; i < n; i++) {       cin >> a[i];     }     int cur = a[n - 1];     long long total = a[n - 1];     for (int i = n - 2; i >= 0; i--) {       cur = min(cur - 1, a[i]);       cur = max(0, cur);       total += cur;     }     cout << total;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 1e8;   const int N = 300100;   int n, m, ans, nans;   string mat[N], ansmat[N], nmat[N];   void upd() {     if (nans >= ans) return;     ans = nans;     for (int i = 0; i < n; ++i) ansmat[i] = nmat[i];   }   int main() {     cin.tie(NULL);     ios_base::sync_with_stdio(0);     cin >> n >> m;     for (int i = 0; i < n; ++i) cin >> mat[i];     for (int i = 0; i < n; ++i) ansmat[i] = nmat[i] = mat[i];     vector<char> v = { A ,  C ,  G ,  T };     ans = INF;     do {       nans = 0;       for (int j = 0; j < m; ++j) {         int op1 = 0, op2 = 0;         for (int i = 0; i < n; ++i) {           op1 += v[2 * (j & 1) + (i & 1)] != mat[i][j];           op2 += v[2 * (j & 1) + !(i & 1)] != mat[i][j];         }         nans += min(op1, op2);         bool f = op1 > op2;         for (int i = 0; i < n; ++i) nmat[i][j] = v[2 * (j & 1) + (f ^ (i & 1))];       }       upd();       nans = 0;       for (int i = 0; i < n; ++i) {         int op1 = 0, op2 = 0;         for (int j = 0; j < m; ++j) {           op1 += v[2 * (i & 1) + (j & 1)] != mat[i][j];           op2 += v[2 * (i & 1) + !(j & 1)] != mat[i][j];         }         nans += min(op1, op2);         bool f = op1 > op2;         for (int j = 0; j < m; ++j) nmat[i][j] = v[2 * (i & 1) + (f ^ (j & 1))];       }       upd();     } while (next_permutation(v.begin(), v.end()));     for (int i = 0; i < n; ++i) cout << ansmat[i] <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 200010;   vector<int> e[N];   set<int> l[N];   int n;   void exitno() {     printf( -1 n );     exit(0);   }   int exitans(int x) {     while (x % 2 == 0) x /= 2;     printf( %d n , x);     exit(0);   }   void _dfs(int p, int fa) {     if (fa && e[p].size() == 1) l[p].insert(0);     for (int i = 0; i < e[p].size(); i++) {       int x = e[p][i];       if (x == fa) continue;       _dfs(x, p);       for (auto j : l[x]) l[p].insert(j + 1);     }     if (l[p].size() >= 3) exitno();   }   void work(int p) {     for (int i = 1; i <= n; i++) l[i].clear();     _dfs(p, 0);     int x = 0;     for (auto i : l[p]) x += i;     exitans(x);   }   void dfs(int p = 1, int fa = 0) {     if (fa && e[p].size() == 1) l[p].insert(0);     for (int i = 0; i < e[p].size(); i++) {       int x = e[p][i];       if (x == fa) continue;       dfs(x, p);       for (auto j : l[x]) l[p].insert(j + 1);     }     if (l[p].size() >= 3) exitno();     if (l[p].size() == 2) work(p);   }   int main() {     cin >> n;     for (int i = 1; i <= n - 1; i++) {       int x, y;       scanf( %d%d , &x, &y);       e[x].push_back(y);       e[y].push_back(x);     }     dfs();     exitans(*l[1].begin());     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     int x;     string y, z;     cin >> x >> y >> z;     if (z[0] ==  w ) {       int fd = 5, ans = 0;       for (int i = 1; i <= 366; ++i) {         if (fd == x) ans++;         fd++;         if (fd == 8) fd = 1;       }       cout << ans <<   n ;     } else {       if (x <= 29)         cout << 12 <<   n ;       else if (x <= 30)         cout << 11 <<   n ;       else         cout << 7 <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int n, m, s, f;     cin >> n >> m >> s >> f;     map<int, pair<int, int> > mop;     for (int i = 0; i < m; i++) {       int t, l, r;       cin >> t >> l >> r;       mop[t] = {l, r};     }     string ans;     while (s != f) {       pair<int, int> p = mop[ans.size() + 1];       if (s < f) {         if ((s >= p.first && s <= p.second) ||             (s + 1 >= p.first && s + 1 <= p.second))           ans +=  X ;         else           ans +=  R , s++;       } else {         if ((s >= p.first && s <= p.second) ||             (s - 1 >= p.first && s - 1 <= p.second))           ans +=  X ;         else           ans +=  L , s--;       }     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   namespace dinic {   using ll = int;   const ll oo = 1e6;   const int N = 202 * 202 * 2;   const int E = 202 * 202 * 6 * 2 * 2;   vector<int> g[N];   int ne;   struct Edge {     int from, to;     ll flow, cap;   } edge[E];   int lvl[N], vis[N], pass, start = N - 2, target = N - 1;   int qu[N], qt, px[N];   ll run(int s, int sink, ll minE) {     if (s == sink) return minE;     ll ans = 0;     for (; px[s] < (int)g[s].size(); px[s]++) {       int e = g[s][px[s]];       auto &v = edge[e], &rev = edge[e ^ 1];       if (lvl[v.to] != lvl[s] + 1 || v.flow >= v.cap) continue;       ll tmp = run(v.to, sink, min(minE, v.cap - v.flow));       v.flow += tmp, rev.flow -= tmp;       ans += tmp, minE -= tmp;       if (minE == 0) break;     }     return ans;   }   bool bfs(int source, int sink) {     qt = 0;     qu[qt++] = source;     lvl[source] = 1;     vis[source] = ++pass;     for (int i = 0; i < qt; i++) {       int u = qu[i];       px[u] = 0;       if (u == sink) return true;       for (auto& ed : g[u]) {         auto v = edge[ed];         if (v.flow >= v.cap || vis[v.to] == pass) continue;         vis[v.to] = pass;         lvl[v.to] = lvl[u] + 1;         qu[qt++] = v.to;       }     }     return false;   }   ll flow(int source = start, int sink = target) {     ll ans = 0;     while (bfs(source, sink)) ans += run(source, sink, oo);     return ans;   }   void addEdge(int u, int v, ll c = 1, ll rc = 0) {     edge[ne] = {u, v, 0, c};     g[u].push_back(ne++);     edge[ne] = {v, u, 0, rc};     g[v].push_back(ne++);   }   };  // namespace dinic   const int N = 205;   int n, m;   char mat[N][N];   int main() {     scanf( %d %d , &n, &m);     for (int i = 0; i < n; i++) scanf( %s , mat[i]);     const int s = dinic::start;     const int t = dinic::target;     const int add = n * m;     int tot = 0;     for (int i = 0; i < n; i++)       for (int j = 0; j < m; j++) {         if (mat[i][j] !=  # ) continue;         tot++;         if (mat[i + 1][j] !=  # ) continue;         if (j - 1 >= 0 and mat[i][j - 1] ==  # ) {           dinic::addEdge(i * m + j, add + i * m + j - 1);         }         if (mat[i][j + 1] ==  # ) {           dinic::addEdge(i * m + j, add + i * m + j);         }         if (j - 1 >= 0 and mat[i + 1][j - 1] ==  # ) {           dinic::addEdge(i * m + j, add + (i + 1) * m + j - 1);         }         if (mat[i + 1][j + 1] ==  # ) {           dinic::addEdge(i * m + j, add + (i + 1) * m + j);         }       }     int ver = 0;     for (int i = 0; i < n; i++)       for (int j = 0; j < m; j++) {         if (mat[i][j] !=  # ) continue;         if (mat[i][j + 1] ==  # ) {           ver++;           dinic::addEdge(add + i * m + j, t);         }         if (mat[i + 1][j] ==  # ) {           ver++;           dinic::addEdge(s, i * m + j);         }       }     printf( %d n , tot - (ver - dinic::flow(s, t)));   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   using ld = long double;   constexpr int MAXN = 100005;   int SQRTN;   int n, k;   int t[MAXN], a[MAXN];   ll p[MAXN];   ll ans[MAXN];   ll cur = 0;   int ind[MAXN], left_ind[MAXN], right_ind[MAXN];   int freq[3 * MAXN];   struct query {     int l, r, i;   } queries[MAXN];   bool cmp(const query& a, const query& b) {     return a.l / SQRTN < b.l / SQRTN ||            (a.l / SQRTN == b.l / SQRTN and a.r < b.r);   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     scanf( %d %d , &n, &k);     for (int i = 1; i <= n; ++i) {       scanf( %d , t + i);     }     for (int i = 1; i <= n; ++i) {       scanf( %d , a + i);     }     vector<ll> vals;     vals.push_back(0LL);     vals.push_back(k);     vals.push_back(-k);     p[0] = 0LL;     for (int i = 1; i <= n; ++i) {       if (t[i] == 1)         p[i] = p[i - 1] + a[i];       else         p[i] = p[i - 1] - a[i];       vals.push_back(p[i]);       vals.push_back(p[i] - k);       vals.push_back(p[i] + k);     }     sort(begin(vals), end(vals));     vals.erase(unique(begin(vals), end(vals)), end(vals));     for (int i = 0; i <= n; ++i) {       ind[i] = lower_bound(begin(vals), end(vals), p[i]) - begin(vals);       left_ind[i] = lower_bound(begin(vals), end(vals), p[i] - k) - begin(vals);       right_ind[i] = lower_bound(begin(vals), end(vals), p[i] + k) - begin(vals);     }     SQRTN = sqrt(n);     int q;     int l, r;     scanf( %d , &q);     for (int i = 0; i < q; ++i) {       scanf( %d %d , &l, &r);       --l;       queries[i] = {l, r, i};     }     sort(queries, queries + q, cmp);     int left_ptr = 0;     int right_ptr = -1;     for (int i = 0; i < q; ++i) {       while (right_ptr < queries[i].r) {         ++right_ptr;         cur += freq[left_ind[right_ptr]];         ++freq[ind[right_ptr]];       }       while (right_ptr > queries[i].r) {         --freq[ind[right_ptr]];         cur -= freq[left_ind[right_ptr]];         --right_ptr;       }       while (left_ptr < queries[i].l) {         --freq[ind[left_ptr]];         cur -= freq[right_ind[left_ptr]];         ++left_ptr;       }       while (left_ptr > queries[i].l) {         --left_ptr;         cur += freq[right_ind[left_ptr]];         ++freq[ind[left_ptr]];       }       ans[queries[i].i] = cur;     }     for (int i = 0; i < q; ++i) {       printf( %lld n , ans[i]);     }     return 0;   }
#include<bits/stdc++.h>   using namespace std;   typedef long long ll;   const int maxn=2e5+7;   const int modn = 1e9+7;   int a[maxn],b[maxn];   map<int,int> mp,mp2;   int binaryl(int value,int l,int r){       int res = l-1;       while(r >= l){           int mid = (r+l) >> 1;           if(b[mid] < value){               res = mid;               l = mid+1;           }           else r = mid-1;       }       return res;   }   int binaryr(int value,int l,int r){       int res = r + 1;       while(r >= l){           int mid = (r+l) >> 1;           if(b[mid] > value){               res = mid;               r = mid-1;           }           else l = mid+1;       }       return res;   }   int main(){       int T;       scanf( %d ,&T);       while(T--){           mp.clear();           mp2.clear();           int n,m;           scanf( %d%d ,&n,&m);           int midn = n+1,midm = m+1;           for(int i = 1;i <= n;i++){               scanf( %d ,&a[i]);               mp[a[i]] = 1;               if(midn == n+1 && a[i] > 0)midn = i;           }           for(int j = 1;j <= m;j++){               scanf( %d ,&b[j]);               mp2[b[j]] = 1;               if(midm == m+1 && b[j] > 0)midm = j;           }              int lstart = 0;           for(int i = 1;i < midm;i++){               if(mp[b[i]])lstart++;           }           int ans1 = lstart,ans2 = 0;           int now = midn-1;           int len = 0;           for(int i = midm-1;i >= 1;i--){   //            printf( %d n ,i);               int res = lstart;               int bb = b[i]-len;               while(now && bb <= a[now]){                   if(mp2[a[now]])res--;                   len++;                   bb--;                   now--;               }               if(!len)continue;               int where = b[i] - len+1;               where = binaryl(where,1,i);   //            printf( %d: where==%d res==%d len==%d n ,i,where,res,len);               lstart = res;               res += i - where;               ans1 = max(ans1,res);           }              int rstart = 0;           for(int i = midm;i <= m;i++){               if(mp[b[i]])rstart++;           }           ans2 = rstart;           now = midn;           len = 0;           for(int i = midm;i <= m;i++){               int res = rstart;               int bb = b[i] + len;               while(now <= n && bb >= a[now]){                   if(mp2[a[now]])res--;                   len++;                   bb++;                   now++;               }               if(len == 0)continue;               int where = b[i] + len-1;               where = binaryr(where,i,m);   //            printf( %d: where==%d res==%d len==%d n ,i,where,res,len);               rstart = res;               res += where - i;               ans2 = max(ans2,res);           }   //        printf( %d %d n ,ans1,ans2);           printf( %d n ,ans1+ans2);       }   }   /*   1000   5 5   -5 -3 -1 8 100   -9 -7 -3 1000 1001      1 5   -5   -10 -9 -8 -7 -4      5 5   -5 -4 -3 -2 -1   -100 -99 -96 -95 -94   */