malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   mt19937 rnd;   const int N = 1e5 + 10;   long long a[N], pref[N];   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     int n, d, m;     cin >> n >> d >> m;     for (int i = 1; i <= n; i++) {       cin >> a[i];     }     sort(a + 1, a + n + 1);     for (int i = 1; i <= n; i++) {       pref[i] = pref[i - 1] + a[i];     }     int cnt = 0;     for (int i = 1; i <= n; i++) {       if (a[i] <= m) {         cnt++;       }     }     long long ans = 0;     for (int k = 0; k <= n - cnt; k++) {       if (1ll * k * d + k + cnt < n) {         continue;       }       if (1ll * (k - 1) * d + k > n) {         continue;       }       int x = min(cnt, n - (k - 1) * d - k);       ans = max(ans, pref[cnt] - pref[cnt - x] + pref[n] - pref[n - k]);     }     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     int n;     cin >> n;     vector<pair<long long, long long>> vp;     long long p, a, l = 0, r = 0, ss = 0;     for (int i = 0; i < n; i++) {       cin >> p >> a;       if (p < 0) {         ++l;       } else {         ++r;       }       ss += a;       vp.push_back(make_pair(p, a));     }     if (l == r or l == r + 1 or r == l + 1) {       cout << ss <<   n ;       return;     }     sort(vp.begin(), vp.end());     if (l == 0) {       cout << vp[0].second <<   n ;       return;     } else if (r == 0) {       cout << vp[n - 1].second <<   n ;       return;     }     long long ans = 0;     if (l < r) {       for (int i = 0; i <= 2 * l; i++) {         ans += vp[i].second;       }     } else {       for (int i = l - r - 1; i < n; i++) {         ans += vp[i].second;       }     }     cout << ans <<   n ;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     ;     int t = 1;     while (t--) solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   double work(int x) {     if (x == 0) return 1;     double n = 1.000000011;     double ans = 1;     while (x > 0) {       if ((x & 1) == 1) ans *= n;       n *= n;       x /= 2;     }     return ans;   }   int main() {     int n, t;     cin >> n >> t;     printf( %0.20lf n , work(t) * n);     return 0;   }
//Template Made By: Ojassvi Kumar   #include<bits/stdc++.h>   using namespace std;       #define ios ios_base::sync_with_stdio(false);cin.tie(NULL);   #define ll long long int   #define fo(i,a,b) for(long long int i=a; i<b; i++)   #define endl   n    #define max3(a,b,c) max(max((a),(b)),(c))   #define max4(a,b,c,d) max(max((a),(b)),max((c),(d)))   #define min3(a,b,c) min(min((a),(b)),(c))   #define min4(a,b,c,d) min(min((a),(b)),min((c),(d)))   #define pb push_back   #define lb lower_bound   #define up upper_bound   #define all(V) V.begin(),V.end()   #define itv vector<long long int>::iterator   #define pll pair<long long int,long long int>   #define mp make_pair   #define itp vector<pair<long long int,long long int>>::iterator   #define sll set<long long int,greater<long long int>>   #define its set<long long int,greater<long long int>>::iterator   #define d0(x) cout<<(x)<<      #define d1(x) cout<<(x)<<endl   #define d2(x,y) cout<<(x)<<   <<(y)<<endl       //const long double pi = 3.14159265358979323846264338;   //Template Ends       int main(){       ios       #ifndef ONLINE_JUDGE       freopen( INPUT.txt ,  r , stdin);       freopen( OUTPUT.txt ,  w , stdout);       #endif       ll Tests=1;       cin>>Tests;       while(Tests--){           ll N,L,R,S;           cin>>N>>L>>R>>S;           ll num=R-L+1;           ll Hsum=0,Lsum=0;           fo(i,0,num){               Hsum+=(N-i);               Lsum+=(i+1);           }           if(S>Hsum||S<Lsum){               cout<<-1<<endl;           }           else{               vector<ll> V(num);               fo(i,0,V.size())                   V[i]=i+1;               ll curS=Lsum;               ll j=num-1;               ll ceill=N;               while(1){                   if(curS==S){                       break;                   }                   else{                       V[j]++;                       curS++;                       if(V[j]==ceill){                           j--;                           ceill--;                       }                   }               }               set<ll> ST;               fo(i,0,num)                   ST.insert(V[i]);               vector<ll> VV;               fo(i,0,N){                   if(!ST.count(i+1)){                       VV.pb(i+1);                   }               }               ll jj=0,jjj=0;               fo(i,0,N){                   if(i>=(L-1)&&i<=(R-1)){                       cout<<V[jj]<<   ;                       jj++;                   }                   else{                       cout<<VV[jjj]<<   ;                       jjj++;                   }               }               cout<<endl;           }       }   }
#include <bits/stdc++.h>   using namespace std;   long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }   long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }   double PI = 3.1415926536;   const int inf = 1e9 + 7;   long long MAX(long long a, long long b) { return a > b ? a : b; }   long long MIN(long long a, long long b) { return a > b ? b : a; }   inline bool ispalindrome(string s) {     int n = s.length(), i = 0, j = n - 1;     while (i <= j) {       if (s[i] != s[j]) return false;       i++, j--;     }     return true;   }   inline bool isprime(long long n) {     if (n % 2 == 0) return false;     for (int i = 3; i * i <= n; i += 2)       if (n % i == 0) return false;     return true;   }   void solve() {     int n, k;     cin >> n >> k;     queue<int> q;     set<int> vals;     for (int i = 0; i < n; ++i) {       int id;       cin >> id;       if (!vals.count(id)) {         if (int(q.size()) >= k) {           int cur = q.front();           q.pop();           vals.erase(cur);         }         vals.insert(id);         q.push(id);       }     }     vector<int> res;     while (!q.empty()) {       res.push_back(q.front());       q.pop();     }     reverse(res.begin(), res.end());     cout << res.size() <<   n ;     for (auto it : res) cout << it <<    ;     cout <<   n ;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     int t = 1;     for (int i = 1; i <= t; i++) {       solve();       cout <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     int n, m;     cin >> n >> m;     string a[2 * n], b[2 * m];     for (int i = 0; i < 2 * n; i += 2) {       cin >> a[i] >> a[i + 1];     }     for (int i = 0; i < 2 * m; i += 2) {       cin >> b[i] >> b[i + 1];     }     for (int i = 1; i < 2 * m; i += 2) {       for (int j = 1; j < 2 * n; j += 2) {         string x = b[i];         if ((x.erase(x.size() - 1)).compare(a[j]) == 0) {           cout << b[i - 1] <<     << b[i] <<   #  << a[j - 1];         }       }       cout <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long t;     double n;     cin >> t;     while (t--) {       cin >> n;       if (n * n - 4 * n < 0) {         cout <<  N  << endl;         continue;       }       if (n == 0) {         double x = 0, y = 0;         cout <<  Y   << fixed << setprecision(9) << x <<     << y << endl;         continue;       }       double x = n + sqrt(n * n - 4 * n);       x /= 2;       double y = x / (x - 1);       cout <<  Y   << fixed << setprecision(9) << x <<     << y << endl;     }     return 0;   }
#include <bits/stdc++.h>   struct three_t {     int x, y, z;     inline three_t(int x = 0, int y = 0, int z = 0) : x(x), y(y), z(z) {}   };   std::vector<int> next[100010];   std::vector<three_t> to[100010];   int n, q, t[100010], v[100010], spc[100010], clr[100010], tag[100010],       col[100010], tmp[100010];   void build(int x, int p, int count, int delta) {     if (spc[x]) {       if (p) to[p].emplace_back(x, count, delta);       count = delta = 0;       p = x;     } else {       count += !col[x];       delta += 1;     }     for (auto &y : next[x]) build(y, p, count, delta);   }   void setBlack(int x) {     if (!col[x]) return void(col[x] = 1);     tag[x]++;     for (auto &y : to[x]) {       if (y.y < tag[x]) {         setBlack(y.x);       }     }   }   void setWhite(int x) {     clr[x] = 1;     col[x] = 0;     tag[x] = 0;     for (auto &y : to[x]) {       y.y = y.z;       setWhite(y.x);     }   }   void restore(int x, int setWhite, int setBlack) {     if (spc[x]) {       setWhite |= clr[x];       setBlack = tag[x];     } else {       col[x] = tmp[x] && !setWhite;       if (setBlack && !col[x]) col[x] = 1, --setBlack;     }     for (auto &y : next[x]) restore(y, setWhite, setBlack);   }   int main() {     std::ios::sync_with_stdio(0);     std::cin.tie(0);     std::cout.tie(0);     std::cin >> n >> q;     for (int i = 2, x; i <= n; i++) std::cin >> x, next[x].push_back(i);     for (int i = 1; i <= q; i++) std::cin >> t[i] >> v[i];     for (int i = 1; i <= q; i += 480) {       memset(spc, 0, sizeof(spc));       memset(clr, 0, sizeof(clr));       memset(tag, 0, sizeof(tag));       memcpy(tmp, col, sizeof(tmp));       for (int i = 1; i <= n; i++) to[i].clear();       for (int j = 0; j < 480 && i + j <= q; j++) spc[v[i + j]] = 1;       build(1, 0, 0, 0);       for (int j = 0; j < 480 && i + j <= q; j++) {         if (t[i + j] == 1) {           setBlack(v[i + j]);         } else if (t[i + j] == 2) {           setWhite(v[i + j]);         } else {           std::cout << (col[v[i + j]] ?  black  :  white ) << std::endl;         }       }       restore(1, 0, 0);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void bktk(int i, char *s, int val, int &ans, vector<int> &cnt) {     if (!s[i]) {       ans += cnt[val];       return;     }     val *= 3;     if (s[i] ==  A ) {       bktk(i + 1, s, val, ans, cnt);       bktk(i + 1, s, val + 1, ans, cnt);     }     if (s[i] ==  a ) {       bktk(i + 1, s, val + 2, ans, cnt);     }     if (s[i] ==  O ) {       bktk(i + 1, s, val, ans, cnt);     }     if (s[i] ==  o ) {       bktk(i + 1, s, val + 1, ans, cnt);       bktk(i + 1, s, val + 2, ans, cnt);     }     if (s[i] ==  X ) {       bktk(i + 1, s, val, ans, cnt);       bktk(i + 1, s, val + 2, ans, cnt);     }     if (s[i] ==  x ) {       bktk(i + 1, s, val + 1, ans, cnt);     }   }   int main() {     int w, n, m;     scanf( %d %d %d , &w, &n, &m);     vector<int> f(1 << w, 0);     for (int i = 1; i <= n; i++) {       int x;       scanf( %d , &x);       f[x]++;     }     vector<int> b3(1 << w, 0);     for (int i = 0; i < (1 << w); i++) {       for (int k = w - 1; k >= 0; k--) {         b3[i] = b3[i] * 3 + ((i >> k) & 1);       }     }     vector<int> cnt(531441, 0);     for (int i = 0; i < (1 << w); i++) {       for (int j = 0; j < (1 << w); j++) {         cnt[b3[i] + b3[j]] += f[i] * f[j];       }     }     while (m--) {       char s[14];       scanf( %s , s);       int ans = 0;       bktk(0, s, 0, ans, cnt);       printf( %d n , ans);     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, w, x, sum = 0, mmax = 0, us = 0;     cin >> n >> w;     for (int i = 1; i <= n; ++i) {       scanf( %d , &x);       sum += x;       us = min(us, sum);       mmax = max(mmax, sum);     }     if (us < 0)       us = -us;     else       us = 0;     printf( %d n , max(w - mmax - us + 1, 0));     return 0;   }
#include <bits/stdc++.h>   int MOD = 1000000007;   long long inf = 1e18;   using namespace std;   vector<int> A, B, C;   int as, bs, cs;   int a, b, c;   int k, n1, n2, n3, t1, t2, t3;   bool ok(int t) {     if (a == n1) return false;     int cntb = 0;     for (int i = bs; i < B.size(); i++) {       if (t + t1 < B[i] + t2) {         cntb++;       }     }     for (int i = as; i < A.size(); i++) {       if (t + t1 < A[i] + t1 + t2) {         cntb++;       }     }     if (cntb >= n2) return false;     int cntc = 0;     for (int i = cs; i < C.size(); i++) {       if (t + t1 + t2 < C[i] + t3) {         cntc++;       }     }     for (int i = bs; i < B.size(); i++) {       if (t + t1 + t2 < B[i] + t2 + t3) {         cntc++;       }     }     for (int i = as; i < A.size(); i++) {       if (t + t1 + t2 < A[i] + t1 + t2 + t3) {         cntc++;       }     }     if (cntc >= n3) return false;     return true;   }   int main() {     ios::sync_with_stdio(0);     cin >> k >> n1 >> n2 >> n3 >> t1 >> t2 >> t3;     int t, x;     bool cont;     for (t = 1; t <= 30000001; t++) {       if (k == 0 && c == 0 && b == 0 && a == 0) {         break;       }       cont = true;       while (c != 0 && cont) {         x = C[cs];         cont = false;         if (x + t3 == t) {           cs++;           c--;           cont = true;         }       }       cont = true;       while (b != 0 && cont) {         x = B[bs];         cont = false;         if (x + t2 == t) {           bs++;           b--;           cont = true;           C.push_back(t);           c++;         }       }       cont = true;       while (a != 0 && cont) {         x = A[as];         cont = false;         if (x + t1 == t) {           as++;           a--;           cont = true;           B.push_back(t);           b++;         }       }       cont = true;       while (k != 0 && cont) {         x = t;         cont = false;         if (ok(t)) {           A.push_back(x);           a++;           cont = true;           k--;         }       }     }     cout << t - 2;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 0x3f3f3f3f;   const int MAXN = (int)5e5 + 5;   int n;   struct node {     int x, y;   } a[MAXN];   struct BIT {     long long sum[MAXN];     int n;     void init(int _n) {       n = _n;       memset(sum, 0, sizeof(sum));       ;     }     int lowbit(int x) { return x & -x; }     void update(int x, long long num) {       while (x <= n) {         sum[x] += num;         x += lowbit(x);       }       return;     }     long long query(int x) {       long long ans = 0;       while (x) {         ans += sum[x];         x -= lowbit(x);       }       return ans;     }   } bita;   vector<int> v;   int getid(int x) { return lower_bound(v.begin(), v.end(), x) - v.begin() + 1; }   map<int, int> mpx;   int main() {     while (~scanf( %d , &n)) {       for (int i = 1; i <= n; i++)         scanf( %d%d , &a[i].x, &a[i].y), v.push_back(a[i].x), v.push_back(a[i].y);       sort(v.begin(), v.end()), v.erase(unique(v.begin(), v.end()), v.end());       for (int i = 1; i <= n; i++) {         a[i].x = getid(a[i].x);         a[i].y = getid(a[i].y);       }       sort(a + 1, a + 1 + n, [](node a, node b) {         if (a.y != b.y) return a.y > b.y;         return a.x < b.x;       });       mpx.clear();       bita.init(MAXN);       long long ans = 0;       for (int i = 1; i <= n; i++) {         int xx = a[i].x, yy = a[i].y, pre = 0;         int now = i;         while (a[now].y == a[i].y && now <= n) {           if (!mpx[a[now].x]) {             mpx[a[now].x] = 1;             bita.update(a[now].x, 1ll);           }           now++;         }         now--;         for (int j = i; j <= now; j++) {           long long l = bita.query(a[j].x - 1) - bita.query(pre);           long long r = bita.query(2 * n + 1) - bita.query(a[j].x);           pre = a[j].x;           ans += (long long)l * r + l + r + 1;         }         i = now;       }       printf( %lld n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int a, b;     scanf( %d%d , &a, &b);     if (b > a) {       printf( -1 n );     } else if (a == b) {       printf( %d.000000000 n , a);     } else {       int k((a - b) / b);       if (k & 1) {         k--;       }       double ans1(1. * (a - b) / k);       k = (a + b) / b;       if (k & 1) {         k--;       }       double ans2(1. * (a + b) / k);       printf( %.9f n , min(ans1, ans2));     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long int n, m, k, i, j, a[200002], sum = 0;     vector<long long int> v;     set<pair<long long int, long long int>> s;     cin >> n >> m >> k;     for (i = 0; i < n; i++) {       cin >> a[i];       s.insert(make_pair(a[i], i));     }     set<pair<long long int, long long int>>::iterator it1, it2;     it1 = s.begin();     it2 = s.end();     for (i = 0; i < m * k; i++) {       it2--;     }     s.erase(it1, it2);     for (i = 0; i < n; i++) {       if (s.find(make_pair(a[i], i)) != s.end()) {         sum += a[i];       }     }     long long int cnt = 0;     for (i = 0; i < n; i++) {       auto it = s.find(make_pair(a[i], i));       if (cnt == m * (k - 1)) {         break;       }       if (it != s.end()) {         cnt++;         if (cnt % m == 0) {           v.push_back(it->second + 1);         }       }     }     long long int sz = v.size();     cout << sum << endl;     for (i = 0; i < sz; i++) {       cout << v[i] <<    ;     }     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline long long read() {     long long x = 0;     char zf = 1;     char ch = getchar();     while (ch !=  -  && !isdigit(ch)) ch = getchar();     if (ch ==  - ) zf = -1, ch = getchar();     while (isdigit(ch)) x = x * 10 + ch -  0 , ch = getchar();     return x * zf;   }   void write(long long y) {     if (y < 0) putchar( - ), y = -y;     if (y > 9) write(y / 10);     putchar(y % 10 + 48);   }   void writeln(const long long y) {     write(y);     putchar(  n );   }   int i, j, k, m, n, x, y, z, cnt, dx[10010], dy[10010];   struct now {     int t, x, y, p;   } q[1000010];   int h, t;   long long dis[105][12][12][3];   bool vis[105][12][12][3];   void push(now x, long long ds) {     if (x.x == dx[x.t] && x.y == dy[x.t]) x.t++;     if (ds >= dis[x.t][x.x][x.y][x.p]) return;     dis[x.t][x.x][x.y][x.p] = ds;     if (!vis[x.t][x.x][x.y][x.p])       q[++t] = {x.t, x.x, x.y, x.p}, vis[x.t][x.x][x.y][x.p] = 1;   }   int main() {     n = read();     for (register int i = 1; i <= n; i++)       for (register int j = 1; j <= n; j++) {         x = read();         dx[x] = i;         dy[x] = j;       }     memset(dis, 10, sizeof(dis));     long long ans = 1000000000000ll;     for (register int i = 0; i <= 2; i++)       dis[2][dx[1]][dy[1]][i] = 0, vis[2][dx[1]][dy[1]][i] = 1;     t = 3;     q[1] = {2, dx[1], dy[1], 0};     q[2] = {2, dx[1], dy[1], 1};     q[3] = {2, dx[1], dy[1], 2};     while (h < t) {       now u = q[++h];       vis[u.t][u.x][u.y][u.p] = 0;       long long ds = dis[u.t][u.x][u.y][u.p];       if (u.t > n * n) {         ans = min(ans, ds);         continue;       }       long long b1 = ds + 1000000;       if (u.p == 0) {         for (register int i = 1; i <= n; i++) {           push({u.t, i, u.y, u.p}, b1);           push({u.t, u.x, i, u.p}, b1);         }       }       if (u.p == 1) {         for (register int i = -2; i <= 2; i++)           for (register int j = -2; j <= 2; j++)             if (i * j == 2 || i * j == -2) {               int xx = u.x + i, yy = u.y + j;               if (xx < 1 || xx > n || yy < 1 || yy > n) continue;               push({u.t, xx, yy, u.p}, b1);             }       }       if (u.p == 2) {         for (register int i = -n; i <= n; i++)           for (register int j = -1; j <= 1; j += 2) {             int xx = u.x + i, yy = u.y + i * j;             if (xx < 1 || xx > n || yy < 1 || yy > n) continue;             push({u.t, xx, yy, u.p}, b1);           }       }       for (register int i = 0; i <= 2; i++) push({u.t, u.x, u.y, i}, b1 + 1);     }     cout << ans / 1000000 <<     << ans % 1000000;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int x0, y0, x, y;     cin >> x0 >> y0 >> x >> y;     if (x0 != x && y != y0 && abs(x - x0) != abs(y - y0)) {       cout <<  -1  << endl;       return 0;     }     int dx = abs(y - y0);     int dy = abs(x0 - x);     if (x0 == x)       cout << x0 + dx <<     << y0 <<     << x + dx <<     << y << endl;     else if (y0 == y)       cout << x0 <<     << y0 + dy <<     << x <<     << y + dy << endl;     else       cout << x0 <<     << y <<     << x <<     << y0 << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   void read(T &n) {     n = 0;     T f = 1;     char c = getchar();     while (!isdigit(c) && c !=  - ) c = getchar();     if (c ==  - ) f = -1, c = getchar();     while (isdigit(c)) n = n * 10 + c -  0 , c = getchar();     n *= f;   }   template <typename T>   void write(T n) {     if (n < 0) putchar( - ), n = -n;     if (n > 9) write(n / 10);     putchar(n % 10 +  0 );   }   struct Matrix {     int n, m;     long long a[3][3];     Matrix(int x = 0, int y = 0) : n(x), m(y) { memset(a, 0, sizeof(a)); }     friend Matrix operator*(Matrix a, Matrix b) {       Matrix c(a.n, b.m);       for (int i = 1; i <= a.n; i++) {         for (int j = 1; j <= b.m; j++) {           for (int k = 1; k <= a.m; k++) {             (c.a[i][j] += a.a[i][k] * b.a[k][j] % 998244353) %= 998244353;           }         }       }       return c;     }   } s[500005 * 4], mat, ans;   int a[500005 * 4];   void build(int p, int l, int r) {     if (l == r) {       s[p].n = s[p].m = 2;       s[p].a[1][1] = a[l] + 1;       s[p].a[2][1] = 1, s[p].a[2][2] = 0;       if (l > 1 && a[l - 1] == 1) s[p].a[1][2] = 9 - a[l];       return;     }     build((p << 1), l, ((l + r) >> 1)),         build((p << 1 | 1), ((l + r) >> 1) + 1, r);     s[p] = s[(p << 1 | 1)] * s[(p << 1)];   }   void update(int p, int l, int r, int u, int k) {     if (l == r) {       s[p].a[1][1] = k + 1;       if (u > 1 && a[u - 1] == 1)         s[p].a[1][2] = 9 - k;       else         s[p].a[1][2] = 0;       a[u] = k;       return;     }     if (((l + r) >> 1) >= u)       update((p << 1), l, ((l + r) >> 1), u, k);     else       update((p << 1 | 1), ((l + r) >> 1) + 1, r, u, k);     s[p] = s[(p << 1 | 1)] * s[(p << 1)];   }   int n, m;   int main() {     mat.n = 2, mat.m = 1;     mat.a[1][1] = mat.a[2][1] = 1;     cin >> n >> m;     for (int i = 1; i <= n; i++) scanf( %1d , &a[i]);     build(1, 1, n);     int x, y;     for (int i = 1; i <= m; i++) {       read(x), read(y);       update(1, 1, n, x, y);       if (x < n) update(1, 1, n, x + 1, a[x + 1]);       ans = s[1] * mat;       write(ans.a[1][1]);       puts(  );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int long long n, i, k = 0;     cin >> n;     double a[n + 5], s = 0, b[n + 5];     for (i = 0; i < n; i++) {       cin >> a[i];       s += a[i];     }     for (i = 0; i < n; i++) {       double r = (s - a[i]) / (n - 1);       if (r == a[i]) {         b[k] = i + 1;         k++;       }     }     cout << k << endl;     for (i = 0; i < k; i++) {       cout << b[i] <<    ;     }     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     long long a, b, d, i, j, k = 0, h, c, p1, p2, q1, q2, A, B, c1, c2, l, m = 0,                              n, t = 1, q = 0, r, e, x = 0, y = 0, o, s, mx1,                              mx2 = 0, mx = 0, p = 0, v, mn = 0, z, w;     string s1, s2, s3, s4;     cin >> n;     int arr[n];     for (i = 0; i < n; i++) cin >> arr[i];     sort(arr, arr + n);     x = arr[0];     t = n / 2;     i = 1;     while (t--) {       cout << arr[i] <<     << x << endl;       i++;     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int t = 1;     cin >> t;     while (t--) solve();   }