malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const unsigned long long hash1 = 201326611;   const double eps = 1e-8;   const long long INF = 0x3f3f3f3f3f3f3f3f;   const int inf = 0x3f3f3f3f;   const long long mod = 1e9 + 7;   const int N = 255;   const int M = 12;   const int dif = 26;   const double PI = acos(-1.0);   inline void Mod(long long& x) {     if (x >= mod) x -= mod;   }   void BinaryBitset(int n) { cout << bitset<sizeof(int) * 4>(n) << endl; }   int n, m;   long long c[N][N], m0[N], m1[N], dp[N][N];   void init(int n) {     m0[0] = m1[0] = 1;     for (int i = 1; i <= n; i++) {       m0[i] = m0[i - 1] * m % mod;       m1[i] = m1[i - 1] * (m - 1) % mod;     }     c[1][0] = 1;     c[1][1] = 1;     c[0][0] = 1;     for (int i = 1; i <= n; i++) c[i][0] = 1, c[i][i] = 1;     for (int i = 2; i <= n; i++) {       for (int j = 1; j < n; j++) {         c[i][j] = (c[i - 1][j - 1] + c[i - 1][j]) % mod;       }     }   }   int main() {     scanf( %d%d , &n, &m);     init(n);     for (int i = 1; i <= n; i++) dp[1][i] = c[n][i] * m1[n - i] % mod;     for (int i = 2; i <= n; i++) {       for (int j = 0; j <= n; j++) {         for (int k = 0; k <= j; k++) {           dp[i][j] = (dp[i][j] + c[n - k][j - k] * dp[i - 1][k] % mod *                                      m1[n - j] % mod * m0[k] % mod) %                      mod;           if (j == k)             dp[i][j] =                 ((dp[i][j] - m1[n] * dp[i - 1][k] % mod + mod) % mod + mod) % mod;         }       }     }     printf( %lld n , dp[n][n]);   }
#include <bits/stdc++.h>   using namespace std;   long long n, m, s, e, v, q;   vector<long long> vs, ve;   int32_t main() {     ios::sync_with_stdio(0), cin.tie(0);     cin >> n >> m >> s >> e >> v;     vs.resize(s), ve.resize(e);     for (auto& u : vs) {       cin >> u;     }     for (auto& u : ve) {       cin >> u;     }     cin >> q;     while (q--) {       long long x, y, a, b;       cin >> x >> y >> a >> b;       if (x == a) {         cout << abs(y - b) <<   n ;       } else {         long long ans = 1e18, idx, es = (abs(x - a) + v - 1) / v;         if (y > b) swap(y, b);         idx = lower_bound(vs.begin(), vs.end(), y) - vs.begin();         if (idx < s) {           ans = min(ans, abs(vs[idx] - y) + abs(vs[idx] - b) + abs(x - a));         }         idx--;         if (idx >= 0) {           ans = min(ans, abs(vs[idx] - y) + abs(vs[idx] - b) + abs(x - a));         }         idx = lower_bound(ve.begin(), ve.end(), y) - ve.begin();         if (idx < e) {           ans = min(ans, abs(ve[idx] - y) + abs(ve[idx] - b) + es);         }         idx--;         if (idx >= 0) {           ans = min(ans, abs(ve[idx] - y) + abs(ve[idx] - b) + es);         }         cout << ans <<   n ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long w[1000000], w1[100000];   long long t[1000000];   pair<long long, long long> ans;   long long a, b, c, n, m, q, k, x, c1, b1;   long long poww(long long x, long long y) {     if (x == 0) return 0;     if (x == 1) return 1;     if (y == 0) return 1;     if (y == 1) return x;     long long d = poww(x, y / 2);     if (y % 2) return d * d * x;     return d * d;   }   map<long long, long long> M;   vector<long long> v;   int main() {     cin >> a >> b >> c;     for (int i = 1; i <= 1000000; i++) {       a *= 10;       if (a / b == c) return cout << i, 0;       a %= b;     }     cout << -1;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, s;     cin >> n >> s;     int sum = 100;     bool res = false;     for (int i = 0; i < n; i++) {       int temp1, temp2;       cin >> temp1 >> temp2;       if (temp1 < s) {         res = true;         if (temp2 != 0 && temp2 < sum) sum = temp2;       }       if (temp1 == s && temp2 == 0) res = true;     }     if (res)       cout << 100 - sum;     else       cout << -1;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int dx[8] = {0, -1, 0, 1, 1, -1, -1, 1};   const int dy[8] = {-1, 0, 1, 0, -1, -1, 1, 1};   const long long mod = 1000000007;   const int base = 311;   const int N = 6e5 + 5;   map<long long, vector<pair<int, int>>> e;   int n, m;   long long a[N];   vector<int> dsk[N];   long long pw[N];   int dd[N];   int k;   void dfs(int u, int &d) {     dd[u] = 1;     ++d;     for (int v : dsk[u])       if (!dd[v]) dfs(v, d);   }   void gogo() {     cin >> n >> m >> k;     for (int i = 1; i <= n; ++i) cin >> a[i];     for (int i = 1; i <= m; ++i) {       int u, v;       cin >> u >> v;       e[a[u] ^ a[v]].push_back(make_pair(u, v));     }     pw[0] = 1;     for (int i = 1; i <= 6e5; ++i) pw[i] = pw[i - 1] * 2 % mod;     long long ans = pw[k] * pw[n] % mod;     for (auto it : e) {       vector<pair<int, int>> tmp = it.second;       for (pair<int, int> i : tmp) {         dsk[i.first].push_back(i.second);         dsk[i.second].push_back(i.first);       }       vector<int> cnt;       for (pair<int, int> i : tmp) {         int d = 0;         if (!dd[i.first]) {           dfs(i.first, d);           cnt.push_back(d);         }       }       int sum = 0;       for (int i : cnt) sum += i;       long long comp = n - sum + ((int)(cnt).size());       ans = (ans - pw[n] + pw[comp] + mod * mod) % mod;       for (pair<int, int> i : tmp) {         dd[i.first] = dd[i.second] = 0;         dsk[i.first].clear();         dsk[i.second].clear();       }     }     cout << ans;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     if (fopen( sol                 .inp ,                r )) {       freopen(            sol             .inp ,            r , stdin);       freopen(            sol             .out ,            w , stdout);     }     gogo();   }
#include <bits/stdc++.h>   using namespace std;   int n;   long long ans, X, Y, s[200010], w[30], t, A[131072], B[131072];   inline long long gcd(long long a, long long b) {     for (long long c; b; a = b, b = c) c = a % b;     return a;   }   int main() {     scanf( %d%lld%lld , &n, &X, &Y);     for (int i = 1; i <= n; ++i) scanf( %lld , s + i);     if (Y % X) return 0 & puts( 0 );     long long D = Y;     for (int i = 2; D > 1 && i <= 1000000; ++i)       if (D % i == 0)         for (w[++t] = i; D % i == 0; D /= i)           ;     if (D > 1) {       long long Q = sqrt(D);       if (Q * Q == D)         w[++t] = Q;       else         for (int i = 1; i <= n; ++i) {           if ((Q = gcd(D, s[i])) > 1 && Q < D) {             w[++t] = Q;             w[++t] = D / Q;             break;           }         }       w[++t] = D;     }     int a[30] = {0}, b[30] = {0}, T;     for (int i = 1; i <= t; ++i) {       for (D = X; D % w[i] == 0; D /= w[i]) ++a[i];       for (D = Y; D % w[i] == 0; D /= w[i]) ++b[i];     }     for (int i = 1; i <= n; ++i)       if (Y % s[i] == 0) {         int c[30] = {0}, k = 0;         D = s[i];         for (int j = 1; j <= t; ++j)           if (D % w[j] == 0)             for (; D % w[j] == 0; ++c[j]) D /= w[j];         for (int j = 1; j <= t; ++j)           if (c[j] == b[j]) k ^= (1 << j - 1);         ++B[k];       }     int N = 1 << t;     for (int i = 1; i <= N; i <<= 1)       for (int j = i; j < N; ++j& i ? 0 : j |= i) B[j ^ i] += B[j];     for (int i = 1; i <= n; ++i)       if (s[i] % X == 0) {         int c[30] = {0}, k = (1 << t) - 1;         D = s[i];         for (int j = 1; j <= t; ++j)           if (D % w[j] == 0)             for (; D % w[j] == 0; ++c[j]) D /= w[j];         for (int j = 1; j <= t; ++j)           if (c[j] == a[j] || a[j] == b[j]) k ^= (1 << j - 1);         ans += B[k];       }     printf( %lld n , ans);   }
#include <bits/stdc++.h>   using namespace std;   double x[1005], y[1005], z[1005], r[1005];   long long int n, m;   int main() {     double res = (1ll << (long long int)(60)), ax, ay, az, vx, vy, vz, R;     cin >> ax >> ay >> az >> vx >> vy >> vz >> R >> n;     for (long long int i = 0; i < ((long long int)(n)); i++) {       cin >> x[0] >> y[0] >> z[0] >> r[0] >> m;       for (long long int j = 0; j < ((long long int)(m)); j++)         cin >> x[j + 1] >> y[j + 1] >> z[j + 1];       for (long long int j = 0; j < ((long long int)(m)); j++)         x[j + 1] += x[0], y[j + 1] += y[0], z[j + 1] += z[0];       for (long long int j = 0; j < ((long long int)(m + 1)); j++) {         double t = -(vx * (ax - x[j]) + vy * (ay - y[j]) + vz * (az - z[j])) /                    ((vx) * (vx) + (vy) * (vy) + (vz) * (vz));         if (t < 0) continue;         if (((vx * t + ax - x[j]) * (vx * t + ax - x[j]) +              (vy * t + ay - y[j]) * (vy * t + ay - y[j]) +              (vz * t + az - z[j]) * (vz * t + az - z[j])) <             (R + r[j]) * (R + r[j]) + 0.0000001) {           double low = 0, high = t;           for (long long int k = 0; k < ((long long int)(100)); k++) {             double mid = (low + high) / 2.0;             if (((vx * mid + ax - x[j]) * (vx * mid + ax - x[j]) +                  (vy * mid + ay - y[j]) * (vy * mid + ay - y[j]) +                  (vz * mid + az - z[j]) * (vz * mid + az - z[j])) <                 (R + r[j]) * (R + r[j]))               high = mid;             else               low = mid;           }           res = min(res, low);         }       }     }     if (res == (1ll << (long long int)(60)))       cout <<  -1  << endl;     else       printf( %0.20lf n , res);   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e6 + 20;   vector<int> a[N];   vector<int> Q;   int t, x, p, k;   int solve(int n, int p) {     int ret = 0;     Q.clear();     Q.push_back(-1);     vector<int>& f = a[p];     for (int i = 0; i < (int)f.size(); ++i) {       int top = Q.size();       for (int j = 0; j < top; ++j) {         Q.push_back(-1 * f[i] * Q[j]);       }     }     for (int i = 1; i < (int)Q.size(); ++i) {       ret += n / Q[i];     }     return n - ret;   }   int main() {     for (int i = 2; i <= 1000000; ++i) {       if (a[i].size() > 0) continue;       for (int j = i; j <= 1000000; j += i) {         a[j].push_back(i);       }     }     scanf( %d , &t);     while (t--) {       scanf( %d %d %d , &x, &p, &k);       k += solve(x, p);       int lb = 1, ub = 1e9, ans = x;       while (lb <= ub) {         int mid = (lb + ub) / 2;         if (solve(mid, p) >= k) {           ans = mid;           ub = mid - 1;         } else {           lb = mid + 1;         }       }       printf( %d n , ans);     }   }
#include <bits/stdc++.h>   using namespace std;   const double PI = 2 * acos(0.0);   void solve(void) {     string str;     cin >> str;     int one = 0, zero = 0;     for (int i = 0; i < str.length(); i++) {       if (str[i] ==  1 ) {         one++;         while (i < str.length() && str[i] ==  1 ) i++;         i--;       } else {         zero++;         while (i < str.length() && str[i] ==  0 ) i++;         i--;       }     }     if (one && zero) {       if (zero <= 1)         cout << 1 <<   n ;       else         cout << 2 <<   n ;     } else if (zero)       cout << 1 <<   n ;     else if (one)       cout << 0 <<   n ;   }   int main(void) {     ios::sync_with_stdio(0), cin.tie(0);     int t;     cin >> t;     while (t--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   inline string tostring(const T &x) {     ostringstream os;     os << x;     return os.str();   }   inline int toint(const string &s) {     istringstream is(s);     int x;     is >> x;     return x;   }   inline int todecimal(string s) {     int a = 0;     for (int i = 0; i < s.size(); i++) a = 2 * a + (s[i] -  0 );     return a;   }   inline string tobinary(int a) {     string s;     while (a != 0) {       s = (char)(a % 2 +  0 ) + s;       a >>= 1;     }     return s;   }   template <typename T>   inline T sqr(T x) {     return x * x;   }   template <typename T>   T gcd(T a, T b) {     return (b == 0) ? abs(a) : gcd(b, a % b);   }   inline int isvowel(char c) {     if (c ==  a  || c ==  e  || c ==  i  || c ==  o  || c ==  u ) return 1;     return 0;   }   inline int isprime(int a) {     for (int i = 2; i * i <= a; i++)       if (!(a % i)) return 0;     return 1;   }   inline void inp(int &n) {     n = 0;     int ch = getchar();     int sign = 1;     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) sign = -1;       ch = getchar();     }     while (ch >=  0  && ch <=  9 )       n = (n << 3) + (n << 1) + ch -  0 , ch = getchar();     n = n * sign;   }   const int dx4[4] = {0, 0, 1, -1};   const int dy4[4] = {1, -1, 0, 0};   const int dx8[8] = {0, 0, 1, 1, 1, -1, -1, -1};   const int dy8[8] = {1, -1, 0, 1, -1, 1, 0, -1};   class node {    public:     int x, y, z;     node(int a, int b, int c) {       x = a;       y = b;       z = c;     }   };   bool operator<(const node &a, const node &b) { return a.x > b.x; }   bool compare(const node &a, const node &b) { return a.x < b.x; }   const int maxn = 66;   int grid[maxn][maxn];   int n;   void solve() {     memset((grid), (0), sizeof(grid));     grid[0][0] = n;     int moving = 1;     while (moving) {       moving = 0;       for (int i = 0; i < maxn; i++) {         for (int j = 0; j < maxn; j++) {           int x = grid[i][j] / 4;           grid[i + 1][j] += x;           grid[i][j + 1] += x;           if (i) grid[i - 1][j] += x * (i == 1 ? 2 : 1);           if (j) grid[i][j - 1] += x * (j == 1 ? 2 : 1);           grid[i][j] %= 4;           if (x) moving = 1;         }       }     }     int q = 0;     ;     cin >> q;     int x, y;     for (int i = 0; i < q; i++) {       cin >> x >> y;       if (x < 0) x = -x;       if (y < 0) y = -y;       if (x >= maxn || y >= maxn)         cout << 0 << endl;       else         cout << grid[x][y] << endl;     }   }   void input() { cin >> n; }   int main() {     int testcase = 1;     for (int i = 0; i < testcase; i++) {       input();       solve();     }     return 0;   }
#include <bits/stdc++.h>   int main() {     int n, v, pre, rotting, a[4005], b[4005], i, j, bag, collect, day, v2;     while (scanf( %d%d , &n, &v) != EOF) {       day = 0;       bag = 0;       for (i = 0; i < n; i++) {         scanf( %d%d , &a[i], &b[i]);         if (a[i] > day) day = a[i];       }       rotting = 0;       day += 2;       for (i = 1; i < day; i++) {         pre = 0;         for (j = 0; j < n; j++) {           if (a[j] == i) {             pre += b[j];           }         }         if (rotting > v) {           bag += v;           v2 = 0;         } else {           bag += rotting;           v2 = v - rotting;         }         if (pre > v2) {           bag += v2;           pre -= v2;         } else {           bag += pre;           pre = 0;         }         rotting = pre;       }       printf( %d n , bag);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string doen() {     char c;     string waarde;     while (cin.get(c) && c !=   n ) {       waarde += c;     }     int aantal = stoi(waarde);     string iets;     getline(cin, iets);     for (int i = 0; i < iets.length(); i = i + 2) {       if (iets[i] ==  1 ) {         return  HARD ;       }     }     return  EASY ;   }   int main() {     cout << doen();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[110];   int d[110];   int main() {     int n;     scanf( %d , &n);     for (int i = 0; i < n; i++) {       scanf( %d%d , &a[i], &d[i]);     }     int ans = 0;     for (int i = 0; i < n; i++) {       for (int j = i + 1; j < n; j++) {         if (a[i] >= a[j]) {           if (a[i] < a[j] + d[j] || a[i] + d[i] < a[j]) {             ans++;             if (a[i] + d[i] >= a[j] + d[j]) ans++;           } else if (a[i] + d[i] < a[j] + d[j])             ans++;         } else {           if (a[i] + d[i] >= a[j] || a[i] >= a[j] + d[j]) {             ans++;             if (a[i] + d[i] < a[j] + d[j]) ans++;           } else if (a[i] + d[i] >= a[j] + d[j])             ans++;         }       }     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   struct {     inline operator int() {       int x;       return scanf( %d , &x), x;     }     inline operator long long() {       long long x;       return scanf( %lld , &x), x;     }     template <class T>     inline void operator()(T &x) {       x = *this;     }     template <class T, class... A>     inline void operator()(T &x, A &...a) {       x = *this;       this->operator()(a...);     }   } read;   const int maxn = 300005;   int l[maxn], r[maxn];   int main() {     int T = read;     while (T--) {       int n = read;       std::fill(l, l + n + 1, 0);       std::fill(r, r + n + 1, 0);       for (int i = 1; i <= n; i++) {         int x = read;         if (!l[x]) l[x] = i;         r[x] = i;       }       int ans = 0, max = 0;       for (int x = 1, y = 0, now = 0; x <= n; x++)         if (l[x]) {           if (r[y] < l[x])             ++now;           else             now = 1;           ++ans;           max = std::max(max, now);           y = x;         }       ans -= max;       printf( %d n , ans);     }   }
#include <bits/stdc++.h>   using namespace std;   vector<int> E[100005];   int head, tail, A[300], B[300];   int N, M, H, T, marked[100005];   bool ok;   void checkHydra(int x) {     int heads = 0;     for (int i = 0; i < int(E[x].size()); ++i) marked[E[x][i]] = 1, ++heads;     if (heads >= H) {       for (vector<int>::iterator it = E[x].begin(); it != E[x].end() && !ok;            ++it) {         --heads;         int tails = 0;         int common = 0;         for (vector<int>::iterator jt = E[*it].begin(); jt != E[*it].end() && !ok;              ++jt) {           if (*jt == x) continue;           ++tails;           if (marked[*jt]) ++common;           if (heads >= H && tails >= T && heads + tails - common >= H + T) {             ok = true;             head = x;             tail = *it;           }         }         ++heads;       }     }     for (int i = 0; i < int(E[x].size()); ++i) marked[E[x][i]] = 0;   }   int main() {     cin >> N >> M >> H >> T;     for (int i = 0; i < M; ++i) {       int x, y;       cin >> x >> y;       E[x].push_back(y);       E[y].push_back(x);     }     ok = false;     for (int i = 1; i <= N && !ok; ++i) checkHydra(i);     if (!ok) {       cout <<  NO ;       return 0;     }     cout <<  YES n ;     cout << head <<     << tail <<   n ;     for (auto &it : E[head])       if (it != tail) marked[it]++;     for (auto &it : E[tail])       if (it != head) marked[it]++;     N = M = 0;     for (auto &it : E[head])       if (marked[it] == 1)         if (N < H) {           A[N++] = it;           marked[it] = 0;         }     for (auto &it : E[tail])       if (marked[it] == 1)         if (M < T) {           B[M++] = it;           marked[it] = 0;         }     for (auto &it : E[head])       if (marked[it] == 2)         if (N < H) {           A[N++] = it;           marked[it] = 0;         }     for (auto &it : E[tail])       if (marked[it] == 2)         if (M < T) {           B[M++] = it;           marked[it] = 0;         }     for (int i = 0; i < H; ++i) cout << A[i] <<    ;     cout <<   n ;     for (int i = 0; i < T; ++i) cout << B[i] <<    ;     cout <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     string start;     string end;     cin >> start;     cin >> end;     int startInt = (stoi(start.substr(0, 3))) * 60 + (stoi(start.substr(3, 5)));     int endInt = (stoi(end.substr(0, 3))) * 60 + (stoi(end.substr(3, 5)));     int dif = (endInt - startInt) / 2;     int hoursToAdd = dif / 60;     int minutesToAdd = dif % 60;     int first = (stoi(start.substr(0, 3)) + hoursToAdd);     int second = (stoi(start.substr(3, 5)) + minutesToAdd);     first += second / 60;     second = second % 60;     string firstS = to_string(first);     string secondS = to_string(second);     if (firstS.size() == 1) firstS.insert(0,  0 );     if (secondS.size() == 1) secondS.insert(0,  0 );     cout << firstS <<  :  << secondS <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   int v[100005];   int st[100005][22];   bool mark[100005];   long long dp[100005];   int n, k;   void build() {     int i, j;     for (j = 1; 1 << j <= n; j++) {       for (i = 0; i + (1 << j) <= n; i++) {         st[i][j] = min(st[i][j - 1], st[i + (1 << (j - 1))][j - 1]);       }     }   }   int getMin(int l, int r) {     int num = r - l + 1, k = 0;     while (num >= 2) num /= 2, k++;     return min(st[l][k], st[r - (1 << k) + 1][k]);   }   long long f(int i) {     if (i >= n) return 0;     if (mark[i]) return dp[i];     mark[i] = 1;     long long ret = getMin(i - k + 1, i) + f(i + k);     ret = max(ret, f(i + 1));     return dp[i] = ret;   }   int main() {     scanf( %d %d , &n, &k);     long long sum = 0;     for (int i = 0; i < n; i++) {       scanf( %d , &st[i][0]);       sum += st[i][0];     }     build();     printf( %lld n , sum - f(k - 1));     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( O3 ,  unroll-loops )   #pragma GCC target( avx2 )   using namespace std;   template <class T, class U>   inline void checkmin(T &x, U y) {     if (y < x) x = y;   }   template <class T, class U>   inline void checkmax(T &x, U y) {     if (y > x) x = y;   }   template <class T, class U>   inline bool ifmax(T &x, U y) {     if (y > x) return x = y, true;     return false;   }   template <class T, class U>   inline bool ifmin(T &x, U y) {     if (y < x) return x = y, true;     return false;   }   template <class T>   inline void sort(T &a) {     sort(a.begin(), a.end());   }   template <class T>   inline void rsort(T &a) {     sort(a.rbegin(), a.rend());   }   template <class T>   inline void reverse(T &a) {     reverse(a.begin(), a.end());   }   template <class T, class U>   inline istream &operator>>(istream &str, pair<T, U> &p) {     return str >> p.first >> p.second;   }   template <class T>   inline istream &operator>>(istream &str, vector<T> &a) {     for (auto &i : a) str >> i;     return str;   }   template <class T>   inline T sorted(T a) {     sort(a);     return a;   }   void read(int &x) {     static char c;     c = getchar();     if (c ==  - ) {       x = 0;       while ((c = getchar()) >=  0 ) x = (x << 3) + (x << 1) + (c -  0 );       x = -x;     } else {       x = c -  0 ;       while ((c = getchar()) >=  0 ) x = (x << 3) + (x << 1) + (c -  0 );     }   }   void print(int x) {     if (x >= 10) print(x / 10);     putchar(x % 10 +  0 );   }   const int N = 1e6 + 1;   int a[N], ind[N];   bool used[N];   void solve() {     int n;     read(n);     for (int i = 0; i < n; ++i) read(a[i]), used[i] = 0;     int v = 0, pind = 0;     while (!used[v]) {       used[v] = true;       ind[pind++] = v;       v -= a[v];     }     bool flag = false;     for (int i = 0;; ++i)       if (ind[i] == v) {         print(pind - i);         putchar(  n );         for (int j = i; j < pind; ++j) print(ind[j] + 1), putchar(   );         putchar(  n );         return;       }   }   signed main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cout << fixed << setprecision(12);     srand(94385);     int t;     read(t);     while (t--) solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, a[300005], s[300005], X, Y;   long long ans;   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       long long x;       scanf( %lld , &x);       for (long long j = 0; j < 60; j++)         if (x >> j & 1) a[i]++;       s[i] = s[i - 1] + a[i];     }     X++;     for (int i = 1; i <= n; i++) {       if (s[i] & 1) {         ans += Y;         Y++;       } else {         ans += X;         X++;       }     }     for (int i = 1; i <= n; i++) {       X = a[i];       for (int j = i; j <= min(n, i + 60 - 1); j++) {         X = max(X, a[j]);         if ((s[j] - s[i - 1]) % 2 == 0 && (s[j] - s[i - 1]) < X + X) ans--;       }     }     printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     string s;     int n;     cin >> n >> s;     int res = 0;     long long a = 0, b = 0;     for (int i = 0; i < n; i++) {       if (s[i] == s[0]) {         a++;       } else {         break;       }     }     for (int i = n - 1; i >= 0; i--) {       if (s[i] == s[n - 1]) {         b++;       } else {         break;       }     }     if (s[0] == s[n - 1]) {       cout << ((a + 1) * (b + 1)) % 998244353;     } else {       cout << (a + b + 1) % 998244353;     }     return 0;   }