QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#560470#8223. 字符串游戏ORzyzRO100 ✓578ms310148kbC++143.7kb2024-09-12 15:51:152024-09-12 15:51:17

Judging History

你现在查看的是最新测评结果

  • [2024-09-12 15:51:17]
  • 评测
  • 测评结果:100
  • 用时:578ms
  • 内存:310148kb
  • [2024-09-12 15:51:15]
  • 提交

answer

#include <bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define pb push_back
#define eb emplace_back
#define rz resize
#define MP make_pair
#define MT make_tuple
#define IT iterator
#define fi first
#define se second
#define For(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define Rep(i, a, b) for (int i = (int)(a); i >= (int)(b); --i)
#define CLR(a, v) memset(a, v, sizeof(a))
#define CPY(a, b) memcpy(a, b, sizeof(a))
#define debug cerr << "ztxakking\n"
#define y0 ztxaknoi
#define y1 ztxakioi
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using uint = unsigned int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using vi = vector<int>;
template<typename T>
using V = vector<T>;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
const int N = 2e6 + 7;
int n, f[N];
string s;
struct FenwickTree {
  int t[N];
  void add(int x, int k) {
    for (; x < N; x += x & -x) t[x] += k;
  }
  int qry(int x) {
    int ans = 0;
    for (; x; x -= x & -x) ans += t[x];
    return ans;
  }
} T;
struct Graph {
  struct edge {
    int to, nxt;
  } e[N];
  int hd[N], tot;
  void add(int u, int v) {
    e[++tot] = (edge){v, hd[u]}, hd[u] = tot;
  }
};
struct SAM {
  Graph G;
  int dfn[N], hson[N], sz[N], top[N], seg[N], rev[N], timer, tot;
  int nxt[N][26], lnk[N], len[N], pos[N], cnt, lst;
  int clone(int x) { ++cnt, lnk[cnt] = lnk[x], CPY(nxt[cnt], nxt[x]); return cnt; }
  void extend(int c) {
    int cur = ++cnt, p = lst; len[cur] = len[p] + 1;
    for (; p && !nxt[p][c]; p = lnk[p]) nxt[p][c] = cur;
    if (!p) lnk[cur] = 1;
    else {
      int q = nxt[p][c];
      if (len[q] == len[p] + 1) lnk[cur] = q;
      else {
        int r = clone(q); len[r] = len[p] + 1;
        for (; p && nxt[p][c] == q; p = lnk[p]) nxt[p][c] = r;
        lnk[cur] = lnk[q] = r;
      }
    }
    lst = cur;
  }
  void dfs1(int u) {
    sz[u] = 1, dfn[u] = ++timer;
    for (int i = G.hd[u]; i; i = G.e[i].nxt) {
      int v = G.e[i].to;
      dfs1(v), sz[u] += sz[v];
      if (sz[hson[u]] < sz[v]) hson[u] = v;
    }
  }
  void dfs2(int u) {
    seg[u] = ++tot, rev[tot] = u;
    if (hson[u]) {
      top[hson[u]] = top[u];
      dfs2(hson[u]);
    }
    for (int i = G.hd[u]; i; i = G.e[i].nxt) {
      int v = G.e[i].to;
      if (v == hson[u]) continue;
      top[v] = v, dfs2(v);
    }
  }
  int find(int l, int r) {
    int L = r - l + 1, u = pos[r], ans = u;
    while (u) {
      if (len[top[u]] >= L) ans = top[u], u = lnk[top[u]];
      else {
        int l = seg[top[u]], r = seg[u];
        while (l <= r) {
          int mid = l + r >> 1;
          if (len[rev[mid]] >= L) ans = rev[mid], r = mid - 1; else l = mid + 1;
        }
        break;
      }
    }
    return ans;
  }
  void ins(int r) {
    int u = pos[r];
    T.add(dfn[u], 1);
  }
  int occ(int l, int r) {
    int u = find(l, r);
    return T.qry(dfn[u] + sz[u] - 1) - T.qry(dfn[u] - 1);
  }
  void init(string s) {
    lst = cnt = 1;
    For(i, 1, n) extend(s[i] - 'a'), pos[i] = lst;
    For(i, 2, cnt) G.add(lnk[i], i);
    dfs1(1), top[1] = 1, dfs2(1);
  }
} S;
int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  cin >> s, n = s.size(), reverse(all(s)), s = '@' + s, S.init(s);
  vi stk = {0};
  For(i, 1, n) {
    S.ins(i);
    while (true) {
      if (!stk.size()) break;
      int u = stk.back();
      f[i] = max(f[i], S.occ(u + 1, i) - f[u]);
      if (f[u] >= f[i]) stk.pop_back(); else break;
    }
    stk.pb(i);
  }
  cout << f[n] << '\n';
  cerr << (double)(clock()) / CLOCKS_PER_SEC << '\n';
  return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 10
