QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#362607#8512. Harmonic Operationsucup-team987#AC ✓114ms13688kbC++2310.9kb2024-03-23 16:19:362024-03-23 16:19:37

Judging History

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

  • [2024-03-23 16:19:37]
  • 评测
  • 测评结果:AC
  • 用时:114ms
  • 内存:13688kb
  • [2024-03-23 16:19:36]
  • 提交

answer

#if __INCLUDE_LEVEL__ == 0

#include __BASE_FILE__

namespace {

void solve() {
  std::string s;
  scan(s);
  int n = len(s);
  int K;
  scan(K);
  std::vector<int> F(K);
  for (int& e : F) {
    char c;
    scan(c);
    if (c == 'I') {
      e = -1;
    } else if (c == 'L') {
      scan(e);
    } else if (c == 'R') {
      scan(e);
      e = n - e;
    } else {
      assert(false);
    }
  }

  {
    const auto z = atcoder::z_algorithm(s);
    int period = 1;
    while (period < n && (n % period != 0 || period + z[period] < n)) {
      ++period;
    }

    n = period;
    s.resize(n);
    for (int& e : F) {
      if (e != -1) {
        e %= n;
      }
    }
  }

  std::basic_string<bool> pref(n + 1, false);
  {
    const auto z = atcoder::z_algorithm(s + std::string(s.rbegin(), s.rend()));
    pref[0] = true;
    for (const int m : rep1(n)) {
      pref[m] = z[n * 2 - m] == m;
    }
  }

  std::basic_string<bool> suff(n + 1, false);
  {
    const auto z = atcoder::z_algorithm(std::string(s.rbegin(), s.rend()) + s);
    suff[n] = true;
    for (const int m : rep(n)) {
      suff[m] = z[n + m] == n - m;
    }
  }

  int m = -1;
  for (const int i : rep(n)) {
    if (pref[i] && suff[i]) {
      assert(m == -1);
      m = i;
    }
  }

  i64 ans = 0;
  if (m == -1) {
    std::map<std::pair<int, int>, int> mp;
    std::pair<int, int> cur{};
    ++mp[cur];
    for (const int e : F) {
      if (e == -1) {
        cur.first ^= 1;
      } else {
        if (cur.first == 0) {
          cur.second += e;
        } else {
          cur.second += n - e;
        }
      }
      cur.second %= n;
      ans += mp[cur]++;
    }

  } else {
    std::map<std::pair<int, int>, int> mp;
    std::pair<int, int> cur{};
    ++mp[cur];
    for (const int e : F) {
      if (e == -1) {
        cur.first ^= 1;
      } else {
        if (cur.first == 0) {
          cur.second += e;
        } else {
          cur.second += n - e;
        }
      }
      cur.second %= n;
      auto tmp = cur;
      tmp.first ^= 1;
      if (cur.first == 0) {
        tmp.second += m;
      } else {
        tmp.second += n - m;
      }
      tmp.second %= n;
      if (mp.contains(tmp)) {
        ans += mp[tmp];
      }
      ans += mp[cur]++;
    }
  }

  print(ans);
}

}  // namespace

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::cout << std::setprecision(DBL_DECIMAL_DIG);

  solve();
}

#else  // __INCLUDE_LEVEL__

#include <bits/stdc++.h>

