malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int N = 200010, M = 7000010;   int n, a[N], rt, tot;   map<int, int> mp;   int val[M];   vector<int> g[M];   int ans, ansx, ansy, S, T, cur, fa[M];   bool vis[M];   void dfs(int x, int fath, int dis, int *var) {     vis[x] = true;     if (x <= n && dis > cur) *var = x, cur = dis;     for (int y : g[x])       if (y != fath) dfs(y, x, dis + 1, var);   }   int getfa(int v) {     int t = 0, x = mp[v];     if (fa[x] != -1) return fa[x];     while ((1 << t) < v) t++;     int w = (1 << t) - v;     if (mp[w] == 0) tot++, mp[w] = tot, val[tot] = w;     g[x].push_back(mp[w]), g[mp[w]].push_back(x);     return fa[x] = w;   }   int main() {     cin >> n, tot = n;     for (int i = 1; i <= n; i++) scanf( %d , &a[i]), mp[a[i]] = i, val[i] = a[i];     sort(a + 1, a + n + 1), rt = a[1];     for (int i = 1; i <= n * 32; i++) fa[i] = -1;     for (int i = 2; i <= n; i++) {       int x = a[i], y = rt;       while (x != y) {         if (x < y) swap(x, y);         x = getfa(x);       }       rt = x;     }     ans = -1;     for (int i = 1; i <= n; i++)       if (!vis[i]) {         cur = 0, dfs(i, 0, 0, &S);         cur = 0, dfs(S, 0, 0, &T);         if (cur > ans) ans = cur, ansx = S, ansy = T;       }     printf( %d %d %d n , ansx, ansy, cur);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n;     cin >> n;     while (n) {       if (n % 10 != 1 && n % 100 != 14 && n % 1000 != 144) {         cout <<  NO ;         return 0;       }       n /= 10;     }     cout <<  YES ;     return 0;   }
#include <bits/stdc++.h>   char s[200005];   int res[200005];   int ptr;   int main() {     int n, a, b, k;     scanf( %d%d%d%d , &n, &a, &b, &k);     scanf( %s , s);     int cons = 0;     int cnt = 0;     for (int i = 0; i < n; i++) {       if (s[i] ==  0 ) cons++;       if (s[i] ==  1 ) {         cnt += cons / b;         cons = 0;       }     }     cnt += cons / b;     cons = 0;     for (int i = 0; i < n; i++) {       if (s[i] ==  0 )         cons++;       else         cons = 0;       if (cons == b && cnt > a - 1) {         res[ptr++] = i + 1;         cons = 0;         cnt--;       }     }     printf( %d n , ptr);     for (int i = 0; i < ptr; i++) printf( %d  , res[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 5;   int prefix[N];   int main() {     string s;     int n, k;     cin >> n >> k >> s;     for (int i = int(1); i <= int(n); i++)       prefix[i] = prefix[i - 1] +  1  - s[i - 1];     int ans = n + 1;     for (int i = int(1); i <= int(n); i++) {       if (s[i - 1] ==  0 ) {         int l = 0, r = n - 1;         while (l + 1 < r) {           int mid = (l + r) >> 1;           int L = i - mid, R = i + mid;           L = max(1, L), R = min(n, R);           if (prefix[R] - prefix[L - 1] > k)             r = mid;           else             l = mid;         }         ans = min(ans, r);       }     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       int n, c = 0;       cin >> n;       int w = 1;       int a[n];       for (int i = 0; i < n; i++) cin >> a[i];       if (n == 1)         cout <<  First  << endl;       else {         for (int i = 0; i < n; i++) {           if (a[i] == 1) c++;           if (a[i] == 1 && w == 1)             w = 2;           else if (a[i] == 1 && w == 2)             w = 1;           if (a[i] != 1) break;         }         if (c == n && c % 2 == 1)           cout <<  First  << endl;         else if (c == n && c % 2 == 0)           cout <<  Second  << endl;         else if (w == 1 && c != n)           cout <<  First  << endl;         else if (w == 2 && c != n)           cout <<  Second  << endl;       }     }   }
#include <bits/stdc++.h>   using namespace std;   int n, k, i, j, m, p, a[510];   double b[710000];   double calc(int x, int y, double a) { return (y - x) * a + x; }   int main() {     scanf( %d%d , &n, &k);     m = 700000 / k;     for (i = 1; i <= n; i++) {       double ans = 0;       for (j = 0; j <= k; j++) scanf( %d , &a[j]);       for (j = 0; j < k; j++) {         for (p = 0; p < m; p++) {           double s = calc(a[j], a[j + 1], 1.0 / m * (p + 0.5));           if (s > b[j * m + p]) ans += s - b[j * m + p], b[j * m + p] = s;         }       }       printf( %.10lf n , ans / m);     }   }
#include <bits/stdc++.h>   using namespace std;   int x[100], y[100];   int l1, l2, l3, l4, s, f[10], n;   int len(int g1, int g2) {     int res =         (((x[g1] - x[g2]) * (x[g1] - x[g2]) + (y[g1] - y[g2]) * (y[g1] - y[g2])));     return res;   }   bool prr(int kk1, int kk2, int kk3, int kk4) {     int ii, jj = 0, aa[4], kk, qq;     for (ii = 0; ii < 8; ii++)       if (ii != kk1 && ii != kk2 && ii != kk3 && ii != kk4) {         aa[jj++] = ii;       }     for (ii = 0; ii < 4; ii++)       for (jj = 0; jj < 4; jj++)         for (kk = 0; kk < 4; kk++)           for (qq = 0; qq < 4; qq++)             if (ii != jj && ii != kk && ii != qq && jj != kk && jj != qq &&                 kk != qq)               if (len(aa[ii], aa[jj]) == len(aa[kk], aa[qq]) &&                   len(aa[ii], aa[jj]) ==                       len(aa[ii], aa[kk]) + len(aa[ii], aa[qq]) &&                   len(aa[qq], aa[kk]) ==                       len(aa[ii], aa[kk]) + len(aa[jj], aa[kk]) &&                   len(aa[ii], aa[qq]) == len(aa[kk], aa[jj]) &&                   len(aa[ii], aa[kk]) == len(aa[jj], aa[qq]))                 return true;     return false;   }   bool kv(int q1, int q2, int q3, int q4) {     int i, a[4], j, k, q;     a[0] = q1;     a[1] = q2;     a[2] = q3;     a[3] = q4;     for (i = 0; i < 4; i++)       for (j = 0; j < 4; j++)         for (k = 0; k < 4; k++)           for (q = 0; q < 4; q++)             if (i != j && j != k && i != k && i != q && j != q && k != q) {               if (len(a[i], a[j]) == len(a[k], a[q]) &&                   len(a[i], a[j]) == len(a[i], a[q]) + len(a[i], a[k]) &&                   len(a[i], a[k]) == len(a[i], a[q]) &&                   len(a[k], a[q]) == len(a[k], a[i]) + len(a[k], a[j]) &&                   len(a[q], a[i]) == len(a[q], a[j])) {                 if (prr(q1, q2, q3, q4)) return true;               }             }     return false;   }   int main() {     for (l1 = 0; l1 < 8; l1++) scanf( %d %d , &x[l1], &y[l1]);     for (l1 = 0; l1 < 8; l1++)       for (l2 = 0; l2 < 8; l2++)         for (l3 = 0; l3 < 8; l3++)           for (l4 = 0; l4 < 8; l4++)             if (l1 != l2 && l1 != l3 && l1 != l4 && l2 != l3 && l2 != l4 &&                 l3 != l4 && kv(l1, l2, l3, l4)) {               printf( YES n );               printf( %d %d %d %d n , l1 + 1, l2 + 1, l3 + 1, l4 + 1);               for (s = 0; s < 8; s++)                 if (s != l1 && s != l2 && s != l3 && s != l4) f[n++] = s;               for (s = 0; s < 3; s++) printf( %d  , f[s] + 1);               printf( %d n , f[3] + 1);               return 0;             }     printf( NO n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, p;   struct Node {     int i, d;   } d[100005];   vector<int> v[100005 << 1];   bool cmp(Node x, Node y) { return x.d > y.d; }   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       scanf( %d , &d[i].d);       d[i].i = 2 * i;     }     sort(d + 1, d + n + 1, cmp);     for (int i = 1; i <= n; i++) {       v[p++].push_back(d[i].i);     }     for (int i = 1; i <= n; i++) {       if (i + d[i].d - 1 == p) {         v[p++].push_back(d[i].i - 1);       } else {         v[i + d[i].d - 2].push_back(d[i].i - 1);       }     }     for (int i = 0; i < p; i++) {       for (int j = 1; j < v[i].size(); j++) {         printf( %d %d n , v[i][0], v[i][j]);       }     }     for (int i = 1; i < p; i++) {       printf( %d %d n , v[i - 1][0], v[i][0]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long int mod = 1000000000 + 7;   const long long int N = 10000000 + 6;   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int a, b;     cin >> a >> b;     vector<pair<int, int> > bb, aa;     for (int i = 1; i < 1000; i++) {       for (int j = 1; j < 1000; j++) {         if (i * i + j * j == a * a) aa.push_back(make_pair(i, j));         if (i * i + j * j == b * b) bb.push_back(make_pair(i, j));       }     }     bool flag = false;     for (int i = 0; i < aa.size(); i++) {       for (int j = 0; j < bb.size(); j++) {         int p = aa[i].first;         int q = aa[i].second;         int r = bb[j].first;         int s = bb[j].second;         if (p * s == q * r) {           if (p != s) {             cout <<  YES n                   <<  0 0 n                   << p <<     << q <<   n                   << s <<     << -r;             flag = true;             break;           }         }       }       if (flag == true) break;     }     if (flag == false) cout <<  NO n  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct Info {     int h, l, r;     vector<int> A;     Info(vector<int> _A, int _h, int _l, int _r) : A(_A), h(_h), l(_l), r(_r) {}   };   int FindMaxGoodSleep(int idx, int time, vector<vector<int>>& memo,                        const Info& input) {     if (idx >= input.A.size()) {       return 0;     }     if (memo[idx][time] != -1) {       return memo[idx][time];     }     int new_time = (time + input.A[idx]) % input.h;     int a = (new_time >= input.l && new_time <= input.r ? 1 : 0) +             FindMaxGoodSleep(idx + 1, new_time, memo, input);     new_time = (time + input.A[idx] - 1) % input.h;     int b = (new_time >= input.l && new_time <= input.r ? 1 : 0) +             FindMaxGoodSleep(idx + 1, new_time, memo, input);     memo[idx][time] = max(a, b);     return memo[idx][time];   }   int main(void) {     int n, h, l, r;     cin >> n >> h >> l >> r;     vector<int> A(n);     for (int i = 0; i < n; i++) {       cin >> A[i];     }     Info info(A, h, l, r);     vector<vector<int>> memo(n + 5, vector<int>(2005, -1));     cout << FindMaxGoodSleep(0, 0, memo, info) << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> G[100009];   map<string, int> pr;   struct comp {     bool operator()(const pair<string, int>& l, const pair<string, int>& r) {       return l.second > r.second;     }   };   int main() {     pr[ captain ] = 1;     pr[ man ] = 2;     pr[ child ] = 3;     pr[ woman ] = 3;     pr[ rat ] = 4;     int n;     cin >> n;     getchar();     vector<pair<string, int> > v;     while (n--) {       string a, b;       cin >> a >> b;       v.push_back({a, pr[b]});     }     stable_sort(v.begin(), v.end(), comp());     for (int i = 0; i < v.size(); i++) cout << v[i].first << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<string> split(const string& s, char c) {     vector<string> v;     stringstream ss(s);     string x;     while (getline(ss, x, c)) v.emplace_back(x);     return move(v);   }   void err(vector<string>::iterator it) {}   template <typename T, typename... Args>   void err(vector<string>::iterator it, T a, Args... args) {     cerr << it->substr((*it)[0] ==    , it->length()) <<   =   << a <<   n ;     err(++it, args...);   }   typedef tuple<int, int, int> State;   int dx[] = {0, 1, 0, -1};   int dy[] = {1, 0, -1, 0};   const int N = 1e6 + 5;   const double EPS = 1e-10;   const long long INF = 1e18;   const double PI = acos(-1);   int n, m, k;   int dcmp(double a, double b) { return fabs(a - b) <= EPS ? 0 : a < b ? -1 : 1; }   string s, s2;   int arr[26];   int arr2[26];   int cnt = 0;   bool ok() {     for (int i = 0; i < 26; i++) {       if (arr[i] > arr2[i]) return 0;     }     return 1;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     cin >> s >> s2;     if (s.size() < s2.size()) {       cout <<  0 ;       return 0;     }     for (int i = 0; i < s2.size(); i++) {       arr2[s2[i] -  a ]++;       if (s[i] !=  ? )         arr[s[i] -  a ]++;       else         cnt++;     }     int ans = ok();     n = s2.size();     for (int i = s2.size(); i < s.size(); i++) {       if (s[i] !=  ? )         arr[s[i] -  a ]++;       else         cnt++;       if (s[i - n] !=  ? )         arr[s[i - n] -  a ]--;       else         cnt--;       ans += ok();     }     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int N = (int)1e5 + 123;   const long long INF = (long long)1e18 + 123;   const int inf = (int)1e9 + 123;   const int MOD = (int)1e9 + 7;   int type(string a) {     if (a ==  S ) return 1;     if (a ==  M ) return 2;     if (a ==  L ) return 3;     if (a ==  XL ) return 4;     if (a ==  XXL ) return 5;     if (a ==  XXXL ) return 6;     return 7;   }   int a[10], n;   string t, name[10] = {  ,  S ,  M ,  L ,  XL ,  XXL ,  XXXL }, res[N];   set<int> st[10];   vector<pair<int, pair<int, int> > > g;   int main() {     for (int i = 1; i <= 6; i++) cin >> a[i];     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> t;       string tmp1 =   , tmp2 =   ;       int pos = (int)(t.size());       for (int j = 0; j < (int)(t.size()); j++) {         if (t[j] ==  , ) {           pos = j + 1;           break;         }         tmp1 += t[j];       }       for (int j = pos; j < (int)(t.size()); j++) tmp2 += t[j];       if (type(tmp2) < type(tmp1)) swap(tmp1, tmp2);       if (type(tmp2) == 7) {         res[i] = tmp1, a[type(tmp1)]--;         continue;       }       g.push_back(make_pair(type(tmp1), make_pair(type(tmp2), i)));     }     sort(g.begin(), g.end());     for (auto i : g) {       if (a[i.first] > 0)         a[i.first]--, res[i.second.second] = name[i.first];       else         a[i.second.first]--, res[i.second.second] = name[i.second.first];     }     for (int i = 1; i <= 6; i++)       if (a[i] < 0) {         puts( NO );         return 0;       }     puts( YES );     for (int i = 1; i <= n; i++) cout << res[i] <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   int t, n, inp[3], cnt[100010];   map<pair<int, int>, vector<pair<int, int>>> el;   int root;   vector<int> qans;   vector<int> neigh[100010];   void solve() {     cin >> n;     el.clear();     for (int i = 1; i <= n; ++i) cnt[i] = 0, neigh[i].clear();     for (int i = 1; i + 2 <= n; ++i) {       for (int j = 0; j < 3; ++j) {         cin >> inp[j];         ++cnt[inp[j]];       }       sort(inp, inp + 3);       if (el.count({inp[0], inp[1]}))         el[{inp[0], inp[1]}].push_back({inp[2], i});       else         el[{inp[0], inp[1]}] = {{inp[2], i}};       if (el.count({inp[0], inp[2]}))         el[{inp[0], inp[2]}].push_back({inp[1], i});       else         el[{inp[0], inp[2]}] = {{inp[1], i}};       if (el.count({inp[1], inp[2]}))         el[{inp[1], inp[2]}].push_back({inp[0], i});       else         el[{inp[1], inp[2]}] = {{inp[0], i}};     }     for (auto& x : el) {       if (x.second.size() == 1) {         neigh[x.first.first].push_back(x.first.second);         neigh[x.first.second].push_back(x.first.first);       }     }     cout << 1 <<     << neigh[1][0];     int curr = neigh[1][0], prev = 1;     for (int i = 3; i <= n; ++i) {       if (neigh[curr][0] == prev) {         cout <<     << neigh[curr][1];         prev = curr;         curr = neigh[curr][1];       } else {         cout <<     << neigh[curr][0];         prev = curr;         curr = neigh[curr][0];       }     }     cout << endl;     for (int i = 1; i <= n; ++i)       if (cnt[i] == 1) {         root = i;         break;       }     pair<int, int> ce = {neigh[root][0], neigh[root][1]};     if (ce.first > ce.second) swap(ce.first, ce.second);     for (auto& x : el[ce]) {       if (x.first == root) {         qans.push_back(x.second);       }     }     queue<pair<pair<int, int>, int>> qq;     qq.push({ce, root});     while (!qq.empty()) {       auto x = qq.front();       qq.pop();       if (el[x.first].size() == 1) {         continue;       }       pair<int, int> y =           (el[x.first][0].first == x.second ? el[x.first][1] : el[x.first][0]);       qans.push_back(y.second);       pair<int, int> nxt1 = {x.first.first, y.first},                      nxt2 = {x.first.second, y.first};       if (nxt1.first > nxt1.second) swap(nxt1.first, nxt1.second);       if (nxt2.first > nxt2.second) swap(nxt2.first, nxt2.second);       qq.push({nxt1, x.first.second});       qq.push({nxt2, x.first.first});     }     while (!qans.empty()) {       cout << qans.back() <<    ;       qans.pop_back();     }     cout << endl;   }   int main() {     ios::sync_with_stdio(false);     for (cin >> t; t--;) solve();     return 0;   }
#include <bits/stdc++.h>      using namespace std;      const int N = 1000 * 1000 + 10;   long long int a[N], mm[N], visited[N], anss[N], ans;   int n;   vector <int> e[N];      void dfs(int v){    visited[v] = 1;    if (e[v].size() == 1 and v != 1){     anss[v] = 1;     return;    }    vector <int> vec;    for (auto u : e[v]){     if (visited[u] == 0){      dfs(u);/*      if (v == 6){       cout << u <<   kk  ;      }*/      vec.push_back(anss[u]);     }    }    sort(vec.begin(), vec.end());        if (v != 1){     if (vec.size() > 1){      ans = max(ans, vec.back() + 1ll);     }         }    else{          if (vec.size() > 1){      ans = max(ans, vec.back() + 0ll);      ans = max(ans, vec[vec.size() - 2] + 1ll);     }    }    anss[v] = vec[0] + 1;    ans = max(ans, vec[0] + 0ll);/*    if (ans == 4){     cout << v <<     << vec.back() + 1 <<   n ;    }*/    vec.clear();       }      int main(){    int tt;    cin >> tt;    while (tt--){     ans = 0;     int n;     cin >> n;     for (int i = 0; i < n - 1; i++){      int x, y;      cin >> x >> y;      e[x].push_back(y);      e[y].push_back(x);     }//vec.clear();     dfs(1);     /*     for (int i = 1; i <= n; i++){      cout << anss[i] <<    ;     }     cout <<   n ;*/     cout << ans <<   n ;     for (int i = 1; i <= n; i++){      e[i].clear();      visited[i] = 0;      anss[i] = 0;     }       }   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   T gcd(T a, T b) {     if (a == 0) return b;     return gcd(b % a, a);   }   template <typename T>   T pow(T a, T b, long long m) {     T ans = 1;     while (b > 0) {       if (b % 2 == 1) ans = (ans * a) % m;       b /= 2;       a = (a * a) % m;     }     return ans % m;   }   int bit[100005];   int n;   int a[100005];   int lis[100005];   void update(int x, int val) {     for (int i = x; i < 100005; i += (i & -i)) bit[i] = max(bit[i], val);   }   int read(int x) {     int res = 0;     for (int i = x; i; i -= (i & -i)) res = max(res, bit[i]);     return res;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     cin >> n;     int ans = 0;     for (int i = 1; i <= n; i++) cin >> a[i];     for (int i = 1; i <= n; i++) {       lis[i] = read(a[i] - 1) + 1;       update(a[i], lis[i]);       ans = max(ans, lis[i]);     }     cout << ans;   }
#include <bits/stdc++.h>   const int maxn = 1010;   int n, m, K, N;   int a[maxn][maxn];   char row[maxn][maxn], col[maxn][maxn];   void Read() {     int i;     scanf( %d%d%d , &n, &m, &K);     for (i = 1; i <= 2 * n - 1; i++)       if (i & 1)         scanf( %s , row[i + 1 >> 1] + 1);       else         scanf( %s , col[i >> 1] + 1);     N = n * (m - 1) + m * (n - 1);   }   void Solve1() {     int i, j, t;     t = 0;     for (i = 1; i <= n; i++)       for (j = 1; j <= m - 1; j++)         if (row[i][j] ==  N ) t++;     for (i = 1; i <= n - 1; i++)       for (j = 1; j <= m; j++)         if (col[i][j] ==  N ) t++;     if (t >= N * 0.25) return (void)printf( NO n );     printf( YES n );     for (i = 1; i <= n; i++) {       for (j = 1; j <= m - 1; j++) printf( 1  );       printf( 1 n );     }   }   void Solve2() {     int i, j, t;     a[1][1] = 1;     for (j = 1; j <= m - 1; j++) {       a[1][j + 1] = a[1][j];       if (row[1][j] ==  N ) a[1][j + 1] = 3 - a[1][j];     }     for (i = 2; i <= n; i++) {       a[i][1] = 1;       t = a[i][1] == a[i - 1][1] ^ col[i - 1][1] ==  E ;       for (j = 1; j <= m - 1; j++) {         a[i][j + 1] = a[i][j];         if (row[i][j] ==  N ) a[i][j + 1] = 3 - a[i][j];         t += a[i][j + 1] == a[i - 1][j + 1] ^ col[i - 1][j + 1] ==  E ;       }       if (t > m / 2)         for (j = 1; j <= m; j++) a[i][j] = 3 - a[i][j];     }   }   void Solve3() {     int i, j, t;     a[1][1] = 1;     for (i = 1; i <= n - 1; i++) {       a[i + 1][1] = a[i][1];       if (col[i][1] ==  N ) a[i + 1][1] = 3 - a[i][1];     }     for (j = 2; j <= m; j++) {       a[1][j] = a[1][j - 1];       t = a[1][j - 1] == a[1][j] ^ row[1][j - 1] ==  E ;       for (i = 1; i <= n - 1; i++) {         a[i + 1][j] = a[i][j];         if (col[i][j] ==  N ) a[i + 1][j] = 3 - a[i][j];         t += a[i + 1][j] == a[i + 1][j - 1] ^ row[i + 1][j - 1] ==  E ;       }       if (t > n / 2)         for (i = 1; i <= n; i++) a[i][j] = 3 - a[i][j];     }   }   void Write() {     int i, j;     printf( YES n );     for (i = 1; i <= n; i++) {       for (j = 1; j <= m - 1; j++) printf( %d  , a[i][j]);       printf( %d n , a[i][m]);     }   }   int main() {     Read();     if (K == 1)       Solve1();     else {       if (n <= m)         Solve2();       else         Solve3();       Write();     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, k;     cin >> n >> k;     if (n < k || (n > 1 && k == 1)) {       cout << -1 << endl;       return 0;     }     if (n <= 2) {       n == 1 ? cout <<  a  << endl : cout <<  ab  << endl;       return 0;     }     char *str = new char[n + 1];     str[n] =   0 ;     int pos = 0;     int prev = 1;     char used =  a  - 1;     while (n - pos > k - 2) {       if (prev == 1) {         str[pos] =  a ;         prev = 0;       } else {         str[pos] =  b ;         prev = 1;       }       if (used < str[pos]) {         used = str[pos];       }       pos++;     }     while (pos != n) {       used++;       str[pos] = used;       pos++;     }     cout << str << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, k, a, b, c, d, now, f[1001];   bool jud[1001];   int main() {     cin.sync_with_stdio(false);     cin >> n >> k;     cin >> a >> b >> c >> d;     if (k < n + 1 || n == 4) {       cout << -1 << endl;       return 0;     }     f[1] = a;     f[2] = c;     f[n - 1] = d;     f[n] = b;     jud[a] = jud[b] = jud[c] = jud[d] = true;     int now = 1;     for (int i = 3; i <= n - 2; i++) {       while (jud[now]) now++;       f[i] = now;       now++;     }     for (int i = 1; i <= n - 1; i++) cout << f[i] <<    ;     cout << f[n] << endl;     cout << f[2] <<     << f[1] <<    ;     for (int i = 3; i <= n - 2; i++) cout << f[i] <<    ;     cout << f[n] <<     << f[n - 1];   }