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

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define INF (1e9 + 1)
// #define INF (1LL<<59)

struct st {
  int x, y, z;

  bool operator<(st a) const {
    if (x != a.x)
      return x < a.x;
    if (y != a.y)
      return y < a.y;
    return z < a.z;
  };
};

int main() {
  int n, h;
  while (cin >> n >> h && (n || h)) {
    set<pii> xy, xz, yz;

    rep(i, h) {
      string s;
      int a, b;
      cin >> s >> a >> b;
      a--, b--;
      if (s == "xy")
        xy.insert(pii(a, b));
      if (s == "xz")
        xz.insert(pii(a, b));
      if (s == "yz")
        yz.insert(pii(a, b));
    }

    int c = 0;
    map<st, int> cross;
    for (auto &e_xy : xy) {
      bool f = false;
      for (auto &e_xz : xz) {
        if (e_xy.first == e_xz.first) {
          cross[st{e_xy.first, e_xy.second, e_xz.second}]++;
          f = true;
        }
      }
      if (f)
        c++;
    }

    for (auto &e_yz : yz) {
      bool f = false;
      for (auto &e_xy : xy) {
        if (e_yz.first == e_xy.second) {
          cross[st{e_xy.first, e_xy.second, e_yz.second}]++;
          f = true;
        }
      }
      if (f)
        c++;
    }

    for (auto &e_xz : xz) {
      bool f = false;
      for (auto &e_yz : yz) {
        if (e_xz.second == e_yz.second) {
          cross[st{e_xz.first, e_yz.first, e_yz.second}]++;
          f = true;
        }
      }
      if (f)
        c++;
    }

    int tw = 0, th = 0;
    for (auto &e : cross) {
      if (e.second == 1)
        tw++;
      else if (e.second == 3)
        th++;
      else
        cout << e.second << endl;
    }

    //       cout<<n*n*n<<" "<<h*n<<" "<<tw<<" "<<th<<endl;
    cout << n * n * n - h * n + tw + th * 2 << endl;
  }
}

Error: TLE

Fixed submission:

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

int main() {
  int n, h;
  while (cin >> n >> h && (n || h)) {
    set<pii> xy, xz, yz;

    rep(i, h) {
      string s;
      int a, b;
      cin >> s >> a >> b;
      a--, b--;
      if (s == "xy")
        xy.insert(pii(a, b));
      if (s == "xz")
        xz.insert(pii(a, b));
      if (s == "yz")
        yz.insert(pii(a, b));
    }

    ll ans = n * n * n;
    rep(i_x, n) {
      rep(i_y, n) {
        rep(i_z, n) {
          if (xy.count(pii(i_x, i_y)) != 0)
            ans--;
          else if (xz.count(pii(i_x, i_z)) != 0)
            ans--;
          else if (yz.count(pii(i_y, i_z)) != 0)
            ans--;
        }
      }
    }
    cout << ans << endl;
  }
}
Problem p00616 (C++) — buggy submission, verdict: Memory Limit Exceeded

#include <algorithm>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
#define REP(i, j) for (int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for (int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef pair<int, int> P;
typedef pair<int, P> PP;

int main() {
  int N, H;
  while (cin >> N >> H && N) {
    set<PP> S;
    REP(h, H) {
      string s;
      int a, b;
      cin >> s >> a >> b;
      FOR(i, 1, N + 1) {
        if (s == "xy")
          S.insert(PP(a, P(b, i)));
        if (s == "xz")
          S.insert(PP(a, P(i, b)));
        if (s == "yz")
          S.insert(PP(i, P(a, b)));
      }
    }
    cout << N * N * N - S.size() << endl;
  }
  return 0;
}

Error: MLE

Fixed submission:

#include <algorithm>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
#define REP(i, j) for (int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for (int i = (int)(j); i < (int)(k); ++i)
#define P pair<int, int>
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
const int MAX_N = 505;

int N, H;
bool v[MAX_N][MAX_N][MAX_N];

