alexjercan/bugnet huggingface dataset:
Problem p02720 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
int main() {
  long int K;
  cin >> K;
  queue<int> c;
  int count = 9;
  long int ans;
  if (K < 9) {
    ans = K;
  } else {
    for (int i = 0; i < 9; i++) {
      c.push(i + 1);
    }
    long int countst = 0, counten = 8;
    for (int p = 0; p <= 10; p++) {
      for (int l = countst; l <= counten; l++) {
        long int g = c.front();
        c.pop();

        int memo = g % 10;
        if (memo == 0) {
          c.push(10 * g);
          count++;
          if (count == K) {
            ans = 10 * g;
          }
          c.push(10 * g + 1);
          count++;
          if (count == K) {
            ans = 10 * g + 1;
          }
        } else if (memo == 9) {
          c.push(10 * g + 8);
          count++;
          if (count == K) {
            ans = 10 * g + 8;
          }
          c.push(10 * g + 9);
          count++;
          if (count == K) {
            ans = 10 * g + 9;
          }
        } else {
          c.push(10 * g + memo - 1);
          count++;
          if (count == K) {
            ans = 10 * g + memo - 1;
          }
          c.push(10 * g + memo);
          count++;
          if (count == K) {
            ans = 10 * g + memo;
          }
          c.push(10 * g + memo + 1);
          count++;
          if (count == K) {
            ans = 10 * g + 1 + memo;
          }
        }
      }
      countst = counten + 1;
      counten = count - 1;
    } // ｐの
  }   // elseの

  cout << ans << endl;
}

Error: -11

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int K;
  cin >> K;
  long int c[100000];
  int count = 9;

  for (int i = 0; i < 9; i++) {
    c[i] = i + 1;
  }
  int countst = 0, counten = 8;
  for (int p = 0; p <= 8; p++) {
    for (int l = countst; l <= counten; l++) {
      long int g = c[l];
      int memo = g % 10;
      if (memo == 0) {
        c[count] = 10 * c[l];
        count++;
        c[count] = 10 * c[l] + 1;
        count++;
      } else if (memo == 9) {
        c[count] = 10 * c[l] + 8;
        count++;
        c[count] = 10 * c[l] + 9;
        count++;
      } else {
        c[count] = 10 * c[l] + memo - 1;
        count++;
        c[count] = 10 * c[l] + memo;
        count++;
        c[count] = 10 * c[l] + memo + 1;
        count++;
      }
    }
    countst = counten + 1;
    counten = count - 1;
  } // ｐの
  cout << c[K - 1] << endl;
}
Problem p02720 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  int K, A = 0;
  long long X;
  cin >> K;
  vector<long long> Q;
  rep(i, 9) Q.push_back(i + 1);
  while (Q.size() <= K) {
    X = Q.at(A);
    if (X % 10 != 0)
      Q.push_back(10 * X + X % 10 - 1);
    Q.push_back(10 * X + X % 10);
    if (X % 10 != 9)
      Q.push_back(10 * X + X % 10 + 1);
    A++;
  }
  cout << Q.at(K - 1) << endl;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  int K, cnt = 0, B = 0, C, D;
  long long X = 1;
  cin >> K;
  while (1) {
    if (X < 10)
      cnt++;
    else {
      for (int i = 10; i < X; i *= 10) {
        C = X % i;
        D = X / i % 10;
        if (abs(D - C) > 1) {
          B = 1;
          break;
        }
      }
      if (B == 0)
        cnt++;
    }
    if (cnt == K)
      break;
    B = 0;
    X++;
  }
  cout << setprecision(11) << X << endl;
}
Problem p02720 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
#define MOD_NUMBER 1000000007
template <class T> void vector_print(vector<T> vec) {
  for (unsigned int i = 0; i < vec.size(); i++) {
    cout << vec.at(i);
    if (i < vec.size() - 1) {
      cout << " ";
    } else if (i == vec.size() - 1) {
      cout << endl;
    }
  }
}

