alexjercan/bugnet huggingface dataset:
Problem p01138 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define MAX 10000
using namespace std;
int ans, cou;
int n;
char s[10], g[10];
struct t {
  int h;
  int m;
  int s;
};
t start[MAX], goal[MAX];
int main() {
  while (true) {
    cin >> n;
    if (n == 0)
      return 0;
    ans = 0;
    cou = 0;
    rep(i, n) {
      cin >> s >> g;
      start[i] = t();
      goal[i] = t();
      start[i].h = (int)(s[0] - '0') * 10 + (int)(s[1] - '0');
      start[i].m = (int)(s[3] - '0') * 10 + (int)(s[4] - '0');
      start[i].s = (int)(s[6] - '0') * 10 + (int)(s[7] - '0');
      goal[i].h = (int)(g[0] - '0') * 10 + (int)(g[1] - '0');
      goal[i].m = (int)(g[3] - '0') * 10 + (int)(g[4] - '0');
      goal[i].s = (int)(g[6] - '0') * 10 + (int)(g[7] - '0');
    }
    rep(i, 24) rep(j, 60) rep(k, 60) {
      rep(l, n) {
        if (goal[l].h == i && goal[l].m == j && goal[l].s == k)
          cou--;
        if (start[l].h == i && start[l].m == j && start[l].s == k)
          cou++;
      }
      if (cou > ans)
        ans = cou;
    }
    cout << ans << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define MAX 10000
using namespace std;
int ans, cou;
int n;
char s[10], g[10];
struct t {
  int h;
  int m;
  int s;
};
t start[MAX], goal[MAX];
int main() {
  while (true) {
    cin >> n;
    if (n == 0)
      return 0;
    ans = 0;
    cou = 0;
    rep(i, n) {
      cin >> s >> g;
      start[i] = t();
      goal[i] = t();
      start[i].h = (int)(s[0] - '0') * 10 + (int)(s[1] - '0');
      start[i].m = (int)(s[3] - '0') * 10 + (int)(s[4] - '0');
      start[i].s = (int)(s[6] - '0') * 10 + (int)(s[7] - '0');
      goal[i].h = (int)(g[0] - '0') * 10 + (int)(g[1] - '0');
      goal[i].m = (int)(g[3] - '0') * 10 + (int)(g[4] - '0');
      goal[i].s = (int)(g[6] - '0') * 10 + (int)(g[7] - '0');
    }
    rep(i, 24) rep(j, 60) rep(k, 60) {
      rep(l, n) if (goal[l].h == i && goal[l].m == j && goal[l].s == k) cou--;
      rep(l, n) if (start[l].h == i && start[l].m == j && start[l].s == k) {
        cou++;
        if (cou > ans)
          ans = cou;
      }
    }
    cout << ans << endl;
  }
  return 0;
}
Problem p01138 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <iostream>
using namespace std;
int main() {
  int n;
  while (cin >> n, n) {
    int imos[86410] = {};
    for (int i = 0; i < n; i++) {
      int a, b, c, d, e, f;
      char ch;
      cin >> a >> ch >> b >> ch >> c;
      cin >> d >> ch >> e >> ch >> f;
      imos[a * 3600 + b * 60 + c]++;
      imos[d * 3600 + e * 60 + f]--;
    }
    int ans = imos[0];
    for (int i = 1; i <= 86400; i++) {
      imos[i] += imos[i - 1];
      ans = max(ans, imos[i]);
    }
    cout << ans << endl;
  }
}

Error: -11

Fixed submission:

#include <algorithm>
#include <iostream>
using namespace std;
int main() {
  int n;
  while (cin >> n, n) {
    int imos[86410] = {};
    for (int i = 0; i < n; i++) {
      int a, b, c, d, e, f;
      scanf("%d:%d:%d", a, b, c);
      scanf("%d:%d:%d", d, e, f);
      imos[a * 3600 + b * 60 + c]++;
      imos[d * 3600 + e * 60 + f]--;
    }
    int ans = imos[0];
    for (int i = 1; i <= 86400; i++) {
      imos[i] += imos[i - 1];
      ans = max(ans, imos[i]);
    }
    cout << ans << endl;
  }
}
Problem p01138 (C++) — buggy submission, verdict: Runtime Error

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

#define fi first
#define se second
#define repl(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repl(i, 0, n)
#define each(itr, v) for (auto itr : v)
#define pb(s) push_back(s)
#define mp(a, b) make_pair(a, b)
#define all(x) (x).begin(), (x).end()
#define dbg(x) cout << #x "=" << x << endl
#define maxch(x, y) x = max(x, y)
#define minch(x, y) x = min(x, y)
#define uni(x) x.erase(unique(all(x)), x.end())
#define exist(x, y) (find(all(x), y) != x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX / 3

#define MAX_N 1000

int n;
int t[100010];

int main() {
  while (1) {
    scanf("%d", &n);
    if (n == 0)
      break;
    memset(t, 0, sizeof(t));
    rep(i, n) {
      int h, m, s;
      scanf("%d:%d:%d", &h, &m, &s);
      t[h * 3600 + m * 60 + s]++;
      scanf("%d:%d:%d", &h, &m, &s);
      t[h * 3600 + m * 60 + s]--;
    }
    int res = t[0];
    rep(i, 100000) {
      t[i + 1] += t[i];
      maxch(res, t[i + 1]);
    }
    printf("%d\\n", res);
  }
  return 0;
}

Error: -11

Fixed submission:

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

#define fi first
#define se second
#define repl(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repl(i, 0, n)
#define each(itr, v) for (auto itr : v)
#define pb(s) push_back(s)
#define mp(a, b) make_pair(a, b)
#define all(x) (x).begin(), (x).end()
#define dbg(x) cout << #x "=" << x << endl
#define maxch(x, y) x = max(x, y)
#define minch(x, y) x = min(x, y)
#define uni(x) x.erase(unique(all(x)), x.end())
#define exist(x, y) (find(all(x), y) != x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX / 3

#define MAX_N 1000

int n;
int t[100010];

int main() {
  cin.sync_with_stdio(false);
  while (1) {
    cin >> n;
    if (n == 0)
      break;
    memset(t, 0, sizeof(t));
    rep(i, n) {
      int h, m, s;
      scanf("%d:%d:%d", &h, &m, &s);
      t[h * 3600 + m * 60 + s] += 1;
      scanf("%d:%d:%d", &h, &m, &s);
      t[h * 3600 + m * 60 + s] -= 1;
      // dbg(h); dbg(m); dbg(s);
    }
    rep(i, 100000) { t[i + 1] += t[i]; }
    int res = 0;
    rep(i, 100000) { maxch(res, t[i]); }
    cout << res << endl;
  }
  return 0;
}
Problem p01139 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <string>
#include <vector>

using namespace std;

int W, H;
vector<string> M;

const vector<int> dx = {0, 1, 0, -1};
const vector<int> dy = {-1, 0, 1, 0};

vector<vector<bool>> ok;

void rec(int x, int y) {
  ok[y][x] = true;

  if (M[y][x] != '.') {
    return;
  }

  for (int dir = 0; dir < 4; dir++) {
    int tx = x + dx[dir];
    int ty = y + dy[dir];

    if (0 <= tx && tx < W && 0 <= ty && ty < H && ok[ty][tx] == false) {
      rec(tx, ty);
    }
  }
}

int main() {
  while (true) {
    cin >> W >> H;

    if (W == 0 && H == 0) {
      break;
    }

    M = vector<string>(H);

    for (int i = 0; i < H; i++) {
      cin >> M[i];
    }

    int b = 0, w = 0;

    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        if (M[i][j] == '.') {
          ok = vector<vector<bool>>(H, vector<bool>(W, false));

          rec(j, i);

          int br = 0, wr = 0;

          for (int k = 0; k < H; k++) {
            for (int l = 0; l < W; l++) {
              if (M[k][l] == 'W' && ok[k][l] == true) {
                wr++;
              }

              if (M[k][l] == 'B' && ok[k][l] == true) {
                br++;
              }
            }
          }

          if (wr != 0 && br == 0) {
            w++;
          }
          if (br != 0 && wr == 0) {
            b++;
          }
        }
      }
    }

    cout << b << ' ' << w << endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
#include <string>
#include <vector>

using namespace std;

int W, H;
vector<string> M;

const vector<int> dx = {0, 1, 0, -1};
const vector<int> dy = {-1, 0, 1, 0};

int rec(int x, int y, vector<vector<bool>> ok) {
  if (M[y][x] == 'W') {
    return 2;
  }

  if (M[y][x] == 'B') {
    return 1;
  }

  int ret = 3;

  for (int dir = 0; dir < 4; dir++) {
    int tx = x + dx[dir];
    int ty = y + dy[dir];

    if (0 <= tx && tx < W && 0 <= ty && ty < H && ok[ty][tx] == false) {
      vector<vector<bool>> ok2 = ok;
      ok2[ty][tx] = true;

      ret = ret & rec(tx, ty, ok2);

      if (ret == 0) {
        return 0;
      }
    }
  }

  return ret;
}

int main() {
  while (true) {
    cin >> W >> H;

    if (W == 0 && H == 0) {
      break;
    }

    M = vector<string>(H);

    for (int i = 0; i < H; i++) {
      cin >> M[i];
    }

    int b = 0, w = 0;

    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        if (M[i][j] == '.') {
          int c = rec(j, i, vector<vector<bool>>(H, vector<bool>(W, false)));

          if (c == 1) {
            b++;
          }
          if (c == 2) {
            w++;
          }
        }
      }
    }

    cout << b << ' ' << w << endl;
  }

  return 0;
}
Problem p01139 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};