Accepted

Test #1:

score: 10
Accepted
time: 0ms
memory: 23644kb

input:

abbabbbbabbaaaaabbbaabaaaaaabbbaabbabababaabababaababaaaaaabaaabaaabbbbababaaabbbabababbbabbbaabaaababbbaabaabbaaabbababaaaaabbbaabaaabbaabaabaaabaaabaababaabbbbbbbbabbbbbabbbaabababbaababbbbbabbbbaaabbaabaabaaabbabbaaabbaaababaabbbaabbbaaaabbababbabaababababaaaabbaaaabaabaaaababaaabababbbaaabababbb...

output:

1281

result:

ok single line: '1281'

Test #2:

score: 10
Accepted
time: 0ms
memory: 23556kb

input:

aaaabababbabbbbbabbbbbbbbbbbabbbbbabbbaaabbbbaababaabbbbbbbbbbbbbabaabbaaabaababaabaaabbabbbabbbabaabbaabaababbbbbbaaabbbbaaabaabbbabbbabbabaabbbbabbbaabaaaabbbbbabaaaabaabbabaaabbaabbabbaaabbabaaababbababababaabaaaabaabaabaaabaabbbabbbbbaababbabbbabbbbababaaabbabbaaaabbbaaabaabbbaaaaaababaababbbbba...

output:

1483

result:

ok single line: '1483'

Test #3:

score: 10
Accepted
time: 0ms
memory: 25068kb

input:

bbaaababbbabbbaabbbbbbababbbabbbbbbbbaabbbbbbbbbbaaabbbbbbbbbbbbbbbabbabbbabaababbbabbbbabbabbabbbbabbbbbbbbbaaababbaaabbbaabbabbbbbbbbbbbbbbbbbbbbabbbbbbababababbbbbbbbbabababaabbbbbbabbbbaabbababbaaababbbbabbbbabbbabbbbbabbbbbabbbbbbbbbbabbaabbbabababbbbaababbbababbbbabbabbaabbbbbbabbbbbababbbbaba...

output:

2310

result:

ok single line: '2310'

Test #4:

score: 10
Accepted
time: 0ms
memory: 23784kb

input:

abbbbbbbbababbbbbbbbbabbbbbbbbabbbabbbbbaaabbbbbabbbbababbbabbbbbbaabbabbbbbaabbbbabbabbbbbbbabbbbaaabbbbbbaabbbbbbbbbbbbbbbbbbbbbabbbabbbabbbbbbbabbbbbbbabbbabbbbbbbbabbbabbbbbbbbbbbbbbbbbaababbbbbbbbbbabbbbbbbbbbbbbababbbbbbbabbbbbbababbbabbbbbaabbbbbbbbbaabbabbbbaabbbabbbbbbbbbbbbbabbbbbbbbbbbbbb...

output:

1

result:

ok single line: '1'

Test #5:

score: 10
Accepted
time: 0ms
memory: 24716kb

input:

bbbabbbbbbbbbbbbbbbbbbbbabbbbbbbbbabbbbbbbbbbbbbbbbbbbbbbbbbabbbabbbabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbabbabbbbbbbbbabbbbabbabbbbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbbabbbbbbbbbbbabbbbbbbbbbbbbbbbbbbabbbbbbabbabbbbbbaabbbabbbbbbbbbbbbbbbbabbbbbabbbabbbbbbbabbbababbabbbbba...

