malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   void solve() {     int n, i, j;     cin >> n;     int arr[n], locked[n];     for (i = 0; i < n; i++) cin >> arr[i];     for (i = 0; i < n; i++) cin >> locked[i];     vector<int> unlocked;     for (i = 0; i < n; i++)       if (!locked[i]) unlocked.push_back(arr[i]);     sort(unlocked.begin(), unlocked.end());     j = unlocked.size() - 1;     for (i = 0; i < n; i++) {       if (!locked[i]) arr[i] = unlocked[j--];     }     for (i = 0; i < n; i++) cout << arr[i] <<    ;     cout << endl;   }   int main() {     int t;     cin >> t;     while (t--) solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m, i;     cin >> n >> m;     int a[n], b[m];     for (i = 0; i < n; i++) cin >> a[i];     for (i = 0; i < m; i++) cin >> b[i];     sort(b, b + m);     for (i = 0; i < n; i++)       if (binary_search(b, b + m, a[i])) cout << a[i] <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 1e9 + 7;   long long power(long long base, long long expo, long long md = mod) {     if (base == 0) return 0;     long long res = 1;     base %= md;     while (expo > 0) {       if (expo & 1) {         res = res * base;         res %= md;       }       expo >>= 1;       base = (base * base) % md;     }     return res;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long tt = 1;     for (long long tc = 1; tc <= tt; tc++) {       long long x, d;       cin >> x >> d;       bitset<69> bit(x);       vector<long long> v;       for (long long i = 0; i < 69; i++) {         if (bit[i]) {           v.push_back(i);         }       }       vector<long long> sol;       long long ins = 1, cnt = 0;       for (auto &xo : v) {         long long times = xo;         cnt++;         while (times--) {           sol.push_back(ins);         }         ins += d;       }       for (long long i = 0; i < cnt; i++) {         sol.push_back(ins);         ins += d;       }       if ((long long)sol.size() > (10000))         cout <<  -1 n ;       else {         cout << sol.size() <<   n ;         for (auto &xo : sol) cout << xo <<    ;         cout <<   n ;       }     }     return 0;   }
#include <iostream>   using namespace std;   int main()   {       long long t;       cin >> t;       while(t--)       {           long long n, s = 0, mx = 0;           cin >> n;           long long a[n + 1];           for(long long i = 1; i <= n; ++i){               cin >> a[i];               s += a[i];               mx = max(mx, a[i]);           }           cout << max((n - 1) * mx, (s + n - 2) / (n - 1) *(n - 1)) - s <<   n ;       }   }
#include <bits/stdc++.h>   using namespace std;   queue<pair<long long, long long> > q;   int32_t trace[5005][5005];   int32_t n, m, t, dp[5005][5005];   vector<pair<long long, long long> > adj[5005];   void solve() {     dp[1][1] = -t - 1;     q.emplace(1, 1);     while (q.size()) {       long long node = q.front().first, cnt = q.front().second;       q.pop();       for (auto i : adj[node]) {         if (dp[i.first][cnt + 1] > dp[node][cnt] + i.second) {           dp[i.first][cnt + 1] = dp[node][cnt] + i.second;           q.emplace(i.first, cnt + 1);           trace[i.first][cnt + 1] = node;         }       }     }   }   signed main() {     cin >> n >> m >> t;     for (long long i = 1; i <= m; i++) {       long long u, v, val;       cin >> u >> v >> val;       adj[u].emplace_back(v, val);     }     solve();     stack<long long> ans;     for (long long i = n; i >= 1; i--) {       if (dp[n][i] < 0) {         cout << i << endl;         long long tr = n;         while (i > 0) {           ans.push(tr);           tr = trace[tr][i];           i--;         }       }     }     while (ans.size()) {       cout << ans.top() <<    ;       ans.pop();     }   }
#include <bits/stdc++.h>   using namespace std;   int n, flag;   int a[100005], b[100005], t[100005];   int main() {     cin >> n;     for (int i = 1; i <= n - 1; i++) cin >> a[i];     for (int i = 1; i <= n - 1; i++) cin >> b[i];     memset(t, -1, sizeof(t));     for (int i = 0; i <= 3; i++) {       t[1] = i;       int num = 0;       for (int j = 2; j <= n; j++) {         for (int k = 0; k <= 3; k++)           if (((k | t[j - 1]) == a[j - 1]) && ((k & t[j - 1]) == b[j - 1]))             t[j] = k;       }       for (int i = 1; i <= n; i++)         if (t[i] != -1) num++;       if (num == n) break;     }     for (int i = 1; i <= n; i++)       if (t[i] == -1) {         printf( NO );         return 0;       }     printf( YES n );     for (int i = 1; i <= n; i++) printf( %d  , t[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long sz = 2e6 + 5, mod = 1e9 + 9;   long long t, n, m, k, q;   const long long inf = 3e18;   long long dx[] = {1, 0, -1, 0};   long long dy[] = {0, 1, 0, -1};   bool vis[sz];   vector<vector<long long> > gr(sz);   vector<long long> cnt(sz, 0);   void DFS(long long s) {     vis[s] = 1;     for (auto i : gr[s]) {       if (!vis[i]) DFS(i);     }     return;   }   signed main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     t = 1;     while (t--) {       cin >> n >> m;       for (long long i = 0; i < m; i++) {         long long a, b;         cin >> a >> b;         if (a == b) {           cnt[a]++;           continue;         }         gr[a].push_back(b);         gr[b].push_back(a);       }       long long cnt1 = 0;       for (long long i = 1; i <= n; i++) {         cnt1 += cnt[i];       }       long long c = 0;       for (long long i = 1; i <= n; i++) {         if (!vis[i] && gr[i].size())           DFS(i), c++;         else if (!vis[i]) {           if (cnt[i]) c++;         }       }       if (c > 1) {         cout << 0 <<   n ;         return 0;       }       long long ans = 0;       ans += cnt1 * (cnt1 - 1) / 2;       ans += cnt1 * (m - cnt1);       for (long long i = 1; i <= n; i++) {         ans += gr[i].size() * (gr[i].size() - 1) / 2;       }       cout << ans <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool solve(long long n, long long k) {     int r = n % k;     long long turn = n / k;     if (turn % 2 == 1) {       return false;     }     return true;   }   int main() {     long long n, k;     cin >> n >> k;     if (!solve(n, k))       cout <<  YES  << endl;     else       cout <<  NO  << endl;     return 0;   }
#include <bits/stdc++.h>   int main() {     int n;     scanf( %d , &n);     int a[n];     for (int i = 0; i < n; ++i) {       scanf( %d , &a[i]);     }     int temp1, temp2, flag = 0;     for (int i = 0; i < n; ++i) {       temp1 = a[i] - 1;       temp2 = a[temp1] - 1;       if (a[temp2] - 1 == i) {         flag = 1;         printf( YES n );         break;       }     }     if (flag == 0) {       printf( NO n );     }     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize  -O3    using namespace std;   const int MAXN = 2100;   int n, m;   long long a[MAXN];   long long aa[MAXN];   long long b[MAXN];   long long bb[MAXN];   long long x;   int main() {     ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);     cin >> n >> m;     for (int i = 0; i < n; ++i) cin >> a[i];     for (int j = 0; j < m; ++j) cin >> b[j];     cin >> x;     for (int i = 1; i <= n; ++i) aa[i] = x + 1;     for (int i = 1; i <= m; ++i) bb[i] = x + 1;     for (int i = 0; i < n; ++i) {       long long sum = 0;       for (int j = i; j < n; ++j) {         sum += a[j];         aa[j - i + 1] = min(aa[j - i + 1], sum);       }     }     for (int i = 0; i < m; ++i) {       long long sum = 0;       for (int j = i; j < m; ++j) {         sum += b[j];         bb[j - i + 1] = min(bb[j - i + 1], sum);       }     }     int ans = 0;     for (int i = 1; i <= n; ++i)       for (int j = 1; j <= m; ++j) {         if (aa[i] * bb[j] <= x) ans = max(ans, i * j);       }     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:600000000 )   using namespace std;   template <class T>   T sqr(T x) {     return x * x;   }   double const pi = 3.1415926535897932384626433832795;   int const inf = (int)1e9;   long long const inf64 = (long long)4e18;   const string name =  a ;   const int NMAX = 101010;   int n, minyl, maxyl, yy[NMAX], used[NMAX];   double x[NMAX], y[NMAX], zn[NMAX];   pair<double, double> q[NMAX];   pair<double, int> qq[NMAX];   int may(double r) {     memset(used, 0, sizeof(used));     double _max = -1e10, _min = 1e10;     int yl = 0;     minyl = 0, maxyl = n - 1;     for (int i = 0; i < (int)n; i++) {       while (yl < n && x[yl] - x[i] <= 2 * r) {         used[yy[yl]] = 1;         while (maxyl >= 0 && used[maxyl]) maxyl--;         while (minyl < n && used[minyl]) minyl++;         yl++;       }       double tmp_max = _max;       if (maxyl >= 0) tmp_max = max(tmp_max, zn[maxyl]);       double tmp_min = _min;       if (minyl < n) tmp_min = min(tmp_min, zn[minyl]);       if (tmp_max - tmp_min <= 2 * r) return 1;       _max = max(_max, y[i]);       _min = min(_min, y[i]);     }     return 0;   }   int main() {     cin >> n;     for (int i = 0; i < (int)n; i++) {       int xx, yy;       scanf( %d%d , &xx, &yy);       q[i] = make_pair(xx + yy, xx - yy);     }     sort(q, q + n);     for (int i = 0; i < (int)n; i++) {       x[i] = q[i].first, y[i] = q[i].second;       qq[i] = make_pair(y[i], i);     }     sort(qq, qq + n);     for (int i = 0; i < (int)n; i++) zn[i] = qq[i].first, yy[qq[i].second] = i;     double l = 0, r = 1e10;     may(0);     for (int i = 0; i < (int)70; i++) {       double m = (l + r) / 2;       if (may(m))         r = m;       else         l = m;     }     printf( %.10lf n , l);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e5 + 5;   long long factor[maxn], cnt, n, k, num;   void process() {     int m = sqrt(n);     cnt = num = 0;     for (int i = 1; i <= m; i++) {       if (n % i == 0) {         factor[cnt++] = i;         if (n / i != i) factor[cnt++] = n / i;       }     }     sort(factor, factor + cnt);   }   void dfs(long long x, long long m) {     if (num >= 100000) return;     if (m == 0 || x == 1) {       cout << x <<    ;       num++;       return;     }     for (int i = 0; i < cnt && factor[i] <= x; i++) {       if (x % factor[i] == 0) {         dfs(factor[i], m - 1);         if (num >= 100000) return;       }     }   }   int main() {     cin >> n >> k;     process();     dfs(n, k);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxN = 200011;   const int limit = 1000000;   const int maxBit = 20;   long long n, X, Y, i, bts, max_conf;   long long a[maxN];   vector<pair<long long, long long> > divs, divs2, act;   vector<long long> to_check;   vector<long long> A, B;   long long data[1 << maxBit];   long long ans;   void give(long long x) {     cout << x;     exit(0);   }   long long gcd(long long x, long long y) {     if (x < y) swap(x, y);     while (y > 0) {       x %= y;       swap(x, y);     }     return x;   }   void fact(long long x) {     long long i, cnt, aux;     if (Y % X) give(0);     for (i = 2; i * i <= x && i <= limit; i++) {       if (x % i) continue;       cnt = 0;       while (x % i == 0) {         cnt++;         x /= i;       }       divs.push_back(make_pair(i, cnt));     }     if (x == 1) return;     aux = llround(sqrt(x));     if (aux * aux == x) {       divs.push_back(make_pair(aux, 2));       return;     }     to_check.push_back(X);     to_check.push_back(Y);     for (auto e : to_check) {       aux = gcd(e, x);       if (aux == 1 || aux == x) continue;       divs.push_back(make_pair(aux, 1));       divs.push_back(make_pair(x / aux, 1));       return;     }     divs.push_back(make_pair(x, 1));   }   void fact_smart(long long x, vector<pair<long long, long long> >& to) {     long long cnt, aux;     to.clear();     aux = x;     for (auto e : divs) {       cnt = 0;       while (aux % e.first == 0) {         cnt++;         aux /= e.first;       }       to.push_back(make_pair(e.first, cnt));     }   }   void add_elem(long long x) {     long long i, j, cnt, aux;     long long conf, pos = 0;     aux = x;     conf = pos = 0;     for (auto e : divs2) {       cnt = 0;       while (aux % e.first == 0) {         cnt++;         aux /= e.first;       }       if (cnt != e.second && e.second != divs[pos].second) conf |= 1 << pos;       pos++;     }     if (x % X == 0) A.push_back(conf);     aux = x;     conf = pos = 0;     for (auto e : divs) {       cnt = 0;       while (aux % e.first == 0) {         cnt++;         aux /= e.first;       }       if (cnt != e.second && e.second != divs2[pos].second) conf |= 1 << pos;       pos++;     }     if (Y % x == 0) B.push_back(conf);   }   void solve() {     long long i, j;     bts = divs.size();     max_conf = 1 << bts;     for (auto e : A) data[e]++;     for (i = 0; i < bts; i++)       for (j = 0; j < max_conf; j++)         if ((j >> i) & 1) data[j] += data[j ^ (1 << i)];     for (auto e : B) ans += data[(max_conf - 1) ^ e];     give(ans);   }   int main() {     cin >> n >> X >> Y;     for (i = 1; i <= n; i++) cin >> a[i], to_check.push_back(a[i]);     fact(Y);     fact_smart(X, divs2);     for (i = 1; i <= n; i++) add_elem(a[i]);     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, maxi, ans;   int a[200100], g[1001000];   int main() {     cin >> n;     for (int i = 1; i <= n; i++) {       scanf( %d , a + i);       g[a[i]] = a[i];     }     sort(a + 1, a + 1 + n);     maxi = a[n];     for (int i = 1; i <= maxi; i++) {       if (g[i] != i) g[i] = g[i - 1];     }     ans = 0;     for (int i = 1; i <= n; i++) {       if (i > 1 && a[i - 1] == a[i]) continue;       for (int j = a[i] << 1; j <= maxi; j += a[i]) {         ans = max(ans, g[j - 1] % a[i]);       }       ans = max(ans, maxi % a[i]);     }     printf( %d n , ans);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string s;     int n, a;     while (cin >> s >> n) {       a = s.length();       if (a % n != 0)         cout <<  NO  << endl;       else {         int b, c = 0;         b = a / n;         for (int i = 0; i < a; i += b) {           for (int j = 0; j < b / 2; j++) {             if (s[i + j] != s[i + b - j - 1]) {               c = 1;               break;             }           }           if (c == 1) break;         }         if (c == 1)           cout <<  NO  << endl;         else           cout <<  YES  << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long ans, f[300005];   ;   vector<pair<int, int> > adj[300005];   int w[300005];   void dfs(int v, int fa) {     f[v] = w[v];     ans = max(ans, 1ll * w[v]);     for (auto i : adj[v]) {       if (i.first != fa) {         dfs(i.first, v);         ans = max(ans, f[v] + f[i.first] - i.second);         f[v] = max(f[v], w[v] + f[i.first] - i.second);       }     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     int n, x, y, z;     cin >> n;     for (int i = 0; i < n; i++) cin >> w[i + 1];     for (int i = 0; i < n - 1; i++) {       cin >> x >> y >> z;       adj[x].push_back({y, z});       adj[y].push_back({x, z});     }     dfs(1, 0);     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string s;     cin >> s;     vector<int> v(7, 0);     for (int i = 0; i < s.size(); i++) {       if (s[i] ==  B )         v[0]++;       else if (s[i] ==  u )         v[1]++;       else if (s[i] ==  l )         v[2]++;       else if (s[i] ==  b )         v[3]++;       else if (s[i] ==  a )         v[4]++;       else if (s[i] ==  s )         v[5]++;       else if (s[i] ==  r )         v[6]++;     }     int min1, min2;     min1 = min(v[1], v[4]);     min1 /= 2;     min2 = *min_element(v.begin(), v.end());     if (min1 > min2)       cout << min2 << endl;     else       cout << min1 << endl;   }
#include <bits/stdc++.h>   using namespace std;   vector<long long> nclaws(2000001, 0);   void solve() {     int n;     cin >> n;     cout << ((nclaws[n] * 4) % 1000000007) << endl;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     nclaws[1] = 0;     nclaws[2] = 0;     nclaws[3] = 1;     nclaws[4] = 1;     for (int i = 5; i < 2000001; i++) {       nclaws[i] = nclaws[i - 1] + 2 * nclaws[i - 2];       if (i % 3 == 0) nclaws[i]++;       nclaws[i] = nclaws[i] % 1000000007;     }     int t = 1;     cin >> t;     while (t--) solve();   }
#include <bits/stdc++.h>   using namespace std;   const int N = 100000, M = 10, pw[5] = {1, 10, 100, 1000, 10000};   const unsigned long long mod = 1ULL << 58, inv = 6723469279985657373ULL;   struct comp {     unsigned long long a[4];     comp(int X = 0) {       a[0] = X;       a[1] = a[2] = a[3] = 0;     }     unsigned long long &operator[](const int &p) { return a[p]; }     comp operator+(const comp &p) const {       comp res;       for (int i = 0; i < 4; ++i) res.a[i] = a[i] + p.a[i];       return res;     }     comp operator-(const comp &p) const {       comp res;       for (int i = 0; i < 4; ++i) res.a[i] = a[i] - p.a[i];       return res;     }     comp operator*(const unsigned long long &p) const {       comp res;       for (int i = 0; i < 4; ++i) res.a[i] = a[i] * p;       return res;     }     comp operator*(const comp &p) const {       comp res;       static unsigned long long tmp[7];       for (int i = 0; i < 7; ++i) tmp[i] = 0;       for (int i = 0; i < 4; ++i)         for (int j = 0; j < 4; ++j) tmp[i + j] += a[i] * p.a[j];       for (int i = 2; i >= 0; --i) {         for (int j = 0; j < 4; ++j) tmp[i + j] -= tmp[i + 4];         tmp[i + 4] = 0;       }       for (int i = 0; i < 4; ++i) res.a[i] = tmp[i];       return res;     }   };   comp Power(comp a, int k) {     comp res(1);     for (; k; k >>= 1, a = a * a)       if (k & 1) res = res * a;     return res;   }   comp wn[M + 9];   void Get_wn() {     wn[0][0] = wn[M][0] = 1;     wn[1][3] = -1;     for (int i = 1; i < M; ++i) wn[i] = wn[i - 1] * wn[1];   }   int gg = 0;   void DFT(comp *a, int t) {     static comp dft[M];     for (int d = 0; d < 5; ++d) {       for (int i = 0; i < N; ++i) {         if (i / pw[d] % M) continue;         for (int j = 0; j < M; ++j) dft[j] = 0;         for (int j = 0; j < M; ++j)           for (int k = 0; k < M; ++k)             dft[j] =                 dft[j] + a[i + k * pw[d]] * wn[t ? M - j * k % M : j * k % M];         for (int j = 0; j < M; ++j) a[i + j * pw[d]] = dft[j];       }     }     if (!t) return;     for (int i = 0; i < N; ++i) a[i] = a[i] * inv;   }   int n;   comp a[N + 9];   void into() {     scanf( %d , &n);     for (int i = 1; i <= n; ++i) {       int x;       scanf( %d , &x);       ++a[x][0];     }   }   void Get_ans() {     DFT(a, 0);     for (int i = 0; i < N; ++i) a[i] = Power(a[i], n);     DFT(a, 1);   }   void work() {     Get_wn();     Get_ans();   }   void outo() {     for (int i = 0; i < n; ++i) printf( %llu n , a[i][0] >> 5 & mod - 1);   }   int main() {     into();     work();     outo();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2000000 + 10;   int n, h, m, x, t, d, c;   vector<int> v;   int main() {     scanf( %d%d%d%d%d%d , &h, &m, &t, &d, &c, &n);     double need = (t + n - 1) / n * c;     if (m != 0 && h < 20) {       t += (60 - m) % 60 * d;       h = (h + 1) % 24;     }     if (h < 20) {       t += (60 * (20 - h)) * d;     }     double y = (t + n - 1) / n * (c * 0.8);     printf( %0.5f n , min(need, y));     return 0;   }
#include<bits/stdc++.h>   #define LL long long   #define ULL unsigned long long   #define P pair<int,int>   #define PI acos(-1.0)   #define ls o<<1   #define rs o<<1|1   using namespace std;        const int mod=1e9+7;   const int base=19260817;   const LL INF=1e18;   const int maxn=2e5+10;   const double eps=1e-8;   int add(int x,int y){ x+=y;return x>=mod?x-mod:x; }   int sub(int x,int y){ x-=y;return x<0?x+mod:x; }   int mul(int x,int y){ return 1LL*x*y%mod; }      typedef pair<LL,int> pli;   int n,m;   LL d[maxn<<2];   bool vis[maxn<<2];   vector<P> g[maxn<<2];      void dijkstra(int n,int s)   {       priority_queue<pli,vector<pli>,greater<pli>> q;       for(int i=1;i<=n;i++) d[i]=INF,vis[i]=0;       d[s]=0,q.push(pli{0,s});       while(!q.empty()){           pli x=q.top();q.pop();           int u=x.second;           if(vis[u]) continue;           vis[u]=1;           for(auto e:g[u]){               int v=e.first,w=e.second;               if(d[u]+w<d[v]){                   d[v]=d[u]+w;                   q.push(pli{d[v],v});               }           }       }   }      inline void addedge(int u,int v,int w,int p,int q)   {       g[u+p*n].push_back(P{v+q*n,w});       g[v+p*n].push_back(P{u+q*n,w});   }      int main()   {   #ifdef LOCAL       freopen( test.in , r ,stdin);   #endif       ios::sync_with_stdio(false);cin.tie(0);       cin>>n>>m;       for(int i=1;i<=m;i++){           int u,v,w;cin>>u>>v>>w;           addedge(u,v,w,0,0);           addedge(u,v,w,1,1);           addedge(u,v,w,2,2);           addedge(u,v,w,3,3);           addedge(u,v,0,0,1);           addedge(u,v,0,2,3);           addedge(u,v,2*w,0,2);           addedge(u,v,2*w,1,3);       }       dijkstra(n<<2,1);       for(auto e:g[1]){           int v=e.first,w=e.second;           if(v<=n) d[v+3*n]=min(d[v+3*n],1LL*w);       }       for(int i=2;i<=n;i++) cout<<d[i+3*n]<<   ;       return 0;      }
#include <bits/stdc++.h>   int main() {     long long n, k, f[10005], t[10005], i, j, s = -1000000005, g = -1000000005, r;     scanf( %lld %lld , &n, &k);     for (i = 0; i < n; i++) {       scanf( %lld %lld , &f[i], &t[i]);     }     for (j = 0; j < n; j++) {       if (t[j] > k) {         r = f[j] - (t[j] - k);         if (r > s) s = r;       } else if (t[j] <= k) {         if (f[j] > g) g = f[j];       }     }     if (g > s)       printf( %lld , g);     else if (s >= g)       printf( %lld , s);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long a1, a2, a3, a4;     cin >> a1 >> a2 >> a3 >> a4;     long long total = 0;     long long minn = min(a1, a3);     minn = min(minn, a4);     total += 256 * minn;     a1 -= minn;     minn = min(a1, a2);     total += 32 * minn;     cout << total << endl;   }
#include <bits/stdc++.h>   using namespace std;   int ans[100009];   int cmp(int a, int b) { return a <= b; }   int main() {     int n;     while (scanf( %d , &n) != EOF) {       for (int i = 0; i < n; i++) scanf( %d , &ans[i]);       sort(ans, ans + n);       int vaule = 0;       for (int i = 0; i < n; i++) {         if (ans[i] > vaule) vaule++;       }       printf( %d n , vaule + 1);     }     return 0;   }
#include <iostream>   #include <algorithm>   #include <cstring>   #include <string>   #include <queue>   typedef long long ll;   using namespace std;         int main()    {    // what is greedy?    int T;    cin >> T;    while (T--) {     int len, a, b;     cin >> len >> a >> b;     string s;     cin >> s;     if (b > 0)       cout << (a + b) * len << endl;     else {      // 尽量连续      char ch = s[0];      int arr[5] = { 0, 0, 0, 0, 0 };      for (int i = 0; i < len; i++) {       if (s[i] != ch) {        arr[ch -  0 ]++;        ch = s[i];       }      }      // cout << s[len - 1] -  0  << endl;      arr[s[len - 1] -  0 ]++;      // cout <<  arr[0] ==   << arr[0] << endl;      // cout <<  arr[1] ==   << arr[1] << endl;      int minEle = arr[0] < arr[1] ? arr[0] : arr[1];      cout << a * len + (minEle + 1) * b << endl;     }     // if (a <= 0 && b <= 0) {     //  // 尽量连续     //  char ch = s[0];     //  int arr[5] = { 0, 0, 0, 0, 0 };     //  for (int i = 0; i < len; i++) {     //   if (s[i] != ch) {     //    arr[ch -  0 ]++;     //    ch = s[i];     //   }     //  }     //  int minEle = arr[0] < arr[1] ? arr[0] : arr[1];     //  cout << a * len + (minEle + 1) * b << endl;     // } else if (a <= 0 && b > 0) {     //  // 一个一个弄     //  cout << (a + b) * len << endl;     // } else if (a >= 0 && b <= 0) {     //  // 尽量连续     //  char ch = s[0];     //  int arr[5] = { 0, 0, 0, 0, 0 };     //  for (int i = 0; i < len; i++) {     //   if (s[i] != ch) {     //    arr[ch -  0 ]++;     //    ch = s[i];     //   }     //  }     //  int minEle = arr[0] < arr[1] ? arr[0] : arr[1];     //  cout << a * len + (minEle + 1) * b << endl;     // } else if (a >= 0 && b > 0) {     //  // 一个一个弄     //  cout << (a + b) * len << endl;     // }    }       return 0;   }