int w, h;
vector<string> ss;
bool is_white[103][103];
bool is_black[103][103];

void dfs(int x_, int y_, bool (*f_)[103], bool f2) {
  // cout<<x_<<","<<y_<<endl;
  if (f_[x_][y_] || (ss[x_][y_] != '.' && f2))
    return;
  f_[x_][y_] = true;
  rep(i, 4) {
    int x = x_ + dx[i];
    int y = y_ + dy[i];
    if (0 <= x && x < ss.size() && 0 <= y && y < ss[x].size()) {
      dfs(x, y, f_, true);
    }
  }
}

void solve() {
  rep(i, 103) rep(j, 103) is_white[i][j] = is_black[i][j] = false;
  ss.resize(h);
  rep(i, h) {
    string t;
    cin >> t;
    ss[i] = t;
  }
  int ans_b = 0, ans_w = 0;
  rep(i, ss.size()) {
    rep(j, ss[i].size()) {
      if (ss[i][j] == 'B')
        dfs(i, j, is_black, false);
      if (ss[i][j] == 'W')
        dfs(i, j, is_white, false);
    }
  }
  rep(i, ss.size()) rep(j, ss[i].size()) {
    // cout<<i<<","<<j<<":"<<is_white[i][j]<<","<<is_black[i][j]<<ss[i][j]<<endl;
    if (ss[i][j] == '.' && (is_white[i][j] ^ is_black[i][j])) {
      if (is_white[i][j])
        ans_w++;
      else
        ans_b++;
    }
  }
  cout << ans_b << " " << ans_w << endl;
  ss.clear();
}