namespace atcoder {

namespace internal {

std::vector<int> sa_naive(const std::vector<int>& s) {
  int n = int(s.size());
  std::vector<int> sa(n);
  std::iota(sa.begin(), sa.end(), 0);
  std::sort(sa.begin(), sa.end(), [&](int l, int r) {
    if (l == r) return false;
    while (l < n && r < n) {
      if (s[l] != s[r]) return s[l] < s[r];
      l++;
      r++;
    }
    return l == n;
  });
  return sa;
}

std::vector<int> sa_doubling(const std::vector<int>& s) {
  int n = int(s.size());
  std::vector<int> sa(n), rnk = s, tmp(n);
  std::iota(sa.begin(), sa.end(), 0);
  for (int k = 1; k < n; k *= 2) {
    auto cmp = [&](int x, int y) {
      if (rnk[x] != rnk[y]) return rnk[x] < rnk[y];
      int rx = x + k < n ? rnk[x + k] : -1;
      int ry = y + k < n ? rnk[y + k] : -1;
      return rx < ry;
    };
    std::sort(sa.begin(), sa.end(), cmp);
    tmp[sa[0]] = 0;
    for (int i = 1; i < n; i++) {
      tmp[sa[i]] = tmp[sa[i - 1]] + (cmp(sa[i - 1], sa[i]) ? 1 : 0);
    }
    std::swap(tmp, rnk);
  }
  return sa;
}

template <int THRESHOLD_NAIVE = 10, int THRESHOLD_DOUBLING = 40>
std::vector<int> sa_is(const std::vector<int>& s, int upper) {
  int n = int(s.size());
  if (n == 0) return {};
  if (n == 1) return {0};
  if (n == 2) {
    if (s[0] < s[1]) {
      return {0, 1};
    } else {
      return {1, 0};
    }
  }
  if (n < THRESHOLD_NAIVE) {
    return sa_naive(s);
  }
  if (n < THRESHOLD_DOUBLING) {
    return sa_doubling(s);
  }

  std::vector<int> sa(n);
  std::vector<bool> ls(n);
  for (int i = n - 2; i >= 0; i--) {
    ls[i] = (s[i] == s[i + 1]) ? ls[i + 1] : (s[i] < s[i + 1]);
  }
  std::vector<int> sum_l(upper + 1), sum_s(upper + 1);
  for (int i = 0; i < n; i++) {
    if (!ls[i]) {
      sum_s[s[i]]++;
    } else {
      sum_l[s[i] + 1]++;
    }
  }
  for (int i = 0; i <= upper; i++) {
    sum_s[i] += sum_l[i];
    if (i < upper) sum_l[i + 1] += sum_s[i];
  }

  auto induce = [&](const std::vector<int>& lms) {
    std::fill(sa.begin(), sa.end(), -1);
    std::vector<int> buf(upper + 1);
    std::copy(sum_s.begin(), sum_s.end(), buf.begin());
    for (auto d : lms) {
      if (d == n) continue;
      sa[buf[s[d]]++] = d;
    }
    std::copy(sum_l.begin(), sum_l.end(), buf.begin());
    sa[buf[s[n - 1]]++] = n - 1;
    for (int i = 0; i < n; i++) {
      int v = sa[i];
      if (v >= 1 && !ls[v - 1]) {
        sa[buf[s[v - 1]]++] = v - 1;
      }
    }
    std::copy(sum_l.begin(), sum_l.end(), buf.begin());
    for (int i = n - 1; i >= 0; i--) {
      int v = sa[i];
      if (v >= 1 && ls[v - 1]) {
        sa[--buf[s[v - 1] + 1]] = v - 1;
      }
    }
  };

  std::vector<int> lms_map(n + 1, -1);
  int m = 0;
  for (int i = 1; i < n; i++) {
    if (!ls[i - 1] && ls[i]) {
      lms_map[i] = m++;
    }
  }
  std::vector<int> lms;
  lms.reserve(m);
  for (int i = 1; i < n; i++) {
    if (!ls[i - 1] && ls[i]) {
      lms.push_back(i);
    }
  }

  induce(lms);

  if (m) {
    std::vector<int> sorted_lms;
    sorted_lms.reserve(m);
    for (int v : sa) {
      if (lms_map[v] != -1) sorted_lms.push_back(v);
    }
    std::vector<int> rec_s(m);
    int rec_upper = 0;
    rec_s[lms_map[sorted_lms[0]]] = 0;
    for (int i = 1; i < m; i++) {
      int l = sorted_lms[i - 1], r = sorted_lms[i];
      int end_l = (lms_map[l] + 1 < m) ? lms[lms_map[l] + 1] : n;
      int end_r = (lms_map[r] + 1 < m) ? lms[lms_map[r] + 1] : n;
      bool same = true;
      if (end_l - l != end_r - r) {
        same = false;
      } else {
        while (l < end_l) {
          if (s[l] != s[r]) {
            break;
          }
          l++;
          r++;
        }
        if (l == n || s[l] != s[r]) same = false;
      }
      if (!same) rec_upper++;
      rec_s[lms_map[sorted_lms[i]]] = rec_upper;
    }

    auto rec_sa = sa_is<THRESHOLD_NAIVE, THRESHOLD_DOUBLING>(rec_s, rec_upper);

    for (int i = 0; i < m; i++) {
      sorted_lms[i] = lms[rec_sa[i]];
    }
    induce(sorted_lms);
  }
  return sa;
}

}  // namespace internal

std::vector<int> suffix_array(const std::vector<int>& s, int upper) {
  assert(0 <= upper);
  for (int d : s) {
    assert(0 <= d && d <= upper);
  }
  auto sa = internal::sa_is(s, upper);
  return sa;
}

template <class T>
std::vector<int> suffix_array(const std::vector<T>& s) {
  int n = int(s.size());
  std::vector<int> idx(n);
  iota(idx.begin(), idx.end(), 0);
  sort(idx.begin(), idx.end(), [&](int l, int r) { return s[l] < s[r]; });
  std::vector<int> s2(n);
  int now = 0;
  for (int i = 0; i < n; i++) {
    if (i && s[idx[i - 1]] != s[idx[i]]) now++;
    s2[idx[i]] = now;
  }
  return internal::sa_is(s2, now);
}

std::vector<int> suffix_array(const std::string& s) {
  int n = int(s.size());
  std::vector<int> s2(n);
  for (int i = 0; i < n; i++) {
    s2[i] = s[i];
  }
  return internal::sa_is(s2, 255);
}

template <class T>
std::vector<int> lcp_array(const std::vector<T>& s, const std::vector<int>& sa) {
  int n = int(s.size());
  assert(n >= 1);
  std::vector<int> rnk(n);
  for (int i = 0; i < n; i++) {
    rnk[sa[i]] = i;
  }
  std::vector<int> lcp(n - 1);
  int h = 0;
  for (int i = 0; i < n; i++) {
    if (h > 0) h--;
    if (rnk[i] == 0) continue;
    int j = sa[rnk[i] - 1];
    for (; j + h < n && i + h < n; h++) {
      if (s[j + h] != s[i + h]) break;
    }
    lcp[rnk[i] - 1] = h;
  }
  return lcp;
}

std::vector<int> lcp_array(const std::string& s, const std::vector<int>& sa) {
  int n = int(s.size());
  std::vector<int> s2(n);
  for (int i = 0; i < n; i++) {
    s2[i] = s[i];
  }
  return lcp_array(s2, sa);
}

template <class T>
std::vector<int> z_algorithm(const std::vector<T>& s) {
  int n = int(s.size());
  if (n == 0) return {};
  std::vector<int> z(n);
  z[0] = 0;
  for (int i = 1, j = 0; i < n; i++) {
    int& k = z[i];
    k = (j + z[j] <= i) ? 0 : std::min(j + z[j] - i, z[i - j]);
    while (i + k < n && s[k] == s[i + k]) k++;
    if (j + z[j] < i + z[i]) j = i;
  }
  z[0] = n;
  return z;
}

std::vector<int> z_algorithm(const std::string& s) {
  int n = int(s.size());
  std::vector<int> s2(n);
  for (int i = 0; i < n; i++) {
    s2[i] = s[i];
  }
  return z_algorithm(s2);
}

}  // namespace atcoder

