malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   long long a1, a2, b1, b2, c1, c2, d1, d2;   int main() {     cin >> a1 >> a2 >> b1 >> b2 >> c1 >> c2;     for (int q = 0; q < 4; q++) {       if (q == 0) {         d1 = b1 - (a1);         d2 = b2 - (a2);       }       if (q == 1) {         d1 = b1 - (-a1);         d2 = b2 - (-a2);       }       if (q == 2) {         d1 = b1 - (-a2);         d2 = b2 - (a1);       }       if (q == 3) {         d1 = b1 - (a2);         d2 = b2 - (-a1);       }       long long k1 = d1 * c1 + d2 * c2;       long long k2 = c1 * c1 + c2 * c2;       long long k3 = c1 * d2 - c2 * d1;       long long k4 = c1 * c1 + c2 * c2;       if (k2 == 0) {         if (d1 == 0 && d2 == 0) {           cout <<  YES ;           return 0;         }       } else if (k1 % k2 == 0 && k3 % k4 == 0) {         cout <<  YES ;         return 0;       }     }     cout <<  NO ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 100005;   int n, m, k, top, a[N];   pair<int, int> op[N * 3];   int main() {     scanf( %d%*d%d%d , &n, &m, &k);     k--;     m /= 2;     if (!k) {       return puts( 0 0 n ), 0;     }     for (int i = (int)(1); i <= (int)(n); i++) {       int x;       scanf( %*d%d , &x);       a[i] = (x %= m);       int l = (x + 1) % m, r = (x + k) % m;       op[++top] = pair<int, int>(l, 1);       op[++top] = pair<int, int>(r + 1, -1);       if (l > r) op[++top] = pair<int, int>(0, 1);     }     op[++top] = pair<int, int>(m, 0);     sort(op + 1, op + top + 1);     int mnv = 1 << 30, mnp = 0, s = 0;     for (int i = (int)(1); i <= (int)(top - 1); i++) {       s += op[i].second;       if (op[i].first != op[i + 1].first) {         if (s < mnv) mnv = s, mnp = op[i].first;       }     }     cout << mnv <<     << mnp << endl;     for (int i = (int)(1); i <= (int)(n); i++) {       int d = (mnp + m - a[i]) % m;       if (d >= 1 && d <= k) cout << i <<    ;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, i, p = 0;     cin >> n;     int ara[n];     for (i = 0; i < n; i++) {       cin >> ara[i];     }     sort(ara + 0, ara + n);     for (i = 0; i < n - 1; i++) {       if (ara[i] + 1 != ara[i + 1]) p = p - 1 + ara[i + 1] - ara[i];     }     cout << p;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> g[101];   int n, m;   bool visited[101];   void dfs(int v) {     visited[v] = true;     for (int i = 0; i < g[v].size(); i++) {       if (!visited[g[v][i]]) dfs(g[v][i]);     }   }   bool isConnected() {     fill(visited, visited + n, false);     dfs(0);     for (int i = 0; i < n; i++)       if (!visited[i]) return false;     return true;   }   int main() {     scanf( %d %d , &n, &m);     for (int i = 0; i < m; i++) {       int x, y;       scanf( %d %d , &x, &y);       x--, y--;       g[x].push_back(y);       g[y].push_back(x);     }     if (n == m && isConnected())       cout <<  FHTAGN!  << endl;     else       cout <<  NO  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long N = 3e5 + 55;   const long long mod = 1000000007;   double add[N << 2], sum[N << 2];   struct node {     int pos, h, l, r;   } a[N];   map<int, int> b;   vector<int> v, v2;   int getid(int x) { return lower_bound(v.begin(), v.end(), x) - v.begin() + 1; }   int get_id(int x) { return upper_bound(v.begin(), v.end(), x) - v.begin() + 1; }   int getid2(int x) {     return lower_bound(v2.begin(), v2.end(), x) - v2.begin() + 1;   }   void PushUp(int rt) { sum[rt] = sum[rt << 1] + sum[rt << 1 | 1]; }   void PushDown(int rt, int m, int l, int r) {     if (fabs(add[rt] - 1) > 0.00001) {       add[rt << 1] *= add[rt];       add[rt << 1 | 1] *= add[rt];       sum[rt << 1] *= add[rt];       sum[rt << 1 | 1] *= add[rt];       add[rt] = 1;     }   }   void build(int l, int r, int rt) {     add[rt] = 1;     sum[rt] = 0;     if (l == r) {       if (v2[getid2(v[l - 1]) - 1] == v[l - 1]) {         sum[rt] = b[v[l - 1]];       } else         sum[rt] = 0;       return;     }     int m = (l + r) >> 1;     build(l, m, rt << 1);     build(m + 1, r, rt << 1 | 1);     PushUp(rt);   }   void upedit(int L, int R, double c, int l, int r, int rt) {     if (L <= l && r <= R) {       add[rt] *= c;       sum[rt] *= c;       return;     }     int m = (l + r) >> 1;     PushDown(rt, m, l, r);     if (L <= m) upedit(L, R, c, l, m, rt << 1);     if (m < R) upedit(L, R, c, m + 1, r, rt << 1 | 1);     PushUp(rt);   }   double query(int L, int R, int l, int r, int rt) {     if (L <= l && r <= R) {       return sum[rt];     }     int m = (l + r) >> 1;     PushDown(rt, m, l, r);     double ret = 0;     if (L <= m) ret += query(L, R, l, m, rt << 1);     if (m < R) ret += query(L, R, m + 1, r, rt << 1 | 1);     return ret;   }   int main() {     ios::sync_with_stdio(false), cin.tie(0);     int n, m, k, kk;     cin >> n >> m;     for (int i = 1; i <= n; i++) {       cin >> a[i].pos >> a[i].h >> a[i].l >> a[i].r;       v.push_back(a[i].pos);       v.push_back(a[i].pos + a[i].h);       v.push_back(a[i].pos - a[i].h);     }     for (int i = 1; i <= m; i++) {       cin >> k >> kk, v.push_back(k), v2.push_back(k);       b[k] += kk;     }     sort(v.begin(), v.end()), v.erase(unique(v.begin(), v.end()), v.end());     sort(v2.begin(), v2.end()), v2.erase(unique(v2.begin(), v2.end()), v2.end());     int sz = v.size();     build(1, sz, 1);     for (int i = 1; i <= n; i++) {       int L = getid(a[i].pos - a[i].h);       int R = get_id(a[i].pos + a[i].h) - 1;       int M = getid(a[i].pos);       if (L < M) {         upedit(L, M - 1, 1 - a[i].l * 1.0 / 100, 1, sz, 1);       }       if (R > M) {         upedit(M + 1, R, 1 - a[i].r * 1.0 / 100, 1, sz, 1);       }     }     printf( %.5f n , sum[1]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int x[55][55], a, b, n, m;   int solve() {     int res = 1000000000;     for (int _n((n - a + 1) - 1), i(0); i <= _n; i++)       for (int _n((m - b + 1) - 1), j(0); j <= _n; j++) {         int cnt = 0;         for (int _n((a)-1), k(0); k <= _n; k++)           for (int _n((b)-1), t(0); t <= _n; t++) cnt += x[i + k][j + t];         res = min(res, cnt);       }     return res;   }   int main() {     scanf( %d%d , &n, &m);     for (int _n((n)-1), i(0); i <= _n; i++)       for (int _n((m)-1), j(0); j <= _n; j++) scanf( %d , &x[i][j]);     scanf( %d%d , &a, &b);     int r1 = solve();     swap(a, b);     int r2 = solve();     cout << min(r1, r2) << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int dp[550005];   int main() {     int n, d, c, i, j, x, flog;     scanf( %d %d , &n, &d);     dp[0] = 1;     for (i = 0; i < n; i++) {       scanf( %d , &c);       for (j = 500000; j >= c; j--) {         dp[j] |= dp[j - c];       }     }     int day = 0;     x = 0;     while (1) {       flog = 0;       for (j = x + d; j > x; j--) {         if (dp[j]) {           flog = 1;           day++;           x = j;           break;         }       }       if (!flog) break;     }     printf( %d %d n , x, day);   }
#include <bits/stdc++.h>   using namespace std;   const int MOD = 1000000007;   int main() {     int a[1010], b[1010];     int n;     while (cin >> n) {       for (int i = 0; i < n; i++) cin >> a[i] >> b[i];       int ans = 0;       for (int i = 0; i < n; i++) {         int s = a[i];         while (s <= ans) s += b[i];         ans = s;       }       cout << ans << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int M = 100010;   int n, i, Ans, b[M], pos[M];   long long A, w1, w2, m, ans, s[M];   struct shit {     long long w;     int id;   } a[M];   bool cmp(shit x, shit y) { return x.w > y.w; }   int main() {     scanf( %d%I64d%I64d%I64d%I64d , &n, &A, &w1, &w2, &m);     for (i = 1; i <= n; i++) {       scanf( %d , &a[i].w);       a[i].id = i;     }     sort(a + 1, a + n + 1, cmp);     for (i = 1; i <= n; i++) s[i] = a[i].w + s[i - 1];     if (m + s[n] - A * n >= 0) {       printf( %I64d n , w1 * n + w2 * A);       for (i = 1; i <= n; i++) printf( %d  , A);       puts(  );       return 0;     }     int now = 1;     for (i = 0; i < n; i++) {       if (m - A * i + s[i] < 0) break;       while (now <= i ||              a[now].w * (n - now + 1) - s[n] + s[now - 1] > m - A * i + s[i])         now++;       pos[i] = now;       long long tmp = (m - A * i + s[i] + s[n] - s[now - 1]) / (n - now + 1);       if (w1 * i + w2 * tmp > ans) ans = w1 * i + w2 * tmp, Ans = i;     }     printf( %I64d n , ans);     long long p =         (m - A * Ans + s[Ans] + s[n] - s[pos[Ans] - 1]) / (n - pos[Ans] + 1);     for (i = 1; i <= Ans; i++) b[a[i].id] = A;     for (i = Ans + 1; i < pos[Ans]; i++) b[a[i].id] = a[i].w;     for (i = pos[Ans]; i <= n; i++) b[a[i].id] = p;     for (i = 1; i <= n; i++) printf( %d  , b[i]);     puts(  );   }
#include <bits/stdc++.h>   using namespace std;   int n;   vector<int> A(100);   bool f(int m) {     int k1 = 0, k2 = 0;     for (int i = 0; i < n; i++) {       k1 += A[i];       k2 += m - A[i];     }     if (k2 > k1)       return true;     else       return false;   }   int main() {     cin >> n;     int MAX = -1;     for (int i = 0; i < n; i++) {       cin >> A[i];       if (A[i] > MAX) MAX = A[i];     }     int l = MAX - 1, r = 201;     while (r - l > 1) {       int m = (l + r) / 2;       if (f(m))         r = m;       else         l = m;     }     cout << r;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, a[105][105];   inline int get(int x, int y) {     bool vis[11];     for (register int i = 0; i <= 10; i++) vis[i] = 0;     vis[a[x - 1][y]] = vis[a[x + 1][y]] = vis[a[x][y - 1]] = vis[a[x][y + 1]] = 1;     for (register int i = 1; i <= 10; i++) {       if (!vis[i]) return i;     }     return 0;   }   inline void draw(int x, int y, int p, int sign) {     for (register int i = 0; i < p; i++) {       for (register int j = 0; j < p; j++) {         a[x + i][y + j] = sign;       }     }   }   inline void slove(int x, int y) {     if (y > m) {       y = 1;       x = x + 1;     }     if (x > n) return;     if (a[x][y]) {       slove(x, y + 1);       return;     }     int p = 1, sign = get(x, y);     while (1) {       if (x + p > n || y + p > m) break;       if (a[x][y + p]) break;       int tmp = get(x, y + p);       if (tmp != sign) break;       p++;     }     draw(x, y, p, sign);     slove(x, y + 1);   }   int main() {     scanf( %d%d , &n, &m);     slove(1, 1);     for (register int i = 1; i <= n; i++) {       for (register int j = 1; j <= m; j++) {         printf( %c , (a[i][j] - 1 +  A ));       }       printf(  n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long INF = 1e9;   const int MAX = 1e5 + 7, N = 1e5 + 3;   double pi = acos(-1);   long long r, l, k, m, n, ans;   int main() {     cin >> n;     cin >> k >> l;     long long m1 = k - 1 + l - 1;     long long m2 = n - k + n - l;     if (m1 <= m2) {       cout <<  White  << endl;     } else {       cout <<  Black  << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char _c;   bool _f;   template <class T>   inline void IN(T &x) {     x = 0, _f = 0;     while (_c = getchar(), !isdigit(_c))       if (_c ==  - ) _f = 1;     while (isdigit(_c)) x = x * 10 + _c -  0 , _c = getchar();     if (_f) x = -x;   }   template <class T>   inline void chkmax(T &x, T y) {     if (x < y) x = y;   }   template <class T>   inline void chkmin(T &x, T y) {     if (x > y) x = y;   }   const int N = 5e5 + 5;   const int mod = 1e9 + 7;   int mul(int x, int y) { return 1ll * x * y % mod; }   int n, cnt = 1, dep[N], parent[N], head[N];   int fa[N << 1], tof[N], nxt[N << 1], pre[N << 1], st[N], ed[N], deg[N];   struct Edge {     int nxt, to;   } G[N << 1];   void addedge(int u, int v) {     G[++cnt] = (Edge){head[u], v}, head[u] = cnt, ++deg[u];     G[++cnt] = (Edge){head[v], u}, head[v] = cnt, ++deg[v];   }   void dfs(int u, int lst) {     parent[u] = lst, dep[u] = dep[lst] + 1;     for (int v, i = head[u]; i; i = G[i].nxt)       if (v = G[i].to, v != lst) dfs(v, u), tof[v] = i ^ 1;   }   int find(int x) { return x == fa[x] ? x : fa[x] = find(fa[x]); }   bool merge(int x, int y) {     x = find(x), y = find(y);     return (x == y) ? false : (fa[x] = y, true);   }   void solve(int x, int y) {     std ::stack<int> s;     std ::queue<int> q;     const int _x = x, _y = y;     while (dep[x] > dep[y]) q.push(tof[x]), --deg[x], x = parent[x];     while (dep[x] < dep[y]) s.push(tof[y]), --deg[y], y = parent[y];     while (x != y) {       q.push(tof[x]), --deg[x], x = parent[x];       s.push(tof[y]), --deg[y], y = parent[y];     }     --deg[x];     while (!s.empty()) q.push(s.top() ^ 1), s.pop();     int lst = q.front();     q.pop();     if (st[_x] || pre[lst]) {       puts( 0 );       exit(0);     };     st[_x] = lst, pre[lst] = -1;     while (!q.empty()) {       int now = q.front();       q.pop(), lst ^= 1;       if (pre[now] || nxt[lst] || !merge(lst, now)) {         puts( 0 );         exit(0);       };       pre[now] = lst, nxt[lst] = now, lst = now;     }     lst ^= 1;     if (ed[_y] || nxt[lst]) {       puts( 0 );       exit(0);     };     ed[_y] = lst, nxt[lst] = -1;     return;   }   int u, v, a[N];   int fac(int x) { return x == 0 ? 1 : mul(x, fac(x - 1)); }   int main() {     IN(n);     for (int i = 1; i <= n - 1; ++i) IN(u), IN(v), addedge(u, v);     for (int i = 1; i <= cnt; ++i) fa[i] = i;     dfs(1, 0);     for (int i = 1; i <= n; ++i) IN(a[i]);     for (int i = 1; i <= n; ++i)       if (a[i] == i) {         puts( 0 );         exit(0);       };     for (int i = 1; i <= n; ++i)       if (a[i]) solve(a[i], i);     int ans = 1;     for (int i = 1; i <= n; ++i) {       if (st[i] && ed[i])         if (find(st[i]) == find(ed[i]) && ~deg[i]) {           puts( 0 );           exit(0);         };       ans = mul(ans, fac(deg[i] == -1 ? 1 : deg[i]));     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   void pr(vector<T> &v) {     for (int i = 0; i < (int)(v).size(); i++) cout << v[i] <<    ;     cout << endl;   }   template <typename T>   void pr(vector<vector<T>> &v) {     for (int i = 0; i < (int)(v).size(); i++) {       pr(v[i]);     }   }   template <typename T>   void re(T &first) {     cin >> first;   }   template <typename T>   void re(vector<T> &a) {     for (int i = 0; i < (int)(a).size(); i++) re(a[i]);   }   template <class Arg, class... Args>   void re(Arg &first, Args &...rest) {     re(first);     re(rest...);   }   template <typename T>   void pr(T first) {     cout << first << endl;   }   template <class Arg, class... Args>   void pr(const Arg &first, const Args &...rest) {     cout << first <<    ;     pr(rest...);     cout << endl;   }   void ps() { cout << endl; }   template <class T, class... Ts>   void ps(const T &t, const Ts &...ts) {     cout << t;     if (sizeof...(ts)) cout <<    ;     ps(ts...);   }   void solve() {     int n;     re(n);     pr(1 + 3 * (n + 1));     ps(0, 0);     for (int i = 0; i < n + 1; i++) {       ps(i, i + 1);       ps(i + 1, i + 1);       ps(i + 1, i);     }   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int t = 1;     for (int tt = 0; tt < t; tt++) {       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   int const N = 100000;   int n;   int ans;   char digits[8][8];   int ten[8];   bitset<N> isprime;   int sum[8];   struct Integer {     int i, j, x;     Integer(int i, int j, int x) : i(i), j(j), x(x) {}     operator int() { return x; }     Integer(int x = 0) : x(x), i(-1), j(-1) {}     void operator=(int other) {       if (i >= 0) {         sum[i] -= x * ten[n - 1 - j];         sum[j] -= x * ten[n - 1 - i];         x = other;         sum[i] += x * ten[n - 1 - j];         sum[j] += x * ten[n - 1 - i];       } else {         x = other;       }     }   };   template <class T>   struct Counter {     vector<int> bnd;     vector<T> value;     Counter<T>(vector<int> bnd) : bnd(bnd), value(bnd.size(), 0) {}     bool operator++(int) {       int n = bnd.size();       int add = -1;       for (int i = n - 1; i >= 0; --i) {         if ((int)value[i] != bnd[i] - 1) {           add = i;           break;         }       }       if (add == -1) {         return false;       }       value[add] = value[add] + 1;       for (int i = add + 1; i < n; ++i) {         value[i] = 0;       }       return true;     }     T &operator[](int x) { return value[x]; }   };   int count_valid_after_fill[8][N];   int main() {     isprime.set();     isprime[0] = isprime[1] = false;     for (int i = 4; i < isprime.size(); i += 2) isprime[i] = false;     for (int i = 3; i < isprime.size(); i += 2)       if (isprime[i]) {         for (int k = i * 3; k < isprime.size(); k += i + i) isprime[k] = false;       }     ten[0] = 1;     for (int i = 1; i < 8; ++i) {       ten[i] = ten[i - 1] * 10;     }     memset(count_valid_after_fill, 0, (sizeof count_valid_after_fill));     for (int i = 0; i < isprime.size(); ++i) {       for (int p = 0; p < 5; ++p) {         int x = i;         if (x / ten[p] % 10 == 0) {           for (int n_ = (10), k = 0; k < n_; ++k) {             if (x < ((int)(isprime).size()) && isprime[x]) {               count_valid_after_fill[p][i]++;             }             x += ten[p];           }         }       }     }     int ca;     cin >> ca;     for (int n_ = (ca), ica = 0; ica < n_; ++ica) {       string input;       cin >> input;       n = input.size();       memset(digits, 0, (sizeof digits));       memset(sum, 0, (sizeof sum));       for (int n_ = (n), i = 0; i < n_; ++i) {         digits[0][i] = digits[i][0] = input[i] -  0 ;         sum[0] += ten[n - 1 - i] * digits[i][0];         if (i != 0) {           sum[i] += ten[n - 1] * digits[i][0];         }       }       vector<int> bnd((n - 1) * (n - 2) / 2, 10);       Counter<Integer> counter(bnd);       int p = 0;       for (int i = 1; i < n; ++i) {         for (int j = i + 1; j < n; ++j) {           counter[p] = Integer(i, j, 0);           p++;         }       }       int ans = 0;       do {         int way = 1;         for (int i = 1; i < n; ++i) {           int way2 = count_valid_after_fill[n - 1 - i][sum[i]];           way *= way2;         }         ans += way;       } while (counter++);       cout << ans << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long GCD(long long x, long long y) {     if (y == 0) return x;     return GCD(y, x % y);   }   long long LCM(long long x, long long y) { return (x * y) / (GCD(x, y)); }   long long LOGK(long long x, long long k) {     if (x >= k) return 1 + LOGK(x / k, k);     return 0;   }   long long MPOW(long long a, long long b, long long m) {     if (b == 0) return 1;     long long x = MPOW(a, b / 2, m);     x = (x * x) % m;     if (b % 2 == 1) x = (x * a) % m;     return x;   }   int main() {     long long test = 1;     while (test--) {       long long n;       cin >> n;       long long ar[n + 1];       long long dp[n + 1];       dp[0] = 1;       for (long long i = 1; i <= n; i++) dp[i] = 0;       long long ans = 0;       for (long long i = 1; i <= n; i++) {         cin >> ar[i];         vector<long long> g;         for (long long j = 1; j <= (long long)(sqrt(ar[i])); j++) {           if (ar[i] % j == 0) {             g.push_back(j);             if (ar[i] / j != j) {               g.push_back(ar[i] / j);             }           }         }         sort(g.begin(), g.end());         reverse(g.begin(), g.end());         for (auto it : g) {           if (it <= n) {             dp[it] += dp[it - 1];             dp[it] %= 1000000007;           }         }       }       for (long long i = 1; i <= n; i++) {         ans += dp[i];         ans %= 1000000007;       }       cout << ans;     }   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 1e9 + 7;   long long t, n;   long long quickpower(int a, int b) {     long long res = 1;     while (b) {       if (b % 2 == 1) res *= a;       a *= a;       b >>= 1;     }     return res;   }   int main() {     cin >> t;     while (t--) {       cin >> n;       long long r = 0;       for (int i = 2;; i++) {         r = quickpower(2, i) - 1;         if (n % r == 0) {           cout << n / r << endl;           break;         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, a, b, m = 0, c = 0;     scanf( %d , &n);     while (n--) {       scanf( %d%d , &a, &b);       if (a > b) {         m++;       } else if (a < b) {         c++;       }     }     if (m > c) {       printf( Mishka );     } else if (m < c) {       printf( Chris );     } else {       printf( Friendship is magic!^^ );     }     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( O3 )   #pragma GCC optimize( unroll-loops )   #pragma GCC optimize( -Ofast )   using namespace std;   void rearrange(long long arr[], long long n) {     long long temp[n];     long long small = 0, large = n - 1;     long long flag = true;     for (long long i = 0; i < n; i++) {       if (flag)         temp[i] = arr[large--];       else         temp[i] = arr[small++];       flag = !flag;     }     for (long long i = 0; i < n; i++) arr[i] = temp[i];   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     string a;     cin >> a;     long long k, i;     cin >> k;     long long snow = 0, candy = 0;     for (i = 0; i < a.size(); i++) {       if (a[i] ==  * )         snow++;       else if (a[i] ==  ? )         candy++;     }     long long cha = k - (a.size() - snow - candy);     if (cha > 0) {       if (snow == 0)         cout <<  Impossible ;       else {         string ans =   ;         for (i = a.size() - 1; i >= 0; i--) {           if (a[i] ==  ? ) continue;           if (a[i] ==  * ) {             while (cha > 0) {               ans = ans + a[i - 1];               cha--;             }           } else {             ans = ans + a[i];           }         }         reverse(ans.begin(), ans.end());         cout << ans;       }     } else {       if (a.size() - 2 * snow - 2 * candy > k)         cout <<  Impossible ;       else {         vector<char> v(a.size(),  1 );         for (i = a.size() - 1; i >= 0; i--) {           if (a[i] ==  ?  || a[i] ==  * ) {             i--;           } else {             v[i] = a[i];             k--;           }         }         for (i = a.size() - 1; i >= 0; i--) {           if (k > 0 && (a[i] ==  ?  || a[i] ==  * )) {             k--;             v[i] = a[i - 1];           }         }         for (i = 0; i < a.size(); i++) {           if (v[i] !=  1 ) cout << v[i];         }       }     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long pow = 1;     long long L, R;     cin >> L >> R;     while (pow * 10 <= R) pow *= 10;     if (L < pow) {       if (R < pow * 5)         cout << R * (pow * 10 - 1 - R) << endl;       else         cout << pow * 5 * (pow * 5 - 1) << endl;     } else {       if (R >= pow * 5 && L <= pow * 5)         cout << pow * 5 * (pow * 5 - 1) << endl;       else         cout << max(R * (pow * 10 - 1 - R), L * (pow * 10 - 1 - L)) << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, l, k, ultim;   map<int, int> cnt;   int main() {     cin >> n >> k;     for (int i = 0; i <= 63; i++)       if ((n >> i) & 1) cnt[i]++, l++;     if (l > k) {       cout <<  No ;       return 0;     }     for (int i = 63; i >= -63; i--) {       if (l + cnt[i] <= k)         l += cnt[i], cnt[i - 1] += cnt[i] * 2, cnt[i] = 0;       else         break;     }     multiset<int> ms;     multiset<int>::iterator it;     for (int i = 63; i >= -63; i--)       for (int j = 0; j < cnt[i]; j++) ms.insert(i);     while (ms.size() < k) {       it = ms.begin();       int u = *it;       ms.erase(it);       ms.insert(u - 1);       ms.insert(u - 1);     }     cout <<  Yes n ;     for (auto it = ms.rbegin(); it != ms.rend(); it++) {       cout << *it <<    ;     }     return 0;   }