void holes(int x, int y, int z, int px, int py, int pz) {
  REP(i, N) {
    v[x][y][z] = 1;
    x += px;
    y += py;
    z += pz;
  }
}

int main() {
  while (cin >> N >> H && N) {
    memset(v, 0, sizeof(v));
    REP(i, H) {
      string s;
      int a, b;
      cin >> s >> a >> b;
      if (s == "xy")
        holes(a - 1, b - 1, 0, 0, 0, 1);
      if (s == "xz")
        holes(a - 1, 0, b - 1, 0, 1, 0);
      if (s == "yz")
        holes(0, a - 1, b - 1, 1, 0, 0);
    }
    int ans = N * N * N;
    REP(i, N) REP(j, N) REP(k, N) if (v[i][j][k])-- ans;
    cout << ans << endl;
  }
  return 0;
}
Problem p00616 (C++) — buggy submission, verdict: Memory Limit Exceeded

#include <algorithm>
#include <array>
#include <cstdio>
#include <iostream>
#include <set>
#include <vector>

using namespace std;

int main() {

  while (true) {
    int n, h;
    cin >> n >> h;
    if (n == 0 and h == 0)
      break;

    set<tuple<int, int, int>> s;
    for (int i = 0; i < h; i++) {
      string c;
      int a, b;
      cin >> c >> a >> b;
      a--;
      b--;
      if ("xy" == c) {
        for (int j = 0; j < n; j++) {
          s.insert(make_tuple(a, b, j));
        }
      } else if ("xz" == c) {
        for (int j = 0; j < n; j++) {
          s.insert(make_tuple(a, j, b));
        }
      } else {
        for (int j = 0; j < n; j++) {
          s.insert(make_tuple(j, a, b));
        }
      }
    }
    cout << n * n * n - s.size() << endl;
  }
}

Error: MLE

Fixed submission:

#include <algorithm>
#include <array>
#include <cstdio>
#include <iostream>
#include <vector>

using namespace std;

bool cube[500][500][500];

int main() {

  while (true) {
    int n, h;
    cin >> n >> h;
    if (n == 0 and h == 0)
      break;

    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        for (int k = 0; k < n; k++) {
          cube[i][j][k] = false;
        }
      }
    }

    for (int i = 0; i < h; i++) {
      string c;
      int a, b;
      cin >> c >> a >> b;
      a--;
      b--;
      if ("xy" == c) {
        for (int j = 0; j < n; j++) {
          cube[a][b][j] = true;
        }
      } else if ("xz" == c) {
        for (int j = 0; j < n; j++) {
          cube[a][j][b] = true;
        }
      } else {
        for (int j = 0; j < n; j++) {
          cube[j][a][b] = true;
        }
      }
    }
    int counter = n * n * n;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        for (int k = 0; k < n; k++) {
          if (cube[i][j][k]) {
            counter--;
          }
        }
      }
    }
    cout << counter << endl;
  }
}
Problem p00616 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <iostream>
using namespace std;

int n, h;
int a, b;
bool c[500 * 500 * 500];
string z;

int main() {
  for (;;) {
    cin >> n >> h;
    if (!n && !h)
      break;

    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++)
        for (int k = 0; k < n; k++)
          c[i * n * n + j * n + k] = true;

    int cnt = 0;
    for (int i = 0; i < h; i++) {
      cin >> z >> a >> b;
      a--;
      b--;
      if (z == "xy")
        for (int j = 0; j < n; j++) {
          if (c[a * n * n + b * n + j]) {
            cnt++;
            c[a * n * n + b * n + j] = false;
          }
        }
      else if (z == "yz")
        for (int j = 0; j < n; j++) {
          if (c[j * n * n + a * n + b]) {
            cnt++;
            c[j * n * n + a * n + b] = false;
          }
        }
      else
        for (int j = 0; j < n; j++) {
          if (c[a * n * n + j * n + b]) {
            cnt++;
            c[a * n * n + j * n + b] = false;
          }
        }
    }

    cout << n * n * n - cnt << endl;
  }
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>
using namespace std;

