malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   struct BIT {     long long T[1000100];     long long ALL;     BIT() { ALL = 0; }     void add(int pos, long long w) {       ++pos;       ALL += w;       for (; pos < 1000100; pos += (pos & (-pos))) T[pos] += w;     }     long long all_from(int pos) {       long long ret = ALL;       for (; pos > 0; pos -= pos & (-pos)) ret -= T[pos];       return ret;     }   };   int N, M, H[1000100], FL[1000100], FR[1000100];   stack<int> pos;   vector<int> ib, ie, spl, spr, val;   vector<int> ids;   inline bool icompare(const int& f, const int& s) {     return ie[f] - ib[f] > ie[s] - ib[s];   }   vector<double> ans;   vector<int> Q, qid;   inline bool qcompare(const int& f, const int& s) { return Q[f] > Q[s]; }   BIT rem_val, rem_sum;   int main() {     scanf( %d , &N);     H[0] = H[N + 1] = -1100000000;     for (int i = 0; i < N; ++i) scanf( %d , &H[i + 1]);     pos.push(0);     for (int i = 1; i <= N; ++i) {       while (H[pos.top()] > H[i]) pos.pop();       FL[i] = pos.top();       pos.push(i);     }     while (!pos.empty()) pos.pop();     pos.push(N + 1);     for (int i = N; i > 0; --i) {       while (H[pos.top()] >= H[i]) pos.pop();       FR[i] = pos.top();       pos.push(i);     }     for (int i = 1; i <= N; ++i) {       ib.push_back(FL[i] + 1);       ie.push_back(FR[i] - 1);       val.push_back(H[i]);       spl.push_back(i - FL[i] - 1);       spr.push_back(FR[i] - i - 1);     }     for (int i = 0; i < ((int)(ib).size()); ++i) ids.push_back(i);     sort(ids.begin(), ids.end(), icompare);     scanf( %d , &M);     ans.resize(M);     Q.resize(M);     for (int i = 0; i < M; ++i) qid.push_back(i);     for (int i = 0; i < M; ++i) scanf( %d , &Q[i]);     sort(qid.begin(), qid.end(), qcompare);     long long val_all = 0, sum_all = 0;     int cur = 0;     for (int i = 0; i < ((int)(qid).size()); ++i) {       int V = Q[qid[i]];       while (cur < ((int)(ids).size()) && ie[ids[cur]] - ib[ids[cur]] + 1 >= V) {         int T = ids[cur++];         val_all += val[T] * 1LL * (ie[T] - ib[T] + 1);         sum_all += val[T];         if (spl[T] > 0)           rem_val.add(spl[T], spl[T] * 1LL * val[T]), rem_sum.add(spl[T], val[T]);         if (spr[T] > 0)           rem_val.add(spr[T], spr[T] * 1LL * val[T]), rem_sum.add(spr[T], val[T]);       }       long long out = val_all - (V - 1) * sum_all;       out -= rem_val.all_from(V) - (V - 1) * rem_sum.all_from(V);       ans[qid[i]] = ((double)out) / (N - V + 1);     }     for (int i = 0; i < M; ++i) printf( %.12lf n , ans[i]);     return 0;   }
#include <bits/stdc++.h>   const double PI = acos(-1.0);   using namespace std;   char a[2000010], b[2000010];   int main() {     int n;     int i;     int x, y, z;     int p, q;     while (~scanf( %d %s %s , &n, a, b)) {       x = y = z = 0;       for (i = 0; i < 2 * n; i++) {         if (a[i] ==  1  && b[i] ==  1 ) {           z++;         } else if (a[i] ==  1 ) {           x++;         } else if (b[i] ==  1 ) {           y++;         }       }       p = x + (z + 1) / 2;       q = y + z - (z + 1) / 2;       if (p == q || p + 1 == q) {         puts( Draw );       } else if (p > q) {         puts( First );       } else {         puts( Second );       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int T;   string hxt[16];   int main() {     cin >> T;     while (T--) {       int n, m;       cin >> n >> m;       for (int i = 1; i <= n; i++) cin >> hxt[i];       bool iif = false;       for (int i = 0; i < m; i++) {         char x = hxt[1][i];         for (char j =  a ; j <=  z ; j++) {           hxt[1][i] = j;           bool flag = true;           for (int k = 2; k <= n; k++) {             int js = 0;             for (int l = 0; l < m; l++) {               if (hxt[k][l] != hxt[1][l]) js++;               if (js > 1) break;             }             if (js > 1) {               flag = false;               break;             }           }           if (flag) {             cout << hxt[1] << endl;             iif = true;             break;           }           hxt[1][i] = x;         }         if (iif) break;       }       if (!iif) cout << -1 << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     vector<string> v;     for (int i = 0; i < 3; i++) {       string s;       cin >> s;       v.push_back(s);     }     vector<string> so;     vector<string> po;     vector<string> mo;     for (int i = 0; i < v.size(); i++) {       if (v[i][1] ==  s )         so.push_back(v[i]);       else if (v[i][1] ==  p )         po.push_back(v[i]);       else if (v[i][1] ==  m )         mo.push_back(v[i]);     }     sort(so.begin(), so.end());     sort(po.begin(), po.end());     sort(mo.begin(), mo.end());     if (v[0] == v[1] && v[1] == v[2])       cout << 0 << endl;     else if (v[0] == v[1] || v[0] == v[2] || v[1] == v[2])       cout << 1 << endl;     else if (so.size() == 3) {       int m1 = (so[2][0] -  0 ) - (so[1][0] -  0 );       int m2 = (so[1][0] -  0 ) - (so[0][0] -  0 );       if (m1 == 1 && m2 == 1)         cout <<  0  << endl;       else if (m1 <= 2 || m2 <= 2)         cout <<  1  << endl;       else         cout <<  2  << endl;     } else if (mo.size() == 3) {       int m1 = (mo[2][0] -  0 ) - (mo[1][0] -  0 );       int m2 = (mo[1][0] -  0 ) - (mo[0][0] -  0 );       if (m1 == 1 && m2 == 1)         cout <<  0  << endl;       else if (m1 <= 2 || m2 <= 2)         cout <<  1  << endl;       else         cout <<  2  << endl;     } else if (po.size() == 3) {       int m1 = (po[2][0] -  0 ) - (po[1][0] -  0 );       int m2 = (po[1][0] -  0 ) - (po[0][0] -  0 );       if (m1 == 1 && m2 == 1)         cout <<  0  << endl;       else if (m1 <= 2 || m2 <= 2)         cout <<  1  << endl;       else         cout <<  2  << endl;     } else if (so.size() == 2) {       int m1 = (so[1][0] -  0 ) - (so[0][0] -  0 );       if (m1 == 1 || m1 == 2)         cout <<  1  << endl;       else         cout <<  2 n ;     } else if (mo.size() == 2) {       int m1 = (mo[1][0] -  0 ) - (mo[0][0] -  0 );       if (m1 == 1 || m1 == 2)         cout <<  1  << endl;       else         cout <<  2 n ;     } else if (po.size() == 2) {       int m1 = (po[1][0] -  0 ) - (po[0][0] -  0 );       if (m1 == 1 || m1 == 2)         cout <<  1  << endl;       else         cout <<  2 n ;     } else       cout <<  2 n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e3 + 2;   int n;   int a[N];   map<int, int> m;   map<pair<int, int>, bool> checked;   int main() {     cin >> n;     int zero = 0;     for (int i = 0; i < n; ++i) {       scanf( %d , a + i);       if (!a[i]) zero++;       ;       m[a[i]]++;     }     sort(a, a + n);     int ans = -1;     int help1, help2, help3;     for (int i = 0; i < n; ++i)       for (int j = 0; j < n; ++j)         if (i != j) {           if (!a[i] and (!a[j])) continue;           if (checked[make_pair(a[i], a[j])]) continue;           checked[make_pair(a[i], a[j])] = true;           map<int, int> m1;           help3 = 2;           m1[a[i]]++, m1[a[j]]++;           help1 = a[i];           help2 = a[j];           while (m1[help1 + help2] < m[help1 + help2]) {             m1[help1 + help2]++;             help3++;             help2 += help1;             help1 = help2 - help1;           }           ans = max(ans, help3);         }     ans = max(ans, zero);     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 4005;   vector<int> v[maxn];   int vis[maxn][maxn];   int main(void) {     int n, m, ans = maxn;     memset(vis, 0, sizeof(vis));     scanf( %d%d , &n, &m);     for (int i = 0; i < m; i++) {       int x, y;       scanf( %d%d , &x, &y);       v[x].push_back(y);       v[y].push_back(x);       vis[x][y] = vis[y][x] = 1;     }     for (int i = 1; i <= n; i++) {       for (int j = i + 1; j <= n; j++) {         if (!vis[i][j]) continue;         for (int k = j + 1; k <= n; k++) {           if (!vis[i][k] || !vis[k][j]) continue;           int cur = 0;           int len = v[i].size();           for (int d = 0; d < len; d++) {             if (v[i][d] != j && v[i][d] != k) cur++;           }           len = v[j].size();           for (int d = 0; d < len; d++) {             if (v[j][d] != i && v[j][d] != k) cur++;           }           len = v[k].size();           for (int d = 0; d < len; d++) {             if (v[k][d] != i && v[k][d] != j) cur++;           }           ans = min(ans, cur);         }       }     }     if (ans == maxn)       printf( -1 n );     else       printf( %d n , ans);   }
#include <bits/stdc++.h>   using namespace std;   int T, N;   int arr[500005];   stack<int> stk;   vector<pair<int, int>> v;   int main() {     cin.sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> T;     while (T--) {       cin >> N;       bool pos = 1;       while (stk.size()) {         stk.pop();       }       v.clear();       for (int i = 1; i <= N; i++) {         while (stk.size() && stk.top() == i) {           stk.pop();         }         cin >> arr[i];         if (arr[i] == -1) {           if (stk.empty()) {             arr[i] = N + 1;           } else {             arr[i] = stk.top();           }         }         v.push_back({-arr[i], i});         if (stk.size() && stk.top() < arr[i]) {           pos = 0;         }         stk.push(arr[i]);       }       if (pos) {         sort(v.begin(), v.end());         int cnt = N;         for (auto p : v) {           arr[p.second] = cnt--;         }         for (int i = 1; i <= N; i++) {           cout << arr[i] <<    ;         }         cout <<   n ;       } else {         cout << -1 <<   n ;       }     }   }
#include <bits/stdc++.h>   using namespace std;   string s;   int yekdast(char c, int l, int r) {     int ans = 0;     for (int i = l; i <= r; i++) {       if (s[i] != c) ans++;     }     return ans;   }   int check(char c, int l, int r) {     if ((r - l) > 1) {       int mid1 = (floor((l * 1.0 + r * 1.0) / 2.0)),           mid2 = (ceil((l * 1.0 + r * 1.0) / 2.0));       int first = check(char(c + 1), l, mid1) + yekdast(c, mid2, r);       int second = check(char(c + 1), mid2, r) + yekdast(c, l, mid1);       return min(first, second);     } else if (r == l + 1) {       int first = check(char(c + 1), l, l) + yekdast(c, r, r);       int second = check(char(c + 1), r, r) + yekdast(c, l, l);       return min(first, second);     } else {       return yekdast(c, l, r);     }   }   int t, n;   int main() {     cin >> t;     for (int i = 0; i < t; i++) {       cin >> n >> s;       cout << check( a , 0, n - 1) << endl;     }   }
#include <bits/stdc++.h>   const int N = 1e5 + 2, p = 1e9 + 7;   int siz[N], f[N];   int n, m, x, y, z, i, c;   inline void read(int &x) {     c = getchar();     while ((c < 48) || (c > 57)) c = getchar();     x = c ^ 48;     c = getchar();     while ((c >= 48) && (c <= 57)) {       x = x * 10 + (c ^ 48);       c = getchar();     }   }   int getf(register int x) {     if (f[x] == x) return f[x];     f[x] = getf(f[x]);     siz[f[x]] += siz[x];     siz[x] = 0;     return f[x];   }   inline int ksm(register int x, register int y) {     register int r = 1;     while (y) {       if (y & 1) r = (long long)r * x % p;       x = (long long)x * x % p;       y >>= 1;     }     return r;   }   int main() {     read(n);     read(m);     for (i = 1; i <= n; i++) siz[f[i] = i] = 1;     for (i = 1; i < n; i++) {       read(x);       read(y);       read(z);       if (z == 0) {         siz[getf(y)] += siz[getf(x)];         siz[f[x]] = 0;         f[f[x]] = f[y];       }     }     c = ksm(n, m);     for (i = 1; i <= n; i++)       if (siz[i]) c = (c - ksm(siz[i], m) + p) % p;     printf( %d , c);   }
#include <bits/stdc++.h>   using namespace std;   int n, m;   char name[2000], part[2000000];   int work() {     int p = 0;     for (int i = 0; i < m; i++) {       if (part[i] == name[p]) p++;       if (p == n) return i;     }     return m;   }   int main() {     scanf( %s , name);     scanf( %s , part);     n = strlen(name), m = strlen(part);     int x = work();     reverse(name, name + n);     reverse(part, part + m);     int y = work();     printf( %d n , max(0, m - y - x - 1));     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int power(int b, int pw) {     long long int res = 1;     for (int i = 1; i <= pw; i++) {       res = res * b;     }     return res;   }   long long int typ[1000000];   int main() {     ios_base::sync_with_stdio(false);     long long int n;     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> typ[i];     }     set<int> prev;     vector<pair<int, int> > ns;     long long int cnt = 0;     long long int from = 1;     for (int i = 1; i <= n; i++) {       if (prev.find(typ[i]) != prev.end()) {         ns.push_back(make_pair(from, i));         prev.clear();         from = i + 1;       } else {         prev.insert(typ[i]);       }     }     if (ns.size() == 0) {       printf( -1 n );       return 0;     }     cout << ns.size() << endl;     int temp = ns.size();     for (int i = 0; i < ns.size(); i++) {       if (i == temp - 1) {         cout << ns[i].first <<     << n << endl;         return 0;       }       cout << ns[i].first <<     << ns[i].second << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 5010;   int n, m;   int pnt[N * 4], last;   char tab[N][N], a[N][N];   int find(int x) {     if (x != pnt[x]) pnt[x] = find(pnt[x]);     return pnt[x];   }   int id(int x, int y, int d) { return (x * m + y) * 4 + d; }   void add(int x, int y) {     pnt[id(x, y, 0)] = x - 1 >= 0 ? id(x - 1, y, 0) : last;     pnt[id(x, y, 1)] = x + 1 < n ? id(x + 1, y, 1) : last;     pnt[id(x, y, 2)] = y - 1 >= 0 ? id(x, y - 1, 2) : last;     pnt[id(x, y, 3)] = y + 1 < m ? id(x, y + 1, 3) : last;   }   void solve() {     int ans = 0, cnt;     last = n * m * 4;     for (int i = 0; i < n; ++i) scanf( %s , tab[i]);     for (int i = 0; i < n; ++i)       for (int j = 0; j < m; ++j) {         if (tab[i][j] ==  . ) continue;         for (int u = 0; u <= last; ++u) pnt[u] = u;         for (int u = 0; u < n; ++u)           for (int v = 0; v < m; ++v) {             a[u][v] = tab[u][v];             if (a[u][v] ==  . ) add(u, v);           }         int x = i, y = j, t = 0;         while (1) {           t++;           int dir;           if (a[x][y] ==  U ) dir = 0;           if (a[x][y] ==  D ) dir = 1;           if (a[x][y] ==  L ) dir = 2;           if (a[x][y] ==  R ) dir = 3;           add(x, y);           int p = find(id(x, y, dir));           if (p == last) break;           x = p / 4 / m;           y = p / 4 % m;         }         if (ans < t)           ans = t, cnt = 1;         else if (ans == t)           cnt++;       }     printf( %d %d n , ans, cnt);   }   int main() {     while (scanf( %d%d , &n, &m) != EOF) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<long long> adj[100005];   long long a[100005];   long long col;   bool ok;   bool dfs(long long v, long long par) {     ok &= (col == a[v]);     for (auto i : adj[v]) {       if (i != par) dfs(i, v);     }   }   bool fn(long long v) {     bool res = 1;     for (auto i : adj[v]) {       ok = 1;       col = a[i];       dfs(i, v);       res &= ok;     }     return res;   }   int main() {     int t = 1;     ios_base::sync_with_stdio(false);     cin.tie(nullptr);     cout.tie(nullptr);     while (t--) {       long long n;       cin >> n;       long long i;       long long p = -1, q = -1;       for (i = 1; i < n; i++) {         long long x, y;         cin >> x >> y;         adj[x].push_back(y);         adj[y].push_back(x);       }       for (i = 0; i < n; i++) cin >> a[i + 1];       for (i = 1; i <= n; i++) {         for (auto j : adj[i]) {           if (a[j] != a[i]) {             p = i;             q = j;           }         }       }       if (q == -1) {         cout <<  YES  << endl;         cout << 1 << endl;         continue;       }       bool a1 = fn(p);       bool a2 = fn(q);       if (a1) {         cout <<  YES  << endl;         cout << p << endl;       } else if (a2) {         cout <<  YES  << endl;         cout << q << endl;       } else         cout <<  NO  << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int R, r, k;   int main() {     int T;     scanf( %d , &T);     while (T--) {       scanf( %d%d%d , &R, &r, &k);       double a = R, b = r;       printf( %lf n , 1 / (1 / (a - b) + k * k * (a - b) / a / b));     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 300005;   priority_queue<pair<long long, int> > Q;   int h[N], a[N];   int n, m, k, p;   bool check(long long lim) {     static long long now[N];     for (int i = 1; i <= n; i++) now[i] = lim;     while (!Q.empty()) Q.pop();     for (int i = 1; i <= n; i++)       if (now[i] - 1ll * a[i] * m < h[i]) Q.push(make_pair(-lim / a[i], i));     for (int i = 1; i <= m; i++)       for (int j = 1; j <= k; j++) {         if (Q.empty()) return true;         pair<long long, int> mx = Q.top();         Q.pop();         if (-mx.first < i) return false;         now[mx.second] += p;         if (now[mx.second] - 1ll * a[mx.second] * m < h[mx.second])           Q.push(make_pair(-now[mx.second] / a[mx.second], mx.second));       }     return Q.empty();   }   int main() {     scanf( %d%d%d%d , &n, &m, &k, &p);     for (int i = 1; i <= n; i++) scanf( %d%d , &h[i], &a[i]);     long long l = 0, r = 6e12, ans;     while (l <= r) {       long long mid = (l + r) >> 1ll;       if (check(mid))         ans = mid, r = mid - 1;       else         l = mid + 1;     }     printf( %lld , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = (int)3e5 + 5;   const int K = (int)3e5 + 5;   vector<pair<int, int>> adj[N];   queue<pair<int, int>> q;   bool visited[N];   int res[300005];   int n;   int k;   int d;   int main() {     scanf( %d%d%d , &n, &k, &d);     for (int i = 0; i < k; i++) {       int place;       scanf( %d , &place);       q.push({place, 0});     }     for (int i = 0; i < n - 1; i++) {       int u, v;       scanf( %d%d , &u, &v);       adj[u].push_back({v, i + 1});       adj[v].push_back({u, i + 1});     }     while (!q.empty()) {       int pos = q.front().first;       int from = q.front().second;       q.pop();       if (visited[pos]) continue;       visited[pos] = 1;       for (pair<int, int> u : adj[pos]) {         if (u.first != from) {           if (visited[u.first])             res[u.second] = 1;           else             q.push({u.first, pos});         }       }     }     int rescnt = 0;     for (int i = 1; i <= n - 1; i++)       if (res[i]) rescnt++;     cout << rescnt << endl;     for (int x = 1; x <= n - 1; x++)       if (res[x]) cout << x <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int cnt, n;   string ss;   int main() {     cin >> n >> ss;     for (int i = 0; i < n; i++) {       if (i < n - 1 && ((ss[i] ==  R  && ss[i + 1] ==  U ) ||                         (ss[i] ==  U  && ss[i + 1] ==  R ))) {         i++;         cnt++;       } else         cnt++;     }     cout << cnt << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, s, i, x, y;     cin >> n >> s;     int sol = 100;     int f = 1;     for (i = 0; i < n; i++) {       cin >> x >> y;       if (x < s) {         if (y) {           sol = min(sol, y);         }       }       if (x < s || (x == s && y == 0)) {         f = 0;       }     }     if (f)       cout << -1 << endl;     else       cout << 100 - sol << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long l, r, ans = 0;   int main() {     cin >> l >> r;     for (long long i = 1; i <= r; i *= 2) {       for (long long j = 1; j <= r; j *= 3) {         if (i * j >= l && i * j <= r) ans++;       }     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using pii = pair<int, int>;   using vpii = vector<pii>;   using vi = vector<int>;   using vvi = vector<vi>;   using ll = long long;   using vll = vector<long long>;   template <class T>   using min_queue = priority_queue<T, vector<T>, greater<T>>;   template <class T>   istream &operator>>(istream &, vector<T> &);   template <class T>   ostream &operator<<(ostream &, const vector<T> &);   template <class T, class U>   istream &operator>>(istream &, pair<T, U> &);   template <class T, class U>   ostream &operator<<(ostream &, const pair<T, U> &);   template <class T>   struct Inf {     static constexpr T inf() {       return std::numeric_limits<T>::has_infinity()                  ? std::numeric_limits<T>::infinty()                  : std::numeric_limits<T>::max();     }   };   template <>   struct Inf<int> {     static constexpr int inf() { return 0x3f3f3f3f; }   };   template <>   struct Inf<long long> {     static constexpr long long inf() { return 0x3f3f3f3f3f3f3f3fLL; }   };   constexpr int INF = Inf<int>::inf();   constexpr ll BINF = Inf<ll>::inf();   int solve() {     int n, k;     cin >> n >> k;     vi a(n);     cin >> a;     ll ans = a[n - 1] - a[0];     vi wtf;     for (int i = 0; i + 1 < n; i++) wtf.push_back(a[i] - a[i + 1]);     sort(wtf.begin(), wtf.end());     for (int i = 0; i < k - 1; i++) ans += wtf[i];     cout << ans << endl;     return 0;   }   int main() {     ios::sync_with_stdio(0);     solve();     return 0;   }   template <class T>   istream &operator>>(istream &is, vector<T> &v) {     for (auto it = v.begin(); it != v.end(); ++it) is >> *it;     return is;   }   template <class T>   ostream &operator<<(ostream &os, const vector<T> &v) {     for (auto it = v.begin(); it != v.end();)       os << *it, os <<    n [++it == v.end()];     return os;   }   template <class T, class U>   istream &operator>>(istream &is, pair<T, U> &p) {     return is >> p.first >> p.second;   }   template <class T, class U>   ostream &operator<<(ostream &os, const pair<T, U> &p) {     return os << p.first <<     << p.second;   }
#include <bits/stdc++.h>   using namespace std;   typedef pair<long long, long long> ll;   typedef vector<long long> vl;   typedef vector<ll> vll;   typedef vector<vl> vvl;   template <typename T>   ostream &operator<<(ostream &o, vector<T> v) {     if (v.size() > 0) o << v[0];     for (unsigned i = 1; i < v.size(); i++) o <<     << v[i];     return o <<   n ;   }   template <typename U, typename V>   ostream &operator<<(ostream &o, pair<U, V> p) {     return o <<  (  << p.first <<  ,   << p.second <<  )  ;   }   template <typename T>   istream &operator>>(istream &in, vector<T> &v) {     for (unsigned i = 0; i < v.size(); i++) in >> v[i];     return in;   }   template <typename T>   istream &operator>>(istream &in, pair<T, T> &p) {     in >> p.first;     in >> p.second;     return in;   }   vvl g(111000);   vl ind(111000, 0), vis(111000, false);   long long c = 0;   bool rec(long long node, long long p) {     vl ch;     ind[node] = c++;     vis[node] = 1;     for (auto &it : g[node]) {       if (it == p) continue;       if (!vis[it]) {         if (!rec(it, node)) ch.push_back((it));       } else if (ind[node] < ind[it])         ch.push_back((it));     }     for (long long i = 0; i + 1 < ch.size(); i += 2)       cout << ch[i] <<     << node <<     << ch[i + 1] <<   n ;     if (ch.size() % 2 == 1) {       cout << p <<     << node <<     << ch[ch.size() - 1] <<   n ;       return true;     }     return false;   }   int main() {     long long n, m;     cin >> n >> m;     if (m % 2 == 1) {       cout <<  No solution             <<   n ;       return 0;     }     while (m--) {       long long x, y;       cin >> x >> y;       g[x].push_back((y));       g[y].push_back((x));     }     rec(1, -1);     return 0;   }