malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, i, j, sum = 1, sum2 = 2, t = 0, k = 0;     cin >> n;     int a[n], b[n];     for (i = 0; i < n; i++) {       cin >> a[i];     }     for (i = 0; i < n; i++) {       if (a[i] == 1) t++;       if (a[i + 1] == 1 || i == n - 1) {         b[k] = a[i];         k++;       }     }     cout << t <<   n ;     for (i = 0; i < k; i++) {       cout << b[i] <<    ;     }   }
#include <bits/stdc++.h>   using namespace std;   int N;   long long shu[200010];   int main() {     while (scanf( %d , &N) != EOF) {       for (int i = 1; i <= N * 2; i++) {         scanf( %I64d , &shu[i]);       }       sort(shu + 1, shu + 1 + 2 * N);       long long ans = (shu[N] - shu[1]) * (shu[2 * N] - shu[N + 1]);       for (int i = 2; i <= N; i++) {         ans = min(ans, (shu[i + N - 1] - shu[i]) * (shu[2 * N] - shu[1]));       }       printf( %I64d n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int w, h;     cin >> w >> h;     char char1[100][100], char2[100][100];     string char3[200];     for (int i(0); i < h; ++i) cin >> char1[i];     for (int i(0); i < w; ++i) {       for (int j(0); j < h; ++j) {         char2[i][j] = char1[abs(j - h + 1)][i];       }     }     for (int i(0); i < w; ++i) {       for (int j(0); j < h / 2; ++j) {         char tmp = char2[i][j];         char2[i][j] = char2[i][abs(j - h + 1)];         char2[i][abs(j - h + 1)] = tmp;       }     }     for (int i(0); i < 2 * w; i += 2) {       for (int j(0); j < h; ++j) {         char3[i].insert(char3[i].end(), char2[i / 2][j]);         char3[i].insert(char3[i].end(), char2[i / 2][j]);       }       char3[i + 1] = char3[i];     }     for (int i(0); i < 2 * w; ++i) cout << char3[i] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main(void) {     int n;     bool val = false;     cin >> n;     char array[n][5];     for (int i = 0; i < n; i++) {       cin >> array[i];     }     for (int i = 0; i < n; i++) {       if (array[i][0] ==  O  & array[i][1] ==  O ) {         val = true;         array[i][0] =  + ;         array[i][1] =  + ;         break;       }       if (array[i][3] ==  O  & array[i][4] ==  O ) {         val = true;         array[i][3] =  + ;         array[i][4] =  + ;         break;       }     }     if (val == true) {       cout <<  YES  <<   n ;     } else if (val == false)       cout <<  NO ;     if (val == true) {       for (int i = 0; i < n; i++) {         cout << array[i][0];         cout << array[i][1];         cout << array[i][2];         cout << array[i][3];         cout << array[i][4] <<   n ;       }     }   }
#include <bits/stdc++.h>   using namespace std;   int n, a[110];   long long ans;   int main() {     ans = 0LL;     scanf( %d , &n);     for (int i = 1; i <= n; ++i) scanf( %d , &a[i]);     for (int i = 1; i <= n; ++i) {       ans += (long long)a[i];       ans += (long long)(i - 1) * (long long)(a[i] - 1);     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long niz[200005];   int main() {     ios_base::sync_with_stdio(false);     cout.precision(10);     cout << fixed;     int n;     cin >> n;     long long k, m;     cin >> m >> k;     for (int i = 1; i <= n; i++) cin >> niz[i];     sort(niz + 1, niz + 1 + n);     long long b = niz[n];     long long a = niz[n - 1];     long long br = m / (k + 1);     long long ost = m % (k + 1);     long long res = 0;     res += ost * b;     res += br * a;     res += br * k * b;     cout << res;     return 0;   }
#include <bits/stdc++.h>   using namespace std;               void solve(){    int n;cin>>n;        if(n <= 45){     int point = 9;     string ans =   ;     int x = n;        while(x > point){      ans += to_string(point);      x -= point;      point--;     }     if(x) ans += to_string(x);     reverse(ans.begin(),ans.end());     cout<<ans<<endl;     return;    }       cout<< -1 <<endl;   }         int main(){    ios::sync_with_stdio(false); cin.tie(0);    #ifndef ONLINE_JUDGE     freopen( input.txt ,  r , stdin);    freopen( result.txt ,  w , stdout);    #endif    int t;cin>>t;    while(t--)     solve();                     return 0;   }//main
#include <bits/stdc++.h>   using namespace std;   int dx[] = {-1, 0, 1, 0, -1, 1, 1, -1};   int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};   int n, m;   bool dfs(pair<int, int> start, vector<string>& G, vector<vector<bool> >& odw,            set<pair<int, int> >& jed) {     stack<pair<int, int> > S;     S.push(start);     odw[start.first][start.second] = true;     bool brzeg = false;     while (!S.empty()) {       pair<int, int> akt = S.top();       S.pop();       if (akt.first == 0 || akt.first == n - 1 || akt.second == 0 ||           akt.second == m - 1)         brzeg = true;       for (int i = 0; i < 8; ++i) {         pair<int, int> nast = make_pair(akt.first + dx[i], akt.second + dy[i]);         if (nast.first >= 0 && nast.first < n && nast.second >= 0 &&             nast.second < m) {           if (G[nast.first][nast.second] ==  0  &&               !odw[nast.first][nast.second]) {             S.push(nast);             odw[nast.first][nast.second] = true;           }           if (G[nast.first][nast.second] ==  1 ) jed.insert(nast);         }       }     }     return brzeg;   }   int main() {     ios_base::sync_with_stdio(0);     cin >> n >> m;     vector<string> a(n);     for (int i = 0; i < n; ++i) cin >> a[i];     int odp = 0;     for (int i = 0; i + 1 < n; ++i)       for (int j = 0; j + 1 < m; ++j)         if (a[i][j] ==  1  && a[i][j + 1] ==  1  && a[i + 1][j] ==  1  &&             a[i + 1][j + 1] ==  1 )           odp = 4;     vector<vector<bool> > odw(n, vector<bool>(m, false));     for (int i = 0; i < n; ++i) {       for (int j = 0; j < m; ++j) {         if (a[i][j] ==  1  || odw[i][j]) continue;         set<pair<int, int> > S;         if (dfs(make_pair(i, j), a, odw, S)) continue;         int wlk = S.size();         pair<int, int> start = *S.begin();         pair<int, int> nast;         int ilSa = 0;         for (int k = 0; k < 4; ++k) {           pair<int, int> t = make_pair(start.first + dx[k], start.second + dy[k]);           if (S.find(t) != S.end()) {             nast = t;             ++ilSa;           }         }         if (ilSa != 2) continue;         S.erase(start);         pair<int, int> akt = nast;         bool ok = true;         while (true) {           ilSa = 0;           for (int k = 0; k < 4; ++k) {             pair<int, int> t = make_pair(akt.first + dx[k], akt.second + dy[k]);             if (S.find(t) != S.end()) {               nast = t;               ++ilSa;             }           }           if (ilSa > 1) {             ok = false;             break;           }           if (ilSa < 1) {             if (S.size() > 1) ok = false;             break;           }           S.erase(akt);           akt = nast;         }         if (ok) odp = max(odp, wlk);       }     }     cout << odp;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int n, r, avg, m, k, t, x, y, i, j, b, d, MOD = 1073741824,                                                         count = 0, ans = 0;     string s;     cin >> s;     long long int a[36] = {0};     for (i = 0; i < s.size(); i++) {       if (s[i] -  a  >= 0) {         a[s[i] -  a  + 10]++;       } else {         x = s[i] - 48;         a[x]++;       }     }     for (i = 0; i < 36; i++) {       count += pow(a[i], 2);     }     cout << count;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   #define ll long long int   const int N=1000005;   //vector<int>prime;   bool prime[N];   void sieve()   {       int k=sqrt(N-2);       for(int i=1;i<=N-2;++i)           prime[i]=true;       for(int i=2;i<=k;++i)       {           if(prime[i])           {               for(int k=i*i;k<=N-2;k+=i)               {                   prime[k]=false;                   //pf[k]=i;               }           }       }   }      void solve()   {           int d;        cin>>d;        int x;        int y;        for(int i=d+1;;i++)        {            if(prime[i])            {                 x=i;                break;            }        }        for(int i=x+d;;i++)        {            if(prime[i])            {                 y=i;                break;            }        }        cout<<x*y<<  n ;   }      int main() {    // your code goes here    ios_base::sync_with_stdio(false);       cin.tie(NULL);    sieve();    int t;    cin>>t;        while(t--)    {        solve();    }            return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int tt;     cin >> tt;     while (tt--) {       int n, l;       cin >> n >> l;       vector<double> flags(n);       for (auto& i : flags) cin >> i;       double a_s = 0, b_s = l;       double a_v = 1, b_v = 1;       int a_i = 0, b_i = n - 1;       double t = 0;       for (;;) {         double a_d = a_i < n ? flags[a_i] - a_s : 1e300,                b_d = b_i >= 0 ? b_s - flags[b_i] : 1e300;         double a_t = a_d / a_v, b_t = b_d / b_v;         double sep = b_s - a_s;         double sep_t = sep / (a_v + b_v);         double mn = min({a_t, b_t, sep_t});         t += mn;         a_s += a_v * mn;         b_s -= b_v * mn;         if (a_t == mn) {           a_v++;           a_i++;         } else if (b_t == mn) {           b_v++;           b_i--;         } else           break;       }       cout << fixed << t << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 5.2e3 + 5;   int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }   char s[MAXN];   bool a[MAXN][MAXN];   int main(void) {     int n;     scanf( %d , &n);     for (int i = 1; i <= n; ++i) {       scanf( %s , s + 1);       for (int j = 1; s[j]; ++j) {         if (s[j] >=  0  && s[j] <=  9 )           s[j] -=  0 ;         else           s[j] = s[j] -  A  + 10;         for (int k = 0; k < 4; ++k) a[i][(j << 2) - k] = (s[j] >> k) & 1;       }     }     int x = 0;     for (int i = 1; i <= n && x != 1; ++i)       for (int l = 1, r = 1; l <= n && x != 1; l = r) {         while (r <= n && a[i][r] == a[i][l]) ++r;         x = gcd(x, r - l);       }     for (int j = 1; j <= n && x != 1; ++j)       for (int l = 1, r = 1; l <= n && x != 1; l = r) {         while (r <= n && a[r][j] == a[l][j]) ++r;         x = gcd(x, r - l);       }     printf( %d , x);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   double sum[2][30][200010];   char A[2][200010];   int main() {     int N;     cin >> N;     cin >> A[0] >> A[1];     for (int i = 0; i < (N); i++)       for (int k = 0; k < (2); k++) A[k][i] -=  A ;     double cont = 0;     double val = 0;     for (int i = (1); i <= (N); i++) val = N - i + 1, val *= val, cont += val;     memset(sum, 0, sizeof(sum));     for (int i = 0; i < (N); i++) {       for (int k = 0; k < (2); k++) {         sum[k][A[k][i]][i] = ((i == 0) ? 0 : sum[k][A[k][i]][i - 1]) + (i + 1);         if (i > 0) {           for (char c = 0; c <= 25; c++) {             sum[k][c][i] = max(sum[k][c][i], sum[k][c][i - 1]);           }         }       }     }     double ans = 0;     for (int i = 0; i < (N); i++) {       for (int k = 0; k < (2); k++) {         double* lst = sum[1 - k][A[k][i]];         double val = lst[i - 1];         ans += ((double)(N - i)) * val / cont;       }       if (A[0][i] == A[1][i]) {         ans += ((double)(N - i)) * (i + 1) / cont;       }     }     double vv = ans;     cout << fixed << setprecision(12) << vv << endl;   }
#include <bits/stdc++.h>   bool u[1000001];   int pr[500001];   int l;   int n;   long long a[8];   int f[7000];   int thr[10];   int b[8];   int inf = 10000;   int g[8];   int cal(long long x) {     int i;     int ret = 0;     for (i = 1; i <= l && pr[i] <= x / pr[i]; i++) {       while (x % pr[i] == 0) {         x = x / pr[i];         ret++;       }     }     if (x > 1) ret++;     return ret;   }   void dfs(int x, int y, long long z, int r, int cur) {     int i;     if (r == n) {       if (f[x] > f[y] + cur + 1) f[x] = f[y] + cur + 1;     } else {       if (z % a[r] == 0 && b[r] == 2)         dfs(x, y - thr[r], z / a[r], r + 1, cur - g[r]);       dfs(x, y, z, r + 1, cur);     }   }   int main() {     int i, j;     memset(u, true, sizeof(u));     l = 0;     for (i = 2; i <= 1000000; i++) {       if (u[i]) {         l++;         pr[l] = i;       }       for (j = 1; j <= l && i <= 1000000 / pr[j]; j++) {         u[i * pr[j]] = false;         if (i % pr[j] == 0) break;       }     }     scanf( %d , &n);     for (i = 0; i < n; i++) scanf( %I64d , &a[i]);     for (i = 0; i < n; i++) g[i] = cal(a[i]);     thr[0] = 1;     for (i = 1; i <= n; i++) thr[i] = thr[i - 1] * 3;     int mm = inf;     f[0] = 0;     for (i = 1; i < thr[n] - 1; i++) {       int cur = i;       bool flag = true;       for (j = n - 1; j >= 0; j--) {         b[j] = cur / thr[j];         cur = cur % thr[j];         if (b[j] == 0) flag = false;       }       f[i] = inf;       for (j = 0; j < n; j++)         if (b[j] == 1) {           if (g[j] == 1) {             if (f[i] > f[i - thr[j]] + 1) f[i] = f[i - thr[j]] + 1;           } else {             if (f[i] > g[j] + f[i - thr[j]] + 1) f[i] = g[j] + f[i - thr[j]] + 1;           }           dfs(i, i - thr[j], a[j], 0, g[j]);         }       if (flag) {         for (j = 0; j < n; j++)           if (b[j] == 1) break;         if (i + thr[j] == thr[n] - 1) {           if (f[i] < mm) mm = f[i];         } else {           if (f[i] + 1 < mm) mm = f[i] + 1;         }       }     }     printf( %d n , mm);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int n;     priority_queue<pair<int, int> > neg;     priority_queue<pair<int, int>, vector<pair<int, int> >,                    greater<pair<int, int> > >         pos;     cin >> n;     int x, a;     pair<int, int> temp;     for (int i = 0; i < n; i++) {       cin >> x >> a;       temp = make_pair(x, a);       if (x < 0) {         neg.push(temp);       } else {         pos.push(temp);       }     }     int ans = 0;     if (pos.size() >= neg.size()) {       while (1) {         if (pos.empty())           break;         else {           ans += pos.top().second;           pos.pop();         }         if (neg.empty())           break;         else {           ans += neg.top().second;           neg.pop();         }       }     } else {       while (1) {         if (neg.empty())           break;         else {           ans += neg.top().second;           neg.pop();         }         if (pos.empty())           break;         else {           ans += pos.top().second;           pos.pop();         }       }     }     printf( %d , ans);     return 0;   }
#include <bits/stdc++.h>   int main() {     std::ios_base::sync_with_stdio(false);     std::cin.tie(0);     int n;     std::cin >> n;     std::vector<bool> col(6 * n);     for (int i = 0; i < 3 * n; ++i) {       int x;       std::cin >> x;       --x;       col[x] = true;     }     std::vector<int> sta;     std::vector<std::vector<int>> tmp(6 * n);     std::vector<std::tuple<int, int, int>> tp;     std::vector<bool> bel;     std::vector<std::vector<int>> E(2 * n);     for (int i = 0; i < 6 * n; ++i) {       sta.push_back(i);       if ((int)sta.size() >= 3) {         auto c = std::prev(sta.end()), b = std::prev(c), a = std::prev(b);         if (col[*a] == col[*b] && col[*b] == col[*c]) {           int u = tp.size();           tp.emplace_back(*a, *b, *c);           bel.push_back(col[*a]);           if (a != sta.begin()) {             tmp[*std::prev(a)].push_back(u);           }           E[u].insert(E[u].end(), tmp[*a].begin(), tmp[*a].end());           E[u].insert(E[u].end(), tmp[*b].begin(), tmp[*b].end());           sta.pop_back(), sta.pop_back(), sta.pop_back();         }       }     }     std::vector<int> fa(2 * n, -1), deg(2 * n, 0);     for (int u = 0; u < 2 * n; ++u) {       for (int v : E[u]) {         fa[v] = u;       }       deg[u] = E[u].size();     }     int cnt = 0;     for (int u = 0; u < 2 * n; ++u) {       if (fa[u] == -1 && !bel[u]) {         ++cnt;       }     }     int p = -1;     std::array<std::queue<int>, 2> Q;     for (int u = 0; u < 2 * n; ++u) {       if (!deg[u]) {         Q[bel[u]].push(u);       }     }     std::vector<std::tuple<int, int, int>> ans;     int c = 0;     for (int i = 0; i < 2 * n - 1; ++i) {       c ^= 1;       while (1) {         int u = Q[c].front();         Q[c].pop();         if (fa[u] == -1 && !bel[u]) {           if (cnt == 1) {             p = u;             continue;           }           --cnt;         }         ans.emplace_back(tp[u]);         if (fa[u] != -1) {           --deg[fa[u]];           if (!deg[fa[u]]) {             Q[bel[fa[u]]].push(fa[u]);           }         }         break;       }     }     if (p == -1) {       c ^= 1;       p = Q[c].front();     }     ans.emplace_back(tp[p]);     for (auto [x, y, z] : ans) {       std::cout << x + 1 <<     << y + 1 <<     << z + 1 <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   int a[52][52] = {0};   int b[52];   bool c[52] = {0};   int main() {     int n;     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= n; j++) {         scanf( %d , &a[i][j]);         if (c[a[i][j]] == 0)           c[a[i][j]] = 1;         else           b[i] = a[i][j];       }       memset(c, 0, sizeof(c));     }     for (int i = 1; i <= n; i++) c[b[i]] = 1;     for (int i = 1; i <= n; i++) {       if (b[i])         cout << b[i];       else {         for (int j = 1; j <= n; j++)           if (c[j] == 0) {             cout << j;             c[j] = 1;             break;           }       }       cout <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<long long> ok;   vector<long long> nok;   void doit() {     long long n, d, m;     cin >> n >> d >> m;     vector<long long> v;     long long x;     while (n--) {       cin >> x;       v.push_back(x);     }     sort(v.begin(), v.end());     long long mleg = 0;     long long ans = 0;     long long cur = 0;     while ((mleg < v.size()) && (v[mleg] <= m)) {       cur += v[mleg];       mleg++;     }     long long sum[mleg];     sum[0] = v[0];     for (int i = 1; i < mleg; i++) {       sum[i] = v[i] + sum[i - 1];     }     ans = cur;     x = 1;     long long comp = 0;     while (v.size() - x >= mleg) {       long long ci = v.size() - x;       comp += v[ci];       long long nesesito = max(((x - 1) * d) - (ci - mleg), (long long)(0));       if (nesesito <= mleg) {         long long mres = 0;         if (nesesito)           mres = comp + (cur - sum[nesesito - 1]);         else           mres = comp + cur;         ans = max(mres, ans);       }       x++;     }     cout << ans << endl;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     int t = 1;     while (t--) {       doit();     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2005, M = N * N;   int n, m;   string s[N];   bool isvalid(int x, int y) {     return 0 <= x && x < n && 0 <= y && y < m && s[x][y] ==  . ;   }   int id(int x, int y) { return x * N + y; }   int par[M];   void init() {     for (int i = 0; i < M; i++) par[i] = i;   }   int find(int u) {     if (par[u] == u) return u;     return par[u] = find(par[u]);   }   void merge(int u, int v) { par[find(u)] = find(v); }   vector<int> adj[M];   bool vis[M];   int dis[M];   void bfs(int s) {     dis[s] = 0;     vis[s] = 1;     queue<int> q;     q.push(s);     while (q.size()) {       int u = q.front();       q.pop();       for (int v : adj[u])         if (!vis[v]) {           vis[v] = 1;           dis[v] = 1 + dis[u];           q.push(v);         }     }   }   int main() {     init();     ios::sync_with_stdio(0);     cin.tie(0);     cin >> n >> m;     int sx, sy, l, r;     cin >> sx >> sy >> l >> r;     sx--;     sy--;     for (int i = 0; i < n; i++) cin >> s[i];     for (int i = 0; i < n; i++)       for (int j = 0; j < m; j++) {         if (s[i][j] !=  . ) continue;         if (isvalid(i + 1, j)) merge(id(i, j), id(i + 1, j));       }     for (int i = 0; i < n; i++)       for (int j = 0; j < m; j++) {         if (s[i][j] !=  . ) continue;         int u = find(id(i, j));         int l = find(id(i, j - 1));         int r = find(id(i, j + 1));         if (isvalid(i, j - 1)) adj[u].push_back(l);         if (isvalid(i, j + 1)) adj[u].push_back(r);       }     bfs(find(id(sx, sy)));     int ans = 0;     for (int i = 0; i < n; i++)       for (int j = 0; j < m; j++) {         int k = find(id(i, j));         if (s[i][j] !=  .  || !vis[k]) continue;         int dif = j - sy;         int sum = dis[k];         assert(sum % 2 == abs(dif) % 2);         int rr = (sum + dif) / 2;         int ll = (sum - dif) / 2;         if (rr <= r && ll <= l) ans++;       }     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   int solve(int n, int a[]) {     int count = 0;     for (int i = 0; i < n; ++i) {       if (a[i] == i) {         ++count;       }     }     for (int i = 0; i < n; ++i) {       if (a[i] != i && a[a[i]] == i) {         return count + 2;       }     }     return min(count + 1, n);   }   int main() {     int n;     int a[100000];     cin >> n;     for (int i = 0; i < n; ++i) {       cin >> a[i];     }     cout << solve(n, a) << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 52;   const int MAX = 1e9 + 5;   int n, a[N];   long double dp[N][N][N][N];   int p;   long double all, P[N];   long double f(int wh, int ret, int left, int whd) {     if (left == 0 && ret) return 0;     if (left == 0 && ret == 0) return 1;     if (ret < 0) return 0;     if (wh > n) return 0;     long double &r = dp[wh][ret][left][whd];     if (r != -1) return r;     if (wh == whd) return r = f(wh + 1, ret, left, whd);     return r = f(wh + 1, ret - a[wh], left - 1, whd) + f(wh + 1, ret, left, whd);   }   int main() {     scanf( %d , &n);     P[0] = 1;     for (int i = 1; i <= n; i++) P[i] = P[i - 1] * i;     for (int i = 1; i <= n; i++) scanf( %d , &a[i]);     scanf( %d , &p);     for (int A = 0; A <= N - 1; A++)       for (int B = 0; B <= N - 1; B++)         for (int C = 0; C <= N - 1; C++)           for (int D = 0; D <= N - 1; D++) dp[A][B][C][D] = -1;     for (int i = 1; i <= n; i++) {       int begin = p - a[i] + 1;       int end = p;       for (int j = begin; j <= end; j++) {         for (int k = 0; k <= n; k++) {           long double temp = f(1, j, k, i);           all += temp * P[k] / P[n] * P[n - k - 1] * k;         }       }     }     for (int i = 0; i <= p; i++) all += f(1, i, n, 0) * n;     cout << setprecision(12) << fixed << all <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     unsigned long long int t;     cin >> t;     while (t--) {       unsigned long long int n;       cin >> n;       unsigned long long int x;       cin >> x;       vector<unsigned long long int> ind;       vector<pair<unsigned long long int, unsigned long long int>> store;       unsigned long long int count = 0, ind1;       for (unsigned long long int i = 1; i <= n - 1; i++) {         unsigned long long int y;         cin >> y;         if (y != x) {           ind1 = i + 1;           count++;           store.push_back({1, i + 1});         } else {           ind.push_back(i);         }       }       if (count == 0)         cout <<  NO               <<   n ;       else {         cout <<  YES               <<   n ;         for (auto pr : store) {           cout << pr.first <<     << pr.second <<   n ;         }         if (ind.size() != 0) {           for (auto x : ind) {             cout << ind1 <<     << x + 1 <<   n ;           }         }       }     }   }   int32_t main() {     ios::sync_with_stdio(0);     cin.tie(0);     solve();     return 0;   }