malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int INF = 1e9;   int main() {     std::ios_base::sync_with_stdio(false);     std::cin.tie(0);     int n, m, w, a, b, v;     cin >> n >> m >> a >> b >> v;     set<int> s;     set<int> l;     for (int i = 0; i < a; ++i) {       int x;       cin >> x;       s.insert(x);     }     for (int i = 0; i < b; ++i) {       int x;       cin >> x;       l.insert(x);     }     int q;     cin >> q;     for (int i = 0; i < q; ++i) {       int x1, y1, x2, y2;       cin >> x1 >> y1 >> x2 >> y2;       if (y1 > y2) {         swap(y1, y2);       }       if (x1 > x2) {         swap(x1, x2);       }       int ans = INF;       if (x1 == x2) {         ans = y2 - y1;       }       auto it = s.lower_bound(y1);       if (it != s.end()) {         int y = *it;         ans = min(ans, x2 - x1 + abs(y1 - y) + abs(y2 - y));       }       if (it != s.begin()) {         --it;         int y = *it;         ans = min(ans, x2 - x1 + abs(y1 - y) + abs(y2 - y));       }       it = l.lower_bound(y1);       if (it != l.end()) {         int y = *it;         ans = min(ans, abs(y1 - y) + abs(y2 - y) + (x2 - x1 + v - 1) / v);       }       if (it != l.begin()) {         --it;         int y = *it;         ans = min(ans, abs(y1 - y) + abs(y2 - y) + (x2 - x1 + v - 1) / v);       }       cout << ans << endl;     }     return 0;   }
#include <bits/stdc++.h>   const double pi = acos(-1);   const int MOD = 1e9 + 7;   const int INF = 1e9 + 7;   const int MAXN = 1e6 + 5;   const double eps = 1e-9;   using namespace std;   double xp, yp, vp, x, y, v, r, R;   double P, len, L;   pair<double, double> pos[2];   double f(double dphi) {     if (dphi > pi) dphi = 2 * pi - dphi;     if (dphi > P) return ((dphi - P) * r + L) / v;     return sqrt(len * len + R * R - 2 * len * R * cos(dphi)) / v;   }   int main() {     scanf( %lf %lf %lf %lf %lf %lf %lf , &xp, &yp, &vp, &x, &y, &v, &r);     double lo = 0, hi = 1e18;     R = hypot(xp, yp);     double omega = vp / R;     double phi0 = 0;     if (x * yp == xp * y) {       if (x * xp < 0 || y * yp < 0) phi0 = pi;     } else {       phi0 = acos((x * xp + y * yp) / (hypot(xp, yp) * hypot(x, y)));       if (x * yp < xp * y) phi0 = 2 * pi - phi0;     }     len = hypot(x, y);     L = sqrt(len * len - r * r) + sqrt(R * R - r * r);     P = acos(r / len) + acos(r / R);     hi = fabs(R - len) / v + 2 * pi * R / vp;     while (abs(hi - lo) > eps) {       double T = (lo + hi) / 2.;       double dphi = fmod(omega * T + phi0, 2 * pi);       if (dphi < 0) dphi += 2 * pi;       if (f(dphi) < T)         hi = T;       else         lo = T;     }     printf( %.20f n , lo);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<vector<int>> perm;   void generate(vector<int>& curr, int n) {     if (n == 4)       perm.push_back(curr);     else {       for (int i = n; i < 4; i++) {         swap(curr[n], curr[i]);         generate(curr, n + 1);         swap(curr[n], curr[i]);       }     }   }   bool yes(vector<string>& s, int i, int j, string& dir, int ind,            vector<int>& num) {     int m = s.size(), n = s[0].length();     if (i < 0 || j < 0 || i >= m || j >= n) return false;     if (s[i][j] ==  E ) return true;     if (s[i][j] ==  # ) return false;     if (ind == dir.length()) return false;     int val = dir[ind] -  0 ;     if (num[val] == 0) return yes(s, i + 1, j, dir, ind + 1, num);     if (num[val] == 1) return yes(s, i, j - 1, dir, ind + 1, num);     if (num[val] == 2) return yes(s, i - 1, j, dir, ind + 1, num);     if (num[val] == 3) return yes(s, i, j + 1, dir, ind + 1, num);     return false;   }   int main() {     vector<int> curr = {0, 1, 2, 3};     generate(curr, 0);     int m, n;     cin >> m;     cin >> n;     vector<string> s(m,   );     for (int i = 0; i < m; i++) cin >> s[i];     string dir;     cin >> dir;     int count = 0, xi, xj;     for (int i = 0; i < m; i++)       for (int j = 0; j < n; j++)         if (s[i][j] ==  S ) {           xi = i;           xj = j;           break;         }     for (int i = 0; i < 24; i++) {       if (yes(s, xi, xj, dir, 0, perm[i])) count++;     }     cout << count << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   map<int64_t, int> mp1, mp2;   int fnc(int n) {     int ans = n + 1;     for (auto i = mp1.begin(); i != mp1.end(); i++) {       if (i->second >= (n + 1) / 2) return 0;       if (i->second + mp2[i->first] >= ((n + 1) / 2))         ans = min(ans, (n + 1) / 2 - i->second);     }     if (ans < n) return ans;     for (auto i = mp2.begin(); i != mp2.end(); i++) {       if (i->second >= (n + 1) / 2) return (n + 1) / 2;     }     if (ans > n) return -1;     return ans;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int m;     cin >> m;     int64_t a, b;     for (int i = 0; i < m; i++) {       cin >> a >> b;       mp1[a]++;       if (a != b) mp2[b]++;     }     cout << fnc(m) << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 3e5 + 10, MAXM = 2e6 + 10, INF = INT_MAX;   const int MOD = 1e9 + 7, mod = 998244353;   char s[MAXN];   char p[] =  twone ;   char k[] =  two ;   char z[] =  one ;   int main() {     int t;     scanf( %d , &t);     while (t--) {       scanf( %s , s + 1);       vector<int> ans;       int sz = strlen(s + 1);       for (int i = 1; i <= sz; i++) {         if (s[i] ==  o ) {           if (i > 2 && i < sz - 1) {             bool f = 0;             for (int j = 0; j < 5; j++) {               if (s[i - 2 + j] != p[j]) f = 1;             }             if (!f) {               ans.push_back(i);               continue;             }           }           if (i < sz - 1) {             bool f = 0;             for (int j = 0; j < 3; j++)               if (s[i + j] != z[j]) f = 1;             if (!f) {               ans.push_back(i + 1);               continue;             }           }           if (i > 2) {             bool f = 0;             for (int j = 0; j < 3; j++)               if (s[i - 2 + j] != k[j]) f = 1;             if (!f) {               ans.push_back(i - 1);               continue;             }           }         }       }       printf( %d n , (int)ans.size());       for (auto j : ans) printf( %d  , j);       puts(  );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[10][10], b[10][10];   int f(int x) {     int o = 0;     while (x) {       o += (x & 1);       x >>= 1;     }     return o;   }   int main() {     int n, ans = 999;     char o1;     int o2;     cin >> n;     for (int i = 1; i <= n; i++) {       int x, y;       cin >> o1 >> o2;       if (o1 ==  B ) x = 0;       if (o1 ==  Y ) x = 1;       if (o1 ==  W ) x = 2;       if (o1 ==  G ) x = 3;       if (o1 ==  R ) x = 4;       y = o2 - 1;       b[x][y] = a[x][y] = 1;     }     int wjt = 1 << 5;     for (int i = 0; i < wjt; i++)       for (int j = 0; j < wjt; j++) {         for (int x = 0; x < 5; x++)           for (int y = 0; y < 5; y++) a[x][y] = b[x][y];         for (int x = 0; x < 5; x++)           for (int y = 0; y < 5; y++) {             if ((1 << x & i) && ((1 << y) & j) && a[x][y]) a[x][y] = 0;           }         int tot;         for (int y = 0; y < 5; y++) {           tot = 0;           if (1 << y & j)             for (int x = 0; x < 5; x++) tot += a[x][y];           if (tot == 1)             for (int x = 0; x < 5; x++) a[x][y] = 0;         }         for (int x = 0; x < 5; x++) {           tot = 0;           if (1 << x & i)             for (int y = 0; y < 5; y++) tot += a[x][y];           if (tot == 1)             for (int y = 0; y < 5; y++) a[x][y] = 0;         }         tot = 0;         for (int x = 0; x < 5; x++)           for (int y = 0; y < 5; y++) tot += a[x][y];         if (tot == 1) {           ans = min(ans, f(i) + f(j));         }       }     cout << ans;   }
#include <bits/stdc++.h>   int main() {     int s = 0, ar[5], t = 0;     for (int i = 0; i < 5; ++i) {       scanf( %d , &ar[i]);       s += ar[i];     }     if (s % 5 || s == 0)       printf( -1 n );     else {       for (int i = 0; i < 5; ++i)         if (ar[i] % 2) ++t;       if ((((s / 5) % 2) && (t == 1 || t == 3 || t == 5)) ||           (!((s / 5) % 2) && (t == 0 || t == 2 || t == 4)))         printf( %d n , s / 5);       else         printf( -1 n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long M = 100 + 19;   long long d[M][M][M], n, m, k;   char c;   struct tuplee {     long long x, y, z;   };   vector<tuplee> v1, v2;   long long go(long long x1, long long y1, long long z1, long long x2,                long long y2, long long z2) {     if (x1 > x2 || y1 > y2 || z1 > z2 || d[x1][y1][z1] == 0) return 0;     if (x1 == x2 && y1 == y2 && z1 == z2) return 1;     return go(x1 + 1, y1, z1, x2, y2, z2) + go(x1, y1 + 1, z1, x2, y2, z2) +            go(x1, y1, z1 + 1, x2, y2, z2);   }   inline bool is_bad(long long x, long long y, long long z) {     tuplee T;     v1.clear();     v2.clear();     if (d[x - 1][y][z]) T.x = x - 1, T.y = y, T.z = z, v1.push_back(T);     if (d[x][y - 1][z]) T.x = x, T.y = y - 1, T.z = z, v1.push_back(T);     if (d[x][y][z - 1]) T.x = x, T.y = y, T.z = z - 1, v1.push_back(T);     if (d[x + 1][y][z]) T.x = x + 1, T.y = y, T.z = z, v2.push_back(T);     if (d[x][y + 1][z]) T.x = x, T.y = y + 1, T.z = z, v2.push_back(T);     if (d[x][y][z + 1]) T.x = x, T.y = y, T.z = z + 1, v2.push_back(T);     if (v1.empty() || v2.empty()) return false;     for (long long i = (0); i <= (v1.size() - 1); i++) {       for (long long j = (0); j <= (v2.size() - 1); j++) {         if (go(v1[i].x, v1[i].y, v1[i].z, v2[j].x, v2[j].y, v2[j].z) == 1)           return true;       }     }     return false;   }   int main() {     ios::sync_with_stdio(false);     scanf( %lld%lld%lld , &n, &m, &k);     long long ct = 0;     for (long long i1 = (1); i1 <= (n); i1++)       for (long long i2 = (1); i2 <= (m); i2++)         for (long long i3 = (1); i3 <= (k); i3++)           scanf(  %c , &c), d[i1][i2][i3] = (c -  0 );     for (long long i1 = (1); i1 <= (n); i1++)       for (long long i2 = (1); i2 <= (m); i2++)         for (long long i3 = (1); i3 <= (k); i3++) {           if (d[i1][i2][i3] && is_bad(i1, i2, i3)) ct++;         }     printf( %lld , ct);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, a, b;     cin >> n >> a >> b;     int h[3000];     for (int i = 0; i < n; i++) {       cin >> h[i];     }     sort(h, h + n);     cout << h[b] - h[b - 1];     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2000005;   const int inf = 1000000009;   int c, Len, Ans, id;   char String[N], s[N];   int D[N], num[N], n, Q[N], h, t, x;   vector<int> e[N];   vector<char> v[N];   void getstr(char *s, int &l) {     l = 0;     while (String[c] !=  ,  && c < Len) s[l++] = String[c], c++;     c++;     s[l] = 0;     return;   }   void getdig(int &x) {     x = 0;     while (String[c] !=  ,  && c < Len) x = x * 10 + String[c] - 48, c++;     c++;     return;   }   void Dfs(int x, int y, int dep) {     Ans = max(Ans, dep);     D[x] = dep;     for (int i = ((int)1); i <= ((int)y); i++) {       getstr(s, n);       id++;       for (int i = ((int)0); i <= ((int)n - 1); i++) v[id].push_back(s[i]);       e[x].push_back(id);       getdig(num[id]);       Dfs(id, num[id], dep + 1);     }   }   void write(int x) {     for (int i = ((int)0); i <= ((int)v[x].size() - 1); i++) putchar(v[x][i]);     putchar(32);     return;   }   int main() {     scanf( %s , String);     Len = strlen(String) - 1;     while (c < Len) {       getstr(s, n);       id++;       e[0].push_back(id);       for (int i = ((int)0); i <= ((int)n - 1); i++) v[id].push_back(s[i]);       getdig(num[id]);       Dfs(id, num[id], 1);     }     printf( %d , Ans);     Q[t = 1] = 0;     h = 0;     while (h < t) {       x = Q[++h];       if (D[x] != D[Q[h - 1]]) puts(  );       if (x != 0) write(x);       for (int j = ((int)0); j <= ((int)e[x].size() - 1); j++) Q[++t] = e[x][j];     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t, x, y, z;     cin >> t;     while (t--) {       cin >> x >> y >> z;       if ((x != y && y != z && x != z) ||           ((x == y && x < z) || (y == z && y < x) || (z == x && z < y))) {         cout <<  NO n ;         continue;       } else {         cout <<  YES n ;         if (x == y && y == z) {           cout << x <<     << x <<     << x <<   n ;         } else {           if (x == y) {             cout << x <<     << z <<     << z <<   n ;           } else if (y == z) {             cout << y <<     << x <<     << x <<   n ;           } else {             cout << z <<     << y <<     << y <<   n ;           }         }       }     }     return 0;   }
#include <bits/stdc++.h>   const int mod = 998244353, g = 3, _g = 332748118, maxn = 2e5 + 9;   inline int Pow(int base, int b) {     int ret(1);     while (b) {       if (b & 1) ret = 1ll * ret * base % mod;       base = 1ll * base * base % mod;       b >>= 1;     }     return ret;   }   int r[maxn], W[maxn];   inline int Fir(int n) {     int limit(1), len(0), up(n << 1);     while (limit < up) {       limit <<= 1;       ++len;     }     for (int i = 0; i < limit; ++i)       r[i] = (r[i >> 1] >> 1) | ((i & 1) << len - 1);     return limit;   }   inline void NTT(int *a, int n, int type) {     for (int i = 0; i < n; ++i)       if (i < r[i]) std::swap(a[i], a[r[i]]);     for (int mid = 1; mid < n; mid <<= 1) {       int wn(Pow(type ? g : _g, (mod - 1) / (mid << 1)));       W[0] = 1;       for (int i = 1; i < mid; ++i) W[i] = 1ll * W[i - 1] * wn % mod;       for (int R = mid << 1, j = 0; j < n; j += R)         for (int k = 0; k < mid; ++k) {           int x(a[j + k]), y(1ll * W[k] * a[j + mid + k] % mod);           a[j + k] = 1ll * (x + y) % mod;           a[j + mid + k] = 1ll * (x - y + mod) % mod;         }     }   }   int T[maxn], F[maxn], H[maxn], G[maxn], fac[maxn], fav[maxn], tmp[maxn],       sum[maxn], B[maxn];   inline int Mul(int n, int *a, int *b, int *ans) {     int limit(Fir(n));     NTT(a, limit, 1);     NTT(b, limit, 1);     for (int i = 0; i < limit; ++i) ans[i] = 1ll * a[i] * b[i] % mod;     NTT(ans, limit, 0);     for (int i = ((n - 1) << 1) + 1; i < limit; ++i) a[i] = b[i] = 0;     return Pow(limit, mod - 2);   }   inline void Solve(int n, int *a) {     if (!n) {       a[0] = 1;       return;     }     if (n == 1) {       a[1] = 1;       return;     }     int len(n / 2);     Solve(len, a);     for (int i = 0; i <= len; ++i) {       F[i] = 1ll * Pow(len, i) * fav[i] % mod;       H[i] = 1ll * fac[i] * a[i] % mod;     }     for (int i = 0; i <= (len >> 1); ++i) std::swap(H[i], H[len - i]);     int limit(Fir(len + 1));     for (int i = len + 1; i < limit; ++i) F[i] = H[i] = 0;     NTT(F, limit, 1);     NTT(H, limit, 1);     for (int i = 0; i < limit; ++i) G[i] = 1ll * F[i] * H[i] % mod;     NTT(G, limit, 0);     int ty(Pow(limit, mod - 2));     for (int i = 0; i <= len; ++i)       tmp[i] = 1ll * G[len - i] * ty % mod * Pow(fac[i], mod - 2) % mod;     int val(Mul(len + 1, a, tmp, B));     for (int i = 0; i <= (len << 1); ++i) a[i] = 1ll * B[i] * val % mod;     if (n & 1) {       for (int i = 0; i < n; ++i) T[i] = a[i];       for (int i = 1; i <= n; ++i)         a[i] = 1ll * (T[i - 1] + 1ll * (n - 1) * T[i] % mod) % mod;     }   }   inline int Get_c(int n, int m) {     return 1ll * fac[n] * fav[m] % mod * fav[n - m] % mod;   }   int n, a, b;   int ans[maxn];   int main() {     scanf( %d%d%d , &n, &a, &b);     fac[0] = fac[1] = 1;     for (int i = 2; i <= n; ++i) fac[i] = 1ll * fac[i - 1] * i % mod;     fav[n] = Pow(fac[n], mod - 2);     for (int i = n; i >= 1; --i) fav[i - 1] = 1ll * fav[i] * i % mod;     Solve(n - 1, ans);     printf( %d n , 1ll * ans[a + b - 2] * Get_c(a + b - 2, a - 1) % mod);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int d, k, a, b, t;     cin >> d >> k >> a >> b >> t;     long long int res = 0;     if (d > k) {       if (t + a * k > b * k) {         res = k * a + (d - k) * b;       } else {         long long int x =             ((d % k) * b < (d % k) * a + t ? (d % k) * b : ((d % k) * a + t));         res = k * a + (d / k - 1) * (t + k * a) + x;       }     } else {       res = a * d;     }     cout << res << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool vis[100005];   int main() {     int n;     while (cin >> n) {       int i, tag = 0, num = 0;       for (i = 5;; i += 5) {         int x = i;         while (x % 5 == 0 && x) {           num++;           x /= 5;         }         if (num == n) {           tag = 1;           break;         } else if (num > n)           break;       }       if (tag) {         cout <<  5  << endl;         for (int p = 0; p < 5; p++) cout << i + p <<    ;         cout << endl;       } else         cout <<  0  << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 5;   int k, t;   int a[11];   long long b[16], c[11], ele[11], hash_val;   map<pair<int, long long>, long long> vis;   void add(int i) {     c[b[i]]--;     hash_val -= ele[b[i]];     b[i]++;     c[b[i]]++;     hash_val += ele[b[i]];   }   void remove(int i) {     c[b[i]]--;     hash_val -= ele[b[i]];     b[i]--;     c[b[i]]++;     hash_val += ele[b[i]];   }   long long find(int ind) {     if (ind == 11) return 1;     pair<int, long long> mp = make_pair(ind, hash_val);     if (vis.find(mp) != vis.end()) return vis[mp];     long long ans = 0;     for (int i = 0; i < 16; i++) {       if (b[i] >= t) continue;       add(i);       ans += find(ind + 1);       remove(i);     }     vis[mp] = ans;     return ans;   }   int main() {     scanf( %d%d , &k, &t);     ele[0] = 1;     for (int i = 1; i < 11; i++) ele[i] = 17 * ele[i - 1];     if (t == 10) {       printf( %x n , k);       return 0;     }     c[0] = 16;     hash_val = 16;     int fir = 10;     add(1);     for (int i = 10; i > 0; i--) {       long long x = 15ll * find(i + 1);       if (k <= x) {         fir = i;         break;       } else         k -= x;     }     remove(1);     for (int i = fir; i <= 10; i++) {       for (int j = 0; j < 16; j++) {         if (j == 0 and i == fir) continue;         if (b[j] == t) continue;         add(j);         long long x = find(i + 1);         if (k > x) {           k -= x;           remove(j);         } else {           a[i] = j;           break;         }       }     }     int i = fir;     while (i <= 10) {       if (a[i] < 10)         printf( %d , a[i]);       else         printf( %c ,  a  + a[i] - 10);       i++;     }     printf(  n );   }
#include <bits/stdc++.h>   using namespace std;   long long gcd(long long a, long long b) {     if (b == 0) {       return a;     }     return gcd(b, a % b);   }   long long lcm(long long a, long long b) { return ((a * b) / gcd(a, b)); }   const long long maxn = 1e5;   long long n, k;   vector<long long> freq(maxn, 0);   vector<long long> arr(maxn);   vector<long long> ans(maxn, 0);   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     ;     cin >> n >> k;     for (long long i = 0; i < n; i++) {       cin >> arr[i];       freq[arr[i]]++;     }     long long counter = 0;     for (long long i = 0; i < 1e4 + 1; i++) {       if (freq[i] > 0) {         for (long long j = i; j < 1e4 + 1; j++) {           if (freq[j] == 0) {             continue;           }           long long now = i ^ j;           if (__builtin_popcount(now) == k) {             if (i == j) {               counter += ((freq[i] * (freq[i] - 1)) / 2);               continue;             }             counter += ((freq[i] * freq[j]));           }         }       }     }     cout << counter;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, a[100010], dp[100010][2], cum[100010];   int calc(int at, int flag) {     if (at == n + 1) return 0;     int &ret = dp[at][flag];     if (~ret) return ret;     ret = 0;     if (flag) {       ret = max(ret, calc(at + 1, 1) - a[at]);       ret = max(ret, calc(at + 1, 0) - a[at]);     } else {       ret = max(ret, calc(at + 1, 0) + a[at]);       ret = max(ret, -cum[n] + cum[at - 1]);     }     return ret;   }   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; ++i) scanf( %d , a + i);     for (int i = 1; i <= n; ++i) cum[i] = cum[i - 1] + a[i];     memset(dp, -1, sizeof dp);     printf( %d , max(calc(1, 0), calc(1, 1)));     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline bool EQ(double a, double b) { return fabs(a - b) < 1e-9; }   string toString(long long n) {     stringstream second;     second << n;     return second.str();   }   long long toNumber(string s) {     stringstream second;     long long n;     second << s;     second >> n;     return n;   }   map<int, int> mapi;   int n, m, a, b, c;   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cin >> n >> m;     for (int i = 0; i < m; i++) {       cin >> a >> b >> c;       if (mapi[a] > 0) {         mapi[b] = 1 ^ mapi[a];         if (mapi[b] == 0) mapi[b] = 2;         mapi[c] = mapi[a] ^ mapi[b];       } else if (mapi[b] > 0) {         mapi[c] = 1 ^ mapi[b];         if (mapi[c] == 0) mapi[c] = 2;         mapi[a] = mapi[b] ^ mapi[c];       } else if (mapi[c] > 0) {         mapi[a] = 1 ^ mapi[c];         if (mapi[a] == 0) mapi[a] = 2;         mapi[b] = mapi[a] ^ mapi[c];       } else {         mapi[a] = 1;         mapi[b] = 2;         mapi[c] = 3;       }     }     for (int i = 1; i < n + 1; i++) {       cout << mapi[i] <<    ;     }     cout <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<string> v;   string s;   int n;   int main() {     cin >> n >> s;     v.push_back(s);     for (int i = 0; i < n; i++) {       string s1 = s;       if (s[i] != 0) {         int kl = 10 - (s[i] - 48);         for (int j = 0; j < n; j++) {           int zn = s[j] - 48 + kl;           zn %= 10;           s1[j] = zn + 48;         }       }       string s2 =   ;       for (int j = i; j < n; j++) s2 += s1[j];       for (int j = 0; j < i; j++) s2 += s1[j];       v.push_back(s2);     }     sort(v.begin(), v.end());     cout << v[0] << endl;     return 0;   }