malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   inline long long mod(long long n, long long m) {     long long ret = n % m;     if (ret < 0) ret += m;     return ret;   }   long long gcd(long long a, long long b) {     return (b == 0LL ? a : gcd(b, a % b));   }   long long exp(long long a, long long b, long long m) {     if (b == 0LL) return 1LL;     if (b == 1LL) return mod(a, m);     long long k = mod(exp(a, b / 2, m), m);     if (b & 1LL) {       return mod(a * mod(k * k, m), m);     } else       return mod(k * k, m);   }   const long long N = 150;   long long a[N];   long long b[N * N];   long long n, k;   long long ok() {     long long sum = 0;     for (long long i = 1; i <= k; i++) {       sum += b[i];     }     long long s2 = sum;     long long tam = n;     for (long long i = k + 1; i <= tam; i++) {       s2 -= a[i - k];       s2 += a[i];       if (s2 != sum) return false;     }     return true;   }   long long T;   long long go(long long n, long long m, long long obj, long long t) {     if (n == obj) {       T = min(T, t);       return t;     }     if (n > obj) return 1e9;     long long has = 1e9;     for (long long x = m; x >= 0; x--) {       has = min(has, go(n + x + m, m + x, obj, t + 1));     }     return has;   }   void go2(long long n, long long m, long long obj, long long t) {     if (n == obj) {       return;     }     for (long long x = m; x >= 0; x--) {       if (go(n + x + m, m + x, obj, t + 1) == T) {         cout << x <<    ;         go2(n + x + m, m + x, obj, t + 1);         return;       }     }   }   void solve(long long coisa = 0) {     long long n, m;     if (coisa == 0)       cin >> n;     else       n = coisa;     if (n == 3) {       cout << 1 <<   n ;       cout << 1 <<   n ;       return;     }     long long t = 0;     for (long long i = 30; i >= 0; i--) {       if (n & (1LL << i)) {         t = i;         break;       }     }     cout << t <<   n ;     T = t;     if (n < 10) {       go2(1, 1, n, 0);       cout <<   n ;     } else if ((1 << t) == n) {       long long has = 1;       for (long long x = 1; x <= t; x++) {         if (x == 1)           cout << 0 <<    ;         else {           cout << has <<    ;           has = has + has;         }       }       cout <<   n ;     } else {       long long has = 1;       long long m = 1;       for (long long x = 1; x < t - 1; x++) {         cout << has <<    ;         m = m + has + has;         has = has + has;       }       long long op1 = m + has + has;       long long has2 = has + has;       op1 = op1 + has2;       if (n < (op1)) {         for (long long x = 1; x <= has; x *= 2) {           has2 = has + x;           long long m2 = m + has2;           if (n - m2 - has2 <= has2 and n - m2 - has2 >= 0) {           } else             continue;           cout << x <<    ;           has += x;           m += has;           cout << n - m - has <<   n ;         }       } else {         cout << has <<    ;         has += has;         m += has;         cout << n - m - has <<   n ;       }     }   }   int32_t main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     long long t;     cin >> t;     while (t--) {       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   long long mod = 1000000007;   template <typename T>   void debug(vector<T> x) {     for (auto e : x) {       cout << e <<    ;     }     cout <<   n ;   }   void solve() {     long long n, m, x, y;     cin >> n >> m >> x >> y;     vector<pair<long long, long long>> ans;     stack<pair<long long, long long>> st;     long long mat[n + 1][m + 1];     for (long long i = 1; i <= n; i++)       for (long long j = 1; j <= m; j++) mat[i][j] = 0;     st.push({x, y});     while (!st.empty()) {       pair<long long, long long> cur = st.top();       if (mat[cur.first][cur.second] == 0) {         mat[cur.first][cur.second] = 1;         ans.push_back({cur.first, cur.second});       }       st.pop();       for (long long i = 1; i <= n; i++) {         if (mat[i][cur.second] == 0) {           st.push({i, cur.second});         }       }       for (long long j = 1; j <= m; j++) {         if (mat[cur.first][j] == 0) {           st.push({cur.first, j});         }       }     }     for (auto x : ans) {       cout << x.first <<     << x.second <<   n ;     }   }   signed main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long t = 1;     while (t--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int N, cn = 0, Z = 0, max = 0;     cin >> N;     int arr[N];     for (int i = 0; i < N; i++) {       cin >> arr[i];     }     for (int i = 0; i < N; i++) {       cn = 0;       for (int j = i + 1; j < N; j++) {         if (arr[i] == arr[j] && arr[j] != 0) {           cn++;           arr[j] = 0;         }       }       if (max <= cn) {         max = cn;       }       if (cn >= 1) {         Z += cn;       }     }     cout << max + 1 <<     << N - Z;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ui32 = unsigned;   using ui64 = unsigned long long;   using i64 = long long;   using i32 = int;   static constexpr bool debug = false;   struct node {     node *c[2] = {0, 0};     int cnt = 0;   };   node *root = new node;   void insert_rec(node *nd, ui32 number, int i) {     ++nd->cnt;     if (i != -1) {       int bit = (number >> i) & 1;       if (nd->c[bit] == nullptr) nd->c[bit] = new node;       insert_rec(nd->c[bit], number, i - 1);     }   }   void insert(ui32 number) { insert_rec(root, number, 31); }   bool remove_rec(node *nd, ui32 number, int i) {     if (i != -1) {       int bit = (number >> i) & 1;       if (remove_rec(nd->c[bit], number, i - 1)) nd->c[bit] = nullptr;     }     if (--nd->cnt == 0) {       delete nd;       return true;     } else {       return false;     }   }   void remove(ui32 number) { remove_rec(root, number, 31); }   void print_numbers_rec(node *nd, ui32 number, int i) {     if (nd == nullptr) return;     if (i == -1) {       for (int j = 0; j < nd->cnt; ++j) {         cerr << number <<    ;       }     }     print_numbers_rec(nd->c[0], number << 1, i - 1);     print_numbers_rec(nd->c[1], (number << 1) | 1, i - 1);   }   void print_numbers() {     print_numbers_rec(root, 0, 31);     cerr << endl;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr);     int n;     cin >> n;     vector<ui32> a(n);     for (int i = 0; i < n; ++i) cin >> a[i];     for (int i = 0; i < n; ++i) {       ui32 t;       cin >> t;       insert(t);     }     vector<int> o(n);     for (int i = 0; i < n; ++i) {       node *cur = root;       ui32 xored = 0;       for (int j = 31; j >= 0; --j) {         int bit = (a[i] >> j) & 1;         if (cur->c[bit] != nullptr) {           cur = cur->c[bit];           xored = (xored << 1) | bit;         } else {           cur = cur->c[bit ^ 1];           xored = (xored << 1) | (bit ^ 1);         }       }       o[i] = a[i] ^ xored;       remove(xored);     }     for (int i = 0; i < n; ++i) {       cout << o[i] <<    n [i + 1 == n];     }   }
#include <bits/stdc++.h>   using namespace std;   const int MAX = 1e5 + 55;   const int inf = 1e9 + 77;   const int MOD = 1e9 + 7;   const double eps = 1e-7;   map<int, int> mp;   pair<int, int> pi;   vector<long long> v;   map<char, int> mp1;   deque<int> d;   int x[MAX], y[MAX];   char c[MAX];   int cnt[MAX];   int main() {     int n;     cin >> n;     long long even = 0;     long long odd = 0;     for (int i = 0; i < n; i++) {       long long a;       cin >> a;       if (a % 2 != 0)         odd++;       else         even++;     }     if (odd == 0)       cout <<  Second ;     else       cout <<  First ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n, k;     cin >> n >> k;     if (k == 0 || k == n) {       cout <<  0 0 ;       return 0;     }     cout << min(1LL, n - k) <<     << min(n - k, k * 2LL);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, tx, ty, ans = 0;     vector<int> x, y;     cin >> n;     for (int i = 0; i <= n; i++) {       cin >> tx >> ty;       x.push_back(tx), y.push_back(ty);     }     for (int i = 1; i < n; i++) {       int fx = x[i + 1], fy = y[i + 1];       int cx = x[i], cy = y[i];       int px = x[i - 1], py = y[i - 1];       if ((fy > cy && cx > px) || (cx > fx && cy > py) || (fy < cy && cx < px) ||           (fx > cx && cy < py))         ans++;     }     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long INF = 1e18;   int INFi = 2e9;   double eps = 1e-6;   long long mod = 1e9 + 7;   vector<char> used;   vector<vector<int>> edge;   vector<int> p;   vector<int> cnt;   int sz = 0;   void add(int beg, int end) {     while (beg != end) {       cnt[beg]++;       beg = p[beg];     }   }   void sub(int beg) {     while (used[beg] == 2) {       cnt[beg]--;       beg = p[beg];     }   }   void dfs(int v) {     used[v] = 1;     for (int u : edge[v]) {       if (used[u] == -1) {         continue;       }       if (used[u] == 2) {         sub(u);         continue;       }       if (used[u] == 1) {         add(v, u);         sz++;         continue;       }       p[u] = v;       dfs(u);     }     used[v] = 2;   }   int main() {     cin.tie(0);     cout.tie(0);     ios_base::sync_with_stdio(false);     int n, m;     cin >> n >> m;     edge.resize(n);     used.resize(n);     p.resize(n);     cnt.resize(n);     int t1, t2;     for (int i = 0; i < m; i++) {       cin >> t1 >> t2;       t1--;       t2--;       edge[t1].push_back(t2);     }     for (int i = 0; i < n; i++) {       if (!used[i]) dfs(i);       for (int j = 0; j < n; j++) {         if (used[j] == 2) used[j] = -1;       }     }     for (int i = 0; i < n; i++) {       if (cnt[i] == sz) {         cout <<  YES n ;         return 0;       }     }     if (sz == 1) {       cout <<  YES n ;     } else {       cout <<  NO n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int power(long long int x, long long int y) {     if (y == 0)       return 1;     else if (y % 2 == 0)       return power(x, y / 2) * power(x, y / 2);     else       return x * power(x, y / 2) * power(x, y / 2);   }   double slope(long long int x1, long long int y1, long long int x2,                long long int y2) {     return (double)((double)(y2 - y1) / (x2 - x1));   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long int ax, ay, bx, by, cx, cy;     cin >> ax >> ay >> bx >> by >> cx >> cy;     long long int dab = power((bx - ax), 2) + power((by - ay), 2);     long long int dbc = power((cx - bx), 2) + power((cy - by), 2);     if (dab != dbc) {       cout <<  No n ;     } else if (slope(ax, ay, bx, by) == slope(bx, by, cx, cy)) {       cout <<  No n ;     } else {       cout <<  Yes n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 1e5 + 5;   int n, m, ROOT, head;   bool vis[MAXN];   int depth[MAXN], deg[MAXN];   vector<int> adj[MAXN];   vector<int> c;   stack<int> stk;   pair<bool, vector<int> > independentSet() {     set<pair<int, int> > s;     vector<int> v;     for (auto i = 0; i < (n); i++) s.insert(make_pair(deg[i], i));     while (!s.empty()) {       int node = s.begin()->second;       s.erase(s.begin());       if (vis[node]) continue;       v.push_back(node);       vis[node] = true;       for (auto u : adj[node]) {         if (vis[u]) continue;         vis[u] = true;         for (auto v : adj[u]) {           if (v == u) continue;           --deg[v];           s.insert(make_pair(deg[v], v));         }       }     }     if (v.size() >= ROOT)       return make_pair(true, v);     else       return make_pair(false, vector<int>{});   }   void simpleCycle() {     while (!stk.empty() && stk.top() != head) {       c.push_back(stk.top());       stk.pop();     }     c.push_back(head);     reverse(c.begin(), c.end());     cout <<  2 n  << c.size() <<   n ;     for (auto u : c) cout << u + 1 <<    ;     exit(0);   }   void dfs(int node, int d) {     if (depth[node] > 0) {       if (d - depth[node] == ROOT) {         head = node;         simpleCycle();       }       return;     }     depth[node] = d;     stk.push(node);     for (auto u : adj[node]) {       dfs(u, d + 1);     }     stk.pop();   }   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     cin >> n >> m;     for (auto i = 0; i < (m); i++) {       int u, v;       cin >> u >> v;       --u;       --v;       adj[u].push_back(v);       adj[v].push_back(u);       ++deg[u];       ++deg[v];     }     ROOT = (int)sqrt(n);     if (ROOT * ROOT < n) ++ROOT;     auto is = independentSet();     if (is.first) {       cout <<  1 n ;       for (auto i = 0; i < (ROOT); i++) cout << is.second[i] + 1 <<    ;       exit(0);     } else {       dfs(0, 1);     }   }
#include <bits/stdc++.h>   using namespace std;   namespace whatever {   int readu() {     char ch = getchar();     while (!isdigit(ch)) ch = getchar();     int value = ch -  0 ;     ch = getchar();     while (isdigit(ch)) {       value = value * 10 + ch -  0 ;       ch = getchar();     }     return value;   }   long long readull() {     char ch = getchar();     while (!isdigit(ch)) ch = getchar();     long long value = ch -  0 ;     ch = getchar();     while (isdigit(ch)) {       value = value * 10 + ch -  0 ;       ch = getchar();     }     return value;   }   void writeull(long long n) {     if (n < 10)       putchar(n +  0 );     else {       writeull(n / 10);       putchar(n % 10 +  0 );     }   }   void run() {     int n = readu();     long long t = readull();     static int a[200000];     for (int i = 0; i < n; ++i) a[i] = readu();     long long result = 0;     while (n != 0) {       long long sum = accumulate(a, a + n, 0ll);       result += t / sum * n;       t %= sum;       for (int i = 0; i < n; ++i)         if (t >= a[i]) {           t -= a[i];           ++result;         }       n = remove_if(a, a + n, [t](int a) { return a > t; }) - a;     }     writeull(result);     putchar(  n );   }   }  // namespace whatever   int main() { whatever::run(); }
#include <bits/stdc++.h>   using namespace std;   const int buffer_size = 1 << 20;   int rd_char() {     static char buf[buffer_size];     static int l = buffer_size, r = buffer_size;     if (l == r && r == buffer_size) {       r = fread(buf, sizeof(char), 1 << 20, stdin);       l = 0;     }     if (l == r) return EOF;     return buf[l++];   }   unsigned int rd_uint() {     int c;     unsigned int x = 0;     while ( 0  <= (c = rd_char())) x = x * 10 + c -  0 ;     return x;   }   int rd_int() {     bool neg = false;     int c = rd_char();     long long x = 0;     if (c ==  - )       neg = true;     else       x = c -  0 ;     while ( 0  <= (c = rd_char())) x = x * 10 + c -  0 ;     return neg ? -x : x;   }   unsigned long long rd_ull() {     int c;     unsigned long long x = 0;     while ( 0  <= (c = rd_char())) x = x * 10 + c -  0 ;     return x;   }   long long rd_ll() {     bool neg = false;     int c = rd_char();     long long x = 0;     if (c ==  - )       neg = true;     else       x = c -  0 ;     while ( 0  <= (c = rd_char())) x = x * 10 + c -  0 ;     return neg ? -x : x;   }   string rd_str() {     string ret;     int c;     while ((c = rd_char()) !=   n  && c !=     && c != EOF) ret += c;     return ret;   }   struct writer_struct {     char buf[buffer_size];     int l = 0;     ~writer_struct() { fwrite(buf, sizeof(char), l, stdout); }   } writer;   void flush() {     fwrite(writer.buf, sizeof(char), writer.l, stdout);     fflush(stdout);     writer.l = 0;   }   void wt(char c) {     if (writer.l == buffer_size) {       fwrite(writer.buf, sizeof(char), buffer_size, stdout);       writer.l = 0;     }     writer.buf[writer.l++] = c;   }   void wt(unsigned int x) {     if (x == 0)       wt( 0 );     else {       char f[10];       int sz = 0;       while (x) {         f[sz++] = x % 10 +  0 ;         x /= 10;       }       while (sz) wt(f[--sz]);     }   }   void wt(int x) {     if (x < 0) wt( - ), x = -x;     wt((unsigned int)x);   }   void wt(unsigned long long x) {     if (x == 0)       wt( 0 );     else {       char f[20];       int sz = 0;       while (x) {         f[sz++] = x % 10 +  0 ;         x /= 10;       }       while (sz) wt(f[--sz]);     }   }   void wt(long long x) {     if (x < 0) wt( - ), x = -x;     wt((unsigned long long)x);   }   void wt(const char* s) {     while (*s !=   0 ) wt(*s++);   }   void wt(const string& s) {     for (char c : s) wt(c);   }   const int LIM = 3e6;   int N, C[LIM + 1];   long long cnt[LIM + 1];   int main() {     N = rd_uint();     for (int i = 0; i < N; i++) C[rd_uint()]++;     for (int i = 1; i <= LIM; i++) {       if ((long long)i * i <= LIM)         cnt[i * i] += (long long)C[i] * (C[i] - 1);       else         cnt[LIM] += (long long)C[i] * (C[i] - 1);       int rest = N - C[i];       for (int j = 1; (long long)i * j <= LIM; j++) {         if (i != j) cnt[i * j] += (long long)C[i] * C[j], rest -= C[j];       }       cnt[LIM] += (long long)C[i] * rest;     }     for (int i = LIM; i >= 1; i--) cnt[i - 1] += cnt[i];     int M = rd_uint();     for (; M--;) {       int p = rd_uint();       wt(cnt[p]);       wt(  n );     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr);     int n, i;     vector<int> arr, sol, orig;     cin >> n;     arr.resize(n);     for (i = 0; i < n; ++i) {       cin >> arr[i];     }     orig = arr;     sort(orig.begin(), orig.end());     for (i = 0; i < n; ++i) {       for (int k = 0; k + 1 < arr.size(); ++k) {         while (arr[i] - arr[i + 1] >= 2) ++arr[i + 1], --arr[i];         while (arr[i] - arr[i + 1] <= -2) --arr[i + 1], ++arr[i];       }       int j = -1, x = -1;       for (int k = 0; k < arr.size(); ++k) {         if (arr[k] > x) {           x = arr[k];           j = k;         }       }       sol.push_back(arr[j]);       arr.erase(arr.begin() + j);     }     reverse(sol.begin(), sol.end());     cout << (sol == orig ?  YES  :  NO ) <<   n ;   }
#include<bits/stdc++.h>   using namespace std;   int main()   {         int t,p,k,q,b;       cin>>t;       string s;       while(t--)       {           cin>>s;           k=0; q=0; b=0; p=0;           for(int i=0;i<s.size();i++)           {               if(s[0]== ) || s[s.size()-1]== ( )               {                   p=0; break;}               else if( s[i]== ( )               {                   k++;               }               else if(s[i]== ? )                 q++;                else if(s[i]== ) )                b++;           }                      if(k==b && q%2!=0 && k>0)           p=0;           else if(k==b&& q%2==0&& k>0)           p=1;           else if(q== abs(k-b) && k>0)           p=1;           if(p==1)           cout<< yes <<endl;           else           cout<< NO <<endl;       }   }
#include<bits/stdc++.h>   using namespace std;   #define il inline   #define rg register   #define int long long   #define M 998244353   const int P=3,Pn=332748118;   il int read()   {      int re=0,k=1;char ch=getchar();       while(ch> 9 ||ch< 0 ){if(ch== - )k=-1;ch=getchar();}       while(ch<= 9 &&ch>= 0 ){re=re*10+ch-48;ch=getchar();}       return re*k;   }   il void write(long long x)   {       if(x<0)return putchar( - ),write(-x),void();       if(x<10)return putchar(x+ 0 ),void();       return write(x/10),putchar(x%10+ 0 ),void();   }   signed main()   {    int T,a,b,c,d;    T=read();    while(T--)    {     d=read();a=read();b=read();c=read();     int ans=min((a-d%a)%a,min((b-d%b)%b,(c-d%c)%c));     write(ans);puts(  );    }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e4 + 10;   const double eps = 1e-8;   const double pi = acos(-1);   int main() {     int T;     cin >> T;     while (T--) {       string s;       cin >> s;       int cnt = 0;       bool flag0 = false, flag1 = false, flag2 = false;       for (int i = 0; i < s.size() - 1; i++) {         if (s[i] ==  0 ) flag0 = true;         if (s[i] ==  1 ) flag1 = true;         if (s[i] ==  2 ) flag2 = true;         if (s[i] ==  0  && s[i + 1] !=  0 ) cnt++;       }       if (s[s.size() - 1] ==  0 ) cnt++;       if (s[s.size() - 1] ==  0 ) flag0 = true;       if (s[s.size() - 1] ==  1 ) flag1 = true;       if (s[s.size() - 1] ==  2 ) flag2 = true;       if (!flag0)         cnt = min(cnt, 0);       else if (!flag1)         cnt = min(cnt, 1);       else if (!flag2)         cnt = min(cnt, 2);       cout << cnt << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 5e3 + 5;   int readint() {     int x = 0, f = 1;     char s = getchar();     while (s <  0  || s >  9 ) {       if (s ==  - ) f = -1;       (s = getchar());     }     while (s >=  0  && s <=  9 ) {       x = (x << 3) + (x << 1) + (s ^ 48);       (s = getchar());     }     return x * f;   }   long long dp[maxn][maxn];   int a[maxn];   int q[maxn];   int main() {     int n = readint(), k = readint(), x = readint();     for (int i = 1; i <= n; i++) {       a[i] = readint();     }     memset(dp, -0x3f, sizeof(dp));     dp[0][0] = 0;     for (int j = 1; j <= x; j++) {       int head = 1, tail = 0;       q[++tail] = 0;       for (int i = 1; i <= n; i++) {         while (head <= tail && i - q[head] > k) head++;         dp[i][j] = dp[q[head]][j - 1] + a[i] + 0ll;         while (head <= tail && dp[q[tail]][j - 1] <= dp[i][j - 1]) tail--;         q[++tail] = i;       }     }     long long ans = -1;     for (int i = n; i >= n - k + 1; i--) {       ans = max(ans, dp[i][x]);     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double PI = 3.1415926535897932384626433;   const long long mod = 1000000007;   const int INF = 0x3f3f3f3f;   const double eps = 1e-8;   template <class T>   T gcd(T a, T b) {     if (!b) return a;     return gcd(b, a % b);   }   const int maxn = 1e5 + 10;   vector<int> edg[maxn], vi, ans;   int now[maxn], nxt[maxn], len1, len2, n, m, vis[maxn], st[maxn], flg;   void dfs(int u) {     if (st[u] < 0) flg = 0;     if (flg == 0) return;     vis[u] = 1;     ans.push_back(u);     for (int i = 0; i < edg[u].size(); i++) {       int nxt = edg[u][i];       if (st[nxt] < 0) flg = 0;       if (!vis[nxt]) dfs(nxt);     }   }   int deal(int *a1, int *a2) {     int len = min(len1, len2);     for (int i = 0; i < len; i++) {       if (a1[i] < a2[i]) {         edg[a2[i]].push_back(a1[i]);         return 1;       } else if (a1[i] > a2[i]) {         vi.push_back(a1[i]);         if (st[a1[i]] == -1 || st[a2[i]] == 1) return 0;         st[a1[i]] = 1;         st[a2[i]] = -1;         return 1;       }     }     return len1 <= len2;   }   int solve() {     memset(st, 0, sizeof(st));     int *a1 = now, *a2 = nxt;     scanf( %d , &len1);     for (int i = 0; i < len1; i++) scanf( %d , &a1[i]);     flg = 1;     for (int t = 1; t < n; t++) {       scanf( %d , &len2);       for (int i = 0; i < len2; i++) scanf( %d , &a2[i]);       if (deal(a1, a2) == 0) flg = 0;       swap(a1, a2);       len1 = len2;     }     memset(vis, 0, sizeof(vis));     for (int i = 0; i < vi.size(); i++)       if (!vis[vi[i]]) dfs(vi[i]);     return flg;   }   int main() {     scanf( %d , &n);     scanf( %d , &m);     if (solve()) {       printf( Yes n%d n , ans.size());       for (int i = 0; i < ans.size(); i++) printf( %d  , ans[i]);       puts(  );     } else {       printf( No n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, k, a[5000] = {0};     cin >> n >> k;     for (int i = 1; i <= k; i++) {       int la = 0;       cin >> la;       if (la == 1) {         int p, q;         cin >> p >> q;         a[p] = 1;         a[q] = 1;       } else if (la == 2) {         int p;         cin >> p;         a[p] = 1;       }     }     int w = 0;     for (int i = 1; i < n; i++) {       if (a[i] == 0) {         w++;       }     }     int max = w, min = w + 1;     for (int i = 1; i <= n; i++) {       if (a[i] == 0 && a[i + 1] == 0) {         min--;         i++;       }     }     cout << min <<     << max << endl;   }