output:

3680

result:

ok single line: '3680'

Test #6:

score: 10
Accepted
time: 3ms
memory: 23700kb

input:

bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbb...

output:

2454

result:

ok single line: '2454'

Test #7:

score: 10
Accepted
time: 3ms
memory: 25476kb

input:

bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb...

output:

2702

result:

ok single line: '2702'

Test #8:

score: 10
Accepted
time: 0ms
memory: 24208kb

input:

bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb...

output:

2499

result:

ok single line: '2499'

Test #9:

score: 10
Accepted
time: 0ms
memory: 25140kb

input:

amahaaajakalaiacabararasafaxasagamajaqagaqaeauauayagasadazavaeagabaaajalajavalatauapacaearaeagafawaaapawadaiaaapalahanavazasayamaiafagabahaxanacaaagaoadasakayagawaiaharanamaraiaramazaoagajataoazasalavatafaoalacaqavanafatajawauayakaoaqawawayasatasazagafacayasasawaqayadasaiazaxamaaaragataxawazadalaxak...

output:

2475

result:

ok single line: '2475'

Test #10:

score: 10
Accepted
time: 0ms
memory: 25184kb

input:

afabagadaeaeacaeaeafagafagababaaagacabaaagadacafadabaaaaacadaaagafacagadaeacacacabadagadaaabafadafadadaeafaaagadafabaeaaafaeaeaaaeabaaabaaaeafagadaaaaacaeaaaaacabaeacadagafafacacabaeaaagagaeaaadagabadaaaaagafagaaabaaaaafacafacadaaagabaaafadagacaaafafadadadacadadaaacagabacaaabacaeadabacagaeagagafafag...

output:

2807

result:

ok single line: '2807'

Subtask #2:

score: 10
Accepted

Test #11:

score: 10
Accepted
time: 543ms
memory: 309404kb

input:

aaaaaaabbaaabbbbabbabbbababaabaaabaabbaaababaaaaaabbbbbaabbbabbbaabbabaababaababaabbbababbbabaaaaaaaaabaaaaabbbabbbbbabaaabaaaababbabbbbbbaabbbbbaababbbbababbbbbbbbbbbaaabbabbaababbaaaabbabaaabbaaabbbbaaababbbbbabbaababbaaababaaabbabaabbbbabbaaabbababbaabbaaaaaaaaaabababbbaaaababbabbbabbababbabbabbb...

output:

234567

result:

ok single line: '234567'

Test #12:

score: 10
Accepted
time: 578ms
memory: 310148kb

input:

aababbbbaaabaabababbbaabbabbaabbaababaabaabaabbbaaaabbabbbbbaaaaabbbaabbbaaaaaaaabbbabaabbbaabaaabaabbabbabbbaaabbbbbaabaabaaaaabbbabbaaaababbaaababbbbaaabaabbababbbbbaaabbaabaaaaaaabbbbbaabbaaabaababababbbbabbbbaabbababbbbbaabbabaaaaabbabbbabbaaaababababbbabaabababaaabbbbaaabbabababaabaabaaabbabaab...

output:

198433

result:

ok single line: '198433'

Test #13:

score: 10
Accepted
time: 555ms
memory: 310028kb

input:

bababbbabaaabbbaabaabaababbbaabaabaaaaaabaaaaaaaabaaabbabbaaaaababbbbbbababaabbaabbabaabaaabaaaabbbbbaaabbababbabbbabbbaaaabbbbaaabbaabbbababbbabbbbabbbbabbbbabaaaabaaaabababbaaabbaaabbaabbbbbababababbbbbbbbabaaabaaaaaaabbbabbabbbaaabbbabbababaabababaabbabbbabaaabbaabbabbbababaababaaabaabababaababbb...

output:

248857

result:

ok single line: '248857'

Test #14:

score: 10
Accepted
time: 561ms
memory: 310116kb

input:

aabababababbaaaababbaabbabaaaaaababbaabaaabbaaaaabaaabbaababbbaaaabbbaabbabbaaaabaaabbbaaaababbbbaabaabbaabaaaaaabababaabbaaabbbaaabbabababaabaaaababaaaaabbbbabbaabbbababbbbaaaaabbbabaabbbaababaabbaaababbaabababbabaaabbbabbbbabaaabaaabbbaabbbaabbbabbbbabaaabbabababbbbabababbbbbbaaababaababaabaabbbbb...

output:

257032

result:

ok single line: '257032'

Test #15:

score: 10
Accepted
time: 561ms
memory: 309480kb

input:

bbbababbaaabbaababaaababaaaababababbbbbabaaaaaabbbbbabbabbaaabaaabababbbabbbaaaaaaaaabbaaaababbbaabaaabbaaabbabbabaabbabbbaabbabaabbbbaaabbbaaabbabbbabbabbbbaabaababaaabbbbabbbbbaaaaaaabbabbbbbabbabbbbaaabbaabbbaabbbbaabbbbbbbababaabaaaabbababaaaaabbabaaabaabbaabbbaaabbbbbbaabababbbbbababbbaabbbabaa...

output:

222902

result:

ok single line: '222902'

Subtask #3:

score: 5
Accepted

Test #16:

score: 5
Accepted
time: 96ms
memory: 254852kb

input:

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

493827

result:

ok single line: '493827'

Subtask #4:

score: 25
Accepted

Test #17:

score: 25
Accepted
time: 42ms
memory: 65432kb

input:

bbbbbbbbbaabbbbbabaaabaabaaabaaaaabaaaabbbbbbbaaaabaabbbababbaaaabbabababbbabbbbabbabaabaaabbabbaaababaaabaaaabababbbbbbbaabbaaabbabbbbbabbbaaaaababbbaaabaabababbabbabababbabbabaaaaabaaaaaabbbabaabbbaaaabbabababaaababaabbbbbbbaaabbbabaabaaaabaabaababbaaaabababaabbbaaaababaaababbbbbbabbbbbbaabbabbaaa...

output:

43524

result:

ok single line: '43524'

Test #18:

score: 25
Accepted
time: 55ms
memory: 76200kb

input:

baaaabbbabbbbabbbbabbbabbbbbabbbabbaabbbbbbabbabaabbbbbbbbbbbbaabbbbbaaabaaabbbbbaabbbbbbbbbbbbbababbbbabbbbbbbbbbbbbbbbabbbbbbbbabbbbabbbbaabaabbbabbbabbbaabbbbbabbbbbbaaabbbbbbaaabbaaabbabbabbbbbaabbbbbabbabababbbbbbbbbbbbabbbbaabbbbabbbbbbbbbbbbbbbabbbbbabbabbabababbbabbbbaabbabbbbbbbbaabbaabbbbb...

output:

107148

result:

ok single line: '107148'

Test #19:

score: 25
Accepted
time: 55ms
memory: 88056kb

input:

bbbbbabbbbbabbbbbbbbbbbbbbbbbbaaabbbbbbabbbbbbbaababbbbbbbbbbbabbbbbababbaabbbbbbbbbbbbbbbbbbabbbbabbbbbbbbaabbbbabbbbbbbbaabbbbbbbbbbbbbbbbbbbbbbabbbbbbaaabbabbbbbbabbbbbbabbbabbabbbbabbbbbbbbbbbbbabbbbbabbbbbbbbbbbbababbbbbbbbbbababbbabbabbbabbbabbabbbbabbababbbbbbbbbbbbbababbbbbabbbabbbbabbbbbbab...

output:

84043

result:

ok single line: '84043'

Test #20:

score: 25
Accepted
time: 37ms
memory: 75460kb

input:

baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

3

result:

ok single line: '3'

Test #21:

score: 25
Accepted
time: 47ms
memory: 78584kb

input:

bbbbbbbbbbbbbbbbabbbbbbbbabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbabbbbbbabbabbbbbbbbbbbbbbbbbb...

output:

142965

result:

ok single line: '142965'

Test #22:

score: 25
Accepted
time: 28ms
memory: 76120kb

input:

baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

