malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   #pragma GCC optimize( Ofast )   #pragma comment(linker,  /stack:200000000 )   using namespace std;   const int mnx = 3e5 + 9;   const int mod = 1e9 + 7;   const long long inf = 1e15 + 4;   long long binpow(long long a, int n) {     long long res = 1;     while (n) {       if (n & 1) res = (res * a) % mod;       a = (a * a) % mod;       n >>= 1;     }     return res % mod;   }   long long fact[mnx], rev[mnx];   void pre() {     fact[0] = rev[0] = 1;     for (int i = 1; i <= 1e5; i++) {       fact[i] = fact[i - 1] * i % mod;       rev[i] = binpow(fact[i], mod - 2) % mod;     }   }   long long cnk(int n, int k) {     if (n < k) return 0;     return (fact[n] * rev[k] % mod) * rev[n - k] % mod;   }   long long n, m, k;   void solve() {     cin >> n >> m >> k;     pre();     cout << cnk(m - 1, k * 2) * cnk(n - 1, k * 2) % mod <<   n ;   }   int main() {     int tt = 1;     while (tt--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int read() {     int x = 0, f = 1;     char c = getchar();     while (c <  0  or c >  9 ) {       if (c ==  - ) f = -f;       c = getchar();     }     while (c >=  0  and c <=  9 ) {       x = x * 10 + c -  0 ;       c = getchar();     }     return x * f;   }   struct EDGE {     int to, Next;   } edge[400100];   struct DOTS {     long long cnt, num[2], all, sum, dpth;     vector<int> sons;   } dot[200100];   int n;   int h[200100], cnt;   long long ans;   bool vis[200100];   void add(int from, int to) {     edge[++cnt].to = to;     edge[cnt].Next = h[from];     h[from] = cnt;   }   void dfs(int t) {     vis[t] = 1;     dot[t].num[0]++;     for (int i = h[t]; i; i = edge[i].Next) {       int v = edge[i].to;       if (!vis[v]) {         dot[t].cnt++;         dot[t].sons.push_back(v);         dot[v].dpth = dot[t].dpth + 1;         dfs(v);         ans += dot[t].num[0] * dot[v].num[1] * 2 * dot[t].sum;         ans %= 1000000007;         ans -= dot[t].num[1] * dot[v].num[0] * 2 * dot[t].sum;         ans %= 1000000007;         dot[t].num[0] += dot[v].num[1];         dot[t].num[1] += dot[v].num[0];       }     }     ans += dot[t].sum;   }   void dp(int t) {     for (int i = 0; i < dot[t].cnt; ++i) {       int v = dot[t].sons[i];       ans += dot[v].num[0] * (dot[1].num[dot[v].dpth & 1] - dot[v].num[0]) * 2 *              dot[v].sum;       ans %= 1000000007;       ans -= dot[v].num[1] * (dot[1].num[(dot[v].dpth ^ 1) & 1] - dot[v].num[1]) *              2 * dot[v].sum;       ans %= 1000000007;       dp(v);     }   }   int main() {     n = read();     for (int i = 1; i <= n; ++i) dot[i].sum = read();     for (int i = 1; i < n; ++i) {       int u = read();       int v = read();       add(u, v);       add(v, u);     }     dfs(1);     dp(1);     ans %= 1000000007;     ans += 1000000007;     ans %= 1000000007;     printf( %lld , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int n, m, count = 0;     cin >> n >> m;     char x;     vector<int> r, c;     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         cin >> x;         if (x ==  S ) {           r.push_back(i);           c.push_back(j);         }       }     }     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         if ((find(r.begin(), r.end(), i) != r.end()) &&             (std::find(c.begin(), c.end(), j) != c.end())) {           continue;         } else {           count++;         }       }     }     cout << count;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, a[11] = {0}, i, maxx, c;     cin >> n;     for (i = 1; i <= n; i++) {       cin >> a[i];       if (i == 1)         maxx = a[1];       else         maxx = max(a[i], maxx);     }     printf( %d , maxx ^ a[n]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, ans, temp;   set<int> st;   int main() {     ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);     ;     cin >> n >> m;     ans = n + m;     temp = 2;     while (n) {       n -= (temp % 6 != 0);       st.insert(temp);       temp += 2;     }     temp = 3;     while (m) {       m -= (temp % 6 != 0);       st.insert(temp);       temp += 3;     }     for (auto i : st) {       ans--;       if (!ans) return cout << i <<   n , 0;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int p = 1000 * 1000 * 1000 + 7;   int main() {     int n, m;     vector<long long> fact(1000001);     fact[0] = 1;     for (int i = 1; i < 1000001; i++) fact[i] = (i * fact[i - 1]) % p;     cin >> n >> m;     vector<pair<int, int>> v(m);     for (int i = 0; i < n; i++) {       int k;       cin >> k;       for (int j = 0; j < k; j++) {         int l;         cin >> l;         l--;         v[l].first *= p;         v[l].first += i + 1;         v[l].second *= 2348621;         v[l].second += i + 1;       }     }     map<pair<int, int>, int> f;     for (int i = 0; i < m; i++) f[v[i]]++;     long long ans = 1;     for (map<pair<int, int>, int>::iterator a = f.begin(); a != f.end(); a++)       ans = (fact[(*a).second] * ans) % p;     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   string arr[10] = { 0 ,  0 ,  2 ,  3 ,  322 ,  5 ,  53 ,  7 ,  7222 ,  7332 };   int main() {     int x;     cin >> x;     char a[x];     string s;     for (int i = 0; i < x; i++) {       cin >> a[i];       if (a[i] !=  0  && a[i] !=  1 ) s += arr[a[i] -  0 ];     }     sort(s.rbegin(), s.rend());     cout << s;   }
#include <bits/stdc++.h>   using namespace std;   vector<pair<long long, pair<long long, long long> > > edges;   vector<long long> wt(100005);   long long sz[100005], parent[100005];   long long ans = 0;   long long n, m;   void make_set() {     for (long long i = 1; i <= n; i++) {       sz[i] = 1;       parent[i] = i;     }   }   long long findParent(long long x) {     if (x == parent[x]) return x;     return findParent(parent[x]);   }   void merge_sets(long long x, long long y, long long w) {     x = findParent(x);     y = findParent(y);     if (x == y) return;     ans += w * sz[x] * sz[y];     if (sz[x] > sz[y]) {       parent[y] = x;       sz[x] += sz[y];     } else {       parent[x] = y;       sz[y] += sz[x];     }   }   int main() {     cin >> n >> m;     for (long long i = 1; i <= n; i++) cin >> wt[i];     for (long long i = 1; i <= m; i++) {       long long x, y;       cin >> x >> y;       edges.push_back(make_pair(min(wt[x], wt[y]), make_pair(x, y)));     }     sort(edges.begin(), edges.end());     reverse(edges.begin(), edges.end());     make_set();     for (long long i = 0; i < m; i++) {       merge_sets(edges[i].second.first, edges[i].second.second, edges[i].first);     }     double anss = (double)ans;     anss /= (double)n;     anss /= (double)(n - 1);     anss *= 2.00;     cout << fixed << setprecision(10) << anss << endl;     return 0;   }
#include <bits/stdc++.h>   const int P = (1 << 30) - 1;   int a, b, c, p[2005], vis[2005];   std::unordered_map<long long, int> mmp[2005];   void sieve(int n) {     vis[0] = vis[1] = 1;     for (int i = 2; i <= n; ++i) {       if (!vis[i]) p[++*p] = i;       for (int j = 1; j <= *p && i * p[j] <= n; ++j) {         vis[i * p[j]] = 1;         if (i % p[j] == 0) break;       }     }   }   int dp(int kk1, int kk2, int kk3, int pid) {     if (pid == 0) return 1;     long long ha = 1ll * kk1 * (a + 1) * (a + 1) + 1ll * kk2 * (a + 1) + kk3;     if (mmp[pid].count(ha)) return mmp[pid][ha];     int ans = 0;     int k1 = 1, k2 = 1, k3 = 1, k4 = 0;     while (k1 <= kk1) {       k2 = 1;       int k5 = 0;       while (k2 <= kk2) {         k3 = 1;         int k6 = 0;         while (k3 <= kk3) {           (ans +=            1ll * dp(kk1 / k1, kk2 / k2, kk3 / k3, pid - 1) * (k4 + k5 + k6 + 1) &            P) &= P;           k3 *= p[pid], ++k6;         }         k2 *= p[pid], ++k5;       }       k1 *= p[pid], ++k4;     }     return mmp[pid][ha] = ans;   }   int main() {     scanf( %d%d%d , &a, &b, &c);     if (a < b) a ^= b ^= a ^= b;     if (a < c) a ^= c ^= a ^= c;     sieve(a);     printf( %d n , dp(a, b, c, *p));     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( Ofast , 3,  inline )   using namespace std;   string s, t;   int n;   void pairr() {     if (cin >> t) {       s += t;       if (t ==  pair ) s +=  < , pairr(), s +=  , , pairr(), s +=  > ;     } else {       cout <<  Error occurred ;       exit(0);     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cin >> n;     pairr();     if (cin >> t) {       cout <<  Error occurred ;       return 0;     }     cout << s;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string s;   int m, ch[1002];   int gt(int bal, int prv, int st) {     if (st == m) return ch[st] = 11;     if (bal <= 0) {       for (int i = 1; i <= 10; i++) {         if (i != prv && s[i] ==  1  && bal + i > 0) {           int t = gt(bal + i, i, st + 1);           if (t) return ch[st] = i;         }       }       return 0;     }     for (int i = 1; i <= 10; i++) {       if (i != prv && s[i] ==  1  && bal - i < 0) {         int t = gt(bal - i, i, st + 1);         if (t) return ch[st] = i;       }     }     return 0;   }   int main() {     memset(ch, -1, sizeof(ch));     cin >> s >> m;     s =     + s;     int to = gt(0, 0, 0);     if (ch[0] == -1)       cout <<  NO ;     else {       int k = 0;       cout <<  YES n ;       while (k < m) {         cout << ch[k] <<    ;         k++;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, a[10000], m, x, v[10000], sol[10000];   void g(int n) {     for (int i = 2; i <= 1000; i++) {       for (int q = i; q <= 1000; q++) {         if (q % i != 0 && i * q <= 1000) v[i * q] = 1;       }     }   }   int main() {     int k = 0;     cin >> n;     g(n);     for (int i = 2; i <= n; i++) {       if (v[i] == 0) {         sol[k] = i;         k++;       }     }     cout << k << endl;     for (int i = 0; i < k; i++) {       cout << sol[i] <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       int n, k;       cin >> n >> k;       char arr[] = { a ,  b ,  c ,  d ,  e ,  f ,  g ,  h ,  i ,                      j ,  k ,  l ,  m ,  n ,  o ,  p ,  q ,  r ,                      s ,  t ,  u ,  v ,  w ,  x ,  y ,  z };       int i = 0;       while (n--) {         cout << arr[i];         i++;         if (i == k) {           i = 0;         }       }       cout << endl;     }   }
#include <bits/stdc++.h>   int n, m;   int len[(1010)], val[(1010)], mxl[(1010)], cost[(1010)], dp[(1010)][(1010)];   char a[(1010)], b[(1010)][(1010)];   std::pair<int, int> lab[(1010)];   int main() {     scanf( %s , a);     m = strlen(a);     std::reverse(a, m + a);     for (int i = m; i < (1002) + 1; ++i) {       a[i] =  0 ;     }     scanf( %d , &n);     for (int i = 0; i < n; ++i) {       scanf( %s , b[i]);       len[i] = strlen(b[i]);       std::reverse(b[i], len[i] + b[i]);       for (int j = len[i]; j < (1002) + 1; ++j) {         b[i][j] =  0 ;       }     }     for (int i = 0; i < 10; ++i) {       scanf( %d , cost + i);     }     memset(dp, 0xee, sizeof(dp));     dp[0][0] = 0;     for (int i = 0; i < n; ++i) {       lab[i] = {0, i};     }     for (int i = 0; i < (1002) + 1; ++i) {       int l = 0, r = 9;       if (i == m - 1) {         l = 1;       }       if (isdigit(a[i])) {         l = r = a[i] -  0 ;       }       for (int j = 0; j < n; ++j) {         val[j] = b[lab[j].second][i] -  0 ;         mxl[j] = std::max(m, len[lab[j].second]);       }       for (int k = l; k < r + 1; ++k) {         int c2 = 0, d2 = 0;         for (int j = 0; j < n; ++j) {           c2 += (val[j] + k >= 10);           d2 += (i >= mxl[j]) ? 0 : cost[(val[j] + k) % 10];         }         for (int j = 0; j < n + 1; ++j) {           dp[i + 1][c2] = std::max(dp[i + 1][c2], dp[i][j] + d2);           if (j < n) {             c2 -= (val[j] + k >= 10),                 d2 -= (i >= mxl[j]) ? 0 : cost[(val[j] + k) % 10];             c2 += (val[j] + k + 1 >= 10), d2 += cost[(val[j] + k + 1) % 10];           }         }       }       for (int j = 0; j < n; ++j) {         lab[j] = {val[j] * (n + 1) + n - j, lab[j].second};       }       std::sort(lab, n + lab, std::greater<std::pair<int, int> >());     }     printf( %d n , dp[(1002) + 1][0]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long s[200005], e[200005];   long long win(long long s, long long e) {     if (e & 1) {       if (s & 1) return 0;       return 1;     }     if (s > e / 2) {       if (s & 1) return 1;       return 0;     }     if (s > e / 4) return 1;     return win(s, e >> 2);   }   long long lose(long long s, long long e) {     if (s > e / 2) return 1;     return win(s, e >> 1);   }   int main() {     long long i, n, j, k, t, m, w, l, cur = 0;     scanf( %lld , &t);     for (i = 1; i <= t; i++) scanf( %lld%lld , &s[i], &e[i]);     for (i = 1; i <= t; i++) {       w = win(s[i], e[i]);       l = lose(s[i], e[i]);       w ^= cur;       l ^= cur;       if (w == l) break;       if (w)         cur = 1;       else         cur = 0;     }     printf( %lld %lld n , w, l);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     std::ios::sync_with_stdio(0);     long long n, m;     cin >> n >> m;     vector<long long> a, b;     vector<long long> sum1, sum2;     long long prev = 0;     for (int i = 0; i < n; i++) {       long long x;       cin >> x;       prev += x;       a.push_back(x);       sum1.push_back(prev);     }     prev = 0;     for (int i = 0; i < m; i++) {       long long x;       cin >> x;       prev += x;       b.push_back(x);       sum2.push_back(prev);     }     long long z;     cin >> z;     vector<long long> dp1, dp2;     for (int l = 1; l <= n; l++) {       long long mini = sum1[l - 1];       for (int i = l; i < sum1.size(); i++) {         mini = min(sum1[i] - sum1[i - l], mini);       }       dp1.push_back(mini);     }     for (int l = 1; l <= m; l++) {       long long mini = sum2[l - 1];       for (int i = l; i < sum2.size(); i++) {         mini = min(sum2[i] - sum2[i - l], mini);       }       dp2.push_back(mini);     }     long long prod = 0;     for (long long i = 0; i < dp1.size(); i++) {       for (long long j = 0; j < dp2.size(); j++) {         if (dp1[i] * dp2[j] <= z) {           prod = max((i + 1) * (j + 1), prod);         }       }     }     cout << prod;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = (int)(1e2 + 5);   int n, m, k;   int grid[N][N];   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cin >> n >> m >> k;     for (int(i) = (1); (i) <= (n); (i)++)       for (int(j) = (1); (j) <= (m); (j)++) cin >> grid[i][j];     int score = 0, updates = 0;     for (int(j) = (1); (j) <= (m); (j)++) {       int col_score = 0;       int col_update = 0;       int update = 0;       for (int(i) = (1); (i) <= (n); (i)++) {         if (i - 1 >= 1) update += grid[i - 1][j];         if (grid[i][j] == 1) {           int temp_score = 0;           for (int q = i; q < i + k && q <= n; q++) temp_score += grid[q][j];           if (temp_score > col_score) {             col_score = temp_score;             col_update = update;           }         }       }       score += col_score;       updates += col_update;     }     cout << score <<     << updates;     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( O3 )   using namespace std;   template <class c>   struct rge {     c b, e;   };   template <class c>   rge<c> range(c i, c j) {     return rge<c>{i, j};   }   template <class c>   auto dud(c* x) -> decltype(cerr << *x, 0);   template <class c>   char dud(...);   struct debug {     template <class c>     debug& operator<<(const c&) {       return *this;     }   };   const long long MOD = 1e9 + 7;   const long long N = 1e6 + 10;   const long long INF = 1e18 + 10;   bool isPrime(long long x) {     if (x <= 1) return false;     for (long long i = 2; i * i <= x; i++) {       if (x % i == 0) return false;     }     return true;   }   vector<bool> prime(N, true);   vector<long long> primes;   void seive() {     prime[0] = prime[1] = false;     for (long long i = 2; i * i <= N; i++) {       if (prime[i]) {         for (long long j = i + i; j < N; j += i) prime[j] = false;       }     }     for (long long i = 0; i < N; i++) {       if (prime[i]) {         primes.emplace_back(i);       }     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     seive();     long long n;     cin >> n;     if (isPrime(n)) {       cout << 1 << endl;       cout << n << endl;       return 0;     }     long long cur = n;     while (cur--) {       if (isPrime(cur)) {         debug() <<   [                  <<  cur                      :                   << (cur) <<  ]  ;         if (cur + 2 == n) {           cout << 2 << endl;           cout << 2 <<     << cur << endl;           return 0;         }         int target = n - cur;         debug() <<   [                  <<  target                      :                   << (target) <<  ]  ;         int L = 0, R = (int)primes.size() - 1;         while (L <= R) {           if (primes[L] + primes[R] == target) {             cout << 3 << endl;             cout << primes[L] <<     << primes[R] <<     << cur << endl;             return 0;           } else if (primes[L] + primes[R] > target)             R--;           else {             debug() <<   [                      <<  L                          :                       << (L)                     <<  ]                            [                      <<  R                          :                       << (R) <<  ]  ;             debug() <<   [                      <<  primes[L]                          :                       << (primes[L])                     <<  ]                            [                      <<  primes[R]                          :                       << (primes[R]) <<  ]  ;             L++;           }         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   signed main() {     long long n;     cin >> n;     char s;     long long cnt = 0;     while (cin >> s) {       cnt += s ==  8 ;     }     long long ans = 0;     for (long long i = 0; i <= cnt; ++i) {       if (min(i, (n - i) / 10) > ans) ans = min(i, (n - i) / 10);     }     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0), cout.tie(0);     long long n, m, l;     cin >> n >> m >> l;     vector<long long> a(n);     vector<pair<long long, long long>> lr(n);     long long ans = 0, old = -1000;     long long flag = 0;     for (long long i = 0; i < n; i++) {       cin >> a[i];       if (a[i] > l) {         if (flag == 0) ans++;         flag = 1;       }       if (a[i] <= l && flag == 1) {         flag = 0;       }     }     while (m--) {       long long tp;       cin >> tp;       if (tp == 0) {         cout << ans << endl;       } else {         long long p, d;         cin >> p >> d;         if (n > 1) {           if (a[p - 1] <= l && a[p - 1] + d > l) {             if (p - 1 > 0 && p - 1 < n - 1) {               if (a[p - 2] > l && a[p] > l)                 ans--;               else if (a[p - 2] <= l && a[p] > l)                 ans += 0;               else if (a[p - 2] > l && a[p] <= l)                 ans += 0;               else                 ans++;             } else if (p - 1 == 0) {               if (a[p] > l)                 ans += 0;               else if (a[p] <= l)                 ans++;             } else {               if (a[p - 2] > l)                 ans += 0;               else if (a[p - 2] <= l)                 ans++;             }           }         } else {           if (a[p - 1] <= l && a[p - 1] + d > l) ans++;         }         a[p - 1] += d;       }     }     return 0;   }
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:200000000 )   using namespace std;   char a[105][105];   int n, m;   bool u[105][105];   int main() {     memset(u, false, sizeof(u));     scanf( %d %d n , &n, &m);     for (int i = 0; i < n; i++, scanf(  n ))       for (int j = 0; j < m; j++) scanf( %c , &a[i][j]);     for (int i = 0; i < n; i++)       for (int j = 0; j < m; j++) {         for (int ix = 0; ix < m; ix++)           if (ix != j && a[i][ix] == a[i][j]) u[i][ix] = u[i][j] = true;         for (int ix = 0; ix < n; ix++)           if (ix != i && a[ix][j] == a[i][j]) u[ix][j] = u[i][j] = true;       }     for (int i = 0; i < n; i++)       for (int j = 0; j < m; j++) {         if (!u[i][j]) putchar(a[i][j]);       }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int v[1005][1005];   long long c[1005][1005], sum[1005][1005], t[1005][1005];   int main() {     int n = 0, m = 0, a = 0, b = 0;     scanf( %d%d%d%d , &n, &m, &a, &b);     for (int i = 1; i <= n; ++i) {       for (int j = 1; j <= m; ++j) {         scanf( %d , &v[i][j]);         sum[i][j] = sum[i][j - 1] + sum[i - 1][j] - sum[i - 1][j - 1] +                     (long long)v[i][j];       }     }     vector<pair<long long, pair<int, int>>> res;     set<pair<long long, pair<int, int>>> cost;     for (int i = 1; i <= n; ++i) {       deque<long long> q;       for (int j = m; j >= 1; --j) {         while (!q.empty() && v[i][q.back()] > v[i][j]) {           q.pop_back();         }         q.push_back(j);         while (q.front() >= j + b) {           q.pop_front();         }         t[i][j] = v[i][q.front()];       }     }     for (int i = 1; i <= m; ++i) {       deque<long long> q;       for (int j = n; j >= 1; --j) {         while (!q.empty() && t[q.back()][i] > t[j][i]) {           q.pop_back();         }         q.push_back(j);         while (q.front() >= j + a) {           q.pop_front();         }         c[j][i] = t[q.front()][i];       }     }     for (int i = 1; i + a - 1 <= n; ++i) {       for (int j = 1; j + b - 1 <= m; ++j) {         long long tmp = sum[i + a - 1][j + b - 1] - sum[i + a - 1][j - 1] -                         sum[i - 1][j + b - 1] + sum[i - 1][j - 1] -                         (long long)a * b * c[i][j];         cost.insert(make_pair(tmp, make_pair(i, j)));       }     }     auto it = cost.begin();     while (it != cost.end()) {       while (it != cost.end() && c[it->second.first][it->second.second] == -1) {         ++it;       }       if (it == cost.end()) {         break;       }       res.push_back(*it);       int row = it->second.first, col = it->second.second;       int rMin = max(row - a + 1, 0), cMin = max(col - b + 1, 0),           rMax = min(row + a - 1, n - (a - 1)),           cMax = min(col + b - 1, m - (b - 1));       for (int i = rMin; i <= rMax; ++i) {         for (int j = cMin; j <= cMax; ++j) {           c[i][j] = -1;         }       }     }     printf( %d n , res.size());     for (int i = 0; i < res.size(); ++i) {       printf( %d %d %I64d n , res[i].second.first, res[i].second.second,              res[i].first);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string a, p, s;   bool suff[2002][2002];   bool pref[2002][2002];   long long int hash1[2002][2002];   long long int hash2[2002][2002];   set<pair<int, int> > ans;   int main() {     cin >> a >> p >> s;     long long int mod1 = 1000000007;     long long int mod2 = 1000003;     for (int i = 0; i < a.size(); i++) {       pref[i][p.size() - 1] = (a[i] == p[p.size() - 1]);       suff[i][s.size() - 1] = (a[i] == s[s.size() - 1]);     }     for (int i = p.size() - 2; i >= 0; i--)       for (int j = 0; j < a.size() - 1; j++)         pref[j][i] = pref[j + 1][i + 1] && (a[j] == p[i]);     for (int i = s.size() - 2; i >= 0; i--)       for (int j = 0; j < a.size() - 1; j++)         suff[j][i] = suff[j + 1][i + 1] && (a[j] == s[i]);     int l = max(p.size(), s.size());     for (int i = 0; i < a.size(); i++) {       hash1[i][i] = a[i] -  a ;       hash2[i][i] = 0;       for (int j = i + 1; j < a.size(); j++) {         hash1[i][j] = (hash1[i][j - 1] * 26 + a[j] -  a ) % mod1;         hash2[i][j] = j - i;       }     }     for (int i = 0; i < a.size(); i++)       for (int j = i + l - 1; j < a.size(); j++)         if (pref[i][0] && suff[j - s.size() + 1][0])           ans.insert(make_pair(hash1[i][j], hash2[i][j]));     cout << ans.size() << endl;     return 0;   }