malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m;     cin >> n >> m;     int a[n];     for (int i = 0; i < n; i++) {       int x;       cin >> x;       a[i] = x;     }     sort(a, a + n);     int count = 0;     for (int i = (n - 1); i >= 0; i--) {       if (m > 0) {         m = m - a[i];         count++;       }     }     cout << count << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int a, b;     cin >> a >> b;     if (a > b) {       if (a == 9 && b == 1)         cout << 9 <<     << 10;       else         cout << -1;       return 0;     }     if ((b - a) > 1) {       cout << -1;       return 0;     }     if (b == a) {       cout << a << 98 <<     << b << 99;       return 0;     }     cout << a <<     << b;     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize(3)   #pragma GCC optimize( inline )   using namespace std;   const int N = 100050, INF = 0x3f3f3f3f;   int n, col, sum, n1, n2;   struct node {     int color, val, id;     friend bool operator<(node x, node y) { return x.val < y.val; }   } white[N], black[N];   int min(int x, int y) { return (x > y) ? y : x; }   signed main() {     scanf( %d , &n);     for (register int i = 1; i <= n; i++) {       scanf( %d%d , &col, &sum);       if (col)         white[++n1] = node{col, sum, i};       else         black[++n2] = node{col, sum, i};     }     sort(white + 1, white + 1 + n1);     sort(black + 1, black + 1 + n2);     for (register int i = 1, j = 1; i <= n1 && j <= n2;) {       int now = min(white[i].val, black[j].val);       cout << white[i].id <<     << black[j].id <<     << now << endl;       white[i].val -= now;       black[j].val -= now;       if (white[i].val)         j++;       else if (black[j].val)         i++;       else if (i < n1)         i++;       else         j++;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long N = 5e3 + 5;   long long read() {     long long s = 0;     char c = getchar(), lc =  + ;     while (c <  0  ||  9  < c) lc = c, c = getchar();     while ( 0  <= c && c <=  9 ) s = s * 10 + c -  0 , c = getchar();     return lc ==  -  ? -s : s;   }   void write(long long x) {     if (x < 0) {       putchar( - );       x = -x;     }     if (x < 10)       putchar(x +  0 );     else {       write(x / 10);       putchar(x % 10 +  0 );     }   }   void print(long long x, char c =   n ) {     write(x);     putchar(c);   }   long long dp[N][N], a[N], q[N];   signed main(signed Recall, char *_902_[]) {     (void)Recall, (void)_902_;     long long n = read(), k = read(), m = read(), ans = -1;     for (long long i = 1; i <= n; i++) a[i] = read();     for (long long i = 1; i <= n; i++) dp[i][0] = dp[0][i] = -1;     for (long long j = 1; j <= m; j++)       for (long long i = 1, h = 0, t = q[0] = 0; i <= n; i++) {         while (h <= t && i - q[h] > k) h++;         if (h <= t && dp[q[h]][j - 1] >= 0)           dp[i][j] = dp[q[h]][j - 1] + a[i];         else           dp[i][j] = -1;         while (h <= t && dp[q[t]][j - 1] <= dp[i][j - 1]) t--;         q[++t] = i;       }     for (long long i = max(n - k + 1, 1LL); i <= n; i++) ans = max(ans, dp[i][m]);     print(ans);     return 0;   }
/****************************************** By Lord Sanskar Bhargava******************************/           #include<bits/stdc++.h>   using namespace std;      typedef long long ll;   typedef long double ld;   typedef complex<ld> cd;       typedef pair<int, int> pi;   typedef pair<ll,ll> pl;   typedef pair<ld,ld> pd;       typedef vector<int> vi;   typedef vector<ld> vd;   typedef vector<ll> vl;   typedef vector<pi> vpi;   typedef vector<pl> vpl;   typedef vector<cd> vcd;      int main()   {       ios::sync_with_stdio(0);cin.tie(0);       int tt;       cin>>tt;       while(tt--)       {         ll n;cin>>n;       ll k=n%2020;         if(n<2020)         {           cout<< NO <<endl;         }         else if(k*2021<=n)         {           cout<< YES <<endl;         }         else         {           cout<< NO <<endl;         }          }   return 0;   }
#include <bits/stdc++.h>   using namespace std;   int dp[1003][1003][12][3];   string s, t;   int solve(int i, int j, int k, int cont) {     if (i < 0 || j < 0) return 0;     if (dp[i][j][k][cont] != -1) return dp[i][j][k][cont];     int ret = -9;     if (s[i] == t[j]) {       if (cont) {         ret = max(ret, 1 + solve(i - 1, j - 1, k, 1));       }       if (k > 0) ret = max(ret, 1 + solve(i - 1, j - 1, k - 1, 1));     }     ret = max(ret, solve(i - 1, j, k, 0));     ret = max(ret, solve(i, j - 1, k, 0));     dp[i][j][k][cont] = ret;     return ret;   }   int main() {     int n, m, k;     cin >> n >> m >> k;     cin >> s >> t;     for (int i = 0; i < 1003; ++i) {       for (int j = 0; j < 1003; ++j) {         for (int k = 0; k < 12; ++k) {           for (int l = 0; l < 3; ++l) {             dp[i][j][k][l] = -1;           }         }       }     }     int ans = solve(n - 1, m - 1, k, 0);     cout << ans <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   const long long mod = 1e9 + 7;   const int N = 510;   int m;   long long n, ans;   int cnt, head[N];   struct edge {     int to, next;   } e[1010];   void ade(int u, int v) {     e[++cnt] = (edge){v, head[u]};     head[u] = cnt;   }   long long getsize(long long num) {     if (num > n) return 0;     long long tl = num, tr = num;     int m1 = 0, m2 = 0;     while (tl * 2 <= n) tl = tl * 2, m1++;     while (tr * 2 + 1 <= n) tr = tr * 2 + 1, m2++;     if (tl <= tr)       return (1 << (m2 + 1)) - 1;     else       return (1 << (m2 + 1)) - 1 + n - tl + 1;   }   map<int, int> vis;   int tot;   long long val[N];   void build(int x) {     val[vis[x]] = 1;     int to = x << 1;     if (to <= n && vis[to]) {       build(to);       ade(vis[x], vis[to]);       ade(vis[to], vis[x]);     } else       val[vis[x]] += getsize(to);     to = x << 1 | 1;     if (to <= n && vis[to]) {       build(to);       ade(vis[x], vis[to]);       ade(vis[to], vis[x]);     } else       val[vis[x]] += getsize(to);   }   int bk[N];   void dfs(int now, long long w) {     bk[now] = 1;     for (int i = head[now]; i; i = e[i].next) {       int to = e[i].to;       if (bk[to]) continue;       dfs(to, w);       ans = (ans + w * val[to] % mod) % mod;     }     bk[now] = 0;   }   int main() {     cin >> n >> m;     if (!m) {       ans = n * n % mod;       ans = (ans % mod + mod) % mod;       printf( %lld n , ans);     } else {       for (int i = 1; i <= m; i++) {         int a, b;         cin >> a >> b;         if (!vis[a]) vis[a] = ++tot;         if (!vis[b]) vis[b] = ++tot;         ade(vis[a], vis[b]);         ade(vis[b], vis[a]);         while (a) {           a >>= 1;           if (!vis[a]) vis[a] = ++tot;         }         while (b) {           b >>= 1;           if (!vis[b]) vis[b] = ++tot;         }       }       build(1);       for (int i = 1; i <= tot; i++) dfs(i, val[i]);       for (int i = 1; i <= tot; i++) ans = (ans + val[i] * val[i] % mod) % mod;       printf( %lld n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX_N = 105, MAX_R = 60005;   int n, r, a, b;   vector<pair<int, int> > inc, d;   int dp[MAX_R][MAX_N];   int main() {     ios::sync_with_stdio(false);     cin >> n >> r;     for (int i = 0; i < n; i++) {       cin >> a >> b;       if (b >= 0) {         inc.push_back({a, b});       } else {         d.push_back({max(a, -b) + b, b});       }     }     sort(inc.begin(), inc.end());     sort(d.begin(), d.end());     int proj = 0;     for (auto p : inc) {       if (r >= p.first) {         proj++;         r += p.second;       }     }     int len = d.size();     for (int i = 0; i <= len; i++) {       if (i == 0) {         for (int j = 0; j <= r; j++) {           dp[j][i] = proj;         }         continue;       }       int a = d[i - 1].first - d[i - 1].second;       int b = d[i - 1].second;       for (int j = 0; j <= r; j++) {         if (j >= a) {           dp[j][i] = max(dp[j][i - 1], 1 + dp[j + b][i - 1]);         } else {           dp[j][i] = dp[j][i - 1];         }       }     }     cout << dp[r][len] << endl;   }
#include <bits/stdc++.h>   using namespace std;   long long n, b, x, q, t, ans, l, r, m, p, now, sum;   bool ok;   string s;   map<int, int> a, pos;   map<char, int> c;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> q;     while (q--) {       cin >> n >> m;       cin >> s;       for (int i = 1; i <= m; ++i) {         cin >> x;         a[x + 1]++;       }       sum = m + 1;       for (int i = 0; i < s.size(); ++i) {         sum -= a[i + 1];         c[s[i]] += sum;       }       for (char j =  a ; j <=  z ; ++j) {         cout << c[j] <<    ;       }       cout <<   n ;       a.clear();       c.clear();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     int a[n], b[n];     for (int i = 0; i < n; i++) cin >> a[i];     b[n - 1] = a[n - 1];     for (int j = 0; j < n - 1; j++) b[j] = a[j] + a[j + 1];     for (int k = 0; k < n; k++) cout << b[k] <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   inline T read(T& x) {     x = 0;     int f = 0;     char ch = getchar();     while (ch <  0  || ch >  9 ) f |= (ch ==  - ), ch = getchar();     while (ch >=  0  && ch <=  9 ) x = x * 10 + ch -  0 , ch = getchar();     return x = f ? -x : x;   }   const int N = 500 + 10;   const long long INF = 2e18;   int i, j, x, n, match[N], pre[N];   long long a[N], b[N], k[N], cost[N][N], lx[N], ly[N], slack[N];   bool vy[N];   void augment(int root) {     fill(vy + 1, vy + n + 1, false);     fill(slack + 1, slack + n + 1, INF);     int py;     match[py = 0] = root;     do {       vy[py] = true;       int x = match[py], yy;       long long delta = INF;       for (int y = 1; y <= n; y++) {         if (!vy[y]) {           if (lx[x] + ly[y] - cost[x][y] < slack[y]) {             slack[y] = lx[x] + ly[y] - cost[x][y];             pre[y] = py;           }           if (slack[y] < delta) {             delta = slack[y];             yy = y;           }         }       }       for (int y = 0; y <= n; y++) {         if (vy[y]) {           lx[match[y]] -= delta;           ly[y] += delta;         } else {           slack[y] -= delta;         }       }       py = yy;     } while (~match[py]);     do {       int cnt = pre[py];       match[py] = match[cnt];       py = cnt;     } while (py);   }   long long KM() {     for (int i = 1; i <= n; i++) {       lx[i] = ly[i] = 0;       match[i] = -1;       for (int j = 1; j <= n; j++) lx[i] = max(lx[i], cost[i][j]);     }     long long ans = 0;     for (int i = 1; i <= n; i++) augment(i);     for (int i = 1; i <= n; i++) {       ans += lx[i];       ans += ly[i];     }     return ans;   }   int main() {     read(n);     for (i = 1; i <= n; i++) {       read(a[i]), read(b[i]), read(k[i]);       for (j = 1; j <= n; j++) {         cost[i][j] = max(a[i] - b[i] * min(k[i], j - 1LL), 0LL);       }     }     printf( %lld n , KM());     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = (int)1e9 + 10;   const int N = (int)1e6 + 10;   const long double eps = 1e-7;   mt19937 rnd(228);   int main() {     int n, q;     cin >> n >> q;     deque<int> d;     int mn = INF;     int mx = -INF;     for (int i = 0; i < n; ++i) {       int x;       cin >> x;       d.push_back(x);       mn = min(mn, x);       mx = max(mx, x);     }     vector<pair<int, int>> ans(N);     for (int iter = 1; iter < N; ++iter) {       int a = d.front();       d.pop_front();       int b = d.front();       ans[iter] = make_pair(a, b);       d.pop_front();       d.push_front(max(a, b));       d.push_back(min(a, b));     }     int st = -1;     for (int i = N / 2 - 1; i >= 1; --i) {       if (ans[i] == pair<int, int>({mx, mn})) {         st = i;         break;       }     }     for (int i = 1; i <= q; ++i) {       long long m;       cin >> m;       if (m < N) {         cout << ans[m].first <<     << ans[m].second <<   n ;         continue;       }       m -= st;       m %= (n - 1);       cout << ans[st + m].first <<     << ans[st + m].second <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 200005;   int n, k;   pair<int, int> a[N];   vector<pair<int, int> > Center;   bool inf;   bool Check(pair<int, int> center) {     int cnt = 0, l = 1, r = n;     pair<int, int> t;     while (l <= r && cnt <= k) {       t = make_pair(center.first - a[l].first, center.second - a[l].second);       if (t == a[r]) {         l++;         r--;       } else {         cnt++;         if (t < a[r])           r--;         else           l++;       }     }     return (cnt <= k);   }   void Solve() {     if (k >= n) {       inf = true;       return;     }     sort(a + 1, a + n + 1);     pair<int, int> center;     int res = 0;     for (int i = 1; i <= k + 1; i++)       for (int j = n - k; j <= n; j++)         if (i <= j) {           center = make_pair(a[i].first + a[j].first, a[i].second + a[j].second);           if (Check(center)) Center.push_back(center);         }   }   int main() {     cin >> n >> k;     for (int i = 1; i <= n; i++) scanf( %d %d , &a[i].first, &a[i].second);     Solve();     if (inf) {       cout << -1 << endl;       return 0;     }     int res = 0;     sort(Center.begin(), Center.end());     for (int i = 0; i < Center.size(); i++)       if (i == 0 || Center[i] != Center[i - 1]) res++;     cout << res << endl;     int cnt = 0;     for (int i = 0; i < Center.size(); i++)       if (i == 0 || Center[i] != Center[i - 1]) {         printf( %.3lf %.3lf n , (Center[i].first + 0.0) / 2.0,                (Center[i].second + 0.0) / 2.0);       }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   #pragma GCC optimize( Ofast,no-stack-protector )   #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native )   #pragma GCC optimize( unroll-loops )   int on_bit(int N, int pos) { return N = N | (1 << pos); }   int off_bit(int N, int pos) { return N = N & ~(1 << pos); }   bool check_bit(long long int N, int pos) { return (bool)(N & (1 << pos)); }   template <class T>   inline bool read(T &x) {     int c = getchar();     int sgn = 1;     while (~c && c <  0  || c >  9 ) {       if (c ==  - ) sgn = -1;       c = getchar();     }     for (x = 0; ~c &&  0  <= c && c <=  9 ; c = getchar()) x = x * 10 + c -  0 ;     x *= sgn;     return ~c;   }   int main() {     unsigned long long ar[500005];     memset((ar), 0, sizeof((ar)));     for (unsigned long long i = 3, j = 1; i <= 500001; i += 2, j++) {       ar[i] = ((i * 4) - 4) * j;     }     for (int i = 5; i <= 500001; i += 2) {       ar[i] += ar[i - 2];     }     int ___T;     cin >> ___T;     for (int cs = 1; cs <= ___T; cs++) {       int n;       cin >> n;       cout << ar[n] <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long nt[105];   string s;   vector<long long> V;   void ts() {     nt[0] = 0;     nt[1] = 0;     for (long long i = 2; i <= 100; i++) {       nt[i] = 1;     }     for (long long i = 2; i <= 100; i++) {       if (nt[i] == 1) {         for (long long j = i * i; j <= 100; j += i) {           nt[j] = 0;         }         V.push_back(i);       }     }   }   signed main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     V.push_back(4);     V.push_back(9);     V.push_back(25);     V.push_back(49);     ts();     long long i = 0;     long long dem = 0;     while (i < 20) {       cout << V[i] << endl;       cin >> s;       if (s ==  yes ) dem++;       if (dem == 2) {         cout <<  composite ;         return 0;       }       i++;     }     cout <<  prime ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string get(int n, int m) {     string str;     for (int i = 1; i <= n; i++) str.push_back( 4 );     for (int i = 1; i <= m; i++) str.push_back( 7 );     return str;   }   int32_t main() {     ios_base ::sync_with_stdio(0);     cin.tie(0);     string str;     cin >> str;     int n = str.size();     if (n & 1) {       cout << get((n + 1) / 2, (n + 1) / 2) << endl;       return 0;     }     int cnta = 0, cntb = 0, ans = -1, aa = 0, bb = 0;     for (int i = 0; i < n; i++) {       if (cnta + 1 <= n / 2 && str[i] <  7 ) {         ans = i;         aa = cnta;         bb = cntb;       }       if (cntb + 1 <= n / 2 && str[i] <  4 ) {         ans = i;         aa = cnta;         bb = cntb;       }       cnta += str[i] ==  7 ;       cntb += str[i] ==  4 ;       if ((str[i] !=  4  && str[i] !=  7 ) || cnta > n / 2 || cntb > n / 2) break;     }     if (cnta + cntb == n && cnta == cntb) {       cout << str << endl;       return 0;     }     if (ans == -1) {       cout << get((n + 2) / 2, (n + 2) / 2) << endl;       return 0;     }     string x;     for (int i = 0; i < ans; i++) {       x.push_back(str[i]);     }     if (bb + 1 <= n / 2 && str[ans] <  4 ) {       ++bb;       x.push_back( 4 );     } else {       ++aa;       x.push_back( 7 );     }     x += get(n / 2 - bb, n / 2 - aa);     cout << x << endl;   }
#include <bits/stdc++.h>   using namespace std;   int n;   vector<int> a;   vector<stack<int>> ids;   vector<int> b;   string answer;   int segtree_size;   template <typename T>   struct segtree {     int segtree_size;     vector<T> segtree;     T identity;     T (*UpdateFn)(T, T);     void InitSegtree(int main_size, T (*UpdateFunction)(T, T), T fun_identity) {       segtree_size = 1;       while (segtree_size < main_size) segtree_size *= 2;       segtree_size *= 2;       segtree.resize(segtree_size);       UpdateFn = UpdateFunction;       this->identity = fun_identity;     }     void UpdateAllParents() {       for (int i = segtree_size / 2 - 1; i > 0; i--)         segtree[i] = UpdateFn(segtree[i * 2], segtree[i * 2 + 1]);     }     void ChangeValue(int index, T value) {       segtree[index + segtree_size / 2] = value;     }     T GetValue(int index) { return segtree[index + segtree_size / 2]; }     void Update(int pos, T value) {       for (segtree[pos += segtree_size / 2] = value; pos > 1; pos /= 2)         segtree[pos / 2] = UpdateFn(segtree[pos], segtree[pos ^ 1]);     }     T Query(int start, int finish) {       T ans = this->identity;       for (start += segtree_size / 2, finish += segtree_size / 2; start < finish;            start /= 2, finish /= 2) {         if (start % 2 == 1) ans = UpdateFn(ans, segtree[start++]);         if (finish % 2 == 0) ans = UpdateFn(ans, segtree[finish--]);       }       return UpdateFn(ans, segtree[start]);     }     void Destroy() { segtree.clear(); }   };   struct segtree<int> tree;   void In() {     cin >> n;     a.resize(n);     ids.resize(n + 1);     b.resize(n);     for (int i = 0; i < n; i++) cin >> a[i];     for (int i = 0; i < n; i++) cin >> b[i];   }   void Solve() {     tree.InitSegtree(         n + 1, [](int a, int b) -> int { return max(a, b); }, INT_MIN);     for (int i = 0; i < n; i++) tree.ChangeValue(i, a[i]);     tree.UpdateAllParents();     answer =  NO ;     for (int i = 0; i < n; i++) ids[a[i]].push(i);     for (int i = n - 1; i >= 0; i--) {       if (ids[b[i]].empty()) return;       int a_idx = ids[b[i]].top();       ids[b[i]].pop();       if (tree.Query(a_idx + 1, n) > b[i]) return;       tree.Update(a_idx, 0);     }     answer =  YES ;   }   void Out() {     cout << answer << endl;     tree.Destroy();     a.clear();     ids.clear();     b.clear();   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int t;     cin >> t;     while (t--) {       In();       Solve();       Out();     }     return 0;   }
#include <bits/stdc++.h>   int main() {     int n, k, i;     scanf( %d%d , &n, &k);     while (n > k) {       for (i = 1; i <= k; i++) {         if (n % 10 > 0)           n--;         else           n = n / 10;       }       printf( %d , n);       n = 0;     }   }
#include <bits/stdc++.h>   using namespace std;   int n, l[200000 + 5], r[200000 + 5];   int p[200000 + 5], q[200000 + 5], sum;   long long add(long long a, long long b) { return (a + b) % 1000000007; }   long long mul(long long a, long long b) { return 1LL * a * b % 1000000007; }   long long dec(long long a, long long b) {     return (a - b + 1000000007) % 1000000007;   }   int fst_pow(int a, int b) {     int res = 1;     while (b) {       if (b & 1) res = mul(res, a);       a = mul(a, a);       b >>= 1;     }     return res;   }   int val(int i) {     int ans = 1;     ans = dec(ans, p[i]), ans = dec(ans, p[i + 1]);     int L = max(l[i - 1], max(l[i], l[i + 1])),         R = min(r[i - 1], min(r[i], r[i + 1]));     if (L < R)       ans = add(ans, mul(R - L, fst_pow(mul(mul(r[i] - l[i], r[i - 1] - l[i - 1]),                                             r[i + 1] - l[i + 1]),                                         1000000007 - 2)));     return ans;   }   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) scanf( %d , &l[i]);     for (int i = 1; i <= n; i++) {       scanf( %d , &r[i]);       r[i]++;     }     int sum = 0;     for (int i = 1; i <= n; i++) {       int L = max(l[i], l[i - 1]), R = min(r[i], r[i - 1]);       if (L < R)         p[i] = mul(R - L, fst_pow(mul(r[i] - l[i], r[i - 1] - l[i - 1]),                                   1000000007 - 2));       q[i] = dec(1, p[i]);       sum = add(sum, q[i]);     }     int ans = 0;     for (int i = 1; i <= n; i++) {       ans = add(ans, q[i]);       int ps = dec(sum, q[i]);       if (i > 2) ans = add(ans, val(i - 1)), ps = dec(ps, q[i - 1]);       if (i < n) ans = add(ans, val(i)), ps = dec(ps, q[i + 1]);       ans = add(ans, mul(q[i], ps));     }     printf( %d , ans);   }
#include <bits/stdc++.h>   using namespace std;   int solve(string s, int x, int y) {     int t = 0;     for (auto i : s) {       if (i -  0  == x) {         t++;         swap(x, y);       }     }     if (x != y && t % 2 == 1) --t;     return t;   }   int main() {     cin.tie(0);     cout.tie(0);     ios_base::sync_with_stdio(0);     int t;     cin >> t;     while (t--) {       string s;       cin >> s;       int ans = 0;       for (int i = 0; i <= 9; i++) {         for (int j = 0; j <= 9; j++) {           ans = max(ans, solve(s, i, j));         }       }       cout << (int)(s.size()) - ans << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char a[2010], b[2010], c[2010];   int aa[256], bb[256];   int n;   void _reverse(char *a, int l) {     for (int i = 0; i < l; i++) c[i] = a[i];     for (int i = 0; i < l; i++) a[i] = c[l - 1 - i];   }   void _rotate(char *a, int p) {     for (int i = 0; i < p; i++) c[n - p + i] = a[i];     for (int i = 0; i < n - p; i++) c[i] = a[p + i];     for (int i = 0; i < n; i++) a[i] = c[i];   }   int main() {     scanf( %d%s%s , &n, a, b);     for (int i = 0; i < n; i++) {       aa[a[i]]++;       bb[b[i]]++;     }     for (int i = 0; i < 256; i++)       if (aa[i] != bb[i]) {         printf( -1 n );         return 0;       }     printf( %d n , 3 * n);     for (int i = 0; i < n; i++) {       int j;       _reverse(a, n);       for (j = 0; j < n; j++)         if (a[j] == b[n - 1 - i]) break;       printf( %d %d %d  , n, n - j - 1, 1);       _reverse(a + j + 1, n - j - 1);       _rotate(a, j + 1);       _rotate(a, n - 1);     }   }
#include <bits/stdc++.h>   void reduce(unsigned& nom, unsigned& denom) {     bool reduced = true;     while (reduced) {       reduced = false;       for (unsigned i = 2; !reduced && i < 1000; ++i) {         if (nom % i == 0 && denom % i == 0) {           nom /= i;           denom /= i;           reduced = true;         }       }     }   }   void solve() {     unsigned sum = 0;     unsigned A;     std::cin >> A;     for (unsigned i = 2; i < A; ++i) {       auto val = A;       while (val > 0) {         sum += val % i;         val /= i;       }     }     auto nom = sum;     auto denom = A - 2;     reduce(nom, denom);     std::cout << nom <<  /  << denom << std::endl;   }   int main(int argc, char* argv[]) {     { solve(); }     return 0;   }