template <class T, class U = T>
bool chmin(T& x, U&& y) {
  return y < x && (x = std::forward<U>(y), true);
}

template <class T, class U = T>
bool chmax(T& x, U&& y) {
  return x < y && (x = std::forward<U>(y), true);
}

template <std::signed_integral T = int>
T inf() {
  T ret;
  std::memset(&ret, 0x3f, sizeof(ret));
  return ret;
}

template <std::floating_point T>
T inf() {
  return std::numeric_limits<T>::infinity();
}

template <class T>
concept Range = std::ranges::range<T> && !std::convertible_to<T, std::string_view>;

template <class T>
concept Tuple = std::__is_tuple_like<T>::value && !Range<T>;

namespace std {

istream& operator>>(istream& is, Range auto&& r) {
  for (auto&& e : r) {
    is >> e;
  }
  return is;
}

istream& operator>>(istream& is, Tuple auto&& t) {
  return apply([&](auto&... xs) -> istream& { return (is >> ... >> xs); }, t);
}

ostream& operator<<(ostream& os, Range auto&& r) {
  for (string_view sep = ""; auto&& e : r) {
    os << exchange(sep, " ") << e;
  }
  return os;
}

ostream& operator<<(ostream& os, Tuple auto&& t) {
  const auto f = [&](auto&... xs) -> ostream& {
    [[maybe_unused]] string_view sep = "";
    ((os << exchange(sep, " ") << xs), ...);
    return os;
  };
  return apply(f, t);
}

}  // namespace std

void scan(auto&&... xs) { std::cin >> std::tie(xs...); }
void print(auto&&... xs) { std::cout << std::tie(xs...) << '\n'; }

template <class F>
class fix {
 public:
  explicit fix(F f) : f_(std::move(f)) {}

  decltype(auto) operator()(auto&&... xs) const {
    return f_(std::ref(*this), std::forward<decltype(xs)>(xs)...);
  }

