malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native )   using namespace std;   void JIZZ(string output =   ) {     cout << output;     exit(0);   }   const long double PI = 3.14159265358979323846264338327950288;   const long double eps = 1e-13;   const long long mod = 1e9 + 7;   long long a[200005], pre[200005];   vector<int> good;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     int n;     long long k;     cin >> n >> k;     for (int i = 1; i <= n; ++i) cin >> a[i];     for (int i = 1; i <= n; ++i) pre[i] = pre[i - 1] + a[i];     for (int i = 1; i <= n; ++i)       if (a[i] > 1) good.push_back(i);     good.push_back(n + 1);     if (0) {       long long ans = 0;       for (int i = 1; i <= n; ++i) {         long long s = 0, p = 1;         for (int j = i; j <= n; ++j) {           if (((long double)p) * a[j] > 2e18) break;           p *= a[j], s += a[j];           if (s * k == p) cout << i <<     << j << endl, ++ans;         }       }       cout << ans << endl;     }     long long ans = 0;     for (int i = 1; i <= n; ++i) {       long long p = a[i], s = a[i];       int now = i;       auto ptr = upper_bound(good.begin(), good.end(), i);       if (s * k <= p && p <= (s + *ptr - now) * k && p % k == 0) ++ans;       while (p <= 2e18) {         if (*ptr == n + 1) break;         if (((long double)p) * a[*ptr] > 2e18) break;         p *= a[*ptr];         s += pre[*ptr] - pre[now];         now = *ptr;         ++ptr;         if (s * k <= p && p <= (s + *ptr - now - 1) * k && p % k == 0) ++ans;       }     }     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   long long N, Q;   long long A[1100100], a, b;   vector<pair<long long, long long> > qu[1100100];   long long sol[1100100], dp[1100100];   long long solve(long long I, long long b) {     if (I > N) return 0;     long long ret = A[I];     return ret += solve(I + b, b);   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cin >> N;     for (long long I = 1; I <= N; I++) cin >> A[I];     cin >> Q;     for (long long q = 1; q <= Q; q++) {       cin >> a >> b;       qu[b].push_back(pair<long long, long long>(a, q));     }     for (long long b = 1; b <= N; b++) {       if (b < 300) {         for (long long I = N; I >= 1; I--) {           dp[I] = A[I];           if (I + b <= N) dp[I] += dp[I + b];         }         for (typeof((qu[b]).begin()) it = (qu[b]).begin(); it != (qu[b]).end();              it++)           sol[it->second] = dp[it->first];       } else {         for (typeof((qu[b]).begin()) it = (qu[b]).begin(); it != (qu[b]).end();              it++)           sol[it->second] = solve(it->first, b);       }     }     for (long long q = 1; q <= Q; q++) cout << sol[q] <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX = 100000 + 10;   int n, m;   pair<int, int> s[MAX];   pair<long long, long long> ans;   void update(long long a, long long b) {     if (b <= 0) return;     if (a > ans.first) {       ans.first = a;       ans.second = b;     } else if (a == ans.first)       ans.second += b;   }   void work1() {     int i, mi = n, mm = 0;     long long num = 0;     for ((i) = (1); (i) <= (m); ++(i))       if (s[i].first == 0) {         ++num;         mi = min(mi, s[i].second);         mm = max(mm, s[i].second);       }     long long num_mi = 0, num_mm = 0;     for ((i) = (1); (i) <= (m); ++(i)) {       if (s[i].first == 0 && s[i].second == mi) ++num_mi;       if (s[i].first == 0 && s[i].second == mm) ++num_mm;     }     if (mm == mi) {       update(0, num * (num - 1) * (num - 2) / 6);       return;     }     num -= num_mi;     num -= num_mm;     update((mm - mi) * 2, (num_mi - 1) * num_mi / 2 * num_mm +                               (num_mm - 1) * num_mm / 2 * num_mi +                               num * num_mi * num_mm);   }   int cmp(pair<int, int> a, pair<int, int> b) {     if (a.second != b.second)       return a.second < b.second;     else       return a.first < b.first;   }   void work2() {     sort(s + 1, s + m + 1, cmp);     int i;     long long num0 = 0;     for ((i) = (1); (i) <= (m); ++(i))       if (s[i].first == 0) ++num0;     int largb = 0, numb = 0, tmp = num0;     for ((i) = (1); (i) <= (m); ++(i))       if (s[i].first == 0) {         --tmp;         if (largb != s[i].second)           update(2LL * n + 2 * largb - 2 * s[i].second, (long long)tmp * numb);       } else if (s[i].second == largb)         ++numb;       else if (s[i].second > largb)         largb = s[i].second, numb = 1;     int smallb = n + 1;     numb = 0;     tmp = num0;     for (i = m; i >= 1; --i)       if (s[i].first == 0) {         --tmp;         if (smallb != s[i].second)           update(2LL * n - 2 * smallb + 2 * s[i].second, (long long)tmp * numb);       } else if (s[i].second == smallb)         ++numb;       else if (s[i].second < smallb)         smallb = s[i].second, numb = 1;     map<int, int> hash;     for ((i) = (1); (i) <= (m); ++(i))       if (s[i].first == 0) hash[s[i].second]++;     tmp = 0;     for ((i) = (1); (i) <= (m); ++(i)) {       if (s[i].first == 0)         ++tmp;       else {         long long u = hash[s[i].second];         long long now = (long long)tmp * (num0 - tmp) +                         (long long)u * (u - 1) / 2 + (tmp - u) * u;         update(2LL * n, now);       }     }   }   void work() {     work1();     work2();   }   int main() {     int i;     scanf( %d%d , &n, &m);     for ((i) = (1); (i) <= (m); ++(i)) scanf( %d%d , &s[i].first, &s[i].second);     work();     for ((i) = (1); (i) <= (m); ++(i)) s[i].first ^= 1;     work();     cout << ans.second << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 200005;   const int inf = 1e9 + 7;   int main() {     int n;     scanf( %d , &n);     while (n--) {       int x;       scanf( %d , &x);       if (x <= 3 || x == 5 || x == 7 || x == 11)         puts( -1 );       else {         int ans = 0, tg = x & 3;         if (!tg) ans = max(ans, x / 4);         if (tg == 2) ans = max(ans, 1 + (x - 6) / 4);         if (tg == 1) ans = max(ans, 1 + (x - 9) / 4);         if (tg == 3) ans = max(ans, 2 + (x - 15) / 4);         printf( %d n , ans);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int Maxn = ((int)1e5) + 100;   int arr[Maxn], n;   map<int, int> num, numL, numR;   long long Solve(int a[]) {     int l = 0, r = n - 1;     while (a[l] == a[r] && l < r) ++l, --r;     if (l >= r) return n * 1ll * (n + 1) / 2;     for (int(i) = (l); (i) <= (r); ++(i)) num[a[i]] += 1;     int odds = 0, key = -1;     for (auto it = num.begin(); it != num.end(); ++it)       if ((it->second) & 1) odds += 1, key = it->first;     if (odds > 1) return 0;     int oks = 0, l2 = l - 1;     while (oks < num.size()) {       numL[a[++l2]] += 1;       int _a = numL[a[l2]] << 1;       int _b = _a - 2, _c = num[a[l2]];       if (_a >= _c && _b < _c) ++oks;     }     oks = 0;     int r2 = r + 1;     while (oks < num.size()) {       numR[a[--r2]] += 1;       int _a = numR[a[r2]] << 1;       int _b = _a - 2, _c = num[a[r2]];       if (_a >= _c && _b < _c) ++oks;     }     int mid = (r + l) >> 1;     if (l2 <= mid && (!(n & 1) || a[mid] == key)) {       int g, h;       if (n & 1)         g = mid - 1, h = mid + 1;       else         g = mid, h = mid + 1;       while (a[g] == a[h]) --g, ++h;       l2 = g, r2 = h;     }     long long sum = 0;     sum += (l + 1) * 1ll * (n - l2);     sum += (n - r) * 1ll * (r2 + 1);     sum -= (l + 1) * 1ll * (n - r);     return sum;   }   int main() {     iostream::sync_with_stdio(false);     cin >> n;     for (int(i) = (0); (i) <= (n - 1); ++(i)) cin >> arr[i];     cout << Solve(arr) << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int inf = 1e9;   const long long INF = 1e18;   const int M = 1e9 + 7;   const int maxn = 1e6;   int b[maxn], c[maxn];   signed main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cout.setf(ios::fixed);     cout.precision(10);     int m, k, n, s;     cin >> m >> k >> n >> s;     vector<int> a(m);     for (int i = 0; i < m; ++i) {       cin >> a[i];     }     for (int i = 0; i < s; ++i) {       int x;       cin >> x;       ++b[x];     }     int res = inf;     int l = 0, r = 0, cnt = 0;     int L = 0, R = 0;     while (r < m) {       while (r < m && cnt < s) {         if (c[a[r]] < b[a[r]]) {           ++cnt;         }         ++c[a[r]];         ++r;       }       while (l < m && cnt == s) {         int tl = l / k, tr = (r - 1) / k;         int tot;         if (tl == tr) {           tot = 0;         } else {           tot = r - tl * k - k;         }         if (tot < res) {           L = l;           R = r - 1;           res = tot;         }         c[a[l]]--;         if (c[a[l]] < b[a[l]]) {           --cnt;         }         ++l;       }     }     if ((m - res) / k < n) {       cout << -1 << endl;     } else {       cout << res << endl;       for (int i = R; i >= L - L % k; --i) {         if (res == 0) break;         if (!b[a[i]]) {           cout << i + 1 <<    ;           --res;         } else {           --b[a[i]];         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 100007;   const int maxv = 100000;   long long fac[maxn], fac2[maxn];   map<pair<int, int>, int> save;   int cnt;   long long mypow(int base, int n) {     if (n == 0) return 1;     long long t = mypow(base, n / 2);     t = (t * t) % 1000000007;     if (n & 1)       return (t * base) % 1000000007;     else       return t;   }   long long C(int n, int k) {     long long res = fac[n] * fac2[k] % 1000000007;     res = res * fac2[n - k] % 1000000007;     return res;   }   long long solve(int f, int n) {     if (f == 1) return (n == 1);     if (f == n) return 1;     if (f > n) return 0;     if (save.count(pair<int, int>(f, n))) return save[pair<int, int>(f, n)];     long long res = 0;     for (int i = 2; i * i <= n; i++)       if (n % i == 0) {         int x = i;         res = (res + solve(f, n / x)) % 1000000007;         if (i * i == n) continue;         x = n / i;         res = (res + solve(f, n / x)) % 1000000007;       }     save[pair<int, int>(f, n)] =         (C(n - 1, f - 1) - res + 1000000007) % 1000000007;     return save[pair<int, int>(f, n)];   }   int main() {     fac[0] = 1;     for (int i = 1, _c = maxv; i <= _c; i++) fac[i] = fac[i - 1] * i % 1000000007;     for (int v = 0, _c = maxv; v <= _c; v++)       fac2[v] = mypow(fac[v], 1000000007 - 2);     int q, f, n;     scanf( %d , &q);     for (int i = 0, _a = (q); i < _a; ++i) {       scanf( %d%d , &n, &f);       printf( %I64d n , solve(f, n));     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m, i, j, s1 = 1, s2 = 1, d = 0;     cin >> n >> m;     if (n == 1 && m == 1) {       cout << 0 << endl;       cout << 1 <<     << 1 << endl;       cout << 1 <<     << 1 << endl;       exit(0);     }     if (n == 1 && m == 2) {       cout << 0 << endl;       cout << 1 <<     << 1 << endl;       cout << 1 <<     << 2 << endl;       cout << 1 <<     << 1 << endl;       exit(0);     }     if (n == 2 && m == 1) {       cout << 0 << endl;       cout << 1 <<     << 1 << endl;       cout << 2 <<     << 1 << endl;       cout << 1 <<     << 1 << endl;       exit(0);     }     if (n == 1) {       cout << 1 << endl;       cout << n <<     << m <<     << 1 <<     << 1 << endl;       for (i = 1; i <= m; i++) {         cout << 1 <<     << i << endl;       }       cout << 1 <<     << 1;       exit(0);     }     if (m == 1) {       cout << 1 << endl;       cout << n <<     << m <<     << 1 <<     << 1 << endl;       for (i = 1; i <= n; i++) {         cout << i <<     << 1 << endl;       }       cout << 1 <<     << 1;       exit(0);     }     if (n % 2 != 0 && m % 2 != 0) {       cout << 1 << endl;       cout << n <<     << m <<     << 1 <<     << 1 << endl;       for (i = 1; i <= n; i++) {         if (d == 0) {           for (j = 1; j <= m; j++) {             cout << i <<     << j << endl;           }           d = 1;         } else {           for (j = m; j >= 1; j--) {             cout << i <<     << j << endl;           }           d = 0;         }       }       cout << 1 <<     << 1;     } else {       cout << 0 << endl;       cout << 1 <<     << 1 << endl;       if (n % 2 == 0) {         s2++;         for (i = 1; i <= n; i++) {           if (d == 0) {             for (j = 2; j <= m; j++) {               cout << i <<     << j << endl;             }             d = 1;           } else {             for (j = m; j >= 2; j--) {               cout << i <<     << j << endl;             }             d = 0;           }         }         for (i = n; i >= 1; i--) {           cout << i <<     << 1 << endl;         }       } else {         s2++;         for (i = 1; i <= m; i++) {           if (d == 0) {             for (j = 2; j <= n; j++) {               cout << j <<     << i << endl;             }             d = 1;           } else {             for (j = n; j >= 2; j--) {               cout << j <<     << i << endl;             }             d = 0;           }         }         for (i = m; i >= 1; i--) {           cout << 1 <<     << i << endl;         }       }     }     return 0;   }
#include <bits/stdc++.h>   char T[1 << 21];   int n, m, ar[21][21];   int U[21], V[21], P[21], way[21], minv[21];   int hungarian(int n, int m, int ar[21][21]) {     memset(way, 0, sizeof(way)), memset(U, 0, sizeof(U)), memset(V, 0, sizeof(V)),         memset(P, 0, sizeof(P));     int i, j, i0, i1, j0, j1, x, y, cur, delta, used, lim = (1 << (m + 1)) - 1;     for (i = 1; i <= n; i++) {       used = 0;       P[0] = i, j0 = 0;       for (j = 0; j <= m; j++) minv[j] = (1 << 27);       do {         used |= (1 << j0);         i0 = P[j0], j1 = 0, delta = (1 << 27), x = (used | 1) ^ lim;         while (x) {           y = (-x & x);           j = T[y];           x ^= y;           cur = ar[i0][j] - U[i0] - V[j];           if (cur < minv[j]) {             minv[j] = cur;             way[j] = j0;           }           if (minv[j] < delta) {             delta = minv[j];             j1 = j;           }         }         for (j = 0; j <= m; j++) {           if (used & (1 << j)) {             U[P[j]] += delta;             V[j] -= delta;           } else             minv[j] -= delta;         }         j0 = j1;       } while (P[j0] != 0);       do {         j1 = way[j0];         P[j0] = P[j1];         j0 = j1;       } while (j0 != 0);     }     return -V[0];   }   int fri[21][21], sat[21][21];   int main() {     int i, j, k, x, res, lim, mask;     for (i = 0; i < 21; i++) T[1 << i] = i;     while (scanf( %d , &n) != EOF) {       for (i = 0; i < n; i++) {         for (j = 0; j < n; j++) {           scanf( %d , &fri[i][j]);         }       }       for (i = 0; i < n; i++) {         for (j = 0; j < n; j++) {           scanf( %d , &sat[i][j]);         }       }       res = 0, lim = 1 << n;       for (mask = 0; mask < lim; mask++) {         if (__builtin_popcount(mask) == (n >> 1)) {           for (i = 0; i < n; i++) {             for (j = 0; j < n; j++) {               if (mask & (1 << i))                 ar[i + 1][j + 1] = -fri[i][j];               else                 ar[i + 1][j + 1] = -sat[i][j];             }           }           x = -hungarian(n, n, ar);           if (x > res) res = x;         }       }       printf( %d n , res);     }     return 0;   }
#include <bits/stdc++.h>   int n, m;   int map[1010][1010];   int strpnt[1001000][2];   int q[1001000][2];   int qs, qe;   int stn;   int ans;   int gcd(int x, int y) {     if (y == 0) return x;     return gcd(y, x % y);   }   int main() {     int i, j, k, l, t;     scanf( %d%d , &n, &m);     for (i = 0; i < n; i++) {       for (j = 0; j < m; j++) {         scanf( %d , &map[i + 1][j + 1]);       }     }     n += 2;     m += 2;     k = 0;     for (i = 0; i < n; i++) {       for (j = 0; j < m; j++) {         if (map[i + 1][j + 1] == 1) {           t = 0;           t += map[i][j + 1];           t += map[i + 1][j];           t += map[i + 1][j + 2];           t += map[i + 2][j + 1];           if (t == 1 || t == 3) {             k++;           }           if (t == 0) {             printf( -1 );             return 0;           }         }       }     }     if (k != 0 && k != 2) {       printf( -1 );       return 0;     }     for (i = 0; i < n; i++) {       for (j = 0; j < m; j++) {         if (map[i + 1][j + 1] == 1) {           t = 0;           t += map[i][j + 1];           t += map[i + 1][j];           t += map[i + 1][j + 2];           t += map[i + 2][j + 1];           if (t != 2 || (!(((map[i][j + 1] == 1 && map[i + 2][j + 1] == 1) ||                             (map[i + 1][j] == 1 && map[i + 1][j + 2] == 1))))) {             strpnt[stn][0] = i;             strpnt[stn][1] = j;             stn++;           }         }       }     }     if (stn < 2) {       printf( -1 );       return 0;     }     for (i = 1; i < stn; i++) {       strpnt[i][0] -= strpnt[0][0];       if (strpnt[i][0] < 0) strpnt[i][0] = -strpnt[i][0];       strpnt[i][1] -= strpnt[0][1];       if (strpnt[i][1] < 0) strpnt[i][1] = -strpnt[i][1];       ans = gcd(strpnt[i][0], ans);       ans = gcd(strpnt[i][1], ans);     }     if (ans < 2) {       printf( -1 );       return 0;     }     t = 0;     for (i = 0; i < n; i++) {       for (j = 0; j < m; j++) {         if (map[i][j] == 1) {           t = 1;           break;         }       }       if (t == 1) break;     }     qe = 1;     q[0][0] = i;     q[0][1] = j;     map[i][j] = 0;     for (qs = 0; qs < qe; qs++) {       if (map[q[qs][0] + 1][q[qs][1]] == 1) {         map[q[qs][0] + 1][q[qs][1]] = 0;         q[qe][0] = q[qs][0] + 1;         q[qe][1] = q[qs][1];         qe++;       }       if (map[q[qs][0] - 1][q[qs][1]] == 1) {         map[q[qs][0] - 1][q[qs][1]] = 0;         q[qe][0] = q[qs][0] - 1;         q[qe][1] = q[qs][1];         qe++;       }       if (map[q[qs][0]][q[qs][1] + 1] == 1) {         map[q[qs][0]][q[qs][1] + 1] = 0;         q[qe][0] = q[qs][0];         q[qe][1] = q[qs][1] + 1;         qe++;       }       if (map[q[qs][0]][q[qs][1] - 1] == 1) {         map[q[qs][0]][q[qs][1] - 1] = 0;         q[qe][0] = q[qs][0];         q[qe][1] = q[qs][1] - 1;         qe++;       }     }     for (i = 0; i < n; i++) {       for (j = 0; j < m; j++) {         if (map[i][j] == 1) {           printf( -1 );           return 0;         }       }     }     for (i = 2; i <= ans; i++) {       if (ans % i == 0) printf( %d  , i);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline long long in() {     int32_t x;     scanf( %d , &x);     return x;   }   inline string getStr() {     char ch[1000000];     scanf( %s , ch);     return ch;   }   const long long MOD = 1e9 + 7;   const long long base = 29;   const long long MAX_N = 3e5 + 1;   inline long long divide(long long a, long long b) { return (a + b - 1) / b; }   vector<long long> g[MAX_N];   long long deg[MAX_N];   bool vis[MAX_N];   long long res[MAX_N];   inline void dfs(long long node, long long part) {     if (vis[node] == true) return;     res[node] = part;     long long cnt = 0;     for (long long i = 0; i < g[node].size(); i++) {       long long u = g[node][i];       if (res[node] == res[u]) cnt++;     }     if (cnt > 1) {       res[node] ^= 1;       dfs(node, res[node]);       vis[node] = false;       return;     }     vis[node] = true;     for (long long pt = 0; pt < g[node].size(); pt++) {       long long u = g[node][pt];       if (res[u] == res[node]) {         dfs(u, res[u]);         vis[node] = 0;         return;       }     }     vis[node] = false;   }   int32_t main() {     long long n = in(), m = in();     for (long long i = 0; i < m; i++) {       long long v = in(), u = in();       deg[v]++, deg[u]++;       g[v].push_back(u);       g[u].push_back(v);     }     for (long long i = 1; i <= n; i++) res[i] = 1;     for (long long i = 1; i <= n; i++) {       dfs(i, res[i]);     }     for (long long i = 1; i <= n; i++) cout << res[i];   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     string s;     cin >> s;     int res = 0;     for (int i = 0; i < n; i++) {       res++;       if (i == n - 1) break;       if (s[i] != s[i + 1]) {         i++;       }     }     cout << res <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   int n, x, y, z, x_, y_, z_;   int main() {     cin >> n;     for (int i = 0; i < n; i++) {       cin >> x_ >> y_ >> z_;       x += x_;       z += z_;       y += y_;     }     if (x != 0 || y != 0 || z != 0)       cout <<  NO  << endl;     else       cout <<  YES  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct IInt {     int z;   };   bool cmp(int a, int b) { return a < b; }   bool operator<(IInt a, IInt b) { return a.z > b.z; }   int main() {     int n, m, x, i, ans, ans1;     IInt t;     scanf( %d%d , &n, &m);     vector<int> q;     priority_queue<IInt> w;     for (i = 0; i < m; i++) {       scanf( %d , &x);       q.push_back(x);       t.z = x;       w.push(t);     }     make_heap(q.begin(), q.end(), cmp);     ans = ans1 = 0;     for (i = 0; i < n; i++) {       ans += q[0];       q[0]--;       make_heap(q.begin(), q.end(), cmp);     }     for (i = 0; i < n; i++) {       t = w.top();       w.pop();       ans1 += t.z;       if (t.z == 1) {         continue;       } else {         t.z--;         w.push(t);       }     }     printf( %d %d n , ans, ans1);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2005, M = 2000010;   const long long MOD = 1E9 + 7;   long long Pow(long long a, long long b) {     long long c = 1;     for (; b; a = a * a % MOD, b >>= 1)       if (b & 1) c = c * a % MOD;     return c;   }   struct Node {     int x, y;     bool operator<(const Node &a) const {       return (x != a.x) ? (x < a.x) : (y < a.y);     }   } p[N];   int h, w, n, m;   long long fac[M], fac_inv[M];   long long f[N];   void Init() {     fac[0] = 1;     for (int i = 1; i <= m; ++i) fac[i] = fac[i - 1] * i % MOD;     fac_inv[m] = Pow(fac[m], MOD - 2);     for (int i = m; i; --i) fac_inv[i - 1] = fac_inv[i] * i % MOD;     return;   }   inline long long F(int a, int b) {     return fac[a + b] * fac_inv[a] % MOD * fac_inv[b] % MOD;   }   int main() {     scanf( %d%d%d , &h, &w, &n);     m = h + w;     Init();     for (int i = 1; i <= n; ++i) scanf( %d%d , &p[i].x, &p[i].y);     sort(p + 1, p + n + 1);     for (int i = 1; i <= n; ++i) {       f[i] = F(p[i].x - 1, p[i].y - 1);       for (int j = 1; j < i; ++j)         if (p[j].y <= p[i].y)           f[i] = (f[i] + MOD - f[j] * F(p[i].x - p[j].x, p[i].y - p[j].y) % MOD) %                  MOD;     }     long long res = F(h - 1, w - 1);     for (int i = 1; i <= n; ++i)       res = (res + MOD - f[i] * F(h - p[i].x, w - p[i].y) % MOD) % MOD;     printf( %lld n , res);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 1000000000;   const int MOD = 1000000007;   signed main() {     cin.tie(0), cout.tie(0);     ios::sync_with_stdio(0);     int n, k;     cin >> n >> k;     int a, b, c, d;     cin >> a >> b >> c >> d;     if (k < n + 1 || n <= 4)       cout << -1 <<   n , exit(0);     else {       cout << a <<     << c <<    ;       for (int i = 1; i <= n; i++)         if (i != a && i != b && i != c && i != d) cout << i <<    ;       cout << d <<     << b <<   n ;       cout << c <<     << a <<    ;       for (int i = 1; i <= n; i++)         if (i != a && i != b && i != c && i != d) cout << i <<    ;       cout << b <<     << d <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int h1, a1, c1, h2, a2;     int move_counter = 0;     vector<char> move;     cin >> h1 >> a1 >> c1 >> h2 >> a2;     while (h2 > 0) {       if (h2 - a1 <= 0) {         move.push_back( S );         ++move_counter;         break;       } else {         if (h1 - a2 <= 0) {           h1 += c1;           move.push_back( H );           ++move_counter;         } else {           h2 -= a1;           move.push_back( S );           ++move_counter;         }         h1 -= a2;       }     }     cout << move_counter <<   n ;     for (const auto it : move) {       if (it ==  H )         cout <<  HEAL  <<   n ;       else         cout <<  STRIKE  <<   n ;     }   }