int main() {
  while (cin >> w >> h) {
    if (w + h == 0)
      return 0;
    solve();
  }

  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};

int w, h;
vector<string> ss;
bool is_white[103][103];
bool is_black[103][103];

void dfs(int x_, int y_, bool (*f_)[103], bool f2) {
  // cout<<x_<<","<<y_<<endl;
  if (f_[x_][y_] || (ss[x_][y_] != '.' && f2))
    return;
  f_[x_][y_] = true;
  rep(i, 4) {
    int x = x_ + dx[i];
    int y = y_ + dy[i];
    if (0 <= x && x < ss.size() && 0 <= y && y < ss[x].size()) {
      dfs(x, y, f_, true);
    }
  }
}

void solve() {
  rep(i, 103) rep(j, 103) is_white[i][j] = is_black[i][j] = false;
  ss.resize(w);
  rep(i, h) {
    string t;
    cin >> t;
    ss[i] = t;
  }
  int ans_b = 0, ans_w = 0;
  rep(i, ss.size()) {
    rep(j, ss[i].size()) {
      if (ss[i][j] == 'B')
        dfs(i, j, is_black, false);
      if (ss[i][j] == 'W')
        dfs(i, j, is_white, false);
    }
  }
  rep(i, ss.size()) rep(j, ss[i].size()) {
    // cout<<i<<","<<j<<":"<<is_white[i][j]<<","<<is_black[i][j]<<ss[i][j]<<endl;
    if (ss[i][j] == '.' && (is_white[i][j] ^ is_black[i][j])) {
      if (is_white[i][j])
        ans_w++;
      else
        ans_b++;
    }
  }
  cout << ans_b << " " << ans_w << endl;
  ss.clear();
}

