malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   void in(int &x) {     register int c = getchar();     x = 0;     for (; (c < 48 || c > 57); c = getchar())       ;     for (; c > 47 && c < 58; c = getchar()) {       x = (x << 1) + (x << 3) + c - 48;     }   }   const int N = 1 << 24;   long long dp[N];   string s[10004];   int main() {     int n, i, j, mask, full = N - 1;     in(n);     for (i = 0; i < n; i++) {       cin >> s[i];       mask = 0;       for (j = 0; j < 3; j++) mask |= 1 << (s[i][j] -  a );       mask ^= full;       dp[mask]++;     }     for (i = 0; i < 24; i++) {       for (mask = N - 1; mask >= 0; mask--)         if (mask & (1 << i)) {           dp[mask ^ (1 << i)] += dp[mask];         }     }     long long ret = 0;     for (i = 0; i < N; i++) ret ^= 1ll * (n - dp[i]) * (n - dp[i]);     printf( %lld n , ret);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   bool chkmax(T &x, T y) {     return x < y ? x = y, true : false;   }   template <typename T>   bool chkmin(T &x, T y) {     return x > y ? x = y, true : false;   }   int readint() {     int x = 0, f = 1;     char ch = getchar();     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) f = -1;       ch = getchar();     }     while (ch >=  0  && ch <=  9 ) {       x = x * 10 + ch -  0 ;       ch = getchar();     }     return x * f;   }   int n, m, rt;   long long a[4005], rmq[4005][20], ch[4005][2], lg2[4005], siz[4005];   long long d[4005][4005];   int getmin(int l, int r) {     int k = lg2[r - l + 1];     return a[rmq[l][k]] < a[rmq[r - (1 << k) + 1][k]] ? rmq[l][k]                                                       : rmq[r - (1 << k) + 1][k];   }   int build(int l, int r) {     int mid = getmin(l, r);     if (l != mid) ch[mid][0] = build(l, mid - 1);     if (r != mid) ch[mid][1] = build(mid + 1, r);     return mid;   }   void dfs(int u) {     if (!u) return;     siz[u] = 1;     dfs(ch[u][0]), dfs(ch[u][1]);     siz[u] += siz[ch[u][0]] + siz[ch[u][1]];     for (int i = 0; i <= siz[ch[u][0]]; i++) {       for (int j = 0; j <= siz[ch[u][1]]; j++) {         chkmax(d[u][i + j], d[ch[u][0]][i] + d[ch[u][1]][j] - 2ll * i * j * a[u]);         chkmax(d[u][i + j + 1], d[ch[u][0]][i] + d[ch[u][1]][j] -                                     2ll * i * j * a[u] + 1ll * (m - 1) * a[u] -                                     2ll * (i + j) * a[u]);       }     }   }   int main() {     n = readint();     m = readint();     for (int i = 1; i <= n; i++) a[i] = readint();     for (int i = 2; i <= n; i++) lg2[i] = lg2[i >> 1] + 1;     for (int i = 1; i <= n; i++) rmq[i][0] = i;     for (int i = 1; (1 << i) <= n; i++)       for (int j = 1; j + (1 << i) - 1 <= n; j++)         rmq[j][i] = a[rmq[j][i - 1]] < a[rmq[j + (1 << (i - 1))][i - 1]]                         ? rmq[j][i - 1]                         : rmq[j + (1 << (i - 1))][i - 1];     rt = build(1, n);     for (int i = 0; i <= n; i++)       for (int j = 0; j <= n; j++) d[i][j] = -(1ll << 60);     d[0][0] = 0;     dfs(rt);     printf( %lld n , d[rt][m]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string ans =   , s;     int n;     cin >> s >> n;     for (int i = 0; i < n; i++) {       string t;       cin >> t;       if (t.length() >= s.length())         if (s == t.substr(0, s.length()))           if (ans ==    || ans > t) ans = t;     }     if (ans ==   )       cout << s << endl;     else       cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   inline bool valid(int64_t x, int64_t y, int64_t n, int64_t m) {     return (x >= 0 && x < n && y >= 0 && y < m);   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int64_t n, m, q;     cin >> n >> m >> q;     vector<string> v(n);     for (int64_t i = 0; i < n; ++i) {       cin >> v[i];     }     int64_t dx[4] = {-1, 1, 0, 0};     int64_t dy[4] = {0, 0, -1, 1};     queue<pair<int64_t, int64_t> > qu;     vector<vector<int64_t> > dis(n, vector<int64_t>(m, -1));     for (int64_t i = 0; i < n; ++i) {       for (int64_t j = 0; j < m; ++j) {         int64_t k = 0;         for (; k < 4; ++k) {           int64_t x = i + dx[k], y = j + dy[k];           if (valid(x, y, n, m)) {             if (v[i][j] == v[x][y]) {               break;             }           }         }         if (k < 4) {           qu.push({i, j});           dis[i][j] = 0;         }       }     }     while (!qu.empty()) {       pair<int64_t, int64_t> p = qu.front();       qu.pop();       for (int64_t k = 0; k < 4; ++k) {         int64_t x = p.first + dx[k], y = p.second + dy[k];         if (valid(x, y, n, m) && dis[x][y] == -1) {           dis[x][y] = 1 + dis[p.first][p.second];           qu.push({x, y});         }       }     }     while (q--) {       int64_t i, j, p;       cin >> i >> j >> p;       --i;       --j;       char ans = v[i][j];       if (dis[i][j] > -1 && p - dis[i][j] > 0 && (p - dis[i][j]) % 2 != 0) {         if (ans ==  1 )           ans =  0 ;         else           ans =  1 ;       }       cout << ans << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int Mod = 998244353;   int add(int a, int b) { return a + b >= Mod ? a + b - Mod : a + b; }   int dec(int a, int b) { return a - b < 0 ? a - b + Mod : a - b; }   int mul(int a, int b) { return 1ll * a * b % Mod; }   void Add(int &a, int b) { a = add(a, b); }   void Dec(int &a, int b) { a = dec(a, b); }   void Mul(int &a, int b) { a = mul(a, b); }   int ksm(int a, int b) {     int ans = 1;     for (; b; b >>= 1, Mul(a, a))       if (b & 1) Mul(ans, a);     return ans;   }   const int N = 2e5 + 50;   int n, q, ans, p[N];   int sm[N], mt[N];   set<int> S;   int calc(int l, int r) {     int iv = ksm(mt[l - 1], Mod - 2);     int y = mul(mt[r - 1], iv);     int x = 1 + mul(iv, dec(sm[r - 2], sm[l - 1]));     return mul(x, ksm(y, Mod - 2));   }   void era(int x) {     auto r = S.find(x), l = r;     --l, Dec(ans, calc(*l, x));     ++r, Dec(ans, calc(x, *r));     Add(ans, calc(*l, *r));     S.erase(x);   }   void ins(int x) {     auto r = S.insert(x).first, l = r;     --l, Add(ans, calc(*l, x));     ++r, Add(ans, calc(x, *r));     Dec(ans, calc(*l, *r));   }   int main() {     cin >> n >> q;     S.insert(1);     S.insert(n + 1);     int iv = ksm(100, Mod - 2);     for (int i = 1; i <= n; i++) scanf( %d , &p[i]), Mul(p[i], iv);     mt[0] = 1;     for (int i = 1; i <= n; i++)       mt[i] = mul(mt[i - 1], p[i]), sm[i] = add(sm[i - 1], mt[i]);     ans = calc(1, n + 1);     for (int i = 1, x; i <= q; i++) {       scanf( %d , &x);       if (S.find(x) != S.end())         era(x);       else         ins(x);       cout << ans <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char inp[1000010];   char out[1000010];   int main() {     int i, j, dot_index, nonzero_index = 0, start, end, p = 0, B;     cin >> inp;     int len = strlen(inp);     dot_index = len;     for (i = 0; inp[i] ==  0  || inp[i] ==  . ; i++)       ;     for (j = len - 1; inp[j] ==  0  || inp[j] ==  . ; j--)       ;     start = i;     end = j;     for (i = 0; i < len; i++) {       if (inp[i] ==  . ) {         dot_index = i;         break;       }     }     out[p++] = inp[start];     if (start != end) out[p++] =  . ;     nonzero_index = start;     for (i = start + 1; i <= end; i++) {       if (inp[i] !=  . ) out[p++] = inp[i];     }     cout << out;     if (dot_index > nonzero_index)       B = dot_index - nonzero_index - 1;     else       B = dot_index - nonzero_index;     if (B) cout <<  E  << B;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 0x7fffffff;   const long double eps = 1e-8;   const int MAXN = 1111;   int n, m;   char g[MAXN][MAXN];   int col[MAXN][MAXN];   int sz[MAXN * MAXN];   char ans[MAXN][MAXN];   bool vis[MAXN][MAXN];   const int dx[4] = {-1, 0, 1, 0};   const int dy[4] = {0, 1, 0, -1};   int qx[MAXN * MAXN], qy[MAXN * MAXN];   void bfs(int x0, int y0) {     static int tot = 0;     ;     int l = 1, r = 1;     ++tot;     for (qx[1] = x0, qy[1] = y0, vis[x0][y0] = 1; l <= r; ++l) {       col[qx[l]][qy[l]] = tot;       for (int d = 0; d <= 3; ++d) {         int tx = qx[l] + dx[d];         int ty = qy[l] + dy[d];         if (tx > 0 && tx <= n && ty > 0 && ty <= m && !vis[tx][ty] &&             g[tx][ty] ==  . ) {           vis[tx][ty] = 1;           ++r;           qx[r] = tx;           qy[r] = ty;         }       }     }     sz[tot] = r;     ;   }   int main() {     scanf( %d%d , &n, &m);     for (int i = 1; i <= n; ++i) scanf( %s , g[i] + 1);     for (int i = 1; i <= n; ++i)       for (int j = 1; j <= m; ++j)         if (g[i][j] ==  .  && !vis[i][j]) bfs(i, j);     for (int i = 1; i <= n; ++i)       for (int j = 1; j <= m; ++j)         if (g[i][j] ==  . )           ans[i][j] =  . ;         else {           int p[4], t = 0, s = 1;           for (int d = 0; d <= 3; ++d) {             int tx = i + dx[d], ty = j + dy[d];             if (tx > 0 && tx <= n && ty > 0 && ty <= m && g[tx][ty] ==  . ) {               bool ok = 1;               for (int k = 0; k <= t - 1; ++k)                 if (p[k] == col[tx][ty]) {                   ok = 0;                   break;                 }               if (ok) {                 p[t++] = col[tx][ty];                 s += sz[col[tx][ty]];               }             }           }           ans[i][j] =  0  + s % 10;         }     for (int i = 1; i <= n; ++i) printf( %s n , ans[i] + 1);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   #define int long long   int32_t main()   {       int t;       cin >> t;       while (t--)       {           int n;           cin >> n;          int c=0,i=1;          while(n>0){              c++;              n-=i;              i+=2;          }          cout<<c<<endl;       }   }
#include <bits/stdc++.h>   using namespace std;   int n;   bool vis[100][100];   char g[100][100];   void dfs(int a, int b) {     if (vis[a][b] || a > n || a < 1 || b < 1 || b > n || g[a][b] ==  1 ) return;     vis[a][b] = 1;     dfs(a + 1, b);     dfs(a, b + 1);     dfs(a - 1, b);     dfs(a, b - 1);   }   int dist(pair<int, int> a, pair<int, int> b) {     return (a.first - b.first) * (a.first - b.first) +            (a.second - b.second) * (a.second - b.second);   }   int main() {     cin >> n;     int r1, c1, r2, c2;     cin >> r1 >> c1 >> r2 >> c2;     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= n; j++) {         cin >> g[i][j];       }     }     set<pair<int, int>> a;     set<pair<int, int>> b;     dfs(r1, c1);     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= n; j++) {         if (vis[i][j]) a.insert({i, j});         vis[i][j] = 0;       }     }     dfs(r2, c2);     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= n; j++) {         if (vis[i][j]) b.insert({i, j});       }     }     if (a == b)       cout << 0 << endl;     else {       int s = 10000000;       for (auto x : a) {         for (auto y : b) {           s = min(s, dist(x, y));         }       }       cout << s << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   typedef vector<vector<int>> graph;   ifstream in( buffcraft.in , ios::in);   ofstream out( buffcraft.out , ios::out);   int main() {     double m, R, ans = 0;     cin >> m >> R;     for (int x = 2; x < m; x++)       ans += ((x - 1) * 2 + 2 * sqrt(2.0)) * 2 * (m - x);     ans += 2 * m + (2 + sqrt(2.0)) * 2 * (m - 1);     cout << setprecision(15) << ans / (m * m) * R;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct rect {     int x1, y1, x2, y2;   };   int main() {     ios_base::sync_with_stdio(false);     int n;     cin >> n;     vector<rect> v(n);     int minx = 1000000000;     int miny = 1000000000;     for (int i = 0; i < n; ++i) {       cin >> v[i].x1 >> v[i].y1 >> v[i].x2 >> v[i].y2;       minx = min(minx, v[i].x1);       miny = min(miny, v[i].y1);     }     cout <<  YES  << endl;     for (int i = 0; i < n; ++i) {       int x = (v[i].x1 - minx) % 2;       int y = (v[i].y1 - miny) % 2;       if (x == 0 && y == 0) {         cout << 1;       } else if (x == 1 && y == 0) {         cout << 2;       } else if (x == 0 && y == 1) {         cout << 3;       } else {         cout << 4;       }       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m;   pair<long long, int> p[200005];   int main(int argc, char const *argv[]) {     ios_base::sync_with_stdio(false);     cin >> n;     for (int i = 0; i < (n); i++) {       cin >> p[i].first;       p[i].second = i;     }     priority_queue<pair<long long, int>, vector<pair<long long, int> >,                    greater<pair<long long, int> > >         que[3];     for (int cnt = 0; cnt < (2); cnt++) {       for (int i = 0; i < (n); i++) {         int a;         cin >> a;         a--;         que[a].push(p[i]);       }     }     bool used[n];     fill(used, used + n, false);     cin >> m;     for (int i = 0; i < (m); i++) {       int c;       cin >> c;       c--;       while (!que[c].empty() && used[que[c].top().second]) que[c].pop();       if (que[c].empty())         cout << -1;       else {         cout << que[c].top().first;         used[que[c].top().second] = true;         que[c].pop();       }       if (i < m - 1)         cout <<    ;       else         cout << endl;     }     return 0;   }
#include <bits/stdc++.h> // Include every standard library   using namespace std;      typedef long long LL;   typedef pair<int, int> pii;   typedef pair<LL, LL> pll;   typedef pair<string, string> pss;   typedef vector<int> vi;   typedef vector<vi> vvi;   typedef vector<pii> vii;   typedef vector<LL> vl;   typedef vector<vl> vvl;      double EPS = 1e-9;   int INF = 1000000005;   long long INFF = 1000000000000000005LL;   double PI = acos(-1);   int dirx[8] = { -1, 0, 0, 1, -1, -1, 1, 1 };   int diry[8] = { 0, 1, -1, 0, -1, 1, -1, 1 };      #ifdef TESTING   #define DEBUG fprintf(stderr,  ====TESTING==== n )   #define VALUE(x) cerr <<  The value of   << #x <<   is   << x << endl   #define debug(...) fprintf(stderr, __VA_ARGS__)   #else   #define DEBUG   #define VALUE(x)   #define debug(...)   #endif      #define FOR(a, b, c) for (int(a) = (b); (a) < (c); ++(a))   #define FORN(a, b, c) for (int(a) = (b); (a) <= (c); ++(a))   #define FORD(a, b, c) for (int(a) = (b); (a) >= (c); --(a))   #define FORSQ(a, b, c) for (int(a) = (b); (a) * (a) <= (c); ++(a))   #define FORC(a, b, c) for (char(a) = (b); (a) <= (c); ++(a))   #define FOREACH(a, b) for (auto&(a) : (b))   #define REP(i, n) FOR(i, 0, n)   #define REPN(i, n) FORN(i, 1, n)   #define MAX(a, b) a = max(a, b)   #define MIN(a, b) a = min(a, b)   #define SQR(x) ((LL)(x) * (x))   #define RESET(a, b) memset(a, b, sizeof(a))   #define fi first   #define se second   #define mp make_pair   #define pb push_back   #define ALL(v) v.begin(), v.end()   #define ALLA(arr, sz) arr, arr + sz   #define SIZE(v) (int)v.size()   #define SORT(v) sort(ALL(v))   #define REVERSE(v) reverse(ALL(v))   #define SORTA(arr, sz) sort(ALLA(arr, sz))   #define REVERSEA(arr, sz) reverse(ALLA(arr, sz))   #define PERMUTE next_permutation   #define TC(t) while (t--)            int main()   {       int line;       cin>>line;          TC(line)       {           LL n;           cin>>n;           if(n==1)cout<<0<<endl;           else if(n==2)cout<<1<<endl;           else if(n==3)cout<<2<<endl;           else           {               if(n&1) cout<<3<<endl;               else cout<<2<<endl;           }       }         }
#include <bits/stdc++.h>   using namespace std;   int main() {     int i, n, rem, k, f = 0, c = 0;     cin >> n;     vector<string> s;     if (n == 0) {       cout <<  zero ;       return 0;     }     while (n != 0) {       rem = n % 10;       n = n / 10;       c++;       if (rem == 0) {         rem = n % 10;         if (rem == 1) {           cout <<  ten ;         } else if (rem == 2) {           cout <<  twenty ;         } else if (rem == 3) {           cout <<  thirty ;         } else if (rem == 4) {           cout <<  forty ;         } else if (rem == 5) {           cout <<  fifty ;         } else if (rem == 6) {           cout <<  sixty ;         } else if (rem == 7) {           cout <<  seventy ;         } else if (rem == 8) {           cout <<  eighty ;         } else if (rem == 9) {           cout <<  ninety ;         }         return 0;       } else if (f == 0) {         f = 1;         if (rem == 1) {           s.push_back( one );         } else if (rem == 2) {           s.push_back( two );         } else if (rem == 3) {           s.push_back( three );         } else if (rem == 4) {           s.push_back( four );         } else if (rem == 5) {           s.push_back( five );         } else if (rem == 6) {           s.push_back( six );         } else if (rem == 7) {           s.push_back( seven );         } else if (rem == 8) {           s.push_back( eight );         } else if (rem == 9) {           s.push_back( nine );         }       } else if (f == 1) {         if (rem == 1) {           if (s[0] ==  one ) {             cout <<  eleven ;             return 0;           } else if (s[0] ==  two ) {             cout <<  twelve ;             return 0;           } else if (s[0] ==  three ) {             cout <<  thirteen ;             return 0;           } else if (s[0] ==  four ) {             cout <<  fourteen ;             return 0;           } else if (s[0] ==  five ) {             cout <<  fifteen ;             return 0;           } else if (s[0] ==  six ) {             cout <<  sixteen ;             return 0;           } else if (s[0] ==  seven ) {             cout <<  seventeen ;             return 0;           } else if (s[0] ==  eight ) {             cout <<  eighteen ;             return 0;           } else if (s[0] ==  nine ) {             cout <<  nineteen ;             return 0;           }         } else if (rem == 2) {           s.push_back( twenty );         } else if (rem == 3) {           s.push_back( thirty );         } else if (rem == 4) {           s.push_back( forty );         } else if (rem == 5) {           s.push_back( fifty );         } else if (rem == 6) {           s.push_back( sixty );         } else if (rem == 7) {           s.push_back( seventy );         } else if (rem == 8) {           s.push_back( eighty );         } else if (rem == 9) {           s.push_back( ninety );         }       }     }     if (c == 1) {       cout << s[0];     } else {       cout << s[1] <<  -  << s[0];     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int trash = 0;   long long int a[50], c[50];   long long int value2power[50];   long long int n, m;   priority_queue<long long int> mainPQ;   vector<long long int> queueArray;   bool test(priority_queue<long long int> &PQ, long long int *b,             long long int n) {     for (long long int i = n; i >= 1; i--) {       for (long long int j = 1; j <= b[i]; j++) {         if (PQ.empty()) {           return true;         }         long long int top = PQ.top();         PQ.pop();         if (top >= value2power[i + 1]) {           return false;         }       }     }     if (PQ.empty()) {       return true;     } else {       return false;     }   }   bool cutoffRemain(long long int num, long long int n) {     priority_queue<long long int> auxiliaryPQ;     long long int size = queueArray.size();     for (long long int i = 1; i <= size; i++) {       auxiliaryPQ.push(queueArray[i - 1]);     }     for (long long int i = 1; i <= n; i++) {       c[i] = a[i];     }     for (long long int i = 1; i <= n; i++) {       if (c[i] > num) {         for (long long int j = 1; j <= c[i] - num; j++) {           auxiliaryPQ.push(value2power[i]);         }         c[i] = num;       }     }     long long int temp = c[n];     for (long long int i = n; i >= 2; i--) {       c[i] = c[i - 1] - c[i];     }     for (long long int i = 1; i <= n - 1; i++) {       c[i] = c[i + 1];     }     c[n] = temp;     return test(auxiliaryPQ, c, n);   }   int main() {     value2power[1] = 1;     for (long long int i = 2; i <= 49; i++) {       value2power[i] = 2 * value2power[i - 1];     }     long long int temp;     cin >> m;     for (long long int i = 1; i <= m; i++) {       scanf( %lld , &temp);       bool mark = true;       for (long long int j = 1; j <= 49; j++) {         if (temp == value2power[j]) {           a[j]++;           mark = false;           break;         }       }       if (mark) {         queueArray.push_back(temp);         mainPQ.push(temp);       }     }     long long int n = 0;     for (long long int i = 1; i <= 40; i++) {       if (a[i] < a[i + 1]) {         for (long long int j = 1; j <= a[i + 1] - a[i]; j++) {           queueArray.push_back(value2power[i + 1]);           mainPQ.push(value2power[i + 1]);         }         a[i + 1] = a[i];       }     }     for (long long int i = 40; i >= 1; i--) {       if (a[i] != 0) {         n = i;         break;       }     }     if (mainPQ.size() > a[1]) {       cout << -1;     } else {       bool v = cutoffRemain(a[1], n);       if (v == false) {         cout << -1;       } else {         long long int minremain = 0;         long long int maxremain = a[1];         while (minremain < maxremain) {           long long int mid = (minremain + maxremain) / 2;           if (cutoffRemain(mid, n)) {             maxremain = mid;           } else {             minremain = mid + 1;           }         }         for (long long int i = minremain; i <= a[1]; i++) {           printf( %lld  , i);         }       }     }   }
#include <bits/stdc++.h>   using namespace std;   const long long N = 1e6;   const long long mod = 1e9 + 7;   vector<long long> primes;   bool not_prime[N];   void sieve_of_eratosthenes(long long n) {     for (long long i = 2; i < N; i++) {       if (not_prime[i]) continue;       primes.push_back(i);       for (long long j = 2 * i; j < N; j += i) {         not_prime[j] = 1;       }     }   }   void solve() {     long long n;     cin >> n;     long long ans = upper_bound(primes.begin(), primes.end(), n) - primes.begin();     ans += 1;     long long sq = sqrt(n);     ans -= (upper_bound(primes.begin(), primes.end(), sq) - primes.begin());     cout << ans;   }   int32_t main() {     sieve_of_eratosthenes(1e6);     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long t = 1;     cin >> t;     while (t--) {       solve();       cout <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<long long> a[100005], vis(100005, 0), tree[100005], lev[2];   long long n, m, k;   set<long long> v;   stack<long long> st;   void dfs(long long node, long long par) {     vis[node] = 1;     st.push(node);     for (auto i : a[node])       if (!vis[i] and v.find(i) != v.end()) {         tree[node].push_back(i);         tree[i].push_back(node);         dfs(i, node);       } else if (v.find(i) != v.end() and i != par) {         cout << 2 <<   n ;         vector<long long> ans;         while (!st.empty() and st.top() != i) {           ans.push_back(st.top());           st.pop();         }         ans.push_back(i);         cout << (long long)ans.size() <<   n ;         for (auto i : ans) cout << i <<    ;         exit(0);       }     st.pop();   }   void dfs1(long long node, long long par, long long d) {     lev[d].push_back(node);     for (auto i : tree[node])       if (i != par) {         dfs1(i, node, 1 - d);       }   }   void get_subgraph() {     queue<long long> q;     q.push(1);     v.insert(1);     while (!q.empty()) {       auto cur = q.front();       q.pop();       for (auto i : a[cur]) {         if (v.find(i) == v.end()) {           v.insert(i);           q.push(i);           if ((long long)v.size() == k) break;         }       }       if ((long long)v.size() == k) break;     }   }   void solve() {     cin >> n >> m >> k;     for (long long i = 0; i < m; i++) {       long long x, y;       cin >> x >> y;       a[x].push_back(y);       a[y].push_back(x);     }     get_subgraph();     dfs(1, -1);     dfs1(1, -1, 0);     long long req = (k + 1) / 2;     cout << 1 <<   n ;     vector<long long> ans;     if ((long long)lev[0].size() >= req)       ans = lev[0];     else       ans = lev[1];     for (long long i = 0; i < req; i++) cout << ans[i] <<    ;   }   signed main() {     long long TESTS = 1;     while (TESTS--) {       solve();     }     return 0;   }