Language: C++

#include <bits/stdc++.h>

using namespace std;

#define int long long
// #define double long double
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define bitcnt(x) __builtin_popcount(x)
#define lbit(x) __builtin_ffsll(x)
#define rbit(x) __builtin_clzll(x)
#define SZ(x) ((ll)(x).size())
#define fi first
#define se second
#define All(a) (a).begin(), (a).end()
#define rAll(a) (a).rbegin(), (a).rend()

template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CCIN(...)                                                              \
    char __VA_ARGS__;                                                          \
    CIN(__VA_ARGS__)
#define DCIN(...)                                                              \
    double __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"
#define Printv(v)                                                              \
    {                                                                          \
        FOREACH(x, v) { cout << x << " "; }                                    \
        cout << "\n";                                                          \
    }
template <typename T = string> inline void eputs(T s) {
    cout << s << "\n";
    exit(0);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *)array, (T *)(array + N), val);
}

template <typename T> using PQG = priority_queue<T, vector<T>, greater<T>>;
template <typename T> using PQ = priority_queue<T>;

typedef long long ll;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<ll, ll> PL;
typedef vector<PL> VPL;
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 1e18;
// const double PI = atan(1.0) * 4.0;
const ll dx[] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[] = {0, 1, 1, 1, 0, -1, -1, -1};
#define PI 3.141592653589793238

ll dp[1LL << 12], a[1001], b[1001];
bool ok[1001][13];
 
signed main() {
    LCIN(N, M);
    ll now = 0, next = 1;
    REP(i, M) {
        cin >> a[i] >> b[i];
        REP(j, b[i]) {
            LCIN(c);
            ok[i][c - 1] = true;
        }
    }
    Fill(dp, LINF);
    dp[0] = 0;
    REP(i, M) {
        REP(s, 1LL << N) {
            //ns: 次の状態
            ll ns = s;
            REP(j, N) {
                //ok[i][j]: 鍵iで宝箱jが開く場合 1 、そうでない場合 0
                //開く宝箱に対応するbitをたてている
                if(ok[i][j]) ns |= (1LL << j);
            }
            //状態のマージ（遷移）
            dp[ns] = min(dp[ns], dp[s] + a[i]);
        }
    }
    cout << (dp[(1LL << N) - 1] == LINF ? -1 : dp[(1LL << N) - 1]) << "\n";
}
#include <bits/stdc++.h>

using namespace std;

#define int long long
// #define double long double
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define bitcnt(x) __builtin_popcount(x)
#define lbit(x) __builtin_ffsll(x)
#define rbit(x) __builtin_clzll(x)
#define SZ(x) ((ll)(x).size())
#define fi first
#define se second
#define All(a) (a).begin(), (a).end()
#define rAll(a) (a).rbegin(), (a).rend()

template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CCIN(...)                                                              \
    char __VA_ARGS__;                                                          \
    CIN(__VA_ARGS__)
#define DCIN(...)                                                              \
    double __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"
#define Printv(v)                                                              \
    {                                                                          \
        FOREACH(x, v) { cout << x << " "; }                                    \
        cout << "\n";                                                          \
    }
template <typename T = string> inline void eputs(T s) {
    cout << s << "\n";
    exit(0);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *)array, (T *)(array + N), val);
}

template <typename T> using PQG = priority_queue<T, vector<T>, greater<T>>;
template <typename T> using PQ = priority_queue<T>;

typedef long long ll;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<ll, ll> PL;
typedef vector<PL> VPL;
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 1e18;
// const double PI = atan(1.0) * 4.0;
const ll dx[] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[] = {0, 1, 1, 1, 0, -1, -1, -1};
#define PI 3.141592653589793238

ll dp[1LL << 12], a[1001], b[1001];
bool ok[1001][13];
 
signed main() {
    LCIN(N, M);
    ll now = 0, next = 1;
    REP(i, M) {
        cin >> a[i] >> b[i];
        REP(j, b[i]) {
            LCIN(c);
            ok[i][c - 1] = true;
        }
    }
    Fill(dp, LINF);
    dp[0] = 0;
    REP(i, M) {
        REP(s, 1LL << N) {
            //ns: 次の状態
            ll ns = s;
            REP(j, N) {
                //ok[i][j]: 鍵iで宝箱jが開く場合 1 、そうでない場合 0
                //開く宝箱に対応するbitをたてている
                if(ok[i][j]) ns |= (1LL << j);
            }
            //状態のマージ（遷移）
            dp[ns] = min(dp[ns], dp[s] + a[i]);
        }
    }
    cout << (dp[(1LL << N) - 1] == LINF ? -1 : dp[(1LL << N) - 1]) << "\n";
}