int main() {
  while (cin >> w >> h) {
    if (w + h == 0)
      return 0;
    solve();
  }

  return 0;
}
Problem p01139 (C++) — buggy submission, verdict: Runtime Error

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

typedef pair<int, int> P;
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

int w, h;
bool visited[64][64];
vector<string> maze;

bool check(int x, int y) { return x >= 0 && x < w && y >= 0 && y < h; }

int dfs(int x, int y) {
  if (maze[y][x] == 'B')
    return 1;
  else if (maze[y][x] == 'W')
    return 2;

  int res = 0;
  for (int i = 0; i < 4; ++i) {
    int nx = x + dx[i];
    int ny = y + dy[i];
    if (!check(nx, ny) || visited[ny][nx])
      continue;
    visited[ny][nx] = true;
    res |= dfs(nx, ny);
  }
  return res;
}
int main() {
  while (cin >> w >> h && (w || h)) {
    string a;
    maze.clear();
    int cntB = 0, cntW = 0;
    for (int i = 0; i < h; ++i) {
      cin >> a;
      maze.push_back(a);
    }
    for (int y = 0; y < h; ++y) {
      for (int x = 0; x < w; ++x) {
        if (maze[y][x] != '.')
          continue;
        memset(visited, 0, sizeof(visited));
        visited[y][x] = true;
        int res = dfs(x, y);
        if (res == 1)
          cntB++;
        else if (res == 2)
          cntW++;
      }
    }
    cout << cntB << " " << cntW << endl;
  }
  return 0;
}

Error: 0

Fixed submission:

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

typedef pair<int, int> P;

int w, h;

bool check(int x, int y) { return x >= 0 && x < w && y >= 0 && y < h; }

int main() {
  int dx[] = {1, 0, -1, 0};
  int dy[] = {0, 1, 0, -1};
  while (cin >> w >> h && (w || h)) {
    string a;
    int cntB = 0, cntW = 0;
    vector<string> maze;
    for (int i = 0; i < h; ++i) {
      cin >> a;
      maze.push_back(a);
    }
    for (int y = 0; y < h; ++y) {
      for (int x = 0; x < w; ++x) {
        if (maze[y][x] != '.')
          continue;
        bool white = false, black = false;
        queue<P> que;
        bool visited[128][128] = {0};
        que.push(P(x, y));
        while (!que.empty()) {
          P p = que.front();
          que.pop();
          int px = p.first;
          int py = p.second;
          visited[py][px] = true;
          if (maze[py][px] == 'W') {
            white = true;
            // cout << x << " " << y << endl;
            continue;
          }
          if (maze[py][px] == 'B') {
            black = true;
            continue;
          }
          for (int i = 0; i < 4; ++i) {
            int nx = px + dx[i];
            int ny = py + dy[i];
            if (check(nx, ny) && !visited[ny][nx])
              que.push(P(nx, ny));
          }
        }
        if (!white && black)
          cntB++;
        else if (white && !black)
          cntW++;
      }
    }
    cout << cntB << " " << cntW << endl;
  }
  return 0;
}
Problem p01139 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef pair<int, int> pii;
#define FST first
#define SEC second

int w, h;
int dd[8] = {0, 1, 0, -1, 0};

