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

#include <bits/stdc++.h> // clang-format off
using Int = long long;
#define REP_(i, a_, b_, a, b, ...) for (Int i = (a), lim##i = (b); i < lim##i; i++)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
struct SetupIO { SetupIO() { std::cin.tie(nullptr), std::ios::sync_with_stdio(false), std::cout << std::fixed << std::setprecision(13); } } setup_io;
#ifndef _MY_DEBUG
#define dump(...)
#endif // clang-format on

/**
 *    author:  knshnb
 *    created: Sat Apr  4 21:00:24 JST 2020
 **/

template <class T> inline bool chmin(T &a, const T &b) {
  if (a <= b)
    return false;
  a = b;
  return true;
}
template <class T> inline bool chmax(T &a, const T &b) {
  if (a >= b)
    return false;
  a = b;
  return true;
}

const Int INF = 1e9;
Int offset = 2000000;
signed main() {
  Int n, K, C;
  std::cin >> n >> K >> C;
  std::string s;
  std::cin >> s;

  std::vector<Int> l(n + 1, -INF), r(n + 1, -INF), ok(n + 10 + offset * 2);
  l[0] = r[n] = 0;
  REP(i, n) {
    l[i + 1] = l[i];
    if (s[i] == 'x')
      continue;
    if (i - C >= 0)
      chmax(l[i + 1], l[i - C] + 1);
    else
      chmax(l[i + 1], 1LL);
  }
  for (int i = n - 1; i >= 0; i--) {
    r[i] = r[i + 1];
    if (s[i] == 'x')
      continue;
    if (i + 1 + C <= n)
      chmax(r[i], r[i + 1 + C] + 1);
    else
      chmax(r[i], 1LL);
  }
  dump(l, r);

  if (C == 0) {
    REP(i, n) {
      if (l[i] + r[i + 1] < K) {
        std::cout << i + 1 << "\\n";
      }
    }
    return 0;
  }
  REP(i, -1 - C, n) {
    Int x = i + 1 < 0 ? 0 : l[i + 1];
    Int y = i + C + 1 > n ? 0 : r[i + C + 1];
    dump(i, x, y);
    if (x + y >= K) {
      ok[i + 1 + offset]++;
      ok[i + C + 1 + offset]--;
    }
  }
  REP(i, ok.size() - 1) {
    if (1 <= i + 1 - offset && i + 1 - offset <= n && ok[i] == 0) {
      dump(i, ok[i]);
      std::cout << i + 1 - offset << "\\n";
    }
    ok[i + 1] += ok[i];
  }
}


Error: 0

Fixed submission:

#include <bits/stdc++.h> // clang-format off
using Int = long long;
#define REP_(i, a_, b_, a, b, ...) for (Int i = (a), lim##i = (b); i < lim##i; i++)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
struct SetupIO { SetupIO() { std::cin.tie(nullptr), std::ios::sync_with_stdio(false), std::cout << std::fixed << std::setprecision(13); } } setup_io;
#ifndef _MY_DEBUG
#define dump(...)
#endif // clang-format on

/**
 *    author:  knshnb
 *    created: Sat Apr  4 21:00:24 JST 2020
 **/

template <class T> inline bool chmin(T &a, const T &b) {
  if (a <= b)
    return false;
  a = b;
  return true;
}
template <class T> inline bool chmax(T &a, const T &b) {
  if (a >= b)
    return false;
  a = b;
  return true;
}

const Int INF = 1e9;
Int offset = 2000000;
signed main() {
  Int n, K, C;
  std::cin >> n >> K >> C;
  std::string s;
  std::cin >> s;

  std::vector<Int> l(n + 1, -INF), r(n + 1, -INF), ok(n + 10 + offset * 2);
  l[0] = r[n] = 0;
  REP(i, n) {
    l[i + 1] = l[i];
    if (s[i] == 'x')
      continue;
    if (i - C >= 0)
      chmax(l[i + 1], l[i - C] + 1);
    else
      chmax(l[i + 1], 1LL);
  }
  for (int i = n - 1; i >= 0; i--) {
    r[i] = r[i + 1];
    if (s[i] == 'x')
      continue;
    if (i + 1 + C <= n)
      chmax(r[i], r[i + 1 + C] + 1);
    else
      chmax(r[i], 1LL);
  }
  dump(l, r);

  if (C == 0) {
    REP(i, n) {
      if (l[i] + r[i + 1] < K) {
        std::cout << i << "\\n";
      }
    }
    assert(0);
    return 0;
  }
  REP(i, -1 - C, n) {
    Int x = i + 1 < 0 ? 0 : l[i + 1];
    Int y = i + C + 1 > n ? 0 : r[i + C + 1];
    dump(i, x, y);
    if (x + y >= K) {
      ok[i + 1 + offset]++;
      ok[i + C + 1 + offset]--;
    }
  }
  REP(i, ok.size() - 1) {
    if (1 <= i + 1 - offset && i + 1 - offset <= n && ok[i] == 0) {
      dump(i, ok[i]);
      std::cout << i + 1 - offset << "\\n";
    }
    ok[i + 1] += ok[i];
  }
}