Compiler output:
a.cc:135:44: error: redefinition of 'template<class T> T IN()'
  135 | template <typename T = long long> inline T IN() {
      |                                            ^~
a.cc:23:44: note: 'template<class T> T IN()' previously declared here
   23 | template <typename T = long long> inline T IN() {
      |                                            ^~
a.cc:140:13: error: redefinition of 'void CIN()'
  140 | inline void CIN() {}
      |             ^~~
a.cc:28:13: note: 'void CIN()' previously defined here
   28 | inline void CIN() {}
      |             ^~~
a.cc:142:13: error: redefinition of 'template<class Head, class ... Tail> void CIN(Head&&, Tail&& ...)'
  142 | inline void CIN(Head &&head, Tail &&... tail) {
      |             ^~~
a.cc:30:13: note: 'template<class Head, class ... Tail> void CIN(Head&&, Tail&& ...)' previously declared here
   30 | inline void CIN(Head &&head, Tail &&... tail) {
      |             ^~~
a.cc:165:44: error: redefinition of 'template<class T> void eputs(T)'
  165 | template <typename T = string> inline void eputs(T s) {
      |                                            ^~~~~
a.cc:53:44: note: 'template<class T> void eputs(T)' previously declared here
   53 | template <typename T = string> inline void eputs(T s) {
      |                                            ^~~~~
a.cc:170:6: error: redefinition of 'template<class A, long unsigned int N, class T> void Fill(A (&)[N], const T&)'
  170 | void Fill(A (&array)[N], const T &val) {
      |      ^~~~
a.cc:58:6: note: 'template<class A, long unsigned int N, class T> void Fill(A (&)[N], const T&)' previously declared here
   58 | void Fill(A (&array)[N], const T &val) {
      |      ^~~~
a.cc:186:11: error: redefinition of 'const long long int INF'
  186 | const int INF = 1e9;
      |           ^~~
a.cc:74:11: note: 'const long long int INF' previously defined here
   74 | const int INF = 1e9;
      |           ^~~
a.cc:187:11: error: redefinition of 'const long long int MOD'
  187 | const int MOD = 1e9 + 7;
      |           ^~~
a.cc:75:11: note: 'const long long int MOD' previously defined here
   75 | const int MOD = 1e9 + 7;
      |           ^~~
a.cc:189:10: error: redefinition of 'const ll LINF'
  189 | const ll LINF = 1e18;
      |          ^~~~
a.cc:77:10: note: 'const ll LINF' previously defined here
   77 | const ll LINF = 1e18;
      |          ^~~~
a.cc:191:10: error: redefinition of 'const ll dx []'
  191 | const ll dx[] = {1, 1, 0, -1, -1, -1, 0, 1};
      |          ^~
a.cc:79:10: note: 'const ll dx [8]' previously defined here
   79 | const ll dx[] = {1, 1, 0, -1, -1, -1, 0, 1};
      |          ^~
a.cc:192:10: error: redefinition of 'const ll dy []'
  192 | const ll dy[] = {0, 1, 1, 1, 0, -1, -1, -1};
      |          ^~
a.cc:80:10: note: 'const ll dy [8]' previously defined here
   80 | const ll dy[] = {0, 1, 1, 1, 0, -1, -1, -1};
      |          ^~
a.cc:195:4: error: redefinition of 'll dp [4096]'
  195 | ll dp[1LL << 12], a[1001], b[1001];
      |    ^~
a.cc:83:4: note: 'll dp [4096]' previously declared here
   83 | ll dp[1LL << 12], a[1001], b[1001];
      |    ^~
a.cc:195:19: error: redefinition of 'll a [1001]'
  195 | ll dp[1LL << 12], a[1001], b[1001];
      |                   ^
a.cc:83:19: note: 'll a [1001]' previously declared here
   83 | ll dp[1LL << 12], a[1001], b[1001];
      |                   ^
a.cc:195:28: error: redefinition of 'll b [1001]'
  195 | ll dp[1LL << 12], a[1001], b[1001];
      |                            ^
a.cc:83:28: note: 'll b [1001]' previously declared here
   83 | ll dp[1LL << 12], a[1001], b[1001];
      |                            ^
a.cc:196:6: error: redefinition of 'bool ok [1001][13]'
  196 | bool ok[1001][13];
      |      ^~
a.cc:84:6: note: 'bool ok [1001][13]' previously declared here
   84 | bool ok[1001][13];
      |      ^~
a.cc:198:8: error: redefinition of 'int main()'
  198 | signed main() {
      |        ^~~~
a.cc:86:8: note: 'int main()' previously defined here
   86 | signed main() {
      |        ^~~~