 private:
  F f_;
};

inline auto rep(int l, int r) { return std::views::iota(std::min(l, r), r); }
inline auto rep(int n) { return rep(0, n); }
inline auto rep1(int l, int r) { return rep(l, r + 1); }
inline auto rep1(int n) { return rep(1, n + 1); }

namespace ranges = std::ranges;
namespace views = std::views;

using i64 = std::int64_t;

#define len(...) static_cast<int>(ranges::size(__VA_ARGS__))

#endif  // __INCLUDE_LEVEL__

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3636kb

input:

pda
2
R 2
L 2

output:

1

result:

ok 1 number(s): "1"

Test #2:

score: 0
Accepted
time: 0ms
memory: 3676kb

input:

aaa
4
R 1
I
I
R 1

output:

10

result:

ok 1 number(s): "10"

Test #3:

score: 0
Accepted
time: 0ms
memory: 3700kb

input:

caso
6
L 1
I
I
R 1
I
I

output:

4

result:

ok 1 number(s): "4"

Test #4:

score: 0
Accepted
time: 0ms
memory: 3812kb

input:

qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq
100
L 12
I
R 47
L 54
I
I
R 80
L 86
L 19
R 5
L 53
L 40
R 20
L 11
R 40
I
I
R 66
R 6
L 76
L 93
R 39
I
I
L 24
R 59
R 99
L 52
I
I
R 77
L 11
R 60
L 16
I
L 40
I
R 35
L 64
R 11
L 34
I
R 35
I
L 87
I
I
L 42
L ...

output:

5050

result:

ok 1 number(s): "5050"

Test #5:

score: 0
Accepted
time: 0ms
memory: 3556kb

input:

wewewewewewewewewewewewewewewewewewewewewewewewewewewewewewewewewewewewewewewewewewewewewewewewewewe
100
R 83
R 34
I
I
R 87
R 74
L 98
I
L 77
L 8
R 23
L 94
I
I
L 79
L 87
L 47
L 85
L 49
L 7
I
I
R 97
R 15
I
R 66
L 8
R 62
R 68
I
I
R 32
R 24
R 36
L 60
R 75
R 77
I
L 42
I
L 61
I
I
R 78
R 51
L 98
I
L 77
I
I...

output:

2556

result:

ok 1 number(s): "2556"

Test #6:

score: 0
Accepted
time: 0ms
memory: 3640kb

input:

rtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtrtr
100
R 27
R 68
I
L 29
L 51
L 19
L 12
L 10
L 52
L 38
L 17
R 30
L 29
L 51
L 17
R 29
I
R 96
R 50
R 56
I
I
I
L 73
L 15
I
R 1
R 81
L 94
R 27
R 52
R 57
R 44
I
I
L 53
I
R 87
L 39
L 25
I
I
R 25
I
I
I
L 88
L ...

output:

116

result:

ok 1 number(s): "116"

Test #7:

score: 0
Accepted
time: 0ms
memory: 3568kb

input:

tcldtcldtcldtcldtcldtcldtcldtcldtcld
100
L 20
I
I
I
L 20
R 13
L 16
L 19
R 10
I
I
I
L 11
R 30
R 30
I
L 35
I
L 28
R 23
R 24
L 20
R 15
I
I
L 13
I
R 1
I
R 6
I
I
L 22
I
L 22
R 22
L 30
L 30
I
I
I
R 35
I
R 3
L 1
R 4
I
R 11
R 2
R 21
R 15
I
R 5
L 2
L 4
L 7
L 19
L 29
R 8
I
L 24
I
I
I
L 29
I
R 35
R 32
I
R 14
L...

output:

703

result:

ok 1 number(s): "703"

Test #8:

score: 0
Accepted
time: 0ms
memory: 3560kb

input:

wflbkhwflbkhwflbkhwflbkhwflbkhwflbkh
100
I
R 28
R 13
R 7
R 29
I
I
I
R 25
R 10
R 23
I
R 26
I
I
L 18
I
R 18
L 6
I
I
R 8
R 8
I
R 6
L 16
I
R 2
R 17
L 31
R 31
L 22
R 26
L 21
L 20
R 10
L 13
R 33
R 13
R 35
R 22
L 2
L 4
R 19
L 32
L 25
I
L 31
R 10
R 17
R 15
L 6
L 9
R 31
R 20
I
I
R 4
I
L 30
L 30
L 2
R 18
R 35...

output:

442

result:

ok 1 number(s): "442"

Test #9:

score: 0
Accepted
time: 0ms
memory: 3880kb

input:

mzgaokjwpmzgaokjwpmzgaokjwpmzgaokjwp
100
R 10
I
L 24
L 8
I
L 19
L 25
I
I
R 27
R 24
I
I
L 16
I
I
L 35
R 14
I
L 23
R 17
R 16
R 4
R 4
L 29
I
R 11
R 9
R 15
I
L 18
I
I
L 25
R 13
L 24
I
I
L 8
I
I
I
I
L 24
I
I
L 19
L 23
I
L 20
R 35
L 31
I
I
R 27
I
I
I
L 35
R 16
L 10
R 28
R 14
I
I
R 30
R 18
L 16
L 6
L 12
R ...

output:

280

result:

ok 1 number(s): "280"

Test #10:

score: 0
Accepted
time: 0ms
memory: 3852kb

input:

gtvcymjngzntgtvcymjngzntgtvcymjngznt
100
L 33
L 5
R 31
R 18
I
R 14
R 9
L 1
I
R 1
R 15
L 15
I
I
I
L 13
R 7
I
I
L 2
I
L 3
I
L 19
L 22
L 2
R 32
I
L 1
R 24
R 23
I
R 25
L 11
R 34
R 25
I
L 25
R 22
R 34
I
I
L 2
R 13
L 3
I
L 30
I
R 7
R 20
I
R 24
L 34
R 23
I
L 26
R 22
I
I
I
R 17
I
I
L 14
R 27
R 35
I
L 34
L 3...

output:

206

result:

ok 1 number(s): "206"

Test #11:

score: 0
Accepted
time: 0ms
memory: 3640kb

input:

dvaauyemcqhrmduoumdvaauyemcqhrmduoum
100
L 21
R 12
R 30
L 13
I
I
L 1
L 31
R 4
L 20
I
L 6
I
L 29
R 19
L 12
R 25
R 25
I
R 21
I
L 12
L 25
R 35
L 8
R 7
R 29
I
R 4
L 24
R 29
I
I
I
L 12
L 24
R 19
L 33
L 4
I
R 35
I
R 16
I
R 10
I
R 18
R 7
L 33
I
I
R 22
L 16
L 7
L 20
R 32
I
I
R 27
I
L 9
R 16
I
I
R 32
I
R 1
L...

output:

180

result:

ok 1 number(s): "180"

Test #12:

score: 0
Accepted
time: 0ms
memory: 3592kb

input:

pkmsckbnjeeojagpdtfxlmlgofbrygcuqiahynrwooxgdruurdgxoowrnyhaiqucgyrbfoglmlxftdpgajoeejnbkcsmkplhxxhl
100
L 14
R 54
L 88
L 66
L 38
R 91
I
I
I
I
R 56
L 4
L 76
R 12
L 86
I
I
I
I
R 52
L 98
L 98
L 39
R 60
L 14
R 23
R 92
R 99
L 71
I
I
I
I
L 1
R 33
I
R 65
L 72
I
I
I
R 20
R 48
L 81
L 7
I
R 72
R 14
I
I
R 10
...

output:

75

result:

ok 1 number(s): "75"

Test #13:

score: 0
Accepted
time: 0ms
memory: 3828kb

input:

txgcggvgarkkflejgkaukutnsjogrglpdmocuhyiboientoffaaaffotneiobiyhucomdplgrgojsntukuakgjelfkkragvggcgxt
100
R 35
R 84
I
R 68
R 24
L 42
L 24
R 16
R 80
R 95
L 9
L 26
L 96
R 64
I
R 56
I
L 5
R 83
R 2
R 57
R 28
I
R 17
I
R 11
I
R 100
L 42
I
L 89
I
L 91
I
I
R 78
I
R 30
L 6
I
L 56
L 48
R 79
L 8
I
R 5
L 25
R 2...

output:

76

result:

ok 1 number(s): "76"

Test #14:

score: 0
Accepted
time: 0ms
memory: 3832kb

input:

qhygenaiejhluibjfyjbdoslylsodbjyfjbiulhjeianegyhqydgoxbmbcuslmfqgraeqkpuerbnbreupkqeargqfmlsucbmbxogdy
100
L 41
R 73
R 41
I
R 59
R 77
I
I
R 21
L 5
R 30
R 3
L 94
I
L 36
R 2
R 85
L 39
L 17
R 47
I
R 86
L 30
R 38
R 80
I
R 39
I
I
L 99
I
L 15
I
L 76
L 68
L 91
I
R 71
R 36
L 14
L 15
I
L 63
R 71
I
L 38
I
R 3...

