malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int dx[9] = {1, 0, -1, 0, 1, 1, -1, -1};   int dy[9] = {0, 1, 0, -1, 1, -1, 1, -1};   struct edge {     int st, ed;     char col;     edge() {       this->st = 0;       this->ed = 0;       this->col = 0;     }     edge(int st, int ed, char col) {       this->st = st;       this->ed = ed;       this->col = col;     }   };   long long n, m;   long long a[2000001], b[2000001];   int main() {     std::ios_base::sync_with_stdio(false);     cin.tie(NULL);     int t = 1;     for (int test_case = 0; test_case < t; ++test_case) {       cin >> n >> m;       string input;       cin >> input;       string s2 =   ;       for (int i = 0; i < n; ++i) {         a[i] = 1000000000;       }       for (int i = 0; i < n; ++i) {         if (a[i % m] == 1000000000) a[i % m] = (long long)input[i] -  0 ;         s2 += input[i % m];       }       bool flg = 0;       if (s2 < input) flg = 1;       if (flg) {         int i;         for (i = 0; i < n; ++i) {           if (a[i] == 1000000000) break;         }         i--;         while (a[i] == 9) {           a[i] = 0;           i--;         }         a[i]++;       }       cout << n <<   n ;       for (int i = 0; i < n; ++i) {         cout << a[i % m];       }       cout <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   inline void read(T &x) {     x = 0;     char c = getchar();     while (!isdigit(c)) c = getchar();     while (isdigit(c)) {       x = x * 10 + c -  0 ;       c = getchar();     }   }   int fr[100005], to[100005 << 1], ne[100005 << 1], x[100005];   int a[100005], b[100005], l, r;   int n, m;   int flag;   int c, d, e;   inline void dfs(int w) {     for (int u = fr[w]; u; u = ne[u])       if (!x[to[u]]) {         x[to[u]] = 3 - x[w];         dfs(to[u]);       } else if (x[w] == x[to[u]])         flag = 1;   }   int main() {     read(n);     read(m);     for (int i = 1; i <= m; ++i) {       read(c);       read(d);       to[++e] = d;       ne[e] = fr[c];       fr[c] = e;       to[++e] = c;       ne[e] = fr[d];       fr[d] = e;     }     flag = 0;     for (int i = 1; i <= n; ++i)       if (!x[i]) {         x[i] = 1;         dfs(i);       }     if (flag)       printf( -1 n );     else {       for (int i = 1; i <= n; ++i)         if (x[i] == 1)           a[++l] = i;         else           b[++r] = i;       printf( %d n , l);       for (int i = 1; i <= l; ++i) printf( %d%c , a[i], i < l ?     :   n );       printf( %d n , r);       for (int i = 1; i <= r; ++i) printf( %d%c , b[i], i < r ?     :   n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long dp[1005][1005];   int K;   void init() {     dp[0][0] = 0;     dp[0][K + 1] = 1;     for (int i = 1; i <= 1000; i++) {       dp[i][0] = (dp[i - 1][1] * 2 + dp[i - 1][0] * 8) % 1000000007;       for (int j = 1; j <= K; j++)         dp[i][j] = (dp[i - 1][K + 1] * 2 + dp[i - 1][(j + 1) % (K + 1)] * 8) %                    1000000007;       dp[i][K + 1] = 10 * dp[i - 1][K + 1] % 1000000007;     }   }   int solve(char s[], int len, bool flag = false) {     int j = 0, ret = 0;     for (int i = 0; i < len; i++) {       int t = s[i] -  0 ;       int a = t <= 4 ? 0 : (t <= 7 ? 1 : 2), b = t - a, g;       if (i == 0) b--;       g = j == 0 ? 1 : (K + 1);       ret += dp[len - i - 1][g] * a % 1000000007;       ret %= 1000000007;       g = j;       if (g != 0 && g != K + 1) g = (g + 1) % (K + 1);       ret += dp[len - i - 1][g] * b % 1000000007;       ret %= 1000000007;       if (i)         ret = (ret +                (7 * dp[len - i - 1][0] + 2 * dp[len - i - 1][1]) % 1000000007) %               1000000007;       if (s[i] ==  4  || s[i] ==  7 )         j = j == 0 ? 1 : (K + 1);       else if (j != 0 && j != K + 1)         j = (j + 1) % (K + 1);     }     if (flag && j == K + 1) ret = (ret + 1) % 1000000007;     return ret;   }   int main() {     int cas;     scanf( %d%d , &cas, &K);     init();     char l[1005], r[1005];     int len;     while (cas--) {       scanf( %s%s , l, r);       len = strlen(l);       int g = solve(l, len);       len = strlen(r);       int h = solve(r, len, 1);       printf( %d n , (h - g + 1000000007) % 1000000007);     }     return 0;   }
#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);   }   void print(int i) {     for (int j = 0; j < 3; j++) {       cout << !!(i & (1 << j));     }     cout <<  - ;   }   int v[5][5];   int OK[10][10];   int n, m;   bool ok(int a, int b) {     if (OK[a][b] != -1) return OK[a][b];     for (int i = 0; i < n; i++) {       for (int j = 0; j < 2; j++) {         int c = (j == 0 ? a : b);         if ((c & (1 << i))) {           v[i][j] = 1;         } else           v[i][j] = 0;       }     }     for (int i = 0; i < n - 1; i++) {       int tot = v[i][0] + v[i][1] + v[i + 1][0] + v[i + 1][1];       if (tot % 2 == 0) return OK[a][b] = 0;     }     return OK[a][b] = 1;   }   const int N = 1e6 + 10;   vector<vector<char> > mat;   int C[N][(1 << 3)];   int cost(int id, int msk) {     if (C[id][msk] != -1) return C[id][msk];     int c = 0;     for (int j = 0; j < n; j++) {       int sla = (msk & (1 << j)) > 0;       if ((sla) != (mat[j][id] -  0 )) c++;     }     return C[id][msk] = c;   }   const int inf = 1e8;   int dp[N][(1 << 3)];   int solve(int j, int msk) {     if (j == m) return 0;     int& x = dp[j][msk];     if (x != -1) return x;     x = inf;     for (int m = 0; m < (1 << n); m++) {       if (ok(m, msk)) x = min(x, solve(j + 1, m) + cost(j, m));     }     return x;   }   int32_t main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     memset(C, -1, sizeof(C));     memset(OK, -1, sizeof(OK));     memset(dp, -1, sizeof(dp));     cin >> n >> m;     mat.resize(n, vector<char>(m));     for (int i = 0; i < (n); ++i)       for (int j = 0; j < (m); ++j) cin >> mat[i][j];     if (n == 1) {       cout << 0 <<   n ;     } else if (n <= 3) {       int res = 1e9;       for (int i = 0; i < (1 << n); i++) {         res = min(res, solve(1, i) + cost(0, i));       }       cout << res <<   n ;     } else {       cout << -1 <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   long long n, m, ans, ini, fin, med, idx;   bool t[40];   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cin >> n >> m;     for (long long i = 0; i < m; i++) {       cout <<  1 n ;       cout.flush();       cin >> ans;       if (!ans) return 0;       if (ans == 1) t[i] = true;     }     ini = 1;     fin = n;     while (ini != fin) {       med = (ini + fin) / 2;       cout << med <<   n ;       cout.flush();       cin >> ans;       if (!ans) return 0;       if (t[idx]) {         if (ans == 1) {           ini = med + 1;         } else {           fin = med - 1;         }       } else {         if (ans == 1) {           fin = med - 1;         } else {           ini = med + 1;         }       }       idx++;       idx %= m;     }     cout << ini <<   n ;     cout.flush();     cin >> ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 5001;   long long n, m, a[N + 1], b[N + 1], type[N], l[N], r[N], x[N];   int main() {     ios_base::sync_with_stdio(false);     cin >> n >> m;     for (int i = 1; i <= n; i++) a[i] = 1e9;     for (int j = 1; j <= m; j++) {       cin >> type[j] >> l[j] >> r[j] >> x[j];       if (type[j] == 1)         for (int i = l[j]; i <= r[j]; i++) b[i] += x[j];       else {         bool ok = false;         for (int i = l[j]; i <= r[j]; i++) {           if (a[i] >= x[j] - b[i]) ok = true;           a[i] = min(a[i], x[j] - b[i]);         }         if (!ok) {           cout <<  NO ;           return 0;         }       }     }     for (int i = 1; i <= n; i++) b[i] = a[i];     bool ok = true;     for (int i = 1; i <= m; i++) {       if (type[i] == 1)         for (int j = l[i]; j <= r[i]; j++) a[j] += x[i];       else {         long long mx = a[l[i]];         for (int j = l[i] + 1; j <= r[i]; j++) mx = max(mx, a[j]);         if (mx != x[i]) {           ok = false;           break;         }       }     }     if (!ok)       cout <<  NO ;     else {       cout <<  YES  << endl;       for (int i = 1; i <= n; i++) cout << b[i] <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int mat[105][105];   int n, m, res;   void solve(int p) {     if (p % 2) return;     for (int i = 0, j = p - 1; i < p / 2; i++, j--)       for (int k = 0; k < m; k++)         if (mat[i][k] != mat[j][k]) return;     res = res / 2;     solve(p / 2);   }   int main() {     scanf( %d%d , &n, &m);     for (int i = 0; i < n; i++)       for (int j = 0; j < m; j++) scanf( %d , &mat[i][j]);     res = n;     solve(n);     printf( %d n , res);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int M = 400005;   int read() {     int x = 0, flag = 1;     char c;     while ((c = getchar()) <  0  || c >  9 )       if (c ==  - ) flag = -1;     while (c >=  0  && c <=  9 )       x = (x << 3) + (x << 1) + (c ^ 48), c = getchar();     return x * flag;   }   int n, m, a[M], b[M], s[M], f[M];   vector<int> t;   void manacher() {     for (int i = 1; i <= n; i++) s[i * 2] = b[i];     for (int i = 1; i <= n; i++) s[i * 2 - 1] = -1;     s[2 * n + 1] = -1;     int r = 0, c = 0;     for (int i = 1; i <= 2 * n + 1; i++) {       f[i] = r > i ? min(r - i + 1, f[2 * c - i]) : 1;       while (i + f[i] <= 2 * n + 1 && i - f[i] >= 1 && s[i - f[i]] == s[i + f[i]])         f[i]++;       if (i + f[i] - 1 > r) {         r = i + f[i] - 1;         c = i;       }     }   }   int chk(int l, int r) {     if (l >= r) return 1;     int p = l + r;     int ll = p - f[p] + 1, rr = p + f[p] - 1;     return ll <= 2 * l && rr >= 2 * r;   }   int main() {     n = read();     m = read();     for (int i = 1; i <= n; i++) a[i] = read();     for (int i = 1; i <= n; i++) b[i] = a[i] - a[i - 1];     if (n == 1) {       printf( 1 n%d n , (a[1] + a[1]) % m);       return 0;     }     manacher();     for (int i = 1; i < n; i++) {       if ((a[1] + a[i]) % m == (a[i + 1] + a[n]) % m)         if (chk(2, i) && chk(i + 2, n)) t.push_back((a[1] + a[i]) % m);     }     if (chk(2, n)) t.push_back((a[1] + a[n]) % m);     sort(t.begin(), t.end());     printf( %d n , t.size());     for (int i = 0; i < t.size(); i++) printf( %d  , t[i]);   }
#include <bits/stdc++.h>   using namespace std;   int n, ans, m;   queue<int> q;   int main() {     cin >> n;     int *a = new int[n + 1];     int *j = new int[n + 1];     memset(a, 0, sizeof(int) * (n + 1));     for (int i = 1; i <= n; i++) {       cin >> j[i];       a[j[i]]++;       if (a[j[i]] > 1) ans++;     }     cout << ans << endl;     for (int i = 1; i <= n; i++) {       if (a[i] == 0) q.push(i);     }     for (int i = 1; i <= n; i++) {       if (q.empty()) {         cout << j[i] <<    ;       } else {         if (a[j[i]] > 1) {           if (j[i] < q.front()) {             cout << j[i] <<    ;             a[j[i]] = 0;           } else {             a[j[i]]--;             m = q.front();             cout << m <<    ;             q.pop();           }         } else if (a[j[i]] == 1) {           cout << j[i] <<    ;         } else {           m = q.front();           cout << m <<    ;           q.pop();         }       }     }     delete[] a;     delete[] j;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 300000 + 5;   int a[maxn];   int main() {     int n;     cin >> n;     int mn = 0x3f3f3f3f;     for (int i = 1; i <= n; i++) {       scanf( %d , &a[i]);       mn = min(a[i], mn);     }     int ans = 0x3f3f3f3f;     for (int i = 1; i <= n; i++) {       if (i != 1) ans = min(min(a[i], a[1]) / abs(1 - i), ans);       if (i != n) ans = min(min(a[i], a[n]) / abs(n - i), ans);     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void xx(int *a, int n) {     for (int j = 1; j < n; ++j)       for (int i = j; i <= n; ++i)         if (a[j] < a[i]) {           int t = a[i];           a[i] = a[j];           a[j] = t;         }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int t, n;     cin >> t;     for (int i = 1; i <= t; ++i) {       cin >> n;       int a[n];       for (int j = 1; j <= n; ++j) cin >> a[j];       xx(a, n);       for (int j = 1; j <= n; ++j) cout << a[j] <<    ;       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool check(long long x, long long y, long long p, long long q, long long t) {     return p * t >= x && q * t - p * t >= y - x;   }   int main() {     long long t;     cin >> t;     while (t--) {       long long x, y, p, q, m;       cin >> x >> y >> p >> q;       long long l = -1;       long long r = (long long)1e9;       if (!check(x, y, p, q, r)) {         printf( -1 n );         continue;       }       while (r - l > 1) {         m = l + (r - l) / 2;         if (check(x, y, p, q, m))           r = m;         else           l = m;       }       printf( %lld n , r * q - y);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 100010;   const int INF = 0x3f3f3f3f;   const int iinf = 1 << 30;   const long long linf = 2e18;   const int mod = 1000000007;   const double eps = 1e-7;   void douout(double x) { printf( %lf n , x + 0.0000000001); }   template <class T>   void print(T a) {     cout << a << endl;     exit(0);   }   template <class T>   void chmin(T &a, T b) {     if (a > b) a = b;   }   template <class T>   void chmax(T &a, T b) {     if (a < b) a = b;   }   void add(int &a, int b) { a = a + b < mod ? a + b : a + b - mod; }   void sub(int &a, int b) { a = (a - b + mod) % mod; }   void mul(int &a, int b) { a = (long long)a * b % mod; }   int addv(int a, int b) { return (a += b) >= mod ? a -= mod : a; }   int subv(int a, int b) { return (a -= b) < 0 ? a += mod : a; }   int mulv(int a, int b) { return (long long)a * b % mod; }   int read() {     int f = 1, x = 0;     char ch = getchar();     while (!isdigit(ch)) {       if (ch ==  - ) f = -1;       ch = getchar();     }     while (isdigit(ch)) {       x = x * 10 + ch -  0 ;       ch = getchar();     }     return x * f;   }   int pw(int a, int b) {     int s = 1;     for (; b; b >>= 1, a = (long long)a * a % mod)       if (b & 1) s = (long long)s * a % mod;     return s;   }   int n, ans;   int val[N] = {1}, ans1[N], ans2[N], ans3[N], p[N];   void dfs(int x) {     if (val[x] == n && x == ans) {       printf( %d n , ans);       for (int i = (0); i <= (ans - 1); i++)         if (~ans2[i])           printf( lea e%cx, [e%cx + %d*e%cx] n , ans1[i] +  a , ans2[i] +  a ,                  p[i], ans3[i] +  a );         else           printf( lea e%cx, [%d*e%cx] n , ans1[i] +  a , p[i], ans3[i] +  a );       exit(0);     }     if (x == ans) return;     for (int i = (0); i <= (x); i++)       for (int j = (-1); j <= (x); j++)         for (int k = 1; k < 9; k <<= 1) {           if (j + 1)             val[x + 1] = val[i] * k + val[j];           else             val[x + 1] = val[i] * k;           ans1[x] = x + 1;           ans2[x] = j;           ans3[x] = i;           p[x] = k;           dfs(x + 1);         }   }   signed main() {     scanf( %d , &n);     for (ans = 0; ans <= n; ans++) dfs(0);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1000;   const double eps = 1e-9;   long long INF = 1e9;   const int OO = 0x3f3f3f3f;   int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};   int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};   bool comp(pair<int, int> a, pair<int, int> b) {     if (a.first < b.first)       return true;     else if (a.first > b.first)       return false;     else       return a.first < b.first;   }   void read(string str, int node) {     stringstream ss;     int number;     ss << str;     while (ss >> number) cout << number << endl;   }   long long fp(long long b, long long p) {     if (p == 0) return 1;     if (p % 2 == 0) return fp((b * b) % INF, p / 2);     return (fp(b, p - 1) * b) % INF;   }   unsigned long long read_binary(string s) {     unsigned long long x = 0, tmp = 1;     for (int i = s.size() - 1; i >= 0; i--) {       x = (x + tmp * (s[i] -  0 )) % INF;       tmp = (tmp * 2) % INF;     }     return x;   }   long long com(long long x, long long y) {     long long sum = 1;     for (int i = 1; i <= y; i++) {       sum *= x;       x--;       sum /= i;     }     return sum;   }   long long gcd(long long n1, long long n2) {     if (n2 != 0)       return gcd(n2, n1 % n2);     else       return n1;   }   int setBit(int num, int idx, int val = 1) {     return (val) ? (num | (1 << idx)) : (num & ~(1 << idx));   }   int getBit(int num, int idx) { return ((num >> idx) & 1) == 1; }   int cntBit(int num) {     int ret = 0;     while (num) {       if (num % 2) ret++;       num /= 2;     }     return ret;   }   bool sum[1500];   void sieve() {     sum[0] = sum[1] = 1;     for (int i = 2; i * i < 1002; i++) {       if (!sum[i]) {         for (int j = 2 * i; j < 1002; j += i) {           sum[j] = 1;         }       }     }   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     ;     long long n;     cin >> n;     string s = to_string(n);     long long mi = INF;     for (int i = 0; i < (1 << s.size()); ++i) {       int cnt = 0;       string k;       for (int j = 0; j < s.size(); j++) {         if (i & (1 << j)) {           k += s[j];           cnt++;         }       }       if (k[0] ==  0 ) continue;       long long val;       istringstream ss(k);       ss >> val;       double d = sqrt(val);       int ii = sqrt(val);       if (d == ii) {         mi = min(mi, (long long)s.size() - cnt);       }     }     if (mi == INF)       cout << -1 << endl;     else       cout << mi << endl;   }
#include <bits/stdc++.h>   using namespace std;   long long xorsum(long long n, long long k) {     if (k == 1) return n;     int msb = (int)log2((double)n);     if ((1ll << msb) > n) msb--;     return (2ll << msb) - 1;   }   int main() {     long long n, k;     cin >> n >> k;     cout << xorsum(n, k) << endl;     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( Ofast )   using namespace std;   void manupulate(string &str) {     for (long long int i = 0; i < str.size(); ++i) str[i] -= 48;   }   bool isprime(long long int n) {     if (n <= 1) return false;     for (long long int i = 2; i * i <= n; ++i)       if (n % i == 0) return false;     return true;   }   long long int expo(long long int a, long long int n) {     if (n == 0) return 1;     if (n == 1) return a;     long long int tmp = expo(a, n / 2);     tmp = (tmp * tmp) % (long)(1e9 + 7);     if (n & 1) tmp = (tmp * a) % (long)(1e9 + 7);     return tmp;   }   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     ;     long long int t;     cin >> t;     while (t--) {       string str;       cin >> str;       set<array<long long int, 4> > s;       long long int ans = 0;       long long int x = 0, y = 0;       for (long long int i = 0; i < str.size(); ++i) {         long long int x1 = x, y1 = y;         if (str[i] ==  N )           ++y1;         else if (str[i] ==  E )           ++x1;         else if (str[i] ==  S )           --y1;         else           --x1;         array<long long int, 4> tmp = {x, y, x1, y1};         array<long long int, 4> tmp2 = {x1, y1, x, y};         if (s.find(tmp) != s.end() || s.find(tmp2) != s.end())           ++ans;         else {           s.insert(tmp);           s.insert(tmp2);           ans += 5;         }         x = x1, y = y1;       }       cout << ans <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline int read() {     register int x = 0, f = 1;     register char ch = getchar();     while (!isdigit(ch)) {       if (ch ==  - ) f = 0;       ch = getchar();     }     while (isdigit(ch)) {       x = x * 10 + (ch ^  0 );       ch = getchar();     }     return f ? x : -x;   }   const int mod = 998244353;   int n, l[55], r[55], inv[105], b[105], t, f[55][105], s[55][105];   inline void inc(int& x, int y) { x = x + y < mod ? x + y : x + y - mod; }   inline int power(int b, int n) {     int ans = 1;     for (; n; n >>= 1, b = 1ll * b * b % mod)       if (n & 1) ans = 1ll * ans * b % mod;     return ans;   }   int main() {     n = read();     for (int i = (1), _ed = (n); i <= _ed; ++i)       l[i] = read(), r[i] = read(), b[++t] = l[i], b[++t] = ++r[i];     inv[0] = inv[1] = 1;     for (int i = (2), _ed = (n + n); i <= _ed; ++i)       inv[i] = 1ll * (mod - mod / i) * inv[mod % i] % mod;     sort(b + 1, b + t + 1), t = unique(b + 1, b + t + 1) - b - 1;     for (int i = (1), _ed = (n); i <= _ed; ++i)       l[i] = lower_bound(b + 1, b + t + 1, l[i]) - b,       r[i] = lower_bound(b + 1, b + t + 1, r[i]) - b;     f[0][t] = s[0][t] = 1;     for (int i = (1), _ed = (n + 1); i <= _ed; ++i)       for (int j = (t - 1), _ed = (1); j >= _ed; --j) {         s[i - 1][j] = (s[i - 1][j + 1] + f[i - 1][j]) % mod;         if (l[i] > j || r[i] <= j) continue;         int L = b[j + 1] - b[j], C = 1, cnt = 0;         for (int k = (i - 1), _ed = (0); k >= _ed; --k) {           ++cnt;           C = 1ll * C * (L + cnt - 1) % mod * inv[cnt] % mod;           inc(f[i][j], 1ll * s[k][j + 1] * C % mod);           if (l[k] > j || r[k] <= j) break;         }       }     int ans = s[n][1];     for (int i = (1), _ed = (n); i <= _ed; ++i)       ans = 1ll * ans * power(b[r[i]] - b[l[i]], mod - 2) % mod;     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   enum { N = 201 };   int n;   int where[N][N];   int cnt[N] = {};   int what[N];   int set[N][N];   int sn[N] = {};   int eq(int i, int j) {     int k;     for (k = 0; k < n - 1; ++k) {       if (where[i][k] != where[j][k]) return 0;     }     return 1;   }   int main(void) {     scanf( %d , &n);     int i, j, k, x;     if (n == 2) {       scanf( %d %d , &k, &x);       printf( 1 %d n%d  , x, k - 1);       for (i = 0; i < k - 1; ++i) {         scanf( %d , &x);         printf( %d  , x);       }       printf(  n );       return 0;     }     int nn = n * (n - 1) / 2;     for (i = 0; i < nn; ++i) {       scanf( %d , &k);       for (j = 0; j < k; ++j) {         scanf( %d , &x);         where[x][cnt[x]] = i;         ++cnt[x];       }     }     for (i = 1; i < N; ++i) {       if (cnt[i] == 0) continue;       what[i] = i;       for (j = 1; j < i; ++j) {         if (cnt[j] == 0) continue;         if (eq(j, i)) {           what[i] = j;           break;         }       }       set[what[i]][sn[what[i]]] = i;       ++sn[what[i]];     }     for (i = 1; i < N; ++i) {       if (sn[i] == 0) continue;       printf( %d  , sn[i]);       for (j = 0; j < sn[i]; ++j) {         printf( %d  , set[i][j]);       }       printf(  n );     }     return 0;   }