malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int maxv = 1.5e7;   const int bit = 29;   int cnt[maxv] = {};   int go[maxv][2] = {};   int tot = 1;   void add(int v, int d, int val) {     cnt[v]++;     if (d == -1) return;     if (!go[v][(val >> d) & 1]) go[v][(val >> d) & 1] = ++tot;     add(go[v][(val >> d) & 1], d - 1, val);   }   void get(int v, int d, int val, int& t_a) {     assert(cnt[v]);     cnt[v]--;     if (d == -1) return;     for (int k = ((val >> d) & 1), l = 0; l < 2; k = 1 - k, ++l)       if (go[v][k]) {         get(go[v][k], d - 1, val, t_a);         if (!cnt[go[v][k]]) go[v][k] = 0;         t_a += (k << d);         return;       }   }   int main() {     int n;     cin >> n;     vector<int> msg(n);     for (int& i : msg) cin >> i;     for (int i = 0; i < n; i++) {       int x;       cin >> x;       add(1, bit, x);     }     for (int i : msg) {       int out = 0;       get(1, bit, i, out);       assert((i ^ out) >= 0);       cout << (i ^ out) <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 7;   int head[N], nxt[N << 1], ver[N << 1], tot;   int n, d[N], out[N], f[N], ji[N], ou[N];   vector<int> v[N];   bool flag;   void add(int x, int y) {     ver[++tot] = y;     nxt[tot] = head[x], head[x] = tot;     out[x]++;   }   void dfs(int x, int fa) {     d[x] = d[fa] + 1;     f[x] = fa;     for (int i = head[x]; i; i = nxt[i]) {       int y = ver[i];       if (y == fa) continue;       dfs(y, x);     }   }   void dfs2(int x, int fa) {     for (int i = head[x]; i; i = nxt[i]) {       int y = ver[i];       if (y == fa) continue;       dfs2(y, x);       if (ou[y]) ji[x] = 1;       if (ji[y]) ou[x] = 1;     }     if (ou[x] && ji[x]) flag = true;   }   int main() {     scanf( %d , &n);     for (int i = 1; i < n; i++) {       int x, y;       scanf( %d%d , &x, &y);       add(x, y), add(y, x);     }     int root = 0, minn = 0, maxx = n - 1;     for (int i = 1; i <= n; i++)       if (out[i] >= 2) {         root = i;         break;       }     for (int i = 1; i <= n; i++)       if (out[i] == 1) ou[i] = 1;     dfs2(root, 0);     minn = (flag ? 3 : 1);     dfs(root, 0);     for (int i = 1; i <= n; i++) v[f[i]].push_back(i);     for (int i = 1; i <= n; i++) {       int siz = v[i].size(), cnt = 0;       if (!siz) continue;       for (int j = 0; j < siz; j++) {         int tt = v[i][j];         if (out[tt] == 1) cnt++;       }       if (cnt) maxx -= cnt - 1;     }     printf( %d %d n , minn, maxx);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int cnt[3], ans;   vector<int> c;   vector<vector<int>> sum;   vector<vector<int>> arr;   void dfs(int x, int p) {     for (auto i : arr[x]) {       if (i != p) {         dfs(i, x);         sum[x][0] += sum[i][0];         sum[x][1] += sum[i][1];         sum[x][2] += sum[i][2];       }     }     sum[x][c[x]]++;     if (sum[x][1] == 0 && sum[x][2] == cnt[2] ||         sum[x][1] == cnt[1] && sum[x][2] == 0)       ans++;   }   int main() {     cin.tie(0), ios::sync_with_stdio(0);     int n;     cin >> n;     c.resize(n);     arr.resize(n);     for (int i = 0; i < n; i++) cin >> c[i], cnt[c[i]]++;     for (int i = 0; i < n - 1; i++) {       int a, b;       cin >> a >> b;       arr[a - 1].push_back(b - 1);       arr[b - 1].push_back(a - 1);     }     sum.resize(n, vector<int>(3, 0));     dfs(0, 0);     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, i, j, k, res[200500], st1[200500][20], st2[200500][20];   int l2(int n) {     int r = 0;     while (n - 1) {       r++;       n >>= 1;     }     return r;   }   int chk1(int l, int r) {     int k = l2(r - l + 1);     return max(st1[l][k], st1[r - (1 << k) + 1][k]);   }   int chk2(int l, int r) {     int k = l2(r - l + 1);     return min(st2[l][k], st2[r - (1 << k) + 1][k]);   }   struct sb {     int id, l, r;     bool operator<(const sb x) const { return r > x.r; }   } tmp, s[200500];   vector<sb> v[200500];   priority_queue<sb> q;   void ans() {     for (int i = 1; i <= n; i++) {       printf( %d  , res[i]);     }     puts(  );   }   int main() {     memset(st2, 0x3f, sizeof(st2));     scanf( %d , &n);     for (i = 1; i <= n; i++) {       scanf( %d%d , &j, &k);       s[i].id = i;       s[i].l = j;       s[i].r = k;       v[j].push_back(s[i]);     }     for (i = 1; i <= n; i++) {       for (auto j : v[i]) {         q.push(j);       }       s[i] = q.top();       q.pop();       res[s[i].id] = i;       st1[i][0] = s[i].r;       st2[i][0] = s[i].l;     }     for (j = 1; j <= 18; j++) {       for (i = 1; i + (1 << j) - 1 <= n; i++) {         st1[i][j] = max(st1[i][j - 1], st1[i + (1 << (j - 1))][j - 1]);         st2[i][j] = min(st2[i][j - 1], st2[i + (1 << (j - 1))][j - 1]);       }     }     for (i = 1; i <= n; i++) {       if (s[i].l < i && chk1(s[i].l, i - 1) >= i) {         puts( NO );         ans();         for (j = i - 1;; j--) {           if (s[j].r >= i) {             swap(res[s[i].id], res[s[j].id]);             break;           }         }         ans();         return 0;       }       if (s[i].r > i && chk2(i + 1, s[i].r) <= i) {         puts( NO );         ans();         for (j = i + 1;; j++) {           if (s[j].l <= i) {             swap(res[s[i].id], res[s[j].id]);             break;           }         }         ans();         return 0;       }     }     puts( YES );     ans();   }
#include <bits/stdc++.h>   using namespace std;   const int M = 1e3 + 5;   long long int dp[M][12][M], inv[M], n, d, mod;   long long int pw(long long int a, long long int b) {     if (b == 0) return 1ll;     long long int p = pw(a, b / 2ll);     if (b % 2ll)       return p * p % mod * a % mod;     else       return p * p % mod;   }   int main() {     cin >> n >> d >> mod;     for (long long int i = 1; i <= n; i++) inv[i] = pw(i, mod - 2ll);     dp[1][0][0] = 1;     for (int i = 2; i <= n; i++)       for (int j = 1; j <= d; j++)         for (int k = (i - 1) / j; k <= i - 1; k++) {           dp[i][j][k] = dp[i][j][k - 1];           long long int cur = 1, buf = dp[k][d - 1][k - 1];           for (int t = 1; t <= j && t * k <= i - 1; t++) {             cur = cur * buf++ % mod * inv[t] % mod;             (dp[i][j][k] += dp[i - t * k][j - t][min(k - 1, i - t * k - 1)] *                             (cur + (k == 1))) %= mod;           }         }     long long int ans = dp[n][d][(n - 1) / 2];     if (n % 2 == 0)       (ans += dp[n / 2][d - 1][n / 2 - 1] * (dp[n / 2][d - 1][n / 2 - 1] + 1) %               mod * inv[2]) %= mod;     cout << (n <= 2 ? 1 : ans) << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr);     long long n, m;     cin >> n >> m;     vector<vector<long long>> dist((size_t)n,                                    vector<long long>((size_t)n, (long long)1e16));     for (long long i = 0; i < n; i++) {       dist[i][i] = (long long)0;     }     for (long long i = 0; i < m; i++) {       long long u, v;       cin >> u >> v;       u--, v--;       dist[u][v] = dist[v][u] = 0;     }     for (long long k = 0; k < n; k++) {       for (long long i = 0; i < n; i++) {         for (long long j = 0; j < n; j++) {           dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);         }       }     }     long long s, b, k, h;     cin >> s >> b >> k >> h;     vector<pair<long long, pair<long long, long long>>> x((size_t)s);     for (long long i = 0; i < s; i++) {       cin >> x[i].first >> x[i].second.first >> x[i].second.second;       x[i].first--;     }     vector<pair<long long, long long>> y((size_t)b);     for (long long i = 0; i < b; i++) {       cin >> y[i].first >> y[i].second;       y[i].first--;     }     vector<vector<long long>> adj((size_t)s);     for (long long i = 0; i < s; i++) {       for (long long j = 0; j < b; j++) {         if (x[i].second.first >= y[j].second &&             x[i].second.second >= dist[x[i].first][y[j].first]) {           adj[i].push_back(j);         }       }     }     vector<bool> visited;     vector<long long> matching((size_t)b, -1);     function<bool(long long)> visit = [&](long long i) {       if (visited[i]) {         return false;       }       visited[i] = true;       for (long long j : adj[i]) {         if (matching[j] == -1 || visit(matching[j])) {           matching[j] = i;           return true;         }       }       return false;     };     long long f = 0;     for (long long i = 0; i < s; i++) {       visited.assign((size_t)s, false);       if (visit(i)) {         f++;       }     }     cout << min(f * k, h * s) << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(false);     cin.tie(nullptr);     int n;     cin >> n;     int x, y;     cin >> x >> y;     string s;     cin >> s;     bool flag = false;     int cnt = 0;     for (int i = 0; i < n; ++i) {       if (s[i] ==  0 ) {         flag = true;       } else if (flag) {         ++cnt;         flag = false;       }     }     if (flag) ++cnt;     long long ans = 1LL * (cnt - 1) * min(x, y) + y;     if (cnt == 0) ans = 0;     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string cad;     int cnt = 0, ans = 0;     cin >> cnt >> cad;     cnt = 0;     for (int i = 0; i < cad.size(); i++) {       if (cad[i] ==  x ) {         cnt++;       } else {         ans += max(0, cnt - 2);         cnt = 0;       }     }     ans += max(0, cnt - 2);     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int x, y, a, b, c;     cin >> x >> y >> a >> b >> c;     long long int t = a * 2;     long long int r = c * 3;     cout << max(t + b - x, 0ll) + max(r + b - y, 0ll);     return 0;   }
#include <bits/stdc++.h>   const int kInf = 0x3f3f3f3f;   int len, n;   int msk[200010];   int mem[21][1 << 20];   int f[200010], s[200010];   int conv(char *s) {     int res = 0;     for (int i = 0; i < len; i++) res = (res << 1) + (s[i] -  0 );     return res;   }   int g(int i, int j) {     int p = msk[i], q = msk[j];     for (int i = len; i >= 0; i--)       if ((p & ((1 << i) - 1)) == (q >> (len - i))) return i;     assert(0);   }   inline void upd(int &x, int y) {     if (y < x) x = y;   }   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       static char ts[22];       scanf( %s , ts);       len = strlen(ts);       msk[i] = conv(ts);     }     for (int i = 2; i <= n; i++) s[i] = s[i - 1] + g(i - 1, i);     memset(mem, 0x3f, sizeof(mem));     mem[0][0] = 0;     for (int i = 1; i <= n; i++) {       f[i] = kInf;       if (i < n) {         for (int l = 0; l <= len; l++) {           int tmp = mem[l][msk[i + 1] >> (len - l)];           if (tmp != kInf) upd(f[i], tmp + i * len - s[i] - l);         }         for (int l = 0; l <= len; l++)           upd(mem[l][msk[i] & ((1 << l) - 1)], f[i] + s[i + 1] - i * len);       } else {         f[i] = mem[0][0] + i * len - s[i];       }     }     printf( %d n , f[n]);   }
#include <bits/stdc++.h>   using namespace std;   long long int n;   long long int a[100001];   vector<pair<long long int, long long int> > g[100001];   long long int dis[100001];   long long int rem[100001];   long long int dp[100001];   long long int child[100001];   long long int ct = 1;   void simpledfs(long long int x) {     rem[x] = 1;     for (long long int i = 0; i < g[x].size(); i++) {       simpledfs(g[x][i].first);     }   }   void dfs1(long long int x, long long int distance) {     dis[x] = distance;     long long int temp = 0;     long long int mi = 1e9;     long long int pos = -1;     for (long long int i = 0; i < g[x].size(); i++) {       dfs1(g[x][i].first, distance + g[x][i].second);       temp = temp + child[g[x][i].first] + 1;       if (dis[g[x][i].first] < mi) {         mi = dis[g[x][i].first];         pos = g[x][i].first;       }     }     dp[x] = pos;     child[x] = temp;   }   void dfs2(long long int x, long long int minv) {     for (long long int i = 0; i < g[x].size(); i++) {       long long int cur = g[x][i].first;       if ((dis[cur] - minv) > a[cur])         continue;       else {         ct++;         dfs2(cur, min(minv, dis[cur]));       }     }   }   int main() {     cin >> n;     for (long long int i = 1; i <= n; i++) cin >> a[i];     for (long long int i = 2; i <= n; i++) {       long long int p, c;       cin >> p >> c;       g[p].push_back(make_pair(i, c));     }     dfs1(1, 0);     dfs2(1, 0);     cout << n - ct;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e4 + 5, mod = 1e9 + 9, bit = 61, sq = 1000;   const int T = (100001 + sq - 1) / sq;   vector<int> lucky;   bool isl[N] = {0};   int bid[100005], a[100005], beg[T], en[T], lazy[T] = {0};   int fq[T][N];   void create() {     for (int d = 1; d <= 4; d++) {       for (int mask = 0; mask < (1ll << d); mask++) {         int curr = 0;         for (int j = 0; j <= d - 1; j++) {           curr = (curr * 10);           if (mask & (1ll << j)) {             curr += 4;           } else {             curr += 7;           }         }         isl[curr] = 1;         lucky.push_back(curr);       }     }   }   signed main() {     ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);     int t = 1;     memset(fq, 0, sizeof(fq));     create();     while (t--) {       int n, q;       cin >> n >> q;       int j = -1;       for (int i = 1; i <= n; i++) {         cin >> a[i];         if (i % sq == 1) {           bid[i] = ++j;           beg[j] = i;           en[j] = min(i + sq - 1, n);         } else {           bid[i] = j;         }         fq[j][a[i]]++;       }       while (q--) {         string tp;         int l, r;         cin >> tp >> l >> r;         if (tp[0] ==  c ) {           int ans = 0;           if (bid[l] == bid[r]) {             for (int i = l; i <= r; i++) {               ans += isl[a[i] + lazy[bid[l]]];             }           } else {             for (int i = l; i <= en[bid[l]]; i++) {               ans += isl[a[i] + lazy[bid[l]]];             }             for (int i = bid[l] + 1; i <= bid[r] - 1; i++) {               for (auto x : lucky) {                 if (x >= lazy[i]) {                   ans += fq[i][x - lazy[i]];                 }               }             }             for (int i = beg[bid[r]]; i <= r; i++) {               ans += isl[a[i] + lazy[bid[r]]];             }           }           cout << ans <<   n ;         } else {           int d;           cin >> d;           if (bid[l] == bid[r]) {             for (int i = l; i <= r; i++) {               fq[bid[i]][a[i]]--;               fq[bid[i]][a[i] + d]++;               a[i] += d;             }           } else {             for (int i = l; i <= en[bid[l]]; i++) {               fq[bid[i]][a[i]]--;               fq[bid[i]][a[i] + d]++;               a[i] += d;             }             for (int i = bid[l] + 1; i <= bid[r] - 1; i++) {               lazy[i] += d;             }             for (int i = beg[bid[r]]; i <= r; i++) {               fq[bid[i]][a[i]]--;               fq[bid[i]][a[i] + d]++;               a[i] += d;             }           }         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int inf = 1e9 + 7;   int main() {     long long int n;     cin >> n;     vector<pair<long long int, long long int> > arr(n + 1);     for (long long int i = 1; i < n + 1; i++) {       long long int a, b;       cin >> a >> b;       arr[i].first = a;       arr[i].second = b;     }     vector<long long int> ans(n + 1);     ans[1] = 1;     long long int x, y;     x = arr[1].first;     y = arr[1].second;     if (arr[x].first == y or arr[x].second == y) {       ans[2] = x;       ans[3] = y;       long long int i = 3;       while (i != n) {         i++;         long long int a = arr[ans[i - 2]].first;         long long int b = arr[ans[i - 2]].second;         ans[i] = (a == ans[i - 1] ? b : a);       }       for (int i = 1; i < ans.size(); i++) {         cout << ans[i] <<    ;       }       return 0;     } else {       ans[2] = y;       ans[3] = x;       long long int i = 3;       while (i != n) {         i++;         long long int a = arr[ans[i - 2]].first;         long long int b = arr[ans[i - 2]].second;         ans[i] = (a == ans[i - 1] ? b : a);       }       for (int i = 1; i < ans.size(); i++) {         cout << ans[i] <<    ;       }       return 0;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long a[100020], b[100020];   int main() {     int m, n;     scanf( %d%d , &m, &n);     long long sum1 = 0, sum2 = 0, s1 = 0, s2 = 0, Max1 = 0, Max2 = 0;     for (int i = 1; i <= m; i++) {       scanf( %I64d , &a[i]);       sum1 += a[i];       if (a[i] > Max1) {         Max1 = a[i];         s1 = i;       }     }     for (int i = 1; i <= n; i++) {       scanf( %I64d , &b[i]);       sum2 += b[i];       if (b[i] > Max2) {         Max2 = b[i];         s2 = i;       }     }     long long ans1 = sum1 * n, ans2 = sum2 * m;     for (int i = 1; i <= m; i++) {       if (i != s1 && a[i] < sum2) ans2 = ans2 - sum2 + a[i];     }     for (int i = 1; i <= n; i++) {       if (i != s2 && b[i] < sum1) ans1 = ans1 - sum1 + b[i];     }     if (ans1 > ans2)       printf( %I64d n , ans2);     else       printf( %I64d n , ans1);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 2005;   char mpt[2005][2005];   int dp[maxn][maxn];   int col[maxn];   int main() {     int n, m, k;     scanf( %d%d%d , &n, &m, &k);     for (int i = 1; i <= n; i++) scanf( %s , mpt[i] + 1);     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= m; j++) {         if (mpt[i][j] ==  L ) {           int w = i - 1;           if (j - w >= 1) dp[i][j - w] += 1;         } else if (mpt[i][j] ==  R ) {           int w = i - 1;           if (j + w <= m) dp[i][j + w] += 1;         } else if (mpt[i][j] ==  U  && i % 2 == 1) {           col[j] += 1;         } else if (mpt[i][j] ==  D ) {           continue;         }       }     }     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= m; j++) {         col[j] += dp[i][j];       }     }     for (int i = 1; i <= m; i++) printf( %d  , col[i]);     printf(  n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, k, c, x, y, rem;   char a[501][501];   int v[501][501];   void dfs(int x, int y) {     if (rem == 0 || a[x][y] ==  # ) return;     if (x < 0 || x >= n || y < 0 || y >= m || v[x][y] == 1) return;     v[x][y] = 1;     rem--;     dfs(x + 1, y);     dfs(x, y + 1);     dfs(x, y - 1);     dfs(x - 1, y);   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> n >> m >> k;     for (int i = 0; i < n; i++)       for (int j = 0; j < m; j++) {         cin >> a[i][j];         if (a[i][j] ==  . ) {           c++;           if (c == 1) {             x = i;             y = j;           }         }       }     rem = c - k;     dfs(x, y);     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         if (v[i][j] == 0 && a[i][j] ==  . )           cout <<  X ;         else           cout << a[i][j];       }       cout <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2e5 + 5;   const int mod = 1e9 + 7;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int n, m;     long long ans = 0;     cin >> n >> m;     for (int i = 1; i <= n; i++) {       ans += ((i % 5) + m) / 5;     }     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   struct opt {     vector<set<int>> s;     vector<int> l;     vector<int> r;     int n;     opt(string t) {       n = t.size();       t =  $  + t;       int c = 1;       s.resize(n + 1);       l.assign(n + 1, 1);       r.assign(n + 1, n);       s[1].insert(n);       for (int i = n - 1; i >= 1; i--) {         if (t[i] == t[i + 1])           c++;         else           c = 1;         s[c].insert(i);       }       char val = t[n];       for (int i = n - 1; i >= 1; i--) {         if (t[i] == val)           r[i] = r[i + 1];         else {           val = t[i];           r[i] = i;         }       }       val = t[1];       for (int i = 2; i <= n; i++) {         if (t[i] == val)           l[i] = l[i - 1];         else {           val = t[i];           l[i] = i;         }       }     }     int nxt(int pos, int sz) {       auto it = s[sz].lower_bound(pos);       if (it == s[sz].end()) return -1;       int x = *it;       int a = max(pos, l[x]);       return a + sz;     }   };   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     int n;     cin >> n;     string s;     cin >> s;     string t = s;     for (int i = 0; i < n; i++)       if (t[i] ==  ? ) t[i] =  0 ;     opt a(t);     t = s;     for (int i = 0; i < n; i++)       if (t[i] ==  ? ) t[i] =  1 ;     opt b(t);     for (int i = 1; i <= n; i++) {       int now = 1;       int res = 0;       while (1) {         int one = a.nxt(now, i);         int two = b.nxt(now, i);         if (one == -1 && two == -1)           break;         else if (one == -1) {           res++;           now = two;         } else if (two == -1) {           res++;           now = one;         } else {           res++;           now = min(one, two);         }       }       cout << res <<    n [i == n];     }     return 0;   }
#include<cstdio>   #include<cstring>   #include<algorithm>   using namespace std;   #define N 100500   int n,is[N],mn=1e9,f1=1,f2=1,as[N],ct,s2[N];   char st[N];   int main()   {    scanf( %s ,st+1);n=strlen(st+1);    st[n+2]= # ;    int s1=0;    for(int i=0;i<=n+2;i++)if(st[i]== # )    {     if(!s1)continue;     mn=min(mn,s1),is[s1-1]=1;     if(s1&1)f2=0;     if(s1>1)f1=0;     s1=0;    }    else s1++;    for(int i=1;i<=mn;i++)    {     if(i==1&&!f1)continue;     if(i==2&&!f2)continue;     if(is[i])continue;     int ls=0;     for(int j=0;j<=n+2;j++)if(st[j]== # )     {      int l1=ls,r1=j-1;ls=j+1;      if(l1>=j)continue;      r1-=i-1;s2[r1]=1;      while(l1<r1)      {       s2[l1]=1;       int v1=l1+i;       if(v1>r1)v1=r1;       if(v1==r1-1)v1--;       l1=v1;      }     }     int s3=0;     for(int j=1;j<=n-i+1;j++)if(s2[j]){if(s3)as[++ct]=s3,s3=0;}else s3++;     if(s3)as[++ct]=s3;     printf( %d n ,ct);for(int i=1;i<=ct;i++)printf( %d  ,as[i]);     return 0;    }    printf( -1 n );   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 0x3f3f3f3f;   int a[10], n;   char s1, s2;   int main() {     a[0] = 118, a[1] = 60, a[2] = 94, a[3] = 62;     while (cin >> s1 >> s2) {       scanf( %d , &n);       n %= 4;       int k;       for (int i = 0; i < 4; i++)         if ((int)s1 == a[i]) {           k = i;           break;         }       int kk = (k + n) % 4, kkk = ((k - n) % 4 + 4) % 4;       if (a[kk] == (int)s2 && kkk == kk)         printf( undefined n );       else if (a[kk] == (int)s2)         printf( cw n );       else         printf( ccw n );     }     return 0;   }