output:

48

result:

ok 1 number(s): "48"

Test #15:

score: 0
Accepted
time: 17ms
memory: 5980kb

input:

yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy...

output:

20000100000

result:

ok 1 number(s): "20000100000"

Test #16:

score: 0
Accepted
time: 16ms
memory: 5928kb

input:

uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu...

output:

20000100000

result:

ok 1 number(s): "20000100000"

Test #17:

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

input:

iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii...

output:

20000100000

result:

ok 1 number(s): "20000100000"

Test #18:

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

input:

opopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopopop...

output:

10000007832

result:

ok 1 number(s): "10000007832"

Test #19:

score: 0
Accepted
time: 114ms
memory: 13504kb

input:

asasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasasas...

output:

199395

result:

ok 1 number(s): "199395"

Test #20:

score: 0
Accepted
time: 14ms
memory: 5872kb

input:

dffdffdffdffdffdffdffdffdffdffdffdffdffdffdffdffdffdffdffdffdffdffdffdffdffdffdffdffdffdffdffdffdffdffdffdffdffdffdffdffdffdffdffdffdffdffdffdffdffdffdffdffdffdffdffdffdffdffdffdffdffdffdffdffdffdffdffdffdffdffdffdffdffdffdffdffdffdffdffdffdffdffdffdffdffdffdffdffdffdffdffdffdffdffdffdffdffdffdffdff...

output:

6666663346

result:

ok 1 number(s): "6666663346"

Test #21:

score: 0
Accepted
time: 16ms
memory: 6028kb

input:

ghjghjghjghjghjghjghjghjghjghjghjghjghjghjghjghjghjghjghjghjghjghjghjghjghjghjghjghjghjghjghjghjghjghjghjghjghjghjghjghjghjghjghjghjghjghjghjghjghjghjghjghjghjghjghjghjghjghjghjghjghjghjghjghjghjghjghjghjghjghjghjghjghjghjghjghjghjghjghjghjghjghjghjghjghjghjghjghjghjghjghjghjghjghjghjghjghjghjghjghj...

output:

3333345323

result:

ok 1 number(s): "3333345323"

Test #22:

score: 0
Accepted
time: 74ms
memory: 13504kb

input:

lkkzzkklzkklzzklllkzlkkzzzzlzlzlkzlzzzkzlklzkklzlzzlzlllkkzlzkkklklkzkkzllklkzkzzzkzkkzzllzllzzkkkzkzzkzklzzzzkllzkzlklzlkzllkkllzzlzkzkzlllzlllkzzkzkkzzkkzlllzzllkkzlkklllzzzkkzkzkkllkklzkkkzzzzlkzlzklzllzkklkzlzzzlzlzkzllkklzlkklzlkllzklllkllzzzzllzllkkllzlklkkllzzlzzlllzzzklzzkkkzlklkkkzlzllzllzk...

output:

74917

result:

ok 1 number(s): "74917"

Test #23:

score: 0
Accepted
time: 70ms
memory: 13688kb

input:

albusdamhnkbpphiurtnhdggnfjsvsdcypnsqurbidrszoremwfrqmdmyjkbxfpdcalhcmtehpatfqupucnlzelvkadygbhlrjjbmlyitutipaermatkqdtdfrmfsnfptcomcpnlkxnunvtbxllyyghykifokwklpptkocrgxjtmcnogbgnhlcgtapemexkxoocllzbsszztvctjnmlnkgrbplakpxgujpfrpelngfoknvrsdqvrdqzajbxtirdsmiekycojmhsbcqkclzsowkvuzmsysmialqmfivvzgndq...

output:

74399

result:

ok 1 number(s): "74399"

Test #24:

score: 0
Accepted
time: 60ms
memory: 13328kb

input:

rniwfckztiivwkcnxteghcavxgiqsygrpxnliiojczdxqylzgnztcburluxmntpjlwxhyugympaeewrjkugdzntrkdkaxgflgfhzxpsaisggvbwmeirprlowksbmyhmjbvtujsvhoawqzqoqcuyzeijmbgqnhzwhyficrtyjrxhlfwqiantnxnbjtxlrzomwycuxohpfschpxbwogepfjmkuxpupulgdkvelkodyoslajfftymsiazgrzhircmdetthficiexfhxoomkmqijoxocqlxmhgwcisiyhurxfkub...

output:

85203

result:

ok 1 number(s): "85203"

Test #25:

score: 0
Accepted
time: 111ms
memory: 13452kb

