malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using LL = long long;   const int N = 100000 + 5;   LL D[N], H[N];   int n, m;   struct Unit {     int l, r;     LL Lmax, Rmax, Mmax, sum;     void show() {       printf( l = %d,r = %d n , l, r);       printf( Lmax = %I64d,Rmax = %I64d,Mmax = %I64d,sum = %I64d n , Lmax, Rmax,              Mmax, sum);     }     Unit operator+(const Unit &rhs) const {       Unit ret;       ret.l = l;       ret.r = rhs.r;       ret.Lmax = std::max(Lmax + D[r] + rhs.sum, rhs.Lmax);       ret.Rmax = std::max(Rmax, sum + D[r] + rhs.Rmax);       ret.Mmax = std::max(Mmax, rhs.Mmax);       ret.Mmax = std::max(ret.Mmax, Lmax + D[r] + rhs.Rmax);       ret.sum = sum + D[r] + rhs.sum;       return ret;     }   };   struct SegmentTree {     Unit t[N << 2];     void build(int l, int r, int rt) {       if (l == r) {         t[rt].l = t[rt].r = l;         t[rt].Lmax = t[rt].Rmax = 2 * H[l];         t[rt].sum = 0;         t[rt].Mmax = -1;         return;       }       int mid = l + r >> 1;       build(l, mid, rt << 1);       build(mid + 1, r, rt << 1 | 1);       t[rt] = t[rt << 1] + t[rt << 1 | 1];     }     Unit query(int L, int R, int l, int r, int rt) {       if (L <= l && r <= R) {         return t[rt];       }       int mid = l + r >> 1;       if (L <= mid && mid < R)         return query(L, R, l, mid, rt << 1) +                query(L, R, mid + 1, r, rt << 1 | 1);       if (L <= mid) return query(L, R, l, mid, rt << 1);       return query(L, R, mid + 1, r, rt << 1 | 1);     }   } sgt;   int main() {     scanf( %d%d , &n, &m);     for (int i = 1; i <= n; ++i) {       scanf( %I64d , D + i);     }     for (int i = 1; i <= n; ++i) {       scanf( %I64d , H + i);     }     sgt.build(1, n, 1);     while (m--) {       int a, b;       scanf( %d%d , &a, &b);       if (a > b) {         printf( %I64d n , sgt.query(b + 1, a - 1, 1, n, 1).Mmax);       } else {         if (a == 1) {           printf( %I64d n , sgt.query(b + 1, n, 1, n, 1).Mmax);         } else if (b == n) {           printf( %I64d n , sgt.query(1, a - 1, 1, n, 1).Mmax);         } else {           printf(                %I64d n ,               (sgt.query(b + 1, n, 1, n, 1) + sgt.query(1, a - 1, 1, n, 1)).Mmax);         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void main0();   int main() {     clock_t start, end;     ios::sync_with_stdio(false);     cin.tie(0);     main0();     return 0;   }   const int dx[8] = {0, 1, -1, 0, 1, 1, -1, -1};   const int dy[8] = {1, 0, 0, -1, 1, -1, -1, 1};   const int N = 5e5 + 5;   const int M = 1e5;   const int INF = 0x3f3f3f3f;   const long long INFF = 0x3f3f3f3f3f3f3f3f;   const int mod = 998244353;   const int G = 3;   const int Gi = 332748118;   const double eps = 1e-6;   mt19937 rnd(       (unsigned int)chrono::steady_clock::now().time_since_epoch().count());   template <typename T>   bool chkmin(T &x, T y) {     return y < x ? x = y, 1 : 0;   }   template <typename T>   bool chkmax(T &x, T y) {     return y > x ? x = y, 1 : 0;   }   long long qpow(long long n, long long m) {     long long ret = 1;     while (m) {       if (m & 1) ret = ret * n % mod;       n = n * n % mod;       m >>= 1;     }     return ret;   }   long long getinv(long long a) { return qpow(a, mod - 2); }   int n;   vector<int> e[N];   long long fac[N];   void init() {     fac[0] = 1;     for (int i = 1; i <= N - 1; ++i) {       fac[i] = fac[i - 1] * i % mod;     }   }   int r[N], lim;   void ntt(vector<long long> &A, int type) {     for (int i = 0; i <= lim - 1; ++i) {       if (i < r[i]) swap(A[i], A[r[i]]);     }     for (int mid = 1; mid <= lim - 1; mid <<= 1) {       long long Wn = qpow(type == 1 ? G : Gi, (mod - 1) / (mid << 1));       for (int j = 0; j <= lim - 1; j += (mid << 1)) {         long long w = 1;         for (int k = 0; k <= mid - 1; ++k, w = (w * Wn) % mod) {           int x = A[j + k];           int y = w * A[j + mid + k] % mod;           A[j + k] = (x + y) % mod;           A[j + mid + k] = (x - y + mod) % mod;         }       }     }     if (type == -1) {       long long tmp = getinv(lim);       for (int i = 0; i <= lim - 1; ++i) {         A[i] = A[i] * tmp % mod;       }     }   }   vector<long long> operator*(vector<long long> A, vector<long long> B) {     int len = A.size() + B.size() - 1;     lim = 1;     while (lim <= len) lim <<= 1;     for (int i = 0; i <= lim - 1; ++i) {       r[i] = (r[i >> 1] >> 1) | ((i & 1) * (lim >> 1));     }     A.resize(lim);     B.resize(lim);     ntt(A, 1);     ntt(B, 1);     for (int i = 0; i <= lim - 1; ++i) {       A[i] = A[i] * B[i] % mod;     }     ntt(A, -1);     A.resize(len);     return A;   }   vector<long long> solve(int l, int r) {     if (l == r) {       vector<long long> tmp({1, (int)e[l].size() - (l != 1)});       return tmp;     }     int mid = (l + r) / 2;     return solve(l, mid) * solve(mid + 1, r);   }   void main0() {     init();     cin >> n;     for (int i = 1; i <= n - 1; ++i) {       int u, v;       cin >> u >> v;       e[u].push_back(v);       e[v].push_back(u);     }     vector<long long> v = solve(1, n);     long long ans = 0;     for (int i = 0; i <= n - 1; ++i) {       ans += (i & 1 ? -1 : 1) * v[i] * fac[n - i] % mod;       ans %= mod;     }     ans += mod;     ans %= mod;     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int inf = 999999999;   int n;   template <typename T>   struct SegTree_t {     int n;     vector<int> tree, A;     SegTree_t(int _n) : n(_n), tree(4 * n, 0), A(4 * n, 0) {}     T operation(const T &a, const T &b) { return max(a, b); }     T query(int node, int l, int r, int a, int b) {       if (a > r || b < l) return 0;       if (l >= a && r <= b) return tree[node];       return operation(query(node << 1, l, (l + r) / 2, a, b),                        query((node << 1) + 1, (l + r) / 2 + 1, r, a, b));     }     T query(int a, int b) { return query(1, 0, n - 1, a, b); }     void update(int node, int l, int r, int idx, int val) {       if (l == r) {         A[idx] = val;         tree[node] = val;       } else {         int mid = (l + r) / 2;         if (l <= idx and idx <= mid)           update(node << 1, l, mid, idx, val);         else           update((node << 1) + 1, mid + 1, r, idx, val);         tree[node] = operation(tree[(node << 1)], tree[(node << 1) + 1]);       }     }     void update(int idx, int val) { return update(1, 0, n - 1, idx, val); }   };   int main() {     scanf( %d , &n);     int ret = 0;     SegTree_t<int> segtree(n);     for (int i = 0; i < n; ++i) {       int x;       scanf( %d , &x);       int y = segtree.query(0, x - 1);       ret = max(ret, y + 1);       segtree.update(x, y + 1);     }     printf( %d n , ret);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   pair<int, int> ar[3001];   const long long INF = 1000000000000000;   long long dp[3001][3001];   int func(int pos, int pre) {     if (pos > n) return 0;     if (dp[pos][pre] != -INF) return dp[pos][pre];     int x = ar[pos].second + func(pos + 1, pos);     int y = abs(ar[pos].first - ar[pre].first) + func(pos + 1, pre);     return dp[pos][pre] = min(x, y);   }   int main() {     cin >> n;     for (int i = 1; i <= n; i++) cin >> ar[i].first >> ar[i].second;     for (int i = 0; i <= n; i++) {       for (int j = 0; j <= n; j++) dp[i][j] = -INF;     }     sort(ar + 1, ar + n + 1);     long long ans = func(2, 1) + ar[1].second;     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   const long long maxn = 1e6, mod = 1e9 + 7;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long n, sum = 0;     cin >> n;     long long x;     long long nm = 0;     for (long long i = 0; i < n; i++) {       cin >> x;       nm = max(nm, x);       sum += x;     }     if (sum % (n - 1) == 0)       sum = sum / (n - 1);     else       sum = sum / (n - 1) + 1;     cout << max(sum, nm) <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 0x3fffffff;   const int SINF = 0x7fffffff;   const long long LINF = 0x3fffffffffffffff;   const long long SLINF = 0x7fffffffffffffff;   const int MAXN = 30007;   const int MAXD = 6;   const int MOD = 998244353;   int n, d;   int a[MAXN][MAXD][MAXD];   int tmp[MAXD][MAXD];   int ans[MAXN];   int m1[MAXN], m2[MAXN];   map<vector<int>, int> mp;   map<vector<int>, int>::iterator it;   void init();   void input();   void work();   vector<int> gauss(int a[][MAXD]);   int add(int x, int y) {     x += y;     if (x >= MOD) x -= MOD;     return x;   }   void addv(int &x, int y) {     x += y;     if (x >= MOD) x -= MOD;   }   int dec(int x, int y) {     x -= y;     if (x < 0) x += MOD;     return x;   }   void decv(int &x, int y) {     x -= y;     if (x < 0) x += MOD;   }   int qpow(int a, int b) {     long long base = a, ans = 1;     while (b) {       if (b & 1) (ans *= base) %= MOD;       (base *= base) %= MOD;       b >>= 1;     }     return static_cast<int>(ans);   }   int main() {     init();     input();     work();   }   void init() { ios::sync_with_stdio(false); }   void input() {     scanf( %d%d , &n, &d);     int nk;     for (int i = 1; i <= n; ++i) {       scanf( %d , &nk);       for (int j = 1; j <= nk; ++j) {         for (int k = 1; k <= d; ++k) scanf( %d , &a[i][j][k]);       }     }   }   void work() {     int kc = 0;     vector<int> v;     for (int i = 1; i <= n; ++i) {       v = gauss(a[i]);       if ((it = mp.find(v)) == mp.end())         mp[v] = ans[i] = ++kc;       else         ans[i] = it->second;     }     for (int i = 1; i <= n; ++i) printf( %d  , ans[i]);     putchar(  n );   }   vector<int> gauss(int a[][MAXD]) {     for (int i = 1; i <= d; ++i) m1[i] = m2[i] = 0;     for (int i = 1; i <= d; ++i)       for (int j = 1; j <= d; ++j) tmp[i][j] = (a[i][j] + MOD) % MOD;     long long g;     int ni = 1;     for (int i = 1; i <= d; ++i) {       for (int j = ni; j <= d; ++j) {         if (tmp[j][i]) {           for (int k = 1; k <= d; ++k) swap(tmp[ni][k], tmp[j][k]);         }       }       if (tmp[ni][i]) {         m1[ni] = i, m2[i] = ni;         for (int j = ni + 1; j <= d; ++j) {           g = qpow(tmp[ni][i], MOD - 2) * static_cast<long long>(tmp[j][i]) % MOD;           for (int k = i; k <= d; ++k) decv(tmp[j][k], g * tmp[ni][k] % MOD);         }         ++ni;       }     }     for (int i = ni - 1; i > 0; --i) {       for (int j = m1[i] + 1; j <= d; ++j) {         if (m2[j]) {           g = qpow(tmp[m2[j]][j], MOD - 2) * static_cast<long long>(tmp[i][j]) %               MOD;           for (int k = j; k <= d; ++k) decv(tmp[i][k], tmp[m2[j]][k] * g % MOD);         }       }     }     for (int i = 1; i < ni; ++i) {       g = qpow(tmp[i][m1[i]], MOD - 2);       for (int j = m1[i]; j <= d; ++j)         tmp[i][j] = static_cast<long long>(tmp[i][j]) * g % MOD;     }     vector<int> ans;     for (int i = 1; i < ni; ++i)       for (int j = 1; j <= d; ++j) ans.push_back(tmp[i][j]);     return ans;   }
#include <bits/stdc++.h>   using namespace std;   int a[150005];   int main() {     int n, k, q;     scanf( %d %d %d , &n, &k, &q);     for (int i = 1; i <= n; i++) {       scanf( %d , &a[i]);     }     multiset<int> t;     for (int i = 1; i <= q; i++) {       int x, y;       scanf( %d %d , &x, &y);       if (x == 1) {         t.insert(a[y]);         if ((int)t.size() > k) {           t.erase(t.begin());         }       } else {         auto it = t.find(a[y]);         printf(it != t.end() ?  YES n  :  NO n );       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 3e5 + 10;   const int LG = 20;   int go[N][LG];   int a[N];   int last[LG];   int main() {     int n, qq;     scanf( %d %d , &n, &qq);     for (int i = 0; i < n; i++) {       scanf( %d , a + i);     }     for (int i = 0; i < LG; i++) {       go[n][i] = n;       last[i] = n;     }     for (int i = n - 1; i >= 0; i--) {       for (int j = 0; j < LG; j++) {         go[i][j] = n;       }       for (int j = 0; j < LG; j++) {         if ((a[i] >> j) & 1) {           for (int k = 0; k < LG; k++) {             go[i][k] = min(go[i][k], go[last[j]][k]);           }           last[j] = i;           go[i][j] = i;         }       }     }     while (qq--) {       int x, y;       scanf( %d %d , &x, &y);       x--;       y--;       bool ok = false;       for (int i = 0; i < LG; i++) {         ok |= (((a[y] >> i) & 1) && go[x][i] <= y);       }       puts(ok ?  Shi  :  Fou );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     int n;     cin >> n;     long long k;     cin >> k;     vector<int> a(n);     int i;     int mx_pos = -1;     for (i = 0; i < n; i++) {       cin >> a[i];       if (a[i] == n) {         mx_pos = i;       }     }     int p1 = -1, p2 = -1;     long long w = 0;     for (i = 0; w < k && i < mx_pos; i++) {       if (p1 == -1) {         p1 = a[i];       } else if (p2 == -1) {         p2 = a[i];       }       if (p2 != -1) {         if (p1 < p2) {           p1 = p2;           p2 = -1;           w = 1;         } else {           p2 = -1;           w++;         }       }     }     if (w == k) {       cout << p1;     } else {       cout << n;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     long long d, n, m;     cin >> d >> n >> m;     vector<pair<long long, long long> > stations(m + 2);     stations[0] = pair<long long, long long>(0, 0);     for (int i = 1; i <= m; i++) {       int x, y;       cin >> x >> y;       stations[i] = pair<long long, long long>(x, y);     }     stations[m + 1] = pair<long long, long long>(d, 0);     sort(stations.begin(), stations.end());     long long cost = 0, current = n, i = 0;     while (i < m + 1) {       bool found = false;       int last = i + 1;       while (stations[last].first <= stations[i].first + n) {         if (stations[last].second <= stations[i].second) {           int needed =               max(0LL, stations[last].first - stations[i].first - current);           current += needed - stations[last].first + stations[i].first;           cost += needed * stations[i].second;           i = last;           if (last == m + 1) {             cout << cost << endl;             return 0;           }           found = true;         }         last++;       }       if (!found) {         if (last == i + 1) {           cout << -1 << endl;           return 0;         }         cost += (n - current) * stations[i].second;         current = n - (stations[i + 1].first - stations[i].first);         i++;       }     }     cout << -1 << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX = 3e5 + 5;   vector<int> ic[MAX];   vector<int> adj[MAX];   int used[MAX];   int cn;   vector<int> tr;   int ans[MAX];   void dfs(int s, int p) {     for (int i = 0; i < ic[s].size(); i++) {       int u = ic[s][i];       if (!ans[u] || used[ans[u]]) {         tr.push_back(u);       } else {         used[ans[u]] = 1;       }     }     int cur = 1;     for (int i = 0; i < tr.size(); i++) {       int u = tr[i];       while (used[cur]) {         cur++;       }       ans[u] = cur;       cur++;     }     cn = max(cn, cur);     tr.clear();     for (int i = 0; i < ic[s].size(); i++) {       int u = ic[s][i];       used[ans[u]] = 0;     }     for (int i = 0; i < adj[s].size(); i++) {       int u = adj[s][i];       if (u != p) {         dfs(u, s);       }     }   }   int main() {     int n, m;     scanf( %d %d , &n, &m);     for (int i = 1; i <= n; i++) {       int cnt;       scanf( %d , &cnt);       for (int j = 1; j <= cnt; j++) {         int a;         scanf( %d , &a);         ic[i].push_back(a);       }     }     for (int i = 1; i < n; i++) {       int a, b;       scanf( %d %d , &a, &b);       adj[a].push_back(b);       adj[b].push_back(a);     }     dfs(1, 0);     if ((cn - 1) == 0) {       printf( 1 n );       for (int i = 1; i <= m; i++) {         printf( 1  );       }     } else {       printf( %d n , cn - 1);       for (int i = 1; i <= m; i++) {         if (ans[i] == 0) {           ans[i] = 1;         }         printf( %d  , ans[i]);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int oo = 0x3f3f3f3f;   const int Max = 256;   const int MaxE = Max * 2;   struct edge {     int to;     edge *s;   };   edge E[MaxE], *hd[Max], *cp;   int n, k, D[Max];   int mp[Max][Max];   int F[Max][Max];   int A[Max], R[Max];   void addEdge(int x, int y) { cp->to = y, cp->s = hd[x], hd[x] = cp++; }   inline void update(int &r, int d) {     if (d < r) r = d;   }   void dfs(int x, int f) {     for (edge *p = hd[x]; p; p = p->s)       if (p->to != f) dfs(p->to, x);     for (int i = 1; i <= n; i++) {       int &cr = F[x][i] = 0;       int dx = mp[x][i];       for (edge *p = hd[x]; p; p = p->s)         if (p->to != f) {           int y = p->to;           cr += dx < mp[y][i] ? min(R[y], F[y][i]) : F[y][i];         }       cr += D[dx];       if (x == i) cr += k;       if (dx < mp[f][i]) update(R[x], cr);     }   }   void aDfs(int x, int f, int g) {     if (g == 0) {       for (int i = 1; i <= n; i++)         if (mp[x][i] < mp[f][i] && F[x][i] == R[x]) {           aDfs(x, f, i);           return;         }     }     A[x] = g;     for (edge *p = hd[x]; p; p = p->s)       if (p->to != f) {         int y = p->to;         aDfs(y, x, mp[x][g] < mp[y][g] && R[y] < F[y][g] ? 0 : g);       }   }   int main() {     while (scanf( %d%d , &n, &k) != EOF && n) {       for (int i = 1; i < n; i++) scanf( %d , &D[i]);       D[n] = oo;       memset(hd, 0, sizeof(hd));       memset(mp, 0x3f, sizeof(mp));       cp = E;       for (int i = 1; i < n; i++) {         int x, y;         scanf( %d%d , &x, &y);         mp[x][y] = mp[y][x] = 1;         addEdge(x, y);         addEdge(y, x);       }       for (int z = 1; z <= n; z++)         for (int x = 1; x <= n; x++)           for (int y = 1; y <= n; y++) update(mp[x][y], mp[x][z] + mp[z][y]);       for (int x = 1; x <= n; x++) mp[x][x] = 0;       memset(R, 0x3f, sizeof(R));       dfs(1, 0);       printf( %d n , R[1]);       aDfs(1, 0, 0);       for (int i = 1; i <= n; i++) printf( %d%c , A[i], i == n ?   n  :    );     }   }
#include <bits/stdc++.h>   using namespace std;   double EPS = 1e-9;   int INF = 2000000000;   long long INFF = 8000000000000000000LL;   double PI = acos(-1);   int dirx[8] = {-1, 0, 0, 1, -1, -1, 1, 1};   int diry[8] = {0, 1, -1, 0, -1, 1, -1, 1};   inline string IntToString(int a) {     char x[100];     sprintf(x,  %d , a);     string s = x;     return s;   }   inline int StringToInt(string a) {     char x[100];     int res;     strcpy(x, a.c_str());     sscanf(x,  %d , &res);     return res;   }   inline string GetString(void) {     char x[1000005];     scanf( %s , x);     string s = x;     return s;   }   inline string uppercase(string s) {     int n = (int)s.size();     for (int(i) = (0); (i) < (n); ++(i))       if (s[i] >=  a  && s[i] <=  z ) s[i] = s[i] -  a  +  A ;     return s;   }   inline string lowercase(string s) {     int n = (int)s.size();     for (int(i) = (0); (i) < (n); ++(i))       if (s[i] >=  A  && s[i] <=  Z ) s[i] = s[i] -  A  +  a ;     return s;   }   inline void OPEN(string s) {     freopen((s +  .in ).c_str(),  r , stdin);     freopen((s +  .out ).c_str(),  w , stdout);   }   int k, n = 500;   int sisa[1005];   void process(int a, int b) {     sisa[a] = k - 1;     for (int(i) = (a + 1); (i) <= (b); ++(i)) sisa[i] = k;     for (int(i) = (a); (i) <= (b); ++(i)) {       vector<pair<int, int> > besar;       for (int(j) = (i + 1); (j) <= (b); ++(j))         if (i != j) besar.push_back(make_pair(sisa[j], j));       sort(besar.begin(), besar.end());       reverse(besar.begin(), besar.end());       for (int(j) = (0); (j) < (sisa[i]); ++(j)) {         printf( %d %d n , i, besar[j].second);         --sisa[besar[j].second];       }       sisa[i] = 0;     }   }   int main() {     scanf( %d , &k);     if (k == 1) {       puts( YES );       puts( 2 1 );       puts( 1 2 );       return 0;     }     if (k % 2 == 0) {       puts( NO );       return 0;     }     puts( YES );     printf( %d %d n , n, (k * n) / 2);     process(1, n / 2 - 1);     process(n / 2, n);     printf( %d %d n , 1, n / 2);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, q;     scanf( %d %d , &n, &q);     string s;     cin >> s;     int size = s.size();     int cnt = 0;     for (int i = 1; i < size; i++) {       if (s[i] ==  .  && s[i] == s[i - 1]) cnt++;     }     while (q--) {       int n1;       char x;       scanf( %d %c , &n1, &x);       n1--;       if (isalpha(x) == isalpha(s[n1]))         ;       else if (x ==  .  && s[n1] !=  . ) {         if (n1 < n - 1)           if (s[n1 + 1] ==  . ) cnt++;         if (n1 > 0)           if (s[n1 - 1] ==  . ) cnt++;       } else {         if (n1 < n - 1)           if (s[n1 + 1] ==  . ) cnt--;         if (n1 > 0)           if (s[n1 - 1] ==  . ) cnt--;       }       s[n1] = x;       printf( %d n , cnt);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int u[1005], v[1005], fa[1005], n, m, k;   bool zt[1005][1005];   int getv(int x) {     if (x == fa[x]) return x;     fa[x] = getv(fa[x]);     return fa[x];   }   void merge(int x, int y) {     x = getv(x);     y = getv(y);     if (x == y) return;     if (x < y) {       int t = x;       x = y;       y = t;     }     fa[x] = y;     for (int i = 1; i <= m; i++) {       if (zt[x][i]) zt[y][i] = true;     }   }   unsigned long long ha(char zf[1005]) {     unsigned long long rt = 0;     for (int i = 0; zf[i]; i++) rt = rt * 13131 + zf[i];     return rt;   }   map<unsigned long long, int> mp;   char zf[1005];   int wz[1005], rw[1005], yw[1005];   int w2[1005], r2[1005], y2[1005];   bool b1[1005], b2[1005];   int main() {     scanf( %d%d%d , &n, &m, &k);     for (int i = 1; i <= n; i++) fa[i] = i;     for (int i = 1; i <= m; i++) scanf( %d%d , &u[i], &v[i]);     for (int i = 1; i <= k; i++) {       int a, s;       scanf( %s%d%d , zf, &a, &s);       rw[i] = a;       mp[ha(zf)] = i;       for (int j = 0; j < s; j++) {         int b;         scanf( %d , &b);         zt[a][b] = 1;         yw[b] = a;       }     }     for (int a = 1; a <= m; a++) {       for (int i = 1; i <= m; i++) {         if (!b1[i] && (zt[getv(u[i])][i] || zt[getv(v[i])][i])) {           merge(u[i], v[i]);           b1[i] = true;         }       }     }     for (int i = 1; i <= n; i++) wz[i] = getv(i);     for (int i = 1; i <= m; i++) yw[i] = getv(yw[i]);     for (int i = 1; i <= k; i++) rw[i] = getv(rw[i]);     for (int i = 1; i <= n; i++) {       fa[i] = i;       for (int j = 1; j <= m; j++) zt[i][j] = 0;     }     for (int i = 1; i <= k; i++) {       int a, s;       scanf( %s%d%d , zf, &a, &s);       r2[mp[ha(zf)]] = a;       for (int j = 0; j < s; j++) {         int b;         scanf( %d , &b);         zt[a][b] = 1;         y2[b] = a;       }     }     for (int a = 1; a <= m; a++) {       for (int i = 1; i <= m; i++) {         if (!b2[i] && (zt[getv(u[i])][i] || zt[getv(v[i])][i])) {           merge(u[i], v[i]);           b2[i] = true;         }       }     }     for (int i = 1; i <= n; i++) w2[i] = getv(i);     for (int i = 1; i <= m; i++) y2[i] = getv(y2[i]);     for (int i = 1; i <= k; i++) r2[i] = getv(r2[i]);     bool zd = false;     for (int i = 1; i <= n; i++) {       if (wz[i] != w2[i]) zd = true;     }     for (int i = 1; i <= k; i++) {       if (rw[i] != r2[i]) zd = true;     }     for (int i = 1; i <= m; i++) {       if (yw[i] != y2[i]) zd = true;     }     for (int i = 1; i <= m; i++) {       if (b1[i] != b2[i]) zd = true;     }     if (zd)       printf( NO );     else       printf( YES );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 55;   long long n, m;   int sol[MAXN];   void solve(int l, int r, long long k) {     if (l == r) {       assert(k == 1);       sol[l] = n;       return;     }     int len = r - l + 1;     long long cant = (1LL << (len - 1));     if (k <= cant / 2) {       sol[l] = n - len + 1;       solve(l + 1, r, k);     } else {       sol[r] = n - len + 1;       solve(l, r - 1, k - cant / 2);     }   }   int main() {     cin >> n >> m;     solve(0, n - 1, m);     for (int i = 0; i < n; i++) cout << sol[i] <<    n [i == n - 1];   }