QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#118107#5440. P-P-Palindromehos_lyricAC ✓276ms443236kbC++1412.2kb2023-07-03 03:45:262023-07-03 03:45:27

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-03 03:45:27]
  • 评测
  • 测评结果:AC
  • 用时:276ms
  • 内存:443236kb
  • [2023-07-03 03:45:26]
  • 提交

answer

#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

#include <cassert>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

using Int = long long;

template <class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &a) { return os << "(" << a.first << ", " << a.second << ")"; };
template <class T> ostream &operator<<(ostream &os, const vector<T> &as) { const int sz = as.size(); os << "["; for (int i = 0; i < sz; ++i) { if (i >= 256) { os << ", ..."; break; } if (i > 0) { os << ", "; } os << as[i]; } return os << "]"; }
template <class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cerr << *i << " "; cerr << endl; }
template <class T> bool chmin(T &t, const T &f) { if (t > f) { t = f; return true; } return false; }
template <class T> bool chmax(T &t, const T &f) { if (t < f) { t = f; return true; } return false; }


////////////////////////////////////////////////////////////////////////////////
// SA-IS
//   String: string, vector<int>, vector<long long>
//   if sigma <= n,  O(n) time, O(n) space
//   if sigma >  n,  O(n log n) time, O(n) space
template <class String> vector<int> suffixArrayRec(const String &as) {
  const int n = as.size();
  if (n == 0) return {};
  const auto minmaxA = minmax_element(as.begin(), as.end());
  const auto minA = *minmaxA.first, maxA = *minmaxA.second;
  if (static_cast<unsigned long long>(maxA) - minA >=
      static_cast<unsigned long long>(n)) {
    vector<int> us(n);
    for (int u = 0; u < n; ++u) us[u] = u;
    std::sort(us.begin(), us.end(), [&](int u, int v) -> bool {
      return (as[u] < as[v]);
    });
    int b = 0;
    vector<int> bs(n, 0);
    for (int i = 1; i < n; ++i) {
      if (as[us[i - 1]] != as[us[i]]) ++b;
      bs[us[i]] = b;
    }
    return suffixArrayRec(bs);
  }
  const int sigma = maxA - minA + 1;
  vector<int> pt(sigma + 1, 0), poss(sigma);
  for (int u = 0; u < n; ++u) ++pt[as[u] - minA + 1];
  for (int a = 0; a < sigma; ++a) pt[a + 1] += pt[a];
  // cmp[u] := (as[u, n) < as[u + 1, n))
  vector<bool> cmp(n);
  cmp[n - 1] = false;
  for (int u = n - 1; --u >= 0; ) {
    cmp[u] = (as[u] != as[u + 1]) ? (as[u] < as[u + 1]) : cmp[u + 1];
  }
  // ><,  nn - id (0 <= id < n)
  int nn = 0;
  vector<int> ids(n, 0);
  int last = n;
  vector<int> nxt(n, 0);
  // put ><, from the tail of each bucket
  vector<int> us(n, 0);
  memcpy(poss.data(), pt.data() + 1, sigma * sizeof(int));
  for (int u = n - 1; --u >= 1; ) if (!cmp[u - 1] && cmp[u]) {
    ids[u] = ++nn;
    nxt[u] = last;
    last = u;
    us[--poss[as[u] - minA]] = u;
  }
  // follow > backwards, from the head of each bucket
  memcpy(poss.data(), pt.data(), sigma * sizeof(int));
  us[poss[as[n - 1] - minA]++] = n - 1;
  for (int i = 0; i < n; ++i) {
    const int u = us[i];
    if (u && !cmp[u - 1]) us[poss[as[u - 1] - minA]++] = u - 1;
  }
  // follow < backwards, from the tail of each bucket
  memcpy(poss.data(), pt.data() + 1, sigma * sizeof(int));
  for (int i = n; --i >= 0; ) {
    const int u = us[i];
    if (u && cmp[u - 1]) us[--poss[as[u - 1] - minA]] = u - 1;
  }
  if (nn) {
    int vsLen = 0;
    vector<int> vs(nn);
    for (const int u : us) if (ids[u]) vs[vsLen++] = u;
    int b = 0;
    vector<int> bs(nn, 0);
    for (int j = 1; j < nn; ++j) {
      // as[v1, w1] (< or =) as[v0, w0]
      int v1 = vs[j - 1], v0 = vs[j];
      const int w1 = nxt[v1], w0 = nxt[v0];
      if (w1 - v1 != w0 - v0) {
        ++b;
      } else {
        for (; ; ++v1, ++v0) {
          if (v1 == n) { ++b; break; }
          if (as[v1] != as[v0]) { ++b; break; }
          if (v1 == w1) break;
        }
      }
      bs[nn - ids[vs[j]]] = b;
    }
    for (int u = 0; u < n; ++u) if (ids[u]) vs[nn - ids[u]] = u;
    const auto sub = suffixArrayRec(bs);
    // put ><, from the tail of each bucket
    memset(us.data(), 0, n * sizeof(int));
    memcpy(poss.data(), pt.data() + 1, sigma * sizeof(int));
    for (int j = nn; --j >= 0; ) {
      const int u = vs[sub[j]];
      us[--poss[as[u] - minA]] = u;
    }
    // follow > backwards, from the head of each bucket
    memcpy(poss.data(), pt.data(), sigma * sizeof(int));
    us[poss[as[n - 1] - minA]++] = n - 1;
    for (int i = 0; i < n; ++i) {
      const int u = us[i];
      if (u && !cmp[u - 1]) us[poss[as[u - 1] - minA]++] = u - 1;
    }
    // follow < backwards, from the tail of each bucket
    memcpy(poss.data(), pt.data() + 1, sigma * sizeof(int));
    for (int i = n; --i >= 0; ) {
      const int u = us[i];
      if (u && cmp[u - 1]) us[--poss[as[u - 1] - minA]] = u - 1;
    }
  }
  return us;
}