input:

fbjylvxoacqlofjvtxpkgglsfesutcqgpipusktuafjmqwqzqgvmnsvahecjbkakutjmblicyiufpjxdtvgsfioluxgukurkccjcynmakwrjdpksdbuqvmjwaadzrhugptwljgawlbscvligbhxeqldczpljzttlzpnmgotkwpuqboompspvbdhaocdirrlwiocmwuqgcghbwgrvsmtzgigucucrukpywyfwrbwaixrslahweekucosreiwgkozmistchdimjnktpxbqxriexqsmympycuwmhaymyzauihhh...

output:

125637

result:

ok 1 number(s): "125637"

Test #26:

score: 0
Accepted
time: 114ms
memory: 13520kb

input:

euzfuvlnzbucvvvbalzcpurzbolgxoohfnfzlrcbpjnxisidecdojzafzaanklvzyttgccekghsomgybamfcwmlvntnavtasvomczpxvzqnacyltszblvbuwwhdmezclilyygggnjjfcshghnitimbtmxbapgkvjhtmwvhlhlfjifhfrazrhpgrdjktaaqspduyxturzecvvubbuhhjvuwzycbdrjjkosiprxomxeobdyqknjidiediyzhihchbginbulepyrgoheosvyhyrkicglsorfzxksrxjyupkzyiz...

output:

124360

result:

ok 1 number(s): "124360"

Test #27:

score: 0
Accepted
time: 101ms
memory: 13548kb

input:

unbnsxcgavvynxatgliythqvjqyfkyldaytaopgdxfqtpyeuyccuounieygpllptrxmesjwgojroodmlzdezcffoxxbffgcsbltnuwbzbhfnbaehkdsuzsjimuubljrtlejbmaxjmpghjashysifcffsbbyzpnxmcehqsnnvbiuobcrimodyfwofowvdpmimsckhceinykwdvnqlvavfczsucdfeilmzqdiaqwdhndljyfahmzrjgimootbmndqnpjkspcgngsvojexrxjlomnlvvaamwzgxdjjjhocvvkqh...

output:

124758

result:

ok 1 number(s): "124758"

Test #28:

score: 0
Accepted
time: 22ms
memory: 5852kb

input:

njvekjflgdvxrkxymgepijcnrjqzroaaschvnlgpavcffffjeyjoigrunncmoduswvmnuojqgsaujhaqrmfmoqwzvajhxdffuztanwynaatjnkbrdgslgetypxtmkraaggdjiyxnfbxbgwkftzxsshrfnbphodltgcguncndshlosjzkychbislawtyrdnjvekjflgdvxrkxymgepijcnrjqzroaaschvnlgpavcffffjeyjoigrunncmoduswvmnuojqgsaujhaqrmfmoqwzvajhxdffuztanwynaatjnkb...

output:

52918599

result:

ok 1 number(s): "52918599"

Test #29:

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

input:

irnzrcherzsoipcrgzkfzycvkrypbdnzeqjtttgpgllujmiaumswqqlajbszcgmmhxxfggnqsvtcewakiqcbjsxaaoryifhvqctuhxbegmzoxjxdmfsxlzudhvboknidjgdgadqgncppnwqtzburacucgctrrwmyhfdxpiybbibvbtcgykiyimkhvxzsxldmsgqrqzqdxhdkxymloksnhkohmuocpfgesgvokzcthvuuklmrdygrpvmiulovrjtwfobrtxajrbbtnmltsduhkxffkvpuvvyjiaydjxdhdoxg...

output:

2006481

result:

ok 1 number(s): "2006481"

Test #30:

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

input:

ckewrtmlvdfgrtwhqfhrnnaqqpbzvnrjnqhclnuigkqtyqcrfdzlxtrtsuefvzytfhohexuytggxkljigzmkbscyeelgmtrzaolaitmzmttbdclogmzyyguzjejehuaybrrrlgxwpukqhhnrucszkympotlckwtaiwedtybbkhlyyzllbtwqbenluuhmnbvdsgtqrqwvmhjbknaljiaigoimvjdpfualdcwmhngjirsyyojkycnkyqjinpfffegisghwsdblsvzelczqnfcnqpsnpiqfuefnntruntrscori...

output:

1827034

result:

ok 1 number(s): "1827034"

Test #31:

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

input:

