malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int *a;   int *b;   int n;   long long int what(long long x) {     long long int s = 0;     for (int i = 0; i < n; i++) {       s += (x * a[i]) / b[i];     }     return s;   }   int main() {     int i, j;     int c;     cin >> n >> c;     a = new int[n];     b = new int[n];     for (i = 0; i < n; i++) {       cin >> a[i] >> b[i];     }     c = c - n;     long long int l = 0;     long long int r = ((c + 1) * b[0]) / a[0] + 3;     long long int x;     x = r;     while (r - l > 1) {       if (what(x) < c)         l = x;       else         r = x;       x = (l + r) / 2;     }     long long int rl = r;     l = 0;     r = ((c + 1) * b[0]) / a[0] + 3;     x = r;     while (r - l > 1) {       if (what(x) <= c)         l = x;       else         r = x;       x = (l + r) / 2;     }     cout << (r - rl);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long M = 1000000007;   long long power(long long a, long long b) {     long long res = 1;     for (long long i = 0; i < b; i++) res = (res * a) % M;     return res;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long t, n, m, k, i, x, ara[100], ans;     cin >> t;     while (t--) {       cin >> n >> k;       x = 0;       m = k;       ans = 0;       while (m != 0) {         ara[x] = m % 2;         x++;         m /= 2;       }       for (i = 0; i < x; i++) {         if (ara[i] == 1) ans = ((ans % M) + power(n, i)) % M;       }       cout << ans <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long vet[9], used[9], available[9];   int dp[100][32];   int dp2[100][32];   vector<int> itens, itens2;   void comp() {     for (int i = 1; i <= 8; i++) {       long long j = 1;       used[i] = min(used[i], (long long)32 / i);       while (used[i]) {         itens.push_back(min(used[i], j) * i);         used[i] -= min(used[i], j);         j <<= 1;       }       j = 1;       available[i] = min(available[i], (long long)32 / i);       while (available[i]) {         itens2.push_back(min(available[i], j) * i);         available[i] -= min(available[i], j);         j <<= 1;       }     }     dp[0][0] = dp2[0][0] = 1;     for (int i = 0; i < itens.size(); i++) {       for (int j = 0; j < 32; j++) {         dp[i + 1][j] |= dp[i][j];         if (j >= itens[i]) dp[i + 1][j] |= dp[i][j - itens[i]];       }     }     for (int i = 0; i < itens2.size(); i++) {       for (int j = 0; j < 32; j++) {         dp2[i + 1][j] |= dp2[i][j];         if (j >= itens2[i]) dp2[i + 1][j] |= dp2[i][j - itens2[i]];       }     }   }   int consegue(int x) {     for (int i = 0; i < 32 - x; i++)       if (dp2[itens2.size()][i] && dp[itens.size()][x + i]) return 1;     return 0;   }   int main() {     long long W, total = 0;     scanf( %lld , &W);     for (int i = 1; i <= 8; i++) {       scanf( %lld , &vet[i]);       total += i * vet[i];     }     if (total <= W)       printf( %lld n , total);     else {       for (int i = 1; i <= 8; i++) used[i] = vet[i];       for (int i = 8; i >= 1; i--) {         if (total - i * used[i] >= W) {           total -= i * used[i];           available[i] = used[i];           used[i] = 0;         } else {           long long d = (total - W) / i;           total -= d * i;           used[i] -= d;           available[i] = d;         }       }       comp();       for (long long z = W; z >= max(0LL, W - 8); z--) {         int x = total - z;         if (consegue(x)) {           return !printf( %lld n , z);         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, k, A, B;   vector<long long> a(100000 + 5);   long long rec(int l, int r) {     long long m = (l + r) / 2, i, j, col = 0, lng = r - l + 1;     i = lower_bound(a.begin(), a.end(), l) - a.begin();     j = upper_bound(a.begin(), a.end(), r) - a.begin();     j--;     col = j - i + 1;     if (l == r && !col) return A;     if (l == r && col) return B * col;     if (!col) return A;     return min(B * lng * col, rec(l, m) + rec(m + 1, r));   }   int main() {     long long x;     cin >> n >> k >> A >> B;     for (int i = 0; i < k; i++) {       cin >> x;       a.push_back(x);     }     sort(a.begin(), a.end());     cout << rec(1, pow(2, n));     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[500100];   int n;   vector<int> g[200100];   int d[200100];   int cnt = 1;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cin >> n;     for (int i = 1; i <= n; i++) cin >> a[i];     for (int i = 1; i <= n; i++) {       int ind = lower_bound(d + 1, d + n + 1, a[i]) - d;       d[ind - 1] = a[i];       g[ind - 1].push_back(a[i]);     }     for (int i = n; i >= 1; i--) {       for (int j = 0; j < g[i].size(); j++) cout << g[i][j] <<    ;       cout << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   double x[(int)2e3 + 5], y[(int)2e3 + 5];   int fio() {     int val = 0;     char ch = getchar();     while (ch ==     || ch ==   n ) ch = getchar();     while (ch >=  0  && ch <=  9 ) {       val = val * 10 + ch -  0 ;       ch = getchar();     }     return val;   }   int main() {     int n, ans = 0;     n = fio();     for (int i = 0; i < n; i++) {       x[i] = fio(), y[i] = fio();     }     map<pair<double, double>, int> mid_points;     for (int i = 0; i < n; i++) {       for (int j = i + 1; j < n; j++) {         double mid_x = (x[i] + x[j]) / 2;         double mid_y = (y[i] + y[j]) / 2;         mid_points[make_pair(mid_x, mid_y)]++;       }     }     map<pair<double, double>, int>::iterator it = mid_points.begin();     while (it != mid_points.end()) {       ans += it->second * (it->second - 1) / 2;       it++;     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, b, p;     cin >> n >> b >> p;     int m = n;     long long int nb = 0;     while (n > 1) {       for (int i = 8; i >= 0; i--) {         if (pow(2, i) <= n) {           nb += b * pow(2, i) + pow(2, i) / 2;           n = n - (pow(2, i)) + pow(2, i) / 2;           break;         }       }     }     cout << nb <<     << m * p;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int gcd(int v, int vv) { return vv == 0 ? v : gcd(vv, v % vv); }   int main() {     int powV1, powV2, v[101], v2[101], vv, vv2, x;     cin >> powV1 >> powV2;     for (int i = 0; i <= powV1; i++) {       cin >> v[i];     }     for (int i = 0; i <= powV2; i++) {       cin >> v2[i];     }     for (int i = 0; i < powV1; i++) {       if (v[i] != 0) {         vv = v[i];         break;       }     }     for (int i = 0; i < powV2; i++) {       if (v2[i] != 0) {         vv2 = v2[i];         break;       }     }     if (powV1 == 0) vv = v[0];     if (powV2 == 0) vv2 = v2[0];     if (powV1 > powV2) {       if (vv * vv2 < 0)         cout <<  -Infinity  << endl;       else         cout <<  Infinity  << endl;     } else if (powV1 < powV2) {       cout <<  0/1  << endl;     } else {       x = gcd(abs(vv), abs(vv2));       if (vv2 < 0) {         vv2 *= -1;         vv *= -1;       }       cout << vv / x <<  /  << vv2 / x << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t, n, i, p;     cin >> t;     while (t--) {       cin >> n;       p = (n + 3) / 4;       for (i = 1; i <= n - p; i++) {         cout <<  9 ;       }       for (i = 1; i <= p; i++) {         cout <<  8 ;       }       cout << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2002;   int a[N][N] = {0}, b[N][N] = {0};   int c[N] = {0}, d[N] = {0}, e[N] = {0}, f[N] = {0};   int main() {     int n, m, ans = 0;     cin >> n >> m;     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= m; j++) {         cin >> a[i][j];         b[i][j] = a[i][j];         if (a[i][j] == 0) {           if (c[i] == 1) ans++;           if (d[j] == 1) ans++;         } else {           c[i] = 1, d[j] = 1;         }       }     }     for (int i = n; i >= 1; i--) {       for (int j = m; j >= 1; j--) {         if (b[i][j] == 0) {           if (e[i] == 1) ans++;           if (f[j] == 1) ans++;         } else {           e[i] = 1, f[j] = 1;         }       }     }     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 5;   vector<int> c[N];   vector<int> s[20][N];   int dp[20][N];   int h[N];   vector<int> v[N];   int sh(int x, int y) {     for (int i = 17; i + 1; --i)       if (y & (1 << i)) x = dp[i][x];     return x;   }   int ac(int x, int y) {     if (h[x] > h[y])       x = sh(x, h[x] - h[y]);     else       y = sh(y, h[y] - h[x]);     for (int i = 17; i + 1 && x != y; --i)       if (dp[i][x] != dp[i][y]) x = dp[i][x], y = dp[i][y];     if (x == y)       return x;     else       return dp[0][x];   }   void dfs(int prec, int node) {     h[node] = h[prec] + 1;     dp[0][node] = prec;     s[0][node] = c[node];     for (auto it : v[node])       if (it != prec) dfs(node, it);   }   vector<int> get(vector<int> a, vector<int> b) {     if (a.empty()) return b;     if (b.empty()) return a;     int *p = new int[a.size() + b.size()];     merge(a.begin(), a.end(), b.begin(), b.end(), p);     vector<int> as;     for (int *r = p, cn = 1; cn <= a.size() + b.size() && cn <= 10; ++r, ++cn)       as.push_back(*r);     while (as.size() && !(*as.begin())) as.erase(as.begin());     return as;   }   int main(void) {     int n, m, q;     scanf( %d%d%d n , &n, &m, &q);     int a, b;     for (int i = 1; i < n; ++i) {       scanf( %d%d , &a, &b);       v[a].push_back(b);       v[b].push_back(a);     }     for (int i = 1; i <= m; ++i) {       scanf( %d , &a);       c[a].push_back(i);     }     for (int i = 1; i <= n; ++i) {       sort(c[i].begin(), c[i].end());       while (c[i].size() > 10) c[i].erase(c[i].end() - 1);     }     dfs(0, 1);     for (int i = 1; i < 18; ++i)       for (int j = 1; j <= n; ++j) {         dp[i][j] = dp[i - 1][dp[i - 1][j]];         s[i][j] = get(s[i - 1][j], s[i - 1][dp[i - 1][j]]);       }     while (q--) {       int a, b, mx;       scanf( %d%d%d , &a, &b, &mx);       int anc = ac(a, b);       int disa = h[a] - h[anc];       int disb = h[b] - h[anc];       vector<int> ans;       for (int i = 17; i + 1; --i)         if ((1 << i) & disa) {           ans = get(ans, s[i][a]);           a = dp[i][a];           while (ans.size() > mx) ans.erase(ans.end() - 1);         }       for (int i = 17; i + 1; --i)         if ((1 << i) & disb) {           ans = get(ans, s[i][b]);           b = dp[i][b];           while (ans.size() > mx) ans.erase(ans.end() - 1);         }       ans = get(ans, c[anc]);       while (ans.size() > mx) ans.erase(ans.end() - 1);       printf( %d  , ans.size());       for (auto it : ans) printf( %d  , it);       printf(  n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxt = 300001;   typedef int mang[maxt + 10];   struct mystr {     int val[4];   };   mang bit1, bit2;   mystr a[100010];   int n, dem, vt = 1;   long long d, m;   vector<pair<long long, pair<int, int>>> b;   int kq[100010];   vector<int> s;   int getbit(int x, mang bit) {     int res = -maxt;     for (; x > 0; x -= x & (-x)) res = max(res, bit[x]);     return res;   }   void updatebit(int x, int val, mang& bit) {     for (; x <= maxt; x += x & (-x)) bit[x] = max(bit[x], val);   }   int main() {     ios::sync_with_stdio(0);     cin >> n >> d;     for (int i = 1; i <= n; i++) {       cin >> m;       b.push_back({m, {i, 1}});       b.push_back({m - d, {i, 2}});       b.push_back({m + d, {i, 3}});     }     b.push_back({(int)-1e18, {0, 0}});     sort(b.begin(), b.end());     for (int i = 1; i < b.size(); i++) {       if (b[i].first != b[i - 1].first) dem++;       a[b[i].second.first].val[b[i].second.second] = dem;     }     for (int i = 1; i <= n; i++) {       int longt =           max(getbit(a[i].val[2], bit1), getbit(maxt - a[i].val[3], bit2)) + 1;       updatebit(a[i].val[1], longt, bit1);       updatebit(maxt - a[i].val[1], longt, bit2);       kq[i] = longt;       if (kq[i] >= kq[vt]) vt = i;     }     cout << kq[vt] <<   n ;     for (int i = vt; i >= 1; i--)       if (kq[vt] == kq[i] + 1 &&           (a[i].val[1] <= a[vt].val[2] || a[i].val[1] >= a[vt].val[3])) {         s.push_back(vt);         vt = i;       }     cout << vt <<    ;     for (int i = s.size() - 1; i >= 0; i--) cout << s[i] <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool used[2011];   int b[2011];   int main() {     int n, k;     cin >> n >> k;     for (int i = 1; i <= n; i++) cin >> b[i];     int cand;     for (int i = 0; i < n; i++) {       int cnt = 0;       for (int j = n; j; j--) {         if (used[j + k]) cnt++;         if (!used[j])           if (b[j] == cnt) cand = j;       }       cout << cand <<    ;       used[cand] = true;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long double pi = acos(-1);   const long long INF = 1e14;   long long gcd(long long a, long long b) {     while (b) {       a = a % b;       swap(a, b);     }     return a;   }   int main() {     long long n, m, k;     cin >> n >> m >> k;     if ((n * m * 2) % k != 0 || k == 1) {       cout <<  NO ;       return 0;     }     cout <<  YES           <<   n ;     if (k % 2 == 0) {       k = k / 2;       long long g = gcd(n, k);       n = n / g;       k = k / g;       g = gcd(m, k);       m = m / g;       k = k / g;       cout << 0 <<     << 0 <<   n ;       cout << n <<     << 0 <<   n ;       cout << 0 <<     << m <<   n ;       return 0;     }     long long g = gcd(n, k);     if (g > 1) {       n = (n / g) * 2;       k = k / g;       g = gcd(m, k);       m = m / g;       k = k / g;     } else {       n = (n / g);       k = k / g;       g = gcd(m, k);       m = (m / g) * 2;       k = k / g;     }     cout << 0 <<     << 0 <<   n ;     cout << n <<     << 0 <<   n ;     cout << 0 <<     << m <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX_NUMBER = 105;   int flower[MAX_NUMBER], odd[MAX_NUMBER], even[MAX_NUMBER];   int number;   int main() {     scanf( %d , &number);     int sums = 0;     int odd_number = 0, even_number = 0;     for (int i = 1; i <= number; i++) {       scanf( %d , &flower[i]);       sums = sums + flower[i];       if (flower[i] % 2 == 1) {         odd[odd_number++] = flower[i];       } else {         even[even_number++] = flower[i];       }     }     if (odd_number == 0) {       printf( 0 n );     } else {       if (odd_number % 2 == 1) {         printf( %d n , sums);       } else {         sort(odd, odd + odd_number);         printf( %d n , sums - odd[0]);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long a[2005], b[2005];   vector<pair<long long, pair<int, int> > > bb;   long long diff = 0L;   bool good(long long x, int place) {     if (place >= bb.size())       return false;     else       return diff + 2 * (bb[place].first - x) <= 0;   }   int find_(long long x) {     int place = -1, jump = bb.size();     while (jump > 0) {       if (good(x, place + jump)) place += jump;       jump /= 2;     }     while (good(x, place + 1)) place++;     return place;   }   bool sorter(pair<long long, pair<int, int> > a,               pair<long long, pair<int, int> > b) {     return a.first < b.first;   }   int main() {     int n;     scanf( %i , &n);     for (int e = 0; e < n; e++) scanf( %I64d , &a[e]);     int m;     scanf( %i , &m);     for (int e = 0; e < m; e++) scanf( %I64d , &b[e]);     for (int e = 0; e < n; e++) diff += a[e];     for (int e = 0; e < m; e++) diff -= b[e];     long long acc = diff;     vector<pair<int, int> > rr;     for (int e = 0; e < n; e++) {       for (int ee = 0; ee < m; ee++) {         if (abs(diff + 2 * (b[ee] - a[e])) < abs(acc)) {           acc = diff + 2 * (b[ee] - a[e]);           rr.clear();           rr.push_back(make_pair(e, ee));         }       }     }     for (int e = 0; e < m; e++) {       for (int ee = e + 1; ee < m; ee++) {         bb.push_back(make_pair(b[e] + b[ee], make_pair(e, ee)));       }     }     sort(bb.begin(), bb.end(), sorter);     for (int e = 0; e < n; e++) {       for (int ee = e + 1; ee < n; ee++) {         long long itm = a[e] + a[ee];         int pl = find_(itm);         if (pl < (int)bb.size() - 1) {           if (abs(diff + 2 * (bb[pl + 1].first - itm)) < abs(acc)) {             acc = diff + 2 * (bb[pl + 1].first - itm);             rr.clear();             rr.push_back(make_pair(e, bb[pl + 1].second.first));             rr.push_back(make_pair(ee, bb[pl + 1].second.second));           }         }         if (pl > -1) {           if (abs(diff + 2 * (bb[pl].first - itm)) < abs(acc)) {             acc = diff + 2 * (bb[pl].first - itm);             rr.clear();             rr.push_back(make_pair(e, bb[pl].second.first));             rr.push_back(make_pair(ee, bb[pl].second.second));           }         }       }     }     printf( %I64d n%i n , abs(acc), rr.size());     for (auto e : rr) printf( %i %i n , e.first + 1, e.second + 1);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int l, r;     cin >> l >> r;     for (int i = l; i <= r; ++i) {       int d[10] = {};       int c = i;       bool ok = true;       while (c) {         if (d[c % 10]) {           ok = false;           break;         }         d[c % 10] += 1;         c /= 10;       }       if (ok) {         cout << i <<   n ;         return 0;       }     }     cout <<  -1 n ;   }
#include <bits/stdc++.h>   using namespace std;   long long dx[] = {-1, 0, 1, 0};   long long dy[] = {0, 1, 0, -1};   long long spf[1];   void sieve() {     long long i, j;     for (i = 0; i < 1; i++) spf[i] = i;     for (i = 4; i < 1; i += 2) spf[i] = 2;     for (i = 3; i * i < 1; i++) {       if (spf[i] == i) {         for (j = i * i; j < 1; j += i) {           if (spf[j] == j) spf[j] = i;         }       }     }   }   bool isvowel(char c) {     switch (c) {       case  a :       case  e :       case  i :       case  o :       case  u :       case  y :         return true;       default:         return false;     }   }   bool isPrime(long long n) {     for (long long i = 2; i <= sqrt(n); i++) {       if (n % i == 0) {         return false;       }     }     return true;   }   long long sum(long long n) {     long long ans = 0;     while (n > 0) {       long long d = n % 10;       ans += d;       n /= 10;     }     return ans;   }   vector<long long> adj[200005];   long long col[200005];   pair<long long, long long> e[200005];   long long bfs(long long node) {     col[node] = 1;     queue<long long> q;     q.push(node);     while (!q.empty()) {       long long curr = q.front();       q.pop();       for (auto child : adj[curr]) {         if (col[child] == -1) {           col[child] = 1 - col[curr];           q.push(child);         } else if (col[child] == col[curr]) {           return false;         }       }     }     return true;   }   int32_t main() {     ios::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long t = 1;     while (t--) {       long long n, m;       cin >> n >> m;       for (long long i = 1; i <= m; i++) {         long long u, v;         cin >> u >> v;         adj[u].push_back(v);         adj[v].push_back(u);         e[i] = {u, v};       }       memset(col, -1, sizeof(col));       for (long long i = 1; i <= n; i++) {         if (col[i] == -1) {           if (bfs(i) == false) {             cout <<  NO                   <<   n ;             return 0;           }         }       }       cout <<  YES             <<   n ;       vector<long long> v;       for (long long i = 1; i <= n; i++) {         if (col[i] == 1) {           v.push_back(i);         }       }       for (long long i = 1; i <= m; i++) {         if (col[e[i].first] == 0) {           cout <<  0 ;         } else {           cout <<  1 ;         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long INF = 1e18;   const int inf = 1e9;   const long double eps = 1e-7;   const long double pi = acos(-1);   const int dx[8] = {0, 2, 1, 0, -2, -1, 1, 2};   const int dy[8] = {2, 0, 1, -2, 0, -1, 2, 1};   const int N = 23;   const int MAXN = 1e5;   const int mod = 1e9 + 7;   int g[N];   int dp[(1 << N)], p[(1 << N)];   int main() {     int n, m;     cin >> n >> m;     if (m == n * (n - 1) / 2) {       cout << 0;       return 0;     }     for (int i = 1; i <= m; i++) {       int u, v;       cin >> u >> v;       u--, v--;       g[u] |= (1 << v);       g[v] |= (1 << u);     }     for (int i = 0; i < n; i++) {       g[i] |= (1 << i);     }     for (int i = 0; i < (1 << n); i++) {       dp[i] = inf;     }     dp[0] = 0;     for (int i = 0; i < n; i++) {       dp[g[i]] = 1;       p[g[i]] = 0;     }     for (int mask = 1; mask < (1 << n); mask++) {       if (dp[mask] == inf) continue;       for (int i = 0; i < n; i++) {         if ((mask >> i) & 1) {           int nmask = (mask | g[i]);           if (dp[nmask] > dp[mask] + 1) {             dp[nmask] = dp[mask] + 1;             p[nmask] = mask;           }         }       }     }     int mask = (1 << n) - 1;     vector<int> ans;     cout << dp[mask] <<   n ;     while (mask) {       int pmask = p[mask];       if (p[mask] == 0) {         for (int i = 0; i < n; i++) {           if (mask == g[i]) {             ans.push_back(i);             break;           }         }         break;       }       for (int i = 0; i < n; i++) {         if ((pmask >> i) & 1) {           int nmask = (pmask | g[i]);           if (nmask == mask) {             ans.push_back(i);             break;           }         }       }       mask = pmask;     }     reverse(ans.begin(), ans.end());     for (int i = 0; i < (int)ans.size(); i++) {       cout << ans[i] + 1 <<    ;     }   }
#include <bits/stdc++.h>   using namespace std;   string slv(string s) {     int sz = s.size();     if (sz % 2 == 1)       return s;     else {       string a = slv(s.substr(0, sz / 2));       string b = slv(s.substr(sz / 2, sz));       return a < b ? a + b : b + a;     }   }   int main() {     string a, b;     cin >> a >> b;     cout << ((slv(a) == slv(b)) ?  YES  :  NO );   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int a, n, ans;     while (cin >> n >> a) {       ans = (a / 2) + 1;       if (a % 2 == 0) {         ans = ans - 1;         ans = (n / 2) - ans;         ans = ans + 1;       }       cout << ans << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m, b;     cin >> n >> m;     vector<int> ct(0);     if (m == 1) {       for (int j = 0; j < n; j++) cout << 1 << endl;       return 0;     }     if (m == 2) {       ct.push_back(1);       ct.push_back(2);       for (int i = 0; i < n; i++) cout << ct[i % 2] << endl;       return 0;     }     if (m % 2 != 0) {       ct.push_back((m + 1) / 2);       int l, r;       l = (m + 1) / 2;       r = (m + 1) / 2;       while (l != 1) {         l--;         ct.push_back(l);         r++;         ct.push_back(r);       }       for (int i = 0; i < n; i++) cout << ct[i % m] << endl;     } else if (m % 2 == 0) {       ct.push_back((m + 1) / 2);       int l, r;       l = (m + 1) / 2;       r = (m + 1) / 2;       while (l != 1) {         r++;         ct.push_back(r);         l--;         ct.push_back(l);       }       ct.push_back(m);       for (int i = 0; i < n; i++) cout << ct[i % m] << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> v[10003], v1[10003];   int cnt[10003];   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     int n, m, i, j;     cin >> m >> n;     for (i = 0; i < m; i++) {       int x, y;       cin >> x;       memset(cnt, 0, sizeof(cnt));       for (j = 0; j < x; j++) {         cin >> y;         v[i].push_back(y);         cnt[y]++;       }       for (j = 1; j <= n; j++) {         if (!cnt[j]) v1[i].push_back(j);       }       sort(v[i].begin(), v[i].end());       sort(v1[i].begin(), v1[i].end());     }     for (i = 0; i < m; i++)       for (j = 0; j < m; j++) {         int fl = 1;         for (int k = 0; k < v[i].size(); k++) {           if (!binary_search(v1[j].begin(), v1[j].end(), v[i][k])) fl = 0;         }         if (fl) {           cout <<  impossible ;           return 0;         }       }     cout <<  possible ;   }