malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int N;   set<pair<int, int>> E[202020];   signed long long ntot[202020];   int vis[202020];   vector<pair<int, signed long long>> V;   map<pair<int, int>, int> M;   vector<signed long long> chi[202020];   void dfs(int cur, signed long long tot) {     if (vis[cur]) return;     vis[cur] = 1;     V.push_back({cur, tot});     for (auto& e : E[cur]) dfs(e.first, tot + e.second);   }   signed long long X[202020], L[202020];   signed long long Rdia[202020], Rma[202020];   signed long long Ldia[202020], Lma[202020];   signed long long tma;   void solve() {     int i, j, k, l, r, x, y;     string s;     cin >> N;     for (i = 0; i < (N); i++) {       cin >> x >> y >> r;       E[x - 1].insert({y - 1, r});       E[y - 1].insert({x - 1, r});       M[{x - 1, y - 1}] = M[{y - 1, x - 1}] = r;     }     queue<int> Q;     for (i = 0; i < (N); i++)       if (E[i].size() == 1) Q.push(i);     while (Q.size()) {       int cur = Q.front();       Q.pop();       auto r = *E[cur].begin();       E[cur].clear();       int tar = r.first;       int co = r.second;       E[tar].erase({cur, co});       chi[cur].push_back(0);       chi[cur].push_back(0);       sort((chi[cur].begin()), (chi[cur].end()));       reverse((chi[cur].begin()), (chi[cur].end()));       tma = max(tma, chi[cur][0] + chi[cur][1]);       chi[tar].push_back(chi[cur][0] + co);       ntot[cur] = -1;       if (E[tar].size() == 1) Q.push(tar);     }     for (i = 0; i < (N); i++)       if (ntot[i] >= 0) {         chi[i].push_back(0);         chi[i].push_back(0);         sort((chi[i].begin()), (chi[i].end()));         reverse((chi[i].begin()), (chi[i].end()));         tma = max(tma, chi[i][0] + chi[i][1]);         ntot[i] = chi[i][0];       }     for (i = 0; i < (N); i++)       if (ntot[i] >= 0) {         dfs(i, 0);         break;       }     int C = V.size();     for (i = 0; i < (C); i++) {       X[i] = V[i].second;       L[i] = ntot[V[i].first];     }     signed long long tot = V.back().second + M[{V[0].first, V.back().first}];     signed long long mi = 1LL << 60;     signed long long RR = 0, LL = 1LL << 60;     for (i = C - 1; i >= 0; i--) {       Rma[i] = max(Rma[i + 1], tot - X[i] + L[i]);       Rdia[i] = max({Rdia[i + 1], RR - X[i] + L[i], L[i]});       RR = max(RR, X[i] + L[i]);     }     for (i = 0; i < (C); i++) {       Lma[i] = max(i ? Lma[i - 1] : 0, X[i] + L[i]);       Ldia[i] = max({i ? Ldia[i - 1] : 0, X[i] + L[i] - LL, L[i]});       LL = min(LL, X[i] - L[i]);       if (i == C - 1) {         mi = min(mi, Ldia[i]);       } else {         mi = min(mi, max({Ldia[i], Rdia[i + 1], Lma[i] + Rma[i + 1]}));       }     }     cout << max(tma, mi) << endl;   }   int main(int argc, char** argv) {     string s;     int i;     if (argc == 1) ios::sync_with_stdio(false), cin.tie(0);     for (i = 0; i < (argc - 1); i++) s += argv[i + 1], s +=   n ;     for (i = 0; i < (s.size()); i++) ungetc(s[s.size() - 1 - i], stdin);     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool cmp(long long a, long long b) { return (a > b); }   long long ceil(const long long &a, const long long &b) {     if (a % b == 0) return a / b;     return a / b + 1;   }   long long mod = 1000000007;   const long long N = 105;   string s;   long long n1;   long long res;   long long dp[N][60][2][2 * N];   long long solve(long long i, long long k, long long cnt = 0,                   long long z = 100) {     if (i == n1) {       if (k % 2 == 0) {         res = max(res, abs(z - 100));       }       return 0;     }     if (dp[i][k][cnt][z] != -1) {       return dp[i][k][cnt][z];     }     long long k1 = 0, k2 = 0;     if (s[i] ==  F ) {       if (k > 0) {         if (cnt % 2 == 0) {           k1 = 1 + solve(i + 1, k, 0, z + 1);           k2 = solve(i + 1, k - 1, 1, z);         } else {           k1 = -1 + solve(i + 1, k, 1, z - 1);           k2 = solve(i + 1, k - 1, 0, z);         }       } else {         if (cnt % 2 == 0) {           k1 = 1 + solve(i + 1, k, 0, z + 1);         } else {           k1 = -1 + solve(i + 1, k, 1, z - 1);         }       }     } else {       if (k > 0) {         if (cnt % 2 == 0) {           k1 = solve(i + 1, k, 1, z);           k2 = 1 + solve(i + 1, k - 1, 0, z + 1);         } else {           k1 = solve(i + 1, k, 0, z);           k2 = -1 + solve(i + 1, k - 1, 1, z - 1);         }       } else {         if (cnt % 2 == 0) {           k1 = solve(i + 1, k, 1, z);         } else {           k1 = solve(i + 1, k, 0, z);         }       }     }     return dp[i][k][cnt][z] = max(abs(k1), abs(k2));   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long n;     cin >> s >> n;     n1 = s.size();     memset(dp, -1, sizeof(dp));     long long x = solve(0, n);     cout << res;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool s[] = {1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1,               0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0};   int main() {     string str;     cin >> str;     for (int x = 0; x < str.length() / 2; x++) {       if (str[x] != str[str.length() - 1 - x]) {         cout <<  NO  << endl;         return 0;       }     }     for (int x = 0; x < str.length(); x++) {       if (!s[str[x] -  A ]) {         cout <<  NO  << endl;         return 0;       }     }     cout <<  YES  << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX = 1e6 + 5;   int n;   long long int a[MAX], BIT[MAX];   void update(int idx, long long int val) {     for (; idx <= n; idx += (idx & (-idx))) {       BIT[idx] += val;     }   }   long long int sum(int idx) {     idx--;     long long int sumi = 0;     for (; idx > 0; idx -= (idx & (-idx))) {       sumi += BIT[idx];     }     return sumi;   }   int main() {     scanf( %d , &n);     int l[n], r[n];     map<long long int, int> make_pair;     for (int i = 0; i < n; i++) {       scanf( %I64d , &a[i]);       make_pair[a[i]]++;       l[i] = make_pair[a[i]];     }     make_pair.clear();     for (int i = n - 1; i >= 0; i--) {       make_pair[a[i]]++;       r[i] = make_pair[a[i]];     }     long long int ans = 0;     for (int i = n - 1; i >= 0; i--) {       ans += sum(l[i]);       update(r[i], 1);     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, k, sumk;     cin >> n >> k;     k--;     int out[500][500];     sumk = 0;     int current = n * n;     for (int i = 0; i < n; ++i) {       for (int j = n - 1; j >= k; --j) {         out[i][j] = current;         if (j == k) {           sumk += current;         }         current--;       }     }     for (int i = 0; i < n; ++i) {       for (int j = k - 1; j >= 0; --j) {         out[i][j] = current;         current--;       }     }     cout << sumk << endl;     for (int i = 0; i < n; ++i) {       for (int j = 0; j < n; ++j) {         cout << out[i][j] <<    ;       }       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double PI = acos(-1.0);   const double EPS = 1E-9;   const int INF = (int)1E9;   int deg[2005];   long long w[2005][2005];   int main() {     int N, K;     long long sum = 0, x;     cin >> N >> K;     memset(deg, 0, sizeof(deg));     for (int i = 0; i < (N); i++) {       for (int j = (i + 1); j <= (N - 1); j++) {         scanf( %I64d , &w[i][j]);         if (w[i][j] != -1) {           deg[i]++;           deg[j]++;         }       }     }     for (int i = 0; i < (N); i++) {       for (int j = (i + 1); j <= (N - 1); j++) {         if (w[i][j] != -1) {           if (K == 1 || K == N - 1) {             sum += w[i][j] * 2;           } else {             sum += w[i][j] * (deg[i] + deg[j] - 2);           }         }       }     }     cout << sum / (K == 2 ? N * (N - 1) / 2 : N) << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 5 * 1e5 + 5;   const int M = 2e6 + 5;   vector<int> a[M], b[M];   vector<int> c[M], d[M];   int vis[M];   int n, w, cnt;   int main() {     scanf( %d%d , &n, &w);     w--;     for (int i = 1; i <= n; i++) {       int k;       scanf( %d , &k);       a[i].resize(k);       for (int j = 0; j < k; j++) {         int g;         scanf( %d , &g);         a[i][j] = g - 1;       }     }     for (int i = 1; i < n; i++) {       int up = min(a[i].size(), a[i + 1].size());       bool flag = false;       for (int j = 0; j < up; j++) {         if (a[i][j] > a[i + 1][j]) {           b[a[i][j]].push_back(a[i + 1][j]);           flag = true;           break;         } else if (a[i][j] < a[i + 1][j]) {           b[a[i][j]].push_back(a[i + 1][j]), flag = true;           break;         }       }       if (!flag && a[i].size() > a[i + 1].size()) {         puts( -1 );         return 0;       }     }     for (int i = 0; i < 1e6; i++) {       if (!b[i].size()) continue;       int mx = -1, mn = 1e6 + 5, mx2 = -1, mn2 = 1e6 + 5, add = w - i + 1;       for (int j : b[i]) {         mx = max(mx, j);         mn = min(mn, j);         mx2 = max(mx2, (j + add) % (w + 1));         mn2 = min(mn2, (j + add) % (w + 1));       }       cnt++;       if (mn > i) {         c[0].push_back(cnt);         d[w - mx].push_back(cnt);         c[w - i + 1].push_back(cnt);         d[2 * w - mx].push_back(cnt);       } else {         c[add].push_back(cnt);         d[add + w - mx2].push_back(cnt);       }     }     int ans = 0;     for (int i = 0; i < 1e6; i++) {       for (int j : c[i]) {         if (!vis[j]) ans++;         vis[j]++;       }       if (ans == cnt) {         printf( %d n , i);         return 0;       }       for (int j : d[i]) {         if (vis[j] == 1) ans--;         vis[j]--;       }     }     puts( -1 );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename U, typename V>   void Min(U &a, const V &b) {     if (a > b) a = b;   }   template <typename U, typename V>   void Max(U &a, const V &b) {     if (a < b) a = b;   }   template <typename U, typename V>   void add(U &a, const V &b) {     a = (a + b) % 1000000007;   }   template <typename U>   U gcd(U a, U b) {     if (a == 0) return b;     if (b == 0) return a;     if (a >= b)       return gcd(a % b, b);     else       return gcd(a, b % a);   }   int pow(int a, int b) {     int ans = 1;     while (b) {       if (b & 1) ans = 1LL * ans * a % 1000000007;       a = 1LL * a * a % 1000000007;       b >>= 1;     }     return ans;   }   int pow(int a, int b, int c) {     int ans = 1;     while (b) {       if (b & 1) ans = 1LL * ans * a % c;       a = 1LL * a * a % c;       b >>= 1;     }     return ans;   }   char s[2005];   vector<pair<int, int> > ans;   void solve(int l, int r, int K) {     if (l > r) return;     if (s[l] !=  ( ) {       for (int i = r + 1 - 1; i >= l + 1; i--)         if (s[i] ==  ( ) {           reverse(s + l, s + i + 1);           ans.push_back({l, i});           break;         }     }     if (s[r] !=  ) ) {       for (int i = l + 1; i < r; i++)         if (s[i] ==  ) ) {           reverse(s + i, s + r + 1);           ans.push_back({i, r});           break;         }     }     if (l + 1 == r) return;     if (K == 0) {       int m = (l + r + 1) >> 1;       int k = r - 1;       for (int i = l + 1; i < m; i++)         if (s[i] !=  ( ) {           while (k > i && s[k] ==  ) ) k--;           reverse(s + i, s + k + 1);           ans.push_back({i, k});         }     } else {       if (s[l + 1] !=  ) ) {         for (int i = l + 2; i < r; i++)           if (s[i] ==  ) ) {             reverse(s + l + 1, s + i + 1);             ans.push_back({l + 1, i});             break;           }       }       solve(l, l + 1, 1);       solve(l + 2, r, K - 1);     }   }   int main() {     int T, i, j, k, m, ca = 0, n, K;     scanf( %d , &T);     while (T--) {       scanf( %d%d%s , &n, &K, s);       K--;       ans.clear();       solve(0, n - 1, K);       printf( %d n , int(ans.size()));       for (auto &o : ans) printf( %d %d n , o.first + 1, o.second + 1);     }   }
#include <bits/stdc++.h>   using namespace std;   bool SR(int &x) { return scanf( %d , &x) == 1; }   bool SR(long long &x) { return scanf( %lld , &x) == 1; }   bool SR(double &x) { return scanf( %lf , &x) == 1; }   bool SR(char *s) { return scanf( %s , s) == 1; }   bool RI() { return true; }   template <typename I, typename... T>   bool RI(I &x, T &...tail) {     return SR(x) && RI(tail...);   }   void SP(const int x) { printf( %d , x); }   void SP(const long long x) { printf( %lld , x); }   void SP(const double x) { printf( %.16lf , x); }   void SP(const char *s) { printf( %s , s); }   void PL() { puts(  ); }   template <typename I, typename... T>   void PL(const I x, const T... tail) {     SP(x);     if (sizeof...(tail)) putchar(   );     PL(tail...);   }   const int maxn = 4e6 + 6;   struct Dsu {     int par[maxn], clc;     void init(int siz) {       clc = siz;       for (int i = 0; i < int(siz); i++) par[i] = i;     }     int find(int x) { return x == par[x] ? x : par[x] = find(par[x]); }     void merge(int a, int b) {       if (find(a) == find(b)) return;       par[find(a)] = find(b);       clc--;     }   } dsu;   int n, m;   void read() { RI(n, m); }   void build() {     int tot = n + m + n + m - 4;     dsu.init(tot);     int pt = 0;     for (int i = 0; i < int(tot / 2); i++) {       dsu.merge(i, pt--);       if (pt < 0) pt += tot;     }     pt = n - 1;     for (int i = (n - 1); i <= int(n - 1 + tot / 2 - 1); i++) {       dsu.merge(i, pt--);       if (pt < 0) pt += tot;     }   }   void sol() { PL(dsu.clc); }   int main() {     read();     build();     sol();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int const N = 13;   int n, m, q;   long long dp[N][1 << N];   struct lca {     int u, v, c;   };   struct edge {     int u, v;   };   vector<edge> edges;   vector<lca> lcas;   inline bool valid(int mask, int sub, int u, int v) {     if (!(mask & (1 << u)) || !(mask & (1 << v))) return false;     if (bool(sub & (1 << u)) == bool(sub & (1 << v))) return false;     return true;   }   inline bool ok(int root, int child, int mask, int sub) {     for (auto ed : edges) {       int u = ed.u, v = ed.v;       if (!valid(mask, sub, u, v)) continue;       if (root == v) swap(u, v);       if (root != u || child != v) return false;     }     for (auto l : lcas) {       int u = l.u, v = l.v, c = l.c;       if (!valid(mask, sub, u, v)) continue;       if (c != root) return false;     }     return true;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cin >> n >> m >> q;     for (int i = 0; i < m; i++) {       int x, y;       cin >> x >> y;       x--, y--;       edges.push_back({x, y});     }     for (int i = 0; i < q; i++) {       int x, y, c;       cin >> x >> y >> c;       x--, y--, c--;       if (x == y && x != c) return cout <<  0 n , 0;       lcas.push_back({x, y, c});     }     for (int i = 0; i < n; i++) dp[i][1 << i] = 1;     for (int mask = 1; mask < (1 << n); mask++) {       for (int root = 0; root < n; root++) {         if (!(mask & (1 << root))) continue;         int p = -1;         for (int i = 0; i < n; i++)           if ((mask & (1 << i)) && i != root) p = i;         if (p == -1) continue;         for (int sub = mask & (mask - 1); sub > 0; sub = (sub - 1) & mask) {           if ((sub & (1 << root)) || !(sub & (1 << p))) continue;           for (int child = 0; child < n; child++)             if (ok(root, child, mask, sub))               dp[root][mask] += dp[child][sub] * dp[root][mask ^ sub];         }       }     }     cout << dp[0][(1 << n) - 1] << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 101000;   int fa[maxn], sz[maxn], c[maxn];   int fd(int f) { return fa[f] == f ? f : fa[f] = fd(fa[f]); }   int n, m, f[maxn];   bool isok(int x) {     while (x) {       int d = x % 10;       if (d != 4 && d != 7) return false;       x /= 10;     }     return true;   }   void bp(int v, int w) {     for (int i = n; i >= v; --i) f[i] = min(f[i], f[i - v] + w);   }   int main() {     scanf( %d%d , &n, &m);     for (int i = 1; i <= n; ++i) fa[i] = i;     for (int i = 1; i <= m; ++i) {       int u, v;       scanf( %d%d , &u, &v);       fa[fd(u)] = fd(v);     }     for (int i = 1; i <= n; ++i) sz[fd(i)]++;     for (int i = 1; i <= n; ++i) c[sz[i]]++, f[i] = 1e9;     for (int i = 1; i <= n; ++i)       if (c[i]) {         for (int s = 1; s <= c[i]; s <<= 1) bp(s * i, s), c[i] -= s;         bp(c[i] * i, c[i]);       }     int ans = 1e9;     for (int i = 1; i <= n; ++i)       if (isok(i)) ans = min(ans, f[i]);     printf( %d n , ans == 1e9 ? -1 : ans - 1);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);     int n, x, y;     cin >> n >> x >> y;     int a[n];     for (int j = 0; j < n; j++) cin >> a[j];     if (x > y) {       cout << n;       return 0;     }     int count = 0;     for (int j = 0; j < n; j++) {       if (a[j] <= x) count++;     }     cout << (count + 1) / 2;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> g[100001];   long long v[100001];   pair<long long, long long> r[100001];   int mark[100001];   void dfs(int s) {     mark[s] = 1;     r[s] = pair<long long, long long>(0, 0);     for (int i = 0; i < g[s].size(); i++) {       if (!mark[g[s][i]]) {         dfs(g[s][i]);         r[s].first = min(r[s].first, r[g[s][i]].first);         r[s].second = max(r[s].second, r[g[s][i]].second);       }     }     long long k = v[s] - r[s].first - r[s].second;     if (k > 0)       r[s].second = r[s].second + k;     else       r[s].first += k;   }   int main() {     int n;     memset(mark, 0, sizeof mark);     cin >> n;     int a, b;     for (int i = 0; i < n - 1; i++) {       cin >> a >> b;       g[a - 1].push_back(b - 1);       g[b - 1].push_back(a - 1);     }     for (int i = 0; i < n; i++) cin >> v[i];     dfs(0);     long long ans = -r[0].first + r[0].second;     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, grid[2500][2500], R[10005], C[10005];   vector<pair<long long, pair<long long, long long> > > A, B;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cin >> n;     for (long long i = 0; i < n; i++)       for (long long j = 0; j < n; j++)         cin >> grid[i][j], R[i + j] += grid[i][j], C[i - j + 5000] += grid[i][j];     long long Min = (long long)1e18;     for (long long i = 0; i < n; i++) {       for (long long j = 0; j < n; j++) {         long long Z = R[i + j] + C[i - j + 5000] - grid[i][j];         Min = min(Min, Z);         if (B.size() < 5000 || Z >= Min)           B.push_back(make_pair(R[i + j] + C[i - j + 5000] - grid[i][j],                                 make_pair(i, j)));       }     }     sort(B.begin(), B.end());     reverse(B.begin(), B.end());     long long a, b, x, y;     long long Max = 0;     for (long long i = 0; i < min((long long)B.size(), 5000LL); i++) {       for (long long j = 0; j < min((long long)B.size(), 3000LL); j++) {         if (B[i].first + B[j].first >= Max &&             ((B[i].second.first + B[i].second.second - B[j].second.first +               B[j].second.second)) %                 2 &&             ((B[i].second.first - B[i].second.second -               (B[j].second.first - B[j].second.second))) %                 2) {           a = B[i].second.first, b = B[i].second.second;           x = B[j].second.first, y = B[j].second.second;           Max = B[i].first + B[j].first;         }       }     }     cout << Max << endl;     cout << a + 1 <<     << b + 1 <<     << x + 1 <<     << y + 1 << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long n;     cin >> n;     long long now = 0;     long long mx = -1;     while (true) {       long long rem = (n - (now * 7));       if (rem < 0) {         break;       } else {         if (rem % 4 == 0) {           mx = max(mx, now);         }       }       now++;     }     if (mx == -1) {       cout << -1;       return 0;     } else {       long long four = n - (mx * 7);       four /= 4;       for (long long i = 0; i < four; i++) {         cout << 4;       }       for (long long i = 0; i < mx; i++) {         cout << 7;       }     }   }
#include <bits/stdc++.h>   using namespace std;   int a[100005];   int Gcd(int x, int y) {     if (y == 0) return x;     return Gcd(y, x % y);   }   int main(void) {     int n, i, ans;     scanf( %d , &n);     for (i = 1; i <= n; i++) scanf( %d , &a[i]);     sort(a + 1, a + n + 1);     ans = 0;     for (i = 1; i <= n; i++) ans = Gcd(ans, a[i]);     if (((a[n] / ans) - (n - 1)) % 2)       printf( Bob n );     else       printf( Alice n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     char mat[n][n];     for (int i = 0; i < n; i++) {       for (int j = 0; j < n; j++) {         cin >> mat[i][j];       }     }     char a = mat[0][0];     char b = mat[0][1];     if (a == b) {       cout <<  NO  << endl;       return 0;     }     for (int i = 0; i < n; i++) {       for (int j = 0; j < n; j++) {         if ((i == j || i == (n - j - 1)) && mat[i][j] != a) {           cout <<  NO  << endl;           return 0;         } else if ((!(i == j || i == (n - j - 1)) && mat[i][j] != b)) {           cout <<  NO  << endl;           return 0;         }       }     }     cout <<  YES  << endl;   }
#include <bits/stdc++.h>   long long prod_dig(long long n) {     long long prod = 1;     int a;     while (n) {       a = n % 10;       if (a) {         prod *= a;       }       n /= 10;     }     return prod;   }   int arr[10][1000000 + 1];   int main() {     int t;     for (int i = 1; i <= 1000000; i++) {       t = i;       while (t / 10) {         t = prod_dig(t);       }       for (int j = 0; j < 10; j++) {         arr[j][i] = arr[j][i - 1];       }       arr[t][i]++;     }     int Q, l, r, x, key;     scanf( %d , &Q);     while (Q--) {       scanf( %d%d%d , &l, &r, &key);       printf( %d n , arr[key][r] - arr[key][l - 1]);     }   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   inline T Abs(T a) {     return a > 0 ? a : -a;   }   void split(string s, string seps, vector<string> &res, bool doEmpty = false) {     int start = 0;     res.clear();     for (int i = 0; i < s.size(); i++) {       if (seps.find(s[i]) != string::npos) {         if (doEmpty || i - start > 0) res.push_back(s.substr(start, i - start));         start = i + 1;       }     }     if (doEmpty || s.size() - start > 0)       res.push_back(s.substr(start, s.size() - start));   }   string Union(vector<string> s, int start = 0) {     string res;     for (int i = start; i < s.size(); i++) res.append(s[i]);     return res;   }   int main() {     string s;     int n;     cin >> s >> n;     vector<string> b(n);     vector<int> fn(s.size());     for (int i = 0; i < n; i++) cin >> b[i];     for (int i = 0; i < n; i++) {       int k = 0;       while (k < s.length()) {         int r = s.find(b[i], k);         if (r == s.npos) break;         fn[r + b[i].size() - 1] = max(fn[r + b[i].size() - 1], r + 1);         k = r + 1;       }     }     int best = 0;     int bi = 0;     int cur = 0;     int ci = 0;     for (int i = 0; i < s.length(); i++) {       if (fn[i]) {         int lci = ci;         ci = -1;         int g = fn[i];         int j = i;         while (j >= g) {           g = max(g, fn[j]);           ci = j;           j--;         }         if (ci == -1) ci = i + 1;         cur = i - ci;       }       cur++;       if (cur > best) {         best = cur;         bi = ci;       }     }     cout << best <<     << bi;     return 0;   }