int main() {
  int k;
  deque<long long> sample = {1, 2, 3, 4, 5, 6, 7, 8, 9};
  cin >> k;
  if (k < 10) {
    cout << sample[k - 1];
    return 0;
  }
  k -= 9;
  while (k > 0) {
    for (long long i = -1; i <= 1; i++) {
      if (0 <= sample[0] % 10 + i && sample[0] % 10 + i < 10) {
        sample.push_back(sample[0] * 10 + sample[0] % 10 + i);
        k--;
        if (k == 0) {
          break;
        }
      }
    }
    sample.pop_front();
  }
  cout << sample.at(sample.size() - 1) << endl;
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  int64_t x = 0;
  int k, cnt = 0, flag = 1, a, b;
  cin >> k;
  do {
    x++;
    if (x < 10) {
      cnt++;
      continue;
    }
    for (int64_t i = 1; i * 10 <= x; i *= 10) {
      a = (x % (i * 100)) / i;
      b = (a / 10) - (a % 10);
      if (b < -1 || 1 < b) {
        flag = 0;
        break;
      }
    }
    if (flag) {
      cnt++;
    }
    flag = 1;
  } while (cnt < k);
  cout << x << endl;
}
Problem p02720 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;

int k;

ll res = 0;
void solve(int pos, int last) {
  if (pos == 0) {
    k--;
    if (k == 0) {
      cout << res << endl;
      exit(0);
    }
    return;
  }
  if (last == -1) {
    for (int i = 1; i <= 9; i++) {
      res = i;
      solve(pos - 1, i);
      res /= 10;
    }
    return;
  }
  for (int i = 0; i <= 9; i++)
    if (abs(i - last) <= 1) {
      res *= 10;
      res += i;
      solve(pos - 1, i);
      res /= 10;
    }
}

int main() {
  cin >> k;
  for (int i = 1;; i++)
    solve(i, -1);
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;

int main() {
  int k;
  cin >> k;
  for (int i = 1;; i++) {
    int x = i, last = -1, ok = 1;
    while (x > 0) {
      if (last != -1 && abs(last - (x % 10)) > 1)
        ok = 0;
      last = x % 10;
      x /= 10;
    }
    if (ok)
      k--;
    if (k == 0) {
      cout << i << endl;
      return 0;
    }
  }
  return 0;
}
Problem p02720 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;

int main() {
  int k;
  cin >> k;
  vector<ll> a;
  for (int i = 1; i <= 9; i++)
    a.push_back(i);
  while (1) {
    if (k <= a.size()) {
      cout << a[k - 1];
      return 0;
    }
    k -= a.size();
    vector<ll> old;
    swap(a, old);
    for (ll d : old) {
      for (int i = -1; i <= 1; i++) {
        int s = d % 10 + i;
        if (s > 9 || s < 0)
          continue;
        a.push_back(d * 10 + s);
      }
    }
  }
}


Error: -6
terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc


Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)

int main() {
  int k;
  cin >> k;
  long long ans;
  if (k < 10) {
    ans = k;
    cout << ans << endl;
    return 0;
  }
  long long i = 10;
  long long nx;
  int cnt = 0;

  while (i != k + 1) {
    vector<int> a(100100100100100100, 0);
    nx = i % 10;
    a[cnt] = nx;
    nx /= 10;
    cnt++;
    while (nx == 0) {
      nx %= 10;
      a[cnt] = nx;
      nx /= 10;
      cnt++;
    }
    bool ok = true;
    for (int i = 0; i < cnt - 1; i++) {
      if (abs(a[i] - a[i + 1]) > 1)
        ok = false;
    }
    if (ok)
      ans = i;
  }
  cout << ans << endl;
}
Problem p02720 (C++) — buggy submission, verdict: Runtime Error