// us[i]: i-th suffix
// su[u]: index of as[u, n)
// hs[i]: longest common prefix of as[us[i - 1], n) and as[us[i], n)
struct SuffixArray {
  int n;
  bool rmq;
  vector<int> us, su, hs, bsr;
  SuffixArray() : n(0), rmq(false) {}
  SuffixArray(const string &as, bool rmq_) : rmq(rmq_) { build(as); }
  SuffixArray(const vector<int> &as, bool rmq_) : rmq(rmq_) { build(as); }
  SuffixArray(const vector<long long> &as, bool rmq_) : rmq(rmq_) { build(as); }
  template <class String> void build(const String &as) {
    n = as.size();
    us = suffixArrayRec(as);
    su.resize(n + 1);
    for (int i = 0; i < n; ++i) su[us[i]] = i;
    su[n] = -1;
    hs.assign(n, 0);
    for (int h = 0, u = 0; u < n; ++u) if (su[u]) {
      for (int v = us[su[u] - 1]; v + h < n && as[v + h] == as[u + h]; ++h) {}
      hs[su[u]] = h;
      if (h) --h;
    }
    if (rmq) {
      const int logN = n ? (31 - __builtin_clz(n)) : 0;
      hs.resize((logN + 1) * n - (1 << logN) + 1);
      for (int e = 0; e < logN; ++e) {
        int *hes = hs.data() + e * n;
        for (int i = 0; i <= n - (1 << (e + 1)); ++i) {
          hes[n + i] = min(hes[i], hes[i + (1 << e)]);
        }
      }
      bsr.resize(n + 1);
      bsr[0] = -1;
      for (int i = 1; i <= n; ++i) bsr[i] = bsr[i >> 1] + 1;
    }
  }
  // Returns longest common prefix of as[u, n) and as[v, n).
  //   0 <= u, v <= n
  //   Assumes rmq.
  inline int lcp(int u, int v) const {
    if (u == v) return n - u;
    int i = su[u], j = su[v];
    if (i > j) swap(i, j);
    const int e = bsr[j - i];
    return min(hs[e * n + i + 1], hs[e * n + j + 1 - (1 << e)]);
  }
};
////////////////////////////////////////////////////////////////////////////////


template <int SIZE_, char OFFSET_> struct Eertree {
  static constexpr int SIZE = SIZE_;
  static constexpr char OFFSET = OFFSET_;
  string s;
  int n;
  vector<int> us, len, fail;
  vector<int> nxt;
  Eertree(const string &s_) : s(s_) {
    n = s.size();
    us.assign(n + 3, 0);
    len.assign(n + 3, 0);
    fail.assign(n + 3, 0);
    nxt.assign((n + 3) * SIZE, 0);
    us[1] = 1; len[1] = -1; fail[1] = 1;
    us[2] = 2; len[2] =  0; fail[2] = 1;
    for (int i = 0; i < n; ++i) {
      const int c = s[i] - OFFSET;
      int u = us[i + 2];
      for (; !isSuffix(i, u); u = fail[u]) {}
      if (!nxt[u * SIZE + c]) {
        nxt[u * SIZE + c] = i + 3;
        len[i + 3] = len[u] + 2;
        if (u == 1) {
          fail[i + 3] = 2;
        } else {
          int v = fail[u];
          for (; !isSuffix(i, v); v = fail[v]) {}
          fail[i + 3] = nxt[v * SIZE + c];
        }
      }
      us[i + 3] = nxt[u * SIZE + c];
    }
  }
  bool isSuffix(int i, int u) const {
    const int j = i - 1 - len[u];
    return (j >= 0 && s[j] == s[i]);
  }
  void dfsPrint(int u, const string &prefix, int type) const {
    printf("%s%s%s %d %d\n",
           prefix.c_str(),
           ((type == 0) ? "" : (type == 1) ? "|-- " : "`-- "),
           ((len[u] <= 0) ? ("(" + to_string(len[u]) + ")")
                          : s.substr(u - 2 - len[u], len[u])).c_str(),
           u,
           fail[u]);
    vector<int> vs;
    for (int c = 0; c < SIZE; ++c) {
      const int v = nxt[u * SIZE + c];
      if (v) vs.push_back(v);
    }
    for (const int v : vs) {
      dfsPrint(v, prefix + ((type == 0) ? "" : (type == 1) ? "|   " : "    "),
               (v == vs.back()) ? 2 : 1);
    }
  }
  void print() const {
    dfsPrint(1, "", 0);
    dfsPrint(2, "  ", 0);
  }
};

////////////////////////////////////////////////////////////////////////////////


