malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   long long pw(long long base, long long e) {     return e ? pw(base * base, e / 2) * (e % 2 ? base : 1) : 1;   }   long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }   long long to_int(string s) {     long long ret = 0;     for (int i = 0; i <= s.size(); i++) {       ret += pw(10, s.size() - i - 1) * (long long)(s[i] -  0 );     }     return ret;   }   const int maxn = 1e5 + 10, mod = 1e9 + 7;   const long long INF = 1e9;   long long n;   long long f(long long x) { return (n - x) / (2 * x); }   int main() {     cin >> n;     n--;     long long ans = 0;     for (int i = 0; i <= log2(n); i++) {       ans += pw(2, i) * (f(pw(2, i)) + 1);     }     return cout << ans <<   n , 0;   }
#include <bits/stdc++.h>   using namespace std;   const double PI = acos(-1);   const long long mod = 1e9 + 7;   const long long N = 2e5 + 5, K = 105;   const int si = (1 << 20);   const long long add = 1e4;   const long long M = 100 + 5;   const double INFdb = 1e10;   int t;   int n;   vector<int> a[N];   priority_queue<int, vector<int>, greater<int> > pq;   void reset() {     for (int i = 0; i < n; ++i) a[i].clear();     while (!pq.empty()) pq.pop();   }   void solve() {     cin >> n;     reset();     for (int i = 0; i < n; ++i) {       int m, c;       cin >> m >> c;       a[m].push_back(c);     }     long long sum = 0;     int used = 0;     int smartNum = n;     for (int i = n - 1; i >= 0; --i) {       for (int x : a[i]) pq.push(x);       smartNum -= (int)a[i].size();       while (smartNum + used < i && !pq.empty()) {         sum += pq.top();         pq.pop();         ++used;       }     }     cout << sum <<   n ;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(0);     cin >> t;     while (t--) {       solve();     }     cerr <<   nTime elapsed:   << 1000 * clock() / CLOCKS_PER_SEC <<  ms n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m;   int l[100500];   int r[100500];   int val[100500];   int t[400500];   int t2[400500];   int mas[100500];   int INF = 0;   void build(int v, int tl, int tr) {     if (tl == tr)       t[v] = 0;     else {       int mid = (tl + tr) >> 1;       build(v << 1, tl, mid);       build((v << 1) + 1, mid + 1, tr);       t[v] = 0;     }   }   void update(int v, int tl, int tr, int ql, int qr, int nval) {     if (ql > qr) return;     if (tl == ql && tr == qr) {       t[v] = t[v] | nval;     } else {       int mid = (tl + tr) >> 1;       update(v << 1, tl, mid, ql, min(qr, mid), nval);       update((v << 1) + 1, mid + 1, tr, max(ql, mid + 1), qr, nval);     }   }   void dfs(int v, int tl, int tr, int curr) {     if (tl == tr) {       mas[tl] = curr | t[v];     } else {       int mid = (tl + tr) >> 1;       dfs(v << 1, tl, mid, curr | t[v]);       dfs((v << 1) + 1, mid + 1, tr, curr | t[v]);     }   }   void build2(int v, int tl, int tr) {     if (tl == tr) {       t[v] = mas[tl];     } else {       int mid = (tl + tr) >> 1;       build2(v << 1, tl, mid);       build2((v << 1) + 1, mid + 1, tr);       t[v] = t[v << 1] & t[(v << 1) + 1];     }   }   int query(int v, int tl, int tr, int ql, int qr) {     if (ql > qr) return INF;     if (tl == ql && tr == qr) {       return t[v];     } else {       int mid = (tl + tr) >> 1;       return query(v << 1, tl, mid, ql, min(qr, mid)) &              query((v << 1) + 1, mid + 1, tr, max(ql, mid + 1), qr);     }   }   int main() {     for (int i = 29; i >= 0; i--) {       INF += (1 << i);     }     cin >> n >> m;     build(1, 1, n);     for (int i = 0; i < m; i++) {       cin >> l[i] >> r[i] >> val[i];       update(1, 1, n, l[i], r[i], val[i]);     }     dfs(1, 1, n, 0);     build2(1, 1, n);     for (int i = 0; i < m; i++) {       if (query(1, 1, n, l[i], r[i]) != val[i]) {         cout <<  NO ;         return 0;       }     }     cout <<  YES n ;     for (int i = 1; i <= n; i++) cout << mas[i] <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n, d, f;     cin >> n;     if (n % 3 == 2)       d = n / 3 + 1;     else       d = n / 3;     f = d / 12;     d = d % 12;     cout << f <<     << d << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   inline void read(T &x) {     x = 0;     char c = getchar(), f = 0;     for (; c <  0  || c >  9 ; c = getchar())       if (c ==  - ) f = 1;     for (; c >=  0  && c <=  9 ; c = getchar())       x = (x << 1) + (x << 3) + (c ^ 48);     if (f) x = -x;   }   int n, m, K, a[2000005][5];   char ch[2000005];   long long N, M;   inline void solve() {     read(n);     if (n % 3 == 0)       printf( %d %d n , n / 3, n / 3);     else if (n % 3 == 1)       printf( %d %d n , n / 3 + 1, n / 3);     else       printf( %d %d n , n / 3, n / 3 + 1);   }   int main() {     int Ca;     for (read(Ca); Ca--;) solve();     return 0;   }
#include <bits/stdc++.h>   const int M = 1000005;   long long f[M];   int A[M];   int n;   int Min(int a, int b) { return a < b ? a : b; }   int Max(int a, int b) { return a < b ? b : a; }   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; ++i) scanf( %d , A + i);     long long ans = 0;     A[0] = 1;     for (int i = 1; i <= n; ++i) {       (ans += A[i] - 1) %= 1000000007;       (ans += f[i - 1] * (Min(A[i], A[i - 1]) - 1)) %= 1000000007;       (f[i] += Min(A[i], A[i + 1]) - 1) %= 1000000007;       (f[i] += Max(0, Min(Min(A[i], A[i - 1]), A[i + 1]) - 1) * f[i - 1]) %=           1000000007;     }     printf( %lld n , (ans + 1000000007) % 1000000007);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2000;   vector<array<int, 2>> que;   int degree[N][N], n, m;   string grid[N];   bool valid(int i, int j) {     return i >= 0 && i < n && j >= 0 && j < m && grid[i][j] ==  . ;   }   void update(int i, int j) {     if (i >= 0 && i < n && j >= 0 && j < m) {       degree[i][j] = 0;     }     if (valid(i - 1, j) && ++degree[i - 1][j] == 3) {       que.push_back({i - 1, j});     }     if (valid(i + 1, j) && ++degree[i + 1][j] == 3) {       que.push_back({i + 1, j});     }     if (valid(i, j - 1) && ++degree[i][j - 1] == 3) {       que.push_back({i, j - 1});     }     if (valid(i, j + 1) && ++degree[i][j + 1] == 3) {       que.push_back({i, j + 1});     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr);     cin >> n >> m;     for (int i = 0; i < n; ++i) {       cin >> grid[i];     }     for (int i = 0; i < n; ++i) {       update(i, -1), update(i, m);     }     for (int i = 0; i < m; ++i) {       update(-1, i), update(n, i);     }     for (int i = 0; i < n; ++i) {       for (int j = 0; j < m; ++j) {         if (grid[i][j] ==  * ) {           update(i, j);         }       }     }     while (!que.empty()) {       auto [i, j] = que.back();       que.pop_back();       if (degree[i][j] == 0) {         continue;       } else if (degree[i][j] == 4) {         cout <<  Not unique n ;         exit(0);       }       if (valid(i - 1, j)) {         grid[i - 1][j] =  ^ , grid[i][j] =  v ;         update(i - 1, j);       } else if (valid(i + 1, j)) {         grid[i][j] =  ^ , grid[i + 1][j] =  v ;         update(i + 1, j);       } else if (valid(i, j - 1)) {         grid[i][j - 1] =  < , grid[i][j] =  > ;         update(i, j - 1);       } else {         grid[i][j] =  < , grid[i][j + 1] =  > ;         update(i, j + 1);       }       update(i, j);     }     for (int i = 0; i < n; ++i) {       if (count(grid[i].begin(), grid[i].end(),  . ) > 0) {         cout <<  Not unique n ;         exit(0);       }     }     for (int i = 0; i < n; ++i) {       cout << grid[i] <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   set<string> st;   set<string>::iterator it1;   vector<int> dp2(20000, 0), dp3(20000, 0);   void solve(string s, int i, string prev) {     if (i < 1) return;     if (i == 1) {       string a = s.substr(i - 1, 2);       if (a != prev)         st.insert(a);       else         return;     } else {       string temp;       string a = s.substr(i - 1, 2);       string b = s.substr(i - 2, 3);       if (a != prev && !dp2[i]) {         dp2[i] = 1;         temp = a;         solve(s, i - 2, temp);       }       if (b != prev && !dp3[i]) {         dp3[i] = 1;         temp = b;         solve(s, i - 3, temp);       }     }     return;   }   int main() {     string str;     cin >> str;     if (str.size() < 7) {       cout << 0;       return 0;     }     string s(str.begin() + 5, str.end());     int n = s.size();     solve(s, n - 1,   );     for (int i = 0; i < n; i++) {       if (dp2[i]) st.insert(s.substr(i - 1, 2));       if (dp3[i]) st.insert(s.substr(i - 2, 3));     }     cout << st.size() << endl;     it1 = st.begin();     for (; it1 != st.end(); it1++) cout << *it1 << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, i, X[200005], poz, nr0;   long long A[200005], B[200005], val, t;   int main() {     ios::sync_with_stdio(false);     cin >> n >> t;     for (i = 1; i <= n; i++) cin >> A[i];     for (i = 1; i <= n; i++) {       cin >> X[i];       if (X[i] < X[i - 1]) {         cout <<  No n ;         return 0;       }       if (X[i] < i) {         cout <<  No n ;         return 0;       }       if (X[i - 1] != X[i] && X[i - 1] != (i - 1)) {         cout <<  No n ;         return 0;       }     }     A[n + 1] = A[n] + 1000000001;     for (i = 1; i <= n; i++) B[X[i]] = A[X[i] + 1] + t - 1;     val = B[n] - 1;     for (i = n - 1; i >= 1; i--) {       if (B[i] != 0)         val = B[i];       else {         if (val < A[i + 1] + t) {           cout <<  No n ;           return 0;         }       }       B[i] = val;       val--;     }     cout <<  Yes n ;     for (i = 1; i <= n; i++) cout << B[i] <<    ;     cout <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int N, A;   vector<int> X;   int main(void) {     cin.sync_with_stdio(0);     cin >> N;     int Curr = 0, __Cnt = 0;     for (int i = 0; i < N; i++) {       cin >> A;       if (A < 0) {         if (__Cnt == 2) {           __Cnt = 0;           X.push_back(Curr);           Curr = 0;         }         __Cnt++;       }       Curr++;     }     if (Curr) X.push_back(Curr);     int Cnt = X.size();     cout << Cnt << endl;     for (int i = 0; i < Cnt; i++) {       if (i) cout <<    ;       cout << X[i];     }     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, x, p, q, count = 0;     cin >> n;     vector<int> v;     vector<int>::iterator it;     for (int i = 0; i < n; i++) {       cin >> x;       v.push_back(x);     }     for (int i = 0; i < n; i++) {       p = i;       for (int j = i + 1; j < n; j++) {         if (v[p] == v[j]) {           v[p] = 0;           p = j;         }       }     }     for (it = v.begin(); it != v.end(); it++) {       if ((*it) != 0) count++;     }     cout << count << endl;     for (it = v.begin(); it != v.end(); it++) {       if ((*it) != 0) cout << *it <<    ;     }     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<vector<int> > g(7);   vector<int> vis(7);   int cycles = 0;   int nds = 0;   bool allvis() {     for (int i = 1; i <= 5; i++)       if (!vis[i]) return false;     return true;   }   bool dfs(int node, int par, int cnt) {     if (vis[node]) {       cycles++;       nds = cnt;       return true;     }     vis[node] = 1;     for (int i = 0; i < g[node].size(); i++) {       int child = g[node][i];       if (child != par) {         if (dfs(child, node, cnt + 1)) return true;       }     }     return false;   }   int main() {     int m;     while (cin >> m) {       g.clear();       g.resize(7);       vis.clear();       vis.resize(7);       cycles = 0;       nds = 0;       int a, b;       for (int i = 0; i < m; i++) {         cin >> a >> b;         g[a].push_back(b);         g[b].push_back(a);       }       int tmp = 0;       for (int i = 1; i <= 5; i++) {         if (g[i].size() < 2) tmp++;       }       dfs(1, 0, 0);       if (cycles == 1 && nds == 5 && m == 5)         cout <<  FAIL  << endl;       else         cout <<  WIN  << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int TESTS = 1;     while (TESTS--) {       vector<pair<int, int>> v;       int i, a, b, index = 0, dp[1000005] = {0}, ans = INT_MIN, n;       cin >> n;       for (long long int i = 0; i < n; i++) {         cin >> a >> b;         v.push_back({a, b});       }       sort((v).begin(), (v).end());       for (i = 0; i < n; i++) {         while (index != v[i].first) {           dp[index] = dp[max(0, index - 1)];           index++;         }         if (index - v[i].second - 1 < 0)           dp[index] = 1;         else           dp[index] = dp[index - v[i].second - 1] + 1;         ans = max(ans, dp[index]);         index++;       }       cout << n - ans;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = INT_MAX / 2, NINF = INT_MIN / 2;   const long double PI = acos(-1.0);   void prepareIO() {     if (strlen(  ) != 0) {       freopen(                         .in ,            r , stdin);       freopen(                         .out ,            w , stdout);     }   }   void debout() {}   template <typename Head, typename... Tail>   void debout(Head H, Tail... T) {}   void stressout() {}   template <typename Head, typename... Tail>   void stressout(Head H, Tail... T) {}   void solve1();   int main() {     prepareIO();     solve1();     fprintf(stderr,  %.6lf n , (double)clock() / CLOCKS_PER_SEC);     return 0;   }   struct T {     int to, cnt, pos;   };   const int N = 1010;   int a[N], mark[N];   void solve1() {     int n;     cin >> n;     for (int i = 0; i < n; i++) {       cin >> a[i];     }     int ans = 0, cnt = 0;     int to = 1;     int pos = 0;     while (cnt < n) {       if (a[pos] <= cnt && mark[pos] == false) {         mark[pos] = 1;         cnt++;         continue;       }       if (to == 1) {         if (pos == n - 1) {           ans++;           to ^= 1;           continue;         }         pos++;       } else {         if (pos == 0) {           ans++;           to ^= 1;           continue;         }         pos--;       }     }     printf( %d n , ans);   }
#include <bits/stdc++.h>   int main() {     int a, i, b, k, temp;     while (~scanf( %d , &a) && a >= 0) {       temp = 0;       while (a) {         b = a;         k = 0;         while (b > 0) {           if (k < b % 10) k = b % 10;           b = b / 10;         }         a -= k;         temp++;       }       printf( %d n , temp);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int delta[1000000], cnt[1000000];   int main() {     int n, m, dx, dy;     cin >> n >> m >> dx >> dy;     int x = 0, y = 0;     delta[0] = 0;     for (int i = 1; i < n; ++i) {       x = (x + dx) % n;       y = (y + dy) % n;       delta[x] = y;     }     for (int i = 0; i < n; ++i) cnt[i] = 0;     for (int i = 0; i < m; ++i) {       cin >> x >> y;       ++cnt[(y + n - delta[x]) % n];     }     int ans = 0;     for (int i = 0; i < n; ++i)       if (cnt[ans] < cnt[i]) ans = i;     cout << 0 <<     << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 1000000009;   const double PI = acos(-1.0);   const double eps = 1e-8;   const int MAXN = 0;   const int MAXM = 0;   long long n, k, t, b, z;   int main() {     z = 1;     int ans = 0;     cin >> k >> b >> n >> t;     while (z <= t) {       ans++;       z = z * k + b;     }     if (z == t)       ans = n - ans;     else {       ans--;       ans = n - ans;     }     cout << max(0, ans) << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long l, i = 0, n, d, t;     cin >> d >> n;     if (d != 1 && n == 0) {       cout <<  No solution n ;       return 0;     }     cout << n;     for (t = 1; t <= d - 1; t++) cout << 0;     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int a, b, c, d;     int n;     cin >> a >> b >> c >> d >> n;     vector<int> v(n);     for (int i = 0; i < n; i++) {       cin >> v[i];     }     cout <<  YES n ;     int row = max(b, d);     int col = a + c;     char ans[row][col];     for (int i = 0; i < row; i++) {       for (int j = 0; j < col; j++) {         ans[i][j] =  . ;       }     }     int x, y, yc;     int dir;     if (d % 2 == 1) {       y = a + c - 1;       yc = a;       x = d - 1;       dir = -1;     } else {       y = a;       yc = a + c - 1;       x = d - 1;       dir = 1;     }     int ind = 0;     for (int i = x; i >= 0; i--) {       for (int j = y; j < a + c and j > a - 1; j += dir) {         if (v[ind]) {           ans[i][j] =  a  + ind;           v[ind]--;         } else {           ind++;           j -= dir;         }       }       dir = (dir == 1) ? -1 : 1;       swap(y, yc);     }     dir = -1;     y = a - 1;     yc = 0;     for (int i = 0; i < b; i++) {       for (int j = y; j < a and j >= 0; j += dir) {         if (v[ind]) {           ans[i][j] =  a  + ind;           v[ind]--;         } else {           ind++;           j -= dir;         }       }       dir = (dir == 1) ? -1 : 1;       swap(y, yc);     }     for (int i = 0; i < row; i++) {       for (int j = 0; j < col; j++) {         cout << ans[i][j];       }       cout << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int a[100100], q[1000000], ql, qr, m[100100][2];   bool edge(int i, int j) { return m[i][0] == j || m[i][1] == j; }   void add(int i, int j) {     if (m[i][0] == -1)       m[i][0] = j;     else       m[i][1] = j;   }   int main() {     int i, j, k, n, l, L, t, x = 1;     for (i = 0; i < 100100; m[i][0] = -1, m[i][1] = -1, i++)       ;     for (scanf( %d%d , &n, &k), l = 0; l < k;          scanf( %d%d , &i, &j), i--, j--, add(i, j), add(j, i), l++)       ;     for (i = 0; i < n; a[i] = i, i++)       ;     for (L = 0; L < 10000000;) {       random_shuffle(a, a + n);       L += n;       ql = 0;       qr = 0;       for (i = 0; i < k; i++)         if (edge(a[i], a[(i + 1) % n])) q[qr++] = i;       for (t = 0; t < n && ql < qr;            t++, L++, x = ((long long)x * 123121 + 412412) % 1000000007) {         i = q[ql++];         if (!edge(a[i], a[(i + 1) % n])) continue;         if (x % 2) i = (i + 2) % n;         swap(a[(i + n - 1) % n], a[i % n]);         for (j = i - 2; j <= i; j += 2)           if (edge(a[(j + 2 * n) % n], a[(j + 1 + 2 * n) % n]))             q[qr++] = (j + 2 * n) % n;       }       if (ql == qr) break;     }     if (L < 10000000) {       for (i = 0; i < k; printf( %d %d n , a[i] + 1, a[(i + 1) % n] + 1), i++)         if (edge(a[i], a[(i + 1) % n])) throw;     } else       printf( -1 n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   double dp[110][110][110] = {0};   double c[110][110] = {0};   int a[110], n, m;   int main() {     scanf( %d%d , &n, &m);     for (int i = 1; i <= m; ++i) scanf( %d , &a[i]);     for (int i = 0; i <= n + m; ++i) c[i][0] = 1;     for (int i = 1; i <= n + m; ++i)       for (int j = 1; j <= i; ++j) c[i][j] = c[i - 1][j - 1] + c[i - 1][j];     for (int i = 0; i <= m; ++i) dp[i][0][0] = 1;     for (int i = 1; i <= m; ++i)       for (int j = 1; j <= n; ++j)         for (int k = 0; k <= j; ++k) {           int l = max(a[i] * (k - 1) + 1, 0), r = a[i] * k;           for (int w = 0; w <= k; ++w)             for (int p = l; p <= min(r, j); ++p)               dp[i][j][k] += dp[i - 1][j - p][w] * c[n - j + p][p];           for (int p = 0; p <= min(l - 1, j); ++p)             dp[i][j][k] += dp[i - 1][j - p][k] * c[n - j + p][p];         }     double ans = 0;     for (int i = 1; i <= n; ++i) ans += dp[m][n][i] * i;     for (int i = 1; i <= n; ++i) ans /= (double)m;     printf( %.10lf , ans);     return 0;   }
#pragma GCC target ( avx2 )   #pragma GCC optimize ( O3 )   #pragma GCC optimize ( unroll-loops )      #include<bits/stdc++.h>   using namespace std;      // mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());   // int rnd(int x, int y) {return (rng() % (y-x +1)) + x;};      #define ll long long   #define pb push_back   #define eb emplace_back   #define mp make_pair   #define lb lower_bound   #define ub upper_bound   #define ins insert   #define ull unsigned long long   #define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))   #define ff first   #define ss second   #define fast ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);   #define nl   n    #define sz(a) (int)(a).size()   #define all(a) (a).begin(),(a).end()   #define fl(a,x) memset(a,x,sizeof(a));   #define pt(a,x) cout << get<x>(a) <<     ;   #define mt make_tuple   #define vec vector   #define mxe max_element   #define mne max_element   #define present(c, x) (c.find(x) != c.end())   #define printall(a) for(auto i : a) cout << i <<     ; cout << nl ;      #define int long long      typedef vector<int> vii;   typedef vector<ll> vll;   typedef pair<int,int> pii;   typedef pair<ll,ll> pll;   typedef vector<pii> vpi;   typedef vector<pll> vpl;   typedef vector<vii> vvi;   typedef vector<vll> vvl;      #define error(args...) { string _s = #args; replace(_s.begin(), _s.end(),  , ,    ); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }      void err(istream_iterator<string> it) {}   template<typename T, typename... Args>   void err(istream_iterator<string> it, T a, Args... args) {       cout << *it <<   =   << a << endl;       err(++it, args...);   }      const int mod = (int) 1e9 + 7 ;   const int MOD = (int) 998244353 ;   const ll INF = (ll) 1e18;      inline int add(int a, int b) {return (a + b >= mod ? a + b - mod : a + b);}   inline int mul(int a, int b) {return (ll) a * b % mod ; }      void solve() {          int n; cin >> n ;       string s; cin >> s;        int ans = 0 ;        int id = 0 , cnt = 0 ;        int x = count(all(s),  * ) ;        rep(i,0,n) {           cnt += (s[i] ==  * ) ;            if(cnt == (x+1)/2) {               id = i ;                break ;           }       }       cnt = 0 ;        for(int i = id + 1 ; i < n ; ++i) {           if(s[i] !=  * ) continue ;            ans += i - id - 1 - cnt ;            ++cnt ;        }       cnt = 0 ;        for(int i = id - 1 ; i >= 0 ; --i) {           if(s[i] !=  * ) continue ;            ans += id - i - 1 - cnt ;            ++cnt ;        }       cout << ans << nl ;   }         int32_t main() {          fast;       int t; cin >> t ; rep(i,0,t)            solve() ;       // cout <<  Time elapsed:   << 1.0 * clock() / CLOCKS_PER_SEC <<   s. n ;       return 0;   }
#include <bits/stdc++.h>   const double eps = (1e-9);   using namespace std;   int dcmp(long double a, long double b) {     return fabsl(a - b) <= eps ? 0 : (a > b) ? 1 : -1;   }   int getBit(int num, int idx) { return ((num >> idx) & 1) == 1; }   int setBit1(int num, int idx) { return num | (1 << idx); }   long long setBit0(long long num, int idx) { return num & ~(1ll << idx); }   long long flipBit(int num, int idx) { return num ^ (1 << idx); }   void FS() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);   }   int countNumBit1(int mask) {     int ret = 0;     while (mask) {       mask &= (mask - 1);       ++ret;     }     return ret;   }   const int N = 100009;   int arr[N];   int main() {     int n;     cin >> n;     int mx = -1;     for (int i = 0; i < n; i++) {       cin >> arr[i];       if (arr[i] > mx) {         mx = arr[i];       }     }     int mxlen = 1;     int cnt = 0, str = -1, en = 0;     for (int i = 0; i < n; i++) {       if (arr[i] == mx) {         if (str == -1) str = i;         en = i;       } else {         if (str != -1) mxlen = max(mxlen, en - str + 1);         str = -1;       }     }     if (str != -1) mxlen = max(mxlen, en - str + 1);     cout << mxlen << endl;   }