malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int main() {     cin.sync_with_stdio(false), cin.tie(nullptr);     int tests;     cin >> tests;     while (tests--) {       int n, k;       string s;       cin >> n >> k >> s;       const int need = n / k;       vector<vector<int>> counts(k, vector<int>(26, 0));       for (int i = 0; i < n; i++) {         counts[i % k][s[i] -  a ]++;       }       int ans = 0;       for (int i = 0, j = k - 1; i <= j; i++, j--) {         int cost = need * 2 - counts[i][0] - counts[j][0];         for (int c = 1; c < 26; c++) {           cost = min(cost, need * 2 - counts[i][c] - counts[j][c]);         }         ans += (i == j ? cost / 2 : cost);       }       cout << ans <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   vector<int> solve(vector<int> a) {     int n = (int)a.size();     vector<int> dp(n + 1, 1e9);     dp[0] = -1e9;     vector<int> ret(n);     for (int i = 0; i < n; i++) {       int x = (int)(upper_bound(dp.begin(), dp.end(), a[i]) - dp.begin());       ret[i] = x;       dp[x] = a[i];     }     return ret;   }   int main() {     int n, m;     cin >> m >> n;     vector<int> a(n);     vector<int> delta(n + 1);     for (int i = 0; i < m; i++) {       int x, y;       cin >> x >> y;       x--;       delta[x]++;       delta[y]--;     }     int temp = 0;     for (int i = 0; i < n; i++) {       temp += delta[i];       a[i] = temp;     }     auto l = solve(a);     reverse(a.begin(), a.end());     auto r = solve(a);     reverse(r.begin(), r.end());     int ans = 0;     for (int i = 0; i < n; i++) {       ans = max(ans, l[i] + r[i] - 1);     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long N = 1e9 + 7;   void solve() {     long long n;     cin >> n;     vector<long long> v(n);     for (int i = 0; i < n; i++) cin >> v[i];     long long b[n];     long long sum = 0;     for (int i = 0; i < n; i++) sum += v[i];     long long x = (n * (n + 1)) / 2;     long long tot = sum / x;     if (sum % x != 0) {       cout <<  NO ;       return;     }     b[0] = v[n - 1] - v[0];     for (int i = 1; i < n; i++) {       b[i] = v[i - 1] - v[i];     }     long long ans = 0;     vector<long long> an;     for (int i = 0; i < n; i++) {       ans = (b[i] + tot) / (n);       an.push_back(ans);     }     if ((b[0] + tot) % n != 0) an[0] = -1;     int f = 1;     for (int i = 0; i < n; i++) {       if (an[i] <= 0) f = 0;     }     if (f) {       cout <<  YES n ;       for (auto y : an) cout << y <<    ;     } else {       cout <<  NO ;     }   }   int main() {     int t;     cin >> t;     while (t--) {       solve();       cout <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     map<char, long long> m;     for (long long i = 0; i < 26; i++) {       char ch;       cin >> ch;       m[ch] = i;     }     string str;     cin >> str;     long long ans = 0, sum = 0;     for (long long i = 0; i < str.length() - 1; i++) {       sum = abs(m[str[i]] - m[str[i + 1]]);       ans += sum;     }     cout << ans <<   n ;     return;   }   signed main() {     ios_base::sync_with_stdio(false), cin.tie(NULL);     long long t = 1;     cin >> t;     for (long long i = 0; i < t; i++) {       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e3 + 3;   char ch;   bool flag = 0;   void read(int &x) {     for (ch = getchar(); !isdigit(ch) && ((flag |= (ch ==  - )) || 1);          ch = getchar())       ;     for (x = 0; isdigit(ch); x = (x << 1) + (x << 3) + ch - 48, ch = getchar())       ;     x *= 1 - 2 * flag;   }   string ans =   ;   bool h = 0;   string s;   void fu() {     if (cin >> s) {       ans += s;       if (s ==  pair ) {         ans +=  < ;         fu();         ans +=  , ;         fu();         ans +=  > ;       }     } else {       h = 1;     }     if (h) return;   }   int main() {     int n;     read(n);     fu();     if (h || (cin >> s))       cout <<  Error occurred  << endl;     else       cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int inf = 1000000000;   long long mod = 1000000007LL;   long long mod2 = 998244353LL;   int n;   int t, q;   long long a[100005], b[100005];   long long pre[100005];   struct node {     int l, r;     long long mx, mn;   } tree[100005 << 2];   void build(int id, int l, int r) {     tree[id].l = l;     tree[id].r = r;     if (l == r) {       tree[id].mx = pre[l];       tree[id].mn = pre[l];       return;     }     int mid = (l + r) / 2;     build(id * 2, l, mid);     build(id * 2 + 1, mid + 1, r);     tree[id].mx = max(tree[id * 2].mx, tree[id * 2 + 1].mx);     tree[id].mn = min(tree[id * 2].mn, tree[id * 2 + 1].mn);   }   long long query(int id, int l, int r, bool mx) {     if (tree[id].l == l && tree[id].r == r) {       return (mx ? tree[id].mx : tree[id].mn);     }     int mid = (tree[id].l + tree[id].r) / 2;     if (r <= mid)       return query(id * 2, l, r, mx);     else if (l > mid)       return query(id * 2 + 1, l, r, mx);     else {       long long r1 = query(id * 2, l, mid, mx);       long long r2 = query(id * 2 + 1, mid + 1, r, mx);       return (mx ? max(r1, r2) : min(r1, r2));     }   }   int main() {     cin >> n >> q;     for (int i = 1; i <= n; ++i) {       scanf( %lld , &a[i]);     }     for (int i = 1; i <= n; ++i) {       scanf( %lld , &b[i]);     }     pre[0] = 0LL;     for (int i = 1; i <= n; ++i) {       pre[i] = pre[i - 1] + b[i] - a[i];     }     build(1, 1, n);     while (q-- > 0) {       int l, r;       scanf( %d%d , &l, &r);       if (pre[r] - pre[l - 1] != 0 || query(1, l, r, false) < pre[l - 1]) {         puts( -1 );       } else {         printf( %lld n , query(1, l, r, true) - pre[l - 1]);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long x, y;   vector<long long> cnt;   vector<char> sol;   bool ok;   void solve(long long x, long long y) {     if (!x) {       if (y == 1) ok = 1;       return;     }     if (!y) {       if (x == 1) ok = 1;       return;     }     if (x == y) {       if (x == 1) ok = 1;       return;     }     if (x > y) {       sol.push_back( A );       if (x % y == 0) {         cnt.push_back(x / y - 1);       } else {         cnt.push_back(x / y);       }       solve(x % y, y);     } else {       sol.push_back( B );       if (y % x == 0) {         cnt.push_back(y / x - 1);       } else {         cnt.push_back(y / x);       }       solve(x, y % x);     }   }   int main() {     cin >> x >> y;     solve(x, y);     if (ok) {       for (int i = 0; i < sol.size(); ++i) {         cout << cnt[i] << sol[i];       }     } else {       cout <<  Impossible ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char c[100003], b[100003];   int ggg[100003];   string a;   long long d, e, f, g, ming, oo, ksa, lxy;   bool nn, o;   int main() {     gets(c);     c[strlen(c)] =    ;     a = c;     for (int i = 0; i <= a.length(); i++) {       if (a.substr(i, 1) ==    ) {         if (o == 0) {           if (i >= 5 && a.substr(i - 5, 5) ==  liala )             nn = 1;           else if (i >= 4 && a.substr(i - 4, 4) ==  etra )             nn = 1;           else if (i >= 6 && a.substr(i - 6, 6) ==  inites )             nn = 1;           o = 1;         }         if (!nn) {           if (i >= 3 && a.substr(i - 3, 3) ==  etr ) {             ming += 1;             g++;             ggg[g] = 2;           } else if (i >= 6 && a.substr(i - 6, 6) ==  initis ) {             g++;             ggg[g] = 3;           } else if (i >= 4 && a.substr(i - 4, 4) ==  lios ) {             g++;             ggg[g] = 1;           } else {             cout <<  NO  << endl;             return 0;           }         }         if (nn) {           if (i >= 4 && a.substr(i - 4, 4) ==  etra ) {             g++;             ggg[g] = 2;             ming += 1;           } else if (i >= 6 && a.substr(i - 6, 6) ==  inites ) {             g++;             ggg[g] = 3;           } else if (i >= 5 && a.substr(i - 5, 5) ==  liala ) {             g++;             ggg[g] = 1;           } else {             cout <<  NO  << endl;             return 0;           }         }         oo++;       }     }     if (oo == 1) {       if (a.length() >= 5 && a.substr(a.length() - 5, 4) ==  lios ) ming = 1;       if (a.length() >= 4 && a.substr(a.length() - 4, 3) ==  etr ) ming = 1;       if (a.length() >= 7 && a.substr(a.length() - 7, 6) ==  inites ) ming = 1;       if (a.length() >= 7 && a.substr(a.length() - 7, 6) ==  initis ) ming = 1;       if (a.length() >= 6 && a.substr(a.length() - 6, 5) ==  liala ) ming = 1;       if (a.length() >= 5 && a.substr(a.length() - 5, 4) ==  etra ) ming = 1;     }     for (int i = 1; i <= 100002; i++) {       if (ggg[i] == 0) {         ksa = 1;         break;       }       if (ggg[i] < ggg[i - 1]) break;     }     if (ming == 1 && oo == 1) {       cout <<  YES  << endl;       return 0;     } else if (oo == 1) {       cout <<  NO  << endl;       return 0;     }     if (ming == 1 && ksa == 1)       cout <<  YES  << endl;     else       cout <<  NO  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct Point {     double x, y;   };   Point points[100000];   int gcd(int a, int b) {     if (b) return gcd(b, a % b);     return a;   }   int main() {     int n;     while (scanf( %d , &n) != EOF) {       long double A = 0.0;       long double b = 0.0;       for (int i = int(0); i < int(n); i++) {         scanf( %lf %lf , &points[i].x, &points[i].y);       }       long double totProb = 1.0;       if (n < 60) {         totProb = pow(2., n) - n * (n - 1) / 2. - n - 1;         for (int i = int(0); i < int(n); i++) {           for (int j = int(1); j < int(n); j++) {             int k = (i + j) % n;             long double prob = pow(2, n - j - 1) - 1.;             A += prob * (points[i].x * points[k].y - points[k].x * points[i].y);             b += prob * gcd(abs(points[i].x - points[k].x),                             abs(points[i].y - points[k].y));           }         }       } else {         for (int i = int(0); i < int(n); i++) {           for (int j = int(1); j < int(60); j++) {             int k = (i + j) % n;             long double prob = pow(2, -j - 1);             A += prob * (points[i].x * points[k].y - points[k].x * points[i].y);             b += prob * gcd(abs(points[i].x - points[k].x),                             abs(points[i].y - points[k].y));           }         }       }       double ans = (A - b) / totProb / 2. + 1.;       printf( %.12lf n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long mod = 998244353;   const long long MAX = 6e6 + 10;   int w[1000];   int a[1000];   void solve() {     int n;     cin >> n;     memset(a, 0, sizeof(a));     for (int i = 0; i < n; i++) {       cin >> w[i];       a[w[i]]++;     }     int ans = 0;     for (int i = 2; i <= n * 2; i++) {       int sum = 0;       for (int j = 0; j <= i; j++) {         sum += min(a[j], a[i - j]);       }       ans = max(ans, sum / 2);     }     cout << ans << endl;   }   int main() {     int _ = 1;     cin >> _;     while (_--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, x, i, a[200], s1, s2, j = 2;   string can =  YES ;   int main() {     cin >> n;     cin >> x;     x = 7 - x;     for (i = 0; i < n * 2; i++) {       cin >> a[i];     }     for (i = 1; i < n; i++) {       s1 = a[j];       s2 = a[j + 1];       if (x == s1 || x == s2 || x == 7 - s2 || x == 7 - s1) {         can =  NO ;         break;       }       j += 2;     }     cout << can;   }
#include <bits/stdc++.h>   using namespace std;   const int maxN = 502;   long long c[maxN][maxN];   long long a[maxN];   int n, m, b, md;   int main() {     cin >> n >> m >> b >> md;     for (int i = 1; i <= n; i++) cin >> a[i];     c[0][0] = 1;     for (int i = 1; i <= n; i++)       for (int j = 0; j < m; j++)         for (int t = 0; t <= b - a[i]; t++)           if (c[j][t] > 0) {             c[j + 1][t + a[i]] = (c[j + 1][t + a[i]] + c[j][t]) % md;           }     long long ans = 0;     for (int i = 0; i <= b; i++) ans = (ans + c[m][i]) % md;     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     long long x, d;     int cntDist = 0;     string inp;     cin >> n >> x;     getline(cin, inp);     for (int i = 0; i < n; i++) {       getline(cin, inp);       stringstream ss(inp.substr(2));       ss >> d;       if (inp[0] ==  + ) {         x += d;       } else {         if (x < d)           cntDist++;         else           x -= d;       }     }     cout << x <<     << cntDist;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a, b, c, d[100005];   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> a >> b >> c;     a = a % b;     d[a]++;     int t;     for (int i = 1; i <= 100005; ++i) {       t = a * 10 / b;       if (t == c) {         cout << i;         exit(0);       }       a = ((a * 10) % b);       d[a]++;       if (d[a] == 2) {         cout <<  -1 ;         exit(0);       }     }   }
#include <bits/stdc++.h>   using namespace std;   long long n, m, r, k, tot;   int dx[] = {0, -1, 0, 1};   int dy[] = {-1, 0, 1, 0};   struct Cell {     long long c, x, y;     bool operator<(const Cell &oth) const { return c < oth.c; }   };   class Map {    private:     set<long long> vis;       public:     bool isVisit(long long x, long long y) {       return vis.count((x - 1) * m + y - 1);     }     void setVisit(long long x, long long y) { vis.insert((x - 1) * m + y - 1); }   } mp;   long long calc(long long x, long long y) {     return min(r, min(n - r + 1, min(x, n - x + 1))) *            min(r, min(m - r + 1, min(y, m - y + 1)));   }   priority_queue<Cell> pq;   void solve() {     scanf( %lld%lld%lld%lld , &n, &m, &r, &k);     pq.push({calc(r, r), r, r});     mp.setVisit(r, r);     while (!pq.empty() && k) {       Cell cur = pq.top();       pq.pop();       k--;       tot += cur.c;       for (int i = 0; i < 4; i++) {         int nx = cur.x + dx[i], ny = cur.y + dy[i];         if (0 < nx && nx <= n && 0 < ny && ny <= m && !mp.isVisit(nx, ny)) {           pq.push({calc(nx, ny), nx, ny});           mp.setVisit(nx, ny);         }       }     }     printf( %.10f n , 1.0 * tot / (1.0 * (n - r + 1) * (m - r + 1)));   }   int main() {     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int pw(int a, int b) {     if (b == 0) return 1;     if (b == 1) return a;     long long rep = pw(a, b / 2), M = 1e9 + 7;     if (b % 2 == 0) return (rep * rep) % M;     return (((rep * rep) % M) * a) % M;   }   int main() {     int n, k, m;     cin >> n >> m >> k;     if (k == 1 || k > n) {       cout << pw(m, n);       return 0;     }     if (k == n) {       cout << pw(m, (n + 1) / 2);       return 0;     }     long long answer = m;     if (k % 2 == 1) {       answer += m * (m - 1);     }     cout << answer << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m, i, j;     string ss;     cin >> n >> m >> ss;     for (i = 0; i < m; i++) {       for (j = 0; j < n; j++) {         if (ss[j] ==  B  && ss[j + 1] ==  G ) {           ss[j] =  G ;           ss[j + 1] =  B ;           j++;         }       }     }     cout << ss << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int Maxn = 4010;   double num1[Maxn];   int num2[Maxn];   double dif[Maxn];   int main() {     int n = 0, N = 0;     int cnt = 0, cnt1 = 0, cnt2 = 0;     double sum = 0;     double ans = 100000000.0;     scanf( %d , &n);     N = 2 * n;     for (int i = 0; i < N; i++) {       scanf( %lf , &num1[i]);       num2[i] = num1[i];       dif[i] = (double)num1[i] - (double)num2[i];     }     for (int i = 0; i < N; i++) {       if (dif[i] != 0) {         cnt1++;         sum += dif[i];       } else {         cnt2++;       }     }     cnt = min(cnt1, n);     for (int i = 0; i <= cnt; i++) {       if (i + cnt2 >= n) {         ans = min(ans, fabs(sum - i * 1.0));       }     }     printf( %.3f , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   double res, a, b;   int main() {     int n, k;     cin >> n >> k;     vector<double> x(n), y(n);     for (int i = 0; i < n; i++) {       cin >> x[i] >> y[i];       if (i) {         a = x[i] - x[i - 1];         b = y[i] - y[i - 1];         res += sqrt((a * a) + (b * b));       }     }     res /= 50;     cout << setprecision(10) << res * k << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m;     cin >> n >> m;     int mass[n];     for (int i = 0; i < n; i++) cin >> mass[i];     list<int> lis;     int ans = 0;     for (int i = 0; i < m; i++) {       int temp;       cin >> temp;       temp--;       if (lis.empty())         lis.push_front(temp);       else {         int sum = 0;         list<int>::iterator i;         for (i = lis.begin(); i != lis.end(); i++) {           if (*i == temp)             break;           else             sum += mass[*i];         }         if (i != lis.end()) lis.erase(i);         lis.push_front(temp);         ans += sum;       }     }     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   int sst(string g) {     int f;     stringstream ss;     ss << g;     ss >> f;     return f;   }   int main() {     string s, s1, s2, s3;     cin >> s;     int max = -1, h = 0;     int t = s.size(), x, y, z;     if (t < 3) {       cout <<  -1  << endl;       return 0;     }     for (int i = 0; i < t - 1; i++) {       for (int j = i + 1; j < t - 1; j++) {         s1 = s.substr(0, i + 1);         s2 = s.substr(i + 1, j - i);         s3 = s.substr(j + 1, t - j - 1);         x = sst(s1);         y = sst(s2);         z = sst(s3);         if (s1.size() == 0 || s2.size() == 0 || s3.size() == 0) continue;         if (s1[0] ==  0  && s1.size() > 1) continue;         if (s2[0] ==  0  && s2.size() > 1) continue;         if (s3[0] ==  0  && s3.size() > 1) continue;         if (x <= 1000000 && y <= 1000000 && z <= 1000000 && x + y + z > max) {           max = x + y + z;           h = 1;         }       }     }     if (h = 1)       cout << max;     else       cout <<  -1 ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string binary(long long n) {     string result;     do result +=  0  + (n & 1);     while (n >>= 1);     reverse(result.begin(), result.end());     return result;   }   int countSubstr(const string& str, const string& sub) {     if (sub.length() == 0) return 0;     int count = 0;     for (size_t offset = str.find(sub); offset != string::npos;          offset = str.find(sub, offset + sub.length())) {       ++count;     }     return count;   }   vector<bool> primes;   vector<int> primesCnt;   void seive(int a, int b) {     primes = vector<bool>(b + 1, true);     primesCnt = vector<int>(b, true);     primes[0] = primes[1] = false;     for (int i = 2; i * i <= b; i++) {       for (int j = i; j * i <= b; j++) {         primes[i * j] = false;       }     }     primesCnt[0] = 0;     for (decltype(b + 1)(i) = (1); (i) < (b + 1); (i)++) {       primesCnt[i] = primesCnt[i - 1] + primes[i];     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr);     int a, b, k, ans = -1;     cin >> a >> b >> k;     seive(a, b);     if (primesCnt[b] - primesCnt[a - 1] < k) {       cout << ans;       return 0;     }     int left = 0, right = b - a + 1, med;     while (right > left + 1) {       med = (right + left) / 2;       bool can = true;       int j = a + med - 1;       while (j <= b) {         if (primesCnt[j] - primesCnt[j - med] < k) {           can = false;           break;         }         j++;       }       if (can)         right = med;       else         left = med;     }     cout << right;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool compare(const pair<int, int>& i, const pair<int, int>& j) {     return i.first < j.first;   }   int ncr(int n, int k) {     if (n < k) return 0;     int C[n + 1][k + 1];     int i, j;     for (i = 0; i <= n; i++) {       for (j = 0; j <= min(i, k); j++) {         if (j == 0 || j == i)           C[i][j] = 1;         else           C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % 1000000007;       }     }     return C[n][k];   }   long long modpowIter(long long a, long long b, long long c) {     long long ans = 1;     while (b != 0) {       if (b % 2 == 1) ans = (ans * a) % LLONG_MAX;       a = (a * a) % LLONG_MAX;       b /= 2;     }     return ans;   }   string intobin(int n) {     string s =   ;     if (n == 0) s =  0 ;     while (n) {       if (n % 2)         s =  1  + s;       else         s =  0  + s;       n /= 2;     }     return s;   }   int bintoin(string s) {     long long n = 0;     vector<long long> v;     v.push_back(1);     for (int i = 0; i < 400; i++) {       v.push_back((v[v.size() - 1] * 2) % 1000003);     }     for (int i = s.length() - 1; i > -1; i--) {       n = (n + (s[i] -  0 ) * v[s.length() - i - 1]) % 1000003;     }     return n;   }   long long nc2(long long n, long long k) {     if (n < k) return 0;     return (n * (n - 1)) / 2;   }   bool prime[1000001];   void SieveOfEratosthenes(int n) {     memset(prime, true, sizeof(prime));     for (int p = 2; p * p <= n; p++) {       if (prime[p] == true) {         for (int i = p * p; i <= n; i += p) prime[i] = false;       }     }   }   int main() {     int n;     cin >> n;     int m;     cin >> m;     int arr[n];     double b[n];     for (int i = 0; i < n; i++) {       cin >> arr[i] >> b[i];     }     int dp[n];     dp[0] = 1;     for (int i = 1; i <= n - 1; i++) {       dp[i] = 1;       for (int j = 0; j < i; j++) {         if (arr[i] >= arr[j] && dp[i] < dp[j] + 1) dp[i] = dp[j] + 1;       }     }     cout << n - (*max_element(dp, dp + n));     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 2000 + 20;   int a[maxn];   int main() {     int n, k;     cin >> n >> k;     for (int i = 0; i < n; i++) {       cin >> a[i];     }     sort(a, a + n);     int ans = 0;     for (int i = n - 1; i >= 0; i -= k) {       ans += 2 * (a[i] - 1);     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 2000;   int n, k;   int a, b, c, d;   int num[MAXN], num_cnt = 0;   int rank[MAXN];   set<int> s;   vector<int> v;   int main() {     cin >> n >> k;     cin >> a >> b >> c >> d;     if (k <= n) {       cout << -1 << endl;     } else {       if (n >= 5) {         for (int i = 1; i <= n; ++i) {           if (i != a && i != b && i != c && i != d) {             s.insert(i);           }         }         v.push_back(a);         v.push_back(c);         while (!s.empty()) {           v.push_back(*s.begin());           s.erase(s.begin());         }         v.push_back(d);         v.push_back(b);         for (int i = 0; i < v.size(); ++i) {           cout << v[i] <<    ;         }         cout << endl;         cout << c <<     << a <<    ;         for (int i = (int)v.size() - 3; i >= 2; --i) {           cout << v[i] <<    ;         }         cout << b <<     << d << endl;       } else if (n == 4) {         cout << -1 << endl;       }     }   }
#include <bits/stdc++.h>   using namespace std;   int a[1234];   int main() {     int n;     scanf( %d , &n);     for (int i = 0; i < n; i++) scanf( %d , a + i);     int mx = 0;     for (int i = 0; i < n; i++)       if (a[i] > mx) mx = a[i];     for (int u = 1; u <= mx; u++) {       for (int i = 0; i < n; i++) {         if (a[i] >= u) putchar( P );         if (i < n - 1)           putchar( R );         else {           for (int j = 0; j < n - 1; j++) putchar( L );         }       }     }     printf(  n );     return 0;   }