malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int maxn = 105;   int a[maxn];   long long n, k;   bool ok(long long d) {     long long ret = 0;     for (int i = 0; i < n; ++i) {       ret += (a[i] - 1 + d) / d;     }     return ret * d <= k;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cin >> n >> k;     for (int i = 0; i < n; ++i) cin >> a[i], k += a[i];     long long ans = 0;     for (long long i = 1; i <= sqrt(k) + 1; ++i) {       if (ok(i)) ans = max(ans, i);       if (ok(k / i)) ans = max(ans, k / i);     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long max(long long a, long long b) {     if (a > b) {       return a;     } else {       return b;     }   }   long long min(long long a, long long b) {     if (a < b) {       return a;     } else {       return b;     }   }   struct P {     double x, y;     P() {}     P(double x, double y) : x(x), y(y) {}     P operator+(const P &a) const { return P(x + a.x, y + a.y); }     P operator-(const P &a) const { return P(x - a.x, y - a.y); }     double operator^(const P &a) const { return x * a.x + y * a.y; }     void in() { scanf( %lf%lf , &x, &y); }     void out() { printf( REQUIRED %.7f %.7f n , x, y); }     double dist(P a, P b) {       return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));     }     double sqdist(P a, P b) {       return (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y);     }   };   int n, k;   int a[9999];   int b[9999];   int cc[9999];   int bb[9999];   long long res = -100000000;   long long ma[9999];   long long query(long long l, long long r) {     int length = r - l + 1;     if (length <= k) return ma[length];     int cnt = 0;     for (int i = (1); i <= (n); i++) {       if ((i < l) || (i > r)) cc[++cnt] = a[i];     }     int cnt2 = 0;     for (int i = (l); i <= (r); i++) bb[++cnt2] = a[i];     sort(cc + 1, cc + cnt + 1);     sort(bb + 1, bb + cnt2 + 1);     int go = 0;     for (int i = (1); i <= (min(min(cnt, cnt2), k)); i++) {       if (cc[cnt - i + 1] > bb[i]) go = i;     }     for (int i = (1); i <= (go); i++) bb[i] = cc[cnt - i + 1];     long long sum = 0;     for (int i = (1); i <= (cnt2); i++) sum += bb[i];     return sum;   }   int main() {     scanf( %d%d , &n, &k);     for (int i = (1); i <= (n); i++) scanf( %d , &a[i]);     for (int i = (1); i <= (n); i++) b[i] = a[i];     sort(b + 1, b + n + 1);     ma[0] = 0;     for (int i = (n); i >= (1); i--) {       ma[n - i + 1] = ma[n - i] + b[i];     }     for (int i = (1); i <= (n); i++) {       for (int j = (i); j <= (n); j++) {         res = max(res, query(i, j));       }     }     printf( %I64d n , res);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void DFS(int s);   vector<int> v[60];   int d = 0;   int c[200];   int main() {     int n, m;     scanf( %d %d , &n, &m);     for (int i = 0; i <= 50; i++) v[i].clear();     memset(c, 0, sizeof(c));     for (int i = 1; i <= m; i++) {       int u, vv;       scanf( %d %d , &u, &vv);       v[u].push_back(vv);       v[vv].push_back(u);     }     int mx = 0;     for (int i = 1; i <= n; i++) {       if (c[i] == 0) {         d = 0;         DFS(i);         mx = mx + d - 1;       }     }     printf( %I64d n , (long long)pow(2, mx));     return 0;   }   void DFS(int s) {     d++;     c[s] = 1;     int sz = v[s].size();     for (int i = 0; i < sz; i++) {       int x = v[s][i];       if (c[x] == 0) {         DFS(x);       }     }   }
#include <bits/stdc++.h>   using namespace std;   const long long maxx = 1e9 + 7;   bool compare(const pair<long long, long long> &a,                const pair<long long, long long> &b) {     return a.first > b.first || (a.first == b.first && a.second < b.second);   }   long long inline power(long long a, long long b, long long p) {     a %= p;     long long ans = 1;     while (b > 0) {       if (b & 1) ans = (ans * a) % p;       a = (a * a) % p;       b >>= 1;     }     return ans;   }   long long inv(long long n, long long p) { return power(n, p - 2, p); }   bool inline isPrime(long long n) {     if (n <= 1) return false;     if (n <= 3) return true;     if (n % 2 == 0 || n % 3 == 0) return false;     for (long long i = 5; i * i <= n; i = i + 6)       if (n % i == 0 || n % (i + 2) == 0) return false;     return true;   }   template <class T>   void printv(T &v, long long n) {     if (n == -1) n = v.size();     for (long long i = 0; i < n; i++) cout << v[i] <<    ;     cout <<   n ;   }   const long long maxn = 2e5 + 5;   vector<long long> parent(maxn, 0);   vector<vector<long long> > v;   long long start;   vector<long long> pos(maxn);   vector<pair<long long, long long> > gap(maxn);   void dfs(long long node) {     start++;     pos[start] = node;     gap[node].first = start;     for (auto &x : v[node]) {       if (x == parent[node]) continue;       dfs(x);     }     gap[node].second = start;   }   void solve() {     long long n, q, u, k;     cin >> n >> q;     start = 0;     v.assign(n + 1, vector<long long>());     for (long long i = 1; i <= n - 1; i++) {       cin >> parent[i + 1];       v[i + 1].push_back(parent[i + 1]);       v[parent[i + 1]].push_back(i + 1);     }     for (auto &x : v) sort(x.begin(), x.end());     dfs(1);     for (long long i = 1; i <= q; i++) {       cin >> u >> k;       if (gap[u].second - gap[u].first + 1 < k) {         cout << -1 <<   n ;         continue;       }       cout << pos[((gap[u].first) + k - 1)] <<   n ;     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long test = 1;     while (test--) {       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   const long long M = 2e5 + 10;   const long long INF = 0x3f3f3f3f;   const long long mod = 998244353;   int mans = INF;   int n, c, dp[M][2], f[M], l[M];   int main() {     scanf( %d%d , &n, &c);     memset(dp, INF, sizeof(dp));     for (int i = 1; i < n; i++) scanf( %d , &f[i]);     for (int i = 1; i < n; i++) scanf( %d , &l[i]);     dp[0][0] = c;     dp[0][1] = 0;     for (int i = 1; i < n; i++) {       dp[i][0] = min(dp[i - 1][0], dp[i - 1][1] + c) + l[i];       dp[i][1] = min(dp[i - 1][0], dp[i - 1][1]) + f[i];     }     for (int i = 0; i < n; i++) printf( %d  , min(dp[i][0], dp[i][1]));     puts(  );     return 0;   }
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:16777216 )   using namespace std;   const double eps = 1e-9;   const double pi = acos(-1.0);   const long long INF = (long long)1e18;   int n;   long long a[11], val[11];   long long dp[1 << 8][1 << 8];   int lastBit[1 << 8];   long long del[11][1 << 8];   long long get(long long v) {     long long i = 2;     long long res = 0;     while (i * i <= v) {       while (v % i == 0) {         res++;         v /= i;       }       i++;     }     if (v > 1) {       res++;     }     return res;   }   long long dfs(int mask1, int mask2) {     if (mask1 == 0 && mask2 == 0) return 0;     if (mask2 == 0 && mask1 != 0) return INF;     long long &res = dp[mask1][mask2];     if (res != -1) return res;     res = INF;     int last = lastBit[mask2];     for (int sub = mask1;; sub = (sub - 1) & mask1) {       if (del[last][sub] != -1) {         res = min(res, dfs(mask1 ^ sub, mask2 ^ (1 << last) ^ sub) + 1 +                            (sub == 0 ? val[last] : del[last][sub]));       }       if (sub == 0) break;     }     return res;   }   int main() {     cin >> n;     for (int i = 0; i < n; i++) {       cin >> a[i];     }     sort(a, a + n);     for (int i = 0; i < n; i++) {       val[i] = get(a[i]);       if (val[i] == 1) val[i] = 0;     }     for (int mask = 0; mask < (1 << n); mask++) {       int last = -1;       for (int i = 0; i < n; i++)         if (mask & (1 << i)) {           last = i;         }       lastBit[mask] = last;     }     for (int i = 0; i < n; i++) {       for (int mask = 0; mask < (1 << n); mask++) {         long long v = a[i];         for (int j = 0; j < n; j++)           if (mask & (1 << j)) {             if (v % a[j] != 0) {               v = -1;               break;             } else {               v /= a[j];             }           }         del[i][mask] = v == -1 ? -1 : get(v);       }     }     memset(dp, -1, sizeof(dp));     long long res = INF;     for (int mask = 1; mask < (1 << n); mask++) {       res = min(res, dfs(((1 << n) - 1) ^ mask, mask) +                          (__builtin_popcountll(mask) == 1 ? 0 : 1));     }     cout << res << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, d, res;   int a[200005];   int main() {     cin >> n;     for (int i = 1; i <= n; ++i) {       cin >> a[i];       if (a[i] == 2) d++;     }     if (d <= n / 2) {       res += d;       n -= 2 * d;       res += n / 3;       cout << res;       return 0;     } else {       cout << n - d;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m;     scanf( %d%d , &n, &m);     printf( %d n , min(n, m) + 1);     for (int i = 0; i <= min(n, m); i++) {       printf( %d %d n , min(n, m) - i, i);     }   }
#include <bits/stdc++.h>   using namespace std;   const int inf = 0x3f3f3f3f;   int n;   int a[10001], c[10001], d[10001];   int ans = 0;   char str[101];   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       scanf( %s , str);       if (str[0] ==  M ) a[i] = 1;       scanf( %d %d , &c[i], &d[i]);     }     for (int i = 1; i <= 366; i++) {       int x = 0, y = 0;       for (int j = 1; j <= n; j++) {         if (c[j] <= i && i <= d[j]) {           if (a[j])             ++x;           else             ++y;         }       }       ans = max(ans, min(x, y));     }     printf( %d n , ans * 2);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char s1[5010], s2[5010];   int dp[5010][5010];   int main() {     int i, j, ind, n, m, ans;     cin >> n >> m;     cin >> s1;     cin >> s2;     for (i = 1; i <= n; i++) {       for (j = 1; j <= m; j++) {         dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]) - 1;         if (s1[i - 1] == s2[j - 1]) {           dp[i][j] = max(dp[i][j], dp[i - 1][j - 1] + 2);           dp[i][j] = max(dp[i][j], 2);         }       }     }     ans = 0;     for (i = 0; i <= n; i++) {       for (j = 0; j <= m; j++) ans = max(ans, dp[i][j]);     }     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   long long n, k, x;   long long inp[200005];   long long precom[64][2];   long long num;   long long ans;   int main() {     cin >> n >> k >> x;     long long i, j, kl;     for (i = 0; i < n; ++i) {       scanf( %lld , &inp[i]);       for (j = 0; j < 63; ++j) {         if (((long long)1 << j) & inp[i]) precom[j][0]++;       }     }     long long pos = 0;     long long ans, tmpans;     ans = 0;     for (j = 0; j < n; ++j) {       num = inp[j];       for (i = 0; i < k; ++i) {         num *= x;       }       for (kl = 0; kl < 64; ++kl) {         precom[kl][1] = 0;         if ((num & ((long long)1 << kl)) && !(inp[j] & ((long long)1 << kl))) {           precom[kl][1] = 1;         }         if (!(num & ((long long)1 << kl)) && (inp[j] & ((long long)1 << kl)))           precom[kl][1] = -1;       }       tmpans = 0;       for (kl = 0; kl < 64; ++kl) {         if (precom[kl][0] + precom[kl][1]) tmpans += ((long long)1 << kl);       }       if (tmpans > ans) {         ans = tmpans;       }     }     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int nax = 3e5 + 5;   long long n, x1, x2;   array<long long, 2> c[nax];   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cin >> n >> x1 >> x2;     for (int i = 0; i < n; i++) cin >> c[i][0], c[i][1] = i;     sort(c, c + n);     for (int rep = 0; rep < 2; rep++) {       int best = n - 1;       for (; ~best; --best)         if (c[best][0] >= (x2 + n - best - 1) / (n - best)) break;       if (best == -1) continue;       for (int k = 1; k < n; k++) {         int j = lower_bound(c, c + n, array<long long, 2>{(x1 + k - 1) / k}) - c;         if (j + k - 1 >= best) continue;         cout <<  Yes n ;         if (rep == 0) {           cout << k <<     << n - best <<   n ;           for (int i = j; i < j + k; i++) cout << c[i][1] + 1 <<    ;           cout <<   n ;           for (int i = best; i < n; i++) cout << c[i][1] + 1 <<    ;           cout <<   n ;         } else {           cout << n - best <<     << k <<   n ;           for (int i = best; i < n; i++) cout << c[i][1] + 1 <<    ;           cout <<   n ;           for (int i = j; i < j + k; i++) cout << c[i][1] + 1 <<    ;           cout <<   n ;         }         exit(0);       }       swap(x1, x2);     }     cout <<  No n ;   }
#include <bits/stdc++.h>   using namespace std;   int n, q;   int a[1000007];   int st[1000007];   int en[1000007];   vector<pair<int, int> > v_st[1000007];   long long ans[1000007];   class Tree {    public:     pair<long long, int> tr[6 * 1000007];     void init(int where, int IL, int IR) {       tr[where] = {0, 0};       if (IL == IR) {         return;       }       int mid = (IL + IR) / 2;       init(2 * where, IL, mid);       init(2 * where + 1, mid + 1, IR);     }     void update(int where, int IL, int IR, int CURL, int CURR,                 pair<long long, int> add) {       if (CURR < CURL) {         return;       }       if (IR < CURL || CURR < IL) {         return;       }       if (CURL <= IL && IR <= CURR) {         tr[where].first += add.first, tr[where].second += add.second;         return;       }       int mid = (IL + IR) / 2;       update(2 * where, IL, mid, CURL, CURR, add);       update(2 * where + 1, mid + 1, IR, CURL, CURR, add);     }     pair<long long, int> query(int where, int IL, int IR, int pos) {       if (IR < pos || pos < IL) {         return {0, 0};       }       if (IL == IR) {         return tr[where];       }       int mid = (IL + IR) / 2;       pair<long long, int> ret;       if (pos <= mid) {         ret = query(2 * where, IL, mid, pos);       } else {         ret = query(2 * where + 1, mid + 1, IR, pos);       }       ret = {ret.first + tr[where].first, ret.second + tr[where].second};       return ret;     }   };   Tree w;   void input() {     scanf( %d%d , &n, &q);     for (int i = 1; i <= n; ++i) {       scanf( %d , &a[i]);     }     for (int i = 1; i <= q; ++i) {       scanf( %d , &st[i]);     }     for (int i = 1; i <= q; ++i) {       scanf( %d , &en[i]);       v_st[en[i]].push_back({st[i], i});     }   }   void calc() {     stack<int> st;     a[0] = n + 1;     st.push(0);     w.init(1, 1, n);     for (int i = 1; i <= n; ++i) {       while (a[st.top()] < a[i]) {         st.pop();       }       w.update(1, 1, n, 1, st.top(), {i - st.top() - 1, 0});       w.update(1, 1, n, st.top() + 1, i, {i, 1});       st.push(i);       int sz = v_st[i].size();       for (int j = 0; j < sz; ++j) {         pair<long long, int> ret = w.query(1, 1, n, v_st[i][j].first);         ans[v_st[i][j].second] += ret.first - 1LL * ret.second * v_st[i][j].first;       }     }   }   void solve() {     calc();     for (int i = 1; i <= (n >> 1); ++i) {       swap(a[i], a[n - i + 1]);     }     for (int i = 1; i <= n; ++i) {       v_st[i].clear();     }     for (int i = 1; i <= q; ++i) {       st[i] = (n - st[i] + 1);       en[i] = (n - en[i] + 1);       swap(st[i], en[i]);       v_st[en[i]].push_back({st[i], i});     }     calc();     for (int i = 1; i <= q; ++i) {       printf( %I64d  , ans[i] + (en[i] - st[i] + 1));     }     printf(  n );   }   int main() {     ios_base ::sync_with_stdio(false);     cin.tie(NULL);     input();     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int inf = 0x3f3f3f3f;   const int maxn = 100005;   int a[maxn], b[maxn];   int main() {     long long d, k, a, b, t;     scanf( %I64d%I64d%I64d%I64d%I64d , &d, &k, &a, &b, &t);     if (d < k) {       printf( %I64d n , d * a);       return 0;     }     d -= k;     long long ans = k * a;     long long k1 = k * a + t, k2 = k * b;     if (k1 >= k2) {       ans += d * b;     } else {       ans += d / k * k1;       d %= k;       ans += min(t + d * a, d * b);     }     printf( %I64d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long INF = 2e9 + 10, MAX = 2100, MOD = 1e9 + 7, MAXL = 25;   void OUT(long double o, int x) {     cout << fixed << setprecision(x) << o;     return;   }   long long dp[MAX][MAX], ra[MAX], a[MAX], re[200000], w[MAX];   vector<int> v[MAX];   pair<long long, long long> c[MAX];   set<int> st;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int n, m, t;     cin >> n >> m >> t;     for (int i = 1; i <= m; i++) {       int l, r;       cin >> l >> r;       for (int j = l + 1; j <= r; j++) ra[j] = 1;     }     for (int i = 1; i <= t; i++) {       cin >> c[i].first >> c[i].second;       st.insert(c[i].second);     }     int cnt = 0;     for (int i = 1; i <= 2000; i++) w[i] = INF;     for (int u : st) {       re[u] = ++cnt;       w[cnt] = u;     }     for (int i = 1; i <= t; i++) v[c[i].first].push_back(re[c[i].second]);     for (int i = 1; i <= 2000; i++) dp[0][i] = INF;     for (int u : v[0]) dp[0][u] = 0;     for (int i = 1; i <= n; i++) {       long long mi = INF;       for (int j = 1; j <= 2000; j++) mi = min(mi, dp[i - 1][j] + w[j]);       if (!ra[i]) mi = min(mi, dp[i - 1][0]);       dp[i][0] = mi;       for (int j = 1; j <= 2000; j++) dp[i][j] = dp[i - 1][j] + w[j];       for (int u : v[i]) dp[i][u] = min(dp[i][u], mi);     }     long long ans = INF;     for (int i = 0; i <= 2000; i++) ans = min(ans, dp[n][i]);     if (ans < INF)       cout << ans;     else       cout << -1;     return 0;   }
#include<bits/stdc++.h>    using namespace std;   namespace Ruri{       #define ms(a,b) memset(a,b,sizeof(a))       #define repi(i,a,b) for(int i=a,bbb=b;i<=bbb;++i)//attention reg int or reg ll ?       #define repd(i,a,b) for(int i=a,bbb=b;i>=bbb;--i)       #define reps(s) for(int i=head[s],v=e[i].to;i;i=e[i].nxt,v=e[i].to)       #define ce(i,r) i==r?  n :          #define pb push_back        #define all(x) x.begin(),x.end()       #define gmn(a,b) a=min(a,b)       #define gmx(a,b) a=max(a,b)       #define fi first       #define se second                                typedef long long ll;       typedef unsigned long long ull;       typedef double db;       const int infi=1e9;//infi较大，注意涉及inf相加时爆int       const ll infl=4e18;       inline ll ceil_div(ll a,ll b){ return (a+b-1)/b; }       inline ll pos_mod(ll a,ll b){ return (a%b+b)%b; }       //std::mt19937 rnd(time(0));//std::mt19937_64 rnd(time(0));   }   using namespace Ruri;   namespace Read{       #define ss(a) scanf( %s ,a)       inline int ri(){ int x; scanf( %d ,&x); return x; }       inline ll rl(){ ll x;  scanf( %lld ,&x); return x; }       inline db rd(){ db x; scanf( %lf ,&x); return x; }   }   namespace DeBug{       #define pr(x) cout<<#x<< :  <<(x)<<endl       #define pra(x,a,b) cout<<#x<< :  <<endl;                repi(i,a,b) cout<<x[i]<<   ;                    puts(  );          #define FR(a) freopen(a, r ,stdin)       #define FO(a) freopen(a, w ,stdout)   }   using namespace Read;   using namespace DeBug;   const int MAX_N=105;   const int mod=1e9+7;   inline void Add(int &x,int y){ x+=y;if(x>=mod) x-=mod; }   int n,b[MAX_N],c[MAX_N];   int sb[MAX_N];   int f[MAX_N*MAX_N],g[MAX_N*MAX_N];   map<int,int> ans;   int Solve(int x)   {    repi(i,0,10001) g[i]=1;    repi(i,1,n){     int lim=i*x+sb[i];     ms(f,0);     for(int j=max(0,lim);j<=10001;++j) f[j]=(g[j]-(j-c[i]-1>=0?g[j-c[i]-1]:0)+mod)%mod;     ms(g,0),g[0]=f[0];     for(int j=1;j<=10001;++j) g[j]=(1ll*g[j-1]+f[j])%mod;    }    return g[10001];   }   int main()   {    n=ri();    int prod=1;    repi(i,1,n) c[i]=ri(),prod=1ll*prod*(c[i]+1)%mod;    repi(i,1,n-1) b[i]=ri();    repi(i,1,n)repi(j,1,i-1) sb[i]+=(i-j)*b[j];    int l=0,r=infi,mx_c=*max_element(c+1,c+n+1);    repi(i,1,n) gmn(l,-((sb[i]-1)/i+1)),gmn(r,(n*mx_c-sb[i]-1)/i+1);    repi(i,l,r) ans[i]=Solve(i);    int Q=ri();    while(Q--)    {     int x=ri();     if(x>r) puts( 0 );     else if(x<l) printf( %d n ,prod);     else printf( %d n ,ans[x]);    }       return 0;   }
#include <bits/stdc++.h>   using namespace std;   int blk_size;   struct node {     int l, r, id;     long long int ans = 0;   };   bool compare(node a, node b) {     if (a.l / blk_size != b.l / blk_size)       return (a.l) / blk_size < (b.l) / blk_size;     return a.r < b.r;   }   bool compare2(node a, node b) { return a.id < b.id; }   long long int freq[3000001];   int main() {     ios_base::sync_with_stdio(false);     ;     int n, m, k;     cin >> n >> m >> k;     std::vector<int> a(n), pxor(n + 1);     for (int i = 0; i < n; i++) cin >> a[i];     pxor[0] = 0;     for (int i = 1; i <= n; i++) pxor[i] = pxor[i - 1] ^ a[i - 1];     blk_size = sqrt(n + 1);     std::vector<node> q(m);     for (int i = 0; i < m; i++) {       cin >> q[i].l >> q[i].r;       q[i].id = i;     }     sort(q.begin(), q.end(), compare);     int start = 0, end = 0;     long long int ans = 0;     freq[0] = 1;     for (int i = 0; i < m; i++) {       int l = q[i].l - 1, r = q[i].r;       while (start > l) {         start--;         ans += freq[pxor[start] ^ k];         freq[pxor[start]]++;       }       while (start < l) {         freq[pxor[start]]--;         ans -= freq[pxor[start] ^ k];         start++;       }       while (end > r) {         freq[pxor[end]]--;         ans -= freq[pxor[end] ^ k];         end--;       }       while (end < r) {         end++;         ans += freq[pxor[end] ^ k];         freq[pxor[end]]++;       }       q[i].ans = ans;     }     sort(q.begin(), q.end(), compare2);     for (int i = 0; i < m; i++) cout << q[i].ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     for (int i = n, p = 1; i - 1; i >>= 1, p <<= 1) {       for (int j = 0; j < (i + 1) / 2; j++) cout << p <<    ;       if (n % p) n -= p / 2;     }     cout << n;   }
#include <bits/stdc++.h>   using namespace std;   bool flag = 0;   void dfs(int u, vector<vector<int> > &g, vector<int> &mark, string &order) {     mark[u] = 1;     for (auto to : g[u]) {       if (mark[to] == 1)         flag = 1;       else if (mark[to] == 0)         dfs(to, g, mark, order);     }     order.push_back( a  + u);     mark[u] = 2;   }   int main() {     ios::sync_with_stdio(0);     int n;     cin >> n;     vector<string> a(n);     for (int i = 0; i < n; i++) cin >> a[i];     vector<vector<int> > g(26);     for (int i = 0; i < n - 1; i++) {       int size = min((int((a[i]).size())), (int((a[i + 1]).size()))), j;       for (j = 0; j < size; j++)         if (a[i][j] != a[i + 1][j]) break;       if (j < size)         g[a[i][j] -  a ].push_back(a[i + 1][j] -  a );       else if ((int((a[i]).size())) > (int((a[i + 1]).size())))         flag = 1;     }     vector<int> mark(26);     string order;     for (int i = 0; i < 26; i++)       if (mark[i] == 0) dfs(i, g, mark, order);     if (flag) {       cout <<  Impossible n ;     } else {       reverse(order.begin(), order.end());       cout << order <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int a[105], ma = 0, mi = 110, maxi, mini, tc;     cin >> tc;     for (int i = 0; i < tc; i++) {       cin >> a[i];       if (a[i] > ma) {         ma = a[i];         maxi = i;       }       if (a[i] <= mi) {         mi = a[i];         mini = i;       }     }     if (maxi > mini) {       mini++;     }     cout << maxi + (tc - 1) - mini << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     char c;     int n, b = 0, a = 0;     cin >> n;     while (n > 0) {       cin >> c;       if (c ==  A )         a++;       else         b++;       n--;     }     if (a > b)       cout <<  Anton ;     else if (a < b)       cout <<  Danik ;     else       cout <<  Friendship ;     return 0;   }