malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const long long LINF = 334ll << 53;   const int INF = 15 << 26;   const long long MOD = 1E9 + 7;   int main() {     cin.tie(0);     ios::sync_with_stdio(false);     int n, q;     cin >> n >> q;     vector<int> t(n), s(n), d(n);     priority_queue<pair<int, int>, vector<pair<int, int>>,                    greater<pair<int, int>>>         used;     priority_queue<int, vector<int>, greater<int>> aval;     for (int(i) = 0; (i) < (n); ++(i)) aval.push(i + 1);     for (int(i) = 0; (i) < (q); ++(i)) {       int now, s, t, ans = 0;       cin >> now >> s >> t;       while (!used.empty()) {         if (used.top().first > now) break;         aval.push(used.top().second);         used.pop();       }       if (aval.size() < s) {         cout << -1 << endl;       } else {         for (int(j) = 0; (j) < (s); ++(j)) {           ans += aval.top();           used.push(make_pair(now + t, aval.top()));           aval.pop();         }         cout << ans << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   const int mod = 998244353;   using namespace std;   inline int read() {     int f = 1, x = 0;     char s = getchar();     while (!isdigit(s)) {       if (s ==  - ) f = -1;       s = getchar();     }     while (isdigit(s)) {       x = (x << 1) + (x << 3) + (s ^ 48), s = getchar();     }     return x * f;   }   int n, a[500100], is[500100], prime[500100], tot, ans1[500100], ans2[500100];   inline void init(void) {     for (int i = 2; i <= 4000; i++) {       if (!is[i]) prime[++tot] = i;       for (int j = 1; j <= tot && i * prime[j] <= 4000; j++) {         is[i * prime[j]] = 1;         if (i % prime[j] == 0) break;       }     }   }   inline int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }   signed main(void) {     n = read();     init();     for (int i = 1; i <= n; i++) {       ans1[i] = ans2[i] = -1;       a[i] = read();       int t = a[i];       for (int j = 1; j <= tot; j++) {         int mul = 1;         while (t % prime[j] == 0) t /= prime[j], mul *= prime[j];         if (mul != 1 && a[i] / mul != 1) ans1[i] = mul, ans2[i] = a[i] / mul;       }       if (t != 1 && a[i] / t != 1) ans1[i] = t, ans2[i] = a[i] / t;     }     for (int i = 1; i <= n; i++) printf( %d  , ans1[i]);     puts(  );     for (int i = 1; i <= n; i++) printf( %d  , ans2[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct node {     string name;     int version;   };   int main(void) {     int n;     cin >> n;     map<pair<string, int>, vector<pair<string, int> > > m;     pair<string, int> init;     for (int i = 0; i < n; i++) {       pair<string, int> cur;       cin >> cur.first >> cur.second;       cur.second *= -1;       if (i == 0) init = cur;       int k;       cin >> k;       for (int j = 0; j < k; j++) {         pair<string, int> node;         cin >> node.first >> node.second;         node.second *= -1;         m[cur].push_back(node);       }     }     set<string> names;     set<pair<string, int> > ans;     set<pair<string, int> > layer;     names.insert(init.first);     layer.insert(init);     while (!layer.empty()) {       set<pair<string, int> > new_layer;       for (set<pair<string, int> >::iterator it = layer.begin();            it != layer.end(); it++) {         for (int k = 0; k < m[*it].size(); k++) {           new_layer.insert(m[*it][k]);         }       }       layer.clear();       for (set<pair<string, int> >::iterator it = new_layer.begin();            it != new_layer.end(); it++) {         if (names.find(it->first) != names.end()) continue;         names.insert(it->first);         ans.insert(*it);         layer.insert(*it);       }     }     cout << ans.size() << endl;     for (set<pair<string, int> >::iterator it = ans.begin(); it != ans.end();          it++) {       cout << it->first <<     << -it->second << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n, l = -1, j, p, m;     long k;     cin >> n >> k;     long long a[k];     for (long i = 0; i < k; i++) {       cin >> a[i];       j = n / a[i];       if ((j * a[i]) > l) {         l = j * a[i];         p = i + 1;         m = j;       }     }     cout << p <<     << m << endl;     return 0;   }
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:102400000,102400000 )   using namespace std;   int n, m, ans, flag;   bool vis[10];   string fac[7] = { 1869 ,  1968 ,  1689 ,  6198 ,  8691 ,  8916 ,  1896 };   string s, ss, anss, xx =  0000 ;   int main() {     int i, j, t, pos, x, y, u, v, w;     while (cin >> s) {       memset(vis, 0, sizeof(vis));       ss =   ;       for (i = 0; i < s.length(); i++) {         if (s[i] ==  1 ) {           if (!vis[1])             vis[1] = 1;           else             ss += s[i];         } else if (s[i] ==  6 ) {           if (!vis[6])             vis[6] = 1;           else             ss += s[i];         } else if (s[i] ==  8 ) {           if (!vis[8])             vis[8] = 1;           else             ss += s[i];         } else if (s[i] ==  9 ) {           if (!vis[9])             vis[9] = 1;           else             ss += s[i];         } else           ss += s[i];       }       flag = 0;       for (i = 0; i < ss.length(); i++) {         if (ss[i] !=  0 ) {           flag = 1;           char c = ss[i];           ss[i] = ss[0];           ss[0] = c;         }       }       if (!flag) {         cout <<  1869  << ss << endl;       } else {         t = 0;         for (i = 0; i < ss.length(); i++) {           t = (t * 10 + ss[i] -  0 ) % 7;         }         for (i = 0; i < 4; i++) {           t = (t * 10 + xx[i] -  0 ) % 7;         }         if (t) t = 7 - t;         cout << ss << fac[t] << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 998244353;   const int MN = 1 << 8;   int exp(int x, int n) {     int ret = 1;     while (n) {       if (n & 1) ret = 1LL * ret * x % mod;       x = 1LL * x * x % mod;       n >>= 1;     }     return ret;   }   int inv(int x) { return exp(x, mod - 2); }   int fact[MN], invf[MN];   int comb(int n, int k) {     return 1LL * fact[n] * invf[k] % mod * invf[n - k] % mod;   }   int fa[MN];   void init() {     for (int i = 0; i < MN; i++) fa[i] = i;   }   int find(int u) {     if (fa[u] == u)       return u;     else       return fa[u] = find(fa[u]);   }   void mrg(int u, int v) {     u = find(u);     v = find(v);     if (u == v) return;     fa[v] = u;   }   int cc[MN][MN];   int dp(int n, int k) {     int &ret = cc[n][k];     if (ret != -1) return ret;     if (k == 0) return ret = n == 0;     ret = 0;     for (int i = 1; i <= n; i++) {       ret +=           1LL * comb(n - 1, i - 1) * fact[i - 1] % mod * dp(n - i, k - 1) % mod;       ret %= mod;     }     return ret;   }   int N;   int A[MN], B[MN], del[MN], chk[MN], tcnt[3], ans[MN];   int main() {     fact[0] = 1;     for (int i = 1; i < MN; i++) {       fact[i] = 1LL * fact[i - 1] * i % mod;     }     for (int i = 0; i < MN; i++) {       invf[i] = inv(fact[i]);     }     memset(cc, -1, sizeof(cc));     scanf( %d , &N);     for (int i = 0; i < N; i++) {       scanf( %d , &A[i]);       A[i]--;     }     for (int i = 0; i < N; i++) {       scanf( %d , &B[i]);       B[i]--;     }     int ccnt = 0;     init();     for (int i = 0; i < N; i++) {       if (A[i] != -1 && B[i] != -1) {         if (find(A[i]) == find(B[i])) {           del[find(A[i])] = 1;           ccnt++;         } else           mrg(A[i], B[i]);       }     }     vector<int> V;     for (int i = 0; i < N; i++)       if (!del[i] && fa[i] == i) V.push_back(i);     if (V.size() == 0) {       for (int i = 0; i < N; i++) {         printf( %d  , (N - i == ccnt));       }       return 0;     }     for (int i = 0; i < N; i++) {       if (A[i] != -1 && B[i] == -1) {         chk[find(A[i])] |= 1;       }       if (A[i] == -1 && B[i] != -1) {         chk[find(B[i])] |= 2;       }     }     for (int i = 0; i < V.size(); i++) {       tcnt[chk[V[i]]]++;     }     for (int i = 1; i <= (int)V.size() - tcnt[3]; i++) {       int tmp = 0;       for (int j = 0; j <= min(tcnt[1], tcnt[2]); j++) {         if (j % 2)           tmp += mod - 1LL * comb(tcnt[1], j) * comb(tcnt[2], j) % mod * fact[j] %                            mod * dp((int)V.size() - tcnt[3] - j, i) % mod;         else           tmp += 1LL * comb(tcnt[1], j) * comb(tcnt[2], j) % mod * fact[j] % mod *                  dp((int)V.size() - tcnt[3] - j, i) % mod;         tmp %= mod;       }       ans[ccnt + i] = tmp;     }     for (int i = 0; i < N; i++) {       printf( %d  , 1LL * ans[N - i] * fact[tcnt[0]] % mod);     }   }
#include <bits/stdc++.h>   using namespace std;   int zero(int n) {     if (n == 0) return 0;     if (n % 10 == 0) return zero(n / 10);     return 10 * zero(n / 10) + (n % 10);   }   int main() {     int a, b;     cin >> a >> b;     if (zero(a) + zero(b) == zero(a + b)) {       cout <<  YES ;     } else {       cout <<  NO ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T1, class T2>   bool chmin(T1 &a, T2 b) {     return b < a && (a = b, true);   }   template <class T1, class T2>   bool chmax(T1 &a, T2 b) {     return a < b && (a = b, true);   }   struct MaxFlow {     struct edge {       int to, cap, rev;     };     vector<int> dist, it;     vector<vector<edge>> g;     MaxFlow(int n) : g(n), dist(n), it(n) {}     void add(int u, int v, int c) {       g[u].push_back({v, c, (int)g[v].size()});       g[v].push_back({u, 0, (int)g[u].size() - 1});     }     int calc(int s, int t) {       int res = 0;       while (bfs(s, t)) {         fill(it.begin(), it.end(), 0);         while (int f = dfs(s, t, 1e9)) res += f;       }       return res;     }     bool bfs(int s, int t) {       fill(dist.begin(), dist.end(), -1);       queue<int> q;       q.push(s);       dist[s] = 0;       while (!q.empty()) {         int v = q.front();         q.pop();         for (edge e : g[v])           if (e.cap > 0 && dist[e.to] < 0) {             dist[e.to] = dist[v] + 1;             q.push(e.to);           }       }       return dist[t] >= 0;     }     int dfs(int v, int t, int f) {       if (v == t) return f;       for (int &i = it[v]; i < g[v].size(); i++) {         edge &e = g[v][i];         if (e.cap > 0 && dist[v] < dist[e.to]) {           if (int d = dfs(e.to, t, min(f, e.cap))) {             e.cap -= d;             g[e.to][e.rev].cap += d;             return d;           }         }       }       return 0;     }   };   template <class T1, class T2>   void sortPair(vector<T1> &v1, vector<T2> &v2) {     vector<pair<T1, T2>> u(v1.size());     for (int i = 0; i < u.size(); i++) u[i] = make_pair(v1[i], v2[i]);     sort(u.begin(), u.end());     for (int i = 0; i < u.size(); i++) tie(v1[i], v2[i]) = u[i];   }   bool solve() {     int n, b, q;     cin >> n >> b >> q;     vector<int> u(q), v(q);     for (int i = 0; i < (q); i++) scanf( %d %d , &u[i], &v[i]);     u.push_back(b);     v.push_back(n);     q++;     sortPair(u, v);     for (int i = 0; i < (q - 1); i++)       if (v[i] > v[i + 1]) return false;     static int sum[10101][5];     for (int i = 0; i < (10101); i++) sum[i][i % 5]++;     for (int i = (1); i < (10101); i++)       for (int j = 0; j < (5); j++) sum[i][j] += sum[i - 1][j];     int lowSum = 0, highSum = 0;     MaxFlow mf(q + q * 5 + 5 + 2);     int src = q + q * 5 + 5;     int dst = src + 1;     int prevU = 0;     int prevV = 0;     for (int mod = 0; mod < (5); mod++) mf.add(q + q * 5 + mod, dst, n / 5);     for (int i = 0; i < (q); i++) {       int mustUse = v[i] - prevV;       int num = u[i] - prevU;       mf.add(src, i, mustUse);       for (int mod = 0; mod < (5); mod++) {         int mm = sum[u[i]][mod] - sum[prevU][mod];         mf.add(i, q + i * 5 + mod, mm);         mf.add(q + i * 5 + mod, q + q * 5 + mod, mm);       }       prevU = u[i];       prevV = v[i];     }     return mf.calc(src, dst) == n;   }   int main() {     cout << (solve() ?  fair  :  unfair ) << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     char a[15], b[15];     while (cin >> a >> b) {       int len_a = strlen(a);       sort(a, a + len_a);       int k = 0;       for (int i = 0; i < len_a; i++) {         if (a[i] !=  0 ) {           k = i;           break;         }       }       char tmp;       tmp = a[0];       a[0] = a[k];       a[k] = tmp;       if (strcmp(a, b) == 0)         cout <<  OK  << endl;       else         cout <<  WRONG_ANSWER  << endl;     }     return 0;   }
#include <bits/stdc++.h>   const int oo = 0x3f3f3f3f, mod = 1e9 + 7;   using namespace std;   int dx[]{1, -1, 0, 0, 1, 1, -1, -1};   int dy[]{0, 0, 1, -1, 1, -1, 1, -1};   long long OO = (1LL * oo * oo);   void K_K() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);   }   int main() {     K_K();     long long n, mx = 0, mxidx = 0;     cin >> n;     map<long long, long long> mp;     vector<long long> v(n + 2);     vector<pair<long long, pair<long long, long long>>> ans;     for (int i = 1; i <= n; i++) {       cin >> v[i], mp[v[i]]++;       if (mp[v[i]] > mx) mxidx = i, mx = mp[v[i]];     }     for (int i = mxidx - 1; i > 0; i--) {       if (v[i] > v[i + 1]) {         v[i] -= abs(v[i] - v[i + 1]);         ans.push_back({2, {i, i + 1}});       } else if (v[i] < v[i + 1]) {         ans.push_back({1, {i, i + 1}});         v[i] += abs(v[i] - v[i + 1]);       }     }     for (int i = mxidx + 1; i <= n; i++) {       if (v[i] > v[i - 1]) {         v[i] -= abs(v[i] - v[i - 1]);         ans.push_back({2, {i, i - 1}});       } else if (v[i] < v[i - 1]) {         ans.push_back({1, {i, i - 1}});         v[i] += abs(v[i] - v[i - 1]);       }     }     cout << (int)(ans.size()) <<   n ;     for (int i = 0; i < (int)(ans.size()); i++)       cout << ans[i].first <<     << ans[i].second.first <<                << ans[i].second.second <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   int a, b, c;   unsigned long ans = 0;   unordered_map<int, int> um;   void eval(int x) {     int t = 0;     for (int i = 1; i <= sqrt(x); ++i) {       if (i * i == x)         t += 1;       else if (x % i == 0)         t += 2;     }     ans += t;     um[x] = t;   }   int main() {     cin >> a >> b >> c;     for (int i = 1; i <= a; ++i) {       for (int j = 1; j <= b; ++j) {         for (int k = 1; k <= c; ++k) {           if (um.find(i * j * k) != um.end())             ans = (ans + um[i * j * k]) % 1073741824LL;           else             eval(i * j * k);         }       }     }     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int64_t M = 1000000007;   const int64_t MM = 998244353;   template <typename T, typename U>   static inline void amin(T &x, U y) {     if (y < x) x = y;   }   template <typename T, typename U>   static inline void amax(T &x, U y) {     if (x < y) x = y;   }   int64_t _runtimeTerror_() {     int64_t n;     cin >> n;     string s;     cin >> s;     vector<long long> d_cnt(n + 1, 0), d_sum(n + 1), u_cnt(n + 1),         u_sum(n + 1, 0);     for (int64_t i = 1; i <= n; ++i) {       u_cnt[i] = u_cnt[i - 1];       u_sum[i] = u_sum[i - 1];       d_cnt[i] = d_cnt[i - 1];       d_sum[i] = d_sum[i - 1];       if (s[i - 1] ==  D ) {         d_cnt[i] += 1;         d_sum[i] += i;       } else {         u_cnt[i] += 1;         u_sum[i] += i;       }     }     for (int64_t i = 1; i <= n; ++i) {       int64_t ans = 0;       if (s[i - 1] ==  U ) {         int64_t r_d = d_cnt[n] - d_cnt[i];         int64_t l_u = u_cnt[i - 1];         if (r_d > l_u) {           auto it = lower_bound(d_cnt.begin(), d_cnt.end(), d_cnt[i] + l_u + 1) -                     d_cnt.begin();           ans += (d_sum[it] - d_sum[i] - (i * (l_u + 1))) * 2;           ans -= (u_sum[i - 1]) * 2;           ans += l_u * i * 2;           ans += i;         } else {           ans += (d_sum[n] - d_sum[i] - (d_cnt[n] - d_cnt[i]) * i) * 2;           ans += (n - i + 1);           auto it =               lower_bound(u_cnt.begin(), u_cnt.end(), u_cnt[i - 1] - r_d + 1) -               u_cnt.begin();           ans -= (u_sum[i - 1] - u_sum[it - 1]) * 2;           ans += (r_d * i) * 2;         }         cout << ans <<    ;       } else {         int64_t r_d = d_cnt[n] - d_cnt[i];         int64_t l_u = u_cnt[i - 1];         if (r_d >= l_u) {           auto it = lower_bound(d_cnt.begin(), d_cnt.end(), d_cnt[i] + l_u) -                     d_cnt.begin();           ans += (d_sum[it] - d_sum[i] - (i * (l_u))) * 2;           ans -= (u_sum[i - 1]) * 2;           ans += l_u * i * 2;           ans += i;         } else {           ans += (d_sum[n] - d_sum[i] - (d_cnt[n] - d_cnt[i]) * i) * 2;           ans += (n - i + 1);           auto it = lower_bound(u_cnt.begin(), u_cnt.end(), u_cnt[i - 1] - r_d) -                     u_cnt.begin();           ans -= (u_sum[i - 1] - u_sum[it - 1]) * 2;           ans += ((r_d + 1) * i) * 2;         }         cout << ans <<    ;       }     }     return 0;   }   int32_t main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int64_t TESTS = 1;     while (TESTS--) _runtimeTerror_();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m, k;     string s;     int x;     cin >> n >> m >> k;     int a[n][m];     int b[n][m];     int c[n][m];     for (int i = 0; i < n; i++) {       cin >> s;       for (int j = 0; j < m; j++) {         cin >> x;         a[i][j] = x;         cin >> x;         b[i][j] = x;         cin >> x;         c[i][j] = x;       }     }     int sum_max = 0;     int sum;     vector<pair<int, int> > abc;     abc.reserve(m);     for (int i = 0; i < n; i++) {       for (int j = 0; j < n; j++) {         if (i == j) continue;         sum = 0;         abc.clear();         for (int ii = 0; ii < m; ii++) {           abc.push_back(make_pair(b[j][ii] - a[i][ii], c[i][ii]));         }         sort(abc.begin(), abc.end());         int left = k;         for (int ii = m - 1; ii >= 0 && left > 0; ii--) {           int d = min(left, abc[ii].second);           if (abc[ii].first > 0) {             sum += d * abc[ii].first;             left -= d;           }         }         if (sum > sum_max) {           sum_max = sum;         }       }     }     cout << sum_max << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 3e5 + 7;   const int M = N * 3;   const int inf = 1e9 + 7;   const int base = 1e9 + 9;   const double pi = acos(-1);   const double ep = 1e-11;   pair<pair<int, int>, int> p[N];   int n;   int vp, vs;   int sqr(int x) { return x * x; }   double sqr(double x) { return x * x; }   int dist(pair<pair<int, int>, int> a, pair<pair<int, int>, int> b) {     return sqr(a.first.first - b.first.first) +            sqr(a.first.second - b.first.second) + sqr(a.second - b.second);   }   pair<pair<double, double>, double> curr(double t) {     for (int i = 1; i <= n; i++) {       double d = sqrt(dist(p[i - 1], p[i])) + ep;       if (d >= t * vs) {         pair<pair<double, double>, double> tmp;         tmp.first.first = t * vs * (p[i].first.first - p[i - 1].first.first) / d +                           p[i - 1].first.first;         tmp.first.second =             t * vs * (p[i].first.second - p[i - 1].first.second) / d +             p[i - 1].first.second;         tmp.second =             t * vs * (p[i].second - p[i - 1].second) / d + p[i - 1].second;         return tmp;       } else {         t -= d / vs;       }     }     return make_pair(make_pair(0, 0), 0);   }   int main() {     cin >> n;     double t = 0;     for (int i = (int)0; i < (int)n + 1; i++) {       int u, v, c;       cin >> u >> v >> c;       p[i] = make_pair(make_pair(u, v), c);     }     cin >> vp >> vs;     { cin >> p[n + 1].first.first >> p[n + 1].first.second >> p[n + 1].second; }     for (int i = (int)1; i < (int)n + 1; i++)       t += sqrt(dist(p[i - 1], p[i])) / vs;     if (dist(p[n], p[n + 1]) > t * t * vp * vp + ep) {       cout <<  NO ;       return 0;     }     cout <<  YES n ;     double lo = 0, hi = t + ep, g, res = -1;     pair<pair<double, double>, double> ans = curr(35);     do {       g = (lo + hi) / 2;       pair<pair<double, double>, double> tmp = curr(g);       double di = sqr(p[n + 1].first.first - tmp.first.first) +                   sqr(p[n + 1].first.second - tmp.first.second) +                   sqr(p[n + 1].second - tmp.second);       ans = tmp;       res = g;       if (di <= sqr(g) * sqr(vp) + ep) {         res = g;         hi = g - ep;       } else         lo = g + ep;     } while (lo + ep < hi);     printf( %.9lf n , res);     printf( %.9lf %.9lf %.9lf , ans.first.first, ans.first.second, ans.second);   }
#include <bits/stdc++.h>   using namespace std;   const int N = 300010;   int sufp[N], freq[N][2];   int mi = 0, ma = 0, par = 0;   void add(int x) {     if (x >= mi and x <= ma) {       if (x % 2 == par)         mi = 0;       else         mi = 1;     } else if (x > ma) {       mi = x - ma;     } else {       mi = mi - x;     }     if (x % 2) par = 1 - par;     ma += x;   }   void reset() { mi = ma = par = 0; }   int main() {     int n;     scanf( %d , &n);     vector<int> v, p;     for (int i = 0; i < n; i++) {       long long x;       scanf( %lld , &x);       v.push_back(__builtin_popcountll(x));       p.push_back(v.back() % 2);     }     for (int i = n - 1; i >= 0; i--) {       sufp[i] = p[i];       if (i + 1 < n) sufp[i] ^= sufp[i + 1];     }     for (int i = 0; i < n; i++) {       freq[i][0] += sufp[i] == 0;       freq[i][1] += sufp[i] == 1;       if (i) {         freq[i][0] += freq[i - 1][0];         freq[i][1] += freq[i - 1][1];       }     }     long long ans = 0;     for (int i = 0; i < n; i++) {       int pos = i;       reset();       while (pos >= 0 and (mi > 1 or ma < 60)) {         add(v[pos]);         if (mi == 0) ans++;         pos--;       }       if (pos < 0) continue;       int base = sufp[pos + 1];       ans += freq[pos][par ^ base];     }     printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   set<string> ans;   string a;   int dp[1000010][5];   int main() {     cin >> a;     int len = a.size();     reverse(a.begin(), a.end());     for (int i = 1; i < len - 5; ++i) {       if (i == 1) {         string s1 =   ;         s1 += a[i];         s1 += a[i - 1];         ans.insert(s1);         dp[1][0] = 1;       }       if (i == 2) {         string s1 =   ;         s1 += a[i];         s1 += a[i - 1];         s1 += a[i - 2];         ans.insert(s1);         dp[2][1] = 1;       }       if (i >= 3 && (a[i] != a[i - 2] || a[i - 1] != a[i - 3]) &&           dp[i - 2][0] == 1) {         string s1 =   ;         s1 += a[i];         s1 += a[i - 1];         ans.insert(s1);         dp[i][0] = 1;       }       if (i >= 2 && dp[i - 2][1] == 1) {         string s1 =   ;         s1 += a[i];         s1 += a[i - 1];         ans.insert(s1);         dp[i][0] = 1;       }       if (i - 3 >= 0 && dp[i - 3][0] == 1) {         string s1 =   ;         s1 += a[i];         s1 += a[i - 1];         s1 += a[i - 2];         ans.insert(s1);         dp[i][1] = 1;       }       if (i - 5 >= 0 &&           (a[i] != a[i - 3] || a[i - 1] != a[i - 4] || a[i - 2] != a[i - 5]) &&           dp[i - 3][1] == 1) {         string s1 =   ;         s1 += a[i];         s1 += a[i - 1];         s1 += a[i - 2];         ans.insert(s1);         dp[i][1] = 1;       }     }     cout << ans.size() << endl;     for (set<string>::iterator it = ans.begin(); it != ans.end(); ++it) {       cout << *it << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, k;   string s;   int main() {     cin >> n >> k >> s;     --k;     if (k < n - 1 - k) {       while (k) {         cout <<  LEFT  << endl;         --k;       }       for (int i = 0; i < n; ++i) {         if (i) cout <<  RIGHT  << endl;         cout <<  PRINT   << s[i] << endl;       }     } else {       while (k < n - 1) {         cout <<  RIGHT  << endl;         ++k;       }       for (int i = 0; i < n; ++i) {         if (i) cout <<  LEFT  << endl;         cout <<  PRINT   << s[n - 1 - i] << endl;       }     }     return 0;   }