int n, h;
int a, b;
bool c[500 * 500 * 500];
string z;

int main() {
  for (;;) {
    cin >> n >> h;
    if (!n && !h)
      break;

    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++)
        for (int k = 0; k < n; k++)
          c[i * n * n + j * n + k] = true;

    for (int i = 0; i < h; i++) {
      cin >> z >> a >> b;
      a--;
      b--;
      if (z == "xy")
        for (int j = 0; j < n; j++)
          c[a * n * n + b * n + j] = false;
      else if (z == "yz")
        for (int j = 0; j < n; j++)
          c[j * n * n + a * n + b] = false;
      else
        for (int j = 0; j < n; j++)
          c[a * n * n + j * n + b] = false;
    }

    cout << count(c, c + n * n * n, true) << endl;
  }
}
Problem p00616 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <set>
#include <string>
using namespace std;

typedef pair<int, pair<int, int>> cube;

int main() {
  int n, h, a, b;
  string str;

  while (cin >> n >> h, n || h) {
    set<cube> s;
    cube t;

    for (int i = 0; i < h; i++) {
      cin >> str >> a >> b;
      for (int c = 1; c <= n; c++) {
        if (str == "xy") {
          t = make_pair(a, make_pair(b, c));
        } else if (str == "xz") {
          t = make_pair(a, make_pair(c, b));
        } else if (str == "yz") {
          t = make_pair(c, make_pair(a, b));
        }
        s.insert(t);
      }
    }
    int ans = n * n * n - s.size();
    cout << ans << endl;
  }
}

Error: -11

Fixed submission:

#include <iostream>
#include <string>
using namespace std;

int main() {
  int n, h, a, b;
  string p;

  while (cin >> n >> h, n || h) {
    char f[501][501][501] = {0};

    for (int i = 0; i < h; i++) {
      cin >> p >> a >> b;
      if (p == "xy") {
        int x = a - 1;
        int y = b - 1;
        for (int z = 0; z < n; z++) {
          f[z][y][x] = 1;
        }
      } else if (p == "xz") {
        int x = a - 1;
        int z = b - 1;
        for (int y = 0; y < n; y++) {
          f[z][y][x] = 1;
        }
      } else if (p == "yz") {
        int y = a - 1;
        int z = b - 1;
        for (int x = 0; x < n; x++) {
          f[z][y][x] = 1;
        }
      }
    }
    int ans = 0;
    for (int z = 0; z < n; z++) {
      for (int y = 0; y < n; y++) {
        for (int x = 0; x < n; x++) {
          if (f[z][y][x] == 0)
            ans++;
        }
      }
    }
    cout << ans << endl;
  }
}
Problem p00616 (C++) — buggy submission, verdict: Memory Limit Exceeded

#include <iostream>
#include <set>
#include <string>
using namespace std;

typedef pair<int, pair<int, int>> cube;

int main() {
  int n, h;
  while (cin >> n >> h, n | h) {
    set<cube> cs;
    for (int i = 0; i < h; i++) {
      string p;
      int a, b;
      cin >> p >> a >> b;
      for (int i = 1; i <= n; i++) {
        cube c;
        if (p == "xy") {
          c = make_pair(a, make_pair(b, i));
        } else if (p == "xz") {
          c = make_pair(a, make_pair(i, b));
        } else if (p == "yz") {
          c = make_pair(i, make_pair(a, b));
        }
        cs.insert(c);
      }
    }
    cout << n * n * n - cs.size() << endl;
  }
}

Error: MLE

Fixed submission:

#include <iostream>
#include <string>
using namespace std;

const int N_MAX = 500;
bool cs[N_MAX][N_MAX][N_MAX];

