malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 10;   int n, m, a[N], p, q[5], nq[5];   long long f[N][10];   char s[N];   int main() {     scanf( %d%d%s , &n, &m, s + 1);     for (int i = 1; i <= n; i++) a[i] = s[i] -  a  + 1;     for (int i = 1; i <= m; i++) {       p = 1;       if (i == a[1]) p |= 2;       if (i == a[1] || i == a[2]) p |= 4;       ++f[1][p];     }     for (int i = 1; i <= n - 1; i++) {       for (int j = 0; j <= 7; j++) {         if (f[i][j]) {           q[0] = i - 2 + (j & 1);           q[1] = i - 1 + (j >> 1 & 1);           q[2] = i - 1 + (j >> 2 & 1);           for (int k = 1; k <= m; k++) {             int p = 0;             nq[0] = (k == a[i] ? q[0] + 1 : q[1]);             nq[1] = (k == a[i + 1] ? q[1] + 1 : max(nq[0], q[2]));             nq[2] = (k == a[i + 2] ? q[2] + 1 : nq[1]);             if (nq[0] < i - 1 || nq[1] < i || nq[2] < i) continue;             p = nq[0] - (i - 1);             p |= (nq[1] - i) << 1;             p |= (nq[2] - i) << 2;             f[i + 1][p] += f[i][j];           }         }       }     }     printf( %lld n , f[n][0] + f[n][1] + f[n][4] + f[n][5]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, x, a[5005], uc, sum, mux = 0;   vector<long long> myvec;   int main() {     cin >> n;     for (int i = 1; i <= n; i++) cin >> a[i];     for (int i = 1; i <= n; i++) {       sum = 0;       for (int j = i; j <= n; j++) {         sum += a[j];         if ((j - i + 1) * 100 < sum) mux = max(mux, (long long)(j - i + 1));       }     }     cout << mux;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int X;   vector<int> E[100010];   int all, all2;   int v[800 + 10];   int dp[800 + 10], dp2[800 + 10];   void calc(int x) {     for (int i = 0; i <= 800 - 1; ++i) v[i] = 0;     for (int i = 0; i < E[x].size(); ++i) v[E[x][i]] = 1;     for (int i = 0; i <= 800 - 1; ++i) dp2[i] = (1 << 29);     int cost = 0;     for (int i = 800 - 1; i >= 0; --i) {       if (v[i]) cost += 3;       int tmp = cost + dp[max(0, i - 1)];       if (tmp < dp2[i]) dp2[i] = tmp;       if (i > 0) tmp += i * (i + 1) / 2 + 2;       if (tmp < dp2[0]) dp2[0] = tmp;     }     for (int i = 0; i <= 800 - 1; ++i) dp[i] = dp2[i];     for (int i = 0; i <= 800 - 1; ++i) dp[i + 1] = min(dp[i + 1], dp[i]);   }   int main() {     int K, i, j, ans = 0;     cin >> X >> K;     for (int i = 1; i <= K; ++i) {       int r, c;       scanf( %d%d , &r, &c);       int x = c - 1;       int y = X - r;       if (y < 800)         E[x].push_back(y);       else         ans += 3;     }     for (i = X - 1; i >= 0; i--) calc(i);     cout << dp[0] + ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int N, K;   void init() { scanf( %d%d , &N, &K); }   void work() {     if (K == 1 && N > 1) {       printf( -1 );       return;     }     if (K == 1 && N == 1) {       printf( a );       return;     }     if (N < K) {       printf( -1 );       return;     }     if (N == K) {       for (int i = 1; i <= K; i++) printf( %c ,  a  + i - 1);       return;     }     for (int i = 1; i <= N - K + 2; i++) {       if (i & 1)         printf( a );       else         printf( b );     }     char j =  c ;     for (int i = N - K + 3; i <= N; i++) printf( %c , j++);   }   int main() {     init();     work();     printf(  n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long p = 998244353;   int gcd(int a, int b, int& x, int& y) {     if (a == 1) {       x = 1;       y = 0;       return 1;     }     if (b == 1) {       x = 0;       y = 1;       return 1;     }     if (b == 0) {       x = 1;       y = 0;       return a;     }     int res = gcd(b, a % b, y, x);     y = y - x * (a / b);     return res;   }   long long Denominator(long long a) {     int x = 0, y = 0;     if (a == 0) return 1;     gcd(p, a, x, y);     return (y + p) % p;   }   int main() {     long long n, res = 1;     cin >> n;     for (long long i = 1; i <= n; ++i) {       res *= (n + i);       res = res % p;       res *= Denominator(i);       res = res % p;     }     long long sum = 0;     vector<long long> a(2 * n);     for (int i = 0; i < 2 * n; ++i) {       cin >> a[i];     }     sort(a.begin(), a.end());     for (int i = 0; i < n; ++i) {       sum += a[2 * n - 1 - i] - a[i];     }     cout << res * (sum % p) % p << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t, m, num = 1;     string com;     int arg;     vector<pair<pair<int, int>, int> > d;     cin >> t >> m;     for (int _n((t)-1), q(0); q <= _n; q++) {       sort((d).begin(), (d).end());       cin >> com;       if (com ==  defragment ) {         if (d.size() > 0) {           d[0].first.second -= d[0].first.first;           d[0].first.first = 0;           for (int _n((d.size() - 1)), i(1); i <= _n; i++) {             int delta = d[i].first.first - d[i - 1].first.second;             d[i].first.first -= delta;             d[i].first.second -= delta;           }         }         continue;       }       cin >> arg;       if (com ==  alloc ) {         int res = -1;         if (d.size() > 0)           if (d[0].first.first >= arg) {             d.push_back(make_pair(make_pair(0, arg), num++));             res = 1;           }         if (res == -1)           for (int _n((d.size() - 1)), i(1); i <= _n; i++)             if (d[i].first.first - d[i - 1].first.second >= arg) {               d.push_back(make_pair(                   make_pair(d[i - 1].first.second, d[i - 1].first.second + arg),                   num++));               res = 1;               break;             }         if (res == -1)           if (d.size() > 0)             if (m - d[d.size() - 1].first.second >= arg) {               d.push_back(make_pair(make_pair(d[d.size() - 1].first.second,                                               d[d.size() - 1].first.second + arg),                                     num++));               res = 1;             }         if (res == -1)           if (d.size() == 0)             if (m >= arg) {               d.push_back(make_pair(make_pair(0, arg), num++));               res = 1;             }         if (res == -1)           cout <<  NULL  << endl;         else           cout << num - 1 << endl;         continue;       }       if (com ==  erase ) {         bool res = false;         for (int i = 0; i < d.size(); i++)           if (d[i].second == arg) {             swap(d[i], d[d.size() - 1]);             d.pop_back();             res = true;             break;           }         if (!res) cout <<  ILLEGAL_ERASE_ARGUMENT  << endl;         continue;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 100050;   struct str {     int pre[26], suf[26], mx[26], len;     str() {}     void Build(char s[], int n) {       len = n;       for (int i = 0; i < 26; i++) pre[i] = suf[i] = mx[i] = 0;       int len = 0;       for (int i = 1; i <= n; i++) {         if (i != 1 && s[i] == s[i - 1])           len++;         else           len = 1;         mx[s[i] -  a ] = max(mx[s[i] -  a ], len);       }       for (int i = 0; i < 26; i++) {         while (pre[i] < n && s[pre[i] + 1] ==  a  + i) pre[i]++;         while (suf[i] < n && s[n - suf[i]] ==  a  + i) suf[i]++;       }     }   } STR[N];   str operator*(str x, str y) {     str ans;     ans.len = y.len * (x.len + 1) + x.len;     for (int i = 0; i < 26; i++) {       if (y.pre[i] == y.len) {         if (x.pre[i] == x.len)           ans.pre[i] = ans.len;         else           ans.pre[i] = y.len * (x.pre[i] + 1) + x.pre[i];         if (x.suf[i] == x.len)           ans.suf[i] = ans.len;         else           ans.suf[i] = y.len * (x.suf[i] + 1) + x.suf[i];         ans.mx[i] = y.len * (x.mx[i] + 1) + x.mx[i];       } else {         ans.pre[i] = y.pre[i];         ans.suf[i] = y.suf[i];         if (x.mx[i] > 0)           ans.mx[i] = y.pre[i] + y.suf[i] + 1;         else           ans.mx[i] = y.mx[i];         ans.mx[i] = max(ans.mx[i], y.mx[i]);       }     }     return ans;   }   char s[N];   int main() {     int n, len, i;     scanf( %i , &n);     for (i = 1; i <= n; i++) {       scanf( %s , s + 1);       len = strlen(s + 1);       STR[i].Build(s, len);     }     for (i = 2; i <= n; i++) {       STR[1] = STR[1] * STR[i];     }     int ans = 0;     for (i = 0; i < 26; i++) ans = max(ans, STR[1].mx[i]);     printf( %i n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double PI = 2.0 * acos(0.0);   const double EPS = 1e-6;   int dp[100005];   static int topp;   void LIS(int x) {     if (topp == 0)       dp[topp++] = x;     else if (x > dp[topp - 1])       dp[topp++] = x;     else {       int left = 0, right = topp;       while (left < right) {         int mid = (left + right) >> 1;         if (dp[mid] > x)           right = mid;         else           left = mid + 1;       }       while (left < topp - 1 && dp[left] == dp[left + 1]) left++;       dp[left] = x;     }   }   int main() {     int n;     scanf( %d , &n);     ::topp = 0;     for (int i = 0; i < n; i++) {       int a;       scanf( %d , &a);       LIS(a);     }     printf( %d n , topp);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, k;   long long a, b, sum, ans, summ;   char s[100010];   long long powe(long long x, int r) {     long long ret = 1;     while (r) {       if (r & 1) ret = (ret * x) % 1000000009;       x = x * x % 1000000009;       r >>= 1;     }     return ret;   }   int main() {     scanf( %d%lld%lld%d , &n, &a, &b, &k);     scanf( %s , s);     long long p = b * powe(a, 1000000009 - 2) % 1000000009, d = powe(a, n);     for (int i = 0; i < k; ++i) {       if ((n + 1) % k == i) summ = sum;       if (s[i] ==  + )         sum = (sum + d) % 1000000009;       else         sum = (sum - d + 1000000009) % 1000000009;       d = (d * p) % 1000000009;     }     p = powe(p, k);     int bt = (n + 1) / k;     if (p == 1)       ans = sum * bt;     else       ans = sum * ((powe(p, bt) - 1 + 1000000009) % 1000000009) % 1000000009 *             powe((p - 1 + 1000000009) % 1000000009, 1000000009 - 2) % 1000000009;     summ = summ * powe(p, bt) % 1000000009;     ans = ((ans + summ) % 1000000009 + 1000000009) % 1000000009;     printf( %lld , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     ;     long long n;     cin >> n;     string s, t;     cin >> s >> t;     long long sa = 0, sb = 0, ta = 0, tb = 0;     for (long long i = 0; i < n; i++) {       if (s[i] ==  a )         sa++;       else         sb++;       if (t[i] ==  a )         ta++;       else         tb++;     }     if ((ta + sa) % 2 == 1 || (tb + sb) % 2 == 1) return cout << -1, 0;     vector<pair<long long, long long> > ans;     vector<long long> va, vb;     for (long long i = 0; i < n; i++) {       if (s[i] != t[i]) {         if (s[i] ==  a )           va.push_back(i);         else           vb.push_back(i);       }     }     {       for (long long i = 0;            i < (long long)va.size() && (long long)va.size() > i + 1; i += 2)         ans.push_back(make_pair(va[i], va[i + 1]));       for (long long i = 0;            i < (long long)vb.size() && (long long)vb.size() > i + 1; i += 2)         ans.push_back(make_pair(vb[i], vb[i + 1]));     }     if ((long long)va.size() % 2 == 1) {       ans.push_back(           make_pair(va[(long long)va.size() - 1], va[(long long)va.size() - 1]));       ans.push_back(           make_pair(va[(long long)va.size() - 1], vb[(long long)vb.size() - 1]));     }     cout << ans.size() <<   n ;     for (long long i = 0; i < (long long)ans.size(); i++)       cout << ans[i].first + 1 <<     << ans[i].second + 1 <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   inline T abs(T a) {     return ((a < 0) ? -a : a);   }   template <typename T>   inline T sqr(T a) {     return a * a;   }   const int INF = (int)1E9 + 7;   const long double EPS = 1E-9;   const long double PI = 3.1415926535897932384626433832795;   int n, m;   pair<int, int> a[100];   int solve(int x, int y, int i) {     int ans = i;     if (y == m) x++, y = 0;     if (x == n) return ans;     ans = max(ans, solve(x, y + 1, i));     bool ok = true;     for (int j = 0; j < int(i); ++j) {       if (sqr(a[j].first - x) + sqr(a[j].second - y) == 5) {         ok = false;         break;       }     }     if (ok) {       a[i] = make_pair(x, y);       ans = max(ans, solve(x, y + 1, i + 1));     }     return ans;   }   long long solve(long long n, long long m) {     if (n < m) swap(n, m);     if (m > 2) return (n * m) / 2 + ((n * m) & 1);     if (m == 1) return n;     int k = (n - 2) / 4, rem = (n - 2) % 4;     int start = 4 + k * 4;     if (rem < 3) return start;     return start + 2;   }   int main() {     int n, m;     cin >> n >> m;     cout << solve(n, m) << endl;     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( Ofast )   #pragma GCC target( avx,avx2,fma )   #pragma GCC optimization( unroll-loops )   using namespace std;   const long long MOD = 998244353;   const long long INF = 0x7f7f7f7f7f7f7f7f;   const int INFi = 0x7f7f7f7f;   const long long N = 150001;   vector<long long> adj[N];   long long vis[N] = {};   int dx8[] = {0, 1, 1, 1, 0, -1, -1, -1}, dy8[] = {1, 1, 0, -1, -1, -1, 0, 1};   int dx4[] = {0, 1, 0, -1}, dy4[] = {1, 0, -1, 0};   int t = 1;   long long n, a[2 * N + 10], fact[2 * N + 10];   long long mult(long long a, long long b) { return (a % MOD * b % MOD) % MOD; }   long long add(long long a, long long b) { return (a % MOD + b % MOD) % MOD; }   long long subt(long long a, long long b) {     return (a % MOD - b % MOD + MOD) % MOD;   }   long long fastModInv(long long x) {     long long res = 1;     long long y = MOD - 2;     while (y) {       if (y & 1) res = mult(res, x);       y >>= 1;       x = mult(x, x);     }     return res;   }   void MAIN() {     cin >> n;     long long ans = 0;     for (long long i = 1; i <= 2 * n; i++) cin >> a[i], a[i] = 2 * a[i];     sort(a + 1, a + 1 + 2 * n);     long long val =         (fact[2 * n - 1] * fastModInv(fact[2 * n - 1 - n + 1]) % MOD) *         fastModInv(fact[n - 1]) % MOD;     for (long long i = 1; i <= n; i++) ans = subt(ans, val * a[i] % MOD);     for (long long i = n + 1; i <= 2 * n; i++) ans = add(ans, val * a[i] % MOD);     cout << ans <<   n ;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cout << fixed;     cout << setprecision(10);     ;     mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());     ;     fact[0] = 1;     for (long long i = 1; i <= 2 * N; i++) fact[i] = fact[i - 1] * i % MOD;     while (t--) {       MAIN();     }   }
#include <bits/stdc++.h>   using namespace std;   int gcd(int a, int b) {     while (b) {       a %= b;       swap(a, b);     }     return a;   }   int check(vector<int> v) {     int k = 0;     for (int i = 0; i < v.size(); ++i) k += (gcd(i + 1, v[i]) > 1);     return k;   }   int main() {     int n, k;     cin >> n >> k;     if (n == k)       cout << -1 << endl;     else {       vector<int> v(n);       v[n - k - 1] = 1;       int p = 2;       for (int i = 0; i < n; ++i) {         if (i == n - k - 1) continue;         v[i] = p++;       }       for (int i = 0; i < n; ++i) cout << v[i] <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n, m, i, j, k, x, y, z, t;     long long hh, mm, h, d, c, N;     cin >> hh >> mm;     cin >> h >> d >> c >> N;     if (hh >= 20) {       double cc = 0.8 * c;       k = (h + N - 1) / N;       double ans = 1.0 * k * cc;       cout << fixed << setprecision(10) << ans << endl;       return 0;     }     double ans1, ans2;     k = (h + N - 1) / N;     ans1 = 1.0 * k * c;     x = (60 - mm) + (20 - hh - 1) * 60;     h += x * d;     double cc = 0.8 * c;     k = (h + N - 1) / N;     ans2 = 1.0 * k * cc;     cout << fixed << setprecision(10) << min(ans1, ans2) << endl;   }
#include <bits/stdc++.h>   using namespace std;   long long const N = 2e5 + 20, MOD = 1e9 + 7;   long long n, x, dp[N][2];   bool vis[N], col[N];   vector<long long> child[N];   void dfs(int v = 0) {     for (auto u : child[v]) dfs(u);     vector<long long> preChild, sufChild;     preChild.push_back(1), sufChild.push_back(1);     for (auto u : child[v]) {       preChild.push_back((preChild.back() * ((dp[u][0] + dp[u][1]) % MOD)) % MOD);     }     for (int i = child[v].size() - 1; i >= 0; i--) {       int u = child[v][i];       sufChild.push_back((sufChild.back() * ((dp[u][0] + dp[u][1]) % MOD)) % MOD);     }     if (col[v]) {       dp[v][0] = 0;       dp[v][1] = preChild.back();       return;     }     dp[v][0] = preChild.back();     dp[v][1] = 0;     preChild.push_back(1), sufChild.push_back(1);     for (int i = 0; i < child[v].size(); i++) {       int u = child[v][i];       dp[v][1] = (dp[v][1] + ((dp[u][1] * preChild[i] % MOD) *                               (sufChild[sufChild.size() - 3 - i] % MOD) % MOD)) %                  MOD;     }     return;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cin >> n;     for (int i = 0; i < n - 1; i++) {       cin >> x;       child[x].push_back(i + 1);     }     for (int i = 0; i < n; i++) cin >> col[i];     dfs();     return cout << dp[0][1], 0;   }
#include <bits/stdc++.h>   int n, t1, t2;   int num = 0;   int dfs(int l, int r) {     int k = (l + r) / 2;     num++;     if (t1 <= k && t2 > k) {       return num;     }     if (t1 <= k && t2 <= k) {       return dfs(l, k);     } else {       return dfs(k, r);     }   }   int FastLog2(int x) {     float fx;     unsigned long ix, exp;     fx = (float)x;     ix = *(unsigned long*)&fx;     exp = (ix >> 23) & 0xFF;     return exp - 127;   }   int main() {     int a, b;     scanf( %d%d%d , &n, &a, &b);     t1 = std::min(a, b);     t2 = std::max(a, b);     int ans = FastLog2(n) + 1 - dfs(1, n);     if (ans == FastLog2(n))       puts( Final! );     else       printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int get(int n, int p) {     int res = 0;     while (n >= p) res += n / p, n /= p;     return res;   }   template <class T>   T power(T N, T P) {     return (P == 0) ? 1 : N * power(N, P - 1);   }   void VC(vector<long long int>& v) {     for (int i = 0; i < v.size(); i++) printf( %lld  , v[i]);     printf(  n );   }   struct hash_pair {     template <class T1, class T2>     size_t operator()(const pair<T1, T2>& p) const {       auto hash1 = hash<T1>{}(p.first);       auto hash2 = hash<T2>{}(p.second);       return hash1 ^ hash2;     }   };   template <typename T>   void print(const T& v) {     cerr << v <<    ;   }   template <typename T1, typename... T2>   void print(const T1& first, const T2&... rest) {     print(first);     print(rest...);   }   const int Maxn = 1e5 + 1;   template <typename T, typename T1>   T mod(T x, T1 p) {     x %= p;     if (x < 0) x += p;     return x;   }   int fact[Maxn];   void factorial() {     fact[0] = 1;     for (int i = 1; i < Maxn; i++) {       fact[i] = 1LL * fact[i - 1] * i % 1000000007;     }   }   int inv[Maxn], ifact[Maxn];   template <typename T>   T inverse(T x, T p) {     x = mod(x, p);     if (x == 1) return x;     return mod((1LL * (-p / x) * (inv[p % x] % p)), p);   }   void inverse_fact() {     ifact[0] = 1;     for (int i = 1; i < Maxn; i++) {       inv[i] = inverse(i, 1000000007);       ifact[i] = (1LL * ifact[i - 1] * inv[i]) % 1000000007;     }   }   int nCr(int n, int r) {     int ret = (1LL * ifact[n - r] * ifact[r]) % 1000000007;     ret = (1LL * ret * fact[n]) % 1000000007;     return ret;   }   bool cmp(int a, int b) { return a > b; }   int main() {     int n, m, p, x, a, b;     scanf( %d , &(n));     scanf( %d , &(m));     scanf( %d , &(p));     int aa[n + 3], bb[m + 4];     for (int i = 0; i < n; i++) {       scanf( %d , &(aa[i]));     }     for (int i = 0; i < m; i++) {       scanf( %d , &(bb[i]));     }     for (int i = 0; i < n; i++) {       if (aa[i] % p) {         a = i;       }     }     for (int i = 0; i < m; i++) {       if (bb[i] % p) {         b = i;       }     }     printf( %d n , a + b);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, i, mx = 2, j;     cin >> n;     int a[n];     for (i = 0; i < n; i++) cin >> a[i];     if (n == 1)       cout <<  1 ;     else if (n == 2)       cout <<  2 ;     else {       for (i = 2; i < n;) {         int x = 0;         for (j = i; j < n; j++) {           if ((a[j] != (a[j - 1] + a[j - 2]))) break;           x++;         }         i = ++j;         mx = max(x + 2, mx);       }       cout << mx;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, top;   long long N;   struct str {     int x1, y1, x2, y2;     void print() { printf( %d %d %d %d n , x1, y1, x2, y2); }   } ans[310];   void print(int x1, int y1, int x2, int y2) {     if (x1 > n || y1 > n || x2 > n || y2 > n) return;     if (x1 < 1 || y1 < 1 || x2 < 1 || y2 < 1) return;     ans[++top] = (str){x1, y1, x2, y2};   }   int main() {     cin >> N;     n = 49;     for (int x = 3, y = 1; x <= n && y <= n; x += 2, y += 2) {       if (x + 1 <= n && y != 1) print(x, y, x + 1, y);       if (x + 1 <= n && y + 1 <= n) print(x, y + 1, x + 1, y + 1);     }     for (int x = 1, y = 3; x <= n && y <= n; x += 2, y += 2) {       if (y + 1 <= n && x != 1) print(x, y, x, y + 1);       if (x + 1 <= n && y + 1 <= n) print(x + 1, y, x + 1, y + 1);     }     for (int x = 2, y = 6; x <= n && y - 1 <= n; x += 2, y += 2) {       print(x - 1, y - 1, x, y - 1);       print(x - 1, y, x, y);     }     for (int y = 2, x = 6; x - 1 <= n && y <= n; x += 2, y += 2) {       print(x - 1, y - 1, x - 1, y);       print(x, y - 1, x, y);     }     for (int x = n - 1, y = n - 1; x > 3 && y > 3; x -= 2, y -= 2) {       int v = (int)(N % 6LL);       if (!v) {         print(x - 2, y, x - 1, y);         print(x - 2, y + 1, x - 1, y + 1);         print(x, y - 2, x, y - 1);         print(x + 1, y - 2, x + 1, y - 1);       } else if (v == 1) {         print(x - 2, y, x - 1, y);         print(x, y - 2, x, y - 1);         print(x + 1, y - 2, x + 1, y - 1);       } else if (v == 2) {         print(x - 2, y, x - 1, y);         print(x, y - 2, x, y - 1);       } else if (v == 3) {         print(x - 2, y + 1, x - 1, y + 1);         print(x, y - 2, x, y - 1);         print(x + 1, y - 2, x + 1, y - 1);       } else if (v == 4) {         print(x, y - 2, x, y - 1);         print(x + 1, y - 2, x + 1, y - 1);       } else {         print(x, y - 2, x, y - 1);       }       N /= 6LL;     }     if (!N) {       print(2, 3, 3, 3);       print(3, 2, 3, 3);     } else {       print(2, 3, 3, 3);       print(2, 2, 3, 2);     }     printf( %d %d n , n, n);     for (printf( %d n , top); top; top--) ans[top].print();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2e6 + 1;   const int INF = 1e9 + 9;   const int B = 1e9 + 7;   int n, b[N], d[N];   long long a[N];   int main() {     ios_base ::sync_with_stdio(0);     cin.tie(0);     cin >> n;     int ans = n;     for (int i = int(1); i <= int(n); ++i) {       cin >> a[i];       while (a[i] % 2 == 0) a[i] /= 2, ++b[i];       d[i] = i - 1;       for (int j = int(1); j <= int(i - 1); ++j)         if (a[j] % a[i] == 0 &&             (b[j] + (i - j) == b[i] || b[i] <= i - j - 1 || b[i] == 0))           d[i] = min(d[i], d[j] + (i - j - 1));       ans = min(ans, d[i] + (n - i));     }     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string s1, s2;     cin >> s1 >> s2;     int n = s1.length(), k = 0, s;     for (int i = 0; i < n; i++)       if (s1[i] != s2[i]) k++;     if (k % 2 == 1)       printf( impossible );     else {       int s = k / 2;       string ans;       for (int i = 0; i < n; i++)         if (s1[i] != s2[i])           if (s > 0) {             ans += s1[i];             s--;           } else             ans += s2[i];         else           ans += s1[i];       cout << ans;     }     return 0;   }