5

result:

ok single line: '5'

Test #23:

score: 25
Accepted
time: 30ms
memory: 88420kb

input:

bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb...

output:

99972

result:

ok single line: '99972'

Test #24:

score: 25
Accepted
time: 16ms
memory: 75340kb

input:

bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb...

output:

99997

result:

ok single line: '99997'

Test #25:

score: 25
Accepted
time: 28ms
memory: 86724kb

input:

bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb...

output:

99999

result:

ok single line: '99999'

Test #26:

score: 25
Accepted
time: 35ms
memory: 89828kb

input:

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

130005

result:

ok single line: '130005'

Test #27:

score: 25
Accepted
time: 55ms
memory: 66512kb

input:

baabbaabaaabbaaaababaabbaabbabaabaaaabaaaaababaaabaabbbbaabbaabaaaabaabaaaaabaabbabaaaaabbaaabaaababbbbbabbbbbbbbabbbbbbbbabbaaabaabaaaabaaaabbbbbaaabaaaaaaabaaabbbaaabbbbbaaabbaaaababaabbbbaabaaabbbbaababaaabaaabbababbbababbabaaaaabaaababbaaabbbabababaababaabbababaaaabbababaababbbbbbaabbaabababbaab...

output:

67291

result:

ok single line: '67291'

Test #28:

score: 25
Accepted
time: 32ms
memory: 83928kb

input:

baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

3

result:

ok single line: '3'

Subtask #5:

score: 25
Accepted

Dependency #1:

100%
Accepted

Dependency #4:

100%
Accepted

Test #29:

score: 25
Accepted
time: 127ms
memory: 107400kb

input:

aabbbaaaaaaaababaabaaaabbbbabababbaaaaaabaabbabbbaaabbaaabbaaaabbabaabaaababbbaaaabbababbabbaabbbbaabaaabbaabababaaaabbbbbabbbaaaaaabbbbabbaaababbaaabaaaabaaaaaaabbbaababaabababaabbabaababababaabbaabaaabababbbbabbbaaabbbbaabaaaabaaaaaababbababbaabbabaababbababbabbbbabbaabbabbbbbbbbaabaabbbbbbbbbbbba...

output:

72979

result:

ok single line: '72979'

Test #30:

score: 25
Accepted
time: 172ms
memory: 127208kb

input:

fefddeecdbffabadeeccbafdcfcabfacbfdbadccbcaebecdfeaaaebaacddcbacefacfcfdccfcecaabaebaeebeadddcfbaecdcaeebfbdeaecfdabcbdeabecbdbcdcdebedaaffacffbbedacefbffecfffebeebbfadabbfcafdbcedadbcddfbdedabbdafcacbafaeccaabbbbffceaebeebeeaffbdbfdceffdcdfdefdbedfdcddacefeafbcbaedbfefbaddeaecbcbfdaaacfdabeeacaaeea...

output:

68728

result:

ok single line: '68728'

Test #31:

score: 25
Accepted
time: 137ms
memory: 118452kb

input:

agahaiaaafagaeagagadajaaaeagagaiacacaeagaeafajajajajacafahaiagaeabaiaiaaagadaeabahacadafajagajahafacaaafadaiahahajajajaeagabahahahaeaaacahahaaafagababaeaeacagaiabacagaaaaaaafadaaajadafacagaaajaiahaiaaacabajaiagaiagacahadabahaaaeaeababadadaaaeaeacaeadaiaeaeagagadaaaiadabaiagaaaaaiajahahagacaeahahahaa...

output:

272423

result:

ok single line: '272423'

Test #32:

score: 25
Accepted
time: 43ms
memory: 143288kb

input:

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

250000

result:

ok single line: '250000'

Test #33:

score: 25
Accepted
time: 67ms
memory: 135280kb

input:

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

249976

result:

ok single line: '249976'

Test #34:

score: 25
Accepted
time: 118ms
memory: 110568kb

input:

abbabababbbaaabbbabbabaaababbabbabbaabbbaabaababbbbaabaabaaabbbbbbaabbbabbbbbabababbbbaababbbbaabaaaaabbbbbbbabbbbabaabaaaababbaabaaaabbbaabbbabbbbaaaaaabbaaaaababbaaabaaaabbaabaabbbabababbababbbbababaaaabbabbbbbbbbbbaaaababababababababaababbbaabbbbbabbbbabbbbbababbabbabbaaaabaaabbababaaabbbabbbbbbb...

output:

106249

result:

ok single line: '106249'

Test #35:

score: 25
Accepted
time: 107ms
memory: 111128kb

input:

abaaabbabbbabbaabbbbbbbabbaababbbabbaabbabaabbabbbbabaababbbbaaaaabbbbbbababbbaabaababaabbbaaababaaaaaaaabaaabaaaaaabaaabbbbabbabbaaabbaabbabbbaabbbbaaabaaaabbaabababbaaabbaaaabbabbbbaabbaaabaaaabbbaabbabbbbaababaabaaaaabbbabbbbababaaabbaabababbaababbabbbbbbabaaaabbbbbaaababbbaaaababaaaaaababaababba...

output:

175546

result:

ok single line: '175546'

Test #36:

score: 25
Accepted
time: 134ms
memory: 119448kb

input:

zksvttiyllprjwwcbhfjhdixsaxlgmolhwqrenaqnhuupvjlloduecabbumzrblxlhrmbiiwsfuyqnxpkqyesjtvvhdxmakdkenackoorbdsaaauhdnyjtpvunfnhjxgexufgcmlofvybcaoaisoofrgcypcaaxtbvwhlkilgryxblkpnprmpnjekybsnwngnudeohozwjdgwnifuxogrkszgjebmanxcvbjfpetcnytapxkmqdoivsqzpfxhckmsosohwtcvdubnfjyydagtarffsmnmjszjyskysyrudrl...

output:

12409

result:

ok single line: '12409'

Test #37:

score: 25
Accepted
time: 149ms
memory: 118828kb

input:

ifcjrrilczgpvwvcryxjygnifpgmkvpzqqapttabzfzcgooybkcnfwtqmjynftxlbqqtsnwcmdrfvpvxhppqwvipewfabeyplslxlplhkrvtyqejmrrwrfxpxwnqynafskbrulumilnsvtnwfmzlvwcmtlsnsidgqwknknlpwpvdurazgajldygvijqpdmkjuygdbhduzopepwbovtggvpvegyhdlenyglmrpdfaolqiseowiqeqsbtuedprcezazmyrtudwpilozezxipedcyfnykueyvgghfpzzlcqsues...

output:

3103

result:

ok single line: '3103'

Test #38:

score: 25
Accepted
time: 160ms
memory: 131416kb

input:

bcbefabbbbacdcfccfedddffbdaddbbdfcdbcbaffdcccbdecddbcfdcffbdeafcaffbebfbcaecaceacadafbcedddabfcdeeffeeebeafccfbdebeccbcdbeaebbfeabedecfdfdadafabbadbddffdbabddacebdcbdefbddebeaaceeceedeecddbbcbfcabbaebcceddcedfaababecdbbebadcfaeacfcdaefeeacebcbdeaadaafffebdcaabadebdbebacfecddccdbddffaeafbdaeefaafbcbb...

output:

59712

result:

ok single line: '59712'

Test #39:

score: 25
Accepted
time: 177ms
memory: 129920kb

input:

dfdbdbacddfcbadafcadaabaafcfbfebcaabefecfbbddceccddacefbadfdcefbcbecdbfceaccdaaaefcfdfefecfaecebacfcccbcaeffccbaceaeddcfadaddadbeedbbbfabbefbaddecefaeadcceabeedfeedaedfdbcacecddacedfeecfbcebfbbccecaccaaadeeeebeebeefaeacdafcedbeaccbfcacaefdcddeaeefdabfccadbfbcbeceedddaeaddffdfddafacdfacfeaffdadcbbded...

output:

59161

result:

ok single line: '59161'

Test #40:

score: 25
Accepted
time: 68ms
memory: 139684kb

input:

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

249976

result:

ok single line: '249976'