#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
typedef long long ll;
#define bay_bay return 0;
#define fori(n) for (int i = 0; i < n; ++i)
#define for1(n) for (int i = 1; i <= n; i += 3)
#define all(v) ((v).begin()), ((v).end())
#define sz(v) v.size()
#define endl "\\n"
constexpr auto EPS = 1e-9;
#define ff fflush(stdout);
clock_t T;
#define ctime cerr << "Time : " << double(clock() - T) / CLOCKS_PER_SEC << endl
void GOAT() {
  std::ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
#ifndef ONLINE_JUDGE
  freopen("in.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
#else
#endif
}
ll m;
ll a[1000005];
int pos = 0;
void solve(ll x) {
  if (x > 1e10)
    return;
  pos++;
  a[pos] = x;
  int last = x % 10;
  if (last == 0) {
    solve(x * 10 + 0);
    solve(x * 10 + 1);
  } else if (last == 9) {
    solve(x * 10 + 8);
    solve(x * 10 + 9);
  } else {
    solve(x * 10 + last - 1);
    solve(x * 10 + last);
    solve(x * 10 + last + 1);
  }
}
int main() {
  // GOAT();
  cin >> m;
  for (ll i = 1; i <= 9; i++)
    solve(i);
  sort(a, a + pos + 1);
  cout << a[m] << endl;
}

Error: WA

Fixed submission:

#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
typedef long long ll;
#define bay_bay return 0;
#define fori(n) for (int i = 0; i < n; ++i)
#define for1(n) for (int i = 1; i <= n; i += 3)
#define all(v) ((v).begin()), ((v).end())
#define sz(v) v.size()
#define endl "\\n"
constexpr auto EPS = 1e-9;
#define ff fflush(stdout);
clock_t T;
#define ctime cerr << "Time : " << double(clock() - T) / CLOCKS_PER_SEC << endl
void GOAT() {
  std::ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
#ifndef ONLINE_JUDGE
  freopen("in.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
#else
#endif
}
ll m;
ll a[1000005];
int pos = 0;
void solve(ll x) {
  if (x > 1e10)
    return;
  pos++;
  a[pos] = x;
  int last = x % 10;
  if (last == 0) {
    solve(x * 10 + 0);
    solve(x * 10 + 1);
  } else if (last == 9) {
    solve(x * 10 + 8);
    solve(x * 10 + 9);
  } else {
    solve(x * 10 + last - 1);
    solve(x * 10 + last);
    solve(x * 10 + last + 1);
  }
}
int main() {
  GOAT();
  cin >> m;
  for (ll i = 1; i <= 9; i++)
    solve(i);
  sort(a, a + pos + 1);
  cout << a[m] << endl;
}
Problem p02720 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()

#define READ(x) (cin >> (x))

#define WRITE_N(x) (cout << (x) << endl)
#define WRITE(x) (cout << (x))

int main() {
  // get values from input
  int N;
  READ(N);

  // main procedure
  if (N < 9) {
    WRITE_N(N);
    return 0;
  }

  int i = 9;
  priority_queue<ll, vector<ll>, greater<ll>> queue;
  for (ll n : {1, 2, 3, 4, 5, 6, 7, 8, 9}) {
    queue.push(n);
  }

  vector<ll> last_added(3);
  while (i < N) {
    ll base = queue.top();
    queue.pop();
    int digit0 = base % 10;
    if (digit0 == 0) {
      queue.push(base * 10);
      queue.push(base * 10 + 1);

      last_added[1] = base * 10;
      last_added[2] = base * 10 + 1;
      i += 2;
    } else if (digit0 == 9) {
      queue.push(base * 10 + 8);
      queue.push(base * 10 + 9);

      last_added[1] = base * 10 + 8;
      last_added[2] = base * 10 + 9;
      i += 2;
    } else {
      queue.push(base * 10 + digit0 - 1);
      queue.push(base * 10 + digit0);
      queue.push(base * 10 + digit0 + 1);

      last_added[0] = base * 10 + digit0 - 1;
      last_added[1] = base * 10 + digit0;
      last_added[2] = base * 10 + digit0 + 1;
      i += 3;
    }
  }
  ll ans = *(last_added.end() - (i + 1 - N));
  // output
  WRITE_N(ans);

  return 0;
}


Error: -11

Fixed submission:

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()

#define READ(x) (cin >> (x))

#define WRITE_N(x) (cout << (x) << endl)
#define WRITE(x) (cout << (x))

int main() {
  // get values from input
  int N;
  READ(N);

  // main procedure
  if (N < 9) {
    WRITE_N(N);
    return 0;
  }

  int i = 9;
  std::priority_queue<ll, vector<ll>, greater<ll>> queue;
  vector<ll> last_added(3);
  while (i <= N) {
    ll base = queue.top();
    queue.pop();
    int digit0 = base % 10;
    if (digit0 == 0) {
      queue.push(base * 10);
      queue.push(base * 10 + 1);

      last_added[1] = base * 10;
      last_added[2] = base * 10 + 1;

      i += 2;
    } else if (digit0 == 9) {
      queue.push(base * 10 + 8);
      queue.push(base * 10 + 9);

      last_added[1] = base * 10 + 8;
      last_added[2] = base * 10 + 9;
      i += 2;
    } else {
      queue.push(base * 10 + digit0 - 1);
      queue.push(base * 10 + digit0);
      queue.push(base * 10 + digit0 + 1);

      last_added[0] = base * 10 + digit0 - 1;
      last_added[1] = base * 10 + digit0;
      last_added[2] = base * 10 + digit0 + 1;
      i += 3;
    }
  }

  ll ans = *(last_added.end() - (i + 1 - N));

  // output
  WRITE_N(ans);

  return 0;
}
Problem p02720 (C++) — buggy submission, verdict: Time Limit Exceeded

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

#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << ": " << x << '\\n'

typedef long long int ll;
typedef pair<int, int> P;

const long long INF = 3e18 + 12;
const int inf = 1e9;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  int n;
  cin >> n;

  vector<ll> v;
  repi(i, 1, 10) { v.push_back(i); }

  while (1) {
    if (n <= v.size()) {
      cout << v[n - 1] << endl;
      return 0;
    }

    n -= v.size();

    vector<ll> vo;
    swap(vo, v);

    for (ll x : vo) {
      repi(i, -1, 2) {
        int d = x % 10 + i;
        if (d < 0 || d > 9)
          continue;
        ll xx = x * 10 + d;
        v.push_back(xx);
      }
    }
  }

  return 0;
}

Error: TLE

Fixed submission:

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << ": " << x << '\\n'

typedef long long int ll;
typedef pair<int, int> P;

const long long INF = 3e18 + 12;
const int inf = 1e9;

ll lun(ll n) {
  string a = to_string(n);
  ll b = a.length();
  bool flag = true;
  rep(i, b - 1) {
    if (abs(a[i] - a[i + 1]) <= 1) {
      continue;
    } else {
      flag = false;
      break;
    }
  }
  return flag;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  ll a;
  cin >> a;

  ll count = 0;

  ll ans = 0;

  for (ll i = 1; i < INF; i++) {
    if (lun(i) == true) {
      count++;
    }
    if (count == a) {
      ans = i;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}
Problem p02721 (C++) — buggy submission, verdict: Runtime Error

// OPTIMIZATONS
#pragma GCC optimize("02")
// CODE
#include <bits/stdc++.h>
#define int long long
#define float double
#define endl "\\n"
#define debug cout << "Good uptill here" << endl << flush;
#define deb(x) cout << #x << ":" << x << endl << flush;

using namespace std;

const int inf = 1e17 + 7;
const int MOD = 1e7 + 9;

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  // CODE FOR SPECIFIED INPUT AND OUTPUT
  // freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
  int n, k, c;
  cin >> n >> k >> c;
  string s;
  cin >> s;
  int dp[k][2];
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'o' && cnt < k) {
      dp[cnt++][0] = i;
      i += c;
    }
  }
  cnt = k - 1;
  for (int i = n - 1; i >= 0; i--) {
    if (s[i] == 'o' && cnt >= 0) {
      dp[cnt--][1] = i;
      i -= c;
    }
  }
  for (int i = 0; i < k; i++) {
    if (dp[i][0] == dp[i][1]) {
      cout << (dp[i][0] + 1) << endl;
    }
  }
  return 0;
}


