malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   template <typename T>   void read(T &t) {     t = 0;     char ch = getchar();     int f = 1;     while ( 0  > ch || ch >  9 ) {       if (ch ==  - ) f = -1;       ch = getchar();     }     do {       (t *= 10) += ch -  0 ;       ch = getchar();     } while ( 0  <= ch && ch <=  9 );     t *= f;   }   const int maxn = (1e5) + 10;   int n, m, c, q, fa[maxn];   map<int, int> fst[maxn];   set<int> s[maxn];   set<int>::iterator it;   char S[2];   int find(int x) {     if (fa[x] == x) return x;     return fa[x] = find(fa[x]);   }   void merge(int x, int y) {     x = find(x);     y = find(y);     if (x == y) return;     if (s[x].size() > s[y].size()) swap(x, y);     for (it = s[x].begin(); it != s[x].end(); it++) s[y].insert(*it);     s[x].clear();     fa[x] = y;   }   void add(int x, int y, int z) {     if (fst[x][z])       merge(fst[x][z], y);     else       fst[x][z] = y;     if (fst[y][z])       merge(fst[y][z], x);     else       fst[y][z] = x;     s[find(x)].insert(y);     s[find(y)].insert(x);   }   int main() {     read(n);     read(m);     read(c);     read(q);     int x, y;     for (int i = 1; i <= n; i++) fa[i] = i, s[i].insert(i);     for (int i = 1; i <= m + q; i++) {       if (i <= m)         S[1] =  + ;       else         scanf( %s , S + 1);       read(x);       read(y);       if (S[1] ==  + )         read(c), add(x, y, c);       else {         if (find(x) == find(y) || s[find(x)].count(y))           printf( Yes n );         else           printf( No n );       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string mirror =  AHIMOTUVWXY ;   string letter =  ABCDEFGHIJKLMNOPQRSTUVWXYZ ;   int main() {     long long n, m, i, j, k, x, y, z, t;     cin >> x >> y;     if ((x == 0 || x == 1) && y == 0) {       cout << 0 << endl;       return 0;     }     if (x == 1 && y == 1) {       cout << 1 << endl;       return 0;     }     if (x > 0) {       if (y > -(x - 1) && y <= x) y = 0;     } else {       if (y >= x && y < -x) y = 0;     }     if (y > 0) {       if (x >= -y && x < y) x = 0;     } else {       if (x > y && x <= abs(y) + 1) x = 0;     }     if (x == 0) {       long long ans = max(0LL, abs(y) - 1) * 4;       if (y > 0)         ans += 2;       else         ans += 4;       cout << ans << endl;       return 0;     }     if (y == 0) {       long long ans = max(0LL, abs(x) - 1) * 4;       if (x < 0)         ans += 3;       else         ans++;       cout << ans << endl;       return 0;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int a[1000000], b = 0, c = 0, d = 0;     long long int n, i;     cin >> n;     for (i = 1; i <= n; i++) {       cin >> a[i];       d += a[i];     }     d = d / n;     for (i = 1; i <= n; i++) {       b += a[i] - d;       c += abs(b);     }     cout << c << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct s {     char g;     long s, e;   };   int main() {     long n, i, j, c, ans = 0, day = 0, m = 0, f = 0;     struct s a[5005];     cin >> n;     for (i = 0; i < n; ++i) cin >> a[i].g >> a[i].s >> a[i].e;     for (day = 1; day <= 366; ++day) {       m = 0;       f = 0;       for (i = 0; i < n; ++i)         if (a[i].s <= day && a[i].e >= day) {           if (a[i].g ==  M )             m++;           else             f++;         }       ans = max(ans, 2 * (min(m, f)));     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int arr[100007];   int main() {     int i, n, k, distinct, r;     map<int, int> M;     while (scanf( %d%d , &n, &k) == 2) {       bool flag = true;       M.clear();       distinct = 0;       for (i = 0; i < n; i++) {         scanf( %d , &arr[i]);         if (M[arr[i]] == 0) {           M[arr[i]]++;           distinct++;         } else if (flag) {           M[arr[i]]++;         }         if (distinct == k && flag) {           r = i;           flag = false;         }       }       if (distinct < k)         puts( -1 -1 );       else {         i = 0;         while (M[arr[i]] > 1) {           M[arr[i]]--;           i++;         }         if (i > r) i = r;         printf( %d %d n , i + 1, r + 1);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, k, i;     scanf( %d%d , &n, &k);     int sum = 0;     int gave = 0;     for (i = 0; (i < n) && gave < k; i++) {       int curr;       scanf( %d , &curr);       sum += curr;       int thisDay = min(sum, 8);       sum -= thisDay;       gave += thisDay;     }     if (gave < k) {       printf( -1 n );     } else {       printf( %d n , i);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long a[100];   struct node {     long long l;     long long r;     long long x;   } p[100];   bool cmp(node aa, node bb) { return aa.x > bb.x; }   int main() {     long long n, h, m, i, ans = 0;     cin >> n >> h >> m;     for (i = 1; i <= n; i++) {       a[i] = -1;     }     for (i = 1; i <= m; i++) {       cin >> p[i].l >> p[i].r >> p[i].x;     }     sort(p + 1, p + 1 + m, cmp);     for (i = 1; i <= m; i++) {       for (long long j = p[i].l; j <= p[i].r; j++) {         a[j] = min(p[i].x, h);       }     }     for (i = 1; i <= n; i++) {       if (a[i] < 0) {         ans += h * h;       } else {         ans += a[i] * a[i];       }     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   const double pi = acos(-1.0), eps = 1e-9;   const int dx[8] = {1, -1, 0, 0, 1, 1, -1, -1};   const int dy[8] = {0, 0, 1, -1, 1, -1, -1, 1};   const int MO = (int)(1e9 + 7);   using namespace std;   string s[2001];   int n, k, l[1001][1001];   int lcp(int a, int b) {     int ret = 0;     while (ret < min((int)((s[a]).size()), (int)((s[b]).size())) &&            s[a][ret] == s[b][ret])       ++ret;     return ret;   }   int who[1001], ans;   void dfs(int dep, int get) {     if (dep == n) {       int ret = 0;       if (get != k) return;       for (int i = 1; i <= k; i++)         for (int j = i + 1; j <= k; j++) ret += l[who[i]][who[j]];       {         if (ret > ans) ans = ret;       };       return;     }     dfs(dep + 1, get);     who[get + 1] = dep + 1;     dfs(dep + 1, get + 1);   }   int main() {     cin >> n >> k;     for (int i = 1; i <= n; i++) cin >> s[i];     for (int i = 1; i <= n; i++)       for (int j = 1; j <= n; j++) l[i][j] = lcp(i, j);     dfs(0, 0);     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   string s[3];   int a[200][200];   int n;   int main() {     char card, team;     int tm, player;     cin >> s[0] >> s[1];     cin >> n;     for (int i = 0; i < n; i++) {       cin >> tm >> team >> player >> card;       if (card ==  y )         a[team][player]++;       else         a[team][player] += 2;       if (a[team][player] >= 2) {         if (team ==  a )           cout << s[1];         else           cout << s[0];         cout <<     << player <<     << tm << endl;         a[team][player] -= 9000;       }     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 3e5;   int arr[N + 100];   vector<pair<long long, int> > v;   set<int> st;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int n, k;     cin >> n >> k;     for (int i = 1; i <= n; i++) {       long long c;       cin >> c;       v.push_back(make_pair(c, i));     }     for (int i = k + 1; i <= k + n; i++) st.insert(i);     sort(v.begin(), v.end(), greater<pair<long long, int> >());     long long ans = 0;     for (auto it : v) {       int ind = it.second;       auto cur = st.lower_bound(ind);       ans += (*cur - ind) * it.first;       arr[ind] = *cur;       st.erase(cur);     }     cout << ans <<   n ;     for (int i = 1; i <= n; i++) {       cout << arr[i] <<    ;     }     cout <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 7;   int n, q, fa[N];   double p[N], sum[N], ans;   vector<int> son[N];   void dfs(int x, int f) {     fa[x] = f;     for (int i = 0; i < son[x].size(); ++i) {       int y = son[x][i];       if (y == f) continue;       dfs(y, x);       sum[x] += 1 - p[y];       ans += p[x] * (1 - p[y]);     }   }   int main() {     scanf( %d , &n);     p[0] = 1;     for (int i = 1; i <= n; ++i) scanf( %lf , p + i);     for (int i = 1; i < n; ++i) {       int u, v;       scanf( %d%d , &u, &v);       ++u, ++v;       son[u].push_back(v);       son[v].push_back(u);     }     ans = 1 - p[1];     dfs(1, 0);     scanf( %d , &q);     while (q--) {       int k;       double p1;       scanf( %d%lf , &k, &p1);       ++k;       sum[fa[k]] -= p1 - p[k];       ans += sum[k] * (p1 - p[k]) - (p1 - p[k]) * p[fa[k]];       p[k] = p1;       printf( %.5lf n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1100;   int n, m, t;   int a[N];   int main() {     scanf( %d , &n);     memset(a, 0, sizeof(a));     for (int i = 1; i <= n; i++) {       int x;       scanf( %d , &x);       a[x]++;     }     scanf( %d , &t);     int mx = -1;     for (int i = 1; i <= 1000; i++) {       int j = i;       int sum = 0;       int k = t + 1;       while (k && j <= 1000) {         sum += a[j];         j++;         k--;       }       if (sum > mx) {         mx = sum;       }     }     printf( %d n , mx);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int i, j;     int n, a = 1, b = 1, c = 0, x;     scanf( %d , &n);     for (i = 0; i < n; i++) {       scanf( %d , &x);       if (x == 1) {         if (a == 0) {           printf( NO n );           break;         } else if (b == 0) {           b = 1;           c = 0;         } else if (c == 0) {           c = 1;           b = 0;         }       }       if (x == 2) {         if (b == 0) {           printf( NO n );           break;         } else if (a == 0) {           a = 1;           c = 0;         } else if (c == 0) {           c = 1;           a = 0;         }       }       if (x == 3) {         if (c == 0) {           printf( NO n );           break;         } else if (a == 0) {           a = 1;           b = 0;         } else if (b == 0) {           b = 1;           a = 0;         }       }     }     if (i == n) {       printf( YES n );     }   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 1000000000;   long long A[100005];   map<long long, long long> mp;   int main() {     long long n, a, i;     cin >> n;     for (i = 1; i <= n; i++) {       cin >> a;       mp[a] += a;     }     A[1] = mp[1];     A[0] = 0;     for (i = 2; i <= 100000; i++) {       A[i] = max(A[i - 1], A[i - 2] + mp[i]);     }     cout << A[100000] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct elem {     int i1, i2, p1, p2, tipo;     elem() {}     elem(int i1, int i2) : i1(i1), i2(i2) { tipo = 0; }     elem(int i1, int i2, int p1, int p2) : i1(i1), i2(i2), p1(p1), p2(p2) {       tipo = 1;     }   };   int inverso(int x) {     if (x == 2) return 3;     if (x == 3) return 2;     return x;   }   vector<elem> lista;   const int limite = 505;   int m, n;   int t[limite][limite];   char buff[limite];   int b[limite];   void escribe() {     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) cout << t[i][j] <<  , ;       cout << endl;     }     cout << endl;   }   int main() {     scanf( %d%d , &m, &n);     for (int j = 0; j < m; j++) {       scanf( %s , buff);       for (int i = 0; i < n; i++) t[i][j] = buff[i] -  a ;     }     int jlibres = 0;     int itope;     {       int jj = 0;       int i = 0;       while (i < n and jj < m) {         int ii = i;         while (ii < n and t[ii][jj] == 0) ii++;         if (ii == n) {           jj++;           jlibres++;         } else {           lista.push_back(elem(i, ii));           for (int j = jj; j < m; j++) swap(t[i][j], t[ii][j]);           for (int ii = i + 1; ii < n; ii++) {             if (t[ii][jj]) {               int p1 = -t[ii][jj];               int p2 = t[i][jj];               lista.push_back(elem(i, ii, p1, p2));               for (int j = jj; j < m; j++)                 t[ii][j] = (t[ii][j] * p2 + t[i][j] * p1) % 5;             }           }           i++;           jj++;         }       }       itope = i;       jlibres += m - jj;     }     long long int sol = 1;     for (int j = 0; j < jlibres; j++) sol = sol * 5 % int(1e9 + 7);     int casos;     scanf( %d , &casos);     for (int cas = 0; cas < casos; cas++) {       scanf( %s , buff);       for (int i = 0; i < n; i++) b[i] = buff[i] -  a ;       for (int k = 0; k < int(lista.size()); k++) {         elem &e = lista[k];         int i1 = e.i1;         int i2 = e.i2;         int p1 = e.p1;         int p2 = e.p2;         if (e.tipo == 0) {           swap(b[i1], b[i2]);         } else {           b[i2] = (b[i2] * p2 + b[i1] * p1) % 5;         }       }       bool error = false;       for (int i = itope; i < n and not error; i++) error = b[i] != 0;       if (error)         printf( %d n , 0);       else         printf( %d n , int(sol));     }   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     int n;     string s;     cin >> n >> s;     if (s.find( 0 ) == string::npos) {       cout << 1 <<     << n / 2 <<    ;       cout << 2 <<     << n / 2 + 1;       return;     } else {       for (int i = 0; i < n / 2; i++) {         if (s[i] ==  0 ) {           cout << i + 2 <<     << n <<    ;           cout << i + 1 <<     << n;           return;         }       }       for (int i = n / 2; i < n; i++) {         if (s[i] ==  0 ) {           cout << 1 <<     << i + 1 <<    ;           cout << 1 <<     << i;           return;         }       }     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     int t;     cin >> t;     while (t--) {       solve();       cout <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int n, m, k, i, j, x, y, z, c, f, t, s, p;     cin >> k >> n >> s >> p;     if (n % s == 0) {       z = (n / s) * k;       if (z % p == 0) {         cout << z / p << endl;       } else {         cout << z / p + 1 << endl;       }     } else {       z = (n / s + 1) * k;       if (z % p == 0) {         cout << z / p << endl;       } else {         cout << z / p + 1 << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize(2)   #pragma G++ optimize(2)   using namespace std;   const int MAX_N = 2e3 + 5;   char s[MAX_N], t[MAX_N];   int sufs[MAX_N][26], suft[MAX_N][26];   int dp[MAX_N][MAX_N];   int solve(int i, int j) {     if (j == 0) return 0;     if (~dp[i][j]) return dp[i][j];     int res = 2e9;     if (i > 0) {       res = 1 + solve(i - 1, j);       if (s[i] == t[j]) res = min(res, solve(i - 1, j - 1));     }     int c = t[j] -  a ;     if (sufs[i + 1][c] > suft[j + 1][c]) res = min(res, solve(i, j - 1));     return dp[i][j] = res;   }   int main() {     int T;     scanf( %d , &T);     while (T--) {       int n;       scanf( %d , &n), scanf( %s , s + 1), scanf( %s , t + 1);       for (register int i = 0; i <= 25; ++i) sufs[n + 1][i] = suft[n + 1][i] = 0;       for (register int i = 0; i <= n; ++i)         for (register int j = 0; j <= n; ++j) dp[i][j] = -1;       for (register int i = n; i >= 1; --i) {         for (register int j = 0; j <= 25; ++j)           sufs[i][j] = sufs[i + 1][j], suft[i][j] = suft[i + 1][j];         sufs[i][s[i] -  a ]++, suft[i][t[i] -  a ]++;       }       int ans = solve(n, n);       if (ans > 1e9) ans = -1;       printf( %d n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long int mxn = 1e5 + 5;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long int t = 1;     cin >> t;     while (t--) {       long long int i, j, k, n, m;       cin >> n >> k;       string s;       cin >> s;       map<long long int, long long int> mp;       long long int sum = 0;       for (i = 0; i < n; i++) {         if (s[i] ==  0 )           sum++;         else           sum--;         mp[sum]++;       }       if (sum == 0 && mp[k])         cout << -1 <<   n ;       else if (sum == 0)         cout << 0 <<   n ;       else {         long long int ans = 0, p = 0;         if (p == k) {           ans++;         }         for (i = 0; i < n; i++) {           if (s[i] ==  0 )             p++;           else             p--;           if ((k - p) % sum == 0 && ((k - p) / sum) >= 0) {             ans++;           }         }         cout << ans <<   n ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long pw(long long x, long long a) {     if (a == 0) return 1;     long long t = pw(x, a / 2);     if (a % 2 == 0)       return (t * t);     else       return (t * t * x);   }   bool prime(int x) {     if (x < 2) return false;     for (int i = 2; i <= sqrt(x); i++) {       if ((x % i) == 0) return false;     }     return true;   }   bool cmp(const pair<int, int> &a, const pair<int, int> &b) {     return (a.first < b.first);   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     int n;     cin >> n;     string x;     cin >> x;     int ind = 0;     int dif = 0;     bool cut = 0;     long long ans = 0;     for (int i = 0; i < n; i++) {       if (x[i] ==  ( )         dif++;       else         dif--;       if (dif < 0) cut = 1;       if (dif == 0 && cut) {         ans += i - ind + 1;         ind = i + 1;         cut = 0;       }       if (dif == 0) ind = i + 1;     }     if (dif != 0)       cout << -1 << endl;     else       cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long fpow(long long n, long long k, long long p = 1000000007) {     long long r = 1;     for (; k; k >>= 1) {       if (k & 1) r = r * n % p;       n = n * n % p;     }     return r;   }   long long inv(long long a, long long p = 1000000007) {     return fpow(a, p - 2, p);   }   long long fact[100001];   void pre() {     fact[0] = 1;     fact[1] = 1;     for (long long i = 2; i <= 100000; i++)       fact[i] = (i * fact[i - 1]) % 1000000007;   }   int main() {     pre();     long long n, k;     cin >> n >> k;     long long arr[n], cnt = 0;     map<long long, long long> m;     for (long long i = 0; i < n; i++) {       cin >> arr[i];       string temp = to_string(arr[i]);       long long flag = 1;       for (long long j = 0; j < temp.size(); j++) {         if (temp[j] ==  4  or temp[j] ==  7 ) {         } else {           flag = 0;           break;         }       }       if (flag) {         m[arr[i]]++;         cnt++;       }     }     long long dp[m.size()][m.size()];     vector<long long> freq;     memset(dp, 0, sizeof(dp));     for (map<long long, long long>::iterator it = m.begin(); it != m.end(); it++)       freq.push_back(it->second);     sort(freq.begin(), freq.end());     for (long long i = 0; i < freq.size(); i++) dp[0][i] = freq[i];     long long cutoff = m.size() - 2;     for (long long i = 1; i < m.size(); i++) {       long long sum = 0;       for (long long j = 0; j <= cutoff; j++) {         long long smallest = dp[0][j];         if (j == 0) {           for (long long k = j + 1; k <= cutoff + 1; k++) {             dp[i][j] =                 (dp[i][j] + (smallest * dp[i - 1][k]) % 1000000007) % 1000000007;             sum = dp[i][j];           }         } else {           sum = (sum * inv(dp[0][j - 1])) % 1000000007;           sum = (sum - dp[i - 1][j] + 1000000007) % 1000000007;           sum = (sum * dp[0][j]) % 1000000007;           dp[i][j] = sum;         }       }       cutoff--;     }     if (m.size() + n - cnt < k)       cout << 0;     else {       long long ans = 0;       for (long long i = 1; i <= min((long long)m.size(), k); i++) {         long long temp = 0;         if (k - i <= n - cnt) {           for (long long j = 0; j < m.size(); j++)             temp = (temp + dp[i - 1][j]) % 1000000007;           long long num = fact[n - cnt];           long long den = (fact[k - i] * fact[n - cnt - k + i]) % 1000000007;           num = (num * inv(den)) % 1000000007;           ans = (ans + (num * temp) % 1000000007) % 1000000007;         }       }       if (n - cnt >= k) {         long long num = fact[n - cnt];         long long den = (fact[k] * fact[n - cnt - k]) % 1000000007;         num = (num * inv(den)) % 1000000007;         ans = (ans + num) % 1000000007;       }       cout << ans;     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 7;   int is0(int d) { return d << 1; }   int is1(int d) { return d << 1 | 1; }   struct TwoSat {     static const int N = ::N << 1;     vector<int> G[N];     int pre[N], dfn[N], dfs_clock;     int scc[N], sccn;     int mark[N], n;     stack<int> S;     void init(int _n) {       for (int i = ((n = _n << 1)) - 1; i >= (0); --i) G[i].clear();     }     void addAnd(int a) { G[a ^ 1].push_back(a); }     void addThen(int a, int b) {       G[a].push_back(b);       G[b ^ 1].push_back(a ^ 1);     }     void addOr(int a, int b) {       G[a ^ 1].push_back(b);       G[b ^ 1].push_back(a);     }     void addXor(int a, int b) {       G[a].push_back(b ^ 1);       G[a ^ 1].push_back(b);       G[b].push_back(a ^ 1);       G[b ^ 1].push_back(a);     }     void dfs(int u) {       pre[u] = dfn[u] = ++dfs_clock;       S.push(u);       for (int _v = (0); _v < (((int)(G[u]).size())); ++_v) {         int v = G[u][_v];         if (!pre[v]) {           dfs(v);           dfn[u] = min(dfn[u], dfn[v]);         } else if (!scc[v])           dfn[u] = min(dfn[u], pre[v]);       }       if (pre[u] == dfn[u]) {         sccn++;         while (1) {           int x = S.top();           S.pop();           scc[x] = sccn;           if (x == u) break;         }       }     }     void find() {       dfs_clock = sccn = 0;       fill(pre, pre + n, 0);       fill(scc, scc + n, 0);       for (int i = (0); i < (n); ++i)         if (!pre[i]) dfs(i);     }     bool solve() {       find();       for (int i = 0; i < n; i += 2) {         if (scc[i] == scc[i + 1]) return false;         mark[i >> 1] = (scc[i] > scc[i + 1]);       }       return true;     }   } G;   int n, m;   vector<int> s[N];   pair<int, int> diff(vector<int> &a, vector<int> &b) {     int L = min(((int)(a).size()), ((int)(b).size()));     for (int i = (0); i < (L); ++i)       if (a[i] != b[i]) return make_pair(a[i], b[i]);     return make_pair(-1, -1);   }   void solve() {     G.init(m);     for (int i = (0); i < (n - 1); ++i) {       pair<int, int> r = diff(s[i], s[i + 1]);       if (!~r.first && ((int)(s[i]).size()) > ((int)(s[i + 1]).size())) {         puts( No );         return;       }       if (~r.first) {         if (r.first > r.second) {           G.addAnd(is1(r.first));           G.addAnd(is0(r.second));         } else {           G.addThen(is1(r.second), is1(r.first));         }       }     }     if (G.solve()) {       puts( Yes );       vector<int> ans;       for (int i = (0); i < (m); ++i)         if (G.mark[i]) ans.push_back(i + 1);       printf( %d n , ((int)(ans).size()));       for (int i = (0); i < (((int)(ans).size())); ++i)         printf( %d%c , ans[i],    n [i == ((int)(ans).size()) - 1]);     } else {       puts( No );     }   }   int main() {     scanf( %d%d , &n, &m);     for (int i = (0); i < (n); ++i) {       int li;       scanf( %d , &li);       for (int j = (0); j < (li); ++j) {         int x;         scanf( %d , &x);         s[i].push_back(x - 1);       }     }     solve();     return 0;   }