Test #41:

score: 25
Accepted
time: 43ms
memory: 140732kb

input:

baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

1

result:

ok single line: '1'

Test #42:

score: 25
Accepted
time: 118ms
memory: 112512kb

input:

abbabababbbaaabbbabbabaaababbabbabbaabbbaabaababbbbaabaabaaabbbbbbaabbbabbbbbabababbbbaababbbbaabaaaaabbbbbbbabbbbabaabaaaababbaabaaaabbbaabbbabbbbaaaaaabbaaaaababbaaabaaaabbaabaabbbabababbababbbbababaaaabbabbbbbbbbbbaaaababababababababaababbbaabbbbbabbbbabbbbbababbabbabbaaaabaaabbababaaabbbabbbbbbb...

output:

106249

result:

ok single line: '106249'

Test #43:

score: 25
Accepted
time: 78ms
memory: 131348kb

input:

baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

71

result:

ok single line: '71'

Test #44:

score: 25
Accepted
time: 60ms
memory: 124420kb

input:

caaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

75

result:

ok single line: '75'

Test #45:

score: 25
Accepted
time: 76ms
memory: 124876kb

input:

baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

2

result:

ok single line: '2'

Subtask #6:

score: 25
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

100%
Accepted

Dependency #5:

100%
Accepted

Test #46:

score: 25
Accepted
time: 395ms
memory: 217920kb

input:

mwwbxfwwayliqflnawfefkmgmwtweyrxobkdiqdleenlncchjgdoonpyekqpklctjirybsftrlewxuyvelkmnprdsdfvzkhatjmamulwfqesxsqjhzoyxceyruxkrpucqcpbqetdnjfslcwdiglgryodhvcwiqrfcrkpvriwdnqkbrdxrqlhjhlhdjlbyhqdnwdsrafqgqpjhtrtkfuetacyzzuitfjstjgiulyxaoneeyspxjyfbvbbqfobidicseztwlwamagvduizgmyscfdumgafhjlbcnmwvtpjkgiz...

output:

3427

result:

ok single line: '3427'

Test #47:

score: 25
Accepted
time: 407ms
memory: 220264kb

input:

jpqxtaollqqmqvnxrznvviaaobvcnzizszcocelshqopokjbydrvsbewxhrqroqlewprxqdmmgetmanzdvmhoosjjypulwqddgsftctcwrfjgzhmsjsnjgizpczenspgmvfqbfxobzlndgveuvbitvrtfofjkexejnxsdmuoydyitdakindsmhjvxcukiwsvlkhjvzomdfcujnlaarlsocbsldjrcoicisxkttaspqhjxayjtvpgberegzscqhtxehkzpxeewpvhskfgmnadspyjdwrpjybztnhxplrwaqwo...

output:

31255

result:

ok single line: '31255'

Test #48:

score: 25
Accepted
time: 268ms
memory: 190076kb

input:

bbabbbaaabbbabaaaabababbabbbbbabbbbbbbbbbbabbbbbabbbaaabbbbaababaabbbbbbbbbbbbbabaabbaaabaababaabaaabbabbbabbbabaabbaabaababbbbbbaaabbbbaaabaabbbabbbabbabaabbbbabbbaabaaaabbbbbabaaaabaabbabaaabbaabbabbaaabbabaaababbababababaabaaaabaabaabaaabaabbbabbbbbaababbabbbabbbbababaaabbabbaaaabbbaaabaabbbaaaaa...

output:

295499

result:

ok single line: '295499'

Test #49:

score: 25
Accepted
time: 257ms
memory: 190896kb

input:

bbaababaaabababbbabbbbbabaaaababababbaababbaaabbabbbababaaaababbbbabbbababbaaaababbbaabaababbabbbaaaabbabbbabbaaaababababaabbbbbbaaababaabaaababaabababbbababbbbabbabaabaaabaaabaaababababaaabbbaaaaabaabbbbbbbababbabababbaabaababaabbbbaaababaabbaaabaabaabbbbaaabababbbaabaaabaaaabaaaaaabaaabaaaabbaaaab...

output:

142897