Error: 0

Fixed submission:

// OPTIMIZATONS
#pragma GCC optimize("02")
// CODE
#include <bits/stdc++.h>
#define int long long
#define float double
#define endl "\\n"
#define debug cout << "Good uptill here" << endl << flush;
#define deb(x) cout << #x << ":" << x << endl << flush;

using namespace std;

const int inf = 1e17 + 7;
const int MOD = 1e7 + 9;

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  // CODE FOR SPECIFIED INPUT AND OUTPUT
  // freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
  int n, k, c;
  cin >> n >> k >> c;
  string s;
  cin >> s;
  int dp[k][2];
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'o') {
      dp[cnt++][0] = i;
      i += c;
    }
  }
  cnt = k - 1;
  for (int i = n - 1; i >= 0; i--) {
    if (s[i] == 'o') {
      dp[cnt--][1] = i;
      i -= c;
    }
  }
  for (int i = 0; i < k; i++) {
    if (dp[i][0] == dp[i][1]) {
      cout << (dp[i][0] + 1) << endl;
    }
  }
  return 0;
}
Problem p02721 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
// #define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) { return fabs(a - b) < DBL_EPSILON; }

std::istream &operator>>(std::istream &in, set<int> &o) {
  int a;
  in >> a;
  o.insert(a);
  return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
  ll a;
  in >> a;
  o.push(a);
  return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

// ofstream outfile("log.txt");
// outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0')
// << rank << endl;
//  std::cout << std::bitset<8>(9);
// const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll>> PQ_ASK;

int main() {

  int n, k, c;
  string s;

  cin >> n >> k >> c >> s;

  vector<int> ls;
  vector<int> rs;

  {rep(i, n){if (s[i] == 'x') continue;
  ls.push_back(i);
  i += c;

  if (ls.size() == k)
    break;
}
}

{
  for (int i = n - 1; i >= 0; i--) {
    if (s[i] == 'x')
      continue;
    rs.push_back(i);
    i -= c;

    if (rs.size() == k)
      break;
  }
  reverse(rs.begin(), rs.end());
}

rep(i, k) {
  if (rs[i] == ls[i])
    cout << rs[i] + 1 << endl;
}
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
// #define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) { return fabs(a - b) < DBL_EPSILON; }

std::istream &operator>>(std::istream &in, set<int> &o) {
  int a;
  in >> a;
  o.insert(a);
  return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
  ll a;
  in >> a;
  o.push(a);
  return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

// ofstream outfile("log.txt");
// outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0')
// << rank << endl;
//  std::cout << std::bitset<8>(9);
// const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll>> PQ_ASK;

bool check(int n, string s, int i, int k, int c) {
  assert(s[i] == 'o');
  s[i] = 'x';
  int choose = 0;
  rep(j, n) {
    if (s[j] == 'o') {
      choose++;
      j += c;
    }
  }
  return choose >= k;
}

int main() {

  int n, k, c;
  string s;

  cin >> n >> k >> c >> s;

  rep(i, n) {
    if (s[i] == 'x')
      continue;
    bool b = check(n, s, i, k, c);
    if (b)
      continue;
    cout << i + 1 << endl;
  }
}
Problem p02721 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  int n, k, c, p, sum = 0;
  bool tf = false;
  cin >> n >> k >> c;
  char a[n];
  bool b[n], d[n];
  for (int i = 0; i < n; i++) {
    char t;
    cin >> t;
    a[i] = t;
    if (t == 'o')
      sum++;
    b[i] = false;
    d[i] = false;
  }
  p = k;
  for (int i = 0; i < n; i++) {
    if (a[i] == 'o') {
      b[i] = true;
      i += c;
      p--;
    }
  }
  if (sum == k) {
    for (int i = 0; i < n; i++) {
      if (b[i])
        cout << i + 1 << endl;
    }
  } else if (p < 0) {
  } else {
    for (int i = n - 1; i >= 0; i--) {
      if (a[i] == 'o') {
        d[i] = true;
        i -= c;
      }
    }
    for (int i = 0; i < n; i++) {
      if (b[i] == true && d[i] == true)
        cout << i + 1 << endl;
    }
  }
}

Error: TLE

Fixed submission:

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

int main() {
  int n, k, c, p, sum = 0;
  bool tf = false;
  cin >> n >> k >> c;
  char a[n];
  bool b[n];
  for (int i = 0; i < n; i++) {
    char t;
    cin >> t;
    a[i] = t;
    if (t == 'o')
      sum++;
    b[i] = false;
  }
  p = k;
  for (int i = 0; i < n; i++) {
    if (a[i] == 'o') {
      b[i] = true;
      i += c;
      p--;
    }
  }
  if (sum == k) {
    for (int i = 0; i < n; i++) {
      if (b[i])
        cout << i + 1 << endl;
    }
  } else if (p < 0) {
  } else {
    for (int i = 0; i < n; i++) {
      p = k;
      tf = false;
      if (b[i]) {
        tf = true;
        for (int j = i + 1; j < n; j++) {
          if (a[j] == 'o') {
            p--;
            j += c;
          }
          if (p == 0) {
            tf = false;
            break;
          }
        }
        k--;
      }
      if (tf) {
        cout << i + 1 << endl;
      }
    }
  }
}
Problem p02721 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cstdio>
#include <cstring>
using namespace std;
typedef long long ll;
#define M 200005
int sl[M], mp[M], vs[M];
char S[M];
inline void rd(int &l) {
  l = 0;
  int f = 0;
  char ch = getchar();
  while (ch > '9' || ch < '0') {
    if (ch == '-')
      f = 1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    l = l * 10 + ch - '0';
    ch = getchar();
  }
  if (f)
    l = -l;
}
int main() {
  int N, K, C, tp = 1;
  rd(N);
  rd(K);
  rd(C);
  scanf("%s", S + 1);
  for (int i = 1; i <= N; ++i)
    mp[i] = (S[i] == 'x');
  for (int i = 1; i <= K; ++i) {
    while (tp <= N && mp[tp])
      ++tp;
    sl[i] = tp;
    tp += C + 1;
  }
  if (K && sl[K]) {
    tp = N;
    for (int i = K; i; --i) {
      while (tp && mp[tp])
        --tp;
      vs[i] = tp;
      // printf("%d %d\\n",sl[i],vs[i]);
      tp -= C + 1;
    }
    for (int i = 1; i <= K; ++i)
      if (vs[i] == sl[i])
        printf("%d\\n", vs[i]);
  }
  // getchar();
  // getchar();
  return 0;
}

Error: 0

Fixed submission:

#include <algorithm>
#include <cstdio>
#include <cstring>
using namespace std;
typedef long long ll;
#define M 100005
int sl[M], mp[M], vs[M];
char S[M];
inline void rd(int &l) {
  l = 0;
  int f = 0;
  char ch = getchar();
  while (ch > '9' || ch < '0') {
    if (ch == '-')
      f = 1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    l = l * 10 + ch - '0';
    ch = getchar();
  }
  if (f)
    l = -l;
}
int main() {
  int N, K, C, tp = 1;
  rd(N);
  rd(K);
  rd(C);
  scanf("%s", S + 1);
  for (int i = 1; i <= N; ++i)
    mp[i] = (S[i] == 'x');
  for (int i = 1; i <= K; ++i) {
    while (tp <= N && mp[tp])
      ++tp;
    sl[i] = tp;
    tp += C + 1;
  }
  if (K && sl[K]) {
    tp = N;
    for (int i = K; i; --i) {
      while (tp && mp[tp])
        --tp;
      vs[i] = tp;
      // printf("%d %d\\n",sl[i],vs[i]);
      tp -= C + 1;
    }
    for (int i = 1; i <= K; ++i)
      if (vs[i] == sl[i])
        printf("%d\\n", vs[i]);
  }
  // getchar();
  // getchar();
  return 0;
}