void experiment() {
  // min period
  auto factor = [&](const string &s) -> string {
    int n = s.size();
    for (int m = 1; m <= n; ++m) if (n % m == 0) {
      bool ok = true;
      // for (int i = 0, j = m - 1; i < j; ++i, --j) ok = ok && (s[i] == s[j]);
      for (int i = 0; i < n; ++i) ok = ok && (s[i] == s[i % m]);
      if (ok) {
        return s.substr(0, m);
      }
    }
    assert(false);
  };
  
  vector<string> pals;
  for (int n = 1; n <= 10; ++n) {
    for (int p = 0; p < 1 << (2 * n); ++p) {
      string s;
      for (int i = 0; i < n; ++i) s += (char)('a' + (p >> (2 * i) & 3));
      bool ok = true;
      for (int i = 0, j = n - 1; i < j; ++i, --j) ok = ok && (s[i] == s[j]);
      if (ok) pals.push_back(s);
    }
  }
cerr<<"|pals| = "<<pals.size()<<endl;
  for (const string &s : pals) for (const string &t : pals) {
    const string st = s + t;
    bool ok = true;
    for (int i = 0, j = (int)st.size() - 1; i < j; ++i, --j) ok = ok && (st[i] == st[j]);
    if (ok) {
      const string ss = factor(s);
      const string tt = factor(t);
      cout << s << " " << t << ": " << ss << " " << tt << endl;
      assert(ss == tt);
    }
  }
}


constexpr int LIM = 2'000'010;
int lpf[LIM];

char buf[LIM];

int N;
vector<int> pt;
string S;

