malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int N = 100005;   int a[N], cnt[N];   int f[N], bj[N];   vector<int> d[N];   int n, mx;   long long ans;   void init(int n) {     for (int i = 1; i <= n; i++) f[i] = 1;     for (int i = 2; i <= n; i++) {       if (bj[i]) continue;       f[i] = -1;       for (int j = i * 2; j <= n; j += i) {         bj[j] = 1;         f[j] = (j % (i * i)) ? f[j] * -1 : 0;       }     }   }   int count(int x) {     int res = 0;     for (int i = 0; i < d[x].size(); i++) {       res += f[d[x][i]] * cnt[d[x][i]];     }     return res;   }   void add(int x, int v) {     for (int i = 0; i < d[x].size(); i++) {       cnt[d[x][i]] += v;     }   }   int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       int x;       scanf( %d , &x);       a[x]++;       mx = max(mx, x);     }     ans = mx;     for (int i = 1; i <= mx; i++) {       for (int j = i; j <= mx; j += i) {         d[j].push_back(i);       }     }     init(mx);     for (int g = 1; g <= mx; g++) {       stack<int> st;       for (int i = mx / g; i >= 1; i--) {         if (!a[i * g]) continue;         int c = count(i);         while (c) {           if (gcd(i, st.top()) == 1) {             ans = max(ans, (long long)i * g * st.top());             c--;           }           add(st.top(), -1);           st.pop();         }         st.push(i);         add(i, 1);       }       while (!st.empty()) {         add(st.top(), -1);         st.pop();       }     }     printf( %lld , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1005, mod = 1e9 + 7;   int yh[N][N], a[N];   long long kpow(long long a, long long b) {     long long ans = 1;     while (b) {       if (b & 1) ans = ans * a % mod;       a = a * a % mod;       b >>= 1;     }     return ans;   }   int main() {     for (int i = (0); i < (N); ++i) yh[i][0] = 1;     for (int i = (1); i < (N); ++i)       for (int j = (1); j < (N); ++j) {         yh[i][j] = yh[i - 1][j - 1] + yh[i - 1][j];         if (yh[i][j] >= mod) yh[i][j] -= mod;       }     int n, m;     cin >> n >> m;     a[0] = 0;     a[m + 1] = n + 1;     for (int i = (1); i < (m + 1); ++i) cin >> a[i];     sort(a + 1, a + m + 1);     long long ans = 1, k = n - m;     for (int i = (1); i < (m + 2); ++i) {       int c = a[i] - a[i - 1] - 1;       ans = ans * yh[k][c] % mod;       if (i != 1 && i != m + 1 && c) ans = ans * kpow(2, c - 1) % mod;       k -= c;     }     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int dp[81][81][81], n, m, i, j, k, ans, inf = 1000007, x, y, l, len;   pair<int, int> p;   vector<pair<int, int> > g[82];   int main() {     cin >> n >> m;     if (m > n) {       cout << -1 << endl;       return 0;     }     cin >> k;     for (i = 0; i < k; i++) {       cin >> x >> y >> l;       if (x == y) continue;       p.first = y;       p.second = l;       g[x].push_back(p);     }     for (i = 1; i <= n; i++)       for (j = 1; j <= n; j++)         for (k = 1; k <= n; k++) dp[i][j][k] = inf;     for (i = 1; i <= n; i++)       for (j = 1; j <= n; j++) dp[i][j][1] = 0;     for (k = 2; k <= m; k++)       for (j = 1; j < n; j++)         for (i = 1; i <= n - j; i++) {           len = g[i].size();           for (l = 0; l < len; l++) {             if (g[i][l].first < i) continue;             if (g[i][l].first > i + j) continue;             dp[i][i + j][k] =                 min(dp[i][i + j][k], min(dp[g[i][l].first][i + 1][k - 1],                                          dp[g[i][l].first][i + j][k - 1]) +                                          g[i][l].second);           }           len = g[i + j].size();           for (l = 0; l < len; l++) {             if (g[i + j][l].first > i + j) continue;             if (g[i + j][l].first < i) continue;             dp[i + j][i][k] =                 min(dp[i + j][i][k], min(dp[g[i + j][l].first][i + j - 1][k - 1],                                          dp[g[i + j][l].first][i][k - 1]) +                                          g[i + j][l].second);           }         }     ans = inf;     for (i = 1; i <= n; i++)       for (j = 1; j <= n; j++) ans = min(ans, dp[i][j][m]);     if (ans == inf)       cout << -1 << endl;     else       cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 100005;   int n;   long long arr[MAXN][3];   map<pair<long long, long long>, pair<long long, int> > height;   void update(long long x, long long y, long long z, int id) {     if (height.find(make_pair((x), (y))) == height.end())       height[make_pair((x), (y))] = make_pair((z), (id));     else       height[make_pair((x), (y))] =           max(height[make_pair((x), (y))], make_pair((z), (id)));   }   int main() {     cin >> n;     int idx1 = 0, idx2[2] = {0, 0};     long long best1 = 0, best2 = 0;     for (int i = 1; i <= n; i++) {       cin >> arr[i][0] >> arr[i][1] >> arr[i][2];       sort(arr[i], arr[i] + 3);       if (arr[i][0] > best1) {         best1 = arr[i][0];         idx1 = i;       }       if (height.find(make_pair((arr[i][1]), (arr[i][2]))) != height.end()) {         long long t =             min(arr[i][0] + height[make_pair((arr[i][1]), (arr[i][2]))].first,                 min(arr[i][1], arr[i][2]));         if (t > best2) {           idx2[0] = i;           idx2[1] = height[make_pair((arr[i][1]), (arr[i][2]))].second;           best2 = t;         }       }       update(arr[i][0], arr[i][1], arr[i][2], i);       update(arr[i][0], arr[i][2], arr[i][1], i);       update(arr[i][1], arr[i][2], arr[i][0], i);     }     if (best1 > best2)       cout << 1 << endl << idx1 << endl;     else       cout << 2 << endl << idx2[0] <<     << idx2[1] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     ;     int t;     cin >> t;     while (t--) {       int n;       cin >> n;       for (long long int i = (long long int)0; i < (long long int)n; i++)         cout << i + 1 <<    n [i == n - 1];     }     return 0;   }
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:1000000000 )   #pragma GCC optimize( Ofast,no-stack-protector )   using namespace std;   const int maxn = (int)2e5 + 10;   vector<int> ed[maxn];   int t[maxn], h[maxn];   long long dp[maxn][2];   void go(int v, int p) {     vector<pair<long long, int> > g;     int in = 0;     int out = 0;     long long sc = 0;     for (int u : ed[v]) {       if (u == p) {         continue;       }       go(u, v);       if (h[u] > h[v]) {         out++;         sc += dp[u][0];       } else if (h[u] < h[v]) {         in++;         sc += dp[u][1];       } else {         out++;         g.push_back(make_pair(-dp[u][0] + dp[u][1], u));         sc += dp[u][0];       }     }     sort((g).begin(), (g).end());     for (int it = 0; it < 2; it++) {       if (p != -1)         if (it == 0) {           in++;         } else {           out++;         }       long long ans = (long long)1e18;       long long cur = sc;       for (int i = 0; i <= (int)g.size(); i++) {         ans = min(ans, cur + max(in + i, out - i) * (long long)t[v]);         if (i != (int)g.size()) cur += g[i].first;       }       dp[v][it] = ans;       if (p != -1)         if (it == 0) {           in--;         } else {           out--;         }     }   }   int main() {     int n;     cin >> n;     for (int i = 0; i < n; i++) {       scanf( %d , &t[i]);     }     for (int i = 0; i < n; i++) {       scanf( %d , &h[i]);     }     for (int i = 0; i < n - 1; i++) {       int x, y;       scanf( %d %d , &x, &y);       x--;       y--;       ed[x].push_back(y);       ed[y].push_back(x);     }     go(0, -1);     cout << dp[0][0] <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   pair<long double, pair<long long, long long> > c[250001];   long double p, q, abcd, ABCD;   long long a, b, n, i, x, y;   bool comp(pair<long double, pair<long long, long long> > a,             pair<long double, pair<long long, long long> > b) {     if (a.first < b.first) return 1;     if (a.first > b.first) return 0;     if (a.second.second < b.second.second) return 1;     if (a.second.second == b.second.second && a.second.first < b.second.first)       return 1;     return 0;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cin >> x >> y >> n;     abcd = x;     ABCD = y;     for (i = 1; i <= n; i++) {       b = i;       a = x * b / y;       p = a;       q = b;       c[i * 2 - 1] = make_pair(abs(abcd / ABCD - p / q), make_pair(a, b));       b = i;       a = (x * b + y - 1) / y;       p = a;       q = b;       c[i * 2] = make_pair(abs(abcd / ABCD - p / q), make_pair(a, b));     }     sort(c + 1, c + 1 + n * 2, comp);     cout << c[1].second.first <<  /  << c[1].second.second <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, m, k, t, x, y, z, w, ct, ans, f;   string s, l;   long long a[200005];   set<long long> si;   queue<long long> qi;   map<long long, long long> mi;   vector<long long> vi;   priority_queue<long long> pqdi;   priority_queue<long long, vector<long long>, greater<long long>> pqai;   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     cerr.tie(NULL);     cin >> t;     while (t--) {       si.clear();       vi.clear();       cin >> n;       for (long long i = 1; i <= n; i++) {         cin >> a[i];         si.insert(a[i]);       }       if (si.size() != n) {         cout <<  NO               <<   n ;       } else {         f = 0;         vector<long long> diff;         sort(a + 1, a + n + 1);         for (long long i = 2; i < n + 1; i++) {           for (long long j = 1; j < i; j++) {             diff.push_back(a[i] - a[j]);           }         }         long long valid[1000000];         long long j = 2;         memset(valid, 0, sizeof(valid));         vi.push_back(1);         valid[1] = 1;         for (long long i = 1; i < n; i++) {           for (auto it : diff) {             valid[(vi[i - 1] + it)] = 1;           }           while (valid[j]) j++;           vi.push_back(j);           valid[j] = 1;           if (j > 1000000) {             f = 1;             break;           }         }         if (f)           cout <<  NO                 <<   n ;         else {           cout <<  YES                 <<   n ;           ;           for (long long i = 1; i <= n; i++) cout << vi[i - 1] <<    ;           cout <<   n ;         }       }     }   }
#include <bits/stdc++.h>   using namespace std;   const int MAX = 1e5 + 10;   const int MAXN = 1e4 + 10;   const int MOD = 1e9 + 7;   const int inf = 1e9;   const double pi = acos(-1.0);   const double eps = 1e-6;   int dx[] = {0, -1, 0, 1};   int dy[] = {1, 0, -1, 0};   map<int, int> mymap, mymap1;   int n, m;   vector<int> Ve, Vo;   int save[200100];   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cin >> n >> m;     int res = 0;     for (int i = 1; i <= n; i++) {       int x;       cin >> x;       if (x % 2) {         if (!mymap[x]) {           Vo.push_back(x);           mymap[x] = 1;           mymap1[x] = i;         }       } else {         if (!mymap[x]) {           Ve.push_back(x);           mymap[x] = 1;           mymap1[x] = i;         }       }     }     int o = Vo.size();     int e = Ve.size();     int r = -1;     if (o >= n / 2 && e <= n / 2)       r = min(o - n / 2, n / 2 - e);     else if (o <= n / 2 && e >= n / 2)       r = min(n / 2 - o, e - n / 2);     if (r != -1) {       res += r;       if (o <= n / 2) {         o += r;         e -= r;       } else {         o -= r;         e += r;       }     }     res += max(n / 2 - o, 0);     res += max(n / 2 - e, 0);     for (int i = 1; i <= min(n, m); i++)       if (i % 2) {         if (!mymap[i]) {           mymap[i] = 1;           Vo.push_back(i);         }       } else {         if (!mymap[i]) {           mymap[i] = 1;           Ve.push_back(i);         }       }     o = Vo.size();     e = Ve.size();     if (o >= n / 2 && e >= n / 2) {       cout << res << endl;       vector<int> K;       K.clear();       for (int i = 0; i < n / 2; i++)         if (mymap1[Vo[i]])           save[mymap1[Vo[i]]] = Vo[i];         else           K.push_back(Vo[i]);       for (int i = 0; i < n / 2; i++)         if (mymap1[Ve[i]])           save[mymap1[Ve[i]]] = Ve[i];         else           K.push_back(Ve[i]);       int p = 1;       int q = 0;       while (p <= n && q < K.size())         if (save[p])           p++;         else {           save[p] = K[q];           p++;           q++;         }       for (int i = 1; i <= n; i++) cout << save[i] <<    ;     } else       cout << -1;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, s, a, ans, a11, r;   vector<long long> aa, ab, c;   int main() {     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> s >> a;       if (s == 11) {         a11++;         ans += a;       }       if (s == 0) c.push_back(a);       if (s == 10) aa.push_back(a);       if (s == 1) ab.push_back(a);     }     sort(aa.begin(), aa.end());     reverse(aa.begin(), aa.end());     sort(ab.begin(), ab.end());     reverse(ab.begin(), ab.end());     r = min(aa.size(), ab.size());     for (int i = r; i < aa.size(); i++) {       c.push_back(aa[i]);     }     for (int i = r; i < ab.size(); i++) {       c.push_back(ab[i]);     }     sort(c.begin(), c.end());     reverse(c.begin(), c.end());     for (int i = 0; i < min(a11, (long long)c.size()); i++) ans += c[i];     for (int i = 0; i < r; i++) {       ans += aa[i];       ans += ab[i];     }     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     int n;     cin >> n;     vector<int> v(n);     for (int i = (int)(0); i < (int)(n); ++i) cin >> v[i];     sort(v.begin(), v.end());     cout << v[(n - 1) / 2] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline int toInt(string s) {     int v;     istringstream sin(s);     sin >> v;     return v;   }   template <class T>   inline string toString(T x) {     ostringstream sout;     sout << x;     return sout.str();   }   const double EPS = 1e-10;   const double PI = acos(-1.0);   vector<int> x, y;   int xo, yo;   int n, d;   int dp[1000][1000];   int sqr(int a) { return a * a; }   int dfs(int x1, int y1) {     if (sqr(x1) + sqr(y1) > sqr(d)) return dp[x1 + 500][y1 + 500] = 1;     if (dp[x1 + 500][y1 + 500] != -1) return dp[x1 + 500][y1 + 500];     for (int i = (0); i < (int((x).size())); ++i)       if (!dfs(x1 + x[i], y1 + y[i])) return dp[x1 + 500][y1 + 500] = 1;     return dp[x1 + 500][y1 + 500] = 0;   }   int main(int argc, char *argv[]) {     ios::sync_with_stdio(false);     memset(dp, -1, sizeof dp);     cin >> xo >> yo >> n >> d;     for (int i = (0); i < (n); ++i) {       int xi, yi;       cin >> xi >> yi;       x.push_back(xi);       y.push_back(yi);     }     if (dfs(xo, yo))       cout <<  Anton  << endl;     else       cout <<  Dasha  << endl;     return 0;   }
#include <bits/stdc++.h>   long long mpow(long long a, long long n, long long mod) {     long long ret = 1;     long long b = a;     while (n) {       if (n & 1) ret = (ret * b) % mod;       b = (b * b) % mod;       n >>= 1;     }     return (long long)ret;   }   using namespace std;   vector<int> v, v1;   pair<int, int> p[100004];   int a[100004], b[100004];   int main() {     int n, i, j;     cin >> n;     for (j = 0; j < n; j++) {       cin >> p[j].first;       p[j].second = j;     }     sort(p, p + n);     long long z = 0;     int need = n - (n + 2) / 3;     for (j = n - need; j < n; j++) {       if (z % 2 == 0) {         a[p[j].second] = p[j].first - z / 2;         b[p[j].second] = z / 2;       } else {         a[p[j].second] = z / 2;         b[p[j].second] = p[j].first - z / 2;       }       z++;     }     for (j = 0; j < n - need; j++) {       a[p[j].second] = 0;       b[p[j].second] = p[j].first;     }     cout <<  YES  << endl;     for (j = 0; j < n; j++) cout << a[j] <<    ;     cout << endl;     for (j = 0; j < n; j++) cout << b[j] <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, k, ans = -1;   int a1[1000001], b1[1000001], a[1000001], b[1000001], t[1000001], d[1000001],       in[1000001], Max[2000001];   int s = 1;   int getmax(int v, int vl, int vr, int l, int r) {     if (l > vr || r < vl) {       return 0;     }     if (vl >= l && vr <= r) {       return Max[v];     }     return max(getmax(v * 2, vl, (vl + vr) / 2, l, r),                getmax(v * 2 + 1, (vl + vr) / 2 + 1, vr, l, r));   }   void update(int v) {     v /= 2;     if (v <= 0) {       return;     }     Max[v] = max(Max[v * 2], Max[v * 2 + 1]);     update(v);   }   int main() {     cin >> n;     for (int i = 0; i < n; i++) {       cin >> a1[i];       t[a1[i]] = i + 1;     }     for (int i = 0; i < n; i++) {       cin >> b1[i];     }     for (int i = 0; i < n; i++) {       a[i] = i;       b[i] = t[b1[i]];     }     while (n > s) {       s *= 2;       k++;     }     for (int i = 1; i < 2 * s; i++) {       Max[i] = 0;     }     for (int i = 0; i < n; i++) {       d[i] = getmax(1, 1, s, b[i], n) + 1;       Max[s + b[i] - 1] = d[i];       update(s + b[i] - 1);     }     for (int i = 0; i < n; i++) {       ans = max(ans, d[i]);     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 0x3fffffff;   const int SINF = 0x7fffffff;   const long long LINF = 0x3fffffffffffffff;   const long long SLINF = 0x7fffffffffffffff;   const long double DINF = pow(2, 100);   const int MAXN = 1007;   const int MOD = static_cast<int>(1e9 + 7);   const long double EPS = 1e-11;   struct cT {     cT() : x(0), y(0) {}     cT(long double _x, long double _y) : x(_x), y(_y) {}     cT operator+(const cT &a) const { return cT(x + a.x, y + a.y); }     cT operator-(const cT &a) const { return cT(x - a.x, y - a.y); }     cT operator/(const int a) { return cT(x / a, y / a); }     bool operator==(const cT &a) const {       return ((((x - a.x) >= 0) ? (x - a.x) : (-(x - a.x))) < EPS &&               (((y - a.y) >= 0) ? (y - a.y) : (-(y - a.y))) < EPS);     }     bool operator!=(const cT &a) const { return !((*this) == a); }     bool operator<(const cT &a) const {       return ((((x - a.x) >= 0) ? (x - a.x) : (-(x - a.x))) > EPS)                  ? x < a.x                  : y < a.y - EPS;     }     long double getk() {       return (((x) >= 0) ? (x) : (-(x))) < EPS ? DINF : (y / x);     }     long double x, y;   } cr[MAXN];   struct dT {     dT() : k(0) {}     dT(cT _cr, long double _k) : cr(_cr), k(_k) {}     bool operator<(const dT &a) const {       return (cr != a.cr) ? cr < a.cr : k < a.k - EPS;     }     cT cr;     long double k;   } med[MAXN * MAXN];   int n;   int km;   void init();   void input();   void work();   int getans(int l, int r);   int add(int x, int y) {     x += y;     if (x >= MOD) x -= MOD;     return x;   }   void addv(int &x, int y) {     x += y;     if (x >= MOD) x -= MOD;   }   int dec(int x, int y) {     x -= y;     if (x < 0) x += MOD;     return x;   }   void decv(int &x, int y) {     x -= y;     if (x < 0) x += MOD;   }   int main() {     init();     input();     work();   }   void init() { ios::sync_with_stdio(false); }   void input() {     scanf( %d , &n);     int a, b, c, d;     for (int i = 1; i <= n; ++i) {       scanf( %d%d%d%d , &a, &b, &c, &d);       cr[i].x = static_cast<long double>(a * b * d * d) /                 (a * a * d * d + b * b * c * c);       cr[i].y = static_cast<long double>(c * d * b * b) /                 (a * a * d * d + b * b * c * c);     }   }   void work() {     for (int i = 1; i <= n; ++i) {       for (int j = i + 1; j <= n; ++j) {         med[++km] = dT((cr[i] + cr[j]) / 2, (cr[j] - cr[i]).getk());       }     }     sort(med + 1, med + 1 + km);     med[km + 1] = dT(cT(DINF, DINF), 1);     int pre = 1, ans = 0;     for (int i = 1; i <= km + 1; ++i) {       if (med[i].cr != med[pre].cr) {         addv(ans, getans(pre, i - 1));         pre = i;       }     }     cout << ans << endl;   }   int getans(int l, int r) {     int pre = l;     int ans = 1;     for (int i = l; i <= r; ++i) {       if ((((med[i].k - med[pre].k) >= 0) ? (med[i].k - med[pre].k)                                           : (-(med[i].k - med[pre].k))) > EPS) {         ans = static_cast<long long>(ans) * (i - pre + 1) % MOD;         pre = i;       }     }     ans = static_cast<long long>(ans) * (r - pre + 2) % MOD;     return dec(ans, r - l + 2);   }
#include <bits/stdc++.h>   using namespace std;   char s[1010];   int main() {     int f1 = 0, f2 = 0;     scanf( %s , s);     int len = strlen(s);     for (int i = 0; i < len; i++) {       if (s[i] ==  0 ) {         if (f1 == 0) {           printf( 1 1 n );           f1 = 1;         } else {           printf( 3 1 n );           f1 = 0;         }       }       if (s[i] ==  1 ) {         if (f2 == 0) {           printf( 4 3 n );           f2 = 1;         } else {           printf( 4 1 n );           f2 = 0;         }       }     }   }
#include <bits/stdc++.h>   using namespace std;   int oo = 1000000000;   long long n;   long long a[100005];   int main() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr), cout.tie(nullptr);     cin >> n;     for (int i = 1; i <= n; i++) cin >> a[i];     if (n == 1) {       cout << 1 <<     << 1 << endl;       cout << -a[1] << endl;       a[1] = 0;       cout << 1 <<     << 1 << endl;       cout << -a[1] << endl;       cout << 1 <<     << 1 << endl;       cout << -a[1] << endl;       return 0;     }     cout << 1 <<     << 1 << endl;     cout << n - (a[1] % n) << endl;     a[1] += n - (a[1] % n);     cout << 2 <<     << n << endl;     for (int i = 2; i <= n; i++) {       cout << (a[i] % n) * (n - 1) <<    ;       a[i] += (a[i] % n) * (n - 1);     }     cout << endl;     cout << 1 <<     << n << endl;     for (int i = 1; i <= n; i++) cout << -a[i] <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> me;   long long sum(long long x) { return (x * (x + 1)) / 2; }   int main() {     int k;     string s;     cin >> k >> s;     for (int i = 0; i < s.size(); i++) {       if (s[i] ==  1 ) {         me.push_back(i);       }     }     long long ans = 0, cnt = 0, idx = -1;     if (k == 0) {       for (int i = 0; i < s.size(); i++) {         if (s[i] ==  1 ) {           ans += sum(cnt);           cnt = 0;         } else {           cnt++;         }       }       ans += sum(cnt);     } else {       long long fst = -1;       for (int i = 0; i < me.size(); i++) {         int idx = me[i];         cnt = 0;         if ((i + k - 1) == me.size() - 1) {           ans += ((idx - fst) * (s.size() - me[i + k - 1]));         } else if (i + k - 1 < me.size() - 1) {           ans += ((idx - fst) * (me[i + k] - me[i + k - 1]));         }         fst = me[i];       }     }     cout << ans;     return 0;   }