clhtskvezsrhnbrtcavswrsilokwqjirzrlfusiiaembtaekmfrffcjmdysafvxyszyobzqbzzgofiunqvsiuttrgxqhhwbnlsesjmfgpdxaykhmfvmxeyfmwhwrnnnqtsyiokbbscmahshftklzucxtudozqcjxnmfffbggnlnfxmbyeifksecwwitglclbmtfpmccvcqjopqzvrbcjnyvhcheviialyjanngeohjxcfxdvnjmkcetseshlggkevayqpcijydtmqobtcdqaorsqhcaddyezvkgwlheejcmc...

output:

986982

result:

ok 1 number(s): "986982"

Test #32:

score: 0
Accepted
time: 66ms
memory: 13064kb

input:

mmcwddbgxskxzjukffqmzvpzhvfytgsugruqwlbbvnpwtvrhjjhdynenaifbljwgaasyzyyabpghmnlezfxhkuujtczchcpotpzvczjjzcvasrnlejelkuesljstscuupwoivjecvrgukipjlmkrvbdirrxqbikqghmxtshxmsermfspigatgrlwyxqfkymhhoajjpzjjsyinpsvooqjjvovpttggwxvlnzhbnmhaczpnlozaxeervjaexiviutxxhgjgoapbcksddztddnsdyiecoagrcvownnxtxzkquyv...

output:

86036

result:

ok 1 number(s): "86036"

Test #33:

score: 0
Accepted
time: 24ms
memory: 5944kb

input:

bznsrbrsyugevrwjgvjlvdpcojndmrzypethckuwmdwutbqkeumdqgwwyypxfrcpejmpmdtryvfnfsyonmusidvrriokmklmjqjexwbkhagyayumotuzormcvqvjwtzolvrxmwiujrgulxjnrjfcbtczbshktkimdmbgqltsmozdeeuxpfhxucjtfnzrqgufdvzgsxbfaivlsfwtztqvkkrtnzjuhxihytkdjsnlnrtmhfvlvzmblnsnnktphimkgrregecbycbujcbhytwhpshushnsgmlrfxshvvnsqnmb...

output:

22394048

result:

ok 1 number(s): "22394048"

Test #34:

score: 0
Accepted
time: 79ms
memory: 13436kb

input:

ppnclotgolzjqnbxzdtgjocaggxughxevjnelmshfjyynnxdqxtmdkpmrhqyojptvbibtonizeqzdeusykdegxewvpcrfwxtryctwilmkiaxvtrpesxvkqgrwonallqtunoqprvqdzlaemwnkfhhapzcvpemmdpbinjjdsosevzzhpwafgozruwrzdfeixfslwmtnweehlrgdvbtfqfsrhukhqsyozdltqqzsspznbkppqxbznksfmbiwrpgzlfbzfciumbhuqcszdtgwtalsetpjowxccgogavemfxtgwok...

output:

75612

result:

ok 1 number(s): "75612"

Test #35:

score: 0
Accepted
time: 16ms
memory: 6112kb

input:

ttcpbgmttcpbgmttcpbgmttcpbgmttcpbgmttcpbgmttcpbgmttcpbgmttcpbgmttcpbgmttcpbgmttcpbgmttcpbgmttcpbgmttcpbgmttcpbgmttcpbgmttcpbgmttcpbgmttcpbgmttcpbgmttcpbgmttcpbgmttcpbgmttcpbgmttcpbgmttcpbgmttcpbgmttcpbgmttcpbgmttcpbgmttcpbgmttcpbgmttcpbgmttcpbgmttcpbgmttcpbgmttcpbgmttcpbgmttcpbgmttcpbgmttcpbgmttcpbg...

output:

1428581328

result:

ok 1 number(s): "1428581328"

Test #36:

score: 0
Accepted
time: 51ms
memory: 7484kb

input:

whnqukzmwgsuzlkvbzqsyjietfpvhjbywaghyimtxlgfqtihizmrnoecskpwwzsnvqubrafgbwrbczqmvvnlymrtmmrlsyfemraiqyqjwmzweirfdeddfskajjtbuunwhjvnypxzgrqsxxvkdjdpbwkuovdvgvqntixlnucpisdkiemwhtqhyfyvkwroepfotjtylskrxdzihqrfopldsutzoyasyhxjalanwcpyrjiekkmcdsvmngexgzbljbjkisohcdvjtaxdeqporvimzsllllkglgmhgyytfpjniacn...

output:

372901

result:

ok 1 number(s): "372901"

Test #37:

score: 0
Accepted
time: 68ms
memory: 13548kb

input:

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

output:

75344

result:

ok 1 number(s): "75344"

Extra Test:

score: 0
Extra Test Passed