malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   #define ll long long   #define F first   #define S second   #define pb push_back   #define P push   #define B break   #define C continue   #define R return   #define gcd(x,y) __gcd(x,y)   #define be(a) a.begin(),a.end()   #define lb(a,x) (lower_bound(be(a),x)-a.begin())   #define ub(a,x) (upper_bound(be(a),x)-a.begin())   #define uniq(a) a.resize(unique(be(a))-a.begin())   #define fast ios::sync_with_stdio(NULL); cin.tie(0); cout.tie(0);   #define po(x) (x%mod+mod)%mod   #define SM(x,y) (po(x)+po(y))%mod   #define M(x,y)  (po(x)*po(y))%mod   using namespace std;   ll t,n,i,j,k,l,r,mid,mod=1e9+7,m,ans;   ll a[400005],f[400005],c[400005];   char ch;   map<ll,ll>mp;   //set<ll>s;   string s,st;   //vector<ll>v[300005],u;   double x,y,z,v,d[105][105],eps=1e-9;   bool b[106][105];   double dp(int i,int j){       double &ret=d[i][j];       if(b[i][j]) R ret;       b[i][j]=1;       ret=0;       double X,Y,Z;       Z=z+((i+j)*v)/2.0;       X=x+(j*v/2.0)-i*v;       Y=y+(i*v/2.0)-j*v;       if(X<eps) {           X*=-1;           Y-=X/2.0;           Z-=X/2.0;           X=1;           for(k=1;;k++) {               ret+=Z*X*(i+j+k);               if(Y<eps) R ret;               X*=Y;               Y-=v;               Z+=v;               Z=min(Z,1.0);           }           R ret;       }       if(Y<eps) {           Y*=-1;           X-=Y/2.0;           Z-=Y/2.0;           Y=1;           for(k=1;;k++) {               ret+=Z*Y*(i+j+k);               if(X<eps) R ret;               Y*=X;               X-=v;               Z+=v;               Z=min(Z,1.0);           }           R ret;       }       R ret=X*dp(i+1,j)+Y*dp(i,j+1)+Z*(i+j+1);   }   int ff(){       cin>>x>>y>>z>>v;       memset(b,0,sizeof b);       double ans=dp(0,0);       cout<<fixed<<setprecision(8)<<ans;       R 0;   }   int main()   {       fast       cin>>t;       while(t--){           ff();           cout<<  n ;       }   }   /**      */
#include <bits/stdc++.h>   using namespace std;   const long long linf = 1e18 + 9;   const int inf = 1e9 + 9;   const int N = 1e3 + 9;   int n, m, c[N], d[N], a[N], b[N], dp[N][N], ans;   int main() {     cin >> n >> m >> c[0] >> d[0];     for (int i = 1; i <= m; i++) cin >> a[i] >> b[i] >> c[i] >> d[i];     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= m; j++) {         int mx = -inf;         for (int k = 0; k <= a[j] / b[j]; k++) {           if (i - c[j] * k < 0) continue;           mx = max(mx, dp[i - c[j] * k][j - 1] + d[j] * k);         }         dp[i][j] = mx;       }     }     for (int i = 0; i <= n; i++) ans = max(ans, dp[i][m] + (n - i) / c[0] * d[0]);     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   using ull = unsigned long long;   using ld = long double;   template <typename T>   ostream& operator<<(ostream& os, const vector<T>& v) {     for (size_t i = 0; i < v.size(); ++i) {       os << v[i];       if (i + 1 != v.size()) {         os <<    ;       }     }     return os;   }   void solve() {     int n;     cin >> n;     vector<ll> a(n);     for (int i = 0; i < n; ++i) {       cin >> a[i];     }     vector<ll> v = a;     sort(v.begin(), v.end());     reverse(v.begin(), v.end());     int m;     cin >> m;     while (m--) {       int k, pos;       cin >> k >> pos;       --k;       int mn = v[k];       int j = k - 1;       while (j >= 0 && v[k] == v[j]) {         --j;       }       int cnt = k - j;       for (int i = 0; i < n; ++i) {         if (a[i] > mn) {           --pos;         } else if (a[i] == mn) {           if (cnt > 0) {             --pos;             --cnt;           }         }         if (pos == 0) {           cout << a[i] <<   n ;           break;         }       }     }   }   int main() {     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double pi = acos(-1);   const int INF = 1e9;   const double inf = 1e15;   const double eps = 1e-9;   const long long MOD = 1e9 + 7;   long long toNum(string s) {     stringstream ss(s);     long long ret;     ss >> ret;     return ret;   }   string toString(long long x) {     stringstream ss;     ss << x;     return ss.str();   }   long long mulMod(long long a, long long b) { return (a * b) % MOD; }   long long addMod(long long a, long long b) { return (a + b) % MOD; }   long long redMod(long long a, long long b) {     return addMod(addMod(a, -b), MOD);   }   long long fast(long long a, long long b) {     if (b == 0) return 1;     long long tmp = fast(a, b / 2);     tmp = mulMod(tmp, tmp);     if (b & 1) tmp = mulMod(tmp, a);     return tmp;   }   long long GCD(long long a, long long b) {     if (a == 0) return b;     return GCD(b % a, a);   }   const int N = 1e5 + 5;   const int BLOCK = 300;   const int CBLOCK = N / BLOCK + 5;   pair<int, int> jmp[N];   int arr[N];   int n, q;   vector<pair<int, int> > lst;   pair<int, int> query(int x) {     int cur = x;     int nxt = jmp[cur].first;     int nod = x, val = 1;     while (cur != nxt) {       val += jmp[cur].second;       nod = nxt;       cur = nxt;       nxt = jmp[cur].first;     }     return make_pair(nod, val);   }   void update(int a, int b) {     arr[a] = b;     int idx = (a - 1) / BLOCK;     int st = idx * BLOCK + 1;     int en = min(n, (idx + 1) * BLOCK);     for (int i = en; i >= st; i -= 1) {       int nxt = i + arr[i];       nxt = min(nxt, n + 1);       if (nxt == n + 1) {         jmp[i] = make_pair(i, 0);       } else {         if ((nxt - 1) / BLOCK != idx) {           jmp[i] = make_pair(nxt, 1);         } else {           jmp[i] = make_pair(jmp[nxt].first, jmp[nxt].second + 1);         }       }     }   }   int main() {     ios_base ::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> n >> q;     for (int i = 1; i <= n; i += 1) cin >> arr[i];     for (int i = n; i >= 1; i -= 1) {       int nxt = i + arr[i];       nxt = min(nxt, n + 1);       if (nxt == n + 1) {         jmp[i] = make_pair(i, 0);       } else {         if ((nxt - 1) / BLOCK != (i - 1) / BLOCK) {           jmp[i] = make_pair(nxt, 1);         } else {           jmp[i] = make_pair(jmp[nxt].first, jmp[nxt].second + 1);         }       }     }     int ins, a, b;     for (int i = 1; i <= q; i += 1) {       cin >> ins >> a;       if (ins == 0) {         cin >> b;         update(a, b);       } else {         pair<int, int> ans = query(a);         cout << ans.first <<     << ans.second << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long iinf = 1 << 29;   const long long inf = 1ll << 60;   const long long mod = 1e9 + 7;   void GG() {     cout <<  No n ;     exit(0);   }   long long mpow(long long a, long long n) {     long long re = 1;     while (n > 0) {       if (n & 1) re = re * a % mod;       a = a * a % mod;       n >>= 1;     }     return re;   }   long long inv(long long b) {     if (b == 1) return b;     return (mod - mod / b) * inv(mod % b) % mod;   }   const long long maxn = 5e6 + 1;   const double PI = acos(-1.0);   void FFT(vector<complex<double> > &a, bool rev = 0) {     long long n = (long long)a.size();     assert(__builtin_popcount(n) <= 1);     for (long long i = 1, j = 0; i < n; i++) {       long long bit = n / 2;       while (j >= bit) j -= bit, bit /= 2;       j += bit;       if (i < j) swap(a[i], a[j]);     }     for (long long B = 2; B <= n; B *= 2) {       double ang = 2 * PI / B * (rev ? -1 : 1);       complex<double> w0(cos(ang), sin(ang));       for (long long i = 0; i < n; i += B) {         complex<double> w(1, 0);         for (long long j = 0; j < B / 2; j++) {           complex<double> u = a[i + j], v = w * a[i + j + B / 2];           a[i + j] = u + v, a[i + j + B / 2] = u - v;           w *= w0;         }       }     }     if (rev)       for (long long i = 0; i < (n); i++) a[i] /= n;   }   vector<long long> mul(vector<long long> a, vector<long long> b) {     long long n = 1;     while (n < (long long)a.size() + (long long)b.size()) n *= 2;     vector<complex<double> > x(n), y(n);     for (long long i = 0; i < ((long long)a.size()); i++)       x[i] = complex<double>(a[i], 0);     for (long long j = 0; j < ((long long)b.size()); j++)       y[j] = complex<double>(b[j], 0);     FFT(x);     FFT(y);     for (long long i = 0; i < (n); i++) x[i] *= y[i];     FFT(x, 1);     vector<long long> re(n);     for (long long i = 0; i < (n); i++) re[i] = (long long)(round(x[i].real()));     while (re.size() > 1 && re.back() == 0) re.pop_back();     return re;   }   signed main() {     long long n, x;     cin >> n >> x;     vector<long long> a(n);     vector<long long> b;     long long cnt = 1;     long long zed = 0;     for (long long i = 0; i < (n); i++) {       cin >> a[i];       if (a[i] < x) {         b.push_back(cnt);         cnt = 0;       }       cnt++;     }     b.push_back(cnt);     for (long long y : b) zed += (y - 1) * (y) / 2;     vector<long long> c = b;     reverse(c.begin(), c.end());     vector<long long> d = mul(b, c);     cout << zed <<    ;     for (long long i = ((long long)b.size()); i < ((long long)b.size() + n);          i++) {       if (i < (long long)d.size())         cout << d[i] <<    ;       else         cout << 0 <<    ;     }   }
#include <bits/stdc++.h>   #pragma GCC optimize( O3 )   const double PI = acos(-1.0);   using namespace std;   const int N = 509, M = 1000000;   int n, m, dis[N][N], in[N][N], ans[N][N], t[N][N];   vector<int> adj[N];   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     ;     cin >> n >> m;     int u, v, d;     memset(dis,  ? , sizeof dis);     for (int i = 1; i <= m; i++) {       cin >> u >> v >> d;       adj[u].push_back(v);       adj[v].push_back(u);       dis[u][v] = dis[v][u] = d;       t[u][v] = t[v][u] = d;     }     for (int i = 1; i <= n; i++) dis[i][i] = 0;     for (int k = 1; k <= n; k++)       for (int i = 1; i <= n; i++)         for (int j = 1; j <= n; j++)           dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= n; j++) {         if (i == j) continue;         for (auto k : adj[j]) {           if (dis[i][k] + t[k][j] == dis[i][j]) in[i][j]++;         }       }     }     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= n; j++) {         for (int k = 1; k <= n; k++) {           if (dis[i][k] + dis[k][j] == dis[i][j]) ans[i][j] += in[i][k];         }       }     }     for (int i = 1; i <= n; i++)       for (int j = i + 1; j <= n; j++) {         if (dis[i][j] >= dis[502][502])           cout <<  0  ;         else           cout << ans[i][j] <<    ;       }     return 0;   }
#include <bits/stdc++.h>   int main() {     int tux;     scanf( %d , &tux);     int foo = 0, bar = 0, baz = 0, quz = 1;     for (int i = 0; i < tux; i++) {       int pur;       scanf( %d , &pur);       foo += pur;       bar++;       if (foo * quz >= bar * baz) {         baz = foo;         quz = bar;       }     }     printf( %.6lf n , (double)baz / quz);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       int n;       cin >> n;       int arr[n];       for (int i = 0; i < n; i++) cin >> arr[i];       for (int i = 0; i < n; i++) arr[i] -= 1;       for (int i = 0; i < n; i++) {         int count = 1;         int index = arr[i];         while (i != index) {           index = arr[index];           count++;         }         cout << count <<    ;       }       cout << endl;       ;     }   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 100005;   long long n, a[maxn], aa[maxn], bb[maxn];   int main() {     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> a[i];     }     for (int i = 1; i <= n; i++) {       aa[i] = aa[i - 1] + a[i];     }     long long b[maxn];     for (int i = 1; i <= n; i++) {       b[i] = a[i];     }     sort(b + 1, b + n + 1);     for (int i = 1; i <= n; i++) {       bb[i] = bb[i - 1] + b[i];     }     int T;     cin >> T;     while (T--) {       int type, l, r;       long long sum = 0;       cin >> type >> l >> r;       if (type == 1) {         sum = aa[r] - aa[l - 1];       } else {         sum = bb[r] - bb[l - 1];       }       cout << sum << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   using db = double;   using pii = pair<int, int>;   using vi = vector<int>;   mt19937 mrand(time(0));   ll get(ll r) { return ((ll)mrand() * mrand() % r + r) % r; }   ll get(ll l, ll r) { return get(r - l + 1) + l; }   int t, T, n, m, L, R = 1e9, c[100100];   pii seg[100100];   vi G[100100];   bool in(pii seg, int x) { return seg.first <= x && x <= seg.second; }   bool dfs(int x) {     for (int y : G[x])       if (!c[y]) {         c[y] = 3 - c[x];         if (!dfs(y)) return false;       } else if (c[y] == c[x])         return false;     return true;   }   signed main() {     scanf( %d %d %d %d , &t, &T, &n, &m);     for (int i = 1; i <= n; i++)       scanf( %d %d , &seg[i].first, &seg[i].second), L = max(L, seg[i].first),                                                      R = min(R, seg[i].second);     if (L + R > T) R = T - L;     if (L + R <= t) L = t - R;     if (L < 0 || R < 0) return puts( IMPOSSIBLE ), 0;     for (int i = 1; i <= n; i++) {       int l_ = in(seg[i], L), r_ = in(seg[i], R);       if (!l_ && !r_) return puts( IMPOSSIBLE ), 0;       if (l_ && !r_) c[i] = 1;       if (!l_ && r_) c[i] = 2;     }     for (int i = 1, x, y; i <= m; i++)       scanf( %d %d , &x, &y), G[x].push_back(y), G[y].push_back(x);     for (int i = 1; i <= n; i++)       if (c[i] && !dfs(i)) return puts( IMPOSSIBLE ), 0;     for (int i = 1; i <= n; i++)       if (!c[i] && (c[i] = 1) && !dfs(i)) return puts( IMPOSSIBLE ), 0;     string ans;     for (int i = 1; i <= n; i++) ans += c[i] +  0 ;     puts( POSSIBLE ), printf( %d %d n , L, R), cout << ans <<   n ;     fprintf(stderr,  time=%.4f n , (db)clock() / CLOCKS_PER_SEC);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void Read(int &n) {     int sign = 1;     n = 0;     char c;     do {       c = getchar();     } while (!isdigit(c) && c !=  - );     if (c ==  - ) {       c = getchar();       sign = -1;     }     do {       n = n * 10 + c - 48;       c = getchar();     } while (isdigit(c));     n *= sign;   }   void Read(long long &n) {     int sign = 1;     n = 0;     char c;     do {       c = getchar();     } while (!isdigit(c) && c !=  - );     if (c ==  - ) {       c = getchar();       sign = -1;     }     do {       n = n * 10ll + c - 48;       c = getchar();     } while (isdigit(c));     n *= sign;   }   void Write(int n) {     if (n == 0) {       putchar( 0 );       return;     } else if (n < 0)       putchar( - ), n = -n;     char C[30];     int d = 0;     while (n) {       C[++d] = (n % 10) + 48;       n /= 10;     }     for (int i = d; i >= 1; --i) putchar(C[i]);   }   void Write(long long n) {     if (n == 0) {       putchar( 0 );       return;     } else if (n < 0)       putchar( - ), n = -n;     char C[30];     int d = 0;     while (n) {       C[++d] = (n % 10ll) + 48;       n /= 10ll;     }     for (int i = d; i >= 1; --i) putchar(C[i]);   }   const int maxn = 1005;   char S[maxn];   int P1 = 0, P2 = 0;   bool DigitOrDot(char c) { return ( 0  <= c && c <=  9 ) || c ==  . ; }   void Solve(int s, int e) {     int val = 0;     int pos = -1;     for (int i = s; i <= e; ++i) {       if (S[i] ==  . ) {         pos = i;         continue;       }       val = val * 10 + (S[i] -  0 );     }     if (e - pos == 2) {       P1 += val / 100;       P2 += val % 100;     } else       P1 += val;   }   int main() {     scanf( %s , S + 1);     int n = strlen(S + 1);     for (int i = 1; i <= n; ++i) {       int s = i, e, j = i;       if (DigitOrDot(S[i]))         while (j <= n && DigitOrDot(S[j])) ++j;       e = j - 1;       if (s <= e) Solve(s, e);       i = j;     }     P1 += P2 / 100;     P2 %= 100;     string ans =   ;     if (P2 != 0)       for (int i = 1; i <= 2; ++i) ans += char((P2 % 10) +  0 ), P2 /= 10;     if (ans !=   ) ans +=  . ;     int d = 0;     if (P1 == 0) ans +=  0 ;     while (P1) {       ans += (char)((P1 % 10) +  0 );       P1 /= 10;       d++;       if (d == 3) d = 0, ans +=  . ;     }     if (ans[ans.size() - 1] ==  . ) ans.erase(ans.size() - 1);     reverse(ans.begin(), ans.end());     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   set<int> remaining;   set<pair<long long int, long long int> > edge;   int cur = 1;   int cmp[300011];   int bfs(int v) {     int cnt = 0;     queue<int> q;     q.push(v);     vector<int> second;     while (q.size()) {       cnt++;       v = q.front();       q.pop();       cmp[v] = cur;       second.clear();       for (auto x : remaining) {         if (!edge.count({x, v})) {           second.push_back(x);         }       }       for (auto x : second) {         remaining.erase(x);         q.push(x);       }     }     return cnt;   }   int main() {     int n, m, k, u, v;     cin >> n >> m >> k;     for (int j = 0; j < m; j++) {       cin >> u >> v;       edge.insert({u, v});       edge.insert({v, u});     }     for (int i = 2; i <= n; i++) remaining.insert(i);     int cnt = 0;     while (remaining.size()) {       int v = *remaining.begin();       remaining.erase(v);       cnt += bfs(v);       cur++;     }     set<int> q;     int w = 0;     for (int i = 2; i <= n; i++) {       if (!edge.count({1, i})) {         q.insert(cmp[i]);         w++;       }     }     if (q.size() <= k and q.size() > 0 and cnt + 1 == n and         q.size() == cur - 1 and w >= k) {       cout <<  possible ;     } else {       cout <<  impossible ;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int x, a, b;     cin >> a >> b >> x;     if (a >= b) {       cout <<  0 ;       if (x % 2 == 0) {         for (int i = 1; i < x / 2; i++) cout <<  10 ;         for (int i = 0; i <= b - x / 2; i++) cout <<  1 ;         for (int i = 1; i <= a - x / 2; i++) cout <<  0 ;       }       if (x % 2 == 1) {         for (int i = 1; i <= x / 2; i++) cout <<  10 ;         for (int i = 1; i < a - x / 2; i++) cout <<  0 ;         for (int i = 0; i < b - x / 2; i++) cout <<  1 ;       }     }     if (b > a) {       cout <<  1 ;       if (x % 2 == 0) {         for (int i = 1; i < x / 2; i++) cout <<  01 ;         for (int i = 0; i <= a - x / 2; i++) cout <<  0 ;         for (int i = 1; i <= b - x / 2; i++) cout <<  1 ;       }       if (x % 2 == 1) {         for (int i = 1; i <= x / 2; i++) cout <<  01 ;         for (int i = 1; i < b - x / 2; i++) cout <<  1 ;         for (int i = 0; i < a - x / 2; i++) cout <<  0 ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, a[1005] = {0,   1,  1, 1, 2,  1, 2,  1, 5,  2, 2,  1, 5,  1, 2, 1,                     14,  1,  5, 1, 5,  2, 2,  1, 15, 2, 2,  5, 4,  1, 4, 1,                     51,  1,  2, 1, 14, 1, 2,  2, 14, 1, 6,  1, 4,  2, 2, 1,                     52,  2,  5, 1, 5,  1, 15, 2, 13, 2, 2,  1, 13, 1, 2, 4,                     267, 1,  4, 1, 5,  1, 4,  1, 50, 1, 2,  3, 4,  1, 6, 1,                     52,  15, 2, 1, 15, 1, 2,  1, 12, 1, 10, 1, 4,  2};   int main() {     scanf( %d , &n);     printf( %d , a[n]);     return 0;   }
#include <bits/stdc++.h>   constexpr int MAXN = 1e2 + 2;   constexpr int MAXE = 1e4 + 4;   using namespace std;   int n;   vector<double> choc, prefixSum, suffixSum, cpy;   int main() {     std::ios::sync_with_stdio(false);     cin >> n;     choc.resize(n), prefixSum.resize(n), suffixSum.resize(n);     for (int i = 0; i < n; i++) {       cin >> choc[i];       if (i == 0)         prefixSum[0] = choc[0];       else         prefixSum[i] = prefixSum[i - 1] + choc[i];     }     for (int i = n - 1; i >= 0; i--) {       if (i == n - 1)         suffixSum[i] = choc[i];       else         suffixSum[i] = suffixSum[i + 1] + choc[i];     }     cpy = suffixSum;     reverse(cpy.begin(), cpy.end());     double mid = prefixSum[n - 1] / 2;     int midPos = upper_bound(prefixSum.begin(), prefixSum.end(), mid) -                  prefixSum.begin() - 1;     int i = 0, j = n - 1;     for (i = 0; i <= midPos; i++) {       int tAlice = prefixSum[i];       j = upper_bound(cpy.begin(), cpy.end(), tAlice * 1.0) - cpy.begin() - 1;       j = n - 1 - j;       int tBob = suffixSum[j];       if (i + 1 == j) {         if (tAlice - choc[i] > tBob)           i--;         else if (tAlice - choc[i] == tBob)           break;         break;       }       if (i + 2 == j) {         if (tAlice == tBob)           i++;         else if (tAlice < tBob)           i++;         break;       }       if (i >= j) break;     }     cout << i + 1 <<     << n - i - 1 << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   #pragma warning(disable : 4996)   const long double PI = 3.14159265358979323846;   const long long MOD = 998244353;   mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());   void solve() {     int n;     cin >> n;     vector<int> a(n);     map<int, deque<int>> d;     vector<int> b;     for (int i = 0; i < n; i++) {       cin >> a[i];       b.push_back(a[i]);     }     sort(b.begin(), b.end());     b.resize(unique(b.begin(), b.end()) - b.begin());     for (int i = 0; i < n; i++) {       a[i] = lower_bound(b.begin(), b.end(), a[i]) - b.begin();       d[a[i]].push_back(i);     }     map<int, int> dp;     int ans = 0;     for (auto c : d) {       dp[c.first] = d[c.first].size();       if (!d[c.first - 1].empty() && d[c.first - 1].back() < d[c.first].front()) {         dp[c.first] = max(dp[c.first], dp[c.first - 1] + (int)d[c.first].size());       }       int cnt = 0;       for (auto kek : d[c.first - 1]) {         if (kek < d[c.first].front()) {           cnt++;         }       }       dp[c.first] = max(dp[c.first], cnt + (int)d[c.first].size());       ans = max(ans, dp[c.first]);       int ret = 0;       for (auto kek : d[c.first]) {         if (!d[c.first - 1].empty() && kek > d[c.first - 1].back()) {           ret++;         }       }       ans = max(ans, dp[c.first - 1] + ret);       vector<pair<int, int>> arr;       for (auto d : d[c.first - 1]) {         arr.push_back({d, 0});       }       for (auto d : d[c.first]) {         arr.push_back({d, 1});       }       sort(arr.begin(), arr.end());       int dp0 = 0, dp1 = 0;       for (auto c : arr) {         if (c.second == 1) {           dp1++;         } else {           dp0++;           dp1 = max(dp1, dp0);         }       }       ans = max(ans, dp1);     }     cout << n - ans <<   n ;   }   int main() {     srand(time(0));     ios_base::sync_with_stdio(false);     cin.tie(0);     int q;     cin >> q;     while (q--) solve();   }
#include <bits/stdc++.h>   using std::cin;   using std::cout;   using std::endl;   const int maxn = 200005;   long long a[maxn], b[maxn];   int n;   int ans, base;   std::map<std::pair<long long, long long>, int> mmp;   long long gcd(long long x, long long y) { return y == 0 ? x : gcd(y, x % y); }   int main() {     cin >> n;     for (int i = 1; i <= n; i++) cin >> a[i];     for (int i = 1; i <= n; i++) cin >> b[i];     for (int i = 1; i <= n; i++) {       if (a[i] == 0) {         if (b[i] == 0) base++;       } else {         long long temp1 = b[i], temp2 = a[i];         if (temp1 < 0)           temp1 = -temp1, temp2 = -temp2;         else if (temp1 == 0)           temp2 = 0;         long long g = gcd(llabs(temp1), llabs(temp2));         if (g) temp1 /= g, temp2 /= g;         mmp[std::make_pair(temp1, temp2)]++;       }     }     for (auto it : mmp) {       ans = std::max(ans, it.second);     }     cout << ans + base << endl;     return 0;   }