malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   template <typename T>   istream& operator>>(istream& is, vector<T>& a) {     for (T& ai : a) is >> ai;     return is;   }   template <typename T>   ostream& operator<<(ostream& os, vector<T> const& a) {     os <<  [  ;     for (const T& ai : a) os << ai <<    ;     return os <<  ] ;   }   template <typename T1, typename T2>   istream& operator>>(istream& is, pair<T1, T2>& a) {     return is >> a.first >> a.second;   }   template <typename T1, typename T2>   ostream& operator<<(ostream& os, pair<T1, T2> const& a) {     return os <<  (  << a.first <<  ,   << a.second <<  ) ;   }   int f() {     int n;     cin >> n;     vector<int> a(n);     cin >> a;     vector<int> val(a);     sort((val).begin(), (val).end());     int m = unique((val).begin(), (val).end()) - val.begin();     val.resize(m);     map<int, int> idx;     for (int i = 0; i < m; ++i) idx[val[i]] = i;     vector<vector<int> > tiers(m);     for (int i = 0; i < n; ++i) tiers[idx[a[i]]].push_back(i);     int i = 0, j = 1, r = 0;     while (i < m) {       while (j < m && tiers[j - 1].back() < tiers[j].front()) ++j;       int s = 0, lb = tiers[i].front(), ub = tiers[j - 1].back();       for (int k = i; k < j; ++k) s += tiers[k].size();       if (i - 1 >= 0) {         for (int x : tiers[i - 1]) {           if (x < lb) ++s;         }       }       if (j < m) {         for (int x : tiers[j]) {           if (x > ub) ++s;         }       }       r = max(r, s);       i = j++;     }     for (int i = 0; i < m - 1; ++i) {       int j = 0, jz = tiers[i + 1].size();       int s = jz;       for (int lhs : tiers[i]) {         ++s;         while (j < jz && tiers[i + 1][j] <= lhs) {           ++j;           --s;         }         r = max(r, s);       }     }     return n - r;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     int t;     cin >> t;     while (t--) cout << f() <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long t, a, b;     cin >> t;     while (t--) {       cin >> a >> b;       int f = 0;       long long area = a * a - b * b;       if ((a - b) != 1)         cout <<  NO ;       else {         area = a + b;         for (int i = 2; i <= sqrt(a + b); i++) {           if (area % i == 0) {             cout <<  NO ;             f = 1;             break;           }         }         if (f == 0) cout <<  YES ;       }       cout << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   long long s(0), p, k;   int main() {     cin >> k >> p;     for (long long cz(1), i(0); i < k; ++i, ++cz) {       string str = to_string(cz);       string res(str);       reverse(begin(str), end(str));       res += str;       s += stoll(res) % p;     }     cout << s % p << endl;   }
#include <bits/stdc++.h>   using namespace std;   long long xl, xr, yu, yd;   long long x, y;   int main() {     ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);     long long n;     cin >> n;     for (int i = 0; i < n; i++) {       cin >> x >> y;       if (i == 0) {         xl = x;         xr = x;         yu = y;         yd = y;       } else {         if (x < xl) xl = x;         if (x > xr) xr = x;         if (y > yu) yu = y;         if (y < yd) yd = y;       }     }     long long ans = max(yu - yd, xr - xl);     cout << ans * ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int o, e, oC, eC, n, en;   int main() {     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> en;       if (en % 2 == 0) {         e = i;         eC++;       } else {         o = i;         oC++;       }     }     if (oC == 1)       cout << o;     else       cout << e;   }
#include <bits/stdc++.h>   using namespace std;   double px[1005], py[1005];   double tx, ty;   int sum;   int pnpoly(int nvert, double *vertx, double *verty, double testx,              double testy) {     int i, j, c = 0;     for (i = 0, j = nvert - 1; i < nvert; j = i++) {       if (((verty[i] > testy) != (verty[j] > testy)) &&           (testx <            (vertx[j] - vertx[i]) * (testy - verty[i]) / (verty[j] - verty[i]) +                vertx[i]))         c = !c;     }     return c;   }   int main() {     ios::sync_with_stdio(false);     int n;     while (cin >> n) {       sum = 0;       memset(px, 0, sizeof(px));       memset(py, 0, sizeof(py));       for (int i = 0; i <= n; i++) {         cin >> px[i] >> py[i];       }       for (int i = 1; i < n; i++) {         if (px[i] - px[i - 1] == 0) {           tx = px[i];           ty = abs(py[i] - py[i - 1]) / (py[i] - py[i - 1]) * 0.1 + py[i];         } else if (py[i] - py[i - 1] == 0) {           ty = py[i];           tx = abs(px[i] - px[i - 1]) / (px[i] - px[i - 1]) * 0.1 + px[i];         }         if (pnpoly(n, px, py, tx, ty)) {           sum++;         }       }       cout << sum << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5;   int w[N], ne[N], la[N], len[N], cst[N], t = 1;   void alink(int x, int y, int z, int c) {     w[++t] = y;     ne[t] = la[x];     la[x] = t;     len[t] = z;     cst[t] = c;   }   void link(int x, int y, int z, int c) {     alink(x, y, z, c);     alink(y, x, 0, -c);   }   int d[N], vis[N], S, T, dep[N], s[N], cur[N], n, m;   int ind[N], oud[N];   int spfa() {     for (int i = 1; i <= T; i++) vis[i] = 0, s[i] = 1e9;     s[S] = 0, vis[S] = 1;     d[1] = S;     int l = 0, r = 1;     while (l < r) {       int x = d[++l];       for (int y = la[x]; y; y = ne[y]) {         int z = w[y];         if (s[z] > s[x] + cst[y] && len[y]) {           s[z] = s[x] + cst[y];           if (!vis[z]) {             vis[z] = 1;             d[++r] = z;           }         }       }       vis[x] = 0;     }     l = 0, r = 1;     vis[S] = 1;     while (l < r) {       int x = d[++l];       cur[x] = la[x];       for (int y = la[x]; y; y = ne[y]) {         int z = w[y];         if (!vis[z] && s[z] == s[x] + cst[y] && len[y]) {           vis[z] = 1;           d[++r] = z;           dep[z] = dep[x] + 1;         }       }     }     return vis[T];   }   int ans;   int flow(int x, int val) {     if (x == T) return val;     int v1 = val;     for (int y = cur[x]; y; cur[x] = y = ne[y]) {       int z = w[y];       if (dep[z] != dep[x] + 1 || s[z] != s[x] + cst[y] || !len[y]) continue;       int use = flow(z, min(val, len[y]));       val -= use;       len[y] -= use;       len[y ^ 1] += use;       ans += cst[y] * use;       if (!val) break;     }     return v1 - val;   }   int main() {     cin >> n >> m;     S = n + 1, T = n + 2;     for (int i = 1; i <= m; i++) {       int x, y, c, f;       scanf( %d%d%d%d , &x, &y, &c, &f);       ind[y] += f;       oud[x] += f;       if (c >= f) {         link(y, x, f, 1);         link(x, y, c - f, 1);         link(x, y, 1 << 30, 2);       } else {         ans += f - c;         link(x, y, 1 << 30, 2);         link(y, x, f - c, 0);         link(y, x, c, 1);       }     }     for (int i = 1; i <= n; i++) link(S, i, ind[i], 0), link(i, T, oud[i], 0);     link(n, 1, 1 << 30, 0);     while (spfa()) flow(S, 1 << 30);     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   int IN() {     int c, x;     while (!isdigit(c = getchar()))       ;     x = c -  0 ;     while (isdigit(c = getchar())) x = (x << 1) + (x << 3) + c -  0 ;     return x;   }   const int N = 1000 + 19, P = 1e9 + 7;   int A[N][N], s[N][N], f[N], c[N], b[N];   int n, m, k, cnt, Ans;   void DFS(int x, int y, int col) {     if (col > k) return;     if (y == m + 1) {       DFS(x + 1, 1, col);       return;     }     if (x == n + 1) {       int tmp = 1;       for (int i = k - col + 1; i <= k - cnt; i++) tmp = 1LL * tmp * i % P;       (Ans += tmp) %= P;       return;     }     int &S = s[x][y];     S = s[x][y - 1] | s[x - 1][y];     if (A[x][y]) {       int t = A[x][y];       if (c[t]) {         if (!(S >> c[t] & 1)) S |= 1 << c[t], DFS(x, y + 1, col), S ^= 1 << c[t];       } else         for (int i = 1; i < col + 2; i++)           if (!(S >> i & 1) && !b[i])             S |= 1 << i, b[i] = 1, c[t] = i, DFS(x, y + 1, max(i, col)),                          S ^= 1 << i, b[i] = 0, c[t] = 0;     } else       for (int i = 1; i < col + 2; i++)         if (!(S >> i & 1)) S |= 1 << i, DFS(x, y + 1, max(i, col)), S ^= 1 << i;   }   int main() {     n = IN(), m = IN(), k = IN();     if (n + m - 1 > k) return puts( 0 ), 0;     for (int i = 1; i < n + 1; i++)       for (int j = 1; j < m + 1; j++) f[A[i][j] = IN()] = 1;     for (int i = 1; i < k + 1; i++) cnt += f[i];     DFS(1, 1, 0);     printf( %d n , Ans);   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 2e5 + 10, Mod = 1e9 + 7;   int t, n, k;   long long Pow(long long a, long long b) {     a %= Mod;     long long ans = 1;     while (b) {       if (b & 1) ans *= a, ans %= Mod;       a *= a, a %= Mod;       b >>= 1;     }     return ans;   }   long long jie[MAXN], ni[MAXN];   void getall() {     jie[0] = 1, ni[0] = 1;     for (int i = 1; i < MAXN; ++i) jie[i] = (jie[i - 1] * i) % Mod;     ni[MAXN - 1] = Pow(jie[MAXN - 1], Mod - 2);     for (int i = MAXN - 2; i >= 1; --i) ni[i] = (ni[i + 1] * (i + 1)) % Mod;   }   long long calc(int a) {     long long ans = jie[n];     ans *= ni[a], ans %= Mod;     ans *= ni[n - a], ans %= Mod;     return ans;   }   int main() {     ios::sync_with_stdio(0);     cin >> t;     getall();     while (t--) {       cin >> n >> k;       if (k == 0) {         cout << 1 << endl;         continue;       }       long long ans = 0, tmp1, tmp2, tt = Pow(2, k);       if (n & 1) {         tmp1 = 1;         for (int i = 0; i <= n; i += 2) tmp1 += calc(i), tmp1 %= Mod;         cout << Pow(tmp1, k) << endl;       } else {         tmp1 = 0, tmp2 = 1, ans = 0;         for (int i = 0; i < n; i += 2) tmp1 += calc(i), tmp1 %= Mod;         ans = Pow(tmp1, k);         for (int i = 1; i <= k; ++i) {           ans += tmp2 * Pow(2, 1ll * (k - i) * n);           ans %= Mod;           tmp2 *= tmp1;           tmp2 %= Mod;         }         cout << ans << endl;       }     }     return 0;   }
#include <bits/stdc++.h>           using namespace std;      const int N = 543;   const long long INF = (long long)(1e18);      struct Matching   {     int n1, n2;     vector<set<int>> g;     vector<int> mt, used;        void init()     {       mt = vector<int>(n2, -1);     }        int kuhn(int x)     {       if(used[x] == 1) return 0;       used[x] = 1;       for(auto y : g[x])        if(mt[y] == -1 || kuhn(mt[y]) == 1)        {          mt[y] = x;          return 1;        }       return 0;     }        int calc()     {       init();       int sum = 0;       for(int i = 0; i < n1; i++)       {        used = vector<int>(n1, 0);        sum += kuhn(i);       }       return sum;     }        void remove_vertex(int v, bool right)     {       if(right)       {        for(int i = 0; i < n1; i++)         g[i].erase(v);       }       else        g[v].clear();     }        void add_edge(int x, int y)     {      g[x].insert(y);     }        Matching() {};     Matching(int n1, int n2) : n1(n1), n2(n2)     {      g.resize(n1);     };   };      int n, m, k;   long long dp[N][N];   int p[N][N];   vector<int> g[N];   long long x[N], y[N];      int main()   {    cin >> n >> m >> k;    for(int i = 0; i < m; i++)    {      int u, v;      cin >> u >> v;      --u;      --v;      g[u].push_back(v);    }    for(int i = 0; i < k; i++)     cin >> x[i] >> y[i];       Matching mt(n, n);    for(int i = 0; i < n; i++)     for(auto j : g[i])      mt.add_edge(i, j);    int cnt = mt.calc();    int cur = cnt;    vector<int> seq;    while(cur > 0)    {     int idx = 0;     for(int i = 0; i < n; i++)     {       Matching mt2 = mt;       mt2.remove_vertex(i, false);       if(mt2.calc() < cur)        idx = i + 1;       mt2 = mt;       mt2.remove_vertex(i, true);       if(mt2.calc() < cur)        idx = -(i + 1);     }     assert(idx != 0);     seq.push_back(idx);     mt.remove_vertex(abs(idx) - 1, idx < 0);     cur--;    }     reverse(seq.begin(), seq.end());    for(int i = 0; i <= k; i++)     for(int j = 0; j <= cnt; j++)      dp[i][j] = -INF;    dp[0][cnt] = 0;    for(int i = 0; i < k; i++)     for(int j = 0; j <= cnt; j++)     {      if(dp[i][j] == -INF) continue;      for(int z = 0; z <= j; z++)      {       if(i + 1 + z >= n) continue;        int t = j - z;        long long add = max(0ll, x[i] - t * y[i]);        if(dp[i + 1][z] < dp[i][j] + add)        {          dp[i + 1][z] = dp[i][j] + add;          p[i + 1][z] = j;        }      }     }    cur = max_element(dp[k], dp[k] + cnt + 1) - dp[k];    vector<int> res;    for(int i = k; i > 0; i--)    {     res.push_back(0);     for(int j = p[i][cur] - 1; j >= cur; j--)      res.push_back(seq[j]);     cur = p[i][cur];     }    reverse(res.begin(), res.end());    cout << res.size() << endl;    for(auto x : res) cout << x <<    ;    cout << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e5 + 100;   int a[maxn], ans[2 * maxn];   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int n, m, c;     cin >> n >> m >> c;     for (int i = 0; i < n; i++) cin >> a[i];     for (int i = 0; i < m; i++) {       int val;       cin >> val;       ans[i] += val;       ans[i + n - m + 1] -= val;     }     ans[0] %= c;     for (int i = 1; i < n; i++) ans[i] = (ans[i] + ans[i - 1]) % c;     for (int i = 0; i < n; i++) cout << ((a[i] + ans[i]) % c + c) % c <<    ;     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct point {     int x, y;     point() {}     point(int _x, int _y) : x(_x), y(_y) {}     point operator-(const point& other) const {       return point(other.x - x, other.y - y);     }     long long operator/(const point& other) const {       return x * 1LL * other.y - y * 1LL * other.x;     }     bool operator<(const point& other) const {       if (x == other.x) return y < other.y;       return x < other.x;     }     bool operator==(const point& other) const {       return x == other.x && y == other.y;     }     bool operator!=(const point& other) const { return !(*this == other); }   };   int gcd(int a, int b) {     while (b != 0) {       int r = a % b;       a = b;       b = r;     }     return a;   }   const int maxn = 4e5 + 5;   int n, c, d;   map<point, int> mp;   vector<point> p;   long long pref[maxn];   void read_input() {     cin >> n >> c >> d;     for (int i = 0; i < n; ++i) {       int x, y;       cin >> x >> y;       x -= c;       y -= d;       int t = gcd(abs(x), abs(y));       x /= t;       y /= t;       if (mp.count(point(x, y)) == 0) p.push_back(point(x, y));       ++mp[point(x, y)];     }   }   int up(point u) {     if (u.y == 0) return u.x > 0;     return u.y > 0;   }   bool cmp(const point& u, const point& v) {     int up_u = up(u), up_v = up(v);     if (up_u == up_v) return u / v > 0;     return up_u > up_v;   }   void init() {     sort(p.begin(), p.end(), cmp);     pref[0] = 0;     for (int i = 0; i < (int)p.size(); ++i) pref[i + 1] = pref[i] + mp[p[i]];   }   point modify(point u) { return point(-u.x, -u.y); }   void solve() {     long long ans = 0;     long long total_cnt = 0;     long long total = 0;     for (int cur = 0, nxt = 0; cur < (int)p.size(); ++cur) {       int t = lower_bound(p.begin(), p.end(), modify(p[cur]), cmp) - p.begin();       if (up(p[cur])) t = 0;       total -= mp[p[cur]] * 1LL * pref[t];       total_cnt -= mp[p[cur]];       while (nxt < (int)p.size() && p[cur] / p[nxt] >= 0 &&              modify(p[cur]) != p[nxt]) {         t = lower_bound(p.begin(), p.end(), modify(p[nxt]), cmp) - p.begin();         if (up(p[nxt])) t = 0;         total += mp[p[nxt]] * 1LL * pref[t];         total_cnt += mp[p[nxt]];         ++nxt;       }       t = upper_bound(p.begin(), p.end(), modify(p[cur]), cmp) - p.begin();       if (up(p[cur])) t = 0;       ans += mp[p[cur]] * 1LL * total;       ans -= mp[p[cur]] * 1LL * pref[t] * total_cnt;     }     cout << ans <<   n ;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr);     read_input();     init();     solve();   }
#include <bits/stdc++.h>   using namespace std;   long long int mod = 1000000007;   long long mod1 = 1000000000000000009;   long long poww(long long x, long long y) {     if (y == 0) return 1;     if (x == 1) return 1;     if (x == 0) return 0;     if (y == 1) return x;     long long d = poww(x, y / 2);     d %= mod;     if (y % 2) return (((d * d) % mod) * x);     return (d * d) % mod;   }   long long combaination(long long n, long long k) {     long long f = 1;     for (long long i = 0; i < k; i++) f *= n - i, f /= i + 1;     return f;   }   long long a[300009];   vector<pair<long long, long long> > v;   int main() {     long long n;     cin >> n;     long long a[n];     long long x = 0, y = 0;     for (long long i = 1; i <= n; i++) cin >> a[i];     long long i = 1;     while (i <= n) {       if (a[i] == i) {         i++;         continue;       }       if (abs(a[i] - i) >= n / 2) {         v.push_back(make_pair(i, a[i]));         swap(a[i], a[a[i]]);       } else {         if ((n - max(i, a[i])) >= n / 2) {           x = i;           y = a[i];           v.push_back(make_pair(x, n));           v.push_back(make_pair(n, y));           v.push_back(make_pair(x, n));           swap(a[x], a[n]);           swap(a[y], a[n]);           swap(a[x], a[n]);         } else if (min(i, a[i]) - 1 >= n / 2) {           x = i;           y = a[i];           v.push_back(make_pair(x, 1));           v.push_back(make_pair(y, 1));           v.push_back(make_pair(x, 1));           swap(a[x], a[1]);           swap(a[y], a[1]);           swap(a[x], a[1]);         } else {           x = i, y = a[i];           if (x > y) swap(x, y);           v.push_back(make_pair(y, 1));           v.push_back(make_pair(x, n));           v.push_back(make_pair(n, 1));           v.push_back(make_pair(y, 1));           v.push_back(make_pair(x, n));           swap(a[y], a[1]);           swap(a[x], a[n]);           swap(a[n], a[1]);           swap(a[y], a[1]);           swap(a[n], a[x]);         }       }     }     cout << v.size() << endl;     for (long long i = 0; i < v.size(); i++)       cout << v[i].first <<     << v[i].second << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   int main() {     ios::sync_with_stdio(0), cin.tie(0);     int tt;     cin >> tt;     while (tt--) {       string s;       cin >> s;       int count = 0;       for (int i = 0; i < s.size(); i++) {         if (s[i] ==  1 ) {           count++;         }       }       int n = s.size();       if (min(count, n - count) % 2 == 1) {         cout <<  DA ;       } else {         cout <<  NET ;       }       cout <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m;     cin >> n >> m;     vector<long long> f(n);     int u, v;     long long z;     while (m--) {       cin >> u >> v >> z;       f[--u] -= z;       f[--v] += z;     }     vector<long long> a, b;     for (int i = 0; i < n; i++)       if (f[i] > 0)         a.push_back(i);       else if (f[i] < 0)         b.push_back(i);     vector<vector<long long> > ans;     int id = 0;     for (int i = 0; i < a.size(); i++) {       while (id < b.size() && f[a[i]] > 0) {         long long x = min(f[a[i]], -f[b[id]]);         f[a[i]] -= x;         f[b[id]] += x;         ans.push_back({b[id], a[i], x});         if (f[b[id]] == 0) id++;       }     }     cout << ans.size() <<   n ;     for (auto x : ans) cout << x[0] + 1 <<     << x[1] + 1 <<     << x[2] <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 100010;   const int mod = 1e9 + 7;   int n, m, T, k;   int f[80][80][80][80], g[80][80];   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> n >> m >> k;     for (int i = 1; i <= n; i++)       for (int j = 1; j <= m; j++) cin >> g[i][j];     memset(f, -1, sizeof f);     f[1][0][0][0] = 0;     for (int i = 1; i <= n; i++)       for (int j = 0; j <= m; j++)         for (int l = 0; l <= m / 2; l++) {           for (int r = 0; r < k; r++) {             if (j >= 1) {               f[i][j][l][r] = max(f[i][j][l][r], f[i][j - 1][l][r]);               if (f[i][j - 1][l][r] != -1)                 f[i][j][l + 1][(r + g[i][j]) % k] =                     max(f[i][j][l + 1][(r + g[i][j]) % k],                         f[i][j - 1][l][r] + g[i][j]);             }           }           for (int r = 0; r < k; r++)             f[i + 1][0][0][r] = max(f[i + 1][0][0][r], f[i][j][l][r]);         }     cout << max(0, f[n + 1][0][0][0]) << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string s;     long n, i, k = 0, u = 0, d = 0, l = 0, r = 0;     cin >> n;     cin >> s;     for (i = 0; i < s.size(); i++) {       if (s[i] ==  U ) u++;       if (s[i] ==  D ) d++;       if (s[i] ==  L ) l++;       if (s[i] ==  R ) r++;     }     k += min(d, u) * 2;     k += min(r, l) * 2;     cout << k;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T1, typename T2>   istream& operator>>(istream& in, pair<T1, T2>& a) {     in >> a.first >> a.second;     return in;   }   template <typename T1, typename T2>   ostream& operator<<(ostream& out, pair<T1, T2> a) {     out << a.first <<     << a.second;     return out;   }   template <typename T, typename T1>   T amax(T& a, T1 b) {     if (b > a) a = b;     return a;   }   template <typename T, typename T1>   T amin(T& a, T1 b) {     if (b < a) a = b;     return a;   }   const long long fx[] = {+1, -1, +0, +0};   const long long fy[] = {+0, +0, +1, -1};   const int32_t M = 1e9 + 7;   const int32_t MM = 998244353;   void solve() {     long long n;     cin >> n;     vector<long long> a(n), b(n);     for (long long i = 0; i < n; i++) {       cin >> a[i];     }     for (long long i = 0; i < n; i++) {       cin >> b[i];     }     vector<long long> points(n, 1);     long long only_a = 0;     long long pa = 0, push_back = 0;     for (long long i = 0; i < n; i++) {       if (a[i] == 1 && b[i] == 0) {         only_a++;       }       if (a[i] == 1) pa++;       if (b[i] == 1) push_back++;     }     if (pa > push_back) {       cout << 1 <<   n ;       return;     } else if (only_a == 0 && pa <= push_back) {       cout << -1 <<   n ;     } else {       long long diff = push_back - pa + 1;       long long x = 1 + diff / only_a;       if (diff % only_a != 0) x++;       cout << x <<   n ;     }   }   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long t = 1;     while (t--) solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long gcd(long long a, long long b) {     if (b == 0) return a;     return gcd(b, a % b);   }   bool isPrime(long long n) {     if (n < 2) return 0;     if (n < 4) return 1;     if (n % 2 == 0 or n % 3 == 0) return 0;     for (long long i = 5; i * i <= n; i += 6)       if (n % i == 0 or n % (i + 2) == 0) return 0;     return 1;   }   long long modexpo(long long x, long long p) {     long long res = 1;     x = x % 1000000007;     while (p) {       if (p % 2) res = res * x;       p >>= 1;       x = x * x % 1000000007;       res %= 1000000007;     }     return res;   }   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long t = 1;     cin >> t;     while (t--) {       long long n, g, b;       cin >> n >> g >> b;       long long x = n / 2 + (n % 2);       long long ans = 0;       ans += (x / g) * g + ((x / g + (x % g ? 1 : 0)) - 1) * b;       ans += x % g;       if (n > ans) ans += n - ans;       cout << ans <<   n ;     }   }