malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int main() {     cin.tie(0);     cout.tie(0);     ios_base::sync_with_stdio(false);     ;     long long t;     cin >> t;     while (t--) {       long long n;       cin >> n;       vector<set<long long>> lol(n - 1);       long long cnt = 0;       long long x;       for (long long i = 0; i < n - 1; i++) {         cin >> cnt;         for (long long j = 0; j < cnt; j++) {           cin >> x;           lol[i].insert(x);         }       }       for (long long i = 1; i <= n; i++) {         bool ok = 1;         vector<set<long long>> st(lol.begin(), lol.end());         long long need = i;         for (auto &z : st) {           z.erase(need);         }         vector<long long> ans;         ans.emplace_back(i);         for (long long j = 1; j < n; j++) {           long long cur = -1;           long long how = 0;           for (auto &z : st) {             if (z.size() == 1) {               cur = (*z.begin());               how++;             }           }           if (how != 1) {             ok = 0;             break;           }           ans.emplace_back(cur);           for (auto &z : st) z.erase(cur);         }         if (!ok) continue;         set<set<long long>> kavo(lol.begin(), lol.end());         for (long long k = 2; k < n; k++) {           set<long long> now;           now.insert(ans[k]);           bool is = 0;           for (long long j = k - 1; j >= 0; j--) {             now.insert(ans[j]);             if (kavo.count(now)) {               kavo.erase(now);               is = 1;               break;             }           }           if (!is) {             ok = 0;             break;           }         }         if (ok) {           for (auto z : ans) {             cout << z <<    ;           }           cout <<   n ;           break;         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long const lim = 1e5 + 5;   long long const mod = 1000000007;   vector<long long> adj[lim + 5];   long long vis[lim + 5], n;   vector<long long> count_edge;   long long child[lim + 5];   void all_clear() {     count_edge.clear();     for (long long i = 1; i <= lim; i++) {       adj[i].clear();       vis[i] = -1;       child[i] = 0;     }   }   void dfs(long long s) {     vis[s] = 1;     for (auto v : adj[s]) {       if (vis[v] == -1) {         dfs(v);         child[s] += child[v];         count_edge.push_back(child[v] * (n - child[v]));       }     }     child[s] += 1;   }   void solve() {     cin >> n;     all_clear();     for (int i = 1; i < n; i++) {       long long a, b;       cin >> a >> b;       adj[a].push_back(b), adj[b].push_back(a);     }     long long m;     cin >> m;     vector<long long> fact;     for (int i = 0; i < m; i++) {       long long p;       cin >> p;       fact.push_back(p);     }     dfs(1);     sort(count_edge.rbegin(), count_edge.rend());     sort(fact.rbegin(), fact.rend());     for (int i = 0; i < count_edge.size(); i++) count_edge[i] %= mod;     long long ans = 0;     if (fact.size() > count_edge.size()) {       while (fact.size() > count_edge.size()) {         long long val = fact[0];         fact.erase(fact.begin());         fact[0] = (fact[0] * val) % mod;       }       for (int i = 0; i < fact.size(); i++) {         ans = (ans + (fact[i] * count_edge[i]) % mod) % mod;       }     } else {       for (int i = 0; i < count_edge.size(); i++) {         if (i >= fact.size()) {           ans = (ans + count_edge[i]) % mod;         } else {           ans = (ans + (fact[i] * count_edge[i]) % mod) % mod;         }       }     }     cout << ans << endl;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0), cout.tie(0);     int t = 1, no = 0;     cin >> t;     while (t--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, i, c, d, cnt1, cnt2;     cin >> n;     pair<int, int> date[n];     for (i = 0; i < n; i++) {       cin >> date[i].first >> date[i].second;     }     sort(date, date + n);     c = date[0].first;     d = date[0].second;     if (c <= d)       cnt1 = c;     else       cnt1 = d;     for (i = 0; i < n; i++) {       c = date[i].first;       d = date[i].second;       if (c <= d)         cnt2 = c;       else         cnt2 = d;       if (cnt1 <= cnt2)         cnt1 = cnt2;       else         cnt1 = c;     }     cout << cnt1;   }
#include <bits/stdc++.h>   using namespace std;   int n, m;   long long v[100100];   vector<int> pos, neg;   vector<int> X, Y;   vector<long long> V;   int main() {     scanf( %d %d , &n, &m);     int x, y;     long long z;     memset(v, 0, sizeof(v));     for (int i = 0; i < m; i++) {       scanf( %d %d %I64d , &x, &y, &z);       v[x] += z;       v[y] -= z;     }     for (int i = 1; i <= n; i++) {       if (v[i] > 0) pos.push_back(i);       if (v[i] < 0) neg.push_back(i);     }     int i = 0, j = 0;     while (i < pos.size() && j < neg.size()) {       long long tem = v[pos[i]] > -v[neg[j]] ? -v[neg[j]] : v[pos[i]];       v[pos[i]] -= tem;       v[neg[j]] += tem;       X.push_back(pos[i]);       Y.push_back(neg[j]);       V.push_back(tem);       if (v[pos[i]] <= 0) i++;       if (v[neg[j]] >= 0) j++;     }     printf( %d n , X.size());     for (int i = 0; i < X.size(); i++) {       cout << X[i] <<     << Y[i] <<     << V[i] << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int n, p;   long long int a[100001];   int is_good(long long int q) {     int b[n];     for (int i = n - 1; i >= 0; i--) {       long long int l = max(a[i] - q, 0ll);       b[i] = n - l - (n - 1 - i);       if (b[i] % p == 0) return 0;     }     return 1;   }   int main() {     cin >> n >> p;     long long int maxx = 0;     for (int i = 0; i < n; ++i) {       cin >> a[i];       maxx = max(maxx, a[i]);     }     sort(a, a + n);     long long int t1 = 0;     for (int i = 0; i < n; i++) {       t1 = max(t1, a[i] - i);     }     long long int l = t1, r = 1000000001;     while (r > l) {       long long int mid = (r + l + 1) / 2;       if (is_good(mid)) {         l = mid;       } else {         r = mid - 1;       }     }     if (l == t1 && !is_good(l)) {       cout <<  0             <<   n ;       cout <<   n ;       exit(0);     }     cout << (l - t1 + 1) <<   n ;     for (long long int i = t1; i <= l; i++) {       cout << i <<    ;     }     cout <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   char ss[1002][1002];   int ak = -1, p = 0;   int main() {     while (gets(ss[p])) {       if ((int)strlen(ss[p]) > ak) ak = (int)strlen(ss[p]);       p++;     }     for (int i = 0; i <= ak + 1; i++) printf( * );     printf(  n );     bool k = false;     for (int i = 0; i < p; i++) {       int len = strlen(ss[i]);       if ((ak - len) % 2 != 0) k = !k;       printf( * );       for (int j = 0; j < (ak - len + (!k)) / 2; j++) printf(   );       printf( %s , ss[i]);       for (int j = 0; j < (ak - len + (k)) / 2; j++) printf(   );       printf( * n );     }     for (int i = 0; i <= ak + 1; i++) printf( * );     printf(  n );     return 0;   }
#include <bits/stdc++.h>   const int N = 30;   int a[N];   int main() {     int n;     scanf( %d , &n);     for (int i = 0; i < n; ++i) {       scanf( %d , &a[i]);     }     int max = 0, sit;     for (int i = 1; i <= 100000; ++i) {       bool div = true;       for (int j = 0; j < n; ++j) {         if (a[j] % i) {           div = false;           break;         }       }       if (!div) continue;       int oddcnt = 0;       for (int j = 0; j < n; ++j) {         oddcnt += a[j] / i & 1;       }       if (oddcnt > 1) continue;       int value = i * (oddcnt ? 1 : 2);       if (max < value) {         max = value;         sit = i;       }     }     printf( %d n , max);     if (!max) {       for (int i = 0; i < n; ++i) {         for (int j = 0; j < a[i]; ++j) {           putchar( a  + i);         }       }       putchar(  n );       return 0;     }     for (int i = 0; i < n; ++i) {       a[i] /= sit;     }     for (int times = 0; times < sit; ++times) {       for (int i = 0; i < n; ++i) {         for (int j = 0; j < a[i] >> 1; ++j) {           putchar( a  + i);         }       }       for (int i = 0; i < n; ++i) {         if (a[i] & 1) {           putchar( a  + i);         }       }       for (int i = n - 1; i >= 0; --i) {         for (int j = 0; j < a[i] >> 1; ++j) {           putchar( a  + i);         }       }     }     putchar(  n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 3e5 + 9;   int32_t main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     int n, s;     cin >> n >> s;     if (s < 2 * n) return cout <<  NO n , 0;     cout <<  YES n ;     for (int i = 1; i < n; i++) cout << 2 <<    ;     cout << s - 2 * (n - 1) <<   n ;     cout << 1 <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   double eps = 1e-9;   pair<int, int> get_closer(int a, vector<int> &v) {     auto it = lower_bound(v.begin(), v.end(), a);     int b = 2000000000, c = 2000000000;     if (it != v.end()) b = *it;     if (it != v.begin()) c = *(it - 1);     return {c, b};   }   unsigned long long int count(int a, int b, int c) {     return (a - b) * 1LL * (a - b) + (a - c) * 1LL * (a - c) +            (b - c) * 1LL * (b - c);   }   int main() {     int t;     scanf( %d , &t);     while (t--) {       int n1, n2, n3;       scanf( %d %d %d , &n1, &n2, &n3);       vector<int> r(n1), g(n2), b(n3);       for (int i = 0; i < n1; i++) scanf( %d , &r[i]);       for (int i = 0; i < n2; i++) scanf( %d , &g[i]);       for (int i = 0; i < n3; i++) scanf( %d , &b[i]);       sort(r.begin(), r.end());       sort(g.begin(), g.end());       sort(b.begin(), b.end());       unsigned long long int mn = count(r[0], b[0], g[0]);       for (int i = 0; i < n1; i++) {         int a = r[i];         pair<int, int> p1 = get_closer(a, g);         pair<int, int> p2 = get_closer(a, b);         pair<int, int> p3 = get_closer(p1.first, b);         pair<int, int> p4 = get_closer(p1.second, b);         mn = min(mn, count(a, p1.first, p2.first));         mn = min(mn, count(a, p1.second, p2.first));         mn = min(mn, count(a, p1.first, p2.second));         mn = min(mn, count(a, p1.second, p2.second));         mn = min(mn, count(a, p1.first, p3.first));         mn = min(mn, count(a, p1.first, p3.second));         mn = min(mn, count(a, p1.second, p4.first));         mn = min(mn, count(a, p1.second, p4.second));       }       for (int i = 0; i < n2; i++) {         int a = g[i];         pair<int, int> p1 = get_closer(a, r);         pair<int, int> p2 = get_closer(a, b);         pair<int, int> p3 = get_closer(p1.first, b);         pair<int, int> p4 = get_closer(p1.second, b);         mn = min(mn, count(a, p1.first, p2.first));         mn = min(mn, count(a, p1.second, p2.first));         mn = min(mn, count(a, p1.first, p2.second));         mn = min(mn, count(a, p1.second, p2.second));         mn = min(mn, count(a, p1.first, p3.first));         mn = min(mn, count(a, p1.first, p3.second));         mn = min(mn, count(a, p1.second, p4.first));         mn = min(mn, count(a, p1.second, p4.second));       }       for (int i = 0; i < n3; i++) {         int a = b[i];         pair<int, int> p1 = get_closer(a, g);         pair<int, int> p2 = get_closer(a, r);         pair<int, int> p3 = get_closer(p1.first, r);         pair<int, int> p4 = get_closer(p1.second, r);         mn = min(mn, count(a, p1.first, p2.first));         mn = min(mn, count(a, p1.second, p2.first));         mn = min(mn, count(a, p1.first, p2.second));         mn = min(mn, count(a, p1.second, p2.second));         mn = min(mn, count(a, p1.first, p3.first));         mn = min(mn, count(a, p1.first, p3.second));         mn = min(mn, count(a, p1.second, p4.first));         mn = min(mn, count(a, p1.second, p4.second));       }       cout << mn <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   int main() {     int n;     int a[10000];     while (scanf( %d , &n) != EOF) {       for (int i = 1; i <= n; i++) scanf( %d , &a[i]);       for (int i = 1; i <= n; i++) {         if (a[i] % 2 == 0) a[i] -= 1;       }       for (int i = 1; i <= n - 1; i++) printf( %d  , a[i]);       printf( %d n , a[n]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     map<char, int> mp;     mp.insert(pair<char, int>( A , 0));     mp.insert(pair<char, int>( B , 0));     mp.insert(pair<char, int>( C , 0));     int i = 3;     while (i--) {       string s;       cin >> s;       if (s[1] ==  > )         mp[s[0]]++;       else         mp[s[2]]++;     }     if (mp[ A ] == mp[ B ] && mp[ C ] == mp[ B ])       cout <<  Impossible ;     else {       if (mp[ A ] == 0)         cout <<  A ;       else if (mp[ B ] == 0)         cout <<  B ;       else if (mp[ C ] == 0)         cout <<  C ;       if (mp[ A ] == 1)         cout <<  A ;       else if (mp[ B ] == 1)         cout <<  B ;       else if (mp[ C ] == 1)         cout <<  C ;       if (mp[ A ] == 2)         cout <<  A ;       else if (mp[ B ] == 2)         cout <<  B ;       else if (mp[ C ] == 2)         cout <<  C ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long GCD(long long u, long long v) {     long long r;     while (v) {       r = u % v;       u = v;       v = r;     }     return u;   }   long long modpow(long long a, long long p, long long mod) {     long long ret = 1;     while (p) {       if (p & 1) ret = (ret * a) % mod;       a = (a * a) % mod;       p /= 2;     }     return ret;   }   long long power(long long a, long long p) {     long long ret = 1;     while (p) {       if (p & 1) ret = (ret * a);       a = (a * a);       p /= 2;     }     return ret;   }   int a[51];   int main() {     int i, j, tmp;     ios_base::sync_with_stdio(0);     cin.tie(NULL);     int n, k;     cin >> n >> k;     for (i = 0; i < n; i++) cin >> a[i];     sort(a, a + n);     if (k > n)       cout << -1 << endl;     else       cout << a[n - k] <<     << a[n - k] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     if (n < 4) {       cout <<  NO n ;       return 0;     }     cout <<  YES n ;     if (n >= 4 && !(n & 1)) {       int ones = 0;       for (int i = 5; i < n; i += 2) {         printf( %d - %d = 1 n , i + 1, i);         ones++;       }       cout <<  1 * 4 = 4 n ;       cout <<  4 * 2 = 8 n ;       cout <<  8 * 3 = 24 n ;       while (ones > 0) {         cout <<  24 * 1 = 24 n ;         ones--;       }       return 0;     }     if (n > 4 && n & 1) {       cout <<  5 - 1 = 4 n ;       cout <<  4 - 2 = 2 n ;       cout <<  4 * 2 = 8 n ;       cout <<  8 * 3 = 24 n ;       int ones = 0;       for (int i = 6; i < n; i += 2) {         printf( %d - %d = 1 n , i + 1, i);         ones++;       }       while (ones > 0) {         cout <<  24 * 1 = 24 n ;         ones--;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, ai, m, xi, yi;     cin >> n;     vector<int> wire(100);     for (int i = 1; i <= n; i++) {       cin >> wire[i];     }     cin >> m;     for (int i = 1; i <= m; i++) {       cin >> xi >> yi;       wire[xi - 1] += (yi - 1);       wire[xi + 1] += (wire[xi] - yi);       wire[xi] = 0;     }     for (int i = 1; i <= n; i++) {       cout << wire[i] << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MOD = 1e6 + 3;   const int INFI = 1e9 * 2;   const long long LINFI = 1e17;   const double pi = acos(-1.0);   const double s2 = sqrt(2.0);   const int N = 222;   const int M = 11;   const int move[8][2] = {1, 0, -1, 0, 0, 1, 0, -1, 1, 1, 1, -1, -1, 1, -1, -1};   int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }   int main() {     int a, b, c, d, p, q, m, x, y;     while (scanf( %d%d%d%d , &a, &b, &c, &d) != EOF) {       m = c * d / gcd(c, d);       a *= m;       b *= m;       x = a / c;       y = b / d;       if (x >= y) {         q = a;         p = a - y * c;       } else {         q = b;         p = b - x * d;       }       m = gcd(p, q);       q /= m;       p /= m;       printf( %d/%d n , p, q);     }     return 0;   }
#include <bits/stdc++.h>   int main() {     int t, n, *arr, i, a, odd, even;     scanf( %d , &t);     while (t--) {       scanf( %d , &n);       arr = (int*)malloc(n * sizeof(int));       for (i = 0; i < n; i++) scanf( %d , &arr[i]);       even = 0;       odd = 0;       for (i = 0; i < n; i++) {         if (arr[i] % 2 == 0)           even++;         else           odd++;       }       a = 0;       if (n % 2 == 0) {         if (even == odd) {           for (i = 0; i < n; i++) {             if ((i % 2) != (arr[i] % 2)) a++;           }           printf( %d n , a / 2);         } else           printf( %d n , -1);       } else {         if (odd == (even - 1)) {           for (i = 0; i < n; i++) {             if ((i % 2) != (arr[i] % 2)) a++;           }           printf( %d n , a / 2);         } else           printf( %d n , -1);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long dp[100][10];   string s;   int ss[100];   int main() {     cin >> s;     int n = ((int)(s).size());     for (int i = 0; i < n; i++) ss[i + 1] = s[i] -  0 ;     for (int i = 0; i < 10; i++) dp[1][i] = 1;     for (int i = 2; i <= n; i++)       for (int j = 0; j < 10; j++) {         long long cnt = 0;         if (j * 2 - 1 >= ss[i] && j * 2 - 1 - ss[i] < 10) {           int k = j * 2 - 1 - ss[i];           cnt += dp[i - 1][k];         }         if (j * 2 >= ss[i] && j * 2 - ss[i] < 10) {           int k = j * 2 - ss[i];           cnt += dp[i - 1][k];         }         if (j * 2 + 1 >= ss[i] && j * 2 + 1 - ss[i] < 10) {           int k = j * 2 + 1 - ss[i];           cnt += dp[i - 1][k];         }         dp[i][j] = cnt;       }     long long can = 1;     for (int i = 2; i <= n; i++) {       if (((ss[i - 1] + ss[i]) / 2 == ss[i] ||            (ss[i - 1] + ss[i]) / 2 - 1 == ss[i]) ||           ((ss[i - 1] + ss[i]) / 2 + 1 == ss[i] && (ss[i - 1] + ss[i]) % 2 == 1))         continue;       can = 0;       break;     }     long long ccnt = 0;     for (int i = 0; i < 10; i++) ccnt += dp[n][i];     cout << ccnt - can << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     int n, c = 0, temp;     int h[101], g[101];     cin >> n;     for (int i = 0; i < n; i++) {       cin >> h[i] >> g[i];     }     for (int j = 0; j < n; j++) {       temp = n - 1;       while (temp > j) {         if (h[j] == g[temp]) c++;         if (h[temp] == g[j]) c++;         temp--;       }     }     cout << c;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int t,n;   int a[100010];   int main(){    cin>>t;    while(t--){     cin>>n;     for(int i=0;i<n;++i)cin>>a[i];     sort(a,a+n);     long long ans=a[n-1],sum=0;     for(int i=0;i<n;++i){      sum+=a[i];      ans+=sum-1ll*a[i]*(i+1);     }     cout<<ans<<  n ;    }   }
#include <bits/stdc++.h>   long int temp, i, j, k, T;   long int ABS(int test) {     if (test < 0)       return test * -1;     else       return test;   }   int x8[] = {1, 1, 0, -1, -1, -1, 0, 1};   int y8[] = {0, 1, 1, 1, 0, -1, -1, -1};   int x4[] = {1, 0, -1, 0};   int y4[] = {0, 1, 0, -1};   long int arr[1000000];   long int buff[1000000];   long int memo[1000000];   using namespace std;   int main() {     char a[100001];     char b[100001];     int jawaban = 0, panjang, tujuh1 = 0, tujuh2 = 0, empat1 = 0, empat2 = 0;     memset(memo, 0, sizeof memo);     cin >> a;     cin >> b;     panjang = strlen(a);     for (i = 0; i < panjang; i++) {       if (a[i] ==  7 ) tujuh1++;       if (a[i] ==  4 ) empat1++;       if (b[i] ==  7 ) tujuh2++;       if (b[i] ==  4 ) empat2++;     }     for (i = 0; i < panjang; i++) {       if (a[i] == b[i]) {         if (a[i] ==  7 ) {           tujuh1--;           tujuh2--;         }         if (a[i] ==  4 ) {           empat1--;           empat2--;         }       }     }     jawaban = max(tujuh1, tujuh2);     cout << jawaban << endl;     {       fflush(stdin);       getchar();     };     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, a[2][300004];   long long sf[2][300004];   long long ca[2][300004];   int w33ha() {     memset(sf, 0, sizeof(sf));     memset(ca, 0, sizeof(ca));     for (int t = 0; t <= 1; t++)       for (int i = 1; i <= n; i++) scanf( %d , &a[t][i]);     for (int t = 0; t <= 1; t++) {       sf[t][0] = 0;       for (int i = 1; i <= n; i++) {         sf[t][i] = sf[t][i - 1] + a[t][i];       }     }     for (int t = 0; t <= 1; t++) {       ca[t][n + 1] = 0;       for (int i = n; i >= 1; i--) {         long long nob = ((n - i + 1LL) << 1) - 1;         ca[t][i] = ca[t][i + 1];         ca[t][i] += nob * a[1 - t][i];         ca[t][i] += sf[t][n] - sf[t][i] + sf[1 - t][n] - sf[1 - t][i];       }     }     long long ans = 0, now = 0;     for (int i = 1; i <= n; i++) {       long long delta =           ((i - 1LL) << 1) * (sf[0][n] - sf[0][i - 1] + sf[1][n] - sf[1][i - 1]);       if (i & 1) {         ans = max(ans, now + delta + ca[0][i]);         now += 1LL * ((i - 1LL) << 1) * a[0][i] +                1LL * ((i - 1LL) << 1 | 1) * a[1][i];       } else {         ans = max(ans, now + delta + ca[1][i]);         now += 1LL * ((i - 1LL) << 1) * a[1][i] +                1LL * ((i - 1LL) << 1 | 1) * a[0][i];       }     }     printf( %lld n , ans);     return 0;   }   int main() {     while (scanf( %d , &n) != EOF) w33ha();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     queue<unsigned long long> q;     vector<unsigned long long> v;     unsigned long long temp;     q.push(0);     while (!q.empty()) {       temp = q.front();       v.push_back(temp * 10 + 4);       v.push_back(temp * 10 + 7);       if (temp * 10 + 7 >= 4444444444) break;       q.pop();       q.push(temp * 10 + 4);       q.push(temp * 10 + 7);     }     unsigned long long left, right, sum = 0;     cin >> left >> right;     int i = 0;     for (i = 0; i < v.size(); i++)       if (v[i] >= left) break;     while (left <= right) {       sum = sum + v[i] * (min(v[i], right) - left + 1);       left = v[i] + 1;       i++;     }     cout << sum;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, b;   struct chel {     int cost;     int mas;     int coun;   };   chel f[103];   chel tem[103];   void mergesort(chel *a, chel *b, int n) {     int i, i0, i1, iRight, iEnd, width, j;     for (width = 1; width < n; width *= 2)       for (i = 0; i < n; i += width * 2) {         i0 = i;         i1 = iRight = min(i + width, n);         iEnd = min(i + width * 2, n);         for (j = i; j < iEnd; j++)           if (i0 < iRight && (i1 == iEnd || a[i0].coun < a[i1].coun))             b[j] = a[i0++];           else             b[j] = a[i1++];         for (j = i; j < iEnd; j++) a[j] = b[j];       }   }   long long dp[(1 << 20)];   int main() {     int i, j;     scanf( %d %d %d , &n, &m, &b);     dp[0] = 0;     for (i = 1; i < (1 << m); i++) dp[i] = (long long)1000000000 * 1000000000 * 2;     long long ans = (long long)1000000000 * 1000000000 * 2;     int x, t;     for (i = 0; i < n; i++) {       scanf( %d %d %d , &f[i].cost, &f[i].coun, &t);       for (j = 0; j < t; j++) {         scanf( %d , &x);         f[i].mas |= (1 << (x - 1));       }     }     mergesort(f, tem, n);     for (i = 0; i < n; i++) {       for (j = 0; j < (1 << m); j++)         dp[(j | f[i].mas)] = min(dp[(j | f[i].mas)], dp[j] + f[i].cost);       ans = min(ans, dp[(1 << m) - 1] + (long long)b * f[i].coun);     }     if (ans == (long long)1000000000 * 1000000000 * 2)       printf( -1 n );     else       printf( %I64d n , ans);     return 0;   }