void bfs(char map[50][50]) {
  stack<pii> q;
  int bc = 0, wc = 0;
  rep(i, h) {
    rep(j, w) {
      if (map[j][i] == '.') {
        q.push(pii(j, i));
        int count = 0;
        pii state = pii(0, 0);
        while (!q.empty()) {
          int cx = q.top().FST, cy = q.top().SEC;
          q.pop();
          if (map[cx][cy] == '.')
            count++;
          map[cx][cy] = '#';
          rep(r, 4) {
            int nx = cx + dd[r], ny = cy + dd[r + 1];
            if (nx < 0 || ny < 0 || nx >= w || ny >= h || map[nx][ny] == '#')
              continue;
            if (map[nx][ny] == 'B') {
              state.FST = 1;
              continue;
            }
            if (map[nx][ny] == 'W') {
              state.SEC = 1;
              continue;
            }
            q.push(pii(nx, ny));
          }
        }
        if (state == pii(1, 0))
          bc += count;
        if (state == pii(0, 1))
          wc += count;
      }
    }
  }
  printf("%d %d\\n", bc, wc);
}

int main() {
  for (;;) {
    cin >> w >> h;
    if (!(w + h))
      break;
    char map[50][50];
    rep(i, h) {
      rep(j, w) { cin >> map[j][i]; }
    }
    bfs(map);
  }
  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef pair<int, int> pii;
#define FST first
#define SEC second

int w, h;
int dd[8] = {0, 1, 0, -1, 0};

void bfs(char map[50][50]) {
  queue<pii> q;
  int bc = 0, wc = 0;
  rep(i, h) {
    rep(j, w) {
      if (map[j][i] == '.') {
        q.push(pii(j, i));
        int count = 0;
        pii state = pii(0, 0);
        while (!q.empty()) {
          int cx = q.front().FST, cy = q.front().SEC;
          q.pop();
          if (map[cx][cy] == '.')
            count++;
          map[cx][cy] = '#';
          rep(r, 4) {
            int nx = cx + dd[r], ny = cy + dd[r + 1];
            if (nx < 0 || ny < 0 || nx >= w || ny >= h || map[nx][ny] == '#')
              continue;
            if (map[nx][ny] == 'B') {
              state.FST = 1;
              continue;
            }
            if (map[nx][ny] == 'W') {
              state.SEC = 1;
              continue;
            }
            q.push(pii(nx, ny));
          }
        }
        if (state == pii(1, 0))
          bc += count;
        if (state == pii(0, 1))
          wc += count;
      }
    }
  }
  printf("%d %d\\n", bc, wc);
}

int main() {
  for (;;) {
    cin >> w >> h;
    if (!(w + h))
      break;
    char map[50][50];
    rep(i, h) {
      rep(j, w) { cin >> map[j][i]; }
    }
    bfs(map);
  }
  return 0;
}
Problem p01139 (C++) — buggy submission, verdict: Memory Limit Exceeded

#include "cstring"
#include "iostream"
#include "string"
#include "vector"
using namespace std;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
bool black[50][50], white[50][50];
string in[50];
bool used[50][50];
int w, h;

void dfs(int y, int x, int f) {
  if (f == 1)
    white[y][x] = true;
  else
    black[y][x] = true;
  used[y][x] = true;
  for (int i = 0; i < 4; i++) {
    int nx = x + dx[i], ny = y + dy[i];
    if (0 <= nx && nx < w && 0 <= ny && ny < h && !used[ny][nx] &&
        in[ny][nx] == '.')
      dfs(ny, nx, f);
  }
}

int main(void) {
  while (cin >> w >> h, w) {
    memset(black, 0, sizeof(black));
    memset(white, 0, sizeof(white));
    for (int i = 0; i < h; i++) {
      cin >> in[i];
    }

    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        int f = 0;
        if (in[i][j] == 'W')
          f = 1;
        else if (in[i][j] == 'B')
          f = 2;

        if (in[i][j] != '.') {
          memset(used, 0, sizeof(used));
          dfs(i, j, f);
        }
      }
    }

    int Black = 0, White = 0;
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        if (in[i][j] != 'B' && black[i][j] && !white[i][j])
          Black++;
        else if (in[i][j] != 'W' && !black[i][j] && white[i][j])
          White++;
      }
    }
    cout << Black << " " << White << endl;
  }
  return 0;
}

Error: MLE

Fixed submission:

#include "cstring"
#include "iostream"
#include "queue"
#include "string"
#include "vector"
using namespace std;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int main(void) {
  int w, h;
  while (cin >> w >> h, w) {
    bool black[h][w], white[h][w];
    memset(black, 0, sizeof(black));
    memset(white, 0, sizeof(white));
    string in[h];
    for (int i = 0; i < h; i++) {
      cin >> in[i];
    }

    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        int f = 0;
        if (in[i][j] == 'W')
          f = 1;
        else if (in[i][j] == 'B')
          f = 2;

        if (in[i][j] != '.') {
          bool used[h][w];
          memset(used, 0, sizeof(used));
          queue<int> xs, ys;
          xs.push(j);
          ys.push(i);
          while (!xs.empty()) {
            int x = xs.front(), y = ys.front();
            xs.pop();
            ys.pop();
            used[y][x] = true;
            if (f == 1)
              white[y][x] = true;
            else
              black[y][x] = true;
            for (int k = 0; k < 4; k++) {
              int nx = x + dx[k], ny = y + dy[k];
              if (0 <= nx && nx < w && 0 <= ny && ny < h && !used[ny][nx] &&
                  in[ny][nx] == '.') {
                xs.push(nx);
                ys.push(ny);
              }
            }
          }
        }
      }
    }

    int Black = 0, White = 0;
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        if (in[i][j] != 'B' && black[i][j] && !white[i][j])
          Black++;
        else if (in[i][j] != 'W' && !black[i][j] && white[i][j])
          White++;
      }
    }
    cout << Black << " " << White << endl;
  }
  return 0;
}
Problem p01143 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;
int main(void) {
  for (;;) {
    int N, M, P;
    cin >> N >> M >> P;
    if (N == 0 && M == 0 && P == 0) {
      return 0;
    }
    int X[N];
    for (int i = 0; i < N; i++) {
      cin >> X[i];
    }
    int sum = 0;
    for (int i = 0; i < N; i++) {
      sum += 100 * X[i];
    }
    sum = sum * (100 - P) / 100;
    if (X[M - 1] > 0) {
      cout << sum / X[M - 1] << endl;
    } else {
      cout << 0 << endl;
    }
  }
}


Error: WA

Fixed submission:

#include <iostream>
using namespace std;
int main(void) {
  for (;;) {
    int N, M, P;
    cin >> N >> M >> P;
    if (N == 0 && M == 0 && P == 0) {
      return 0;
    }
    int X[N];
    for (int i = 0; i < N; i++) {
      cin >> X[i];
    }
    int sum = 0;
    for (int i = 0; i < N; i++) {
      sum += X[i];
    }
    sum = sum / (100 - P) * 100;
    if (X[M - 1] > 0) {
      cout << sum / X[M - 1] << endl;
    } else {
      cout << 0 << endl;
    }
  }
}
Problem p01143 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

typedef long long LL;

// container util
//------------------------------------------
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define DECIM8 fixed << setprecision(8)
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(), (c).end())

// repetition
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

// constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);

// clear memory
#define CLR(a) memset((a), 0, sizeof(a))

using namespace std;
int main(void) {
  for (;;) {
    int n, m, p, sum = 0, div;
    cin >> n >> m >> p;
    if (!n && !m && !p)
      return 0;
    REP(i, n) {
      int tmp;
      cin >> tmp;
      sum += tmp;
      if (i + 1 == m)
        div = tmp;
    }
    if (div == 0)
      sum = 0;
    else
      sum = sum * (100 - p) / div;
    cout << sum << endl;
  }
}

Error: -8

Fixed submission:

#include <bits/stdc++.h>

typedef long long LL;

// container util
//------------------------------------------
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define DECIM8 fixed << setprecision(8)
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(), (c).end())

// repetition
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

// constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);

// clear memory
#define CLR(a) memset((a), 0, sizeof(a))

using namespace std;
int main(void) {
  for (;;) {
    int n, m, p, sum = 0, div;
    cin >> n >> m >> p;
    if (!n && !m && !p)
      return 0;
    REP(i, n) {
      int tmp;
      cin >> tmp;
      sum += tmp;
      if (i + 1 == m)
        div = tmp;
    }
    cout << sum * (100 - p) / div << endl;
  }
}