malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       int n, k;       cin >> n >> k;       if (n == k)         cout <<  0  << endl;       else if (k > n)         cout << k - n << endl;       else {         if ((n - k) % 2 == 0)           cout <<  0  << endl;         else           cout <<  1  << endl;       }     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     ;     int n, m;     pair<int, int> tl = {-100, -100}, br = {-100, -100};     cin >> n >> m;     char paper[n][m];     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         cin >> paper[i][j];         if (paper[i][j] ==  *  && (tl.first == -100 && tl.second == -100))           tl = {i, j};         else if (j < tl.second && paper[i][j] ==  * )           tl = {tl.first, j};         if (paper[i][j] ==  *  && (i >= br.first && j > br.second))           br = {i, j};         else if (paper[i][j] ==  *  && (i > br.first))           br = {i, br.second};         else if (paper[i][j] ==  *  && (j > br.second))           br = {br.first, j};       }     }     for (int i = tl.first; i <= br.first; i++) {       for (int j = tl.second; j <= br.second; j++) {         cout << paper[i][j];       }       cout <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 200010;   const int maxv = 1000000010;   int a[maxn];   int l[maxn], r[maxn];   int rj[maxn];   stack<int> s;   int main() {     int n;     cin >> n;     a[0] = 0;     for (int i = 1; i <= n; i++) scanf( %d , &a[i]);     a[n + 1] = 0;     s.push(0);     for (int i = 1; i < n + 1; i++) {       while (a[s.top()] >= a[i]) s.pop();       l[i] = s.top();       s.push(i);     }     while (s.size()) s.pop();     s.push(n + 1);     for (int i = n; i > 0; i--) {       while (a[s.top()] >= a[i]) s.pop();       r[i] = s.top();       s.push(i);     }     for (int i = 1; i <= n; i++)       rj[r[i] - l[i] - 1] = max(rj[r[i] - l[i] - 1], a[i]);     int val = 0;     for (int i = n; i > 0; i--) {       val = max(val, rj[i]);       rj[i] = val;     }     for (int i = 1; i <= n; i++) printf( %d  , rj[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e6 + 5;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long t;     cin >> t;     while (t--) {       long long n;       cin >> n;       long long a[n], b[n];       long long m = INT_MAX;       for (int i = 0; i < n; i++) {         cin >> a[i];         b[i] = a[i];         m = min(m, a[i]);       }       sort(b, b + n);       long long flag = 0;       for (int i = 0; i < n; i++)         if (a[i] != b[i] && a[i] % m > 0) flag = 1;       if (flag)         cout <<  NO  << endl;       else         cout <<  YES  << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct Point {     int x;     int y;   };   bool onSegment(Point p, Point q, Point r) {     if (q.x <= max(p.x, r.x) && q.x >= min(p.x, r.x) && q.y <= max(p.y, r.y) &&         q.y >= min(p.y, r.y))       return true;     return false;   }   int orientation(Point p, Point q, Point r) {     int val = (q.y - p.y) * (r.x - q.x) - (q.x - p.x) * (r.y - q.y);     if (val == 0) return 0;     return (val > 0) ? 1 : 2;   }   bool doIntersect(Point p1, Point q1, Point p2, Point q2) {     int o1 = orientation(p1, q1, p2);     int o2 = orientation(p1, q1, q2);     int o3 = orientation(p2, q2, p1);     int o4 = orientation(p2, q2, q1);     if (o1 != o2 && o3 != o4) return true;     if (o1 == 0 && onSegment(p1, p2, q1)) return true;     if (o2 == 0 && onSegment(p1, q2, q1)) return true;     if (o3 == 0 && onSegment(p2, p1, q2)) return true;     if (o4 == 0 && onSegment(p2, q1, q2)) return true;     return false;   }   bool isInside(Point polygon[], int n, Point p) {     if (n < 3) return false;     Point extreme = {10000, p.y};     int count = 0, i = 0;     do {       int next = (i + 1) % n;       if (doIntersect(polygon[i], polygon[next], p, extreme)) {         if (orientation(polygon[i], p, polygon[next]) == 0)           return onSegment(polygon[i], p, polygon[next]);         count++;       }       i = next;     } while (i != 0);     return count & 1;   }   int main() {     Point s1[4];     Point s2[4];     for (__typeof(0) i = 0; i <= 3; i++) cin >> s1[i].x >> s1[i].y;     for (__typeof(0) i = 0; i <= 3; i++) cin >> s2[i].x >> s2[i].y;     for (__typeof(0) i = 0; i <= 3; i++) {       for (__typeof(0) j = 0; j <= 3; j++) {         if (doIntersect(s1[i], s1[(i + 1) % 4], s2[j], s2[(j + 1) % 4])) {           cout <<  YES n ;           return 0;         }       }     }     if (isInside(s1, 4, s2[0]) || isInside(s2, 4, s1[0]))       cout <<  YES n ;     else       cout <<  NO n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int d[105], n, sum1 = 0, sum2 = 0, begin, end;     cin >> n;     for (int i = 1; i <= n; i++) cin >> d[i];     cin >> begin >> end;     if (begin > end) {       int t;       t = begin;       begin = end;       end = t;     }     for (int i = begin; i < end; i++) sum1 += d[i];     for (int i = end; i != begin; i++) {       sum2 += d[i];       if (i >= n) i = 0;     }     sum1 = sum1 > sum2 ? sum2 : sum1;     cout << sum1 << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MX = 1e5 + 5;   struct Edge {     int v, nxt;   } E[MX * 2];   int Head[MX], erear;   void edge_init() {     erear = 0;     memset(Head, -1, sizeof(Head));   }   void edge_add(int u, int v) {     E[erear].v = v;     E[erear].nxt = Head[u];     Head[u] = erear++;   }   int siz[MX];   double ans[MX];   void DFS1(int u, int f) {     siz[u] = 1;     for (int i = Head[u]; ~i; i = E[i].nxt) {       int v = E[i].v;       if (v == f) continue;       DFS1(v, u);       siz[u] += siz[v];     }   }   void DFS2(int u, int f) {     for (int i = Head[u]; ~i; i = E[i].nxt) {       int v = E[i].v;       if (v == f) continue;       ans[v] = ans[u] + 1 + (siz[u] - siz[v] - 1) / 2.0;       DFS2(v, u);     }   }   int main() {     int n;     edge_init();     scanf( %d , &n);     for (int i = 2; i <= n; i++) {       int t;       scanf( %d , &t);       edge_add(i, t);       edge_add(t, i);     }     ans[1] = 1;     DFS1(1, -1);     DFS2(1, -1);     for (int i = 1; i <= n; i++) {       printf( %.8lf%c , ans[i], i == n ?   n  :    );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int test;   int n, k;   string s;   int tipus[200009];   int darab[3];   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cin >> test;     for (int tt = 1; tt <= test; tt++) {       cin >> n;       int minx = -100000;       int maxx = 100000;       int miny = -100000;       int maxy = 100000;       for (int i = 1; i <= n; i++) {         int x, y;         int a, b, c, d;         cin >> x >> y >> a >> b >> c >> d;         if (a == 0) minx = max(minx, x);         if (b == 0) maxy = min(maxy, y);         if (c == 0) maxx = min(maxx, x);         if (d == 0) miny = max(miny, y);       }       if (minx <= maxx && miny <= maxy) {         cout << 1 <<     << minx <<     << miny << endl;       } else {         cout << 0 << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline long long n2(int n) { return (n * 1ll * (n + 1)) / 2; }   const int N = 2e5;   vector<int> f(N + 1);   long long get(int pos) {     long long res = 0;     for (; pos >= 0; pos = (pos & (pos + 1)) - 1) res += f[pos];     return res;   }   long long get(int l, int r) { return get(r) - (l ? get(l - 1) : 0); }   void update(int pos, int val) {     for (; pos < int(f.size()); pos |= pos + 1) f[pos] += val;   }   void solve() {     int n;     cin >> n;     map<int, vector<int> > My;     map<int, int> cntx;     vector<int> indComp(n);     for (int i = 0; i < n; ++i) {       int x, y;       cin >> x >> y;       indComp[i] = x;       cntx[x]++;       My[y].push_back(x);     }     sort(indComp.begin(), indComp.end());     indComp.resize(unique(indComp.begin(), indComp.end()) - indComp.begin());     for (pair<int, int> p : cntx) {       int i =           lower_bound(indComp.begin(), indComp.end(), p.first) - indComp.begin();       update(i, 1);     }     long long ans = 0;     for (auto &vp : My) {       sort(vp.second.begin(), vp.second.end());       int lst = -1;       for (int x : vp.second) {         int i = lower_bound(indComp.begin(), indComp.end(), x) - indComp.begin();         int l = get(lst + 1, i);         int r = get(i, N);         ans += l * 1ll * r;         lst = i;         cntx[x]--;         if (cntx[x] == 0) update(i, -1);       }     }     cout << ans << endl;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int T = 1, tc = 1;     while (T--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   class Graph {    public:     vector<vector<int>> a;     vector<int> vis;     int N, M;     int n;     int R(int i) { return i; }     int C(int i) { return i + N; }     void addEdge(int l, int r) {       a[R(l)].push_back(C(r));       a[C(r)].push_back(R(l));     }     Graph() {       cin >> N >> M;       n = N + M;       a.assign(n, vector<int>());       vis.assign(n, 0);       for (int i = 0; i < int(N); i++) {         cin.get();         for (int j = 0; j < int(M); j++) {           char c = cin.get();           if (c ==  . ) continue;           addEdge(i, j);         }       }     }     bool dfs(int v, set<int> &r, set<int> &c) {       vis[v] = 1;       if (v < N && a[v].size() != c.size()) return 0;       if (v >= N && a[v].size() != r.size()) return 0;       for (int to : a[v]) {         if (!vis[to] && !dfs(to, r, c)) return 0;         if (v < N && !c.count(to)) return 0;         if (v >= N && !r.count(to)) return 0;       }       return 1;     }     bool isCompleteBipariate(int v) {       if (a[v].empty()) return 1;       set<int> c((a[v]).begin(), (a[v]).end());       set<int> r((a[a[v][0]]).begin(), (a[a[v][0]]).end());       return dfs(v, r, c);     }     void solve() {       for (int i = 0; i < int(N); i++)         if (!vis[i] && !isCompleteBipariate(i)) {           cout <<  No  << endl;           return;         }       cout <<  Yes  << endl;     }   };   int main() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr);     cout.tie(nullptr);     Graph g;     g.solve();   }
#include <bits/stdc++.h>   using namespace std;   const int maxs = 405;   const int inf = 1e9 + 7;   int dp[maxs][maxs];   string s, t, x, y;   int slen, tlen;   int nxt[maxs][26];   int g(int x) { return x + 1; }   int f(int a, int b) {     if (a == -1 && b == -1) return 0;     if (a < -1 || b < -1) return inf;     int& r = dp[g(a)][g(b)];     if (r == -1) {       r = inf;       int idx;       if (a >= 0) {         idx = f(a - 1, b);         if (idx < inf) r = min(r, nxt[idx][x[a] -  a ] + 1);       }       if (b >= 0) {         idx = f(a, b - 1);         if (idx < inf) r = min(r, nxt[idx][y[b] -  a ] + 1);       }     }     return r;   }   int main(void) {     ios_base::sync_with_stdio(0);     cin.tie(0);     int T;     cin >> T;     while (T--) {       cin >> s >> t;       int i = 0, j = 0;       slen = s.size(), tlen = t.size();       while (i < slen && j < tlen) {         if (s[i] == t[j]) ++j;         ++i;       }       if (j == tlen) {         cout <<  YES n ;         continue;       }       for (int i = 0; i <= slen; ++i)         for (int j = 0; j < 26; ++j) nxt[i][j] = inf;       for (int i = slen - 1; i >= 0; --i) {         for (int j = 0; j < 26; ++j) nxt[i][j] = nxt[i + 1][j];         nxt[i][s[i] -  a ] = i;       }       bool yes = false;       for (int i = 1; i < tlen; ++i) {         for (int j = 0; j <= tlen; ++j)           for (int k = 0; k <= tlen; ++k) dp[j][k] = -1;         x = t.substr(0, i);         y = t.substr(i, tlen - i);         if (f(i - 1, tlen - i - 1) < inf) {           yes = true;           break;         }       }       cout << (yes ?  YES n  :  NO n );     }     return 0;   }
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:100000000000,100000000000 )   using namespace std;   const double eps = 1E-9;   const double Exp = 2.718281828459045;   const double Pi = 3.1415926535897932;   const int NMAX = 100 + 5;   const int MMAX = 100000 + 5;   const int INF = 1000000000;   const int BS = 1000000007;   template <typename T>   inline T abs(const T a) {     if (a < 0) return -a;     return a;   }   template <typename T>   inline T sqr(const T& a) {     return a * a;   }   int a[NMAX][NMAX];   int b[NMAX][NMAX];   int c[NMAX][NMAX];   void mult(int n, int m, int k) {     int i, j, t;     for (i = 1; i <= n; i++) {       for (j = 1; j <= k; j++) {         c[i][j] = 0;         for (t = 1; t <= m; t++) {           c[i][j] = (c[i][j] + a[i][t] * 1ll * b[t][j]) % BS;         }       }     }   }   const int BORD = 102;   void pw(int p) {     int i, j;     if (0 == p) {       for (i = 1; i <= BORD; i++) {         for (j = 1; j <= BORD; j++) {           c[i][j] = (i == j);         }       }       return;     }     if (1 == p) {       for (i = 1; i <= BORD; i++) {         for (j = 1; j <= BORD; j++) {           c[i][j] = a[i][j];         }       }       return;     }     if (p & 1) {       int buf[NMAX][NMAX];       for (i = 1; i <= BORD; i++) {         for (j = 1; j <= BORD; j++) {           buf[i][j] = a[i][j];         }       }       pw(p - 1);       for (i = 1; i <= BORD; i++) {         for (j = 1; j <= BORD; j++) {           a[i][j] = buf[i][j];         }       }       for (i = 1; i <= BORD; i++) {         for (j = 1; j <= BORD; j++) {           b[i][j] = c[i][j];         }       }       mult(BORD, BORD, BORD);     } else {       pw(p / 2);       for (i = 1; i <= BORD; i++) {         for (j = 1; j <= BORD; j++) {           a[i][j] = c[i][j];         }       }       for (i = 1; i <= BORD; i++) {         for (j = 1; j <= BORD; j++) {           b[i][j] = c[i][j];         }       }       mult(BORD, BORD, BORD);     }   }   int main() {     ios::sync_with_stdio(false);     int n, x;     int d[NMAX] = {0};     int i, j, y;     cin >> n >> x;     for (i = 1; i <= n; i++) {       cin >> y;       d[y]++;     }     int beg[NMAX];     beg[0] = 1;     for (i = 1; i <= 100; i++) {       beg[i] = 1;       for (j = 1; j <= i; j++) {         beg[i] = (beg[i] + beg[i - j] * 1ll * d[j]) % BS;       }     }     memset(a, 0, sizeof(a));     a[1][1] = 1;     for (i = 2; i <= BORD; i++) {       for (j = 2; j <= BORD; j++) {         if (i == j + 1)           a[i][j] = 1;         else           a[i][j] = 0;       }     }     a[1][BORD] = 1;     for (i = 2; i <= BORD; i++) {       a[i][BORD] = d[BORD - i + 1];     }     pw(x);     for (i = 1; i <= BORD; i++) {       for (j = 1; j <= BORD; j++) {         b[i][j] = c[i][j];       }     }     a[1][1] = 1;     for (j = 2; j <= BORD; j++) {       a[1][j] = beg[j - 2];     }     mult(1, BORD, BORD);     cout << c[1][2] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m;   int c[1010100], cc[1010100];   int lowbit(int x) { return x & (-x); }   void upd(int v, int idx, int a[]) {     while (idx <= n) {       a[idx] += v;       idx += lowbit(idx);     }   }   int qu(int idx, int a[]) {     int sum = 0;     if (idx == 0) return 0;     while (idx > 0) {       sum += a[idx];       idx -= lowbit(idx);     }     return sum;   }   struct Node {     int v, id;   } arr[1010100];   int cmp(Node a, Node b) { return a.v < b.v; }   int find() {     int ll = 1, rr = n + 1, mid, ans = n;     while (ll < rr) {       mid = (ll + rr) / 2;       if (qu(mid, cc) < mid)         ans = rr = mid;       else         ll = mid + 1;     }     return ans;   }   int vis[1010100];   int main() {     int i, j;     while (scanf( %d %d , &n, &m) != EOF) {       memset(vis, 0, sizeof(vis));       for (i = 1; i <= n; i++) scanf( %d , &arr[i].v), arr[i].id = i;       for (i = 1; i <= m; i++) scanf( %d , &j), vis[j] = 1;       sort(arr + 1, arr + 1 + n, cmp);       memset(c, 0, sizeof(c));       memset(cc, 0, sizeof(cc));       long long sum = 0;       for (i = 1; i <= n; i++) {         if (vis[arr[i].v]) {           upd(1, arr[i].id, c);         } else {           int ll = 0, rr = arr[i].id, mid;           int v = qu(rr, c), x = rr;           while (ll < rr) {             mid = (ll + rr) / 2;             if (qu(mid, c) == v)               x = rr = mid;             else               ll = mid + 1;           }           if (qu(n, c) == 0) x = 0;           ll = arr[i].id, rr = n + 1;           v = qu(ll, c);           int y = ll;           while (ll < rr) {             mid = (ll + rr) / 2;             if (qu(mid, c) == v)               y = mid, ll = mid + 1;             else               rr = mid;           }           y = y - qu(y, cc);           x = max(find() - 1, x);           x = x - qu(x, cc);           sum = sum + (y - x);           upd(1, arr[i].id, cc);         }       }       printf( %I64d n , sum);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 10200;   const int mod = 1e9 + 7;   int dp[N];   int len[N];   inline int get_len(int x) {     if (x == 0) return 1;     int res = 0;     while (x) res++, x /= 10;     return res;   }   vector<int> del[N];   vector<int> calc_prefix(string s) {     int n = (int)s.length();     vector<int> pi(n);     for (int i = 1; i < n; ++i) {       int j = pi[i - 1];       while (j > 0 && s[i] != s[j]) j = pi[j - 1];       if (s[i] == s[j]) ++j;       pi[i] = j;     }     return pi;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     string s;     cin >> s;     int n = s.length();     for (int i = 0; i <= n; ++i) len[i] = get_len(i);     for (int i = 1; i <= n; ++i)       for (int j = i; j <= n; j += i) del[j].push_back(i);     for (int i = 1; i <= n; ++i) dp[i] = 1e9;     dp[0] = 0;     string t;     vector<int> p;     for (int i = 1; i <= n; ++i) {       int cur_len = 0, times;       int period;       t =   ;       for (int j = i; j <= n; ++j) t += s[j - 1];       p = calc_prefix(t);       for (int j = i; j <= n; ++j) {         cur_len++;         dp[j] = min(dp[j], dp[i - 1] + cur_len + 1);         period = cur_len - p[j - i];         if (cur_len % period != 0) continue;         dp[j] = min(dp[j], dp[i - 1] + len[cur_len / period] + period);       }     }     cout << dp[n];     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long INF = 8e+1000;   int n, k, x, c[1000];   int main() {     ios_base::sync_with_stdio(false);     cin >> n >> k >> x;     for (int i = 0; i < n; i++) cin >> c[i];     int res = 0;     for (int i = 0; i < n - 1; i++) {       if (c[i] == c[i + 1] && c[i] == x) {         int l = i - 1, r = i + 2;         while (l >= 0 && r < n) {           bool mark = false;           if (c[l] != c[r]) break;           if (l > 0 && c[l - 1] == c[l]) l--, mark = true;           if (r < n - 1 && c[r + 1] == c[r]) r++, mark = true;           if (mark == false) break;           l--, r++;         }         res = max(res, r - l - 1);       }     }     cout << res;     return 0;   }
#include <bits/stdc++.h>   #define endl   n    #define IOS ios::sync_with_stdio(false); cin.tie(nullptr), cout.tie(nullptr)   using namespace std;   typedef long long LL;   typedef pair<int, int> PII;   const int maxn = 1e3 + 5;      string input;   int cnt[maxn], mx;   double a, b;      inline double randrand(){       return (double ) rand() / RAND_MAX;   }      int main(){       IOS;       srand(time(nullptr));       int n, m, c1, c2;       char c;       cin >> n >> m;       for(int j = 0; j < m; j++){           cin >> input;           a = b = 0;           if(j){               for (int i = 0; i < n; i++){                   if (input[i] ==  0 ) {                       a += pow(0.9, cnt[i]);                   } else {                       b += pow(0.9, cnt[i]);                   }               }           }           if(a == b) cout << 1 << endl;           else cout << (randrand() <= a / (a + b) ? 0 : 1) << endl;           cout.flush();           cin >> c;           for(int i = 0; i < n; i++){               cnt[i] += (input[i] != c);           }       }   }
#include <bits/stdc++.h>   using namespace std;   pair<int, int> afis[1503];   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     int n, cnt = 0, i, x = 1;     cin >> n;     afis[++cnt] = {0, 0};     while (x <= n + 1) {       afis[++cnt] = {x, x};       afis[++cnt] = {x, x - 1};       afis[++cnt] = {x - 1, x};       x++;     }     cout << cnt <<   n ;     for (i = 1; i <= cnt; i++)       cout << afis[i].first <<     << afis[i].second <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 5;   int n, m, k, a[N];   long long rem, cnt, sum;   double ans;   int main() {     cin >> n >> k >> m;     for (int i = 1; i <= n; ++i) {       scanf( %d , a + i);       sum += a[i];     }     sort(a + 1, a + n + 1);     for (int i = 1; i <= n; ++i) {       cnt = n - i + 1;       rem = m - i + 1;       if (rem < 0) {         break;       }       ans = max(ans, (sum + min(rem, cnt * k)) * 1.0 / cnt);       sum -= a[i];     }     printf( %0.9lf , ans);     return 0;   }
#include <bits/stdc++.h>   #include <string>      using namespace std;      bool susp() {       int n;       cin >> n;       string days;       cin >> days;       for (int i = 0; i < n - 1; i++) {           for (int j = i + 1; j < n; j++) {               if (days[j] == days[i] && days[j - 1] != days[i])                   return false;           }       }       return true;   }      int main()   {       int t;       cin >> t;       bool cases[t];       for (int i = 0; i < t; i++) {           cases[i] = susp();       }       for (bool b : cases) {           if (b)               cout <<  YES  << endl;           else               cout <<  NO  << endl;       }       return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     set<string> s;     int n;     cin >> n;     for (int i = 0; i < n; ++i) {       string ss;       cin >> ss;       s.insert(ss);     }     cout << 6 - n <<   n ;     if (s.find( purple ) == s.end()) {       cout <<  Power n ;     }     if (s.find( green ) == s.end()) {       cout <<  Time n ;     }     if (s.find( blue ) == s.end()) {       cout <<  Space n ;     }     if (s.find( orange ) == s.end()) {       cout <<  Soul n ;     }     if (s.find( red ) == s.end()) {       cout <<  Reality n ;     }     if (s.find( yellow ) == s.end()) {       cout <<  Mind n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long N = 1e5 + 7;   const long long inf = 1e9 + 7;   const long long mod = 1e9 + 7;   int n;   int m;   int x;   int y;   vector<int> g[N];   int main() {     ios_base::sync_with_stdio(false);     cin >> n >> m;     for (int i = 1; i <= m; i++) {       cin >> x >> y;       g[x].push_back(y);       g[y].push_back(x);     }     int badbus = 0, cnt = 0;     for (int i = 1; i <= n; i++) {       badbus |= (g[i].empty());       if ((int)g[i].size() == 1) {         cnt++;         continue;       }       badbus |= ((int)g[i].size() != 2);     }     if (cnt == 2 && badbus == 0) {       cout <<  bus topology n ;       return 0;     }     int badring = 0;     for (int i = 1; i <= n; i++) {       badring |= ((int)g[i].size() != 2);     }     if (badring == 0) {       cout <<  ring topology n ;       return 0;     }     cnt = 0;     int badstar = 0;     for (int i = 1; i <= n; i++) {       if ((int)g[i].size() == n - 1) {         cnt++;         continue;       }       badstar |= ((int)g[i].size() != 1);     }     if (cnt == 1 && badstar == 0) {       cout <<  star topology n ;       return 0;     }     cout <<  unknown topology n ;   }