int main() {
  int n, h;
  while (cin >> n >> h, n | h) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        for (int k = 0; k < n; k++) {
          cs[i][j][k] = false;
        }
      }
    }
    int ans = n * n * n;
    for (int i = 0; i < h; i++) {
      string c;
      int a, b;
      cin >> c >> a >> b;
      a--;
      b--;
      if (c == "xy") {
        for (int z = 0; z < n; z++) {
          if (!cs[a][b][z]) {
            cs[a][b][z] = true;
            ans--;
          }
        }
      } else if (c == "xz") {
        for (int y = 0; y < n; y++) {
          if (!cs[a][y][b]) {
            cs[a][y][b] = true;
            ans--;
          }
        }
      } else if (c == "yz") {
        for (int x = 0; x < n; x++) {
          if (!cs[x][a][b]) {
            cs[x][a][b] = true;
            ans--;
          }
        }
      }
    }
    cout << ans << endl;
  }
}
Problem p00616 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cstring>
#include <iostream>
#include <vector>

using namespace std;

const int MAX = 1000;
struct Point {
  int x, y, z;
};
vector<Point> V;

int sum, n, h;

void init() {
  V.clear();
  sum = n * n * n;
}

bool isCross(Point a, Point b) {

  if (a.x == b.x && a.y == b.y && a.z == b.z)
    return false;

  if (a.x != -1 && b.x != -1)
    if (a.x != b.x)
      return false;

  if (a.y != -1 && b.y != -1)
    if (a.y != b.y)
      return false;

  if (a.z != -1 && b.z != -1)
    if (a.z != b.z)
      return false;

  return true;
}

void make(string s, int a, int b) {

  Point p;
  p.x = p.y = p.z = -1;

  if (s == "xy") {
    p.x = a;
    p.y = b;
  } else if (s == "xz") {
    p.x = a;
    p.z = b;
  } else {
    p.y = a;
    p.z = b;
  }
  V.push_back(p);
}

