malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   char mat[6][40];   int t[6], n, v[6];   int solve() {     if (t[v[4]] != t[v[1]] + t[v[3]] - 1) return 0;     if (t[v[5]] != t[v[0]] + t[v[2]] - 1) return 0;     if (mat[v[0]][0] != mat[v[1]][0]) return 0;     if (mat[v[0]][t[v[0]] - 1] != mat[v[4]][0]) return 0;     if (mat[v[1]][t[v[1]] - 1] != mat[v[5]][0]) return 0;     if (mat[v[5]][t[v[5]] - 1] != mat[v[3]][0]) return 0;     if (mat[v[3]][t[v[3]] - 1] != mat[v[2]][t[v[2]] - 1]) return 0;     if (mat[v[4]][t[v[4]] - 1] != mat[v[2]][0]) return 0;     if (mat[v[5]][t[v[0]] - 1] != mat[v[4]][t[v[1]] - 1]) return 0;     return 1;   }   int main() {     n = 6;     vector<string> ans, aux;     for (int i = 0; i < n; i++) {       scanf(  %s , mat[i]);       t[i] = strlen(mat[i]);     }     for (int i = 0; i < n; i++) v[i] = i;     do {       int k = solve();       if (!k) continue;       aux.resize(t[v[4]]);       for (int i = 0; i < t[v[4]]; i++) {         aux[i].resize(t[v[5]]);         for (int j = 0; j < t[v[5]]; j++) aux[i][j] =  . ;       }       for (int i = 0; i < t[v[0]]; i++) aux[0][i] = mat[v[0]][i];       for (int i = 0; i < t[v[1]]; i++) aux[i][0] = mat[v[1]][i];       for (int i = 0; i < t[v[2]]; i++)         aux[aux.size() - 1][i + t[v[0]] - 1] = mat[v[2]][i];       for (int i = 0; i < t[v[3]]; i++)         aux[t[v[1]] - 1 + i][t[v[5]] - 1] = mat[v[3]][i];       for (int i = 0; i < t[v[4]]; i++) aux[i][t[v[0]] - 1] = mat[v[4]][i];       for (int i = 0; i < t[v[5]]; i++) aux[t[v[1]] - 1][i] = mat[v[5]][i];       if (ans.size() == 0 || aux < ans) ans = aux;     } while (next_permutation(v, v + n));     if (ans.size() == 0)       printf( Impossible n );     else {       for (int i = 0; i < ans.size(); i++) printf( %s n , ans[i].c_str());     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     char a[200000], *s;     cin >> a;     if ((s = strstr(a,  AB )) && (strstr(s + 2,  BA )))       puts( YES );     else if ((s = strstr(a,  BA )) && strstr(s + 2,  AB ))       puts( YES );     else       puts( NO );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int shi(int a[], int k, int len) {     int s = 0, j;     for (j = len - 1; j >= 0; j--) {       s = s * k + a[j];     }     return s;   }   int bian(int n, int k) {     int i;     for (i = 0; n > 0; i++) {       n /= k;     }     return i;   }   int change(int a[1000], int n) {     int i;     for (i = 0; n > 0; i++) {       a[i] = n % 10;       n /= 10;     }     return i;   }   int main() {     int a, b;     int ta[1000], tb[1000];     int i, la, lb;     while (scanf( %d%d , &a, &b) != -1) {       int max = 0;       la = change(ta, a);       lb = change(tb, b);       for (i = 0; i < la; i++) {         if (ta[i] > max) max = ta[i];       }       for (i = 0; i < lb; i++) {         if (tb[i] > max) max = tb[i];       }       max += 1;       int sa = shi(ta, max, la), sb = shi(tb, max, lb);       int sum = sa + sb;       int ss = bian(sum, max);       printf( %d n , ss);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int n;     cin >> n;     string s;     cin >> s;     for (int i = 1; i < n; i++) {       if (s[i] < s[i - 1]) {         cout <<  YES  <<   n ;         cout << i <<     << i + 1 <<   n ;         return 0;       }     }     cout <<  NO  <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 10;   int A[N][N * N], B[N][N * N], C[N][N * N];   int main() {     int n, m, k;     cin >> n >> m >> k;     for (int i = 0; i < n; i++) {       string s;       cin >> s;       for (int j = 0; j < m; j++) cin >> A[i][j] >> B[i][j] >> C[i][j];     }     int ans = 0;     for (int i = 0; i < n; i++) {       for (int j = 0; j < n; j++) {         if (i == j) continue;         vector<pair<int, int> > vec(m);         for (int z = 0; z < m; z++) {           vec[z] = {B[j][z] - A[i][z], C[i][z]};         }         sort(vec.rbegin(), vec.rend());         int rem = k;         int tempAns = 0;         for (int z = 0; z < m && rem && vec[z].first > 0; z++) {           tempAns += vec[z].first * min(vec[z].second, rem);           rem -= min(rem, vec[z].second);         }         ans = max(ans, tempAns);       }     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long PM(long long a, long long b) { return ((a % b) + b) % b; }   void solve() {     int n;     cin >> n;     string a;     cin >> a;     long long sum = 0;     long long ans = 0;     map<long long, long long> m;     m[0] = 1;     for (int i = 0; i < n; i++) {       sum += a[i] -  0 ;       ans += m[sum - i - 1];       m[sum - i - 1]++;     }     cout << ans << endl;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int t;     cin >> t;     while (t--) {       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   const int tinf = (int)1e9 + 7;   const long long inf = (long long)1e18 + 7;   const int N = 1e3 + 5;   int main() {     {       ios::sync_with_stdio(false);       cin.tie(0);       cout.tie(0);     }     long long n, k;     cin >> n >> k;     long long a[n], Min = inf, Max = -inf;     for (int i = 0; i < n; i++)       cin >> a[i], Min = min(Min, a[i]), Max = max(Max, a[i]);     if (k == 1)       cout << Min;     else if (k == 2)       cout << max(a[0], a[n - 1]);     else if (k >= 3)       cout << Max;     else       cout << Min;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   const ll inf = 1000000001, INF = (ll)1e18 + 1;   const int maxn = 1e6;   int n, m;   vector<int> a, b;   pair<ll, ll> fact[maxn];   ll power(ll a, ll b) {     ll result = 1;     while (b) {       if (b % 2) result = (result * a) % m;       a = (a * a) % m;       b /= 2;     }     return result;   }   void precalc() {     fact[0].first = 1;     fact[0].second = 0;     for (int i = 1; i < maxn; i++) {       int d = i;       fact[i].second = fact[i - 1].second;       while (d % 2 == 0) {         fact[i].second++;         d /= 2;       }       (fact[i].first = fact[i - 1].first * d) %= m;     }   }   void solve() {     map<int, int> u;     for (int i = 0; i < n; i++) {       u[a[i]]++;       u[b[i]]++;     }     ll ans = 1, cntws = 0;     for (auto i : u) {       (ans *= fact[i.second].first) %= m;       cntws += fact[i.second].second;     }     for (int i = 0; i < n; i++)       if (a[i] == b[i]) cntws--;     (ans *= power(2, cntws)) %= m;     cout << ans << endl;   }   int main() {     ios_base::sync_with_stdio(false);     cin >> n;     a.resize(n), b.resize(n);     for (int i = 0; i < n; i++) cin >> a[i];     for (int i = 0; i < n; i++) cin >> b[i];     cin >> m;     precalc();     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long l1, r1, l2, r2, k;     cin >> l1 >> r1 >> l2 >> r2 >> k;     l1 = max(l1, l2);     r1 = min(r1, r2);     if ((l1 <= k) && (r1 >= k))       cout << r1 - l1;     else       cout << max((long long)0, r1 - l1 + 1);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int x[100100], y[100100], id[100100];   bool cmp(int i, int j) {     if (y[i] >= 0 && y[j] < 0)       return true;     else if (y[i] < 0 && y[j] >= 0)       return false;     if (y[i] == 0 && y[j] == 0) {       return x[j] < 0;     }     return x[i] * y[j] >= x[j] * y[i];   }   bool cmp_frac(long long ap, long long aq, long long bp, long long bq) {     if (ap >= 0 && bp < 0) return false;     if (ap < 0 && bp >= 0) return true;     if (ap < 0 && bp < 0) return cmp_frac(-bp, bq, -ap, aq);     long long as = ap / aq, ar = ap % aq, bs = bp / bq, br = bp % bq;     if (as < bs)       return true;     else if (as > bs)       return false;     if (br == 0)       return false;     else if (ar == 0)       return true;     return cmp_frac(bq, br, aq, ar);   }   int main() {     int n;     long long ap, aq, tp, tq;     int now = -1;     scanf( %d , &n);     for (int i = 0; i < n; i++) scanf( %d%d , &x[i], &y[i]), id[i] = i;     sort(id, id + n, cmp);     for (int i = 0; i < n; i++) {       int a = id[i], b = id[(i + 1) % n];       tp = x[a] * x[b] + y[a] * y[b];       if (tp > 0)         tp = tp * tp;       else         tp = -tp * tp;       tq = 1LL * (x[a] * x[a] + y[a] * y[a]) * (x[b] * x[b] + y[b] * y[b]);       if (now == -1 || cmp_frac(ap, aq, tp, tq)) {         ap = tp;         aq = tq;         now = i;       }     }     printf( %d %d n , id[now] + 1, id[(now + 1) % n] + 1);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string vow =  aeiou ;   int month[] = {-1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};   const int dxhorse[] = {-2, -2, -1, -1, 1, 1, 2, 2};   const int dyhorse[] = {1, -1, 2, -2, 2, -2, 1, -1};   const int dx[] = {-1, 0, 1, 0};   const int dy[] = {0, 1, 0, -1};   const long double pie = 3.1415926535897932384626;   const long long mod = 1e9 + 7;   void solve(int test_case) {     int n;     cin >> n;     vector<int> v(n);     for (int i = 0; i < n; i++) cin >> v[i];     vector<int> div;     for (int d = 1; d * d <= n; d++) {       if (n % d) continue;       ;       int d1 = n / d;       int d2 = d;       div.push_back(d1);       if (d1 != d2) div.push_back(d2);     }     int ans = 0;     for (auto i : v) ans += i;     for (auto d : div) {       int take = n / d;       if (take < 3) continue;       ;       for (int i = 0; i < d; i++) {         int s = 0;         for (int j = i; j < n; j += d) s += v[j];         ans = max(ans, s);       }     }     cout << ans;     cout <<   n ;     ;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int t = 1;     for (int i = 1; i <= t; i++) solve(i);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, p;     string A;     cin >> n >> p >> A;     int i = n - 1;     while (i >= 0 && i < n) {       A[i]++;       if (A[i] - 96 > p) {         A[i] = 96;         i--;         continue;       }       if (i > 0 && A[i] == A[i - 1]) continue;       if (i > 1 && A[i] == A[i - 2]) continue;       i++;     }     if (i < 0)       cout <<  NO n ;     else       cout << A <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long N = 1e3 + 5;   long long C[N][5], dif_fact[5];   void calc() {     for (long long i = 0; i < N; i++) {       for (long long j = 0; j <= min(i, 4LL); j++) {         if (j == 0 || j == i) {           C[i][j] = 1;         } else {           C[i][j] = C[i - 1][j - 1] + C[i - 1][j];         }       }     }     dif_fact[1] = 0;     dif_fact[2] = 1;     dif_fact[3] = 2;     dif_fact[4] = 9;   }   signed main() {     ios_base ::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     calc();     long long n, k;     cin >> n >> k;     long long ans = 1;     for (long long i = 2; i <= k; i++) {       long long curr = C[n][i] * dif_fact[i];       ans += curr;     }     cout << ans;   }
#include <bits/stdc++.h>   long long a[10000];   using namespace std;   int main() {     long long n, i, j, c;     cin >> n;     for (i = 1; i < n + 1; i++) cin >> a[i];     for (i = 1; i < n + 1; i++) {       for (j = i + 1; j < n + 1; j++) {         if (a[i] > a[j]) {           c = a[i];           a[i] = a[j];           a[j] = c;         }       }     }     i = 1;     while ((a[i] == 0) && (i < n + 1)) i++;     int rez = 0;     j = i;     while ((a[j] != a[j + 2]) && (j < n)) {       if (a[j] == a[j + 1]) rez++;       j++;     }     if (i == n + 1)       cout << rez;     else {       if (j == n)         cout << rez;       else         cout << -1;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   int a[200010];   int main() {     bool bo = 0;     int X, Y = -1, t, Mx = 0;     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       scanf( %d , &a[i]);       Mx = max(Mx, a[i]);     }     for (int i = 2; i <= n; i++) {       t = abs(a[i] - a[i - 1]);       if (t == 0) {         bo = 1;         break;       }       if (t == 1) continue;       if (Y == -1)         Y = t;       else {         if (t == Y)           continue;         else {           bo = 1;           break;         }       }     }     if (!bo && Y <= 1e9 && Y != -1) {       for (int i = 1; i < n; i++) {         if (a[i] % Y == 0 && a[i + 1] == a[i] + 1) {           bo = 1;           break;         }         if (a[i] % Y == 1 && a[i + 1] == a[i] - 1) {           bo = 1;           break;         }       }     }     if (Y == -1) Y = Mx;     if (bo || Y > 1e9)       printf( NO n );     else {       X = Mx / Y;       if (Mx % Y != 0) X++;       if (X > 1e9)         printf( NO n );       else {         printf( YES n );         printf( %d %d , X, Y);       }     }     return 0;   }
#include <bits/stdc++.h>   int a[18];   int sum(int i, int n) {     int j, s = 0;     for (j = i; j < n; j++) s = s + a[j];     return s;   }   void print(int n) {     int i;     printf( %d n , n);     for (i = 1; i <= n; i++) printf( %d  , i);   }   int main() {     int n, i, sum1 = 0, sum2 = 0;     scanf( %d , &n);     for (i = 0; i < n; i++) scanf( %d , &a[i]);     if (n == 1) {       printf( -1 );       return 0;     } else if (n == 2) {       if (a[0] == a[1])         printf( -1 );       else         printf( 1 n1 );       return 0;     } else {       for (i = 1; i < n; i++) {         sum2 = sum(0, i);         sum1 = sum(i, n);         if (sum1 != sum2) {           print(i);           return 0;         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double PI = 2.0 * acos(0.0);   const double EPS = 1e-6;   int main() {     char s[1005];     scanf( %s , s);     int n;     scanf( %d , &n);     int len = strlen(s);     int cnt[26] = {0};     for (int i = 0; i < len; i++) cnt[s[i] -  a ]++;     bool found = false;     for (int res = 1; res <= len; res++) {       int need = 0;       int res_cnt[26] = {0};       for (int k = 0; k < 26; k++)         need += res_cnt[k] = (int)ceil((double)cnt[k] / res);       if (need <= n) {         found = true;         printf( %d n , res);         for (int k = 0; k < 26; k++)           for (int j = 0; j < res_cnt[k]; j++) putchar(k +  a );         for (int i = 0; i < n - need; i++) putchar( z );         puts(  );         break;       }     }     if (!found) puts( -1 );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void solve();   int main(int argc, const char** argv) {     int t = 1;     cin >> t;     while (bool(t--)) {       solve();       cout <<   n ;     }   }   void solve() {     vector<int> v(3);     int s = 0;     for (int i = 0; i < 3; i++) {       cin >> v[i];       s += v[i];     }     sort(v.begin(), v.end());     if (v[1] == v[0]) {       if (v[2] % 2 != 0) {         cout <<  NO ;         return;       } else {         cout <<  YES ;         return;       }     }     if (v[2] != v[1]) {       if (s != 2 * v[2]) {         cout <<  NO ;         return;       } else {         cout <<  YES ;         return;       }     } else {       if (v[0] % 2 != 0) {         cout <<  NO ;         return;       } else {         cout <<  YES ;         return;       }     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 5 * 100 + 10;   int n, dp1[N][N], dp2[N][N], k, par[N][N];   string s;   void printpath(int i, int j) {     if (j == 0) return;     printpath(i - par[i][j], j - 1);     if (j > 1) cout <<  + ;     if (par[i][j] == 1)       cout << s[i - 1];     else {       for (int l = i - par[i][j]; l <= i - (((par[i][j] + 1) / 2) + 1); l++)         cout << s[l];       if (par[i][j] % 2 == 1) cout << s[i - (((par[i][j] + 1) / 2) + 1) + 1];       for (int l = i - (((par[i][j] + 1) / 2) + 1); l >= i - par[i][j]; l--)         cout << s[l];     }   }   int main() {     cin >> s >> k;     n = s.size();     for (int i = 0; i < n; i++)       for (int j = i + 1; j < n; j++)         for (int l = i; l <= ((j - i) / 2) + i; l++)           if (s[l] != s[j - l + i]) dp1[i][j]++;     for (int i = 0; i < N; i++) fill(dp2[i], dp2[i] + N, INT_MAX);     dp2[0][0] = 0;     for (int i = 0; i < n; i++)       for (int j = 0; j < k; j++)         for (int len = 1; len <= n; len++)           if (dp2[i][j] != INT_MAX)             if (dp2[i + len][j + 1] >= dp2[i][j] + dp1[i][i + len - 1])               dp2[i + len][j + 1] = dp2[i][j] + dp1[i][i + len - 1],                                par[i + len][j + 1] = len;     int ans = INT_MAX, r;     for (int i = 1; i <= k; i++)       if (dp2[n][i] < ans) ans = dp2[n][i], r = i;     cout << ans << endl;     printpath(n, r);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline long long R() {     char c;     long long res, sign = 1;     while ((c = getchar()) >  9  || c <  0 )       if (c ==  - ) sign = -1;     res = c -  0 ;     while ((c = getchar()) >=  0  && c <=  9 ) res = res * 10 + c -  0 ;     return res * sign;   }   priority_queue<long long> q;   const long long N = 210000;   long long a[N], n, m, pre[N], cnt;   signed main() {     n = R();     m = R();     for (long long i = 1; i <= n; i++) a[i] = R();     for (long long i = n; i >= 1; i--) {       if (a[i] < 0)         q.push(a[i]);       else {         while (!q.empty() && a[i] >= 0) a[i] += q.top(), q.pop();         if (a[i] < 0) q.push(a[i]);       }     }     while (!q.empty()) pre[++cnt] = q.top(), q.pop();     for (long long i = 1; i <= cnt; i++) pre[i] = -pre[i] + pre[i - 1];     while (m--)       printf( %lld n ,              (cnt - (upper_bound(pre + 1, pre + 1 + cnt, R()) - pre) + 1));   }
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:256000000 )   using namespace std;   const int INF = (int)(1e9 + 1337);   const long long LINF = (long long)(2e18);   const double EPS = 1e-11;   const int MAXN = 200100;   string a;   void solve() {     cin >> a;     a +=  # ;     int cur = 0;     int sz = 0;     long long sum = 0;     for (int i = 0; i < a.size(); ++i) {       if (a[i] >=  0  && a[i] <=  9 ) {         cur *= 10;         cur += a[i] -  0 ;         sz++;       } else if (a[i] ==  . ) {         sz = 0;       } else {         if (sz != 2) cur *= 100;         sum += cur;         cur = 0;         sz = 0;       }     }     int kop = sum % 100;     sum /= 100;     string ans;     if (sum == 0) ans =  0 ;     int pr = 0;     while (sum) {       pr++;       ans += (sum % 10) +  0 ;       sum /= 10;       if (sum && pr % 3 == 0) ans +=  . ;     }     reverse(ans.begin(), ans.end());     cout << ans;     if (kop) {       if (kop >= 10)         cout <<  .  << kop;       else         cout <<  .0  << kop;     }   }   int main() {     srand(1337);     int ts = 1;     for (int i = 0; i < ts; ++i) solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 3002;   int n, m, a, b;   long long G[N][N], x, y, z, g[N * N], r[N][N], ans;   deque<int> q;   void init() {     for (int i = 1; i <= (n - 1) * m + m - 1; i++) {       g[i] = (g[i - 1] * x % z + y) % z;     }     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= m; j++) {         G[i][j] = g[(i - 1) * m + j - 1];       }     }   }   void cal1() {     for (int i = 1; i <= n; i++) {       while (!q.empty()) q.pop_back();       for (int j = 1; j <= m + 1; j++) {         if (j >= b + 1) {           while (!q.empty() && q.front() < j - b) q.pop_front();           r[i][j - b] = G[i][q.front()];         }         while (!q.empty() && G[i][q.back()] > G[i][j]) q.pop_back();         q.push_back(j);       }     }   }   void cal2() {     for (int j = 1; j <= m; j++) {       while (!q.empty()) q.pop_back();       for (int i = 1; i <= n + 1; i++) {         if (i >= a + 1) {           while (!q.empty() && q.front() < i - a) q.pop_front();           ans += r[q.front()][j];         }         while (!q.empty() && r[q.back()][j] > r[i][j]) q.pop_back();         q.push_back(i);       }     }   }   int main() {     scanf( %d %d %d %d %lld %lld %lld %lld , &n, &m, &a, &b, &g[0], &x, &y, &z);     init();     cal1();     cal2();     printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, t, o, s;   char A[1000005], B[1000005];   int main() {     scanf( %s , A);     scanf( %s , B);     n = strlen(A);     m = strlen(B);     for (int i = 0; i < m - 1; i++) t ^= (B[i] != B[i + 1]);     for (int i = 0; i < m; i++) o ^= (B[i] ^ A[i]);     if (o % 2 == 0) s++;     for (int i = 1; i <= n - m; i++) {       o ^= (A[i - 1] ^ B[0]);       o ^= (A[i + m - 1] ^ B[m - 1]);       o ^= t;       if (o % 2 == 0) s++;     }     cout << s << endl;   }
#include <bits/stdc++.h>   int main() {     long long a, b, c;     while (~scanf( %I64d%I64d%I64d , &a, &b, &c)) {       if (c == 0) {         if (a == b)           printf( YES n );         else           printf( NO n );       } else {         long long d = (b - a) / c;         long long h = (b - a) % c;         if (d >= 0 && !h)           printf( YES n );         else {           printf( NO n );         }       }     }   }
#include <bits/stdc++.h>   #pragma GCC optimize( O3 )   using namespace std;   int n, k;   double h;   struct lms {     int i, m, v;   } a[100005];   int pos[100005];   inline int put(double t) {     int ptr = 1;     for (int i = 0; i < n; ++i) {       if ((double)ptr <= t * a[i].v) {         pos[ptr] = a[i].i;         ++ptr;       }     }     return ptr - 1;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cin >> n >> k >> h;     for (int i = 0; i < n; ++i) a[i].i = i + 1;     for (int i = 0; i < n; ++i) cin >> a[i].m;     for (int i = 0; i < n; ++i) cin >> a[i].v;     sort(a, a + n, [](const lms &a, const lms &b) {       return a.m == b.m ? a.v < b.v : a.m < b.m;     });     double L = 0, R = 1e9, A = R;     int t = 90;     while (t--) {       double M = (L + R) / 2;       if (put(M) >= k)         R = A = M;       else         L = M;     }     put(A);     for (int i = 1; i <= k; ++i) cout << pos[i] <<    ;     cout << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX_N = 1e5 + 9;   int a[MAX_N];   void mergesort(int l, int r, int &k, int &remain) {     if (k > 0 && r - l > 1) {       k -= 2;       int m = (l + r) / 2;       mergesort(l, m, k, remain);       mergesort(m, r, k, remain);     } else {       int c = r - l;       for (int i = 0; i < c; i++) {         a[l + i] = remain - c + i + 1;       }       remain -= c;     }   }   int main() {     int n, k;     cin >> n >> k;     if (k % 2 == 0 || k > 2 * n - 1) {       return !printf( -1 );     }     int remain = n;     k -= 1;     mergesort(0, n, k, remain);     for (int i = 0; i < n; i++) {       printf( %d  , a[i]);     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string n;     cin >> n;     string m;     cin >> m;     sort(m.begin(), m.end());     int cn = 0;     int cm = 0;     int res = 0;     for (int i = 0; i < m.length(); i += cm) {       cm = count(m.begin(), m.end(), m[i]);       cn = count(n.begin(), n.end(), m[i]);       if (cn == 0) {         cout << -1;         return 0;       } else if (cn >= cm)         res += cm;       else         res += cn;     }     cout << res;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int N;     cin >> N;     int A[200010];     int fri[100010];     for (int i = 0; i < N; i++) {       int p, q;       cin >> p >> q;       fri[i] = p;       A[p] = q;       A[q] = p;     }     int res[200010] = {};     for (int i = 1; i <= 2 * N; i++) {       if (res[i] == 0) {         int tmp = 1;         int now = A[i];         res[i] = tmp;         tmp = 2;         while (now != i) {           if (res[A[now]] == 0) {             res[now] = tmp;             now = A[now];             if (tmp == 1) {               tmp = 2;             } else {               tmp = 1;             }           } else {             res[now] = tmp;             if (now % 2 == 1) {               now++;             } else {               now--;             }             if (tmp == 1) {               tmp = 2;             } else {               tmp = 1;             }           }         }       }     }     for (int i = 0; i < N; i++) {       if (res[fri[i]] == 1) {         cout <<  1 2  << endl;       } else {         cout <<  2 1  << endl;       }     }     return 0;   }