malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int n, first, a[1111];   int b[1111], ub = -1, pos;   vector<int> c[1111];   vector<int> d;   int can[1111];   void go(int p, int v) {     if (v == -1) return;     if (v == first) ub = p;     c[p].push_back(v);     go(p, a[v]);   }   int main() {     scanf( %d%d , &n, &first);     --first;     for (int i = 0; i < n; ++i) b[i] = -1;     for (int i = 0; i < n; ++i) {       scanf( %d , a + i);       a[i]--;       b[a[i]] = i;     }     for (int i = 0; i < n; ++i) {       c[i].clear();       if (b[i] == -1) {         go(i, i);       }     }     assert(ub >= 0);     d.clear();     for (int i = 0; i < c[ub].size(); ++i) {       if (c[ub][i] == first) pos = c[ub].size() - i;     }     for (int i = 0; i < n; ++i) {       if (i == ub) continue;       if (c[i].size() != 0) d.push_back(c[i].size());     }     sort(d.begin(), d.end());     for (int i = 0; i < n; ++i) can[i] = 0;     can[0] = 1;     for (int i = 0; i < d.size(); ++i) {       for (int j = n - 1; j >= 0; --j) {         if ((j + d[i] < n) && (can[j] == 1)) can[j + d[i]] = 1;       }     }     for (int i = 0; i < n; ++i) {       if (can[i]) cout << i + pos << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, i, maxi = 0;     cin >> n;     if (n == 1) {       cout <<  1  << endl;       return 0;     }     vector<int> a(n, 0);     vector<int> right(n, 0);     vector<int> left(n, 0);     vector<int> ans(n, 0);     for (i = 0; i < n; i++) scanf(  %d , &a[i]);     for (i = 1; i < n; i++)       if (a[i] > a[i - 1]) left[i] += left[i - 1] + 1;     for (i = n - 2; i >= 0; i--)       if (a[i] < a[i + 1]) right[i] += right[i + 1] + 1;     for (i = 1; i < n - 1; i++) {       if (a[i - 1] < a[i] && a[i] < a[i + 1])         ans[i] = left[i] + right[i] + 1;       else if (a[i + 1] > a[i - 1] + 1)         ans[i] = left[i - 1] + right[i + 1] + 3;       else         ans[i] = max(left[i - 1], right[i + 1]) + 2;     }     ans[0] = (a[0] < a[1]) ? right[0] + 1 : right[1] + 2;     ans[n - 1] = (a[n - 1] > a[n - 2]) ? left[n - 1] + 1 : left[n - 2] + 2;     for (i = 0; i < n; i++)       if (ans[i] > maxi) maxi = ans[i];     cout << maxi << endl;   }
#include <bits/stdc++.h>   using namespace std;   int n, sum, as, b[100005], len, ia, la;   pair<int, int> a[100005];   int main() {     cin >> n;     for (int i = 0; i < n; ++i) {       cin >> a[i].first;       a[i].second = i + 1;       sum += a[i].first;     }     sort(a, a + n);     la = n / 2;     for (int i = 0; i < n / 2; ++i) as += a[i].first;     for (int d = (sum - a[n - 1].first + 1) / 2; as < d;          as -= a[ia++].first, as += a[la++].first)       ;     cout << la - ia << endl;     for (int i = 0; i < n; ++i) {       if (i < ia || i >= la)         b[len++] = a[i].second;       else {         if (i - ia) cout <<    ;         cout << a[i].second;       }     }     cout << endl;     cout << len << endl;     for (int i = 0; i < len; ++i) {       if (i) cout <<    ;       cout << b[i];     }     cout << endl;     return 0;   }
#include <bits/stdc++.h>   const double PI = acos(-1);   int N;   long long A;   struct point {     long long x, y;   } p[100001];   struct line {     double start, end;   } q[100001];   inline long long sqr(long long x) { return x * x; }   inline double tan_360(double x, double y) {     if (x == 0) return PI * (y > 0 ? 0.5 : 1.5);     if (y == 0) return PI * (x > 0 ? 0.0 : 1.0);     double ans = atan(y / x);     if (x > 0 && y > 0) return ans;     if (x < 0 && y > 0) return ans + PI;     if (x < 0 && y < 0) return ans + PI;     return ans + PI * 2;   }   bool check(double mid) {     int L = 0;     for (int i = 1; i <= N; i++)       if (sqrt(sqr(A + p[i].x) + sqr(p[i].y)) <=           mid - sqrt(sqr(A - p[i].x) + sqr(p[i].y)))         return true;     for (int i = 1; i <= N; i++) {       double R1 = mid, R2 = sqrt(sqr(A - p[i].x) + sqr(p[i].y)),              dis = sqrt(sqr(A + p[i].x) + sqr(p[i].y));       if (R1 + R2 > dis && R1 + dis > R2 && R2 + dis > R1) {         double mid_angle = tan_360(p[i].x + A, p[i].y),                dif = acos((R1 * R1 + dis * dis - R2 * R2) / (2 * R1 * dis));         q[++L] = {mid_angle < dif ? mid_angle - dif + 2 * PI : mid_angle - dif,                   mid_angle + dif >= 2 * PI ? mid_angle + dif - 2 * PI                                             : mid_angle + dif};         if (q[L].start > q[L].end) std::swap(q[L].start, q[L].end);       }     }     std::sort(q + 1, q + L + 1, [](const line &a, const line &b) {       return a.start < b.start || a.start == b.start && a.end < b.end;     });     static int stack[100001];     int D = 0;     for (int i = 1; i <= L; i++) {       while (D && q[stack[D]].end < q[i].start) D--;       if (D && q[stack[D]].end < q[i].end) return true;       stack[++D] = i;     }     return false;   }   int main() {     scanf( %d%lld , &N, &A);     for (int i = 1; i <= N; i++) scanf( %lld%lld , &p[i].x, &p[i].y);     double l = 0, r = A * 2;     for (int T = 55; T--;) {       double mid = (l + r) / 2;       (check(mid) ? r : l) = mid;     }     printf( %.10lf n , l);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int M = 1000100;   struct node {     int w, flag;     int a, b;     int id;     long long num;   } a[M];   int n, pos[M], m, s[M];   bool cmp(const node &x, const node &y) {     if (x.w == y.w) return x.flag > y.flag;     return x.w < y.w;   }   int fa[M];   bool cmp1(const node &x, const node &y) { return x.id < y.id; }   int main() {     scanf( %d%d , &n, &m);     for (int i = 1; i <= m; i++) {       scanf( %d%d , &a[i].w, &a[i].flag);       a[i].id = i;     }     sort(a + 1, a + 1 + m, cmp);     for (int i = 1; i <= n; i++) fa[i] = i;     int k = 1;     for (int i = 1; i <= m; i++)       if (a[i].flag) {         a[i].a = k;         pos[k] = i;         a[i].num = (long long)(k - 1) * k / 2 + 1;         a[i].b = ++k;       }     bool flag = 0;     for (int i = 1; i <= m; i++)       if (a[i].flag)         if (a[i].num < (long long)i) {           flag = 1;           break;         }     if (flag) {       printf( -1 n );       return 0;     }     pos[n] = m + 1;     int h = 3, s1 = 1;     for (int i = 1; i < n; i++) {       for (int j = pos[i] + 1; j < pos[i + 1];) {         a[j].a = s1;         a[j].b = h;         s1++;         if (s1 == h - 1) {           s1 = 1;           h++;         }         j++;       }     }     if (flag) {       printf( -1 n );       return 0;     }     sort(a + 1, a + 1 + m, cmp1);     for (int i = 1; i <= m; i++) printf( %d %d n , a[i].a, a[i].b);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 605;   int nask(vector<int> tmp) {     if (!tmp.size() || tmp.size() == 1) return 0;     cout <<  ?   << tmp.size() << endl;     for (int i = (0), iend = ((int)tmp.size() - 1); i <= iend; i++)       cout << tmp[i] <<    ;     cout << endl;     cout.flush();     int ans;     cin >> ans;     if (ans == -1) exit(0);     return ans;   }   int dask(int u, vector<int> tar) {     int cntsig = nask(tar);     tar.push_back(u);     int cnttot = nask(tar);     return cnttot - cntsig;   }   int n;   bool vis[maxn];   int bl[maxn];   int find(int u, vector<int> tmp) {     vector<int> c1, c2;     if (tmp.size() == 1) return tmp[0];     for (int i = (0), iend = ((int)(tmp.size()) - 1); i <= iend; i++) {       if (c1.size() < tmp.size() / 2)         c1.push_back(tmp[i]);       else         c2.push_back(tmp[i]);     }     if (dask(u, c1))       return find(u, c1);     else       return find(u, c2);   }   vector<int> half[2];   vector<int> side[maxn];   void dfs(int u) {     half[bl[u]].push_back(u);     while (1) {       vector<int> tmp;       for (int i = (1), iend = (n); i <= iend; i++)         if (!vis[i]) tmp.push_back(i);       if (dask(u, tmp) == 0) return;       int tar = find(u, tmp);       side[u].push_back(tar);       side[tar].push_back(u);       vis[tar] = 1;       bl[tar] = bl[u] ^ 1;       dfs(tar);     }   }   int stk[maxn], top;   vector<int> ans;   void cfs(int u, int tar) {     stk[++top] = u;     if (u == tar) {       for (int i = (1), iend = (top); i <= iend; i++) ans.push_back(stk[i]);       return;     }     for (int i = (0), iend = (side[u].size() - 1); i <= iend; i++) {       int v = side[u][i];       if (!vis[v]) {         vis[v] = 1;         cfs(v, tar);       }     }     top--;   }   void ans_out(int u, int v) {     memset(vis, 0, sizeof(vis));     vis[u] = 1;     cfs(u, v);     cout <<  N   << ans.size() << endl;     for (int i = (0), iend = ((int)(ans.size()) - 1); i <= iend; i++)       cout << ans[i] <<    ;     return;   }   int main() {     ios::sync_with_stdio(0);     cin >> n;     vis[1] = 1;     dfs(1);     if (!nask(half[0]) && !nask(half[1])) {       cout <<  Y   << half[0].size() << endl;       for (int i = (0), iend = ((int)(half[0].size()) - 1); i <= iend; i++)         cout << half[0][i] <<    ;       return 0;     } else {       for (int i = (0), iend = (1); i <= iend; i++)         for (int j = (0), jend = ((int)(half[i].size()) - 1); j <= jend; j++) {           vector<int> tmp;           int u = half[i][j];           for (int k = (0), kend = ((int)(half[i].size()) - 1); k <= kend; k++)             if (half[i][k] != u) tmp.push_back(half[i][k]);           if (dask(u, tmp)) {             for (int k = (0), kend = ((int)(tmp.size()) - 1); k <= kend; k++) {               vector<int> gg;               gg.push_back(u);               gg.push_back(tmp[k]);               if (nask(gg)) {                 ans_out(u, tmp[k]);                 return 0;               }             }           }         }     }   }
#include <bits/stdc++.h>   using namespace std;   int n;   int a[200010];   int prv[200010];   int f[200010][10];   void FillAll(int l, int r, int x, int y) {     for (int i = x, j = l; i <= y; i++) {       int ci = (r - j + 1) / (y - i + 1);       ci = max(ci, 2);       ci = min(ci, 5);       for (int jj = j; jj < j + ci; jj++) a[jj] = i;       j += ci;     }   }   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       scanf( %d , a + i);     }     for (int i = 1; i <= n; i++) prv[i] = a[i - 1] ? i - 1 : prv[i - 1];     memset(f, -1, sizeof f);     f[0][5] = 0;     int last = 0;     for (int i = 1; i <= n; i++)       if (a[i]) {         last = i;         int j = prv[i];         int space = i - j - 1;         if (a[i] > a[j]) {           for (int ki = 0; ki < min(5, space + 1); ki++)             for (int kj1 = 1; kj1 <= 5 && f[i][ki + 1] == -1; kj1++)               if (f[j][kj1] >= 0) {                 for (int kj2 = max(0, 2 - kj1); kj2 <= min(space - ki, 5 - kj1);                      kj2++) {                   int least = kj2 + 2 * (a[i] - a[j] - 1) + ki;                   int most = kj2 + 5 * (a[i] - a[j] - 1) + ki;                   if (least <= space && space <= most) {                     f[i][ki + 1] = kj2;                     break;                   }                 }               }         }         if (a[i] == a[j]) {           int ki = space + 1;           for (int kj = 1; kj <= 5 - ki; kj++)             if (f[j][kj] >= 0) f[i][ki + kj] = 0;         }         if (a[i] < a[j]) {           printf( -1 );           return 0;         }       }     if (last) {       int had = last == n - 1;       for (int i = last; i; i = prv[i]) {         int j = prv[i];         if (a[i] != a[j]) {           int lbound = max(1, 2 - had);           int rbound = 5 - had;           if (i == last) {             lbound = 1 + (last == n);             rbound = 5 - (last == n - 1);           }           bool isRet = 0;           for (int ki = rbound; ki >= lbound; ki--)             if (f[i][ki] >= 0) {               for (int k = i - ki + 1; k <= i; k++) a[k] = a[i];               for (int k = j + 1; k <= j + f[i][ki]; k++) a[k] = a[j];               FillAll(j + f[i][ki] + 1, i - ki, a[j] + 1, a[i] - 1);               had = f[i][ki];               isRet = 1;               break;             }           if (!isRet) {             printf( -1 );             return 0;           }         } else {           for (int k = j + 1; k < i; k++) a[k] = a[i];           had += i - j;         }       }       if (a[last] != a[last - 1]) {         a[last + 1] = a[last];         last++;       }       if (last > n) {         printf( -1 );         return 0;       }     }     for (int i = last + 1; i <= n; i++)       if (i == 1 || a[i - 1] == a[i - 2])         a[i] = a[i - 1] + 1;       else         a[i] = a[i - 1];     if (a[n] != a[n - 1]) a[n] = a[n - 1];     printf( %d n , a[n]);     for (int i = 1; i <= n; i++) printf( %d  , a[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long mod = 998244353;   const int N = 1e6 + 5;   long long p[N];   long long cnt[N];   vector<long long> a[N];   long long qmi(long long a, long long b) {     long long ans = 1;     while (b) {       if (b & 1) ans = ans * a % mod;       b >>= 1;       a = a * a % mod;     }     return ans % mod;   }   int main() {     long long n, k, z;     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> k;       for (int j = 1; j <= k; j++) {         cin >> z;         a[i].push_back(z);         cnt[z]++;       }     }     long long ans = 0;     for (int i = 1; i <= n; i++) {       long long m = a[i].size();       long long temp = 0;       for (int j = 0; j < m; j++) {         temp += cnt[a[i][j]];       }       long long cur = qmi((long long)n * n * m % mod, mod - 2) * temp % mod;       ans = (cur + ans) % mod;       ans %= mod;     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int Iinf = 1e9;   const long long LLinf = 1e18;   const double eps = 1e-6;   const long long mod = 1e9 + 7;   int32_t main() {     ios_base::sync_with_stdio(0);     cin.tie();     cout.tie();     int s, x1, x2;     cin >> s >> x1 >> x2;     int t1, t2;     cin >> t1 >> t2;     int p, d;     cin >> p >> d;     if (d > 0) {       if (x1 > x2) {         cout << min(t1 * (s * 2 - p - x1 + abs(x1 - x2)), t2 * abs(x1 - x2));       } else if (p > x2) {         cout << min(t1 * (s * 2 - p + x1 + abs(x1 - x2)), t2 * abs(x1 - x2));       } else if (p <= x1) {         cout << min(t1 * (x1 - p + abs(x1 - x2)), t2 * abs(x1 - x2));       } else if (p > x1) {         cout << min(t1 * (s * 2 - p + x1 + abs(x1 - x2)), t2 * abs(x1 - x2));       }     } else {       if (x1 > x2) {         if (p >= x1) {           cout << min(t1 * (p - x1 + abs(x1 - x2)), t2 * (x1 - x2));         } else {           cout << min(t1 * (p + s + s - x1 + abs(x1 - x2)), t2 * abs(x1 - x2));         }       } else {         cout << min(t1 * (p + x1 + abs(x1 - x2)), t2 * abs(x1 - x2));       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int n = 1 << 17;   double sum[n * 2], lazy_mul[n * 2], lazy_add[n * 2];   void push(int i, int l, int r) {     if (lazy_mul[i] != 1 || lazy_add[i] != 0) {       sum[i] = sum[i] * lazy_mul[i] + lazy_add[i] * (r - l);       if (i < n) {         for (int j : {i * 2, i * 2 + 1}) {           lazy_mul[j] *= lazy_mul[i];           lazy_add[j] *= lazy_mul[i];           lazy_add[j] += lazy_add[i];         }       }       lazy_mul[i] = 1;       lazy_add[i] = 0;     }   }   void fma(double mul, double add, int a, int b, int l = 0, int r = n,            int i = 1) {     push(i, l, r);     if (a >= r || b <= l) return;     if (a <= l && b >= r) {       lazy_mul[i] = mul;       lazy_add[i] = add;       push(i, l, r);       return;     }     int m = l + r >> 1;     fma(mul, add, a, b, l, m, i * 2);     fma(mul, add, a, b, m, r, i * 2 + 1);     sum[i] = sum[i * 2] + sum[i * 2 + 1];   }   double querySum(int a, int b, int l = 0, int r = n, int i = 1) {     push(i, l, r);     if (a >= r || b <= l) return 0;     if (a <= l && b >= r) {       return sum[i];     }     int m = l + r >> 1;     return querySum(a, b, l, m, i * 2) + querySum(a, b, m, r, i * 2 + 1);   }   int main() {     fill_n(lazy_mul, n * 2, 1.);     ios::sync_with_stdio(0);     cin.tie(0);     int n, q;     cin >> n >> q;     for (int i = 0; i < n; i++) {       int a;       cin >> a;       fma(1, a, i, i + 1);     }     while (q--) {       int type;       cin >> type;       if (type == 1) {         int l1, r1, l2, r2;         cin >> l1 >> r1 >> l2 >> r2;         l1--, l2--;         double e1 = querySum(l1, r1) / (r1 - l1);         double e2 = querySum(l2, r2) / (r2 - l2);         double p1 = 1. / (r1 - l1);         fma(1 - p1, p1 * e2, l1, r1);         double p2 = 1. / (r2 - l2);         fma(1 - p2, p2 * e1, l2, r2);       } else {         int l, r;         cin >> l >> r;         l--;         cout << setprecision(20) << querySum(l, r) <<   n ;       }     }   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     int n, m;     cin >> n >> m;     int arr[n];     int a = 0, b = 0;     for (int i = 0; i < n; i++) {       cin >> arr[i];       if (arr[i] == 1)         a++;       else         b++;     }     vector<pair<int, int>> v(m);     for (int i = 0; i < m; i++) cin >> v[i].first >> v[i].second;     for (int i = 0; i < m; i++) {       if ((v[i].second - v[i].first + 1) % 2 == 1)         cout <<  0  << endl;       else {         int c = v[i].second - v[i].first + 1;         int d = c / 2;         if (d <= a && d <= b)           cout <<  1  << endl;         else           cout <<  0  << endl;       }     }   }   int main() {     ios_base::sync_with_stdio(NULL);     cin.tie(NULL);     cout.tie(NULL);     int t;     t = 1;     while (t--) {       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   int n, m, x, y, f[300010], a[300010][4];   void dfs(int x) {     int cnt = 0;     for (int i = 1; i <= a[x][0]; i++) cnt += f[x] == f[a[x][i]];     if (cnt > 1) {       f[x] ^= 1;       for (int i = 1; i <= a[x][0]; i++)         if (f[x] == f[a[x][i]]) dfs(a[x][i]);     }   }   int main() {     cin >> n >> m;     while (m--) {       cin >> x >> y;       a[x][++a[x][0]] = y;       a[y][++a[y][0]] = x;     }     for (int i = 1; i <= n; i++) dfs(i);     for (int i = 1; i <= n; i++) cout << f[i];   }
#include <bits/stdc++.h>   using namespace std;   string str;   int main() {     cin >> str;     bool chk = false;     for (int i = 0; i <= str.length(); i++) {       for (char ch =  a ; ch <=  z ; ch++) {         string temp1 = str.substr(0, i) + ch + str.substr(i);         string temp2 = temp1;         reverse(temp2.begin(), temp2.end());         if (temp1.compare(temp2) == 0) {           cout << temp1 << endl;           chk = true;           break;         }       }       if (chk == true) {         break;       }     }     if (chk == false) {       cout <<  NA n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 100010;   const int M = 55;   const int K = 200010;   const int LIT = 2500;   const int INF = 1 << 30;   const int dir[6][2] = {{2, 0}, {-2, 0}, {1, 1}, {-1, 1}, {1, -1}, {-1, -1}};   bool check(long long x, long long y, long long n) {     long long dist = x * x + 3 * y * y;     long long cmp = 4 * n * n;     return dist <= cmp;   }   bool inside(long long x, long long y, long long n) {     for (int j = 0; j < 6; j++) {       long long xx = x + dir[j][0];       long long yy = y + dir[j][1];       if (!check(xx, yy, n)) return 0;     }     return 1;   }   void solve(int n) {     long long x = 0, y = 0;     long long res = 1;     while (1) {       y += 2;       if (!inside(x, y, n)) break;       res += 2;     }     while (y >= 0) {       x += 3, y++;       while (y >= 0) {         if (inside(x, y, n)) {           res += (y + 1) * 2;           break;         }         y -= 2;       }     }     cout << res << endl;   }   int main() {     int n;     while (cin >> n) {       solve(n);     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 100100;   long long n, x;   void printbin(long long a) {     for (int i = 20; i >= 0; i--) {       long long c = a & (1LL << i);       cout << bool(c);     }     cout <<   n ;   }   int main() {     cin >> n >> x;     long long reversed = 0;     reversed |= 1LL << 17;     if (n == 1) {       cout <<  YES n  << x;       return 0;     }     if (n == 2 && x == 0) {       cout <<  NO n ;       return 0;     }     if (n == 2) {       cout <<  YES n  << 0 <<     << x <<   n ;       return 0;     }     cout <<  YES n ;     long long value = 0;     long long test = 0;     for (int i = 1; i <= n - 3; i++) {       cout << i <<    ;       value ^= i;       test ^= i;     }     reversed = x ^ value;     reversed |= 1LL << 17;     long long temp2 = 1LL << 17;     if (reversed == 1LL << 17) {       reversed |= 1LL << 18;       long long temp = 1LL << 18;       cout << reversed <<     << temp <<     << (temp ^ reversed) <<   n ;     } else {       cout << reversed <<     << temp2 <<     << 0 <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 5e2 + 5;   const int mod = 1e9 + 7;   const long long inf = 1e18;   int n, ans, pos, pos1;   int un[N], un1[N], cl[N], cl1[N], tr;   string t, s;   int calc(string e) {     un[0] = cl[0] = 0, tr = 0;     for (int i = 0; i < n; i++) {       if (i) un[i] = un[i - 1], cl[i] = cl[i - 1];       if (e[i] ==  ( )         un[i]++;       else {         if (un[i])           un[i]--;         else           cl[i]++;       }     }     if (cl[n - 1] == 0 and un[n - 1] == 0) tr = 1;     un1[0] = cl1[0] = 0;     for (int i = n - 1; i >= 0; i--) {       un1[i] = un1[i + 1], cl1[i] = cl1[i + 1];       if (e[i] ==  ) )         un1[i]++;       else {         if (un1[i])           un1[i]--;         else           cl1[i]++;       }     }     int jog = 0;     for (int i = n - 1; i >= 1; i--)       if (un[i - 1] == 0 and un1[i] == 0 and cl[i - 1] == cl1[i]) jog++;     return jog + tr;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(nullptr);     cin >> n >> s;     ans = calc(s);     for (int i = 0; i < n; i++) {       for (int j = i + 1; j < n; j++) {         t = s;         swap(t[i], t[j]);         if (ans < calc(t)) {           ans = calc(t);           pos = i, pos1 = j;         }       }     }     cout << ans <<   n  << pos + 1 <<     << pos1 + 1;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXS = 100000;   inline long long get(long long n, long long ma, long long b) {     return max(ma, (6 * n + b - 1) / b) * b;   }   int main() {     long long n, a, b;     cin >> n >> a >> b;     if (a * b >= 6 * n) {       cout << a * b << endl;       cout << a <<     << b << endl;     } else {       long long best = b;       for (int i = b; i <= MAXS; i++)         if (get(n, a, best) > get(n, a, i)) best = i;       long long best2 = a;       for (int i = a; i <= MAXS; i++)         if (get(n, b, best2) > get(n, b, i)) best2 = i;       if (get(n, a, best) < get(n, b, best2)) {         a = max(a, (6 * n + best - 1) / best);         b = best;       } else {         a = best2;         b = max(b, (6 * n + best2 - 1) / best2);       }       cout << a * b << endl;       cout << a <<     << b << endl;     }   }
#include <bits/stdc++.h>   const int MAXN = 100;   int R[2 * MAXN + 2];   int main() {     int n, k, i;     scanf( %d%d , &n, &k);     for (i = 1; i <= 2 * n + 1; ++i) scanf( %d , R + i);     for (i = 2; i <= 2 * n && k; ++i)       if (R[i - 1] < R[i] - 1 && R[i] - 1 > R[i + 1]) {         --R[i];         --k;       }     for (i = 1; i <= 2 * n + 1; ++i) printf( %d  , R[i]);     putchar(  n );     return 0;   }