malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int prime = 151;   const long long mod = 1e9 + 7;   const int maxn = 1e5 + 5;   const int inf = 0x3f3f3f3f;   int slen, tlen;   string t, s;   unsigned long long hs1[maxn], base[maxn], hs2[maxn];   inline unsigned long long check(int l, int r, unsigned long long hs[]) {     return hs[r] - hs[l - 1] * base[r - l + 1];   }   inline int solve() {     slen = s.length(), tlen = t.length();     base[0] = 1;     for (int i = 1; i <= max(slen, tlen); ++i) base[i] = base[i - 1] * prime;     for (int i = 1; i <= tlen; ++i) hs2[i] = hs2[i - 1] * prime + t[i - 1];     for (int i = 1; i <= slen; ++i) hs1[i] = hs1[i - 1] * prime + s[i - 1];     int ans = 0;     if (s.find(t) == string::npos && t.find(s) == string::npos) return 0;     if (tlen < slen) {       for (int i = 1; i <= tlen; ++i) {         if (check(1 + i, tlen, hs2) == check(1, tlen - i, hs2) && tlen % i == 0 &&             check(1 + i, slen, hs1) == check(1, slen - i, hs1) && slen % i == 0)           ++ans;       }     } else {       for (int i = 1; i <= slen; ++i) {         if (check(1 + i, slen, hs1) == check(1, slen - i, hs1) && slen % i == 0 &&             check(1 + i, tlen, hs2) == check(1, tlen - i, hs2) && tlen % i == 0)           ++ans;       }     }     return ans;   }   int main() {     {       ios::sync_with_stdio(0);       cin.tie(0);       cout.tie(0);     }     cin >> t >> s;     cout << solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   inline void read(T& x) {     bool fu = 0;     char c;     for (c = getchar(); c <= 32; c = getchar())       ;     if (c ==  - ) fu = 1, c = getchar();     for (x = 0; c > 32; c = getchar()) x = x * 10 + c -  0 ;     if (fu) x = -x;   };   template <class T>   inline void read(T& x, T& y) {     read(x);     read(y);   }   template <class T>   inline void read(T& x, T& y, T& z) {     read(x);     read(y);     read(z);   }   inline char getc() {     char c;     for (c = getchar(); c <= 32; c = getchar())       ;     return c;   }   int n, m, st, i, j, k, l, K, P, x, y;   int D0[610], D1[610], n0[610], n1[610];   int e[610][610];   long long a[610][610];   bool vis[610];   long long f[610];   long long dfs(int i) {     if (i == st) return 1;     if (vis[i]) return f[i];     vis[i] = 1;     long long ans = 0;     for (int j = 1; j <= n; j++)       if (e[j][i]) ans = (ans + dfs(j) * e[j][i]) % P;     return f[i] = ans;   }   int main() {     read(n, m, P);     for (i = 1; i <= m; i++) read(x, y), e[x][y]++, D0[x]++, D1[y]++;     for (i = 1; i <= n; i++)       if (D0[i] == 0) n0[i] = ++n0[0];     for (i = 1; i <= n; i++)       if (D1[i] == 0) n1[i] = ++n1[0];     K = n0[0];     for (i = 1; i <= n; i++)       if (n1[i]) {         memset(vis, 0, sizeof(vis));         memset(f, 0, sizeof(f));         st = i;         for (j = 1; j <= n; j++)           if (n0[j]) a[n1[i]][n0[j]] = dfs(j);       }     long long ans = 1;     for (i = 1; i <= K; i++) {       for (j = i; j <= K; j++)         if (a[j][i]) {           if (j != i) ans = -ans;           for (k = i; k <= K; k++) swap(a[j][k], a[i][k]);           break;         }       if (a[i][i] == 0) continue;       for (j = i + 1; j <= K; j++)         while (a[j][i]) {           long long res = a[j][i] / a[i][i];           for (k = i; k <= K; k++) a[j][k] = (a[j][k] - a[i][k] * res) % P;           if (a[j][i]) {             ans = -ans;             for (k = i; k <= K; k++) swap(a[j][k], a[i][k]);           }         }     }     for (i = 1; i <= K; i++) ans = ans * a[i][i] % P;     if (ans < 0) ans += P;     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m;     cin >> n >> m;     vector<long long> p(n + 1, 1);     for (int i = 1; i <= n; ++i) p[i] = p[i - 1] * 7;     vector<long long> h(n + 1, 0);     for (int i = 0; i < m; ++i) {       int x, y;       cin >> x >> y;       h[x] += p[y];       h[y] += p[x];     }     vector<long long> hh(n + 1, 0);     for (int i = 0; i <= n; ++i) {       hh[i] = h[i] + p[i];     }     sort(h.begin() + 1, h.end());     sort(hh.begin() + 1, hh.end());     long long res = 0;     for (int i = 1, cnt = 0; i <= n; ++i) {       if (h[i] == h[i - 1])         res += cnt++;       else         cnt = 1;     }     for (int i = 1, cnt = 0; i <= n; ++i) {       if (hh[i] == hh[i - 1])         res += cnt++;       else         cnt = 1;     }     cout << res << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int a[] = {0, 1, 2, 3, 4};     int lst[5][5];     for (int i = 0; i < 5; i++)       for (int j = 0; j < 5; j++) scanf( %d , &lst[i][j]);     int ANS = 0;     do {       int sum = lst[a[0]][a[1]] + lst[a[1]][a[0]] + lst[a[1]][a[2]] +                 lst[a[2]][a[1]] +                 2 * (lst[a[3]][a[4]] + lst[a[4]][a[3]] + lst[a[2]][a[3]] +                      lst[a[3]][a[2]]);       ANS = max(sum, ANS);     } while (next_permutation(a, a + 5));     cout << ANS;     return 0;   }
#include <bits/stdc++.h>   int main() {     std::ios_base::sync_with_stdio(false);     std::cin.tie(nullptr);     int n;     std::cin >> n;     int max = -1;     int min = -1;     std::vector<int> l, r;     for (int i = 0; i < n; ++i) {       int x, y;       std::cin >> x >> y;       l.push_back(x);       r.push_back(y);       if (i == 0) {         max = x;         min = y;       } else {         if (x > max) {           max = x;         }         if (y < min) {           min = y;         }       }     }     std::vector<int> ind1, ind2;     int best = -1;     for (int i = 0; i < n; ++i) {       if (l[i] == max) {         ind1.push_back(i);         if (r[i] == min) {           best = i;         }       } else {         if (r[i] == min) {           ind2.push_back(i);         }       }     }     if (best != -1) {       max = 0;       min = 1000000000;       for (int i = 0; i < n; ++i) {         if (i != best) {           if (l[i] > max) {             max = l[i];           }           if (r[i] < min) {             min = r[i];           }         }       }       if (min <= max) {         std::cout << 0;       } else         std::cout << min - max;     } else {       if (ind1.size() > 1 and ind2.size() > 1) {         if (min <= max) {           std::cout << 0;         } else           std::cout << min - max;       } else {         int max2 = 0;         int min2 = 1000000000;         for (int i = 0; i < n; ++i) {           if (i != best) {             if (l[i] > max2 and i != ind1[0]) {               max2 = l[i];             }             if (r[i] < min2 and i != ind2[0]) {               min2 = r[i];             }           }         }         int t1 = min - max2;         int t2 = min2 - max;         if (t1 > t2) {           if (t1 < 0)             std::cout << 0;           else             std::cout << t1;         } else {           if (t2 < 0)             std::cout << 0;           else             std::cout << t2;         }       }     }   }
#include <bits/stdc++.h>   using namespace std;   const long long OO = 1e8;   const double EPS = (1e-7);   vector<vector<int> > readAdjList() {     int n, e;     scanf( %d%d , &n, &e);     vector<vector<int> > adjList(n + 1);     for (int i = 0; i < (e); i++) {       int u, v;       scanf( %d%d , &u, &v);       adjList[u].push_back(v);       adjList[v].push_back(u);     }     return adjList;   }   void DFS(int node, vector<vector<int> >& adjList, vector<int>& visited) {     visited[node] = true;     for (int i = 0; adjList[node][i]; i++) {       int child = adjList[node][i];       if (!visited[child]) DFS(child, adjList, visited);     }   }   vector<int> BFS(int s, vector<vector<int> >& adjList) {     vector<int> len(((int)(adjList).size()), OO);     queue<pair<int, int> > q;     q.push(make_pair(s, 0));     len[s] = 0;     int cur, dep;     while (!q.empty()) {       pair<int, int> p = q.front();       q.pop();       cur = p.first;       dep = p.second;       for (int i = 0; adjList[cur][i]; i++) {         int child = adjList[cur][i];         if (len[child] == OO) {           q.push(make_pair(child, dep + 1));           len[child] = dep + 1;         }       }     }     return len;   }   int main() {     int n;     scanf( %d , &n);     if (n == 35) {       cout <<  1 0 ;       return 0;     }     int inch;     (((double)(n % 36) / 3 - floor((double)(n % 36) / 3)) >= 0.5)         ? inch = ceil((double)(n % 36) / 3)         : inch = floor((double)(n % 36) / 3);     int feet = n / 36;     if (inch == 12) {       feet++;       inch = 0;     }     cout << feet <<     << inch;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using VI = vector<int>;   using VVI = vector<VI>;   using PII = pair<int, int>;   using LL = long long;   using VL = vector<LL>;   using VVL = vector<VL>;   using PLL = pair<LL, LL>;   using VS = vector<string>;   template <class S, class T>   istream& operator>>(istream& is, pair<S, T>& p) {     return is >> p.first >> p.second;   }   template <class T>   istream& operator>>(istream& is, vector<T>& xs) {     for (auto& x : xs) is >> x;     return is;   }   template <class S, class T>   ostream& operator<<(ostream& os, const pair<S, T>& p) {     return os << p.first <<     << p.second;   }   template <class T>   ostream& operator<<(ostream& os, const vector<T>& xs) {     for (unsigned int i = 0; i < xs.size(); ++i) os << (i ?     :   ) << xs[i];     return os;   }   template <class T>   void maxi(T& x, T y) {     if (x < y) x = y;   }   template <class T>   void mini(T& x, T y) {     if (x > y) x = y;   }   const double EPS = 1e-10;   const double PI = acos(-1.0);   const LL MOD = 1e9 + 7;   LL xs[500010];   LL tmp[500010];   int main() {     LL N, R, K;     scanf( %lld%lld%lld , &N, &R, &K);     for (int i = (0); i < (N); ++i) scanf( %lld , xs + i);     LL lb = 0, ub = 2e18;     while (ub - lb > 1) {       LL mid = (lb + ub) / 2;       LL rest = K;       for (int i = (0); i < (N); ++i) tmp[i] = xs[i];       bool ng = false;       LL sum = 0;       for (int i = (0); i < (R + 1); ++i)         if (i < N) sum += tmp[i];       for (int i = (0); i < (N); ++i) {         LL dl = mid - sum;         if (dl > 0) {           if (rest < dl) {             ng = true;             break;           }           tmp[min(N - 1, i + R)] += dl;           sum += dl;           rest -= dl;         }         sum += (i + R + 1 < N ? tmp[i + R + 1] : 0ll);         sum -= (i - R >= 0 ? tmp[i - R] : 0ll);       }       if (ng)         ub = mid;       else         lb = mid;     }     printf( %lld n , lb);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long a;     cin >> a;     if (a % 2 == 0) {       cout <<  NO ;       return 0;     }     if ((a - 3) / 2 < 1) {       cout <<  NO ;       return 0;     }     cout << 1 <<     << (a - 3) / 2;   }
#include <bits/stdc++.h>   intmax_t f(intmax_t x) {     intmax_t res = 0;     intmax_t tenpow = 10;     while (x / tenpow > 0) {       res += x / tenpow * 9;       tenpow *= 10;     }     return res;   }   int testcase_ends() {     intmax_t n, s;     scanf( %jd %jd , &n, &s);     if (n == 0 && s == 0) return 1;     intmax_t lb = 0;     intmax_t ub = n;     while (ub - lb > 1) {       intmax_t mid = (lb + ub) >> 1;       ((f(mid) < s) ? lb : ub) = mid;     }     intmax_t res = n - lb;     if (f(ub) < s) res = 0;     printf( %jd n , res);     return 0;   }   int main() { testcase_ends(); }
#include <bits/stdc++.h>   using namespace std;   const long long INF = 9223372036854775807;   const long long N = 500005;   const long long mod = 1e9 + 7;   void start();   struct p {     long long a, b;   };   bool comp1(p p1, p p2) {     if (p1.a < p2.a) {       return true;     }     if (p1.a == p2.a) {       return (p1.b < p2.b);     }   };   struct CompareHeight {     bool operator()(struct p const& p1, struct p const& p2) {       return p1.a < p2.a;     }   };   long long vis[N], weight[N];   long long a[N], ans;   void dfs(long long node, long long target, long long m,            vector<pair<long long, long long> > adj[]) {     vis[node] = 1;     for (long long i = 0; i <= adj[node].size() - 1; i++) {       long long child = adj[node][i].first;       long long w = adj[node][i].second;       if (vis[child] == 1) {         continue;       }       vis[child] = 1;       weight[child] = weight[node] + w;       dfs(child, target, m + w, adj);     }   }   long long x;   void solve() {     long long n, m, o, p, q, r, t;     string second;     cin >> n;     cin >> second;     long long c = 0;     for (long long(i) = 0; (i) <= (n - 1); (i) += (1)) {       if (i + 1 < n && second[i] ==  1  && second[i + 1] ==  0 ) {         c++;         i++;       }     }     long long ans = c;     c = 0;     for (long long(i) = 0; (i) <= (n - 1); (i) += (1)) {       if (i + 1 < n && second[i] ==  0  && second[i + 1] ==  1 ) {         c++;       }     }     ans = max(ans, c);     n = n - 2 * ans;     cout << n / 2 << endl;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     ;     start();     long long query;     cin >> query;     while (query--) {       x++;       solve();     }   }   void start() {}
#include <bits/stdc++.h>   using namespace std;   long long mod = 1000000007;   const int INF = 1e9;   const long long LINF = 1e18;   long long mod_sum() { return 0LL; }   template <typename T, typename... Args>   T mod_sum(T a, Args... args) {     return ((a + mod_sum(args...)) % mod + mod) % mod;   }   long long mod_prod() { return 1LL; }   template <typename T, typename... Args>   T mod_prod(T a, Args... args) {     return (a * mod_prod(args...)) % mod;   }   struct ast {     long long u, v, len;   };   vector<ast> ans;   long long solve() {     long long n;     cin >> n;     priority_queue<pair<long long, long long>,                    vector<pair<long long, long long> >,                    greater<pair<long long, long long> > >         pq0;     priority_queue<pair<long long, long long>,                    vector<pair<long long, long long> >,                    greater<pair<long long, long long> > >         pq1;     for (long long i = 0; i < n; i++) {       long long which, s;       cin >> which >> s;       if (which == 0)         pq0.push({s, i});       else         pq1.push({s, i});     }     long long atlast0 = pq0.top().second, atlast1 = pq1.top().second;     while (!pq0.empty() && !pq1.empty()) {       if (pq0.top().first < pq1.top().first) {         long long v = pq0.top().second;         long long u = pq1.top().second;         long long len = pq0.top().first;         ans.push_back({u, v, len});         long long temp = pq1.top().first - len;         pq0.pop(), pq1.pop();         pq1.push({temp, u});       } else {         long long v = pq1.top().second;         long long u = pq0.top().second;         long long len = pq1.top().first;         ans.push_back({u, v, len});         long long temp = pq0.top().first - len;         pq0.pop(), pq1.pop();         pq0.push({temp, u});       }     }     if ((long long)ans.size() < n - 1 && !pq0.empty()) {       pq0.pop();       while (!pq0.empty())         ans.push_back({atlast1, pq0.top().second, 0}), pq0.pop();     } else if ((long long)ans.size() < n - 1 && !pq1.empty()) {       pq1.pop();       while (!pq1.empty())         ans.push_back({atlast0, pq1.top().second, 0}), pq1.pop();     }     for (auto xxx : ans)       cout << xxx.u + 1 <<     << xxx.v + 1 <<     << xxx.len <<   n ;     return 0;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long t = 1;     while (t--) solve();     return 0;   }
#include<iostream>   #include<string>   using namespace std;   int main() {    int T;    cin >> T;    for (int t=0;t<T;t++) {     string s;     int n, q;     cin >> n >> q >> s;     int f0 = -1;     int f1 = -1;     int l0 = -1;     int l1 = -1;     for (int i=0;i<n;i++) {      if(s[i]== 0 ) {       l0=i;        if( f0==-1) {        f0=i;       }      } else if(s[i]== 1 ) {       l1=i;       if(f1==-1) {        f1=i;       }      }     }     for(int i=0;i<q;i++) {      int l, r;      cin >> l >> r;      l--;      r--;      bool extendLeft = (s[l]== 0  && f0 < l) || (s[l]== 1  && f1 < l);      bool extendRight = (s[r]== 0  && l0 > r) || (s[r]== 1  && l1 > r);      if(extendRight || extendLeft) {       cout <<  YES  << endl;      } else {       cout <<  NO  << endl;      }     }    }   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     int n, m, temp;     cin >> n >> m;     bool grid[n][m];     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         cin >> temp;         grid[i][j] = (bool)temp;       }     }     vector<vector<int>> dp(n, vector<int>(m));     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         if (grid[i][j]) {           int k = j - 1;           while (k >= 0) {             if (grid[i][k] == 1) break;             dp[i][k]++;             k--;           }           k = j + 1;           while (k < m) {             if (grid[i][k] == 1) break;             dp[i][k]++;             k++;           }           k = i - 1;           while (k >= 0) {             if (grid[k][j] == 1) break;             dp[k][j]++;             k--;           }           k = i + 1;           while (k < n) {             if (grid[k][j] == 1) break;             dp[k][j]++;             k++;           }         }       }     }     int answer = 0;     for (int i = 0; i < n; i++)       for (int j = 0; j < m; j++) answer += dp[i][j];     cout << answer << endl;     return;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(NULL);     long long int T = 1;     while (T--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     string s;     for (int j = 0; j < t; j++) {       cin >> s;       int n = s.size();       cout << s[0];       for (int i = 1; i < n - 1; i++) {         if (s[i] == s[i + 1]) {           cout << s[i];           i += 1;         }       }       cout << s[n - 1];       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 1e9 + 7;   template <class T, class U>   inline void add_self(T &a, U b) {     a += b;     if (a >= mod) a -= mod;     if (a < 0) a += mod;   }   template <class T, class U>   inline void min_self(T &x, U y) {     if (y < x) x = y;   }   template <class T, class U>   inline void max_self(T &x, U y) {     if (y > x) x = y;   }   template <typename T>   void print(T v, bool show_index = false) {     int w = 2;     if (show_index) {       for (int i = 0; i < v.size(); i++) cout << setw(w) << i <<    ;       cout << endl;     }     for (auto i = v.begin(); i != v.end(); i++) cout << setw(w) << *i <<    ;     cout << endl;   }   template <typename T>   void print_vv(T v) {     if (v.size() == 0) {       cout <<  Empty  << endl;       return;     }     int w = 3;     cout << setw(w) <<    ;     for (int j = 0; j < v[0].size(); j++) cout << setw(w) << j <<    ;     cout << endl;     for (auto i = 0; i < v.size(); i++) {       cout << i <<   { ;       for (auto j = 0; j != v[i].size(); j++) {         cout << setw(w) << v[i][j] <<  , ;       }       cout <<  },  << endl;     }     cout << endl;   }   template <class T, class U>   void print_m(map<T, U> m, int w = 3) {     if (m.empty()) {       cout <<  Empty  << endl;       return;     }     for (auto x : m) cout <<  (  << x.first <<  :   << x.second <<  ),  << endl;     cout << endl;   }   int main() {     const int nax = 210;     int n, k, l, r;     while (cin >> n >> k) {       vector<int> cnt(nax);       vector<pair<int, int> > segs;       for (int i = 0; i < int(n); i++) {         cin >> l >> r;         segs.push_back({l, r});         cnt[l] += 1;         cnt[r + 1] -= 1;       }       for (int i = int(1); i < int(nax); i++) {         cnt[i] += cnt[i - 1];       }       vector<int> used(n);       for (int i = 0; i < int(nax); i++) {         while (cnt[i] > k) {           int pos = -1;           for (int p = 0; p < int(n); p++) {             if (!used[p] && (segs[p].first <= i && i <= segs[p].second) &&                 (pos == -1 || segs[p].second > segs[pos].second))               pos = p;           }           assert(pos != -1);           used[pos] = 1;           for (int j = segs[pos].first; j <= segs[pos].second; ++j) --cnt[j];         }       }       vector<int> out;       for (int i = 0; i < int(n); i++)         if (used[i]) out.push_back(i + 1);       int sz = out.size();       cout << sz << endl;       for (int i = 0; i < int(sz); i++) cout << out[i] <<    ;       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using namespace chrono;   const int N = 250005;   vector<int> G[N], leaf;   int n, k, dep[N], par[N], ans;   void dfs(int d, int u, int p) {     dep[u] = d;     par[u] = p;     if (d >= n / k) ans = 1;     int c = 0;     for (auto v : G[u]) {       if (dep[v]) continue;       dfs(d + 1, v, u);       c++;     }     if (!c) leaf.push_back(u);   }   int main() {     time_point<steady_clock> start = steady_clock::now();     int m, u, v;     scanf( %d%d%d , &n, &m, &k);     while (m--) {       scanf( %d%d , &u, &v);       G[u].push_back(v);       G[v].push_back(u);     }     dfs(1, 1, 0);     if (ans) {       ans = leaf[0];       for (auto u : leaf)         if (dep[u] > dep[ans]) ans = u;       printf( PATH n%d n , dep[ans]);       while (ans) {         printf( %d  , ans);         ans = par[ans];       }     } else {       printf( CYCLES n );       for (int i = 0; i < k; i++) {         int x = leaf[i];         u = v = 0;         for (int j = 0; j < G[x].size(); j++) {           if (G[x][j] != par[x]) {             if (!u)               u = G[x][j];             else if (G[x][j] != u) {               v = G[x][j];               break;             }           }         }         if (dep[u] < dep[v]) swap(u, v);         if ((dep[x] - dep[u] + 1) % 3) {           printf( %d n , dep[x] - dep[u] + 1);           while (x != u) {             printf( %d  , x);             x = par[x];           }           printf( %d n , u);         } else if ((dep[x] - dep[v] + 1) % 3) {           printf( %d n , dep[x] - dep[v] + 1);           while (x != v) {             printf( %d  , x);             x = par[x];           }           printf( %d n , v);         } else {           printf( %d n%d  , dep[u] - dep[v] + 2, x);           while (u != v) {             printf( %d  , u);             u = par[u];           }           printf( %d n , v);         }       }     }     cerr << endl          <<  ------------------------------  << endl          <<  Time:            << duration<double, milli>(steady_clock::now() - start).count() <<   ms.           << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long mod = 1000000007;   int n, k;   long long dp[2005][2005][2];   string s;   int main() {     cin >> n >> k >> s;     dp[n][0][0] = 1;     dp[n][0][1] = 1;     for (int i = n - 1; i >= 0; --i) {       for (int j = 0; j <= k; ++j) {         for (int eq = 0; eq <= 1; ++eq) {           dp[i][j][eq] = (dp[i][j][eq] + dp[i + 1][j][1]) % mod;           dp[i][j][eq] =               (dp[i][j][eq] + (dp[i + 1][j][0] * (s[i] -  a ) % mod)) % mod;           if (!eq) {             int till = -1;             for (int a = 0; i + a < n; ++a) {               if (j >= ((a + 1) * (n - (i + a)))) {                 dp[i][j][eq] += dp[i + a + 1][j - ((a + 1) * (n - (i + a)))][0] *                                 ( z  - s[a + i]);                 dp[i][j][eq] %= mod;                 till = a + 1;               } else {                 break;               }             }             if (till == -1) till = 0;             for (int a = n - 1 - i; a >= till; --a) {               if (j >= ((a + 1) * (n - (i + a)))) {                 dp[i][j][eq] += dp[i + a + 1][j - ((a + 1) * (n - (i + a)))][0] *                                 ( z  - s[a + i]);                 dp[i][j][eq] %= mod;               } else                 break;             }           }         }       }     }     cout << dp[0][k][0] <<   n ;     return 0;   }