malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int maxn = 3e5 + 10;   const int INF = 1e9;   vector<int> p[maxn];   bool vis[maxn];   int nmultiple[maxn], N, tag[maxn], a[maxn];   int gcd(int x, int y) { return x == 0 ? y : gcd(y % x, x); }   int main() {     for (int i = 2; i < maxn; ++i) {       if (!vis[i]) {         for (int j = i; j < maxn; j += i) {           vis[j] = 1;           p[j].push_back(i);         }       }     }     scanf( %d , &N);     for (int i = 1; i <= N; ++i) {       scanf( %d , &a[i]);       int x = 1;       for (int j : p[a[i]]) x *= j;       a[i] = x;       tag[a[i]] = 1;     }     if (tag[1]) {       printf( 1 n );       return 0;     }     int d = a[1];     for (int i = 1; i <= N; ++i) d = gcd(d, a[i]);     if (d > 1) {       printf( -1 n );       return 0;     }     for (int i = 1; i < maxn; ++i) {       for (int j = i; j < maxn; j += i) {         nmultiple[i] += tag[j];       }     }     int ans = INF;     for (int i = 1; i <= N; ++i) {       int v = a[i], sz = p[v].size(), up = (1 << sz) - 1;       vector<int> DP(up + 1, INF), mp(up + 1, 0);       vector<vector<int>> ways(up + 1, vector<int>(sz + 1));       for (int mask = 0; mask <= up; ++mask) {         int x = 1;         for (int j = 0; j < sz; ++j) {           if (mask >> j & 1) {             x *= p[v][j];           }         }         mp[mask] = x;         ways[mask][0] = nmultiple[x];       }       for (int j = 0; j < sz; ++j) {         for (int mask = 0; mask <= up; ++mask) {           int pmask = mask ^ (1 << j);           ways[pmask][j + 1] = ways[pmask][j];           if (mask >> j & 1) {             ways[pmask][j + 1] -= ways[mask][j];           }         }       }       DP[up] = 1;       for (int mask = up; mask >= 0; --mask) {         for (int pick = 0; pick <= up; ++pick) {           if (ways[pick][sz]) {             DP[mask & pick] = min(DP[mask & pick], DP[mask] + 1);           }         }       }       ans = min(ans, DP[0]);     }     printf( %d n , ans);   }
#include <bits/stdc++.h>   using namespace std;   long long f[203][203][2], g[203][203][2], A[203], B[203], C[203], SA[203],       SB[203], N, T, K;   int main() {     cin >> N >> T >> K;     for (int i = 1; i <= N; ++i) cin >> A[i] >> B[i] >> C[i];     ++N;     A[N] = C[N] = 1e15;     memset(f, 0x3f, sizeof(f));     memset(g, 0x3f, sizeof(g));     for (int i = 1; i <= N; ++i) {       SA[i] = SA[i - 1] + A[i];       SB[i] = SB[i - 1] + B[i];     }     memset(f[0], 0, sizeof(f[0]));     memset(g[0], 0, sizeof(g[0]));     for (int i = 1; i <= N; ++i)       for (int j = 0; j <= T; ++j)         for (int k = 0; k <= 1; ++k) {           if (k * A[i] + B[i] * j <= C[i] && f[i - 1][j][k] <= 1e15) {             f[i][j][k] = f[i - 1][j][k];             long long vl = (k * SA[i - 1] + j * SB[i - 1] + K - 1) / K;             if (vl * K <= k * SA[i] + j * SB[i]) g[i][j][k] = vl;           }           for (int l = 0; l < j; ++l) {             long long stp = g[i][l][k];             if (stp > 1e15) continue;             long long lft = SA[i] * k + SB[i] * l - stp * K,                       need = max((lft + (j - l) * B[i] - C[i] + K - 1) / K, 0ll);             if (need * K > lft) continue;             if (f[i - 1][j - l][0] > 1e15) continue;             f[i][j][k] = min(f[i][j][k], stp + need + f[i - 1][j - l][0]);             long long vl = ((j - l) * SB[i - 1] + K - 1) / K;             if (vl * K > lft - need * K + vl * SB[i]) continue;             g[i][j][k] = min(g[i][j][k], stp + need + vl);           }         }     cout << f[N][T][1] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int A[100000];   void solve() {     int n;     cin >> n;     int prv = -1;     for (int i = 0; i < (n); i++) cin >> A[i];     int res = 1;     for (int i = 0; i < (n); i++) {       int x = A[i];       ;       ;       if (x == 0) {         if (prv == 0) {           cout <<  -1 n ;           return;         }       } else {         if (prv != 1) {           res++;         } else {           res += 5;         }       }       prv = x;     }     cout << res <<   n ;   }   int main() {     ios_base::sync_with_stdio(0), cout.setf(ios::fixed), cout.precision(10),         cin.tie(0), cout.tie(0);     ;     int t;     cin >> t;     while (t--) solve();   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);     int n, i, lim, cnt = 0, other = 0;     string str;     cin >> n >> str;     lim = str.size();     int petya = (n - 11) / 2;     for (i = 0; i < lim; i++) {       if (str[i] ==  8 )         cnt++;       else         other++;       if (cnt > petya) break;     }     if (cnt > petya && other <= petya)       cout <<  YES  << endl;     else       cout <<  NO  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int a, b;     cin >> a >> b;     int ans = a;     while (a >= b) {       int t = a / b;       ans += t;       a = t + (a - b * t);     }     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     ;     int n, a, b;     cin >> n >> a >> b;     string s;     cin >> s;     if (s[a - 1] == s[b - 1])       cout << 0 <<   n ;     else {       cout << 1 <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long t, a, b, x;     cin >> t;     while (t--) {       cin >> a >> b;       if (a == b) {         cout << 0 << endl;         continue;       }       if (a < b) {         x = (b / 10) - (a / 10);       } else {         x = (a / 10) - (b / 10);       }       if (a + x * 10 < b || b + x * 10 < a)         cout << x + 1 << endl;       else         cout << x << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 0x3fffffff;   const int SINF = 0x7fffffff;   const long long LINF = 0x3fffffffffffffff;   const long long SLINF = 0x7fffffffffffffff;   const int MAXN = 1007;   const int MAXS = 107;   const int MAXM = 13;   const int MAXL = 13;   const int BASE = 4;   const int MOD = 1e9 + 9;   int toid[128];   int n, m, kn, ml;   char s[MAXM][MAXL];   int nxt[MAXS][BASE], fail[MAXS], q[MAXS];   int ok[MAXS];   int tag[MAXS];   int dp[MAXN][MAXL][MAXS];   void init();   void input();   void work();   void trie_add(char s[]);   void buildac();   int main() {     init();     input();     work();   }   void init() {     ios::sync_with_stdio(false);     toid[ A ] = 0;     toid[ C ] = 1;     toid[ G ] = 2;     toid[ T ] = 3;   }   void input() {     scanf( %d%d , &n, &m);     for (int i = 0; i < m; ++i) scanf( %s , s[i]);   }   void work() {     kn = 1;     memset(nxt, -1, sizeof(nxt));     memset(tag, 0, sizeof(tag));     for (int i = 0; i < m; ++i)       trie_add(s[i]), ml = (((ml) > (strlen(s[i]))) ? (ml) : (strlen(s[i])));     buildac();     ++ml;     memset(dp, 0, sizeof(dp));     dp[0][0][0] = 1;     int v, nj, nl;     for (int i = 0; i < n; ++i) {       for (int j = 0; j < ml; ++j) {         for (int k = 0; k < kn; ++k) {           if (dp[i][j][k]) {             for (int nc = 0; nc < BASE; ++nc) {               v = nxt[k][nc];               nj = j + 1;               if (tag[v] || ok[v]) {                 if (tag[v])                   nl = tag[v];                 else                   nl = tag[ok[v]];                 if (nl >= nj) nj = 0;               }               dp[i + 1][nj][v] += dp[i][j][k];               dp[i + 1][nj][v] %= MOD;             }           }         }       }     }     int sum = 0;     for (int i = 0; i < kn; ++i) {       sum += dp[n][0][i];       sum %= MOD;     }     printf( %d n , sum);   }   void trie_add(char s[]) {     int len = strlen(s), now = 0, nc;     for (int i = 0; i < len; ++i) {       nc = toid[s[i]];       if (nxt[now][nc] ^ -1)         now = nxt[now][nc];       else         now = nxt[now][nc] = kn++;     }     tag[now] = len;   }   void buildac() {     int l = 0, r = 0, now, v, f;     q[r++] = 0;     fail[0] = 0;     while (l < r) {       now = q[l++];       for (int i = 0; i < BASE; ++i) {         if (nxt[now][i] ^ -1) {           v = nxt[now][i];           q[r++] = v;           f = fail[now];           while (f && nxt[f][i] == -1) f = fail[f];           fail[v] = (now && nxt[f][i] ^ -1) ? nxt[f][i] : 0;         } else           nxt[now][i] = (nxt[fail[now]][i] ^ -1) ? nxt[fail[now]][i] : 0;       }       f = fail[now];       while (f && !tag[f]) f = ok[f];       ok[now] = f;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int n, m, k;     cin >> n >> m >> k;     long long int a[m];     for (int i = 0; i < m; i++) cin >> a[i];     long long int s = 0, S = 0;     for (int i = 0; i < m; i++) {       long long int d;       if ((a[i] - s) % k == 0)         d = (a[i] - s) / k - 1;       else         d = (a[i] - s) / k;       int z = i;       long long int K = s;       while (1) {         long long int D;         if ((a[z] - K) % k == 0)           D = (a[z] - K) / k - 1;         else           D = (a[z] - K) / k;         if (D != d) break;         s++;         z++;         if (z == m) break;       }       S++;       i = z - 1;     }     cout << S;     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( O3 )   #pragma comment(linker,  /stack:200000000 )   #pragma GCC optimize( unroll-loops )   using namespace std;   const long long mod = 998244353;   const long long sz = 2e5 + 9;   long long gcd(long long a, long long b) {     if (b == 0) return a;     return gcd(b, a % b);   }   long long BL[200002];   struct query {     long long l, r, idx;     bool operator<(const query &rhs) {       return (BL[l] == BL[rhs.l]) ? (r < rhs.r) : (BL[l] < BL[rhs.l]);     }   };   long long power(long long x, long long y, long long p) {     long long res = 1;     x = x % p;     while (y > 0) {       if (y & 1) {         res = (res * x) % p;       }       y = y >> 1;       x = (x * x) % p;     }     return res;   }   void ruk_teri_maa_chodtha_hu() {     int n, m;     cin >> n;     vector<pair<long long, long long> > v(n);     for (long long i = 0; i < n; i++) {       cin >> m;       v[i] = {m, i};     }     long long prev = v[0].first, f = 0;     for (long long i = 1; i < n; i++) {       if (prev > v[i].first) {         f = 1;         break;       }       prev = v[i].first;     }     if (f == 0) {       cout << 0 <<   n ;       return;     }     sort(v.begin(), v.end());     long long ans = 0, c = 1;     for (long long i = 1; i < n; i++) {       if (v[i - 1].first <= v[i].first && v[i - 1].second < v[i].second)         c++;       else         c = 1;       ans = max(c, ans);     }     cout << n - ans <<   n ;   }   void solve() {     long long tc;     cin >> tc;     while (tc--) ruk_teri_maa_chodtha_hu();   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     clock_t beg = clock();     solve();     clock_t end = clock();     fprintf(stderr,  %.3f sec, Copyright %c 2019 PyThor.  n ,             double(end - beg) / CLOCKS_PER_SEC, 184);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cout.setf(ios::fixed);     cout.precision(20);     const int MAX_N = (int)1e7;     vector<bool> isPrime(MAX_N, true);     isPrime[1] = false;     for (int i = 2; i < MAX_N; i++) {       if (isPrime[i]) {         for (int j = 2 * i; j < MAX_N; j += i) {           isPrime[j] = false;         }       }     }     int n, m;     cin >> n >> m;     long long sum = 0;     vector<set<int>> has(n + 10);     vector<int> u, v, w;     auto push = [&](int a, int b, int c) {       u.push_back(a);       v.push_back(b);       w.push_back(c);       has[a].insert(b);       has[b].insert(a);       m--;       sum += c;     };     push(1, n, 2);     for (int i = 1; i + 1 < n; i++) {       if (i + 1 == n - 1) {         int w = 2;         while (!isPrime[sum + w]) {           w++;         }         push(i, i + 1, w);         break;       }       push(i, i + 1, 2);     }     assert(isPrime[sum]);     cout << 2 <<     << sum <<   n ;     for (int i = 1; i <= n && m > 0; i++) {       for (int j = i + 1; j <= n && m > 0; j++) {         if (has[i].count(j)) {           continue;         }         const int MAX_VALUE = (int)1e8;         push(i, j, MAX_VALUE);       }     }     for (int i = 0; i < ((int)(u).size()); i++) {       cout << u[i] <<     << v[i] <<     << w[i] <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   bool umin(T& a, T b) {     if (a > b) {       a = b;       return 1;     }     return 0;   }   template <class T>   bool umax(T& a, T b) {     if (a < b) {       a = b;       return 1;     }     return 0;   }   const int N = 1e2 + 9;   char s[N], t[N];   int dp[N][N], sz, n, k, par[N], pw[N];   pair<int, int> way[N][N];   int mod(long long x) {     while (x < 0) x += 1000000007;     return (x % 1000000007);   }   int get(int x, int y) {     if (x > y) return 0;     return mod(par[y] - mod(par[x - 1] * 1LL * pw[y - x + 1]));   }   int rec(int x, int y) {     if (x > sz) {       if (t[x - sz] ==  1  and y != sz) return 0;       if (t[x - sz] ==  0  and y == sz) return 0;     }     if (x > n) return 1;     int& ret = dp[x][y];     if (~ret) return ret;     ret = 0;     for (int i = 0; i < k; i++) {       int len = 0;       for (int j = min(y + 1, sz); j >= 1; j--)         if (mod(get(y - j + 2, y) * 27LL + i + 1) == par[j]) {           len = j;           break;         }       if (rec(x + 1, len)) {         way[x][y] = make_pair(i, len);         return ret = 1;       }     }     return 0;   }   int main() {     memset(dp, -1, sizeof dp);     scanf( %d%d , &n, &k);     scanf( %s , s + 1);     sz = strlen(s + 1);     pw[0] = 1;     for (int i = 1; i <= sz; i++) {       par[i] = mod(par[i - 1] * 27LL + (s[i] -  a  + 1));       pw[i] = mod(pw[i - 1] * 27LL);     }     scanf( %s , t + 1);     if (!rec(1, 0)) return 0 * puts( No solution );     int now = 0;     for (int i = 1; i <= n; i++) {       printf( %c , char(way[i][now].first + 97));       now = way[i][now].second;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long kkk, kk, otv = 0;     string ss;     long long i, a;     cin >> a;     for (i = 0; i < a; i++) {       long long s1, s2, s3;       cin >> s1 >> s2 >> s3;       if ((s1 > s2 + s3 + 1) || (s2 > s1 + s3 + 1) || (s3 > s1 + s2 + 1))         cout <<  No  << endl;       else         cout <<  Yes  << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n, k, i;     while (scanf( %lld%lld , &n, &k) != EOF) {       long long a[k + 1];       vector<pair<long long, long long> > v;       for (i = 0; i < k; i++) {         cin >> a[i], v.push_back(make_pair((n % a[i]), i + 1));       }       sort(v.rbegin(), v.rend());       int j = v[k - 1].second;       cout << j <<     << (n / a[j - 1]) << endl;     }     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize(3)   #pragma GCC optimize(2)   using namespace std;   const int maxn = 510;   const int inf32 = 1e9 + 10;   const long long inf64 = 1e18 + 10;   const int mod = 998244353;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     int N;     cin >> N;     vector<long long> a(N), b(N);     for (int i = 0; i < N; ++i) cin >> a[i];     sort(a.begin(), a.end());     for (int i = 0; i < N; ++i) b[i] = a[N - 1] - a[i];     vector<vector<long long>> dp(65, vector<long long>(N + 1, inf64));     vector<vector<int>> sum(N + 1, vector<int>(2));     dp[0][0] = 0;     for (int i = 1; i <= 63; ++i) {       int current_bit = i - 1;       vector<int> p(N);       for (int j = 0; j < N; ++j) p[j] = j;       sort(p.begin(), p.end(), [&](int& l, int& r) {         return b[l] % (1ll << current_bit) < b[r] % (1ll << current_bit);       });       for (int j = 0; j <= N; ++j) {         for (int k = 0; k < 2; ++k) {           sum[j][k] = 0;         }       }       for (int j = 1; j <= N; ++j) {         ++sum[j][b[p[j - 1]] >> current_bit & 1];       }       for (int j = 1; j <= N; ++j) {         for (int k = 0; k < 2; ++k) {           sum[j][k] += sum[j - 1][k];         }       }       for (int j = 0; j <= N; ++j) {         int new_carry = sum[N][1] - sum[N - j][1];         int cost = sum[N - j][1] + sum[N][0] - sum[N - j][0];         dp[i][new_carry] = min(dp[i][new_carry], dp[i - 1][j] + cost);         new_carry =             sum[N][1] - sum[N - j][1] + sum[N][0] - sum[N - j][0] + sum[N - j][1];         cost = sum[N - j][0] + sum[N][1] - sum[N - j][1];         dp[i][new_carry] = min(dp[i][new_carry], dp[i - 1][j] + cost);       }     }     cout << dp[63][0] << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e5 + 10;   bool bad[(1 << 20) + 10];   int belong[maxn], frequent[21];   int main() {     int n, m, d;     scanf( %d%d%d , &n, &m, &d);     for (int i = 0; i < m; i++) {       int s, x;       scanf( %d , &s);       while (s--) {         scanf( %d , &x);         belong[x] = i;       }     }     for (int i = 1; i <= n; i++) {       if (i > d) frequent[belong[i - d]]--;       frequent[belong[i]]++;       if (i >= d) {         int mask = 0;         for (int j = 0; j < m; j++) {           if (!frequent[j]) {             mask |= (1 << j);           }         }         bad[mask] = 1;       }     }     int ans = m + 1;     for (int i = (1 << m) - 1; i >= 0; i--) {       if (bad[i]) {         for (int j = 0; j < m; j++) {           if (i & (1 << j)) bad[i ^ (1 << j)] = 1;         }       } else         ans = min(ans, __builtin_popcount(i));     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       string a;       cin >> a;       int ans = 0;       vector<int> vc;       for (size_t i = 0; i < a.size(); i++) {         if (a[i] ==  w  && a[i - 1] ==  t  && a[i + 1] ==  o  &&             a[i + 2] ==  o  && i > 0 && i < a.size() - 2) {           ans++;           vc.push_back(i + ans);           a.erase(a.begin() + i);         } else if (a[i] ==  o  && a[i - 1] ==  w  && a[i - 2] ==  t  && i > 1) {           ans++;           vc.push_back(i + ans);           a.erase(a.begin() + i);         } else if (a[i] ==  n  && a[i - 1] ==  o  && a[i + 1] ==  e  &&                    i < a.size() - 1 && i) {           ans++;           vc.push_back(i + ans);           a.erase(a.begin() + i);         }       }       cout << ans << endl;       for (auto i : vc) {         cout << i <<    ;       }       cout << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 1e9 + 7;   struct SD {     int x, y, c;   } p, pp;   int f[50000], bk[110][110];   int n, m, k, maxx, ans, cur, sum, x, y;   int minn;   int nex[4][2] = {0, 1, 1, 0, 0, -1, -1, 0};   char mapp[1100][1100];   queue<struct SD> q;   int bfs(int x, int y) {     while (q.size()) q.pop();     p.x = x, p.y = y, p.c = 0;     q.push(p);     ans = 1;     memset(bk, 0, sizeof(bk));     ;     bk[x][y] = 1;     while (q.size()) {       p = q.front();       q.pop();       if (p.c > 1) return ans < sum;       for (int i = p.x; i < n; i++) {         if (mapp[i][p.y] ==  B ) {           if (bk[i][p.y]) continue;           pp.x = i, pp.y = p.y, pp.c = p.c + 1;           bk[pp.x][pp.y] = 1;           ans++;           q.push(pp);         } else           break;       }       for (int i = p.x; i >= 0; i--) {         if (mapp[i][p.y] ==  B ) {           if (bk[i][p.y]) continue;           ans++;           pp.x = i, pp.y = p.y, pp.c = p.c + 1;           bk[pp.x][pp.y] = 1;           q.push(pp);         } else           break;       }       for (int i = p.y; i < m; i++) {         if (mapp[p.x][i] ==  B ) {           if (bk[p.x][i]) continue;           pp.x = p.x, pp.y = i, pp.c = p.c + 1;           ans++;           bk[pp.x][pp.y] = 1;           q.push(pp);         } else           break;       }       for (int i = p.y; i >= 0; i--) {         if (mapp[p.x][i] ==  B ) {           if (bk[p.x][i]) continue;           pp.x = p.x, pp.y = i, pp.c = p.c + 1;           ans++;           bk[pp.x][pp.y] = 1;           q.push(pp);         } else           break;       }     }     return ans < sum;   }   int main() {     while (cin >> n >> m) {       cur = sum = 0;       for (int i = 0; i < n; i++) scanf( %s , mapp[i]);       for (int i = 0; i < n; i++) {         for (int j = 0; j < m; j++) {           if (mapp[i][j] ==  B ) {             sum++;           }         }       }       for (int i = 0; i < n; i++) {         for (int j = 0; j < m; j++) {           if (mapp[i][j] ==  B ) {             if (bfs(i, j)) {               cur = 1;               break;             }           }         }         if (cur) break;       }       if (cur)         cout <<  NO  << endl;       else         cout <<  YES  << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     int test;     cin >> test;     while (test--) {       int n;       cin >> n;       string s;       cin >> s;       for (int i = 0; i < n; i++) {         if (s[i] !=  ? ) {           int j = i - 1;           while (j >= 0 && s[j] ==  ? ) {             if (s[j + 1] ==  R ) {               s[j] =  B ;             } else {               s[j] =  R ;             }             j--;           }         }       }       reverse((s).begin(), (s).end());       for (int i = 0; i < n; i++) {         if (s[i] !=  ? ) {           int j = i - 1;           while (j >= 0 && s[j] ==  ? ) {             if (s[j + 1] ==  R ) {               s[j] =  B ;             } else {               s[j] =  R ;             }             j--;           }         }       }       reverse((s).begin(), (s).end());       if (s[0] ==  ? ) {         for (int i = 0; i < n; i++) {           if (i % 2) {             s[i] =  R ;           } else {             s[i] =  B ;           }         }       }       cout << s <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   using namespace chrono;   long long mod_add(long long a, long long b, long long m) {     a = a % m;     b = b % m;     return (((a + b) % m) + m) % m;   }   long long mod_mul(long long a, long long b, long long m) {     a = a % m;     b = b % m;     return (((a * b) % m) + m) % m;   }   long long mod_sub(long long a, long long b, long long m) {     a = a % m;     b = b % m;     return (((a - b) % m) + m) % m;   }   long long power(long long x, long long y, long long p) {     long long res = 1;     x = x % p;     while (y > 0) {       if (y & 1) res = (res * x) % p;       y = y >> 1;       x = (x * x) % p;     }     return res;   }   long long modInverse(long long n, long long p) { return power(n, p - 2, p); }   long long nCrMODp(long long n, long long r, long long p) {     if (n < r) return 0;     if (r == 0) return 1;     long long fac[n + 1];     fac[0] = 1;     for (int i = 1; i <= n; i++) fac[i] = (fac[i - 1] * i) % p;     return (fac[n] * modInverse(fac[r], p) % p * modInverse(fac[n - r], p) % p) %            p;   }   void divisors(int n) {     for (int i = 1; i <= sqrt(n); i++) {       if (n % i == 0) {         if (n / i == i)           cout <<     << i;         else           cout <<     << i <<     << n / i;       }     }   }   void primeFactors(int n) {     while (n % 2 == 0) {       cout << 2 <<    ;       n = n / 2;     }     for (int i = 3; i <= sqrt(n); i = i + 2) {       while (n % i == 0) {         cout << i <<    ;         n = n / i;       }     }     if (n > 2) cout << n <<    ;   }   void solve() {     int t;     cin >> t;     cin.ignore();     while (t--) {       int i, x = 0, y = 0;       string str;       cin >> str;       for (i = 0; i < str.size(); i++) str[i] ==  B  ? x++ : y++;       y == x ? cout <<  YES n  : cout <<  NO n ;     }     return;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     auto start1 = high_resolution_clock::now();     solve();     auto stop1 = high_resolution_clock::now();     auto duration = duration_cast<microseconds>(stop1 - start1);     return 0;   }