malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const long long N = 2e5 + 3;   long long n, ans, sz[N], up[N], down[N];   vector<long long> q[N];   void dfs1(long long v, long long p) {     sz[v] = 1;     for (auto i : q[v]) {       if (i != p) {         dfs1(i, v);         sz[v] += sz[i];         down[v] += down[i] + sz[i];       }     }   }   void dfs2(long long v, long long p) {     if (p != -1) {       up[v] = down[p] + up[p] - (down[v] + sz[v]) + (sz[1] - sz[v]);     }     ans = max(ans, down[v] + up[v] + n);     for (auto i : q[v]) {       if (i != p) {         dfs2(i, v);       }     }   }   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cin >> n;     for (long long i = 1; i < n; i++) {       long long x, y;       cin >> x >> y;       q[x].push_back(y);       q[y].push_back(x);     }     dfs1(1, -1);     dfs2(1, -1);     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   int n;   int x[411111], d[411111];   int go[20][411111], w[20][411111];   int ma[20][411111];   int comp(int a, int b) {     if (a == -1) return b;     if (b == -1) return a;     if (x[a] + d[a] > x[b] + d[b]) return a;     return b;   }   int main() {     cin >> n;     for (int i = 0; i < n; i++) scanf( %d%d , &x[i], &d[i]);     for (int i = 0; i < n; i++) ma[0][i] = i;     for (int i = 1; i < 20; i++)       for (int j = 0; j < n; j++)         if (j + (1ll << (i)) <= n) {           int a = ma[i - 1][j];           int b = ma[i - 1][j + (1ll << (i - 1))];           ma[i][j] = comp(a, b);         }     for (int i = 0; i < n; i++) {       if (i == n - 1) {         go[0][i] = i;         w[0][i] = 0;         continue;       }       if (x[i] + d[i] < x[i + 1]) {         go[0][i] = i + 1;         w[0][i] = x[i + 1] - (x[i] + d[i]);         continue;       }       int best = -1;       int t = i + 1;       for (int j = 19; j >= 0; j--)         if (t + (1ll << (j)) <= n && x[t + (1ll << (j)) - 1] <= x[i] + d[i]) {           best = comp(best, ma[j][t]);           t += (1ll << (j));         }       if (comp(best, i) == i) {         if (t == n) {           go[0][i] = i;           w[0][i] = 0;         } else {           go[0][i] = t;           w[0][i] = x[t] - (x[i] + d[i]);         }       } else {         go[0][i] = best;         w[0][i] = 0;       }     }     for (int i = 1; i < 20; i++)       for (int j = 0; j < n; j++) {         go[i][j] = go[i - 1][go[i - 1][j]];         w[i][j] = w[i - 1][j] + w[i - 1][go[i - 1][j]];       }     int m;     cin >> m;     while (m--) {       int a, b;       scanf( %d%d , &a, &b);       a--;       b--;       int ans = 0;       for (int i = 19; i >= 0; i--)         if (go[i][a] <= b) {           ans += w[i][a];           a = go[i][a];         }       if (x[a] + d[a] < x[b]) ans += x[b] - (x[a] + d[a]);       printf( %d n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX = 1e6 + 5;   struct T {     int l, r, i;     bool operator<(T const& other) {       return (l == other.l ? r < other.r : l < other.l);     }   };   int con[MAX][2];   pair<int, int> num[2 * MAX];   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int n, k, l, r;     cin >> n >> k;     for (int i = 0; i < n; i++) {       cin >> l >> r;       num[i * 2] = {l, 1};       num[i * 2 + 1] = {r, 2};     }     sort(num, num + 2 * n);     int c = 0, a = 0;     for (int i = 0; i < 2 * n; i++) {       bool go = true;       if (num[i].second == 1)         a++;       else         go = false, a--;       if (a == k && go) con[c][0] = num[i].first;       if (a == k - 1 && !go) con[c][1] = num[i].first, c++;     }     cout << c << endl;     for (int i = 0; i < c; i++) cout << con[i][0] <<     << con[i][1] << endl;   }
#include <bits/stdc++.h>   using namespace std;   char BUF_I[1048576], *S_I = BUF_I, *T_I = BUF_I;   struct Input {     Input() {}     inline Input &operator>>(char &c) {       return (c = ((S_I == T_I) &&                            (T_I = (S_I = BUF_I) + fread(BUF_I, 1, 1048576, stdin),                             S_I == T_I)                        ? EOF                        : *S_I++),               *this);     }     template <class T>     inline Input &operator>>(T &S_I) {       S_I = 0;       char c;       while (*this >> c, c < 48 || c > 57)         ;       while (S_I = S_I * 10 + c - 48, *this >> c, c > 47 && c < 58)         ;       return *this;     }     inline int Getint() {       char c;       register int S_I = 0;       register bool w = false;       while (*this >> c, c == 45 && (w = true), c < 48 || c > 57)         ;       while (S_I = S_I * 10 + c - 48, *this >> c, c > 47 && c < 58)         ;       return w ? -S_I : S_I;     }   } tin;   char BUF_O[262144], *S_O = BUF_O, *Limit_O = BUF_O + 262144;   struct Output {     ~Output() { Flush(); }     inline int Flush() {       fwrite(BUF_O, 1, S_O - BUF_O, stdout);       S_O = BUF_O;       return 0;     }     inline Output &operator<<(const char &c) {       if (S_O == Limit_O) Flush();       return (*S_O++ = c, *this);     }     template <class T>     inline Output &operator<<(T x) {       static char Stack[25];       static int Top;       if (x < (Top = 0)) *this <<  - , x = -x;       do {         Stack[++Top] = x % 10 + 48;       } while (x /= 10);       while (Top) (*this) << Stack[Top--];       return *this;     }   } tout;   int n, a[1005][1005];   int main() {     tin >> n;     for (int i = 1; i <= n; i++)       for (int j = 1; j <= n; j++) a[i][j] = (i + j - 2) % (n - 1) + 1;     for (int i = 1; i <= n; i++) {       a[i][n] = a[n][i] = a[i][i];       a[i][i] = 0;     }     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= n; j++) tout << a[i][j] <<    ;       tout <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long c1, c2, c3, c4, n, m, i, kol1, kol, ans, ans1;   int main() {     cin >> c1 >> c2 >> c3 >> c4;     cin >> n >> m;     long long a[n + 1], b[m + 1];     for (i = 1; i <= n; i++) cin >> a[i];     for (i = 1; i <= m; i++) cin >> b[i];     for (i = 1; i <= n; i++) {       long long ans = 0;       if (a[i] * c1 <= c2)         ans += a[i] * c1;       else         ans += c2;       kol += ans;     }     kol = min(c3, kol);     for (i = 1; i <= m; i++) {       long long ans1 = 0;       if (b[i] * c1 <= c2)         ans1 += b[i] * c1;       else         ans1 += c2;       kol1 += ans1;     }     kol1 = min(c3, kol1) + kol;     cout << min(kol1, c4);     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize(3,  Ofast ,  inline )   using namespace std;   const long long maxn = (long long)4e5 + 5;   const long long mod = 1000000007;   const long long inf = 0x3f3f3f3f;   long long a[maxn], b[maxn], n, ans;   bool cal(long long L, long long R) {     long long sum = 0;     for (long long i = n, l = 1, r = 1; i >= 1; --i) {       while (l <= n && b[i] + b[l] < L) ++l;       while (r <= n && b[i] + b[r] <= R) ++r;       sum += r - l - (l <= i && i < r);     }     return (sum >> 1) & 1;   }   bool solve(long long k) {     for (long long i = 1; i <= n; ++i) b[i] = a[i] & ((1 << (k + 1)) - 1);     sort(b + 1, b + n + 1);     return cal(1 << k, (1 << (k + 1)) - 1) ^ cal(3 << k, (1 << (k + 2)) - 2);   }   signed main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     ;     cin >> n;     for (long long i = 1; i <= n; ++i) cin >> a[i];     for (long long i = 0; i <= 30; ++i) ans |= solve(i) << i;     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n1, n2, k1, k2;     cin >> n1 >> n2 >> k1 >> k2;     if (n1 > n2)       cout <<  First  << endl;     else if (n1 == n2)       cout <<  Second  << endl;     else       cout <<  Second  << endl;     return 0;   }
#include <bits/stdc++.h>   int main() {     int n, m, k;     while (scanf( %d%d , &n, &m) != EOF) {       int ans = n / m;       k = n % m;       for (int i = 1; i <= m; i++) {         if (i <= m - k) {           printf( %d , ans);         } else {           printf( %d , ans + 1);         }         if (i != m) {           printf(   );         } else {           printf(  n );         }       }     }   }
#include <bits/stdc++.h>   using namespace std;   const int MOD = 1000000007;   const int N = 710;   string s;   int n, t[N];   stack<int> st;   struct node {     long long f[3][3];     void init() {       for (int i = 1; i <= 2; i++) f[i][0] = f[0][i] = 1;     }     node() { memset(f, 0, sizeof(f)); }     void mergein(node t) {       for (int i = 0; i <= 2; i++)         for (int j = 0; j <= 2; j++)           if ((i == 0 || j == 0) && i != j)             for (int i1 = 0; i1 <= 2; i1++)               for (int j1 = 0; j1 <= 2; j1++)                 if ((i1 != i || i1 + i == 0) && (j1 != j || j1 + j == 0))                   f[i][j] = (f[i][j] + t.f[i1][j1]) % MOD;     }     void mergenear(node x, node y) {       for (int i = 0; i <= 2; i++)         for (int j = 0; j <= 2; j++)           for (int i1 = 0; i1 <= 2; i1++)             for (int j1 = 0; j1 <= 2; j1++)               if (i1 != j1 || i1 + j1 == 0)                 f[i][j] = (f[i][j] + (x.f[i][i1] * y.f[j1][j]) % MOD) % MOD;     }   };   node DAC(int l, int r) {     node tmp;     if (t[l] == r) {       if (l == r - 1)         tmp.init();       else         tmp.mergein(DAC(l + 1, r - 1));     } else       tmp.mergenear(DAC(l, t[l]), DAC(t[l] + 1, r));     return tmp;   }   void prepare() {     cin >> s;     n = s.length();   }   void solve() {     for (int i = 1; i <= n; i++)       if (s[i - 1] ==  ( )         st.push(i);       else         t[i] = st.top(), st.pop(), t[t[i]] = i;     node ans = DAC(1, n);     long long way = 0;     for (int i = 0; i <= 2; i++)       for (int j = 0; j <= 2; j++) way = (way + ans.f[i][j]) % MOD;     cout << way;   }   int main() {     prepare();     solve();   }
#include <bits/stdc++.h>   #pragma optimization_level 3   #pragma GCC optimize( Ofast,no-stack-protector,unroll-loops,fast-math,O3 )   #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx )   using namespace std;   const long long N = 1e6 + 5;   const long long mod = 1e9 + 7;   const long long INF = 0x7f7f7f7f7f7f7f7f;   const int INFi = 0x7f7f7f7f;   long long test = 1, n, m, a[N], sz = 0, tot, ch[N];   string second =  0 ;   long long tree[N] = {};   void update(int idx, int val) {     idx++;     while (idx <= N - 1) {       tree[idx] += val;       idx += idx & (-idx);     }   }   long long query(int idx) {     idx++;     long long sum = 0;     while (idx > 0) {       sum += tree[idx];       idx -= idx & (-idx);     }     return sum;   }   int bs(int x) {     int l = 1, r = N - 1, ans = 0;     while (l <= r) {       int mid = (l + r) / 2;       if (query(mid) >= x) {         ans = mid;         r = mid - 1;       } else         l = mid + 1;     }     return ans;   }   void solve() {     cin >> n >> m;     for (int i = 1; i <= m; i++) cin >> a[i];     for (int i = 1; i <= n; i++) {       int x;       cin >> x;       if (x == -1) {         vector<long long> v;         for (int i = 1; i <= m; i++) {           if (a[i] > sz) break;           v.push_back(bs(a[i]));         }         sz -= v.size();         for (auto it : v) ch[it] = 0, update(it, -1);       } else {         second += x +  0 ;         sz++, tot++;         update(tot, 1);         ch[tot] = 1;       }     }     if (sz == 0)       cout <<  Poor stack!             <<   n ;     else {       for (int i = 1; i <= tot; i++) {         if (ch[i] == 1) cout << second[i];       }       cout <<   n ;       ;     }   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cout << fixed;     cout << setprecision(15);     ;     for (int i = 1; i <= test; i++) {       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   vector<vector<long long> > g;   vector<vector<pair<long long, long long> > > updates;   vector<long long> tree;   vector<long long> ans;   long long n;   void update(long long v, long long l, long long r, long long al, long long ar,               long long val) {     if (al <= l && ar >= r) {       tree[v] += val;       return;     }     if (al <= r && ar >= l) {       update(v * 2, l, (r + l) / 2, al, ar, val);       update(v * 2 + 1, (r + l) / 2 + 1, r, al, ar, val);     }   }   long long answer(long long v, long long l, long long r, long long ind) {     if (l == r) {       return tree[v];     }     if (ind <= (r + l) / 2) {       return tree[v] + answer(v * 2, l, (r + l) / 2, ind);     } else {       return tree[v] + answer(v * 2 + 1, (r + l) / 2 + 1, r, ind);     }   }   void dfs(long long v, long long pred = -1, long long h = 0) {     for (long long i = 0; i < updates[v].size(); i++) {       update(1, 0, n - 1, h, min(updates[v][i].second + h, n),              updates[v][i].first);     }     ans[v] = answer(1, 0, n - 1, h);     for (long long i = 0; i < g[v].size(); i++) {       if (g[v][i] != pred) {         dfs(g[v][i], v, h + 1);       }     }     for (long long i = 0; i < updates[v].size(); i++) {       update(1, 0, n - 1, h, min(updates[v][i].second + h, n),              -updates[v][i].first);     }   }   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cin >> n;     tree.resize(n * 4);     g.resize(n);     ans.resize(n);     updates.resize(n);     for (long long i = 0; i < n - 1; i++) {       long long x, y;       cin >> x >> y;       x--;       y--;       g[x].push_back(y);       g[y].push_back(x);     }     long long m;     cin >> m;     for (long long i = 0; i < m; i++) {       long long v, x, d;       cin >> v >> d >> x;       v--;       updates[v].push_back({x, d});     }     dfs(0);     for (long long i = 0; i < ans.size(); i++) {       cout << ans[i] <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int flag[3000500];   int dp[200050];   int maxx[200050];   int ans[200050];   stack<int> st;   int main() {     string s;     cin >> s;     int n = s.size();     for (int i = 0; i < n; i++) {       ans[i] = 0;       if (s[i] ==  1 ) st.push(i);       if (s[i - 1] ==  1  && s[i] ==  0 ) {         int j = i;         while (!st.empty() && s[j] ==  0  && j < n) {           int temp = st.top();           st.pop();           ans[temp] = 1;           j++;           i = j - 1;         }       }     }     for (int i = 0; i < n; i++) cout << ans[i];     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   int C[1 << 12], A[1 << 12], B[1 << 12], LA[1 << 12], LB[1 << 12];   int main() {     int i, s = 0;     scanf( %d , &n);     n = (1 << n);     for (i = 0; i < n; i++) {       scanf( %d , &C[i]);       s ^= C[i];     }     if (s) {       puts( Fou );       return 0;     }     puts( Shi );     for (i = 0; i < n; i++) {       A[i] = B[i] = i;       LA[i] = LB[i] = i;     }     for (i = 0; i < n; i++) {       int u = i;       while (1) {         if ((A[u] ^ B[u]) == C[u]) break;         int v = LA[C[u] ^ B[u]];         swap(A[v], A[u]);         swap(LA[A[v]], LA[A[u]]);         if (v > i) break;         swap(B[v], B[i + 1]);         swap(LB[B[v]], LB[B[i + 1]]);         u = v;       }     }     for (i = 0; i < n; i++) printf( %d  , A[i]);     puts(  );     for (i = 0; i < n; i++) printf( %d  , B[i]);   }
#include <bits/stdc++.h>   using namespace std;   inline long long calc(long long x, long long k) {     if (x < 0) return 0LL;     return x / k + 1LL;   }   int main() {     long long k, a, b;     scanf( %lld%lld%lld , &k, &a, &b);     if (a <= 0 && b <= 0) {       a = abs(a), b = abs(b);       printf( %lld n , calc(a, k) - calc(b - 1LL, k));     } else if (a >= 0 && b >= 0) {       printf( %lld n , calc(b, k) - calc(a - 1LL, k));     } else {       a = abs(a);       printf( %lld n , calc(b, k) + calc(a, k) - 1LL);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, w, csets;   int weights[1001];   int beauties[1001];   int ranksz[1001];   int parents[1001];   bool superprnt[1001];   vector<vector<int>> setlist;   vector<int> beautysum;   vector<int> wtsum;   map<int, int> setidmap;   vector<vector<int>> dpmap;   int find_parent(int i) {     if (parents[i] == i) return i;     return parents[i] = find_parent(parents[i]);   }   void union_nodes(int a, int b) {     int prta{find_parent(a)};     int prtb{find_parent(b)};     if (prta == prtb) return;     if (ranksz[prta] > ranksz[prtb]) {       parents[prtb] = prta;       ranksz[prta] += ranksz[prtb];       superprnt[prtb] = 0;     } else {       parents[prta] = prtb;       ranksz[prtb] += ranksz[prta];       superprnt[prta] = 0;     }   }   int solvedp(int i, int wts) {     if (i == csets || wts == 0) return 0;     if (dpmap[i][wts] != -1) return dpmap[i][wts];     int ans1{-500}, ans2{-500}, ans3{-500};     if (wtsum[i] <= wts) ans1 = beautysum[i] + solvedp(i + 1, wts - wtsum[i]);     for (int j : setlist[i]) {       if (weights[j] <= wts) {         ans2 = max(ans2, beauties[j] + solvedp(i + 1, wts - weights[j]));       }     }     ans3 = solvedp(i + 1, wts);     return dpmap[i][wts] = max(max(ans1, ans2), ans3);   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int m, a, b;     cin >> n >> m >> w;     for (int i = 1; i <= n; ++i) {       cin >> weights[i];       parents[i] = i;       ranksz[i] = 1;       superprnt[i] = 1;     }     for (int i = 1; i <= n; ++i) {       cin >> beauties[i];     }     for (int i = 0; i < m; ++i) {       cin >> a >> b;       union_nodes(a, b);     }     int setid{0};     csets = 0;     for (int i = 1; i <= n; ++i) {       if (superprnt[i]) {         csets++;         setidmap[i] = setid++;       }     }     setlist = vector<vector<int>>(csets);     beautysum = vector<int>(csets, 0);     wtsum = vector<int>(csets, 0);     for (int i = 1; i <= n; ++i) {       int prt{find_parent(i)};       int id{setidmap[prt]};       setlist[id].push_back(i);       beautysum[id] += beauties[i];       wtsum[id] += weights[i];     }     dpmap = vector<vector<int>>(csets, vector<int>(w + 1, -1));     int ans{solvedp(0, w)};     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int s[65] = {0, 1, 1,  1,  2, 1,  2,  1,  5, 2,  2, 1, 5, 1,  2,  1,  14,                1, 5, 1,  5,  2, 2,  1,  15, 2, 2,  5, 4, 1, 4,  1,  51, 1,                2, 1, 14, 1,  2, 2,  14, 1,  6, 1,  4, 2, 2, 1,  52, 2,  5,                1, 5, 1,  15, 2, 13, 2,  2,  1, 13, 1, 2, 4, 267};   int n;   int main() {     scanf( %d , &n);     printf( %d n , s[n]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     long long int n;     cin >> n;     long long int a[n];     for (auto i = 0; i <= n - 1; i++) cin >> a[i];     sort(a, a + n);     for (auto i = n - 1; i >= 0; i--) {       if (a[i] <= i + 1) {         cout << i + 2 <<   n ;         return;       }     }     cout <<  1 n ;   }   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long int t;     cin >> t;     while (t--) solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const char E =   n ;   int main() {     set<string> a;     string s;     cin >> s;     a.insert(s);     int n = s.length();     for (int i = 1; i <= n + 1; i++) {       char z = s[n - 1];       for (int j = n; j >= 1; j--) {         s[j] = s[j - 1];       }       s[0] = z;       a.insert(s);     }     cout << a.size() << E;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool query(int x, int y) {     cout <<  ?   << x <<     << y << endl;     char resp;     cin >> resp;     if (resp ==  e ) exit(0);     return resp ==  x ;   }   void answer(int v) {     cout <<  !   << v << endl;     return;   }   void solve() {     int k = -1;     ;     for (int i = 0; i < 30; i++) {       int x = (1 << (i + 1)), y = (1 << i);       if (!query(x, y)) {         k = i;         break;       }     }     if (k == -1) {       answer(1);       return;     }     int l = (1 << k);     int u = (1 << (k + 1));     while (u - l > 2) {       int mid = (u + l) / 2;       if (!query(mid, mid / 2))         u = mid;       else         l = mid;     }     if (!query(u, 1))       answer(u);     else       answer(u - 1);     return;   }   int main() {     string msg;     while (cin >> msg, msg !=  end ) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int n, t, i, c = 0, s, x, y, u;     cin >> n >> t;     if (t < 10) {       for (i = 0; i < n; i++) cout << t;     } else {       s = t / 10;       c++;       while (1) {         s = s / 10;         c++;         if (s == 0) break;       }       if (c == n)         cout << t;       else if (c > n)         cout <<  -1 ;       else if (c < n) {         u = n - c;         cout << t;         for (i = 1; i <= u; i++) cout << 0;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int flag[13], change[13];   bool is_leap(int y) {     if (y % 100 == 0)       return y % 400 == 0;     else       return y % 4 == 0;   }   int main() {     memset(flag, 0, sizeof(flag));     memset(change, 0, sizeof(change));     int y;     cin >> y;     while (1) {       bool last = is_leap(y);       y++;       bool now = is_leap(y);       if (last && (!now))         for (int i = 1; i <= 12; i++) change[i] = (change[i] + 1 + (i <= 2)) % 7;       else if ((!last) && now)         for (int i = 1; i <= 12; i++) change[i] = (change[i] + 1 + (i >= 3)) % 7;       else         for (int i = 1; i <= 12; i++) change[i] = (change[i] + 1) % 7;       bool ok = true;       for (int i = 1; i <= 12; i++)         if (flag[i] != change[i]) {           ok = false;           break;         }       if (ok) break;     }     cout << y << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 2147483647;   const long long LLINF = 9223372036854775807LL;   int m;   const int mod = 1000000007;   struct matr {     int a[60][60];     matr() { memset(a, 0, sizeof(a)); }   };   matr mul(matr m1, matr m2) {     matr res;     for (int i = 0; i < m; ++i)       for (int j = 0; j < m; ++j)         for (int k = 0; k < m; ++k)           res.a[i][j] = (res.a[i][j] + (long long)m1.a[i][k] * m2.a[k][j]) % mod;     return res;   }   matr pow(matr x, long long p) {     if (p == 0) {       matr res;       for (int i = 0; i < m; ++i) res.a[i][i] = 1;       return res;     } else if (p & 1)       return mul(x, pow(x, p - 1));     else {       matr t = pow(x, p >> 1);       return mul(t, t);     }   }   int g(char c) {     if (c >=  a  && c <=  z )       return c -  a ;     else       return c -  A  + 26;   }   int main() {     long long n;     int k;     cin >> n >> m >> k;     n--;     matr p;     for (int i = 0; i < m; ++i)       for (int j = 0; j < m; ++j) p.a[i][j] = 1;     for (int i = 0; i < k; ++i) {       string s;       cin >> s;       int v1 = g(s[0]);       int v2 = g(s[1]);       p.a[v2][v1] = 0;     }     p = pow(p, n);     int ans = 0;     for (int i = 0; i < m; ++i)       for (int j = 0; j < m; ++j) ans = (ans + p.a[i][j]) % mod;     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long A, B, x, y, z;     cin >> A >> B >> x >> y >> z;     for (int i = 0; i < x; i++) A = A - 2;     for (int i = 0; i < y; i++) {       A--;       B--;     }     for (int i = 0; i < z; i++) B = B - 3;     long long a = 0, b = 0;     if (A < 0) a = -A;     if (B < 0) b = -B;     cout << (a + b);     return 0;   }