Problem p02721 (C++) — buggy submission, verdict: Runtime Error

//{{{
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O2")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
using namespace std;

#define putchar(x) cout << (x)
#define repeat(x)                                                              \\
  int _ = 0;                                                                   \\
  _ < (x);                                                                     \\
  ++_

template <typename T> constexpr auto range(T start, T stop, T step) {
  struct iterator {
    using difference_type = T;
    using value_type = T;
    using pointer = T *;
    using reference = T &;
    using iterator_category = random_access_iterator_tag;

    T i, step;
    T operator-(const iterator &other) const { return i - other.i; };
    bool operator!=(const iterator &other) const { return i != other.i; }
    auto &operator+=(const int &n) {
      i += step * n;
      return *this;
    }
    auto &operator++() {
      i += step;
      return *this;
    }
    auto &operator*() { return i; }
  };
  struct iterable_wrapper {
    T start, stop, step;
    auto begin() const { return iterator{start, step}; }
    auto end() const { return iterator{stop, step}; }
    size_t size() const { return (stop - start) / step; }

    iterable_wrapper(T start_, T stop_, T step_)
        : start(start_), stop(stop_), step(step_) {
      stop = step > 0 ? max(start, stop) : min(start, stop);
      stop += (step - (stop - start) % step) % step;
    }
  };
  return iterable_wrapper(start, stop, step);
};
template <typename T> constexpr auto range(T start, T stop) {
  return range(start, stop, T(1));
}
template <typename T> constexpr auto range(T stop) {
  return range(T(0), stop, T(1));
}

template <typename T, typename Iter = decltype(rbegin(declval<T>()))>
constexpr auto reversed(T &&iterable) {
  struct iterable_wrapper {
    T iterable;
    auto begin() const { return std::rbegin(iterable); }
    auto end() const { return std::rend(iterable); }
    auto size() const { return iterable.size(); }
  };
  return iterable_wrapper{forward<T>(iterable)};
}

template <typename T, typename Iter = decltype(begin(declval<T>()))>
constexpr auto printer(T &&iterable) {
  struct iterator {
    Iter iter, ed;
    auto operator!=(const iterator &other) const {
      auto ret = (iter != other.iter);
      if (not ret)
        cout << '\\n';
      return ret;
    }
    auto &operator++() {
      ++iter;
      if (iter != ed)
        cout << ' ';
      return *this;
    }
    auto &operator*() { return *iter; }
  };
  struct iterable_wrapper {
    T iterable;
    auto begin() const {
      return iterator{std::begin(iterable), std::end(iterable)};
    }
    auto end() const {
      return iterator{std::end(iterable), std::end(iterable)};
    }
  };
  return iterable_wrapper{forward<T>(iterable)};
};

template <class... T> void absorb(T &&...) {}
template <size_t L, size_t I, class T>
bool zip_it_ne(const T &it1, const T &it2) {
  if (not(get<I>(it1) != get<I>(it2)))
    return false;
  if (I + 1 == L)
    return true;
  return zip_it_ne<L, (I + 1) % L, T>(it1, it2);
}
template <size_t... Is, class T, class... Cs,
          class Iter = tuple<decltype(begin(declval<Cs>()))...>,
          class Ref = tuple<decltype(*begin(declval<Cs>())) &...>>
constexpr auto zip(index_sequence<Is...>, T &&iterables, Cs &&...) {
  struct iterator {
    Iter iter;
    unique_ptr<Ref> tref = nullptr;
    bool operator!=(const iterator &other) const {
      return zip_it_ne<sizeof...(Is), 0, Iter>(iter, other.iter);
    }
    auto &operator++() {
      absorb(++get<Is>(iter)...);
      return *this;
    }
    auto &operator*() {
      tref.reset(new Ref(tie(*get<Is>(iter)...)));
      return *tref;
    }
  };
  struct iterable_wrapper {
    T iterables;
    auto begin() const {
      return iterator{Iter{std::begin(get<Is>(iterables))...}};
    }
    auto end() const { return iterator{Iter{std::end(get<Is>(iterables))...}}; }
    auto size() const { return min({get<Is>(iterables).size()...}); }
  };
  return iterable_wrapper{forward<T>(iterables)};
}
template <class... Cs, class = tuple<decltype(begin(declval<Cs>()))...>>
constexpr auto zip(Cs &&...cs) {
  return zip(index_sequence_for<Cs...>{}, tuple<Cs...>(forward<Cs>(cs)...),
             forward<Cs>(cs)...);
}