int main() {
  // experiment();
  
  iota(lpf, lpf + LIM, 0);
  for (int p = 2; p < LIM; ++p) if (lpf[p] == p) {
    for (int n = 2 * p; n < LIM; n += p) chmin(lpf[n], p);
  }
  
  for (; ~scanf("%d", &N); ) {
    pt.clear();
    S = "";
    for (int i = 0; i < N; ++i) {
      scanf("%s", buf);
      pt.push_back((int)S.size());
      S += buf;
      S += '`';
    }
    pt.push_back((int)S.size());
// cerr<<"pt = "<<pt<<endl;
// cerr<<"S = "<<S<<endl;
    
    // Depam<char, 27, '`'> pam(0, pt[N]);
    // for (const char c : S) {
      // pam.pushBack(c);
    // }
    const Eertree<27, '`'> pam(S);
    const SuffixArray sa(S, true);
    
    // using Entry = pair<pair<int, int>, pair<int, int>>;
    using Entry = pair<int, int>;
    vector<Entry> es;
    // for (int u = 2; u < pam.nodesLen; ++u) {
    for (int u = 3; u < pam.n + 3; ++u) if (pam.us[u] == u) {
      // const int l = pam.nodes[u].pos - 1;
      // const int r = l + pam.nodes[u].len;
      const int pos = u - 2 - pam.len[u];
      const int len = pam.len[u];
      const int i = upper_bound(pt.begin(), pt.end(), pos) - pt.begin() - 1;
      if (pt[i] <= pos && pos + len <= pt[i + 1] - 1) {
        int per = len - pam.len[pam.fail[u]];
        if (len % per != 0) {
          per = len;
        }
// cerr<<S.substr(l,r-l)<<" "<<S.substr(ll,rr-ll)<<endl;
// cerr<<S.substr(pos,len)<<" "<<S.substr(pos,per)<<" "<<pos<<" "<<per<<endl;
        es.emplace_back(pos, per);
      }
    }
    const int esLen = es.size();
    
    auto cmp = [&](const pair<int, int> &e0, const pair<int, int> &e1) -> int {
      const int pos0 = e0.first, len0 = e0.second;
      const int pos1 = e1.first, len1 = e1.second;
      const int res = sa.lcp(pos0, pos1);
      if (res < len0 && res < len1) {
        if (S[pos0 + res] < S[pos1 + res]) return -1;
        if (S[pos0 + res] > S[pos1 + res]) return +1;
      }
      if (len0 < len1) return -1;
      if (len0 > len1) return +1;
      return 0;
    };
    sort(es.begin(), es.end(), [&](const Entry &e0, const Entry &e1) -> bool {
      return (cmp(e0, e1) < 0);
    });
    
    Int ans = 0;
    for (int i = 0, j; i < esLen; i = j) {
      for (j = i + 1; j < esLen && cmp(es[i], es[j]) == 0; ++j) {}
      const Int m = j - i;
      ans += m * m;
    }
    printf("%lld\n", ans);
  }
  return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 14ms
memory: 12200kb

input:

2
aaaa
aaa

output:

16

result:

ok 1 number(s): "16"

Test #2:

score: 0
Accepted
time: 15ms
memory: 11608kb

input:

3
abaaa
abbbba
bbbaba

output:

28

result:

ok 1 number(s): "28"

Test #3:

score: 0
Accepted
time: 15ms
memory: 13088kb

input:

1
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab

output:

15130

result:

ok 1 number(s): "15130"

Test #4:

score: 0
Accepted
time: 7ms
memory: 11904kb

input:

3
aaaaaaaaaaaaaaaaaaaaaaaaa
bbbbbbbbbbbbbbbbbbbbbbbbb
bababababababaabababababa

output:

1282

result:

ok 1 number(s): "1282"

Test #5:

score: 0
Accepted
time: 33ms
memory: 74244kb

input:

5
ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff...

output:

3600000000

result:

ok 1 number(s): "3600000000"

Test #6:

score: 0
Accepted
time: 33ms
memory: 74272kb

input:

5
wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww...

output:

3600000000

result:

ok 1 number(s): "3600000000"

Test #7:

score: 0
Accepted
time: 62ms
memory: 76344kb

input:

3
abbababbababbabbababbababbabbababbabbababbababbabbababbabbababbababbabbababbababbabbababbabbababbababbabbababbababbabbababbabbababbababbabbababbabbababbababbabbababbababbabbababbabbababbababbabbababbababbabbababbabbababbababbabbababbabbababbababbabbababbababbabbababbabbababbababbabbababbabbababbab...

output:

133586

result:

ok 1 number(s): "133586"

Test #8:

score: 0
Accepted
time: 57ms
memory: 75112kb

input:

3
abbabbababbabbababbababbabbababbabbababbababbabbababbababbabbababbabbababbababbabbababbabbababbababbabbababbababbabbababbabbababbababbabbababbababbabbababbabbababbababbabbababbabbababbababbabbababbababbabbababbabbababbababbabbababbababbabbababbabbababbababbabbababbabbababbababbabbababbababbabbabab...

output:

118967

result:

ok 1 number(s): "118967"

Test #9:

score: 0
Accepted
time: 52ms
memory: 75476kb

input:

3
bbababbabbababbabbababbababbabbababbabbababbababbabbababbababbabbababbabbababbababbabbababbababbabbababbabbababbababbabbababbabbababbababbabbababbababbabbababbabbababbababbabbababbababbabbababbabbababbababbabbababbabbababbababbabbababbababbabbababbabbababbababbabbababbabbababbababbabbababbababbabb...

output:

114444

result:

ok 1 number(s): "114444"

Test #10:

score: 0
Accepted
time: 47ms
memory: 75164kb

input:

3
abbabbababbababbabbababbababbabbababbabbababbababbabbababbabbababbababbabbababbababbabbababbabbababbababbabbababbababbabbababbabbababbababbabbababbabbababbababbabbababbababbabbababbabbababbababbabbababbababbabbababbabbababbababbabbababbabbababbababbabbababbababbabbababbabbababbababbabbababbabbabab...

output:

115321

result:

ok 1 number(s): "115321"

Test #11:

score: 0
Accepted
time: 63ms
memory: 74904kb

input:

3
azzazzazazzazzazazzazazzazzazazzazazzazzazazzazzazazzazazzazzazazzazazzazzazazzazzazazzazazzazzazazzazzazazzazazzazzazazzazazzazzazazzazzazazzazazzazzazazzazzazazzazazzazzazazzazazzazzazazzazzazazzazazzazzazazzazazzazzazazzazzazazzazazzazzazazzazzazazzazazzazzazazzazazzazzazazzazzazazzazazzazzazaz...

output:

131825

result:

ok 1 number(s): "131825"

Test #12:

score: 0
Accepted
time: 31ms
memory: 73296kb

input:

3
yazbyazbybyazbyazbybyazbybyazbyazbybyazbybyazbyazbybyazbyazbybyazbybyazbyazbybyazbybyazbyazbybyazbyazbybyazbybyazbyazbybyazbyazbybyazbybyazbyazbybyazbybyazbyazbybyazbyazbybyazbybyazbyazbybyazbybyazbyazbybyazbyazbybyazbybyazbyazbybyazbyazbybyazbybyazbyazbybyazbybyazbyazbybyazbyazbybyazbybyazbyazbyb...

output:

6

result:

ok 1 number(s): "6"

Test #13:

score: 0
Accepted
time: 26ms
memory: 72320kb

input:

3
azbybyazbyazbybyazbybyazbyazbybyazbyazbybyazbybyazbyazbybyazbyazbybyazbybyazbyazbybyazbybyazbyazbybyazbyazbybyazbybyazbyazbybyazbyazbybyazbybyazbyazbybyazbybyazbyazbybyazbyazbybyazbybyazbyazbybyazbybyazbyazbybyazbyazbybyazbybyazbyazbybyazbyazbybyazbybyazbyazbybyazbybyazbyazbybyazbyazbybyazbybyazby...

output:

6

result:

ok 1 number(s): "6"

Test #14:

score: 0
Accepted
time: 25ms
memory: 72608kb

input:

3
byazbybyazbyazbybyazbybyazbyazbybyazbybyazbyazbybyazbyazbybyazbybyazbyazbybyazbyazbybyazbybyazbyazbybyazbybyazbyazbybyazbyazbybyazbybyazbyazbybyazbybyazbyazbybyazbyazbybyazbybyazbyazbybyazbyazbybyazbybyazbyazbybyazbybyazbyazbybyazbyazbybyazbybyazbyazbybyazbyazbybyazbybyazbyazbybyazbybyazbyazbybyaz...

output:

6

result:

ok 1 number(s): "6"

Test #15:

score: 0
Accepted
time: 44ms
memory: 40972kb

input:

1
abbabaabbaababbabaababbaabbabaabbaababbaabbabaababbabaabbaababbabaababbaabbabaababbabaabbaababbaabbabaabbaababbabaababbaabbabaabbaababbaabbabaababbabaabbaababbaabbabaabbaababbabaababbaabbabaababbabaabbaababbabaababbaabbabaabbaababbaabbabaababbabaabbaababbabaababbaabbabaababbabaabbaababbaabbabaabba...

output:

113382

result:

ok 1 number(s): "113382"

Test #16:

score: 0
Accepted
time: 37ms
memory: 74932kb

input:

5
rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr...

output:

123447499

result:

ok 1 number(s): "123447499"

Test #17:

score: 0
Accepted
time: 38ms
memory: 72568kb

input:

5
tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt...

output:

25319820

result:

ok 1 number(s): "25319820"

Test #18:

score: 0
Accepted
time: 34ms
memory: 73124kb

input:

5
ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff...

output:

2746507

result:

ok 1 number(s): "2746507"

Test #19:

score: 0
Accepted
time: 38ms
memory: 75484kb

input:

3
oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo...

output:

1912677071

result:

ok 1 number(s): "1912677071"

Test #20:

score: 0
Accepted
time: 39ms
memory: 74808kb

input:

3
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...

output:

111259628

result:

ok 1 number(s): "111259628"

Test #21:

score: 0
Accepted
time: 42ms
memory: 72172kb

input:

3
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc...

output:

13754174

result:

ok 1 number(s): "13754174"

Test #22:

score: 0
Accepted
time: 33ms
memory: 72272kb

input:

3
dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd...

output:

1867151

result:

ok 1 number(s): "1867151"

Test #23:

score: 0
Accepted
time: 28ms
memory: 72456kb

input:

1
jjqjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjvjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj...

output:

1856484

result:

ok 1 number(s): "1856484"

Test #24:

score: 0
Accepted
time: 34ms
memory: 72672kb

input:

1
vvvvvvvvvvvvvvvvvvvvvvvvvvvqvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvmvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvsvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvnvvvvvvvvvvvvvvvvvvvv...

output:

190722

result:

ok 1 number(s): "190722"

Test #25:

score: 0
Accepted
time: 38ms
memory: 73340kb

input:

1
txxxxxxxxxxxxxxxxxxxxxxxxxxxxhxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxrxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxhxxxxxtxlxxxxxxxxxktxxxxxxxxxxxxxxxxxexxxxxxxxxxxxxxgxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxjxxxxxxxxxxxxxxxxxxxvxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxzqxxjxxxxxxxxxxxxxxx...

output:

76004

result:

ok 1 number(s): "76004"

Test #26:

score: 0
Accepted
time: 38ms
memory: 73300kb

input:

1
gggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg...

output:

81149988

result:

ok 1 number(s): "81149988"

Test #27:

score: 0
Accepted
time: 38ms
memory: 74800kb

input:

1
llllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll...

output:

1272080790

result:

ok 1 number(s): "1272080790"

Test #28:

score: 0
Accepted
time: 45ms
memory: 75560kb

input:

1
eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee...

output:

12890286923

result:

ok 1 number(s): "12890286923"

Test #29:

score: 0
Accepted
time: 50ms
memory: 74016kb

input:

5
dgasxxawfuzttbnrniddspiplejfqzzoadnogyemjktjqqjtkjmeygondaozzqfjelpipsddinrnbttzufwaxxsagdvkrreghjrkkrjhgerrkvdgasxxawfuzttbnrniddspiplejfqzzoadnogyemjktjqqjtkjmeygondaozzqfjelpipsddinrnbttzufwaxxsagdvkrreghjrkkrjhgerrkvdgasxxawfuzttbnrniddspiplejfqzzoadnogyemjktjqqjtkjmeygondaozzqfjelpipsddinrnbt...

output:

652993

result:

ok 1 number(s): "652993"

Test #30:

score: 0
Accepted
time: 37ms
memory: 74440kb

input:

5
jlpzojmatlmawicowbaazzfyzqdjodsyngoqfnxbshbjywkgafhdarnchbwcskosqxpdjffjdpxqsokscwbhcnradhfagkwyjbhsbxnfqognysdojdqzyfzzaabwociwamltamjozpljjlpzojmatlmawicowbaazzfyzqdjodsyngoqfnxbshbjywkgafhdarnchbwcskosqxpdjffjdpxqsokscwbhcnradhfagkwyjbhsbxnfqognysdojdqzyfzzaabwociwamltamjozpljjlpzojmatlmawicowb...

output:

425510

result:

ok 1 number(s): "425510"

Test #31:

score: 0
Accepted
time: 41ms
memory: 74432kb

input:

5
zwzxfvwcwglyetqbpgxubiqntaydeqmdpassapdmqedyatnqibuxgpbqteylgwcwvfxzwzjeiveeviejzwzxfvwcwglyetqbpgxubiqntaydeqmdpassapdmqedyatnqibuxgpbqteylgwcwvfxzwzjeiveeviejzwzxfvwcwglyetqbpgxubiqntaydeqmdpassapdmqedyatnqibuxgpbqteylgwcwvfxzwzjeiveeviejzwzxfvwcwglyetqbpgxubiqntaydeqmdpassapdmqedyatnqibuxgpbqte...

output:

1180524

result:

ok 1 number(s): "1180524"

Test #32:

score: 0
Accepted
time: 35ms
memory: 73772kb

input:

5
rmgwqmkvznpmdkqiiqkdmpnzvkmqwgmrpocxxcoprmgwqmkvznpmdkqiiqkdmpnzvkmqwgmrpocxxcoprmgwqmkvznpmdkqiiqkdmpnzvkmqwgmrpocxxcoprmgwqmkvznpmdkqiiqkdmpnzvkmqwgmrpocxxcoprmgwqmkvznpmdkqiiqkdmpnzvkmqwgmrpocxxcoprmgwqmkvznpmdkqiiqkdmpnzvkmqwgmrpocxxcoprmgwqmkvznpmdkqiiqkdmpnzvkmqwgmrpocxxcoprmgwqmkvznpmdkqiiq...

output:

4551019

result:

ok 1 number(s): "4551019"

Test #33:

score: 0
Accepted
time: 46ms
memory: 74580kb

input:

5
tnzbhxooxhbzntlskksltnzbhxooxhbzntlskksltnzbhxooxhbzntlskksltnzbhxooxhbzntlskksltnzbhxooxhbzntlskksltnzbhxooxhbzntlskksltnzbhxooxhbzntlskksltnzbhxooxhbzntlskksltnzbhxooxhbzntlskksltnzbhxooxhbzntlskksltnzbhxooxhbzntlskksltnzbhxooxhbzntlskksltnzbhxooxhbzntlskksltnzbhxooxhbzntlskksltnzbhxooxhbzntlskk...

output:

18042012

result:

ok 1 number(s): "18042012"

Test #34:

score: 0
Accepted
time: 40ms
memory: 74232kb

input:

5
wosalwxbdgvouchgnkqygjphbtpoxduzlpmpbuhhmwvgsbrfolbykyjzoukregdyxskkinjqzjeuublzpuukcaazbsggluyqlmyiallofjebbukuqcalufrqdjjkgvooretzaasgnpnztfalutzztulaftznpngsaazteroovgkjjdqrfulacqukubbejfollaiymlqyulggsbzaackuupzlbuuejzqjnikksxydgerkuozjykyblofrbsgvwmhhubpmplzudxoptbhpjgyqknghcuovgdbxwlasowovxg...

output:

61625

result:

ok 1 number(s): "61625"

Test #35:

score: 0
Accepted
time: 44ms
memory: 72728kb

input:

5
pyybsfiukgpneuwnykmxylcpaujvzpvcubdlvljkdwxkniwznzqvfblfedmydoqqrysksoobrwsqguocoxtfnisqmtbbieekshiwrzrbluflrtzfxwkvqtplcinkqqjsxogdsyucodbzhhnzaluymttfnzovqnevrqtbtqpmtgsfvnenstchzhdrequfxuasnkoxexafwpbgzqaobiicvmwugeugfgpmjvfphfojacdfhjplypqfoxzoacnfoucbhlqqnxxywfdaykxbsfkkkbwuryfwowvhecdgtnzcnp...

output:

57998

result:

ok 1 number(s): "57998"

Test #36:

score: 0
Accepted
time: 43ms
memory: 72744kb

input:

5
pndpupqzhnvxfilkpqdiabywphmclxjchfoctreacxnxwernjkhtyrgokfjpcuuqstsoserfmhfnrgdhzsioknvrhqflrjfkgkjrtoouchgeduceggstnsraurhpxgreryesioloxkcnndjdzyrfmksunizovolqltamzkmaggqftuvwjnkrhgyewthkqchdrgqrkwdfdwdoqunjulkpykaavlinxbzfuzzoqyvwrsfgmtvrzoyidesgkfwtbunicodseljtsxdzxpvpjnbaunefavrjjzhufqqsvekbpl...

output:

46840

result:

ok 1 number(s): "46840"

Test #37:

score: 0
Accepted
time: 42ms
memory: 79460kb

input:

1
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

90000000000

result:

ok 1 number(s): "90000000000"

Test #38:

score: 0
Accepted
time: 45ms
memory: 74024kb

input:

5
nmnnmnnmnnmnnmmmnnmmmmmnnnnnmmnmnnnnnmmnmmmnnnmnmnmnmmmmmnnnnmnnnmnnnmmmnmnmmmmnmmnmmmnnnnmmmmmnmnnmmmnmmnmmnmmmnnnmmmnmmnnnmmmnnmnnnmnmmmnnnnmmmnmnnmnmmmmnnnnnnnmnnnmmmmnmmnnnmnnnmmmnnmmnmnmmnnmmmmnnmnnnmmmmmmnmmnnnmnnnnnmmnmnmmnmnnnmnmmnmnmmmnnmmnmnnnmnmmmmnmnnnmmmnmnmmnnnnnmmmnnmnnnnnnmmmmmmmnm...

output:

4526

result:

ok 1 number(s): "4526"

Test #39:

score: 0
Accepted
time: 44ms
memory: 72824kb

input:

5
aaupapuupauuauapupapauauuuuuaapauuaaapppuauuppupuapappuapuuuuaupappaauupapppuppauuaauppuappaappaupaaapaapupuuapaauuuppppuaapaaauuapupuaaapppuuaaapuuuapuaupaaapupaauaapuaapaaaaupuuuupupuapaaaapaupaaaapppuapapuauauapuaauuapapuappauauappuappppuppaauapapuapuauuapupaupaauauupaauapuaupauauuapaappaapaapp...

output:

2372

result:

ok 1 number(s): "2372"

Test #40:

score: 0
Accepted
time: 48ms
memory: 74156kb

input:

5
bkdbddddvddkvkvdbkvdvbbdkkkvvkbvbvbvvbvvvkdbdkkkdvbdkdkvbbbbkbbvbkddkbdvbkkkbdvvdkkdvkbkkdvddbdvdkkdkvbkkdkkbvddddvdvvkkvbbdvkkvkbkkkkkvddbbkdkbvdkbkkdvkvvvvkbkkvkbbdvbkdbkdbkvkkkkvkvkkvvkkvkbbvbvbbbvkbvbvkkvkvkbvbdvvdkkvdbkvbdvvdkvddvvddvkdbkbbvkbvdbvvdddkbdddvbbbdvvdddvdkbdkbkkdbvbkdvdddvddbkkvk...

output:

2339

result:

ok 1 number(s): "2339"

Test #41:

score: 0
Accepted
time: 12ms
memory: 11620kb

input:

2
afffafafaa
afaafaafaf

output:

29

result:

ok 1 number(s): "29"

Test #42:

score: 0
Accepted
time: 54ms
memory: 73264kb

input:

5
wjdulwwjulujdddljudwwlddduddujljjjdluljwddjuddddljwjuujdllllljuudddjwududddudllwudluldwudddwdllldlwwwdjlwuwwlddlluluwdlldjuudujdjujddwduwwjwlluudjjujjdudlljwdwduwjdljlwdjddwddddludwuuwlddddddljddlduddwldwddllduwjwddjdulwddjwddddwujwluujjjludwjddwwdjwddulldjwljudjljljduddjlddjujdddddudduljduuuljwul...

output:

2063

result:

ok 1 number(s): "2063"

Test #43:

score: 0
Accepted
time: 276ms
memory: 443236kb

input:

1000000
i
n
l
f
q
i
s
m
u
x
r
v
v
u
b
m
o
u
s
q
k
t
t
c
n
t
y
m
x
q
k
v
h
q
s
w
o
b
o
y
n
s
f
w
d
d
y
d
l
i
e
r
c
l
e
d
h
h
c
l
x
q
f
l
v
j
q
j
p
o
e
s
l
w
u
h
q
f
j
g
l
h
v
x
k
w
t
h
o
b
e
s
x
c
m
v
r
r
p
w
d
g
r
u
g
d
j
a
a
c
w
t
u
h
x
i
l
s
o
z
i
m
p
h
j
u
p
t
g
f
p
w
x
f
o
w
u
m
a
k
p
p
q
x
n
r
...

output:

26

result:

ok 1 number(s): "26"

Test #44:

score: 0
Accepted
time: 259ms
memory: 441808kb

input:

1000000
u
i
n
f
z
i
g
y
o
t
a
t
y
q
m
g
u
z
t
j
j
s
f
r
f
z
a
e
k
s
q
u
p
e
o
l
x
g
q
b
l
w
x
c
u
x
j
e
s
e
y
r
r
v
v
i
d
p
q
e
q
q
z
a
d
i
e
y
w
p
e
x
m
n
e
f
j
l
c
y
x
i
d
a
m
k
w
q
y
j
c
u
y
h
k
l
y
j
r
e
r
b
n
i
w
r
o
i
q
m
o
r
x
d
s
u
n
i
w
r
t
g
c
i
d
h
n
a
x
h
t
c
s
h
c
j
c
i
b
z
u
z
c
b
e
k
...

output:

26

result:

ok 1 number(s): "26"

Test #45:

score: 0
Accepted
time: 270ms
memory: 438784kb

input:

1000000
c
c
b
c
b
b
a
c
c
b
c
b
a
a
a
a
c
b
a
c
c
c
c
b
c
a
c
c
b
a
a
a
c
c
b
b
c
a
c
a
c
c
c
c
a
b
c
b
a
b
c
a
a
a
b
c
a
c
b
c
b
a
c
b
a
b
c
c
a
c
b
c
a
b
c
c
b
a
a
a
c
b
c
a
b
b
c
b
a
a
c
c
c
b
b
a
b
a
c
b
a
b
c
b
b
b
a
b
a
a
c
a
b
b
c
a
a
c
c
b
a
a
c
b
a
b
a
b
b
b
b
b
c
a
b
b
c
a
a
a
b
a
b
b
a
c
...

output:

3

result:

ok 1 number(s): "3"

Test #46:

score: 0
Accepted
time: 136ms
memory: 221720kb

input:

1
alngdzgfsplrmhhyblurpjxyqhrxmbyyubvvxtmuwrnfimiggwhsoluetintakqfohgtmtampxljpkawolbuyrsrmdjapecfytjcfxcdcyymbfaqshkujxxypteohceukrejaveenkmsdxrmpdlapcnsnowykiiqisgdratbqcwxfzspkglkqghmcsiqwemkilaisqucgithhcrjvoydpnmtmxdwsmjfjtimsqpvesagpqucssfwyricarvcpcujfsxupluoxxkzelyjqewsptiyobhrvdatjhbcohcdfd...

output:

3195

result:

ok 1 number(s): "3195"

Test #47:

score: 0
Accepted
time: 135ms
memory: 220648kb

input:

1
ghbhcdfhccifjigghcfhejhfcaibghfhehehjichadijbiihajddhgjgbdibecjjcaagedfaafejcfjjgdaiebcjihecjicadacefgbajeafccjdbafdjhjddjggbdhgdijbbiadeabbaiieacbeighagbaajgdbdajgajcabhcgfcadbadigjhehaibighhdjhaeggefhgfcfhaahhchedcjhbaedihgfgjiejeifbdieacghbghfjdjfehfgdfadeeghdjdcghibjdhiiggdchdbihfchbhchaeefccb...

output:

3395

result:

ok 1 number(s): "3395"

Test #48:

score: 0
Accepted
time: 152ms
memory: 220144kb

input:

1
fgffhhghheehgggfgghdeeeedgfdhdfehghhegeeggfhgdfhgfgedgdgdegedhegeedddefdfedhfgdhghehhggehdffdfgddhegeghefffgddedfeeggfheghhgghhhehfefhfegfgghfffdhfddgheegdgefdhhegfffefghhehgggheegdggddeggdehddhdfefgeffdgfdghefgegdhegdfggeggddhhddefghfgedhhdeghgfedhddefdhfhfdhfdghhegedfhdeefffegedddgfgefheffeeeedd...

output:

4178

result:

ok 1 number(s): "4178"

Test #49:

score: 0
Accepted
time: 154ms
memory: 219920kb

input:

100
xuxmuutatmmtxmautmmttuuaatmtamxmutxautxxttmuamtxaaumaautaaattmmmxumtxaaxmxxmmumuttmututmtmuauutuuuumtuaxmaaxattxattuuxumxtummmttmmutmmataxuuttattmatumxxatuxumatxutmtuuaaatxatutmmtutauauuuuxumataxtamauttaaxxuttaaxtauamammxumauxumuuutmuxmauxutuxuxtutmtatuxttxtummtxutxmaxuuxxtxuatuamuxaatuatuauxxmu...

output:

30276

result:

ok 1 number(s): "30276"

Test #50:

score: 0
Accepted
time: 136ms
memory: 219084kb

input:

100
wddldawddddlwwawawdwdldldldldawdwwdwaaddlddddadwladdddaddawadladlwldlalldddlddlddwdlwwddaddllwwdldddwwldddaadwadddddlddlwwdawawdwaawadadadldddwaaldadallwdwlwdlddadlddladdlddddaaddddlwwdaalddddwldaddadaddwawwalaalladdalllddadwddddadlwlddlddwldaadlwddwlldddadwwaddaaldddwwlddddddwddadddalwawddwdawd...

output:

30213

result:

ok 1 number(s): "30213"

Test #51:

score: 0
Accepted
time: 137ms
memory: 219584kb

input:

100
ygripyrkwoyooyykfppktyktktikoyyogttiorfyptgtogkygrtkiwgyoipkpkkiiikypgftggfpktrwoygfwptwpwfyptpwrwyigyokwprkfpkfkfwpfykrfygoyykkgfigyktyryrfpkfwoipoipotypiifpyooykkpokgopooykywyiwgoypwtwygfikorpoirptfffkwirriyyyypfpkiwrpyfgtwrtfyfotpttfrwpfoprftpyigfrtggpwifypwyfpowpripgtfrgkyirkrorfgrorwpopioig...

output:

16720

result:

ok 1 number(s): "16720"

Test #52:

score: 0
Accepted
time: 179ms
memory: 226696kb

input:

100
ywwcynkynntwwqtcyjcnkjtkwctnqwcttnnqwqjjqjjwykwwyjwnywkwqwnjytqkyyjwqwwycyycjtqyqyjyqqynqwwtnwcjwjckjnnywjwwjntnwwjywywwwkwwtcqnkqqjqqwkknnykjcynwnyyqwjwyjckkcnqyqwkywyykkwcwwwkcknkwttnqyqytnttyjqtwwywqyytywkcwyqnqwywwwtwywjwqjwcwcqwkqcqnywkkwyncjwtkcwqtjycywtjkywyknyjqcwqwtywqjktwytkcwykwknnwyj...

output:

346933

result:

ok 1 number(s): "346933"

Test #53:

score: 0
Accepted
time: 192ms
memory: 227248kb

input:

100
nmxxmmvdyyfnmmvmmunvmfmvrnddnryrmdrvuurmuvnmudnnrrmyvmvuvdxvyxvmumnnrxummffuvdrmxnydfxnxfnxmnvmyfnmuyxruxfymyryunrmfmdmmxmufnmmmmmryrnfmrrvrfvfdxumymxmmxmxxmnfyddmmurvfvumfmxrmvfmnxnmnrvmyxfyrvnyfyyvvrmryynruyxmfmvmxxmrxrvmxudyvfxndrnvunvmnyxvyfvvxrndmffdvrfvfmmufdumxdvmumvmmxnmxdudyyfrdvmrxvyyx...

output:

354764

result:

ok 1 number(s): "354764"

Test #54:

score: 0
Accepted
time: 120ms
memory: 223436kb

input:

100
hohohoohoohhoohhhhhhohohhhooohhohoooohohhhoooohohhhoohhooohhhooohhoooohooooooohohhhoohohohhhohoohhohhohhoohohhhohohoohhhohooooooohoooohhooohhhooohhoohhhohoooohhhohoooohohhooohhhohohhhhhhoohhoohoohohohhohhoohohhhohohoohhhohooooooohoooohhooohhhooohhoohhhohoooohhhohoooohohhooohhhohohhhhhhoohhoohooh...

output:

400202791

result:

ok 1 number(s): "400202791"

Test #55:

score: 0
Accepted
time: 137ms
memory: 223844kb

input:

100
yyyyyjyyjjjyyjjjjjyjyyyjyyjyyjyyyjyyyyjjyyjjjyyyjyyyyjjjyyyjjyjyyyyyyyyyjjjyyjjyjjjyyyyjjjyyyyjyyyyyyyyyyjyyyyjjjyyyyjjjyjjyyjjjyyyyyyyyyjyjjyyyjjjyyyyjyyyjjjyyjjyyyyjyyyjyyjyyjyyyjyjjjjjyyjjjyyjyyyyyyyyyyjyyjjjyyjjjjjyjyyyjyyjyyjyyyjyyyyjjyyjjjyyyjyyyyjjjyyyjjyjyyyyyyyyyjjjyyjjyjjjyyyyjjjyyyyjy...

output:

200209587

result:

ok 1 number(s): "200209587"

Test #56:

score: 0
Accepted
time: 125ms
memory: 223912kb

input:

100
coppocpcpccpccppocopcooccopopccopccocccpocooccocpcppccocoppcocoppcoocoopopoooopppopppoccppccpcppccoccoccppcpccppccopppopppoooopopoocoocppococppococcppcpcoccoocopcccoccpoccpopoccoocpocoppccpccpcpcoppoccoccppcpccppccopppopppoooopopoocoocppococppococcppcpcoccoocopcccoccpoccpopoccoocpocoppccpccpcpco...

output:

203651

result:

ok 1 number(s): "203651"