malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   vector<int> alph(26, 0);   vector<int> comp(26, 0);   int main() {     int n, t, even = 0, l1, l2;     cin >> n;     for (int i = 0; i < n; i++) {       cin >> t;       if (t % 2 == 0) {         even++;         l1 = i;       } else {         even--;         l2 = i;       }     }     if (even > 0)       cout << l2 + 1;     else       cout << l1 + 1;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int z = 1000000007;   map<int, int> parent;   map<int, int> XOR;   pair<long long int, long long int> finding(int n, int xo) {     if (parent.find(n) == parent.end())       return pair<long long int, long long int>(n, 0);     pair<long long int, long long int> temp = finding(parent[n], 0);     int pa = temp.first;     parent[n] = pa;     XOR[n] = (temp.second) ^ XOR[n];     return pair<long long int, long long int>(parent[n], XOR[n]);   }   void unite(int a, int b, int xo) {     parent[a] = b;     XOR[a] = xo;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int q;     cin >> q;     int ans = 0;     for (int i = 1; i <= q; i++) {       int op;       cin >> op;       if (op == 1) {         int l, r, x;         cin >> l >> r >> x;         l = l ^ ans;         r = r ^ ans;         if (l > r) swap(l, r);         r = r + 1;         x = x ^ ans;         int xl = 0, xr = 0;         pair<long long int, long long int> temp = finding(l, xl);         int nl = temp.first;         xl = temp.second;         temp = finding(r, xr);         int nr = temp.first;         xr = temp.second;         if (nl != nr) unite(nl, nr, ((xl ^ xr) ^ x));       } else {         int l, r;         cin >> l >> r;         l = l ^ ans;         r = r ^ ans;         if (l > r) swap(l, r);         r = r + 1;         int xl = 0, xr = 0;         pair<long long int, long long int> temp = finding(l, xl);         int nl = temp.first;         xl = temp.second;         temp = finding(r, xr);         int nr = temp.first;         xr = temp.second;         if (nl == nr) {           cout << (xl ^ xr) << endl;           ans = (xl ^ xr);         } else {           ans = 1;           cout << -1 << endl;         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, i, j, k, l, art[505][505], low[505][505], used[505][505], ans, cn, t,       x, y, z, mx, mn, s, timer, vis[505][505];   char c[505][505], d[1000009], ch;   void dfs(int row, int col) {     timer++;     used[row][col] = 1;     if ((row - 1 >= 0) && (used[row - 1][col] == 0) && (timer < s) &&         (c[row - 1][col] ==  . )) {       dfs(row - 1, col);     }     if ((col - 1 >= 0) && (used[row][col - 1] == 0) && (timer < s) &&         (c[row][col - 1] ==  . )) {       dfs(row, col - 1);     }     if ((row + 1 < n) && (used[row + 1][col] == 0) && (timer < s) &&         (c[row + 1][col] ==  . )) {       dfs(row + 1, col);     }     if ((col + 1 < m) && (used[row][col + 1] == 0) && (timer < s) &&         (c[row][col + 1] ==  . )) {       dfs(row, col + 1);     }   }   int main() {     while (scanf( %d %d %d , &n, &m, &k) != EOF) {       x = y = s = 0;       timer = 1;       for (i = 0; i < n; i++) {         scanf( %s , c[i]);         for (j = 0; j < m; j++) {           if (c[i][j] ==  . ) {             s++;             x = i;             y = j;           }         }       }       s -= k;       memset(used, 0, sizeof(used));       timer = 0;       dfs(x, y);       for (i = 0; i < n; i++) {         for (j = 0; j < m; j++) {           if ((used[i][j] == 0) && (c[i][j] ==  . )) {             k--;             printf( X );           } else {             printf( %c , c[i][j]);           }         }         printf(  n );       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T, class U>   void ckmin(T &a, U b) {     if (a > b) a = b;   }   template <class T, class U>   void ckmax(T &a, U b) {     if (a < b) a = b;   }   int N;   bitset<200013> bs;   int nxt[200013];   long long ans;   long long c(int r, int m, int mod) { return (r + (mod - m)) / mod; }   int cc(int lt, int rt, int m, int mod) {     if (lt > rt) return 0;     return c(rt, m, mod) - c(lt - 1, m, mod);   }   int32_t main() {     cout << fixed << setprecision(12);     cerr << fixed << setprecision(4);     ios_base::sync_with_stdio(false);     cin.tie(0);     string temps;     cin >> temps;     N = ((int)(temps).size());     for (auto i = (1); i < (N + 1); i++) {       bs[i] = (temps[i - 1] ==  1 );     }     nxt[N + 1] = N + 1;     for (auto i = (N + 1) - 1; i >= (0); i--) {       nxt[i] = (bs[i + 1] ? i + 1 : nxt[i + 1]);     }     int co = N / (213 - 1) + 5;     for (auto i = (1); i < (N + 1); i++) {       long long num = bs[i], lt = i, rt = nxt[i] - 1;       while (true) {         if (num) {           ans += cc(max(num * 213 + i - 1, lt), rt, (i - 1) % num, num);         }         rt++;         lt = rt;         if (rt > N) break;         rt = nxt[rt] - 1;         num++;         if (num > co) break;       }     }     for (auto i = (1); i < (213); i++) {       vector<long long> vec;       vec.push_back(0);       for (auto j = (1); j < (N + 1); j++) {         vec.push_back(vec.back() + 1 - (bs[j] ? i : 0));       }       sort((vec).begin(), (vec).end());       long long dp = 0;       for (auto j = (0); j < (((int)(vec).size())); j++) {         ans += dp;         if (j != ((int)(vec).size()) - 1 && vec[j] == vec[j + 1]) {           dp++;         } else {           dp = 0;         }       }     }     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( O3 )   #pragma GCC optimize( O1 )   #pragma GCC optimize( O2 )   #pragma GCC optimize( Os )   #pragma GCC optimize( Ofast )   #pragma GCC target( avx2 )   #pragma GCC optimization( unroll-loops )   long long int gcd(long long int a, long long int b) {     return (b ? gcd(b, a % b) : a);   }   long long int P(long long int B, long long int power, long long int modulo) {     long long int ans = 1LL;     while (power > 0LL) {       if (power % 2LL == 1LL) {         ans = (ans * B) % modulo;       }       B = (B * B) % modulo;       power /= 2LL;     }     return ans;   }   bool isPrime(long long int n) {     if (n <= 1LL) {       return false;     }     if (n <= 3LL) {       return true;     }     if (n % 2 == 0LL || n % 3 == 0LL) {       return false;     }     for (long long int i = 5LL; (i * i) <= n; i += 6LL) {       if (n % i == 0LL || n % (i + 2LL) == 0LL) {         return false;       }     }     return true;   }   using namespace std;   void vok() {     ios_base::sync_with_stdio(false);     cout.tie(NULL);     cin.tie(NULL);   }   const int mxN = int(1e5) + 100;   int dp[mxN];   bool vis[mxN];   void dfs(int u, vector<int> graph[]) {     vis[u] = 1;     for (auto x : graph[u]) {       if (!vis[x]) {         dfs(x, graph);       }       dp[u] = max(dp[u], dp[x] + 1);     }   }   int main() {     vok();     int t;     cin >> t;     while (t--) {       int n, k;       cin >> n >> k;       vector<int> v(n);       set<int> index;       for (int i = 0; i < n; i++) {         cin >> v[i];         if (v[i] == k) {           index.insert(i);         }       }       if (int(index.size()) == 0) {         cout <<  no               <<   n ;         continue;       }       bool flag = false;       for (int i = 0; i < n - 1; i++) {         if (v[i] >= k && v[i + 1] >= k) {           flag = true;           break;         }         if (i < n - 2) {           if (v[i] >= k && v[i + 2] >= k) {             flag = true;             break;           }         }       }       if (flag || int(index.size()) == n || n == 1) {         cout <<  yes               <<   n ;         continue;       }       cout <<  no             <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   #pragma GCC target( avx2 )   #pragma GCC optimization( O3 )   #pragma GCC optimization( unroll-loops )   void solve() {     long long n, m, k;     cin >> n >> m >> k;     long long lb = n / m;     long long ub = (n + m - 1) / m;     vector<long long> seat;     for (long long i = 0; i <= m; i++) {       long long remain = n - i * lb;       if (remain >= 0 && remain % ub == 0 && (i + remain / ub == m)) {         for (long long j = 0; j < i; j++) seat.push_back(lb);         for (long long j = 0; j < remain / ub; j++) seat.push_back(ub);         break;       }     }     sort(seat.begin(), seat.end());     priority_queue<pair<long long, long long>> pq;     for (long long i = 0; i < n; i++) pq.push({0, i});     while (k--) {       priority_queue<pair<long long, long long>> temp;       for (auto &x : seat) {         cout << x <<    ;         for (long long i = 0; i < x; i++) {           long long p = pq.top().first, u = pq.top().second;           pq.pop();           p += (x != lb);           cout << (u + 1) <<    n [i == x - 1];           temp.push({p, u});         }       }       pq = temp;     }     cout <<   n ;   }   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long t;     cin >> t;     while (t--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string a, b, p1 =  Widget , p2 =  VBox , p3 =  HBox , ans[105];   map<string, int> q;   vector<int> d[105];   int id[105];   long long l[105], r[105], h1[105], h2[105];   void dfs(int x) {     if (l[x] != -1) return;     l[x] = 0;     for (int i = 0; i < (int)d[x].size(); ++i) {       int v = d[x][i];       dfs(v);       if (id[x] == 2) {         l[x] += l[v];         r[x] = max(r[x], r[v]);       } else {         r[x] += r[v];         l[x] = max(l[x], l[v]);       }     }     if (d[x].size()) {       if (id[x] == 2) {         l[x] = l[x] + (d[x].size() - 1) * h2[x];         r[x] += 2 * h1[x];         l[x] += 2 * h1[x];       } else {         r[x] = r[x] + (d[x].size() - 1) * h2[x];         l[x] += 2 * h1[x];         r[x] += 2 * h1[x];       }     }   }   int main() {     memset(l, -1, sizeof(l));     int n, tot = 0;     scanf( %d , &n);     for (int i = 1; i <= n; ++i) {       cin >> a;       if (a == p1) {         cin >> a;         b =   ;         for (int j = 0, k; j < (int)a.size(); ++j) {           if (a[j] ==  ( ) {             q[b] = ++tot;             ans[tot] = b;             l[tot] = 0;             for (k = j + 1;; ++k) {               if (a[k] ==  , ) break;               l[tot] = l[tot] * 10 + a[k] -  0 ;             }             for (++k;; ++k) {               if (a[k] ==  ) ) break;               r[tot] = r[tot] * 10 + a[k] -  0 ;             }             break;           }           b += a[j];         }       } else if (a == p2) {         cin >> a;         q[a] = ++tot;         ans[tot] = a;         id[tot] = 1;       } else if (a == p3) {         cin >> a;         q[a] = ++tot;         ans[tot] = a;         id[tot] = 2;       } else {         string c =   ;         for (int j = 0; j < (int)a.size(); ++j) {           if (a[j] ==  . ) {             if (a[j + 1] ==  p ) {               b =   ;               for (int k = j + 6; k < (int)a.size() - 1; ++k) b += a[k];               d[q[c]].push_back(q[b]);             } else {               long long tp = 0;               for (int k = j + 1; k < (int)a.size(); ++k)                 if (a[k] >=  0  && a[k] <=  9 ) tp = tp * 10 + a[k] -  0 ;               if (a[j + 5] ==  b )                 h1[q[c]] = tp;               else                 h2[q[c]] = tp;             }             break;           }           c += a[j];         }       }     }     sort(ans + 1, ans + tot + 1);     for (int i = 1; i <= tot; ++i) {       dfs(q[ans[i]]);       cout << ans[i] <<    ;       printf( %I64d %I64d n , l[q[ans[i]]], r[q[ans[i]]]);     }   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e5 + 5;   int n, a[maxn], ans;   int gcd(int x, int y) {     if (y == 0) return x;     return gcd(y, x % y);   }   int main() {     cin >> n;     for (int i = 1; i <= n; i++) cin >> a[i];     int x = gcd(a[1], a[2]);     for (int i = 3; i <= n; i++)       if (x > 1) {         x = gcd(x, a[i]);       }     if (x > 1) {       cout <<  YES  << endl;       cout <<  0  << endl;     } else {       for (int i = 1; i < n; i++) {         if (a[i] % 2 == 0)           continue;         else if (a[i + 1] % 2 == 0)           ans += 2, a[i] = 0;         else           ans++, a[i + 1] = 0, a[i] = 0;       }       if (a[n] % 2 == 0) {         cout <<  YES  << endl;         cout << ans << endl;       } else {         cout <<  YES  << endl;         cout << ans + 2 << endl;       }     }   }
#include <bits/stdc++.h>   using namespace std;   int n = 0, T = 0;   long long D[1003], g[1003];   long long x1[1003], xn[1003], Y1[1003], Yn[1003];   void getDisPre(long long x, int N, long long (&t1)[1003],                  long long (&tn)[1003]) {     if (N == 0) {       t1[0] = tn[0] = 0;       return;     }     if (N == 1) {       t1[1] = (x == 2);       tn[1] = (x == 1);       return;     }     if (x <= D[N - 1]) {       getDisPre(x, N - 1, t1, tn);       t1[N] = min(t1[N - 1], tn[N - 1] + 2);       tn[N] = min(t1[N - 1], tn[N - 1]) + g[N - 2] + 1;     } else {       getDisPre(x - D[N - 1], N - 2, t1, tn);       t1[N] = t1[N - 2] + 1;       tn[N] = tn[N - 2];     }   }   long long dis(long long x, long long y, long long N) {     if (N <= 1) return x != y;     if (x > y) swap(x, y);     if (x <= D[N - 1] && y <= D[N - 1])       return min(min(min(x1[N - 1] + Y1[N - 1], xn[N - 1] + Yn[N - 1]),                      min(x1[N - 1] + Yn[N - 1] + 2, xn[N - 1] + Y1[N - 1] + 2)),                  dis(x, y, N - 1));     else if (x <= D[N - 1])       return min(x1[N - 1], xn[N - 1]) + 1 + Y1[N - 2];     else       return dis(x - D[N - 1], y - D[N - 1], N - 2);   }   int main() {     scanf( %d %d , &T, &n);     if (n > 80) n = 80;     D[0] = 1;     D[1] = 2;     for (int i = 2; i <= n; ++i) D[i] = D[i - 1] + D[i - 2];     g[0] = 0;     g[1] = 1;     g[2] = 1;     for (int i = 3; i <= n; ++i) g[i] = g[i - 2] + 1;     for (int t = 1; t <= T; ++t) {       long long x = 0, y = 0;       scanf( %lld %lld , &x, &y);       if (x > y) swap(x, y);       getDisPre(x, n, x1, xn);       getDisPre(y, n, Y1, Yn);       printf( %lld n , dis(x, y, n));     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool debug = 0;   int n, m, k;   int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};   string direc =  RDLU ;   long long ln, lk, lm;   void etp(bool f = 0) {     puts(f ?  YES  :  NO );     exit(0);   }   void addmod(int &x, int y, int mod = 1000000007) {     assert(y >= 0);     x += y;     if (x >= mod) x -= mod;     assert(x >= 0 && x < mod);   }   void et() {     puts( -1 );     exit(0);   }   long long fastPow(long long x, long long y, int mod = 1000000007) {     long long ans = 1;     while (y > 0) {       if (y & 1) ans = (x * ans) % mod;       x = x * x % mod;       y >>= 1;     }     return ans;   }   long long gcd1(long long x, long long y) {     long long z = y;     while (x % y != 0) {       z = x % y;       x = y;       y = z;     }     return z;   }   char s[100005];   bool vis[30];   void fmain(int ID) {     scanf( %d%d , &n, &k);     scanf( %s , s + 1);     for (int(i) = 1; (i) <= (int)(n); (i)++) vis[s[i] -  a ] = 1;     if (n < k) {       for (int(i) = 1; (i) <= (int)(n); (i)++) printf( %c , s[i]);       for (int(j) = 0; (j) < (int)(26); (j)++)         if (vis[j]) {           for (int(cc) = 0; (cc) < (int)(k - n); (cc)++) printf( %c ,  a  + j);           break;         }       return;     }     for (int i = k; i; i--) {       for (int j = (s[i] -  a ) + 1; j < 26; j++)         if (vis[j]) {           for (int(z) = 1; (z) <= (int)(i - 1); (z)++) printf( %c , s[z]);           printf( %c ,  a  + j);           for (int(tar) = 0; (tar) < (int)(26); (tar)++)             if (vis[tar]) {               for (int z = i + 1; z <= k; z++) printf( %c ,  a  + tar);               return;             }           return;         }     }   }   int main() {     int t = 1;     for (int(i) = 1; (i) <= (int)(t); (i)++) {       fmain(i);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string s;     cin >> s;     int hr = s[0] -  0 ;     hr = hr * 10 + s[1] -  0 ;     if (hr >= 12) hr -= 12;     int min = s[3] -  0 ;     min = min * 10 + s[4] -  0 ;     double b = min * 6;     double a = ((double)hr + (double)min / 60) * 30;     printf( %.9lf %.9lf , a, b);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t = 0, counterarr[3] = {5, 7, 5}, c = 0;     string x;     bool arr[3] = {};     while (t < 3) {       getline(cin, x);       for (int i = 0; i < x.length(); i++) {         if (x[i] ==  a  || x[i] ==  e  || x[i] ==  u  || x[i] ==  i  ||             x[i] ==  o )           c++;       }       if (c == counterarr[t]) {         arr[t] = true;       }       c = 0;       t++;     }     if (arr[0] == 1 && arr[1] == 1 && arr[2] == 1)       cout <<  YES n ;     else       cout <<  NO n ;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int sum1 = 0, sum2 = 0, sum3 = 0;     int n;     cin >> n;     int a, b, c;     for (int i = 0; i < n; i++) {       cin >> a >> b >> c;       sum1 += a;       sum2 += b;       sum3 += c;     }     if (sum1 == 0 && sum2 == 0 && sum3 == 0)       cout <<  YES ;     else       cout <<  NO ;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       int n;       cin >> n;       n *= 2;       int arr[n];       vector<int> ans;       unordered_set<int> s;       for (int i = 0; i < n; i++) {         cin >> arr[i];         if (s.find(arr[i]) == s.end()) {           ans.push_back(arr[i]);           s.insert(arr[i]);         }       }       for (int i = 0; i < ans.size(); i++) {         cout << ans[i] <<    ;       }       cout << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   const int64_t INF = 1e18, MOD = 1e9 + 7;   const int64_t MAXN = 1e3;   pair<int64_t, int64_t> last = {0, 0};   pair<int64_t, int64_t> ask(int64_t i) {     if (i != -1) cout <<  +   << (i + 1) << endl;     int64_t a, b;     cin >> a >> b;     a -= last.first, b -= last.second;     last = {a + last.first, b + last.second};     return {a, b};   }   int64_t search(int64_t v) {     for (int64_t i = 1; i < MAXN; i++) {       if ((i * (i - 1)) / 2 == v) return i;     }     return -1;   }   int32_t main() {     ios_base::sync_with_stdio(false);     int64_t n;     cin >> n;     ask(-1);     vector<int64_t> ans(n);     pair<int64_t, int64_t> q1 = ask(0);     pair<int64_t, int64_t> q2 = ask(1);     pair<int64_t, int64_t> q3 = ask(2);     pair<int64_t, int64_t> q4 = ask(0);     ans[0] = search(q4.first) + 1;     if (q2.second == 0)       ans[2] = 1;     else       ans[2] = search(q3.first) + 1;     ans[1] = q4.second / ans[2];     int64_t carry = q3.second - ans[1] * (ans[0] - 1);     for (int64_t i = 3; i < n - 1; i++) {       pair<int64_t, int64_t> qur = ask(i);       if (carry == 0)         ans[i] = 1;       else         ans[i] = search(qur.first) + 1;       carry = qur.second - ans[i - 1] * ans[i - 2];     }     if (carry == 0)       ans[n - 1] = 0;     else       ans[n - 1] = carry / ans[n - 3];     ans[0]--;     for (int64_t i = 0; i < n - 1; i++) ans[i]--;     cout <<  !  ;     for (int64_t i = 0; i < n; i++) cout << ans[i] <<    ;     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 1e9;   const int Maxn = 1005;   const int dx[] = {-1, 0, 1, 0};   const int dy[] = {0, 1, 0, -1};   struct pos {     int first, second, third;   };   string s;   int n, k;   pair<int, int> d[11111];   int main() {     scanf( %d%d , &n, &k);     cin >> s;     int ans = INF;     string as =   ;     string os = s;     for (char c =  0 ; c <=  9 ; c++) {       s = os;       for (int(i) = 0; (i) < (int)(n); i++)         d[i] = {abs(s[i] - c), s[i] >= c ? -(n - i) : n - i};       sort(d, d + n);       int cur = 0;       for (int(i) = 0; (i) < (int)(k); i++) {         cur += d[i].first;         int x = d[i].second;         if (x < 0) x = -x;         x = -x + n;         s[x] = c;       }       if (cur < ans || (cur == ans && s < as)) {         as = s;         ans = cur;       }     }     printf( %d n , ans);     puts(as.c_str());     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int L[100000 + 10], dp1[100000 + 10], dp2[100000 + 10];   int lis(int *seq, int *ls, int N) {     int len = 0;     for (int i = 1; i <= N; ++i) {       int lo = 1, hi = len;       while (lo <= hi) {         int m = (lo + hi) / 2;         if (L[m] <= seq[i])           lo = m + 1;         else           hi = m - 1;       }       L[lo] = seq[i], ls[i] = lo;       if (len < lo) len = lo;     }     return len;   }   int A[100000 + 10], Rev[100000 + 10];   int solve(int n) {     lis(A, dp1, n);     lis(Rev, dp2, n);     int ans = 0;     for (int i = 1, j = n; i <= n; i++, j--) {       ans = max(ans, dp1[i] + dp2[j] - 1);     }     return ans;   }   int go(vector<int> &arr, int n) {     for (int i = 1, j = n; i <= n; i++, j--) A[i] = arr[i - 1], Rev[j] = A[i];     return solve(n);   }   vector<int> V;   int arr[100000 + 5];   int main() {     int n, m, i, l, r, ans = 0;     scanf( %d %d , &n, &m);     for (i = 1; i <= n; i++) {       scanf( %d %d , &l, &r);       arr[l]++;       arr[r + 1]--;     }     for (i = 1; i <= m; i++) arr[i] += arr[i - 1];     for (int i = 1; i <= m; i++) {       V.push_back(arr[i]);     }     cout << go(V, V.size()) << endl;   }
#include <bits/stdc++.h>   using namespace std;   int n, c0, c1, t0, t1, w0, w1, tot, q[2][1000010];   char s[1000010];   vector<int> v[1000010];   int main() {     scanf( %s , s + 1);     n = strlen(s + 1);     for (int i = (1); i <= (n); i++)       if (s[i] ==  0 )         c0++;       else         c1++;     if (c0 < c1) {       puts( -1 );       return 0;     }     t0 = 1;     w0 = 0;     t1 = 1;     w1 = 0;     for (int i = (1); i <= (n); i++) {       if (s[i] ==  0 ) {         if (t1 > w1) {           v[++tot].push_back(i);           q[0][++w0] = tot;         } else {           int now = q[1][t1];           v[now].push_back(i);           q[0][++w0] = now;           t1++;         }       } else {         if (t0 > w0) {           puts( -1 );           return 0;         }         int now = q[0][t0];         v[now].push_back(i);         q[1][++w1] = now;         t0++;       }     }     for (int i = (1); i <= (tot); i++) {       int w = (int)v[i].size() - 1;       if (s[v[i][w]] ==  1 ) {         puts( -1 );         return 0;       }     }     printf( %d n , tot);     for (int i = (1); i <= (tot); i++) {       printf( %d , (int)v[i].size());       for (int j = (0); j <= ((int)v[i].size() - 1); j++) printf(  %d , v[i][j]);       puts(  );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long left(long long i, long long n) {     if (i == 0) return n - 1;     return i - 1;   }   long long solve(string a, long long n) {     long long cw = 0;     long long ccw = 0;     for (long long i = 0; i < n; i++) {       if (a[i] ==  - ) continue;       if (a[i] ==  < )         ccw++;       else         cw++;     }     if (cw == 0 || ccw == 0) return n;     long long cnt = 0;     for (long long i = 0; i < n; i++) {       if (a[left(i, n)] ==  -  || a[i] ==  - ) cnt++;     }     return cnt;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long t;     cin >> t;     while (t--) {       long long n;       cin >> n;       string a;       cin >> a;       cout << solve(a, n) <<   n ;     }     return 0;   }