malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int P = 1e9 + 7, INF = 0x3f3f3f3f;   long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }   long long qpow(long long a, long long n) {     long long r = 1 % P;     for (a %= P; n; a = a * a % P, n >>= 1)       if (n & 1) r = r * a % P;     return r;   }   long long inv(long long first) {     return first <= 1 ? 1 : inv(P % first) * (P - P / first) % P;   }   inline int rd() {     int first = 0;     char p = getchar();     while (p <  0  || p >  9 ) p = getchar();     while (p >=  0  && p <=  9 ) first = first * 10 + p -  0 , p = getchar();     return first;   }   const int N = 1e6 + 10;   int n, m, k, a[N], deg1[N], deg2[N];   int L[N], R[N], vis[N];   int first[N], second[N], b[N];   vector<int> g1[N], g2[N];   int main() {     scanf( %d%d%d , &n, &m, &k);     for (int i = 1; i <= n; ++i) {       scanf( %d , a + i);       if (a[i])         L[i] = R[i] = a[i];       else         L[i] = 1, R[i] = k;     }     for (int i = 1; i <= m; ++i) {       scanf( %d%d , first + i, second + i);       g2[first[i]].push_back(second[i]), ++deg2[second[i]];       g1[second[i]].push_back(first[i]), ++deg1[first[i]];     }     queue<int> q;     for (int i = 1; i <= n; ++i)       if (!deg1[i]) q.push(i);     int cnt = 0;     while (q.size()) {       int u = q.front();       q.pop();       if (L[u] > R[u]) return puts( -1 ), 0;       ++cnt;       for (auto &v : g1[u]) {         L[v] = max(L[v], L[u] + 1);         if (!--deg1[v]) q.push(v);       }     }     if (cnt != n) return puts( -1 ), 0;     for (int i = 1; i <= n; ++i)       if (!deg2[i]) q.push(i);     while (q.size()) {       int u = q.front();       q.pop();       if (L[u] > R[u]) return puts( -1 ), 0;       for (auto &v : g2[u]) {         R[v] = min(R[v], R[u] - 1);         if (!--deg2[v]) q.push(v);       }     }     for (int i = 1; i <= n; ++i) b[i] = i;     sort(b + 1, b + 1 + n, [](int a, int b) { return L[a] < L[b]; });     int now = 1;     set<pair<int, int> > s;     for (int i = 1; i <= k; ++i) {       while (now <= n && L[b[now]] <= i) {         s.insert(pair<int, int>(R[b[now]], b[now]));         ++now;       }       int ok = 0;       while (s.size()) {         int id = s.begin()->second;         if (ok && R[id] > i) break;         ok = 1;         s.erase(s.begin());         a[id] = i;       }       if (!ok) return puts( -1 ), 0;     }     for (int i = 1; i <= n; ++i) printf( %d  , a[i] ? a[i] : L[i]);     putchar(10);   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 5;   const int M = 22;   int n, a[N];   long long f[N][M][2];   vector<int> v[N];   long long ans = 0;   void dfs(int x, int tr) {     ans += a[x];     for (int i = 0; i < M; i++) {       f[x][i][(a[x] >> i) & 1]++;     }     for (auto u : v[x])       if (u != tr) {         dfs(u, x);         for (int i = 0; i < M; i++) {           ans += (1 << i) * (f[x][i][0] * f[u][i][1] + f[x][i][1] * f[u][i][0]);           f[x][i][((a[x] >> i) & 1) ^ 0] += f[u][i][0];           f[x][i][((a[x] >> i) & 1) ^ 1] += f[u][i][1];         }       }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> a[i];     }     for (int i = 1; i < n; i++) {       int x, y;       cin >> x >> y;       v[x].push_back(y);       v[y].push_back(x);     }     dfs(1, 0);     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int DIM = 1005;   bitset<DIM> oki;   int val[DIM], nxt[DIM];   int main(void) {     ios ::sync_with_stdio(false);     cin.tie();     cout.tie();     int n, m, ans = 0;     cin >> n >> m;     for (int i = 1; i <= n; ++i) cin >> val[i], nxt[i] = -1;     for (int i = 1; i <= m; ++i) {       int x;       cin >> x;       for (int j = 1; j <= n; ++j)         if (nxt[x] < nxt[j]) ans += val[j];       nxt[x] = i;     }     cout << ans << endl;     return 0;   }
// Author: wlzhouzhuan   #pragma GCC optimize( Ofast )   #pragma GCC target( avx )   #include <bits/stdc++.h>   using namespace std;      #define ull unsigned long long       namespace IO {     const int SIZE = 1 << 23;     char ibuf[SIZE], *iS, *iT;     char obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1;     bool flush() {       fwrite(obuf, 1, oS - obuf, stdout);       oS = obuf;       return true;     }     #define gc() (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin), (iS == iT ? EOF : *iS++)) : *iS++)     #define pc(x) (*oS++ = x)      int read() {       int x = 0, f = 0;       char c = gc();       while (!isdigit(c)) f |= c ==  - , c = gc();       while (isdigit(c)) x = 10 * x + c -  0 , c = gc();       return f ? -x : x;     }     char qu[55]; int qlen;     template <class T> void print(T x) {       if (!x) pc( 0 );       if (x < 0) pc( - ), x = -x;       while (x) qu[++qlen] = x % 10 +  0 , x /= 10;       while (qlen) pc(qu[qlen--]);     }     template <class T> void print(T x, char charset) {       print(x), pc(charset);     }     struct Flusher {       ~Flusher() {         flush();       }     } flusher;   }   using namespace IO;      const int N = 1005;   const int mod = 998244353;      int qpow(int a, int b = mod - 2) {     int res = 1;     while (b > 0) {       if (b & 1) res = 1ll * res * a % mod;       a = 1ll * a * a % mod;       b >>= 1;     }     return res;   }      ull mul(ull a, ull b) {     return (static_cast<unsigned long long>(a) * b) % mod;   }   int a[N], m, n;   ull fz = 1, sumfz = 0, fm = 1, ans = 0;   int j = 0;   void run(int t) {     for (; j < t; j++) {       fz = mul(fz, 2 * n - j);       sumfz = mul(sumfz, (n - j)) + fz;       fm = mul(fm, n - j);     }   }   int main() {     m = read();     for (int i = 1; i <= m; i++) {       a[i] = read(), n += a[i];     }     sort(a + 1, a + m + 1);     for (int i = 1; i <= m; i++) {       run(a[i]);       ans = (ans + mul(sumfz, qpow(fm))) % mod;     }     run(n);     ans = (ans + mod - mul(sumfz, qpow(fm))) % mod;     print((mod - ans) % mod,   n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m;     cin >> n >> m;     if (n > m) swap(m, n);     long long cc = 0;     for (int i = 1; i <= n; i++) {       cc += (m + i) / 5 - i / 5;     }     cout << cc << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     char c[101];     int count = 0;     int sum = 0;     while (cin.getline(c, 101)) {       if (c[0] ==  + ) {         count++;         continue;       }       if (c[0] ==  - ) {         count--;         continue;       }       int x = 0;       for (; c[x] !=  : ; x++) {       }       sum += (strlen(c) - (x + 1)) * count;     }     cout << sum;   }
#include <bits/stdc++.h>   using namespace std;   void __print(int x) { cerr << x; }   void __print(long x) { cerr << x; }   void __print(long long x) { cerr << x; }   void __print(unsigned x) { cerr << x; }   void __print(unsigned long x) { cerr << x; }   void __print(unsigned long long x) { cerr << x; }   void __print(float x) { cerr << x; }   void __print(double x) { cerr << x; }   void __print(long double x) { cerr << x; }   void __print(char x) { cerr <<      << x <<     ; }   void __print(const char *x) { cerr <<     << x <<    ; }   void __print(const string &x) { cerr <<     << x <<    ; }   void __print(bool x) { cerr << (x ?  true  :  false ); }   template <typename T, typename V>   void __print(const pair<T, V> &x) {     cerr <<  { ;     __print(x.first);     cerr <<  , ;     __print(x.second);     cerr <<  } ;   }   template <typename T>   void __print(const T &x) {     int f = 0;     cerr <<  { ;     for (auto &i : x) cerr << (f++ ?  ,  :   ), __print(i);     cerr <<  } ;   }   void _print() { cerr <<  ] n ; }   template <typename T, typename... V>   void _print(T t, V... v) {     __print(t);     if (sizeof...(v)) cerr <<  ,  ;     _print(v...);   }   const int SIZE = 2e5 + 5;   const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};   const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};   void fastio() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);   }   void solveTest() {     long long n, m;     cin >> n >> m;     --m;     vector<long long> a(n);     long long mn = INT_MAX;     for (int i = 0; i < n; i++) {       cin >> a[i];       mn = min(mn, a[i]);     }     for (int i = 0; i < n; i++) {       a[i] -= mn;     }     long long cnt = (1ll * mn) * n;     while (a[m] != 0) {       a[m]--;       cnt++;       if (m == 0)         m = n - 1;       else         m--;     }     a[m] = cnt;     for (int i = 0; i < n; i++) {       cout << a[i] <<    ;     }     return;   }   int main() {     fastio();     int t = 1;     while (t--) {       solveTest();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, k;   int log2(long long x) {     int ret = 0;     while (x > 0) {       x /= 2;       ret++;     }     return ret;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     clock_t ck;     ck = clock();     cin >> n >> k;     if (k == 1) {       cout << n <<   n ;       return 0;     }     int exp = log2(n);     cout << (1ll << exp) - 1 <<   n ;     ck = clock() - ck;     cerr <<  It took   << 1.0 * ck / CLOCKS_PER_SEC <<   sec n ;     return 0;   }
#include<bits/stdc++.h>   using namespace std;      int n;   inline int lst(int i){return i==1?n:i-1;}   inline int nxt(int i){return i==n?1:i+1;}   inline int lst(int i,int d){return (((i-d-1)%n+n)%n+1);}   inline int nxt(int i,int d){return ((i+d-1)%n+1);}      inline int getval(){    fflush(stdout);    int val;    scanf( %d ,&val);    return val;   }   inline int curval(int i){    printf( ? %d n n ,i);    return getval();   }   inline int lstval(int i){    printf( ? %d n n ,lst(i));    return getval();   }   inline int nxtval(int i){    printf( ? %d n n ,nxt(i));    return getval();   }      int k;   int a[200],b[200];      inline void ansis(int ans)   {    printf( ! %d n ,ans);    exit(0);   }   inline void findit(int pos,int val,int len)   {    if (val>k){     int lef=1,rig=len,mid;     while (lef<=rig){      mid=((lef+rig)>>1);      int curpos=lst(pos,mid);      int cur=curval(curpos);      if (cur==k) ansis(curpos);      if (cur>k) lef=mid+1; else rig=mid-1;     }    }else{     int lef=1,rig=len,mid;     while (lef<=rig){      mid=((lef+rig)>>1);      int curpos=nxt(pos,mid);      int cur=curval(curpos);      if (cur==k) ansis(curpos);      if (cur<k) lef=mid+1; else rig=mid-1;     }    }   }   int main()   {    scanf( %d%d ,&n,&k);    curval(1);    int pos=1;    for (int t=1;t<=950;t+=2){     int val1=curval(pos);     if (val1!=k) {      findit(pos,val1,t);      return 0;     }     int val2=nxtval(pos);     if (val2!=k) {      findit(nxt(pos),val2,t+1);      return 0;     }     pos=nxt(pos,t*2+1);    }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 100000 + 77;   int n, q;   long long a[N];   vector<long long> V, Ps;   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; ++i) scanf( %lld , a + i);     if (n == 1) {       int q;       scanf( %d , &q);       long long x, y;       while (q--) {         scanf( %lld %lld , &x, &y);         x = y - x + 1;         printf( %lld  , x);       }       return 0;     }     sort(a + 1, a + 1 + n);     for (int i = 2; i <= n; ++i) V.push_back(a[i] - a[i - 1]);     sort(V.begin(), V.end());     Ps.push_back(V[0]);     for (int i = 3; i <= n; ++i) Ps.push_back(Ps.back() + V[i - 2]);     int sz = V.size();     scanf( %d , &q);     while (q--) {       long long x, y;       scanf( %lld %lld , &x, &y);       x = y - x + 1;       int id = upper_bound(V.begin(), V.end(), x - 1) - V.begin() - 1;       long long A = 0;       if (id == -1) {         A = n * x;       } else {         A = (n - id - 1) * x + Ps[id];       }       printf( %lld  , A);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> prefix_function(string s) {     int n = (int)s.length();     vector<int> pi(n);     for (int i = 1; i < n; ++i) {       int j = pi[i - 1];       while (j > 0 && s[i] != s[j]) j = pi[j - 1];       if (s[i] == s[j]) ++j;       pi[i] = j;     }     return pi;   }   int main() {     int t, n, x = 0;     cin >> t >> n;     string s;     cin >> s;     cout << s;     vector<int> v = prefix_function(s);     s = s.substr(v[v.size() - 1], s.size() - v[v.size() - 1]);     for (int i = 1; i < n; i++) {       cout << s;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long a, b;     cin >> a >> b;     long long d = abs(a - b);     long long p1 = (d + 1) / 2, p2 = d / 2;     long long s1 = (p1 * (p1 + 1)) / 2, s2 = (p2 * (p2 + 1)) / 2;     cout << s1 + s2;   }
#include <bits/stdc++.h>   using namespace std;   int n, q;   int a[200010];   int last[200010];   int x = -1, y = -1, z = -1;   stack<int> t;   int main() {     scanf( %d%d , &n, &q);     for (int i = 0; i < n; i++) {       scanf( %d , &a[i]);       if (a[i] == 0) {         z = i;         if (i) a[i] = a[i - 1];       } else {         if (x == -1) x = i;         if (a[i] == q) y = i;       }     }     if (x == -1) {       cout <<  YES  << endl;       for (int i = 0; i < n; i++) cout << q <<    ;       return 0;     }     for (int i = x - 1; i >= 0; i--) a[i] = a[i + 1];     if (y == -1) {       if (z == -1) {         cout <<  NO  << endl;         return 0;       }       a[z] = q;     }     for (int i = 0; i < n; i++) last[a[i]] = i;     for (int i = 0; i < n; i++) {       if (!t.empty() && t.top() > a[i]) {         cout <<  NO  << endl;         return 0;       } else if (t.empty() || t.top() < a[i])         t.push(a[i]);       if (last[a[i]] == i) t.pop();     }     cout <<  YES  << endl;     for (int i = 0; i < n; i++) cout << a[i] <<    ;     return 0;   }
#include <bits/stdc++.h>   char c[99];   int i, x;   int main() {     for (;;) {       scanf( %s , c);       fflush(stdout);       ;       if (*c ==  e ) break;       for (i = 2; i <= 1 << 30; i <<= 1) {         printf( ? %d %d n , i, i >> 1);         fflush(stdout);         ;         scanf( %s , c);         fflush(stdout);         ;         if (*c ==  y  || i == 1 << 30) break;       }       if (*c ==  x ) {         puts( ! 1 );         fflush(stdout);         ;         continue;       }       int l = i >> 1, r = i, m;       for (; l + 1 < r;) {         m = (l + r) >> 1;         printf( ? %d %d n , l, m);         fflush(stdout);         ;         scanf( %s , c);         fflush(stdout);         ;         if (*c ==  y )           l = m;         else           r = m;       }       printf( ! %d n , r);       fflush(stdout);       ;     }     return 0;   }
#include <bits/stdc++.h>   const int maxn = 1e5 + 500;   const int mod = 1e9 + 7;   const int inf = 123456789;   using namespace std;   int n, t, a, b, c;   vector<int> v[maxn], ans2[maxn];   vector<int> ans;   set<int> st[maxn];   int vis[maxn];   map<tuple<int, int>, int> mp;   void add(int a, int b, int i) {     if (mp.find({a, b}) != mp.end()) {       int x = mp[{a, b}];       ans2[x].push_back(i);       ans2[i].push_back(x);       mp.erase({a, b});     } else {       mp[{a, b}] = i;     }   }   void ins(int a, int b) {     if (st[a].count(b)) {       st[a].erase(b);     } else {       st[a].insert(b);     }     if (st[b].count(a)) {       st[b].erase(a);     } else {       st[b].insert(a);     }   }   void dfs(int x, int fa) {     vis[x] = 1;     ans.push_back(x);     for (int i : v[x]) {       if (i == fa || vis[i]) continue;       dfs(i, x);       if (x == 1) break;     }   }   void dfs1(int x, int fa) {     for (int i : ans2[x]) {       if (i != fa) {         dfs1(i, x);       }     }     cout << x <<    ;   }   void init(int x) {     ans.clear();     mp.clear();     memset(vis, 0, sizeof(vis));     for (int i = 1; i <= x; i++) {       ans2[i].clear();       v[i].clear();       st[i].clear();     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     int t;     cin >> t;     while (t--) {       cin >> n;       init(n);       for (int i = 1; i < n - 1; i++) {         cin >> a >> b >> c;         if (a > b) swap(a, b);         if (a > c) swap(a, c);         if (b > c) swap(b, c);         ins(a, b);         ins(a, c);         ins(b, c);         add(a, b, i);         add(a, c, i);         add(b, c, i);       }       for (int i = 1; i <= n; i++) {         for (int it : st[i]) {           v[i].push_back(it);         }       }       dfs(1, 0);       for (int i : ans) {         cout << i <<    ;       }       cout <<   n ;       dfs1(1, 0);       cout <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int Tn;     cin >> Tn;     while (Tn--) {       int n, x;       cin >> n >> x;       int mx = 0, flag = 0;       while (n--) {         int t;         cin >> t;         if (t == x) flag = 1;         mx = max(mx, t);       }       if (!flag)         printf( %d n , max((x - 1) / mx + 1, 2));       else         printf( %d n , 1);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 1010;   long long c[2][2][MAXN][MAXN] = {0};   int n, m;   long long val;   int lowbit(int x) { return x & -x; }   void add(int a, int b) {     for (int i = a; i <= n; i += lowbit(i))       for (int j = b; j <= n; j += lowbit(j)) c[a & 1][b & 1][i][j] ^= val;   }   long long sum(int a, int b) {     long long ans = 0;     for (int i = a; i >= 1; i -= lowbit(i))       for (int j = b; j >= 1; j -= lowbit(j)) ans ^= c[a & 1][b & 1][i][j];     return ans;   }   int main() {     scanf( %d%d , &n, &m);     int x1, x2, y1, y2, op;     long long ans;     for (int i = 1; i <= m; i++) {       scanf( %d , &op);       if (op == 1) {         scanf( %d%d%d%d , &x1, &y1, &x2, &y2);         ans =             sum(x2, y2) ^ sum(x2, y1 - 1) ^ sum(x1 - 1, y2) ^ sum(x1 - 1, y1 - 1);         printf( %I64d n , ans);       } else {         scanf( %d%d%d%d%I64d , &x1, &y1, &x2, &y2, &val);         add(x1, y1);         add(x2 + 1, y1);         add(x1, y2 + 1);         add(x2 + 1, y2 + 1);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   constexpr int maxn = 1010;   constexpr int dx[5] = {0, 0, 1, -1};   constexpr int dy[5] = {1, -1, 0, 0};   using Node = struct { int x, y, v; };   char G[maxn][maxn];   bool vis[maxn][maxn];   int n, m;   vector<Node> p, ret;   inline bool ok(int x, int y) { return x >= 0 && x < n && y >= 0 && y < m; }   void gao(int x, int y) {     int tot = 1;     bool flag = true;     bool yes = false;     while (flag) {       flag = false;       int cnt = 0;       for (int i = 0; i < 4; i++) {         int tx = x + dx[i] * tot;         int ty = y + dy[i] * tot;         if (ok(tx, ty) && G[tx][ty] ==  * ) cnt++;       }       if (cnt != 4) break;       for (int i = 0; i < 4; i++) {         int tx = x + dx[i] * tot;         int ty = y + dy[i] * tot;         vis[tx][ty] = 1;       }       flag = true;       yes = true;       tot++;     }     if (yes) {       vis[x][y] = 1;       ret.push_back({x + 1, y + 1, tot - 1});     }   }   signed main() {     while (~scanf( %d%d , &n, &m)) {       p.clear();       ret.clear();       memset(vis, 0, sizeof(vis));       for (int i = 0; i < n; i++) scanf( %s , G[i]);       for (int i = 0; i < n; i++) {         for (int j = 0; j < m; j++) {           if (G[i][j] ==  * ) p.push_back({i, j, 0});         }       }       if (p.size() == 0) {         printf( 0 n );         continue;       }       for (auto t : p) gao(t.x, t.y);       if (ret.size() == 0) {         printf( -1 n );         continue;       }       bool flag = 0;       for (int i = 0; i < n; i++) {         for (int j = 0; j < m; j++) {           if (!vis[i][j] && G[i][j] ==  * ) {             flag = 1;           }         }       }       if (flag) {         printf( -1 n );         continue;       }       printf( %d n , ret.size());       for (auto t : ret) {         printf( %d %d %d n , t.x, t.y, t.v);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int dp[1003][1003][11][2];   string s, t;   int n, m;   int k;   int rec(int i, int j, int how_k, int op) {     if (how_k > k) return -1e9;     if (i >= n || j >= m) {       if (how_k == k && !op) return 0;       return -1e9;     }     if (s[i] != t[j] && op) return -1e9;     int &ret = dp[i][j][how_k][op];     if (ret != -1) return ret;     ret = -1e9;     if (s[i] == t[j]) {       if (op) {         ret = max(ret, rec(i + 1, j + 1, how_k + 1, 0) + 1);         ret = max(ret, rec(i + 1, j + 1, how_k, op) + 1);       } else {         ret = max(ret, rec(i + 1, j + 1, how_k + 1, op) + 1);         ret = max(ret, rec(i + 1, j + 1, how_k, 1) + 1);       }     }     ret = max(ret, rec(i + 1, j, how_k + (op == 1), 0));     ret = max(ret, rec(i, j + 1, how_k + (op == 1), 0));     return ret;   }   int main() {     cin >> n >> m >> k;     memset(dp, -1, sizeof dp);     cin >> s >> t;     cout << rec(0, 0, 0, 0);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 200500;   int mapp[maxn], num[maxn], ans[maxn];   int main() {     int n, a, b, k;     while (cin >> n >> a >> b >> k) {       memset(ans, 0, sizeof(ans));       char c;       for (int i = 0; i < n; i++) {         cin >> c;         mapp[i] = c -  0 ;       }       int len = 0, pos = 0, tk = a;       int sum, sum2 = 0;       for (int i = 0; i < n; i++) {         if (0 == mapp[i]) len++;         if (1 == mapp[i] || i == n - 1) {           num[pos++] = len;           int kk = len / b;           if (kk <= tk)             tk -= kk;           else {             if (i == n - 1 && !mapp[i]) i++;             for (int j = tk + 1; j <= kk; j++) {               ans[i - len - 1 + j * b] = 1;               sum2++;             }             tk = 0;           }           len = 0;         }       }       sum = 1;       len = 0;       for (int i = 0; i < n; i++) {         if (0 == mapp[i]) len++;         if ((1 == mapp[i] || i == n - 1) && sum > 0) {           if (i == n - 1 && !mapp[i]) i++;           int kk = len / b;           for (int j = 1; j <= kk; j++) {             sum--;             if (!ans[i - len - 1 + j * b]) sum2++;             ans[i - len - 1 + j * b] = 1;             if (sum <= 0) break;           }           len = 0;         }       }       cout << sum2 << endl;       int flag = 0;       for (int i = 0; i < n; i++) {         if (!ans[i]) continue;         if (!flag)           flag = 1;         else           cout <<    ;         cout << i + 1;       }       cout << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   long long n, n1, n2, a[111111], sum1 = 0, sum2 = 0;   int main() {     cin >> n >> n1 >> n2;     for (int i = 0; i < n; i++) cin >> a[i];     if (n1 > n2) swap(n1, n2);     sort(a, a + n);     reverse(a, a + n);     int i = 0;     int m1 = n1;     int m2 = n2;     while (m1 != 0) {       sum1 += a[i];       i++;       m1--;     }     while (m2 != 0) {       sum2 += a[i];       i++;       m2--;     }     cout << fixed << setprecision(7) << (sum1 * 1.0 / n1) + (sum2 * 1.0 / n2);   }