template <typename T, typename Iter = decltype(begin(declval<T>()))>
constexpr auto enumerate(T &&iterable) {
  return zip(range(iterable.size()), forward<T>(iterable));
}

template <size_t... Is, typename T> auto getis(const T &t) {
  return tie(get<Is>(t)...);
}
template <class T> void setmax(T &a, const T &b) { a = max(a, b); }
template <class T> void setmin(T &a, const T &b) { a = min(a, b); }

template <typename T> struct is_const_char_arr_ref : false_type {};
template <size_t N>
struct is_const_char_arr_ref<char const (&)[N]> : true_type {};
template <typename T, typename = void> struct is_container : false_type {};
template <typename T>
struct is_container<T,
                    conditional_t<false, decltype(begin(declval<T>())), void>>
    : true_type {};
template <class T>
using IsC = typename enable_if<is_container<T>::value and
                               not is_same<T, string>::value>::type;
template <class T>
using NotC = typename enable_if<not is_container<T>::value or
                                is_same<T, string>::value>::type;
template <class T> inline IsC<T> print_1(const T &v);
template <class T> inline NotC<T> print_1(const T &x) { cout << x; }
template <size_t N> void print_1(const array<char, N> &x) { cout << &x[0]; };
inline void print_1(const tuple<> &) { cout << "()"; };
template <size_t L, size_t I, class T> void print_tuple(const T &t) {
  if (I != 0)
    cout << ", ";
  print_1(get<I>(t));
  if (I + 1 < L)
    print_tuple<L, (I + 1) % L>(t);
}
template <class... T> inline void print_1(const tuple<T...> &x) {
  cout << "(";
  print_tuple<sizeof...(T), 0, tuple<T...>>(x);
  cout << ")";
}
inline void print_n() {}
template <class T, class... U>
inline void print_n(const T &head, const U &...tail);
template <class T, class U> inline void print_1(const pair<T, U> &p) {
  cout << "(";
  print_1(p.first);
  cout << ", ";
  print_1(p.second);
  cout << ")";
}
template <class T, class... U>
inline void print_n(const T &head, const U &...tail) {
  print_1(head);
  if (sizeof...(tail))
    cout << " ";
  print_n(tail...);
}
template <class T> inline IsC<T> print_1(const T &v) {
  cout << "[";
  for (auto it = v.begin(); it != v.end(); ++it) {
    if (it != v.begin())
      cout << ", ";
    print_1(*it);
  }
  cout << "]";
}
template <class... T> inline void print(const T &...args) {
  print_n(args...);
  putchar('\\n');
}
inline void read() {}
template <class T, class... U> inline void read(T &head, U &...tail) {
  cin >> head;
  read(tail...);
}

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
static int fastio = []() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(17);
  return 0;
}();

