malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int mod1 = 1e9 + 7;   const int mod2 = 998244353;   const long long int inf = 1e18;   const double pi = 3.1415926535897932384626;   long long int mpow(long long int a, long long int b, long long int m) {     long long int res = 1;     while (b) {       if (b % 2) res = res * a % m;       a = a * a % m;       b /= 2;     }     return res;   }   long long int inv(long long int a, long long int m) {     return mpow(a, m - 2, m);   }   long long int gcd(long long int a, long long int b) {     if (b == 0) return a;     return gcd(b, a % b);   }   long long int ncr(long long int n, long long int k) {     if (n < k) return 0;     long long int C[n + 1][k + 1];     long long int i, j;     for (i = 0; i <= n; i++) {       for (j = 0; j <= min(i, k); j++) {         if (j == 0 || j == i)           C[i][j] = 1;         else           C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]);       }     }     return C[n][k];   }   void solve() {     long long int n, m;     cin >> n >> m;     long long int a[n], b[m];     vector<long long int> x;     for (long long int i = 0; i < n; i++) {       cin >> a[i];     }     sort(a, a + n);     for (int i = 0; i < m; i++) {       cin >> b[i];       x.push_back(upper_bound(a, a + n, b[i]) - a);     }     for (auto i : x) cout << i <<    ;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     clock_t start, end;     start = clock();     solve();     end = clock();     double time_taken = double(end - start) / double(CLOCKS_PER_SEC);     cerr <<   nExecution time :   << fixed << time_taken << setprecision(5)          <<   s  n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1005;   int b[maxn];   int c[maxn];   bool visit[maxn];   int n, k;   int main() {     int i, p;     while (scanf( %d%d , &n, &k) != EOF) {       for (i = 1; i <= n; i++) scanf( %d , &b[i]);       memset(c, 0, sizeof(c));       memset(visit, false, sizeof(visit));       for (p = 1; p <= n; p++) {         for (i = 1; i <= n; i++)           if (c[i] == b[i] && visit[i] == false) break;         printf( %d  , i);         int u = i;         visit[u] = true;         for (i = 1; i <= n; i++)           if (u >= i + k)             c[i]++;           else             break;       }       printf(  n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   const ll mod = 1e9 + 7;   int main() {     ios_base::sync_with_stdio(false);     int n, m;     cin >> n;     char prev =  a ;     int dur = 0;     vector<int> durs;     for (int i = 0; i < n; ++i) {       char c;       cin >> c;       if (c ==  W ) {         if (dur != 0) durs.push_back(dur);         dur = 0;       } else {         ++dur;       }     }     if (dur != 0) durs.push_back(dur);     cout << durs.size() <<   n ;     for (int i = 0; i < durs.size(); ++i) {       cout << durs[i] <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long INF = 1e10;   const double pi = 3.14159265359;   const long long mod = 1743;   const long long MAXN = 2 * 1e5 + 6;   const long long MAXM = 2 * 1e5 + 6;   const long long zero = 0;   double v1, v2, e1, e2, h, d, r, area;   int main() {     ios::sync_with_stdio(false);     cin >> d >> h >> v1 >> e1;     r = d * 0.5;     area = r * r * pi;     v2 = area * e1;     cout.precision(10);     if (v2 >= v1)       cout <<  NO ;     else       cout <<  YES  << endl << (area * h) / (v1 - v2);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 3e3 + 10;   vector<pair<int, int> > v[N];   int ps[N], mx[N], cnt, wr;   void dfs(int u, int par) {     for (auto y : v[u]) {       if (y.first == par) continue;       ps[y.first] = ps[u];       if (y.second == 1)         ps[y.first]++;       else {         wr++;         ps[y.first]--;       }       mx[y.first] = max(mx[u], ps[y.first]);       cnt = min(cnt, ps[y.first] - mx[y.first]);       dfs(y.first, u);     }   }   int main() {     int n;     cin >> n;     for (int i = 0; i < n - 1; i++) {       int a, b;       cin >> a >> b;       a--;       b--;       v[a].push_back(make_pair(b, 1));       v[b].push_back(make_pair(a, 2));     }     int ans = n - 1;     for (int i = 0; i < n; i++) {       fill(mx, mx + N, 0);       fill(ps, ps + N, 0);       cnt = 0;       wr = 0;       dfs(i, -1);       ans = min(ans, wr + cnt);     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int modl = 1e9 + 7;   string pattern;   int n;   vector<vector<int>> nums;   void init();   int main() {     cin >> n;     cin >> pattern;     init();     vector<vector<int>> dp(n + 1, vector<int>(1 << 20, 0));     for (int i = 0; i <= n; i++) {       dp[i][0] = 1;       for (int j = 0; j < (1 << 20); j++) {         if (dp[i][j]) {           for (int k = i; k < n; k++) {             if (nums[i][k])               dp[k + 1][j | (1 << (nums[i][k] - 1))] =                   (dp[k + 1][j | (1 << (nums[i][k] - 1))] + dp[i][j]) % modl;           }         }       }     }     int res = 0;     for (int i = 0; i <= n; i++) {       for (int j = 2; j <= (1 << 20); j <<= 1) {         res = (res + dp[i][j - 1]) % modl;       }     }     cout << res << endl;     return 0;   }   void init() {     nums = vector<vector<int>>(n, vector<int>(n, 0));     for (int i = 0; i < n; i++) {       for (int j = i, k = 0; j < n; j++) {         k = ((k << 1) + pattern[j] -  0 );         if (k > 20) break;         nums[i][j] = k;       }     }   }
#include <bits/stdc++.h>   using namespace std;   const int MOD = 1e9 + 7;   const int INF = 1e9;   const long long LNF = 1e18;   void setIO(string s) {     ios_base::sync_with_stdio(0);     cin.tie(0);   }   const int N = 1e5 + 7;   vector<int> adj[N], ans;   bool vis[N][2], cvis[N];   bool dfs(int u, int p) {     if (vis[u][p]) return false;     vis[u][p] = true;     if (adj[u].empty() && p) {       ans.emplace_back(u);       return true;     }     for (auto& v : adj[u]) {       if (dfs(v, p ^ 1)) {         ans.emplace_back(u);         return true;       }     }     return false;   }   bool cycle(int u) {     if (cvis[u]) return true;     cvis[u] = true;     for (auto& i : adj[u]) {       if (cycle(i)) return true;       cvis[i] = false;     }     return false;   }   int main() {     setIO( input );     int n, m;     cin >> n >> m;     for (int i = 0; i < n; ++i) {       int c;       cin >> c;       for (int j = 0; j < c; ++j) {         int v;         cin >> v;         adj[i].emplace_back(--v);       }     }     int s;     cin >> s;     --s;     if (dfs(s, 0)) {       cout <<  Win n ;       for (int i = (int)ans.size() - 1; i >= 0; --i) cout << ans[i] + 1 <<    ;     } else {       if (cycle(s))         cout <<  Draw ;       else         cout <<  Lose ;     }   }
#include <bits/stdc++.h>   using namespace std;   char s[200010];   int T, N;   int Solve() {     N = strlen(s + 1);     int Ans = 0, Len = 1;     while ((1 << (Len)) <= N) ++Len;     for (register int i = 1; i <= N; ++i) {       if (s[i] ==  0 ) continue;       int p = i, num = 0;       while (p > 1 && s[p - 1] ==  0 ) --p;       for (register int j = i; j <= min(i + Len - 1, N); ++j) {         num = (num << 1) + s[j] -  0 ;         if (num > N) break;         int L = j - i + 1, R = j - p + 1;         if (L <= num && num <= R) ++Ans;       }     }     return Ans;   }   int main() {     scanf( %d , &T);     while (T--) {       scanf( %s , s + 1);       printf( %d n , Solve());     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 5555;   int t[N], l[N], r[N], x[N], a[N], dif[N];   int main() {     int n, m;     scanf( %d %d , &n, &m);     for (int i = 0; i < m; ++i) {       scanf( %d %d %d %d , t + i, l + i, r + i, x + i);       --l[i], --r[i];     }     for (int i = 0; i < n; ++i) a[i] = 1000000000;     for (int i = 0; i < m; ++i) {       if (t[i] == 1) {         for (int j = l[i]; j <= r[i]; ++j) {           dif[j] += x[i];         }       } else {         for (int j = l[i]; j <= r[i]; ++j) {           a[j] = min(a[j], x[i] - dif[j]);         }       }     }     for (int i = 0; i < m; ++i) {       if (t[i] == 1) {         for (int j = l[i]; j <= r[i]; ++j) {           a[j] += x[i];         }       } else {         int mx = -2e9;         for (int j = l[i]; j <= r[i]; ++j) {           mx = max(mx, a[j]);         }         if (mx != x[i]) {           puts( NO );           return 0;         }       }     }     puts( YES );     for (int i = 0; i < n; ++i) {       printf( %d  , a[i] - dif[i]);     }   }
#include <bits/stdc++.h>   using namespace std;   inline long long rin() {     long long s = 0;     bool bj = false;     char c = getchar();     for (; (c >  9  || c <  0 ) && c !=  - ; c = getchar())       ;     if (c ==  - ) bj = true, c = getchar();     for (; c >=  0  && c <=  9 ; c = getchar())       s = (s << 1) + (s << 3) + (c ^  0 );     if (bj) return -s;     return s;   }   inline void pri(long long ans, long long x, long long y, int n, int m, int xt,                   int yt) {     xt = (xt == -1);     yt = (yt == -1);     xt ^= (((x - 1) / n) & 1);     yt ^= (((y - 1) / m) & 1);     printf( %d %d n , xt ? 0 : n, yt ? 0 : m);     return;   }   inline int Gcd(int a, int b) { return (!b) ? (a) : (Gcd(b, a % b)); }   inline void Ex_Gcd(int a, int b, long long &x, long long &y) {     (!b) ? (x = y = 1) : (Ex_Gcd(b, a % b, y, x), y -= x * (a / b));     return;   }   int n, m, x, y, xt, yt;   inline int work() {     if (!xt && !yt) {       puts( -1 );       return 0;     }     if (!xt) {       if (x == 0 || x == n)         printf( %d %d n , x, (yt == -1) ? 0 : m);       else         puts( -1 );     } else {       if (y == 0 || y == m)         printf( %d %d n , (xt == -1) ? (0) : n, y);       else         puts( -1 );     }     return 0;   }   int main() {     n = rin();     m = rin();     x = rin();     y = rin();     xt = rin();     yt = rin();     if (xt == 0 || yt == 0) return work();     if (xt == -1) x = n - x;     if (yt == -1) y = m - y;     long long ans = n - x;     int z = Gcd(n, m);     if ((-y - ans) % z) {       puts( -1 );       return 0;     }     long long X, Y;     Ex_Gcd(n / z, m / z, X, Y);     X *= ((-ans - y) / z);     X %= m;     long long M = 1LL * n / z * m;     ans += X * n;     ans = (ans % M + M) % M;     pri(ans, ans + x, ans + y, n, m, xt, yt);     return 0;   }
/*   --------------------       |       LOSER        |       |     ~NOOBOSS~      |        --------------------   */   #include <bits/stdc++.h>   using namespace std;   #define      mxx                 1e18   #define      mnn                 -1e18   #define      Y()                 cout<<  YES  <<endl   #define      N()                 cout <<  NO <<endl   #define      endl                  n    #define      Ceil(x,y)           ((x+y-1)/y)   #define      sz(s)               (int)s.size()   #define      angle(x)            double(x * acos(-1) / 180.0)   #define      max_3(a,b,c)        max(a, max(b,c))   #define      min_3(a,b,c)        min(a, min(b,c))   #define      gcd(a,b)            __gcd(a,b)   #define      lcm(a,b)           (a*b)/gcd(a,b)   #define      loser               return 0   #define      ll                  long long   #define      PI                  acos(-1)   #define      mem(a,v)            memset(a,v,sizeof(a))   #define      SORT(v)             sort(v.begin(),v.end())   #define      REV(v)              reverse(v.begin(),v.end())   #define      B                   begin()   #define      E                   end()   #define      V                   vector   #define      F                   first   #define      S                   second   #define      PSB                 push_back   #define      MP                  make_pair   #define      flash               cout.flush()   #define      InTheNameOfGod      ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);   constexpr ll MOD = 998244353;   constexpr ll mod = 1e9  + 7;   int dx[] = {0,0,1,-1};   int dy[] = {1,-1,0,0};   /*-----*/   #define bug1(a)  cerr<<a<<endl;   #define bug2(a,b)  cerr<<a<<   <<b<<endl;   #define bug3(a,b,c)  cerr<<a<<   <<b<<   <<c<<endl;   /*----*/   const ll N=3e6+5;   vector<ll> adj[N];   ll power(ll n,ll p){if(p==0) return 1;if(p==1)return n;if(p%2)return power(n,p-1)*n;else{ll x=power(n,p/2);return x*x;}}   ll modpow(ll a,ll b,ll m){ll ans=1;while(b){if(b&1)ans=(ans*a)%m;b/=2;a=(a*a)%m;}return ans;}   ll nsum(ll num){return (num*(num+1))/2;}   void edge (ll u,ll v) {adj[u].PSB(v) ;adj[v].PSB(u);}   /*------------------START---------------------*/      /*-----*/   void solve(){      ll n,k;      string s;      cin>>n>>k;      if(n<3){        if(k) cout<<-1<<endl;        else{           for(ll i=1;i<=n;i++) cout<<i<<   ;           cout<<endl;        }        return;      }         ll mx=1; ll bal=n-3;      mx+=bal/2;      if(k>mx){       cout<<-1<<endl;      }      else{         cout<<1<<   ;         ll ct=2;         for(ll i=2;i<=n;i++){           if(k){               cout<<i+1<<   <<i<<   ;               --k; i++;           }           else{               cout<<i<<   ;           }         }         cout<<endl;      }         //cout << fixed << setprecision(10);   }   /*-----*/   int main(){      InTheNameOfGod         ll Test=1;      cin>>Test;      while(Test--){        solve();       }     loser;   }   ///////   C O D I N G  I S  L I F E   ///////
#include <bits/stdc++.h>   using namespace std;   vector<vector<int> > v(14 + 1);   int go[1001][14], fail[1001], weight[1001], nxt, maxLength;   pair<int, long long> a[1001];   long long dp[1001][(1 << 14)];   const long long negativeInfinity = LLONG_MIN / 2;   void AddStringToAhoCorasick(string s, int val) {     int i = 0;     for (auto c : s) {       int k = c -  a ;       if (go[i][k] == 0) {         go[i][k] = ++nxt;       }       i = go[i][k];     }     maxLength = max(maxLength, (int)s.size());     weight[i] += val;   }   void BuildAhoCorasick() {     queue<int> Q;     for (int x = 0; x < 14; ++x) {       if (go[0][x]) {         Q.push(go[0][x]);       }     }     while (!Q.empty()) {       const int i = Q.front();       Q.pop();       weight[i] += weight[fail[i]];       for (int x = 0; x < 14; ++x) {         const int j = go[i][x];         if (j) {           fail[j] = go[fail[i]][x];           Q.push(j);         } else {           go[i][x] = go[fail[i]][x];         }       }     }   }   void ResetTransitions() {     for (int i = 0; i <= nxt; ++i) {       a[i].first = -1;     }   }   inline pair<int, long long> GetTransitionedNode(int i, const string &s) {     int j = i;     long long val = 0;     for (auto c : s) {       j = go[j][c -  a ];       val += weight[j];     }     a[i] = make_pair(j, val);     return a[i];   }   void ApplyStringTransitions(const string &s, const int n, const int qCount) {     for (int i = 0; i <= n; ++i) {       int j;       long long val;       tie(j, val) = GetTransitionedNode(i, s);       for (int mask : v[qCount]) {         if (dp[i][mask] < negativeInfinity) {           continue;         }         val += dp[i][mask];         for (int x = 0; x < 14; ++x) {           if ((mask & (1 << x)) > 0) {             continue;           }           const int k = go[j][x], nmask = mask | (1 << x);           dp[k][nmask] = max(dp[k][nmask], val + weight[k]);         }         val -= dp[i][mask];       }     }   }   int Initialise() {     int n;     cin >> n;     while (n--) {       string s;       int val;       cin >> s >> val;       AddStringToAhoCorasick(s, val);     }     BuildAhoCorasick();     for (int mask = 0; mask < (1 << 14); ++mask) {       v[__builtin_popcount(mask)].push_back(mask);     }     return nxt;   }   int main() {     int n = Initialise();     string t;     cin >> t;     int cur = 0;     for (int i = 0; i <= n; ++i) {       for (int mask = 0; mask < (1 << 14); ++mask) {         dp[i][mask] = LLONG_MIN;       }     }     dp[0][0] = 0;     string s;     int qCount = 0;     for (auto c : t) {       if (c !=  ? ) {         s.push_back(c);         continue;       }       ApplyStringTransitions(s, n, qCount);       s.clear();       ++qCount;     }     long long ans = LLONG_MIN;     for (int i = 0; i <= n; ++i) {       int j;       long long val;       tie(j, val) = GetTransitionedNode(i, s);       for (int mask : v[qCount]) {         if (dp[i][mask] < negativeInfinity) {           continue;         }         ans = max(ans, val + dp[i][mask]);       }     }     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int dp[100010][3];   vector<int> v;   int n;   int solve(int i, int op, int last) {     if (i == n) {       return 0;     }     if (dp[i][op] != -1) {       return dp[i][op];     }     int ans = 0x3f3f3f3f;     int aux = op;     if (aux == 2) {       aux = -1;     }     int aux2 = last;     if (aux2 == 2) {       aux2 = -1;     }     if ((v[i] - v[i - 1] + 1 - aux) == (v[i - 1] + aux - v[i - 2] - aux2)) {       ans = min(ans, 1 + solve(i + 1, 1, op));     }     if ((v[i] - v[i - 1] - aux) == (v[i - 1] + aux - v[i - 2] - aux2)) {       ans = min(ans, solve(i + 1, 0, op));     }     if ((v[i] - v[i - 1] - 1 - aux) == (v[i - 1] + aux - v[i - 2] - aux2)) {       ans = min(ans, 1 + solve(i + 1, 2, op));     }     return dp[i][op] = ans;   }   int main() {     cin.tie(0);     ios_base::sync_with_stdio(0);     cin >> n;     v.resize(n, 0);     for (int i = 0; i < (n); i++) {       cin >> v[i];     }     memset(dp, -1, sizeof dp);     int ans = 0x3f3f3f3f;     for (int i = 0; i < (3); i++) {       for (int j = 0; j < (3); j++) {         memset(dp, -1, sizeof dp);         int aux = (i > 0) + (j > 0);         ans = min(ans, aux + solve(2, i, j));       }     }     if (n <= 2) {       cout << 0 <<   n ;       return 0;     }     if (ans > n + 1) {       cout << -1 <<   n ;     } else {       cout << ans <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string s, p;     cin >> s;     int sz = s.size();     for (char ch =  a ; ch <=  z ; ch++) {       for (int i = 0; i <= s.size(); i++) {         p = s.substr(0, i) + ch + s.substr(i, sz);         if (p == string(p.rbegin(), p.rend())) {           cout << p <<   n ;           return 0;         }       }     }     cout <<  NA n ;   }
#include <bits/stdc++.h>   using namespace std;   const int NM_MAX = 82;   const int U_MAX = 6404;   int U;   vector<int> edges[U_MAX];   short int C[U_MAX][U_MAX];   short int R[U_MAX][U_MAX];   short int F[U_MAX][U_MAX];   int dist[U_MAX];   int parent[U_MAX];   queue<int> q;   bool BellmanFord() {     for (int i = 1; i <= U; i++) {       dist[i] = INT_MAX;       parent[i] = -1;     }     parent[1] = 0;     dist[1] = 0;     q.push(1);     while (q.empty() == false) {       int u = q.front();       q.pop();       for (int v : edges[u])         if (R[u][v] > 0 && dist[u] + C[u][v] < dist[v]) {           dist[v] = dist[u] + C[u][v];           parent[v] = u;           q.push(v);         }     }     return (parent[U] != -1);   }   void pushFlow(int u, int v, int flow) {     R[u][v] -= flow;     R[v][u] += flow;     F[u][v] += flow;     F[v][u] -= flow;   }   int minCostMaxFlow() {     while (BellmanFord() == true) {       int u;       u = U;       int flow = INT_MAX;       while (u != 1) {         flow = min(flow, (int)R[parent[u]][u]);         u = parent[u];       }       u = U;       while (u != 1) {         pushFlow(parent[u], u, flow);         u = parent[u];       }     }     int ans = 0;     for (int i = 1; i <= U; i++)       for (int j = 1; j <= U; j++) ans += C[i][j] * F[i][j];     return ans;   }   int n, m;   int ma[NM_MAX][NM_MAX];   int da[] = {-1, 0, 1, 0}, db[] = {0, 1, 0, -1};   bool inside(int a, int b) { return (1 <= a && a <= n && 1 <= b && b <= m); }   int codif(int a, int b) { return (a - 1) * m + b + 1; }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cin >> n >> m;     for (int i = 1; i <= n; i++)       for (int j = 1; j <= m; j++) cin >> ma[i][j];     U = 1 + n * m + 1;     for (int i = 1; i <= n; i++)       for (int j = 1; j <= m; j++)         for (int d = 0; d < 4; d++) {           int i1 = i + da[d], j1 = j + db[d];           if (inside(i1, j1)) {             int u = codif(i, j), v = codif(i1, j1);             if ((i + j) & 1) swap(u, v);             edges[u].push_back(v);             edges[v].push_back(u);             C[u][v] = (ma[i][j] != ma[i1][j1]);             R[u][v] = 1;             F[u][v] = 0;             C[v][u] = -(ma[i][j] != ma[i1][j1]);             R[v][u] = 0;             F[v][u] = 0;           }         }     for (int i = 1; i <= n; i++)       for (int j = 1; j <= m; j++)         if ((i + j) & 1) {           int u = codif(i, j);           edges[u].push_back(U);           edges[U].push_back(u);           C[u][U] = 0;           R[u][U] = 1;           F[u][U] = 0;           C[U][u] = 0;           R[U][u] = 0;           F[U][u] = 0;         } else {           int u = codif(i, j);           edges[1].push_back(u);           edges[u].push_back(1);           C[1][u] = 0;           R[1][u] = 1;           F[1][u] = 0;           C[u][1] = 0;           R[u][1] = 0;           F[u][1] = 0;         }     cout << minCostMaxFlow() / 2 <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       int n;       cin >> n;       vector<int> a(2 * n);       for (auto &it : a) cin >> it;       vector<int> kop(n);       vector<int> ARR;       for (int i = 0; i < 2 * n; ++i) {         if (!kop[a[i] - 1]) {           kop[a[i] - 1] = true;           ARR.push_back(a[i]);         }       }       for (auto it : ARR) cout << it <<    ;       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e6 + 10;   long long gcd(long long p, long long q) { return q == 0 ? p : gcd(q, p % q); }   int to[4][2] = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};   long long n, ans;   long long qp(long long a, long long b) {     long long s = 1;     while (b) {       if (b & 1) s = s * a % 998244353;       a = a * a % 998244353;       b >>= 1;     }     return s;   }   int main() {     ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);     cin >> n;     ans = (qp(3, n * n) - qp(qp(3, n) - 3, n) + 998244353) % 998244353;     long long xs = -1, c1 = 1;     for (int i = 1; i <= n; i++) {       xs *= -1;       c1 = c1 * (n - i + 1) % 998244353;       c1 = c1 * qp(i, 998244353 - 2) % 998244353;       ans += xs *              (3 * c1 % 998244353 * qp(qp(3, n - i) - 1, n) % 998244353 +               c1 * (qp(3, i) - 3) % 998244353 * qp(3, (n - i) * n) % 998244353) %              998244353;     }     ans = (ans % 998244353 + 998244353) % 998244353;     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long inf = (1LL << 60);   long long dp[1 << 22];   struct node {     int x, k, p;   } f[110];   int cmp(node x, node y) { return x.k < y.k; }   long long ans;   int main() {     int n, m, b;     scanf( %d%d%d , &n, &m, &b);     int l = 1 << m;     for (int i = 1; i <= l; i++) {       dp[i] = inf;     }     int cnt;     for (int i = 1; i <= n; i++) {       f[i].p = 0;       int x;       scanf( %d%d%d , &f[i].x, &f[i].k, &cnt);       for (int j = 0; j < cnt; j++) {         scanf( %d , &x);         f[i].p |= (1 << (x - 1));       }     }     ans = inf;     sort(f + 1, f + n + 1, cmp);     for (int i = 1; i <= n; i++) {       for (int j = 0; j < l; ++j) {         dp[j | f[i].p] = min(dp[j] + f[i].x, dp[j | f[i].p]);       }       ans = min(ans, dp[l - 1] + (long long)f[i].k * b);     }     if (ans >= inf) {       printf( -1 n );     } else {       printf( %lld , ans);     }     return 0;   }