result:

ok single line: '142897'

Test #50:

score: 25
Accepted
time: 91ms
memory: 256736kb

input:

baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

1

result:

ok single line: '1'

Test #51:

score: 25
Accepted
time: 250ms
memory: 184836kb

input:

bbaaabaabababaaababbababaabbaaaabbabbbaabaaabaabaaaabbababbbaaabbaaaabaaabaaabbbabbbbabbaaaaababbbaabbabababaabbabbabbabbaaabbbaababaaabbabbaababaabaaabbbaababbbaaabbaaabbaabaabbababbaababbbbbaabaabababababaaaaabbbbabbabbbbabbbbabbbbabaabbbaabbabbaaaabbabaaabbbababbbaaabaaabbaaabaaabbbaabaaaabaabbaa...

output:

204172

result:

ok single line: '204172'

Test #52:

score: 25
Accepted
time: 465ms
memory: 240168kb

input:

eafebaefcabeaadaeeacecdfdfababaeadfbdaabcfccafcafacfbbdaebaddffaedbadafbbbfafcfbbceeccccbeddaefcddaaacaaaebdefdafadaacdaaebeaefbfaccfdbfaabfffafecacdedfabadafababedabcaabfaedefabfbccafccbacccafcdddaafaeddedadedbbbbfeefcbdabeaefaebeddeebaedadfcacaebcdccaeaeaaaacdcbfbeeeaeddeaaddacdcbfebaddbffddfaabca...

output:

21449

result:

ok single line: '21449'

Test #53:

score: 25
Accepted
time: 415ms
memory: 238836kb

input:

dbddbcffaeeecbdbcbccebcfdcbfeefbfbeffabfcedccbadadeecfbeefabdbacfefaebfbbcbbbeefffaacfeedffbbcfadecaefcddacfbfcbbddeeabeddccbfcaadcdeeaccfafaacaccdebdfcdbdafddcdbfbacfccfdfcedbfdecfebabaaadeddeeacbbbffafabcfceebcbdfaffbcbabdedfefbeddfedbceaedeabaedfecfbbbcaefdcadcceaeafeefaceabfcbadfdaaaaecfffefaaac...

output:

67202

result:

ok single line: '67202'

Test #54:

score: 25
Accepted
time: 145ms
memory: 240892kb

input:

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

500000

result:

ok single line: '500000'

Test #55:

score: 25
Accepted
time: 138ms
memory: 249044kb

input:

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

499954

result:

ok single line: '499954'

Test #56:

score: 25
Accepted
time: 303ms
memory: 212916kb

input:

ayaxaiakaeasaiacawakadaqacaqaoauakaeaqazaaamajabazauaradagalanahajaoahadadataqauawasawapabanaaapajahajadabalacadafadaaacaoadajaraqaaaaacaoaxaxajaeakafadapalacahayazadawakamaaafahacavatazacaoasacararacatamaralazaaadajavamamaxacarakauaoarayalakakalaqabafapaxavaaabafabaiajauaoanatarayaoakanaqalayataoap...

output:

500603

result:

ok single line: '500603'

Test #57:

score: 25
Accepted
time: 139ms
memory: 236704kb

input:

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

499950

result:

ok single line: '499950'

Test #58:

score: 25
Accepted
time: 421ms
memory: 272432kb

input:

acacababababaaacaaacacacaaaaabaaaaacacabacababacabacaaaaababaaacacacacacaaaaacacaaaaaaababaaaaabacaaacacabababaaacacacaaaaacacabacaaacacabacaaaaaaacacabaaababababacacaaaaaaacabacacaaacacacabaaabacaaabaaacabababacacaaacabacabaaabacabacaaabaaacaaacacaaaaabacacabaaacaaacacaaacacabaaacaaabababacaaacacac...

output:

537438

result:

ok single line: '537438'

Test #59:

score: 25
Accepted
time: 79ms
memory: 143720kb

input:

baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

76

result:

ok single line: '76'

Test #60:

score: 25
Accepted
time: 249ms
memory: 241332kb

input:

baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

3

result:

ok single line: '3'