template <class T> void print_dbg(const string &s, T &&x) {
  if (is_const_char_arr_ref<T>::value) {
    print_n(x);
  } else {
    print_n(s, "=", x);
  }
}
#define SELECT(_1, _2, _3, _4, _5, _6, _7, _8, NAME, ...) NAME
#define dbg1(a)                                                                \\
  print_dbg(#a, a);                                                            \\
  cout << endl;
#define dbg2(a, b)                                                             \\
  print_dbg(#a, a);                                                            \\
  cout << ", ";                                                                \\
  dbg1(b);
#define dbg3(a, b, c)                                                          \\
  print_dbg(#a, a);                                                            \\
  cout << ", ";                                                                \\
  dbg2(b, c);
#define dbg4(a, b, c, d)                                                       \\
  print_dbg(#a, a);                                                            \\
  cout << ", ";                                                                \\
  dbg3(b, c, d);
#define dbg5(a, b, c, d, e)                                                    \\
  print_dbg(#a, a);                                                            \\
  cout << ", ";                                                                \\
  dbg4(b, c, d, e);
#define dbg6(a, b, c, d, e, f)                                                 \\
  print_dbg(#a, a);                                                            \\
  cout << ", ";                                                                \\
  dbg5(b, c, d, e, f);
#define dbg7(a, b, c, d, e, f, g)                                              \\
  print_dbg(#a, a);                                                            \\
  cout << ", ";                                                                \\
  dbg6(b, c, d, e, f, g);
#define dbg8(a, b, c, d, e, f, g, h)                                           \\
  print_dbg(#a, a);                                                            \\
  cout << ", ";                                                                \\
  dbg7(b, c, d, e, f, g, h);
#define debug(...)                                                             \\
  SELECT(__VA_ARGS__, dbg8, dbg7, dbg6, dbg5, dbg4, dbg3, dbg2, dbg1)          \\
  (__VA_ARGS__)
//}}}
using PII = pair<int, int>;
using LL = long long;

const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const LL LLINF = 0x3f3f3f3f3f3f3f3f;
const int MAX_N = 200005;

using Data = int;
vector<Data> dat;
const Data zero_c = INT_MIN;
Data modify(const Data &val1, const Data &val2) {
  ignore = val1;
  return val2;
}
Data combine(const Data &val1, const Data &val2) { return max(val1, val2); }

struct SegTree { //{{{
  int N;
  SegTree(int n_, Data *ptr = nullptr) {
    N = 1;
    while (N < n_)
      N <<= 1;
    dat.assign(N * 2, zero_c);

    if (ptr != NULL) {
      for (int i = 0; i < n_; i++)
        dat[i + N] = ptr[i];
      for (int k = N - 1; k >= 0; k--) {
        dat[k] = combine(dat[k * 2], dat[k * 2 + 1]);
      }
    }
  }

  void update(int a, const Data &val, int l = 0, int r = -1, int k = 1) {
    r = (r < 0) ? N : r;

    if (r <= a or a < l) {
      return;
    }
    if (l == r - 1) {
      dat[k] = modify(dat[k], val);
      return;
    }
    int mid = l + (r - l) / 2;
    update(a, val, l, mid, k * 2);
    update(a, val, mid, r, k * 2 + 1);
    dat[k] = combine(dat[k * 2], dat[k * 2 + 1]);
  }

  Data query(int a, int b, int l = 0, int r = -1, int k = 1) {
    r = (r < 0) ? N : r;

    if (r <= a or b <= l) {
      return zero_c;
    }
    if (a <= l and r <= b) {
      return dat[k];
    }
    int mid = l + (r - l) / 2;
    Data vl = query(a, b, l, mid, k * 2);
    Data vr = query(a, b, mid, r, k * 2 + 1);
    return combine(vl, vr);
  }
}; //}}}

struct Solution {
  vector<int> getmax(string &s, int C) {
    vector<int> goodday;
    for (int i : range(s.size())) {
      if (s[i] == 'o') {
        goodday.push_back(i);
      }
    }

    vector<int> mxw(goodday.size(), 1);
    for (int i : range(1, int(goodday.size()))) {
      int j = upper_bound(goodday.begin(), goodday.begin() + i,
                          goodday[i] - C - 1) -
              goodday.begin();
      j -= 1;
      if (j >= 0) {
        mxw[i] = mxw[j] + 1;
      }
    }
    return mxw;
  }

  Solution(int) {
    int N, K, C;
    string s;
    read(N, K, C, s);

    auto mx0 = getmax(s, C);
    reverse(s.begin(), s.end());
    auto mx1 = getmax(s, C);
    reverse(s.begin(), s.end());
    reverse(mx1.begin(), mx1.end());

    vector<int> goodday;
    for (int i : range(N)) {
      if (s[i] == 'o') {
        goodday.push_back(i);
      }
    }
    int M = goodday.size();

    vector<int> sum(M);
    for (int i : range(M)) {
      int j = lower_bound(goodday.begin(), goodday.end(), goodday[i] + C + 1) -
              goodday.begin();
      sum[i] = mx0[i] + ((j < M) ? mx1[j] : 0);
    }

    auto st = SegTree(M, &sum[0]);
    for (int i : range(M)) {
      int j = upper_bound(goodday.begin(), goodday.begin() + i,
                          goodday[i] - C - 1) -
              goodday.begin();
      int x = st.query(j, i);
      if (i < M - 1)
        x = max(x, mx1[i + 1]);
      if (i > 0)
        x = max(x, mx0[i - 1]);
      if (i < M - 1 and i > 0) {
        x = max(x, mx0[i - 1] + mx1[i + 1]);
      }
      if (x < K) {
        print(goodday[i] + 1);
      }
    }
  }
};

int main() {
  int T = 1;
  // cin >> T;
  for (int i = 1; i <= T; ++i) {
    ignore = Solution(i);
  }
  return 0;
}


Error: 0

Fixed submission:

//{{{
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O2")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
using namespace std;

#define putchar(x) cout << (x)
#define repeat(x)                                                              \\
  int _ = 0;                                                                   \\
  _ < (x);                                                                     \\
  ++_

template <typename T> constexpr auto range(T start, T stop, T step) {
  struct iterator {
    using difference_type = T;
    using value_type = T;
    using pointer = T *;
    using reference = T &;
    using iterator_category = random_access_iterator_tag;

    T i, step;
    T operator-(const iterator &other) const { return i - other.i; };
    bool operator!=(const iterator &other) const { return i != other.i; }
    auto &operator+=(const int &n) {
      i += step * n;
      return *this;
    }
    auto &operator++() {
      i += step;
      return *this;
    }
    auto &operator*() { return i; }
  };
  struct iterable_wrapper {
    T start, stop, step;
    auto begin() const { return iterator{start, step}; }
    auto end() const { return iterator{stop, step}; }
    size_t size() const { return (stop - start) / step; }

    iterable_wrapper(T start_, T stop_, T step_)
        : start(start_), stop(stop_), step(step_) {
      stop = step > 0 ? max(start, stop) : min(start, stop);
      stop += (step - (stop - start) % step) % step;
    }
  };
  return iterable_wrapper(start, stop, step);
};
template <typename T> constexpr auto range(T start, T stop) {
  return range(start, stop, T(1));
}
template <typename T> constexpr auto range(T stop) {
  return range(T(0), stop, T(1));
}

template <typename T, typename Iter = decltype(rbegin(declval<T>()))>
constexpr auto reversed(T &&iterable) {
  struct iterable_wrapper {
    T iterable;
    auto begin() const { return std::rbegin(iterable); }
    auto end() const { return std::rend(iterable); }
    auto size() const { return iterable.size(); }
  };
  return iterable_wrapper{forward<T>(iterable)};
}

template <typename T, typename Iter = decltype(begin(declval<T>()))>
constexpr auto printer(T &&iterable) {
  struct iterator {
    Iter iter, ed;
    auto operator!=(const iterator &other) const {
      auto ret = (iter != other.iter);
      if (not ret)
        cout << '\\n';
      return ret;
    }
    auto &operator++() {
      ++iter;
      if (iter != ed)
        cout << ' ';
      return *this;
    }
    auto &operator*() { return *iter; }
  };
  struct iterable_wrapper {
    T iterable;
    auto begin() const {
      return iterator{std::begin(iterable), std::end(iterable)};
    }
    auto end() const {
      return iterator{std::end(iterable), std::end(iterable)};
    }
  };
  return iterable_wrapper{forward<T>(iterable)};
};

template <class... T> void absorb(T &&...) {}
template <size_t L, size_t I, class T>
bool zip_it_ne(const T &it1, const T &it2) {
  if (not(get<I>(it1) != get<I>(it2)))
    return false;
  if (I + 1 == L)
    return true;
  return zip_it_ne<L, (I + 1) % L, T>(it1, it2);
}
template <size_t... Is, class T, class... Cs,
          class Iter = tuple<decltype(begin(declval<Cs>()))...>,
          class Ref = tuple<decltype(*begin(declval<Cs>())) &...>>
constexpr auto zip(index_sequence<Is...>, T &&iterables, Cs &&...) {
  struct iterator {
    Iter iter;
    unique_ptr<Ref> tref = nullptr;
    bool operator!=(const iterator &other) const {
      return zip_it_ne<sizeof...(Is), 0, Iter>(iter, other.iter);
    }
    auto &operator++() {
      absorb(++get<Is>(iter)...);
      return *this;
    }
    auto &operator*() {
      tref.reset(new Ref(tie(*get<Is>(iter)...)));
      return *tref;
    }
  };
  struct iterable_wrapper {
    T iterables;
    auto begin() const {
      return iterator{Iter{std::begin(get<Is>(iterables))...}};
    }
    auto end() const { return iterator{Iter{std::end(get<Is>(iterables))...}}; }
    auto size() const { return min({get<Is>(iterables).size()...}); }
  };
  return iterable_wrapper{forward<T>(iterables)};
}
template <class... Cs, class = tuple<decltype(begin(declval<Cs>()))...>>
constexpr auto zip(Cs &&...cs) {
  return zip(index_sequence_for<Cs...>{}, tuple<Cs...>(forward<Cs>(cs)...),
             forward<Cs>(cs)...);
}

template <typename T, typename Iter = decltype(begin(declval<T>()))>
constexpr auto enumerate(T &&iterable) {
  return zip(range(iterable.size()), forward<T>(iterable));
}

template <size_t... Is, typename T> auto getis(const T &t) {
  return tie(get<Is>(t)...);
}
template <class T> void setmax(T &a, const T &b) { a = max(a, b); }
template <class T> void setmin(T &a, const T &b) { a = min(a, b); }

template <typename T> struct is_const_char_arr_ref : false_type {};
template <size_t N>
struct is_const_char_arr_ref<char const (&)[N]> : true_type {};
template <typename T, typename = void> struct is_container : false_type {};
template <typename T>
struct is_container<T,
                    conditional_t<false, decltype(begin(declval<T>())), void>>
    : true_type {};
template <class T>
using IsC = typename enable_if<is_container<T>::value and
                               not is_same<T, string>::value>::type;
template <class T>
using NotC = typename enable_if<not is_container<T>::value or
                                is_same<T, string>::value>::type;
template <class T> inline IsC<T> print_1(const T &v);
template <class T> inline NotC<T> print_1(const T &x) { cout << x; }
template <size_t N> void print_1(const array<char, N> &x) { cout << &x[0]; };
inline void print_1(const tuple<> &) { cout << "()"; };
template <size_t L, size_t I, class T> void print_tuple(const T &t) {
  if (I != 0)
    cout << ", ";
  print_1(get<I>(t));
  if (I + 1 < L)
    print_tuple<L, (I + 1) % L>(t);
}
template <class... T> inline void print_1(const tuple<T...> &x) {
  cout << "(";
  print_tuple<sizeof...(T), 0, tuple<T...>>(x);
  cout << ")";
}
inline void print_n() {}
template <class T, class... U>
inline void print_n(const T &head, const U &...tail);
template <class T, class U> inline void print_1(const pair<T, U> &p) {
  cout << "(";
  print_1(p.first);
  cout << ", ";
  print_1(p.second);
  cout << ")";
}
template <class T, class... U>
inline void print_n(const T &head, const U &...tail) {
  print_1(head);
  if (sizeof...(tail))
    cout << " ";
  print_n(tail...);
}
template <class T> inline IsC<T> print_1(const T &v) {
  cout << "[";
  for (auto it = v.begin(); it != v.end(); ++it) {
    if (it != v.begin())
      cout << ", ";
    print_1(*it);
  }
  cout << "]";
}
template <class... T> inline void print(const T &...args) {
  print_n(args...);
  putchar('\\n');
}
inline void read() {}
template <class T, class... U> inline void read(T &head, U &...tail) {
  cin >> head;
  read(tail...);
}

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
static int fastio = []() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(17);
  return 0;
}();

template <class T> void print_dbg(const string &s, T &&x) {
  if (is_const_char_arr_ref<T>::value) {
    print_n(x);
  } else {
    print_n(s, "=", x);
  }
}
#define SELECT(_1, _2, _3, _4, _5, _6, _7, _8, NAME, ...) NAME
#define dbg1(a)                                                                \\
  print_dbg(#a, a);                                                            \\
  cout << endl;
#define dbg2(a, b)                                                             \\
  print_dbg(#a, a);                                                            \\
  cout << ", ";                                                                \\
  dbg1(b);
#define dbg3(a, b, c)                                                          \\
  print_dbg(#a, a);                                                            \\
  cout << ", ";                                                                \\
  dbg2(b, c);
#define dbg4(a, b, c, d)                                                       \\
  print_dbg(#a, a);                                                            \\
  cout << ", ";                                                                \\
  dbg3(b, c, d);
#define dbg5(a, b, c, d, e)                                                    \\
  print_dbg(#a, a);                                                            \\
  cout << ", ";                                                                \\
  dbg4(b, c, d, e);
#define dbg6(a, b, c, d, e, f)                                                 \\
  print_dbg(#a, a);                                                            \\
  cout << ", ";                                                                \\
  dbg5(b, c, d, e, f);
#define dbg7(a, b, c, d, e, f, g)                                              \\
  print_dbg(#a, a);                                                            \\
  cout << ", ";                                                                \\
  dbg6(b, c, d, e, f, g);
#define dbg8(a, b, c, d, e, f, g, h)                                           \\
  print_dbg(#a, a);                                                            \\
  cout << ", ";                                                                \\
  dbg7(b, c, d, e, f, g, h);
#define debug(...)                                                             \\
  SELECT(__VA_ARGS__, dbg8, dbg7, dbg6, dbg5, dbg4, dbg3, dbg2, dbg1)          \\
  (__VA_ARGS__)
//}}}
using PII = pair<int, int>;
using LL = long long;

const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const LL LLINF = 0x3f3f3f3f3f3f3f3f;
const int MAX_N = 200005;

struct SparseTable { //{{{
  vector<vector<int>> st;
  int __lg(int n) { return 31 - __builtin_clz(n); }

  SparseTable(const vector<int> &a) {
    int n = a.size();
    int logn = __lg(n);
    st.assign(logn + 1, vector<int>(n));

    for (int i = 0; i < n; ++i) {
      st[0][i] = a[i];
    }
    for (int k = 1; (1 << k) <= n; ++k) {
      for (int i = 0; i + (1 << k) <= n; ++i) {
        st[k][i] = max(st[k - 1][i], st[k - 1][i + (1 << (k - 1))]);
      }
    }
  }

  int get(int l, int r) {
    if (l >= r) {
      return 0;
    }
    int k = __lg(r - l);
    return max(st[k][l], st[k][r - (1 << k)]);
  }
}; //}}}

struct Solution {
  vector<int> getmax(string &s, int C) {
    vector<int> goodday;
    for (int i : range(s.size())) {
      if (s[i] == 'o') {
        goodday.push_back(i);
      }
    }

    vector<int> mxw(goodday.size(), 1);
    for (int i : range(1, int(goodday.size()))) {
      int j = upper_bound(goodday.begin(), goodday.begin() + i,
                          goodday[i] - C - 1) -
              goodday.begin();
      j -= 1;
      if (j >= 0) {
        mxw[i] = mxw[j] + 1;
      }
    }
    return mxw;
  }

  Solution(int) {
    int N, K, C;
    string s;
    read(N, K, C, s);

    auto mx0 = getmax(s, C);
    reverse(s.begin(), s.end());
    auto mx1 = getmax(s, C);
    reverse(s.begin(), s.end());
    reverse(mx1.begin(), mx1.end());

    // mx0.insert(mx0.begin(), 0);
    // mx1.insert(mx1.begin(), mx1[0]);

    vector<int> goodday;
    for (int i : range(s.size())) {
      if (s[i] == 'o') {
        goodday.push_back(i);
      }
    }
    int M = goodday.size();

    vector<int> sum(M);
    for (int i : range(M)) {
      int j = lower_bound(goodday.begin(), goodday.end(), goodday[i] + C + 1) -
              goodday.begin();
      sum[i] = mx0[i] + ((j < M) ? mx1[j] : 0);
    }
    // auto& gdd = goodday;
    // debug(gdd);
    // debug(mx0);
    // debug(mx1);
    // debug(sum);

    auto st = SparseTable(sum);
    for (int i : range(M)) {
      int j = upper_bound(goodday.begin(), goodday.begin() + i,
                          goodday[i] - C - 1) -
              goodday.begin();
      int x = st.get(j, i);
      if (i < M - 1)
        x = max(x, mx1[i + 1]);
      if (i > 0)
        x = max(x, mx0[i - 1]);
      if (i < M - 1 and i > 0) {
        x = max(x, mx0[i - 1] + mx1[i + 1]);
      }
      // debug(goodday[j], goodday[i]);
      // debug(i, j, st.get(j, i), x);
      // if(x < K) {
      //     print("=================================================",
      //     goodday[i] + 1);
      // }
      if (x < K) {
        print(goodday[i] + 1);
      }
    }
  }
};

int main() {
  int T = 1;
  // cin >> T;
  for (int i = 1; i <= T; ++i) {
    ignore = Solution(i);
  }
  return 0;
}