malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int ABS(int a) {     if (a < 0) return (-a);     return a;   }   void input() {}   int a[100005];   int seg[100005];   int nxt[100005];   int hop[100005];   void readInt(int &n) {     n = 0;     char ch = getchar();     while (!isdigit(ch)) ch = getchar();     while (isdigit(ch)) {       n = n * 10 + ch - 48;       ch = getchar();     }   }   int main() {     input();     int n, q;     readInt(n);     readInt(q);     int sq = sqrt(n);     int c = 0, cnt = 0;     for (int i = (0); i < (n); ++i) {       readInt(a[i]);       seg[i] = cnt;       c++;       if (c == sq) c = 0, cnt++;     }     for (int i = (n - 1); i >= (0); --i) {       int to = i + a[i];       hop[i] = 1;       if (to >= n)         nxt[i] = -1;       else if (seg[to] != seg[i])         nxt[i] = to;       else {         nxt[i] = nxt[to];         hop[i] += hop[to];       }     }     while (q--) {       int type;       readInt(type);       if (type == 0) {         int x, y;         readInt(x);         readInt(y);         x--;         int i = x;         a[x] = y;         while (i >= 0) {           if (seg[i] != seg[x]) break;           int to = i + a[i];           hop[i] = 1;           if (to >= n)             nxt[i] = -1;           else if (seg[to] != seg[i])             nxt[i] = to;           else {             nxt[i] = nxt[to];             hop[i] += hop[to];           }           i--;         }       } else {         int x;         readInt(x);         x--;         int ans = 0;         int last = x;         while (x != -1) {           ans += hop[x];           last = x;           x = nxt[x];         }         while (last + a[last] < n) last = last + a[last];         printf( %d %d n , last + 1, ans);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mx = 200100;   struct node {     int x, y, z;   } a[mx];   struct nod {     int id, x;   } b[mx];   int fa[mx];   long long num[mx];   long long ans[mx];   int n, m;   bool cmp(node x, node y) { return x.z < y.z; }   bool cmp1(nod x, nod y) { return x.x < y.x; }   int find(int x) {     if (x != fa[x]) {       return fa[x] = find(fa[x]);     }     return fa[x];   }   int main() {     cin >> n >> m;     for (int i = 1; i <= n; i++) fa[i] = i, num[i] = 1;     for (int i = 1; i < n; i++) {       cin >> a[i].x >> a[i].y >> a[i].z;     }     for (int i = 1; i <= m; i++) {       cin >> b[i].x;       b[i].id = i;     }     sort(a + 1, a + n, cmp);     sort(b + 1, b + m + 1, cmp1);     int l = 1;     long long sum = 0;     for (int i = 1; i < n; i++) {       while (l <= m && a[i].z > b[l].x) {         ans[b[l].id] = sum;         l++;       }       int x = find(a[i].x);       int y = find(a[i].y);       sum += num[y] * num[x];       fa[x] = y;       num[y] += num[x];     }     while (l <= m) {       if (a[n - 1].z <= b[l].x) {         ans[b[l].id] = sum;       }       l++;     }     for (int i = 1; i <= m; i++) cout << ans[i] <<    n [i == m];     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int a[100005], ans[100005];   int main() {     long long int n, i, j;     cin >> n;     for (i = 0; i < n; i++) {       cin >> j;       a[j] += 1 * j;     }     ans[1] = a[1];     ans[2] = a[2];     ans[3] = a[1] + a[3];     for (i = 4; i < 100005; i++) {       ans[i] = max(ans[i - 2] + a[i], ans[i - 3] + a[i]);     }     cout << ans[100004];   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   int main() {     int T;     cin >> T;     while (T--) {       int n;       cin >> n;       long double theta = 3.14159265358979323846 / (2 * n);       long double answer = 1 / tan(theta);       cout << setprecision(15) << answer <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   const int M = 1 << 20, L = 100020;   char s[L];   int n, m, g[M], f[M], i, j, k, x, y, D;   void init() {     scanf( %d%d%s , &n, &m, s + 1);     D = (1 << m) - 1;     for (i = 1; i < n; i++) {       x = s[i] - 97;       y = s[i + 1] - 97;       if (x != y) g[1 << x | 1 << y]++;     }     for (j = 0; j < m; j++)       for (i = 0; i <= D; i++)         if (i >> j & 1) g[i] += g[i ^ 1 << j];   }   int min(int x, int y) { return x < y ? x : y; }   void work() {     memset(f, 0x3f, sizeof(f));     f[0] = 0;     for (i = 0; i <= D; i++)       for (j = 0; j < m; j++)         if ((i >> j & 1) == 0)           f[i | 1 << j] = min(f[i | 1 << j], f[i] + g[D] - g[i] - g[D ^ i]);     printf( %d , f[D]);   }   int main() {     init();     work();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   signed main() {     ios_base::sync_with_stdio(false);     cin.tie();     cout.tie();     long long t;     cin >> t;     while (t--) {       long long n;       cin >> n;       string a;       cin >> a;       string last = a;       for (long long i = 0; i <= n; ++i) {         string s;         s = a;         for (long long k = 1; k < n; ++k) {           if (a[k - 1] ==  A ) {             s[k] =  A ;           }         }         a = s;         if (a == last) {           cout << i <<   n ;           break;         }         last = a;       }     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string s;     cin >> s;     int n = s.length();     vector<int> P(n, 0);     int C = 0;     int R = 0;     for (int i = 1; i < n - 1; i++) {       int mirror = 2 * C - i;       if (R > i) {         P[i] = min(R - i, P[mirror]);       } else {         P[i] = 0;       }       while ((i + 1 + P[i] < n) && (i - 1 - P[i] >= 0) &&              (s[i + 1 + P[i]] == s[i - 1 - P[i]])) {         P[i]++;       }       if (i + P[i] > R) {         C = i;         R = i + P[i];       }     }     string rev(s);     reverse(rev.begin(), rev.end());     vector<int> T(n, 0);     T[0] = -1;     int pos = 2;     int cnd = 0;     while (pos < n) {       if (rev[pos - 1] == rev[cnd]) {         cnd++;         T[pos] = cnd;         pos++;       } else if (cnd > 0) {         cnd = T[cnd];       } else {         T[pos] = 0;         pos++;       }     }     int m = 0;     int revI = 0;     vector<int> found(n + 1, -1);     found[0] = 0;     while (revI < n && m + revI < n) {       if (rev[revI] == s[m + revI]) {         if (found[revI + 1] == -1) {           found[revI + 1] = m;         }         revI++;       } else {         m = m + revI - T[revI];         if (T[revI] > -1) {           revI = T[revI];         } else {           revI = 0;         }       }     }     vector<int> fend(n + 1, -1);     int fendMax = 0;     for (int i = 0; i <= n; i++) {       if (found[i] != -1) {         fend[i] = found[i] + i;         fendMax = i;       }     }     int best = 0;     int bestMidSt = 0;     int bestMidL = 0;     int bestLeftSt = 0;     int bestSideL = 0;     for (int i = 0; i < n; i++) {       int midStart = i - P[i];       int midEnd = i + P[i];       int lLow = 0;       int lHigh = min(n - midEnd, fendMax + 1);       int lCur = (lLow + lHigh) / 2;       while (lHigh - lLow > 1) {         if (fend[lCur] <= midStart) {           lLow = lCur;         } else {           lHigh = lCur;         }         lCur = (lLow + lHigh) / 2;       }       int curBest = 2 * P[i] + 1 + 2 * lCur;       if (curBest > best) {         best = curBest;         bestMidSt = midStart;         bestMidL = 2 * P[i] + 1;         bestLeftSt = found[lCur];         bestSideL = lCur;       }     }     if (bestSideL == 0) {       cout << 1 << endl;       cout << (bestMidSt + 1) <<     << bestMidL << endl;     } else {       cout << 3 << endl;       cout << (bestLeftSt + 1) <<     << bestSideL << endl;       cout << (bestMidSt + 1) <<     << bestMidL << endl;       cout << (n - bestSideL + 1) <<     << bestSideL << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool ck(int x) {     int t[50], l = 0;     while (x) t[l++] = x & 1, x >>= 1;     if (l & 1) {       int lim = l - 1 >> 1;       for (int i = 0; i < lim; i++)         if (t[i]) return 0;       for (int i = lim; i < l; i++)         if (!t[i]) return 0;     } else       return 0;     return 1;   }   int main() {     int n;     cin >> n;     for (int i = n; i >= 1; i--) {       if (n % i == 0 && ck(i)) {         printf( %d n , i);         return 0;       }     }   }
#include <bits/stdc++.h>   const int N = 2010;   std::set<std::pair<long long, int>> set;   long long a[N][N], dis[N];   bool vis[N];   int n;   int main() {     scanf( %d , &n);     memset(dis, 0x7f, sizeof(dis));     long long mine = LLONG_MAX;     for (int i = 0; i < n; ++i) {       for (int j = i + 1; j < n; ++j) {         scanf( %I64d , &a[i][j]);         mine = std::min(mine, a[j][i] = a[i][j]);       }     }     for (int i = 0; i < n; ++i) {       for (int j = 0; j < n; ++j) {         if (i == j) {           continue;         }         a[i][j] -= mine;         dis[i] = std::min(dis[i], 2 * a[i][j]);       }     }     for (int i = 0; i < n; ++i) {       set.insert({dis[i], i});     }     for (int i = 0; i < n; ++i) {       std::pair<long long, int> p = *(set.begin());       set.erase(set.begin());       vis[p.second] = true;       for (int j = 0; j < n; ++j) {         if (!vis[j] && p.second != j) {           set.erase({dis[j], j});           dis[j] = std::min(dis[p.second] + a[p.second][j], dis[j]);           set.insert({dis[j], j});         }       }     }     for (int i = 0; i < n; ++i) {       printf( %I64d n , dis[i] + (n - 1) * mine);     }     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( O3 )   #pragma GCC target( avx2 )   using namespace std;   void solve() {     int q;     cin >> q;     unordered_map<string, string> map;     while (q--) {       string a, b;       cin >> a >> b;       if (map.find(a) != map.end()) {         string s = map[a];         map.erase(a);         map[b] = s;         continue;       }       map[b] = a;     }     cout << map.size() <<   n ;     for (auto i : map) {       cout << i.second <<     << i.first <<   n ;     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     int t;     t = 1;     while (t--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int inf = INT_MAX;   const int mod = 1e9 + 7;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int t;     cin >> t;     while (t--) {       int n;       cin >> n;       int arr[2][n];       int sum[2][n];       for (int i = 0; i < 2; i++) {         for (int j = 0; j < n; j++) {           cin >> arr[i][j];           if (j == 0)             sum[i][j] = arr[i][j];           else             sum[i][j] = sum[i][j - 1] + arr[i][j];         }       }       int move1 = sum[0][n - 1];       int move2 = sum[1][n - 1];       int ans = min(move1 - arr[0][0], move2 - arr[1][n - 1]);       for (int i = 1; i < n; i++) {         int temp1 = move1 - sum[0][i];         int temp2 = sum[1][i - 1];         ans = min(ans, max(temp1, temp2));       }       cout << ans << endl;     }   }
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:167772160 )   using namespace std;   int main() {     int n;     cin >> n;     pair<int, int> x[1111];     for (int i = 0; i < n; ++i) cin >> x[i].first >> x[i].second;     long long p = 0, maxx = -1;     int j = 0;     for (int i = 0; i < x[n - 1].first; i++) {       if (p != 0) --p;       if (i == x[j].first - 1) {         p += x[j].second;         ++j;       }       if (p > maxx) maxx = p;     }     cout << x[n - 1].first + p <<     << maxx << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int n, k, a, b;   vector<long long int> arr;   long long int rec(long long int l, long long int r) {     long long int i = lower_bound(arr.begin(), arr.end(), l) - arr.begin();     long long int j = upper_bound(arr.begin(), arr.end(), r) - arr.begin();     long long int x = j - i;     long long int val;     if (x == 0) {       val = a;     } else {       val = b * x * (r - l + 1);     }     if (l == r || x == 0) {       return val;     }     long long int mid = (l + r) / 2;     return min(val, rec(l, mid) + rec(mid + 1, r));   }   int main() {     cin >> n >> k >> a >> b;     for (int i = 0; i < k; i++) {       int x;       cin >> x;       arr.push_back(x);     }     sort(arr.begin(), arr.end());     long long int start = 1;     long long int end = pow(2, n);     cout << rec(start, end) << endl;   }
#include <bits/stdc++.h>   using namespace std;   char s[10];   int main() {     scanf( %s , s);     int res = 1;     for (int i = 1; i < 7; i++) {       if (s[i] ==  1 )         res += 10, i++;       else         res += s[i] -  0 ;     }     printf( %d n , res);   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e6 + 10;   char s[N];   int main() {     vector<int> v1, v2;     scanf( %s , s);     int len = strlen(s);     for (int i = 0; i < len; i++) {       if (s[i] ==  l ) {         v1.push_back(i + 1);       } else         v2.push_back(i + 1);     }     for (int x : v2) printf( %d n , x);     for (int i = (int)v1.size() - 1; i >= 0; i--) printf( %d n , v1[i]);     return 0;   }
#include <bits/stdc++.h>   static const int MAXN = 50004;   static const int MAXE = 100004 * 2;   static const int MAXL = 20;   static const int MAXT = 1000005;   int n, e;   int head[MAXN], dest[MAXE], next[MAXE];   int l[MAXN], t[MAXN][MAXL];   int T = 0;   int p[MAXN];   int conf[MAXN], team[MAXN];   int team_conf[MAXT];   inline void add_edge(int u, int v) {     static int w = 0;     dest[w] = v;     next[w] = head[u];     head[u] = w++;   }   int main() {     scanf( %d%d , &n, &e);     for (int i = 0; i < n; ++i) head[i] = -1;     int u, v;     for (int i = 0; i < e; ++i) {       scanf( %d%d , &u, &v);       --u, --v;       add_edge(u, v);       add_edge(v, u);     }     for (int i = 0; i < n; ++i) {       scanf( %d , &l[i]);       for (int j = 0; j < l[i]; ++j) {         scanf( %d , &t[i][j]);         --t[i][j];         T = std::max(T, t[i][j]);       }     }     ++T;     srand(87665544);     for (int i = 0; i < n; ++i) p[i] = i;     for (int attempts = 0;; ++attempts) {       if (attempts % 16 == 0) {         std::random_shuffle(p, p + n);         std::fill(conf, conf + n, -1);         int ct[2];         for (int i = 0; i < n; ++i) {           ct[0] = ct[1] = 0;           for (int w = head[p[i]]; w != -1; w = next[w]) {             if (conf[dest[w]] != -1) ++ct[conf[dest[w]]];           }           conf[p[i]] = (ct[0] > ct[1] ? 1 : 0);         }       }       for (int i = 0; i < T; ++i) team_conf[i] = rand() % 2;       bool valid = true;       for (int i = 0; i < n; ++i) {         team[i] = -1;         for (int j = 0; j < l[i]; ++j)           if (conf[i] == team_conf[t[i][j]]) {             team[i] = t[i][j];             break;           }         if (team[i] == -1) {           valid = false;           break;         }       }       if (!valid) continue;       for (int i = 0; i < n; ++i)         printf( %d%c , team[i] + 1, i == n - 1 ?   n  :    );       for (int i = 0; i < T; ++i)         printf( %d%c , team_conf[i] + 1, i == T - 1 ?   n  :    );       break;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m;   int ans = 654;   vector<int> a, b, us(10);   int main() {     cin >> n >> m;     a.resize(n);     b.resize(m);     for (int i = 0; i < n; ++i) {       cin >> a[i];       us[a[i]] = 1;     }     for (int j = 0; j < m; ++j) {       cin >> b[j];       if (us[b[j]] == 1) {         ans = min(ans, b[j]);       }     }     sort(a.begin(), a.end());     sort(b.begin(), b.end());     cout << min({(a[0] * 10) + b[0], (b[0] * 10) + a[0], ans});   }
#include <bits/stdc++.h>   using namespace std;   inline void read(int &x) {     x = 0;     char c = getchar();     int f = 1;     while (!isdigit(c)) {       if (c ==  - ) f = -1;       c = getchar();     }     while (isdigit(c)) {       x = x * 10 + c -  0 ;       c = getchar();     }     x *= f;   }   const int N = 505000;   int n, a[N], ans[N];   int main() {     read(n);     for (int i = 1; i <= n; i++) read(a[i]);     for (int i = 0; i <= n - 2; i++) {       if ((n - i) & 1)         ans[i] = max(min(a[(1 + n - i) / 2],                          max(a[(1 + n - i) / 2 + 1], a[(1 + n - i) / 2 - 1])),                      min(a[(1 + n + i) / 2],                          max(a[(1 + n + i) / 2 + 1], a[(1 + n + i) / 2 - 1])));       else         ans[i] = max(a[(n - i + 1) / 2], a[(n + i + 2) / 2]);       if ((n & 1) && i == 1) ans[i] = max(ans[i], a[n / 2 + 1]);       if (i - 2 >= 0) ans[i] = max(ans[i], ans[i - 2]);     }     for (int i = 1; i <= n; i++) ans[n - 1] = max(ans[n - 1], a[i]);     for (int i = 0; i <= n - 1; i++) printf( %d  , ans[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MOD = 1000000007;   int dp[1001][2010];   int digit[1002], k;   void init() { memset(dp, -1, sizeof dp); }   int dfs(int pos, int dist, bool doing) {     if (pos == -1) return dist == 0;     if (!doing && dp[pos][dist] != -1) return dp[pos][dist];     int ans = 0;     int end = doing ? digit[pos] : 9;     for (int i = 0; i <= end; i++) {       int nextdist = dist == 0 ? 0 : dist + 1;       if (i == 4 || i == 7) {         if (dist <= k)           nextdist = 0;         else           nextdist = 1;       }       ans = (ans + dfs(pos - 1, nextdist, doing && i == end)) % MOD;     }     if (!doing) dp[pos][dist] = ans;     return ans;   }   int cal(char x[]) {     int pos = 0, l = strlen(x);     while (pos < l) {       digit[pos] = x[l - pos - 1] -  0 ;       pos++;     }     return dfs(pos - 1, k + 2, 1);   }   bool check(char x[]) {     int dist = k + 1;     for (int i = 0; i < strlen(x); i++) {       if (!dist) break;       if (x[i] ==  4  || x[i] ==  7 ) {         if (dist <= k)           dist = 0;         else           dist = 1;       } else         dist++;     }     return dist == 0;   }   int main() {     int T;     init();     char a[1002], b[1002];     scanf( %d %d , &T, &k);     while (T--) {       scanf( %s %s , a, b);       int ansa = cal(a);       int ansb = cal(b);       if (check(a)) ansa--;       ansb = ((ansb - ansa) % MOD + MOD) % MOD;       printf( %d n , ansb);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<string> vec_splitter(string s) {     s +=  , ;     vector<string> res;     while (!s.empty()) {       res.push_back(s.substr(0, s.find( , )));       s = s.substr(s.find( , ) + 1);     }     return res;   }   void debug_out(vector<string> __attribute__((unused)) args,                  __attribute__((unused)) int idx,                  __attribute__((unused)) int LINE_NUM) {     cerr <<   n ;   }   template <typename Head, typename... Tail>   void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {     if (idx > 0)       cerr <<  ,  ;     else       cerr <<  Line(  << LINE_NUM <<  )  ;     stringstream ss;     ss << H;     cerr << args[idx] <<   =   << ss.str();     debug_out(args, idx + 1, LINE_NUM, T...);   }   void run() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr), cout.tie(nullptr);   }   const int N = 5e4 + 4, MOD = 1e9 + 7, mod2 = 998244353;   int dp[N][503];   int n, k;   vector<int> adj[N];   long long ans;   void dfs(int u, int p) {     dp[u][0] = 1;     for (auto &v : adj[u]) {       if (v == p) continue;       dfs(v, u);       for (int i = 0; i < k; ++i) {         dp[u][i + 1] += dp[v][i];       }     }     long long sum = 0;     for (auto &v : adj[u]) {       if (v == p) continue;       for (int i = 1; i < k; ++i) {         sum += dp[v][i - 1] * (dp[u][k - i] - dp[v][k - i - 1]);       }     }     ans += dp[u][k] + sum / 2;   }   int main() {     run();     cin >> n >> k;     for (int i = 0; i < (int)(n - 1); ++i) {       int u, v;       cin >> u >> v;       adj[v].push_back(u);       adj[u].push_back(v);     }     dfs(1, -1);     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   void Genawy() {     std::ios_base::sync_with_stdio(0);     cin.tie(NULL);   }   int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }   int n, cost[305];   int length[305];   map<pair<int, int>, int> dp;   int solve(int ind, int gc) {     if (ind == n) return gc == 1 ? 0 : 1e9;     if (dp.find({ind, gc}) != dp.end()) return dp[{ind, gc}];     dp[{ind, gc}] = solve(ind + 1, gc);     dp[{ind, gc}] =         min(dp[{ind, gc}], solve(ind + 1, gcd(gc, length[ind])) + cost[ind]);     return dp[{ind, gc}];   }   int main() {     Genawy();     cin >> n;     for (int i = 0; i < n; i++) cin >> length[i];     for (int i = 0; i < n; i++) cin >> cost[i];     int ans = solve(0, 0);     if (ans >= 1e9) ans = -1;     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   int compare(const void *a, const void *b) {     long long la = *(long long *)a;     long long lb = *(long long *)b;     return la == lb ? 0 : la < lb ? -1 : 1;   }   long long aa[8], aa_[8];   int bb[8], dp[8][1 << (8 - 1)];   char pp[8];   int n, ans = 0x3f3f3f3f;   void solve(int i) {     int j;     if (i == n) {       int cnt, sum;       cnt = 0, sum = 0;       for (i = 0; i < n; i++) {         int k;         if (!pp[i]) cnt++;         k = dp[i][bb[i]];         sum += k == 1 && bb[i] == 0 ? 1 : k + 1;       }       if (cnt >= 2) sum++;       if (ans > sum) ans = sum;       return;     }     solve(i + 1);     pp[i] = 1;     for (j = i + 1; j < n; j++)       if (aa_[j] % aa[i] == 0) {         aa_[j] /= aa[i], bb[j] ^= 1 << i;         solve(i + 1);         aa_[j] *= aa[i], bb[j] ^= 1 << i;       }     pp[i] = 0;   }   int main() {     int i, j;     scanf( %d , &n);     for (i = 0; i < n; i++) scanf( %lld , &aa[i]);     qsort(aa, n, sizeof *aa, compare);     for (i = 0; i < n; i++) {       long long a;       int k, p, b;       a = aa[i];       k = 0;       for (p = 2; p <= a / p; p++)         while (a % p == 0) {           k++;           a /= p;         }       if (a > 1) k++;       dp[i][0] = k;       for (b = 1; b < 1 << i; b++) {         a = aa[i];         k = dp[i][0];         for (j = 0; j < i; j++)           if ((b & 1 << j)) {             if (a % aa[j] != 0) {               k = -1;               break;             }             a /= aa[j];             k -= dp[j][0];           }         dp[i][b] = k;       }     }     for (i = 0; i < n; i++) aa_[i] = aa[i];     solve(0);     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<string> v;   int main() {     string x, y;     int cnt = 0;     char temp;     int n;     cin >> n;     n = n + n - 1;     for (int i = 0; i < n; i++) {       cin >> x;       if (x ==  ** ) continue;       cin >> y;       x += y;       sort(v.begin(), v.end());       if (binary_search(v.begin(), v.end(), x)) continue;       cnt++;       v.push_back(x);       for (int j = 1; j <= 3; j++) {         y =   ;         if (j == 1) {           y += x[2];           y += x[0];           y += x[3];           y += x[1];           v.push_back(y);         } else if (j == 2) {           y += x[3];           y += x[2];           y += x[1];           y += x[0];           v.push_back(y);         } else if (j == 3) {           y += x[1];           y += x[3];           y += x[0];           y += x[2];           v.push_back(y);         }       }     }     cout << cnt;     return 0;   }