int main() {
  while (cin >> n >> h && n + h) {
    init();

    for (int i = 0; i < h; i++) {
      string s;
      int a, b;
      cin >> s >> a >> b;
      make(s, a, b);
      sum -= n;
    }

    bool flg = false;

    for (int i = 0; i < V.size(); i++) {
      vector<int> HIT;
      for (int j = i + 1; j < V.size(); j++)
        if (isCross(V[i], V[j])) {
          sum++;
          HIT.push_back(j);
        }

      for (int k = 0; k < HIT.size(); k++)
        for (int l = k + 1; l < HIT.size(); l++)
          if (isCross(V[HIT[k]], V[HIT[l]]))
            sum--;
    }
    cout << sum << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cstring>
#include <iostream>
#include <vector>

using namespace std;

typedef pair<int, int> P;
typedef pair<int, P> PP;
const int MAX = 1000;

vector<PP> V;
int sum, n, h;

void init() {
  V.clear();
  V.push_back(PP(MAX, P(MAX, MAX)));
  sum = n * n * n;
}

bool find(PP pp) {
  sort(V.begin(), V.end());
  return binary_search(V.begin(), V.end(), pp);
}

void make(string s, int a, int b) {

  if (s == "xy") {
    for (int z = 1; z <= n; z++)
      if (!find(PP(a, P(b, z)))) {
        V.push_back(PP(a, P(b, z)));
        sum--;
      }
  }

  if (s == "xz") {
    for (int y = 1; y <= n; y++)
      if (!find(PP(a, P(y, b)))) {
        V.push_back(PP(a, P(y, b)));
        sum--;
      }
  }
  if (s == "yz") {
    for (int x = 1; x <= n; x++)
      if (!find(PP(x, P(a, b)))) {
        V.push_back(PP(x, P(a, b)));
        sum--;
      }
  }
}
int main() {
  while (cin >> n >> h && n + h) {
    init();

    for (int i = 0; i < h; i++) {
      string s;
      int a, b;
      cin >> s >> a >> b;
      make(s, a, b);
    }

    cout << sum << endl;
  }
  return 0;
}
Problem p00616 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <set>
#include <string>

using namespace std;

int main() {
  int s, t, u, v;
  string str;

  while (cin >> s >> t && s && t) {
    set<int> st;
    while (t--) {
      cin >> str >> u >> v;
      if (str == "xy") {
        for (int i = 1; i <= s; i++) {
          st.insert((u + s * (v - 1) + s * s * (i - 1)));
        }
      } else if (str == "xz") {
        for (int i = 1; i <= s; i++) {
          st.insert((u + s * (i - 1) + s * s * (v - 1)));
        }
      } else {
        for (int i = 1; i <= s; i++) {
          st.insert((i + s * (u - 1) + s * s * (v - 1)));
        }
      }
    }
    cout << (s * s * s - st.size()) << endl;
  }

  return 0;
}

Error: 0

Fixed submission:

#include <iostream>
#include <string>

using namespace std;

struct P {
  int x;
  int y;
  int z;
};

int main() {
  int n, m, v, q, t;
  P pa[201], pa2[201];
  string str;
  while (cin >> n >> m && n && m) {
    v = n * m;
    q = t = 0;
    for (int i = 0; i < m; i++) {
      cin >> str;
      if (str == "xy") {
        cin >> pa[i].x;
        cin >> pa[i].y;
        pa[i].z = -i;
      } else if (str == "xz") {
        cin >> pa[i].x;
        cin >> pa[i].z;
        pa[i].y = -i;
      } else {
        cin >> pa[i].y;
        cin >> pa[i].z;
        pa[i].x = -i;
      }
    }
    for (int i = 0; i < m; i++) {
      for (int j = i + 1; j < m; j++) {
        if (pa[i].x == pa[j].x || pa[i].y == pa[j].y || pa[i].z == pa[j].z) {
          P s;
          s.x = (pa[i].x > pa[j].x) ? pa[i].x : pa[j].x;
          s.y = (pa[i].y > pa[j].y) ? pa[i].y : pa[j].y;
          s.z = (pa[i].z > pa[j].z) ? pa[i].z : pa[j].z;
          bool f = true;
          for (int k = 0; k < q; k++) {
            if (pa2[k].x == s.x && pa2[k].y == s.y && pa2[k].z == s.z) {
              f = false;
              break;
            }
          }

          if (f || t == i) {
            v--;
            t = i;
            pa2[q++] = s;
          }
        }
      }
    }

    cout << (n * n * n - v) << endl;
  }

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

#include <iostream>
#include <set>
#include <string>
using namespace std;
int check(int a, int b, int c) { return (a * 1000000 + b * 1000 + c); }

int main(void) {
  int n, h;
  while (cin >> n >> h) {
    if (!n)
      break;
    int count = 0;
    set<int> hole;
    while (h--) {
      int a, b;
      string c;
      cin >> c >> a >> b;
      for (int i = 0; i < n; i++) {
        if (c == "xy")
          hole.insert(check(a - 1, b - 1, i));
        else if (c == "xz")
          hole.insert(check(a - 1, i, b - 1));
        else
          hole.insert(check(i, a - 1, b - 1));
      }
    }
    cout << n * n * n - hole.size() << endl;
  }
  return (0);
}

Error: TLE

Fixed submission:

#include <iostream>
#include <string>
using namespace std;
void check(int a, int b, int c, int hole[], int &count) {
  bool f = false;
  int point = a * 1000000 + b * 1000 + c;
  for (int i = 0; i < count; i++) {
    if (hole[i] == point) {
      f = true;
      break;
    }
  }
  if (!f) {
    hole[count++] = point;
  }
}

int main(void) {
  int n, h;
  while (cin >> n >> h) {
    if (!n)
      break;
    int count = 0;
    int hole[100000] = {0};
    while (h--) {
      int a, b;
      string c;
      cin >> c >> a >> b;
      for (int i = 0; i < n; i++) {
        if (c == "xy")
          check(a - 1, b - 1, i, hole, count);
        else if (c == "xz")
          check(a - 1, i, b - 1, hole, count);
        else
          check(i, a - 1, b - 1, hole, count);
      }
    }
    cout << n * n * n - count << endl;
  }
  return (0);
}
Problem p00616 (C++) — buggy submission, verdict: Memory Limit Exceeded

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define all(v) (v).begin(), (v).end()
#define rev(s) (s).rbegin(), (s).rend()
#define MP make_pair
#define X first
#define Y second

using namespace std;

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

const int INF = 100000000;
const double EPS = 1e-10;

int main() {
  while (1) {
    int n, h;
    cin >> n >> h;
    if (!n && !h)
      break;
    set<pair<int, P>> hole; // x, y, z
    rep(i, h) {
      string s;
      cin >> s;
      if (s == "xy") {
        int x, y;
        cin >> x >> y;
        for (int j = 1; j <= n; j++) {
          hole.insert(MP(x, MP(y, j)));
        }
      } else if (s == "xz") {
        int x, z;
        cin >> x >> z;
        for (int j = 1; j <= n; j++) {
          hole.insert(MP(x, MP(j, z)));
        }
      } else if (s == "yz") {
        int y, z;
        cin >> y >> z;
        for (int j = 1; j <= n; j++) {
          hole.insert(MP(j, MP(y, z)));
        }
      }
    }
    int cnt = n * n * n - hole.size();
    cout << cnt << endl;
  }

  return 0;
}

Error: MLE

Fixed submission:

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define all(v) (v).begin(), (v).end()
#define rev(s) (s).rbegin(), (s).rend()
#define MP make_pair
#define X first
#define Y second

using namespace std;

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

const int INF = 100000000;
const double EPS = 1e-10;

int main() {
  while (1) {
    int n, h;
    cin >> n >> h;
    vector<vector<vector<int>>> cube(n,
                                     vector<vector<int>>(n, vector<int>(n, 1)));
    if (!n && !h)
      break;
    rep(i, h) {
      string s;
      cin >> s;
      if (s == "xy") {
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        rep(z, n) { cube[x][y][z] = 0; }
      } else if (s == "xz") {
        int x, z;
        cin >> x >> z;
        x--;
        z--;
        rep(y, n) { cube[x][y][z] = 0; }
      } else if (s == "yz") {
        int y, z;
        cin >> y >> z;
        y--;
        z--;
        rep(x, n) { cube[x][y][z] = 0; }
      }
    }
    int cnt = 0;
    rep(i, n) {
      rep(j, n) {
        rep(k, n) { cnt += cube[i][j][k]; }
      }
    }
    cout << cnt << endl;
  }

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

#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, h;
  while (cin >> n >> h && (n || h)) {
    int ans = n * n * n;
    set<pair<int, pair<int, int>>> ps;
    for (int i = 0; i < h; i++) {
      string str;
      int p[2];
      cin >> str >> p[0] >> p[1];
      for (int j = 1; j <= n; j++) {
        if (str == "xy") {
          ps.insert(make_pair(p[0], make_pair(p[1], j)));
        }
        if (str == "xz") {
          ps.insert(make_pair(p[0], make_pair(j, p[1])));
        }
        if (str == "yz") {
          ps.insert(make_pair(j, make_pair(p[0], p[1])));
        }
      }
    }
    ans -= ps.size();
    cout << ans << "\\n";
  }
  return 0;
}

Error: 0
x 3
y 3


Fixed submission:

#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, h;
  while (cin >> n >> h && (n || h)) {
    int ans = n * (n * n - h);
    map<char, vector<int>> ms;
    ms['x'].resize(n + 1, false);
    ms['y'].resize(n + 1, false);
    ms['z'].resize(n + 1, false);
    for (int i = 0; i < h; i++) {
      string str;
      int p[2];
      cin >> str >> p[0] >> p[1];
      if (ms[str[0]][p[0]]) {
        ans++;
        cerr << str[0] << " " << p[0] << "\\n";
      } else if (ms[str[1]][p[1]]) {
        ans++;
        cerr << str[1] << " " << p[1] << "\\n";
      }
      ms[str[0]][p[0]] = true;
      ms[str[1]][p[1]] = true;
    }
    cout << ans << "\\n";
  }
  return 0;
}