malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   inline int read() {     int f = 1, ans = 0;     char c = getchar();     while (c <  0  || c >  9 ) {       if (c ==  - ) f = -1;       c = getchar();     }     while (c >=  0  && c <=  9 ) {       ans = ans * 10 + c -  0 ;       c = getchar();     }     return f * ans;   }   const int MAXN = 4e5 + 11;   vector<int> vec[MAXN];   int ch[MAXN][27], las = 1, tot = 1, TT = 0, N, Q, len[MAXN], fa[MAXN], rt[MAXN],                     all;   char S[MAXN];   struct Segment {     int ls[MAXN * 34], rs[MAXN * 34];     void Modify(int &k, int l, int r, int ps) {       if (!k) k = ++TT;       if (l == r) return;       int mid = (l + r) >> 1;       if (ps <= mid) Modify(ls[k], l, mid, ps);       if (mid < ps) Modify(rs[k], mid + 1, r, ps);       return;     }     void print(int k, int l, int r) {       if (!k) return;       if (l == r) {         printf( %d  , l);         return;       }       int mid = (l + r) >> 1;       print(ls[k], l, mid), print(rs[k], mid + 1, r);     }     int merge(int p, int q) {       if (!p || !q) return p + q;       int u = (++TT);       ls[u] = merge(ls[p], ls[q]), rs[u] = merge(rs[p], rs[q]);       return u;     }     bool Query(int k, int l, int r, int x, int y) {       if (!k) return 0;       if (x <= l && r <= y) return 1;       int mid = (l + r) >> 1;       bool res = 0;       if (x <= mid) res |= Query(ls[k], l, mid, x, y);       if (mid < y) res |= Query(rs[k], mid + 1, r, x, y);       return res;     }     void debug(int k) {       print(rt[k], 1, N);       printf(  n );       return;     }   } T;   void ins(int c) {     int p = las, np = las = ++tot;     len[np] = len[p] + 1;     T.Modify(rt[np], 1, N, len[np]);     for (; p && !ch[p][c]; p = fa[p]) ch[p][c] = np;     if (!p) {       fa[np] = 1;       return;     }     int q = ch[p][c];     if (len[p] + 1 == len[q]) {       fa[np] = q;       return;     }     int nq = ++tot;     len[nq] = len[p] + 1, fa[nq] = fa[q];     for (int i = 0; i < 27; i++) ch[nq][i] = ch[q][i];     fa[q] = fa[np] = nq;     for (; p && ch[p][c] == q; p = fa[p]) ch[p][c] = nq;     return;   }   void dfs(int u) {     for (auto v : vec[u]) dfs(v), rt[u] = T.merge(rt[u], rt[v]);   }   int L, R, LEN;   char Ans[MAXN];   bool ff = 1;   void calc(int now, int len, bool f) {     if (!f) {       for (int i = 1; i < len; i++) printf( %c , Ans[i]);       printf(  n );       ff = 0;       return;     }     int be;     if (!f || len > LEN)       be = 0;     else       be = S[len] -  a ;     for (int i = be; i < 26; i++) {       int u = ch[now][i];       if (!u) continue;       if (!T.Query(rt[u], 1, N, L + len - 1, R)) continue;       Ans[len] = i +  a ;       calc(u, len + 1, f & (i == (S[len] -  a )));       if (!ff) return;     }   }   int main() {     scanf( %s , S + 1);     N = strlen(S + 1);     Q = read();     for (int i = 1; i <= N; i++) ins(S[i] -  a );     for (int i = 2; i <= tot; i++) vec[fa[i]].push_back(i);     dfs(1);     while (Q--) {       L = read(), R = read();       scanf( %s , S + 1);       LEN = strlen(S + 1);       ff = 1;       calc(1, 1, 1);       if (ff) printf( -1 n );     }   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     long long n, k;     cin >> n >> k;     vector<long long> a(n);     for (int i = 0; i < n; i++) cin >> a[i];     ;     sort(a.begin(), a.end());     long long mm = a[n / 2];     for (int i = n / 2; i < n - 1; i++) {       long long r = a[i + 1] - a[i];       if (k >= r * (i - n / 2 + 1))         k -= r * (i - n / 2 + 1);       else if (k > 0) {         mm += k / (i - n / 2 + 1);         k = 0;         break;       } else         break;       mm = a[i + 1];     }     if (k > 0) mm += k / (n / 2 + 1);     cout << mm <<   n ;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     ;     int t = 1;     while (t--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int M = 200005;   int n, m, tot, ans;   struct Node {     int u, v, w;   } node[M];   int vis[M], match[M];   int sum1[M], sum2[M];   int head[M], Nxt[M], ver[M];   bool v[M], flag = 0;   vector<int> e[M];   inline bool dfs(long long x) {     for (int i = 0; i < e[x].size(); i++) {       long long y = e[x][i];       if (!vis[y]) {         vis[y] = 1;         if (!match[y] || dfs(match[y])) {           match[y] = x;           return 1;         }       }     }     return 0;   }   bool cmp(Node a, Node b) { return a.w > b.w; }   int main() {     scanf( %d%d , &n, &m);     for (int i = 1; i <= m; i++) {       scanf( %d%d%d , &node[i].u, &node[i].v, &node[i].w);       sum1[node[i].u]++;       sum2[node[i].v]++;       e[node[i].u].push_back(node[i].v);     }     for (int i = 1; i <= n; i++) {       memset(vis, 0, sizeof(vis));       if (dfs(i)) ans++;     }     if (ans != n) {       printf( -1 n );       return 0;     }     sort(node + 1, node + 1 + m, cmp);     for (int i = 1; i <= m; i++) {       sum1[node[i].u]--;       sum2[node[i].v]--;       if (sum1[node[i].u] == 0 || sum2[node[i].v] == 0) {         printf( %d n , node[i].w);         return 0;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     for (int z = 0; z < t; z++) {       int n;       cin >> n;       string s;       cin >> s;       bool found = false;       for (int i = 0; i <= n - 11; i++) {         if (s[i] ==  8 ) {           cout <<  YES  << endl;           found = true;           break;         }       }       if (found) {         continue;       }       cout <<  NO  << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   void show(const vector<T> &a) {     for (T x : a) cout << x <<    ;     cout <<   n ;   }   mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());   mt19937_64 rng_64(chrono::steady_clock::now().time_since_epoch().count());   vector<long long> xx = {1, 0, -1, 0};   vector<long long> yy = {0, 1, 0, -1};   string dir =  LRUD ;   const long long N = 3e5 + 50, oo = 2e18 + 500;   const long long mod = 998244353;   const long long M2 = 1000000093, x2 = 27162;   const long long M1 = 1000000087, x1 = 241;   const double eps = 1e-12, PI = 2 * acos(0.0);   long long n, m, k;   long long cnt = 0;   long long lg = 18;   vector<vector<long long>> g;   vector<vector<long long>> rg;   signed main() {     ios::sync_with_stdio(0);     cout.tie(0);     cin.tie(0);     string s;     cin >> s;     n = ((long long)(s.size()));     vector<vector<string>> vc(26);     for (long long i = 0; i < n; i++) {       string t = s.substr(i, n - i) + s.substr(0, i);       vc[s[i] -  a ].push_back(t);     }     double ans = 0;     for (long long i = 0; i < 26; i++) {       if (!((long long)(vc[i].size()))) continue;       long long val = 0;       for (long long j = 0; j < n; j++) {         vector<long long> count_letters(26);         for (long long z = 0; z < ((long long)(vc[i].size())); z++) {           count_letters[vc[i][z][j] -  a ]++;         }         bool fl = 1;         long long cur = 0;         for (long long z = 0; z < 26; z++) {           if (count_letters[z] == 1) {             cur++;           } else {             if (count_letters[z]) fl = 0;           }         }         if (fl) {           val = ((long long)(vc[i].size()));           break;         }         val = max(val, cur);         ;       }       cnt += val;     }     ans = (double)cnt / (double)n;     cout << fixed << setprecision(10) << ans;   }
#include<bits/stdc++.h>   using namespace std ;      # define all(v) (v).begin() , (v).end()   # define allrev(v) (v).rbegin() , (v).rend()   # define allcomp(v) (v).begin() , (v).end() , comp      # define ll long long      # define line cout <<   n  ;   # define fast ios_base :: sync_with_stdio ( false ) ; cin.tie ( 0 ) ;      # define pii pair < int , int >   # define pll pair < ll , ll >      # define F first   # define S second      const int mod = 998244353  ;      const int dx[] = { -1 , 0 , 1 , 0 , -1 , -1 , 1 , 1 } ;   const int dy[] = { 0 , 1 , 0 , -1 , -1 , 1 , -1 , 1 } ;      ll mod_pow ( ll a , ll b )   {       if ( b == 0 )           return 1 ;          if ( b == 1 )           return a%mod ;          if ( b == 2 )       {           return ((a%mod) * (a%mod))%mod ;       }          return (mod_pow ( mod_pow ( a , b>>1 ) , 2 ) * mod_pow ( a , b&1 ))%mod ;   }      void solve ( int test_case )   {       int n ;       cin >> n ;          int bak = n ;          int nr = 0 ;       if ( n <= 2 )           nr = 1 ;             else       {           n -= 2 ;           ll a = 1 , b = 1 ;              while ( n -- )           {               b += a ;               a = b - a ;                  a %= mod ;               b %= mod ;           }              nr = b ;       }          ll f = 1 ;       for ( int i = 1 ; i <= bak ; i ++ )           f <<= 1 , f %= mod ;      //    cout <<  nr :   << nr <<   and dr :   << f ; line ;          f = mod_pow ( f , mod - 2 ) ;                ll ans = nr * f ;       ans %= mod ;          cout << ans ; line ;   }      int main()   {fast       int t = 1 ;       // cin >> t ;          for ( int i = 1 ; i <= t ; i ++ )       {           solve ( i ) ;       }          return 0 ;   }
#include <bits/stdc++.h>   using namespace std;   map<long long, long long> mp;   void Hash(string str, long long B, long long mod) {     long long power = 1, h = 0;     long long m = (int)str.length();     for (long long i = m - 1; i >= 0; i--) {       h = h + (power * (str[i] -  a  + 1)) % mod;       h = h % mod;       power = (power * B) % mod;     }     mp[h]++;   }   bool match(string str, long long B, long long mod) {     long long power = 1, h = 0;     long long m = (int)str.length();     for (long long i = m - 1; i >= 0; i--) {       h = h + (power * (str[i] -  a  + 1)) % mod;       h = h % mod;       power = (power * B) % mod;     }     power = 1;     for (long long i = m - 1; i >= 0; i--) {       long long t1, t2;       if (str[i] ==  a ) {         t1 = h + power;         t1 = t1 % mod;         t2 = t1 + power;         t2 = t2 % mod;       } else if (str[i] ==  b ) {         t1 = h - power;         t1 = (t1 + mod) % mod;         t2 = h + power;         t2 = (t2 + mod) % mod;       } else {         t1 = h - power;         t1 = (t1 + mod) % mod;         t2 = t1 - power;         t2 = (t2 + mod) % mod;       }       power = (power * B) % mod;       if (mp[t1] != 0) return true;       if (mp[t2] != 0) return true;     }     return false;   }   int main() {     long long B[10], mod[10];     B[0] = 137, B[1] = 347;     mod[0] = 100404001, mod[1] = 1000000007;     int n, m;     scanf( %d %d , &n, &m);     string str[n], query[m];     for (int i = 0; i < n; i++) cin >> str[i];     for (int i = 0; i < m; i++) cin >> query[i];     bool ans[m];     memset(ans, true, sizeof ans);     for (int i = 0; i < 2; i++) {       mp.clear();       for (int j = 0; j < n; j++) {         Hash(str[j], B[i], mod[i]);       }       for (int j = 0; j < m; j++) {         if (match(query[j], B[i], mod[i]) == false) ans[j] = false;       }     }     for (int j = 0; j < m; j++) {       if (ans[j])         printf( YES n );       else         printf( NO n );     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, k;     cin >> n >> k;     int a[n];     for (int i = 0; i < n; i++) {       cin >> a[i];     }     int l = n - k;     int max_1 = 0;     for (int i = 0; i < (n - k); i++) {       max_1 = max(max_1, a[i] + a[2 * (n - k) - i - 1]);     }     max_1 = max(max_1, a[n - 1]);     cout << max_1 << endl;   }
#include <bits/stdc++.h>   using namespace std;   long long max(long long a, long long b) {     if (a < b) return b;     return a;   }   long long min(long long a, long long b) {     if (a < b) return a;     return b;   }   long long X;   vector<long long> x;   long long dfs(long long node, long long par, vector<vector<long long> > &v) {     long long cnt = 0;     for (int i = 0; i < v[node].size(); i++) {       long long adj = v[node][i];       if (adj == par) continue;       long long y = dfs(adj, node, v);       if (node == X) x.push_back(y);       cnt += y;     }     return cnt + 1;   }   void solve() {     x.clear();     long long n;     cin >> n >> X;     vector<vector<long long> > v(n + 1);     long long degree[n + 1];     memset(degree, 0, sizeof(degree));     vector<vector<long long> > comp;     for (int i = 0; i < n - 1; i++) {       long long a, b;       cin >> a >> b;       degree[a]++, degree[b]++;       v[a].push_back(b);       v[b].push_back(a);     }     if (degree[X] == 1 || n == 1)       cout <<  Ayush n ;     else {       dfs(X, -1, v);       long long cnt = 0;       for (int i = 0; i < x.size(); i++) cnt += max(0, x[i] - 1);       cnt += max(0, v[X].size() - 1);       if (cnt % 2 == 0) {         cout <<  Ayush n ;       } else         cout <<  Ashish n ;     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long test = 0;     cin >> test;     while (test--) solve();     return 0;   }
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:102400000,102400000 )   using std::bitset;   using namespace std;   int g[302][302][302], f[302][302];   int s[10];   int n, ans;   void updateg(int a, int b, int c) {     int i, j, tem, t;     for (i = c + 1; i < 300; i++) {       g[a][b][i] = 1;       g[a][c][i] = 1;       g[b][c][i] = 1;     }     for (i = b + 1; i <= c; i++) {       g[a][i][c] = 1;       g[b][i][c] = 1;     }     for (i = a + 1; i <= b; i++) g[i][b][c] = 1;     for (t = 1; c + t < 300; t++) g[a + t][b + t][c + t] = 1;   }   void updatef(int a, int b) {     int i, j, tem, t;     for (i = b + 1; i < 300; i++) {       f[a][i] = 1;       f[b][i] = 1;     }     for (i = a + 1; i <= b; i++) f[i][b] = 1;     for (t = 1; b + t < 300; t++) f[a + t][b + t] = 1;   }   void init() {     int i, j, tem;     memset(g, -1, sizeof(g));     ;     int a, b, c;     for (a = 0; a < 300; a++)       for (b = a; b < 300; b++)         for (c = b; c < 300; c++) {           if (g[a][b][c] == -1) {             g[a][b][c] = 0;             updateg(a, b, c);           }         }     memset(f, -1, sizeof(f));     ;     for (a = 0; a < 300; a++)       for (b = a; b < 300; b++) {         if (f[a][b] == -1) {           f[a][b] = 0;           updatef(a, b);         }       }   }   int main() {     int i, j, tem;     init();     while (scanf( %d , &n) != EOF) {       memset(s, 0, sizeof(s));       ;       for (i = 1; i <= n; i++) scanf( %d , &s[i]);       if (n == 1) {         if (s[1] != 0)           printf( BitLGM n );         else           printf( BitAryo n );       } else if (n == 2) {         if (s[1] > s[2]) swap(s[1], s[2]);         if (f[s[1]][s[2]] == 1)           printf( BitLGM n );         else           printf( BitAryo n );       } else {         sort(s + 1, s + 1 + 3);         if (g[s[1]][s[2]][s[3]] == 1)           printf( BitLGM n );         else           printf( BitAryo n );       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int t, n, a, b, p, q, z, k;     cin >> t;     while (t--) {       z = 0;       k = 0;       cin >> a >> b >> n;       p = max(a, b);       q = min(a, b);       while (k <= n) {         z++;         k = q + p;         q = p;         p = k;       }       cout << z << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int t, a[30], n, b[2010], r;   vector<int> aux[30];   int val(int x, int y) {     int hr = 0, hxt = 0;     for (int i = 1; i <= aux[x].size() / 2; i++) {       hxt = lower_bound(aux[y].begin(), aux[y].end(), aux[x][aux[x].size() - i]) -             upper_bound(aux[y].begin(), aux[y].end(), aux[x][i - 1]);       if (hxt > 0) hr = max(hr, 2 * i + hxt);     }     return hr;   }   int main() {     scanf( %d , &t);     while (t--) {       scanf( %d , &n);       for (int i = 1; i <= 26; i++) aux[i].clear();       r = 0;       for (int i = 0; i < n; i++) {         scanf( %d , &b[i]);         aux[b[i]].push_back(i);         int h = aux[b[i]].size();         r = max(r, h);       }       for (int i = 1; i < 26; i++)         for (int j = i + 1; j <= 26; j++) r = max(r, max(val(i, j), val(j, i)));       printf( %d n , r);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long b, r, g, w, i, j = 0, p = 0, n, m, s1, s2;     cin >> n >> m >> s1 >> s2;     if (s2 == 2) {       cout << s1 <<     << s2 << endl;       cout <<  1             <<     << s2 << endl;       for (i = 1; i <= n; i++) {         if (i % 2 == 1) {           for (j = 1; j <= m; j++) {             if ((i == 1 && j == 2) || (i == s1 && j == 2)) {               continue;             } else               cout << i <<     << j << endl;           }         } else {           for (j = m; j >= 1; j--) {             if ((i == 1 && j == 2) || (i == s1 && j == 2)) {               continue;             } else               cout << i <<     << j << endl;           }         }       }     } else {       cout << s1 <<     << s2 << endl;       cout << s1 <<                <<  2  << endl;       cout <<  1             <<                <<  2  << endl;       for (i = 1; i <= n; i++) {         if (i % 2 == 1) {           for (j = 1; j <= m; j++) {             if ((i == 1 && j == 2) || (i == s1 && j == s2) ||                 (i == s1 && j == 2)) {               continue;             } else               cout << i <<     << j << endl;           }         } else {           for (j = m; j >= 1; j--) {             if ((i == 1 && j == 2) || (i == s1 && j == s2) ||                 (i == s1 && j == 2)) {               continue;             } else               cout << i <<     << j << endl;           }         }       }     }     return 0;   }
#pragma GCC optimize(3,  Ofast ,  inline )      #include <bits/stdc++.h>      #define rep(i,a,b) for(int i=(a);i<=(b);i++)   using namespace std;   typedef long long ll;   typedef unsigned long long ull;   typedef pair<int, int> P;   typedef pair<double, double> Pd;   typedef pair<ll, ll> pll;   const int maxn = 1e6+10;            int n,m;   int a[111][111];   struct node   {    int x,y;    int v;   }e[10005];      int tot = 0;   bool cmp(node A,node B) {    return A.v<B.v;   }   int main()   {   #ifndef ONLINE_JUDGE       freopen( /volumes/D/acm/1.txt ,  r , stdin);   #endif            int T;       scanf( %d ,&T);       while(T--) {        tot = 0;        scanf( %d%d ,&n,&m);        rep(i,1,n) {         rep(j,1,m) {          scanf( %d ,&a[i][j]);          e[++tot]={i,j,a[i][j]};         }        }        sort(e+1,e+1+tot,cmp);        for(int i=1;i<=m;i++) {         int x = e[i].x;         int y = e[i].y;         int z = e[i].v;         for(int j=i+1;j<=m;j++) {          if(e[j].v==a[x][i]&&e[j].x==x&&e[j].y==i) {           e[j].y=y;           break;          }         }         swap(a[x][i],a[x][y]);        }        rep(i,1,n) {         rep(j,1,m) {          printf( %d ,a[i][j]);          if(j!=m) printf(   );          else printf(  n );         }        }       }       return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 200100;   mt19937 rnd;   struct Treap {     int id, y, best;     Treap *l, *r;     Treap(int id) : id(id), y(rnd()), best(id), l(NULL), r(NULL) {}   };   int n, m;   int x[MAXN];   long long len[MAXN];   int p[MAXN], b[MAXN];   set<pair<int, int> > alive;   int c[MAXN];   void update(Treap *&t) {     if (t) {       t->best = t->id;       if (t->l && x[t->l->best] < x[t->best]) t->best = t->l->best;       if (t->r && x[t->r->best] < x[t->best]) t->best = t->r->best;     }   }   void merge(Treap *&t, Treap *l, Treap *r) {     if (!l)       t = r;     else if (!r)       t = l;     else if (l->y < r->y) {       merge(l->r, l->r, r);       t = l;     } else {       merge(r->l, l, r->l);       t = r;     }     update(t);   }   void split(Treap *t, Treap *&l, Treap *&r, long long k, int id) {     if (!t) {       l = r = NULL;     } else if (x[t->id] + len[t->id] < k ||                (x[t->id] + len[t->id] == k && t->id < id)) {       split(t->r, t->r, r, k, id);       l = t;     } else {       split(t->l, l, t->l, k, id);       r = t;       update(t);     }   }   Treap *t;   void insert(int id) {     Treap *L, *R;     split(t, L, R, x[id] + len[id], id);     merge(t, L, new Treap(id));     merge(t, t, R);   }   void erase(Treap *&t, int id) {     if (t->id == id) {       merge(t, t->l, t->r);     } else if (x[t->id] + len[t->id] < x[id] + len[id] ||                (x[t->id] + len[t->id] == x[id] + len[id] && t->id < id)) {       erase(t->r, id);     } else {       erase(t->l, id);     }     update(t);   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     rnd = mt19937(0xdeadbeef);     cin >> n >> m;     for (int i = 0; i < n; ++i) {       cin >> x[i] >> len[i];       insert(i);     }     for (int i = 0; i < m; ++i) {       cin >> p[i] >> b[i];       Treap *L, *R;       split(t, L, R, p[i], 0);       int best = R ? R->best : -1;       merge(t, L, R);       if (best != -1 && x[best] <= p[i]) {         erase(t, best);         len[best] += b[i];         insert(best);         ++c[best];         while (true) {           auto it = alive.upper_bound(make_pair(x[best] - 1, 1e9));           if (it != alive.end() && it->first <= x[best] + len[best]) {             ++c[best];             erase(t, best);             len[best] += b[it->second];             insert(best);             alive.erase(it);           } else             break;         }       } else {         alive.insert(make_pair(p[i], i));       }     }     for (int i = 0; i < n; ++i) cout << c[i] <<     << len[i] <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       string s, s1, s2;       cin >> s >> s1 >> s2;       bool lock = false;       for (int i = 0; i < s.length(); i++) {         if (s[i] == s2[i]) {           swap(s1[i], s2[i]);         } else {           if (s1[i] == s2[i]) {             swap(s[i], s2[i]);           } else {             lock = true;             break;           }         }       }       if (lock)         cout <<  NO  << endl;       else {         if (s == s1)           cout <<  YES  << endl;         else           cout <<  NO  << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long int sz = 2e5;   long long int col[sz], vis[sz];   vector<long long int> adj[sz];   long long int n;   void reset() {     long long int i;     for (i = 0; i < n + 14; i++) {       col[i] = -1;       adj[i].clear();       vis[i] = 0;     }   }   void coloring(long long int n, long long int c) {     vis[n] = 1;     col[n] = c;     for (auto it : adj[n]) {       if (vis[it] == 0) coloring(it, c ^ 1);     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     ;     long long int i, j, k, len, x, y, z, c, f, flag, p, q, mx, mn, l, r, sum, ans,         tmp, it, pos, avg, m, cnt;     long long int t;     cin >> t;     while (t--) {       f = 0;       flag = 0;       ans = 0;       cnt = 0;       sum = 0;       mn = LLONG_MAX;       mx = LLONG_MIN;       string s;       cin >> n >> m;       reset();       for (i = 0; i < m; i++) {         cin >> l >> r;         adj[l].push_back(r);         adj[r].push_back(l);       }       coloring(1, 0);       vector<long long int> sol1, sol2;       for (i = 1; i <= n; i++) {         if (col[i])           sol1.push_back(i);         else           sol2.push_back(i);       }       if (sol2.size() < sol1.size()) {         cout << sol2.size() <<   n ;         for (auto dsp : sol2) cout << dsp <<    ;         cout <<   n ;         ;       } else {         cout << sol1.size() <<   n ;         for (auto dsp : sol1) cout << dsp <<    ;         cout <<   n ;         ;       }     }     return 0;   }