prithivMLmods/Coder-Stat huggingface dataset:
Problem p01102 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
#include <string>
using namespace std;
int main() {
  while (1) {
    string s1;
    cin >> s1;

    if (s1 == ".")
      break;

    string s2;
    cin >> s2;

    if (s1 == s2) {
      cout << "IDENTICAL" << endl;
      continue;
    }

    string t1 = s1;
    string t2 = s2;

    while (1) {
      size_t d1b = t1.find('\"');
      if (d1b == string::npos)
        break;
      t1.replace(d1b, 1, "@");

      size_t d1e = t1.find('\"');
      t1.replace(d1e, 1, "@");

      size_t d2b = t2.find('\"');
      if (d2b == string::npos)
        break;
      t2.replace(d2b, 1, "@");

      size_t d2e = t2.find('\"');
      t1.replace(d2e, 1, "@");

      string u1 = s1;
      u1.replace(d1b + 1, d1e - d1b - 1, "");
      string u2 = s2;
      u2.replace(d2b + 1, d2e - d2b - 1, "");

      if (u1 == u2) {
        t1 = u1;
        t2 = u2;
        break;
      }
    }

    if (t1 == t2) {
      cout << "CLOSE" << endl;
    } else {
      cout << "DIFFERENT" << endl;
    }
  }

  return 0;
}

Fixed submission:
#include <iostream>
#include <string>
using namespace std;
int main() {
  while (1) {
    string s1;
    cin >> s1;

    if (s1 == ".")
      break;

    string s2;
    cin >> s2;

    if (s1 == s2) {
      cout << "IDENTICAL" << endl;
      continue;
    }

    string t1 = s1;
    string t2 = s2;

    while (1) {
      size_t d1b = t1.find('\"');
      if (d1b == string::npos)
        break;
      t1.replace(d1b, 1, "@");

      size_t d1e = t1.find('\"');
      t1.replace(d1e, 1, "@");

      size_t d2b = t2.find('\"');
      if (d2b == string::npos)
        break;
      t2.replace(d2b, 1, "@");

      size_t d2e = t2.find('\"');
      t2.replace(d2e, 1, "@");

      string u1 = s1;
      u1.replace(d1b + 1, d1e - d1b - 1, "");
      string u2 = s2;
      u2.replace(d2b + 1, d2e - d2b - 1, "");

      if (u1 == u2) {
        t1 = u1;
        t2 = u2;
        break;
      }
    }

    if (t1 == t2) {
      cout << "CLOSE" << endl;
    } else {
      cout << "DIFFERENT" << endl;
    }
  }

  return 0;
}
Problem p01102 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for (int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

vector<string> split(const string &s, char c = ' ') {
  vector<string> ret;
  stringstream ss(s);
  string t;
  while (getline(ss, t, c)) {
    ret.push_back(t);
  }
  return ret;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  while (1) {
    string s, t;
    cin >> s;
    if (s == ".")
      break;
    cin >> t;
    if (s == t) {
      cout << "IDENTICAL" << endl;
      continue;
    }
    char c = '"';
    vector<string> ss = split(s, c);
    vector<string> tt = split(t, c);
    int cnt = 0;
    if (ss.size() != tt.size())
      cnt = INF;
    rep(i, 0, ss.size()) {
      if (i % 2 == 0) {
        if (ss[i] != tt[i])
          cnt = INF;
      } else {
        if (ss[i] != tt[i])
          cnt++;
      }
    }
    if (cnt <= 1) {
      cout << "CLOSE" << endl;
    } else {
      cout << "DIFFERENT" << endl;
    }
  }
}


Fixed submission:
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for (int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

vector<string> split(const string &s, char c = ' ') {
  vector<string> ret;
  stringstream ss(s);
  string t;
  while (getline(ss, t, c)) {
    ret.push_back(t);
  }
  return ret;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  while (1) {
    string s, t;
    cin >> s;
    if (s == ".")
      break;
    cin >> t;
    if (s == t) {
      cout << "IDENTICAL" << endl;
      continue;
    }
    char c = '"';
    vector<string> ss = split(s, c);
    vector<string> tt = split(t, c);
    int cnt = 0;
    if (ss.size() != tt.size())
      cnt = INF;
    rep(i, 0, min(ss.size(), tt.size())) {
      if (i % 2 == 0) {
        if (ss[i] != tt[i])
          cnt = INF;
      } else {
        if (ss[i] != tt[i])
          cnt++;
      }
    }
    if (cnt <= 1) {
      cout << "CLOSE" << endl;
    } else {
      cout << "DIFFERENT" << endl;
    }
  }
}
Problem p01104 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
int main() {
  for (int N, M;;) {
    cin >> N >> M;
    if (N == 0 and M == 0) {
      break;
    }
    if (N <= 25) {
      vector<vector<int>> b(N, vector<int>(M));
      for (int i = 0; i < N; i++) {
        for (int j = 0; j < M; j++) {
          char c;
          cin >> c, b[i][j] = c - '0';
        }
      }
      const int MASK = 1 << N;
      int ans = 0;
      for (int mask = 0; mask < MASK; mask++) {
        int cnt = 0;
        vector<int> sum(M, 0);
        for (int i = 0; i < N; i++) {
          if (mask & (1 << i)) {
            cnt++;
            for (int j = 0; j < M; j++) {
              sum[j] ^= b[i][j];
            }
          }
        }
        bool ok = true;
        for (int i = 0; i < M; i++) {
          if (sum[i] == 1) {
            ok = false;
          }
        }
        if (ok) {
          ans = max(ans, cnt);
        }
      }
      cout << ans << endl;
    } else {
      vector<int> b(N, 0);
      for (int i = 0; i < N; i++) {
        for (int j = 0; j < M; j++) {
          char c;
          cin >> c, b[i] |= (c - '0') << j;
        }
      }
      const int MASK = 1 << M;
      vector<int> dp(MASK, -1);
      dp[0] = 0;
      for (int i = 0; i < N; i++) {
        auto tmp = dp;
        for (int j = 0; j < MASK; j++) {
          if (dp[j] == -1) {
            continue;
          }
          tmp[j ^ b[i]] = max(tmp[j ^ b[i]], dp[j] + 1);
        }
        dp = tmp;
      }
      cout << dp[0] << endl;
    }
  }
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  for (int N, M;;) {
    cin >> N >> M;
    if (N == 0 and M == 0) {
      break;
    }
    if (N <= 20) {
      vector<vector<int>> b(N, vector<int>(M));
      for (int i = 0; i < N; i++) {
        for (int j = 0; j < M; j++) {
          char c;
          cin >> c, b[i][j] = c - '0';
        }
      }
      const int MASK = 1 << N;
      int ans = 0;
      for (int mask = 0; mask < MASK; mask++) {
        int cnt = 0;
        vector<int> sum(M, 0);
        for (int i = 0; i < N; i++) {
          if (mask & (1 << i)) {
            cnt++;
            for (int j = 0; j < M; j++) {
              sum[j] ^= b[i][j];
            }
          }
        }
        bool ok = true;
        for (int i = 0; i < M; i++) {
          if (sum[i] == 1) {
            ok = false;
          }
        }
        if (ok) {
          ans = max(ans, cnt);
        }
      }
      cout << ans << endl;
    } else {
      vector<int> b(N, 0);
      for (int i = 0; i < N; i++) {
        for (int j = 0; j < M; j++) {
          char c;
          cin >> c, b[i] |= (c - '0') << j;
        }
      }
      const int MASK = 1 << M;
      vector<int> dp(MASK, -1);
      dp[0] = 0;
      for (int i = 0; i < N; i++) {
        auto tmp = dp;
        for (int j = 0; j < MASK; j++) {
          if (dp[j] == -1) {
            continue;
          }
          tmp[j ^ b[i]] = max(tmp[j ^ b[i]], dp[j] + 1);
        }
        dp = tmp;
      }
      cout << dp[0] << endl;
    }
  }
  return 0;
}
Problem p01104 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using Int = int64_t;
const Int inf = 1LL << 53;

int main() {
  for (;;) {
    Int n, m;
    std::cin >> n >> m;
    if (n == 0 && m == 0) {
      break;
    }
    auto xss = std::vector<std::string>(n);
    for (Int i = 0; i < n; ++i) {
      std::string ss;
      std::cin >> ss;
      xss[i] = ss;
    }
    if (n <= 23) {
      Int res = 0;
      for (Int i = 0; i < (1 << n); ++i) {
        std::string ss(m, '0');
        Int num = 0;
        for (Int k = 0; k < n; ++k) {
          if ((i & (1 << k)) != 0) {
            num += 1;
            for (Int j = 0; j < m; ++j) {
              ss[j] = ss[j] == xss[k][j] ? '0' : '1';
            }
          }
        }
        bool valid = true;
        for (Int j = 0; j < m; ++j) {
          if (ss[j] != '0') {
            valid = false;
          }
        }
        if (valid) {
          res = std::max(res, num);
        }
      }
      std::cout << res << std::endl;
    } else {
      auto ys = std::vector<Int>(n);
      for (Int i = 0; i < n; ++i) {
        Int t = 0;
        for (Int k = 0; k < m; ++k) {
          if (xss[i][k] == '1') {
            t |= 1 << k;
          }
        }
        ys[i] = t;
      }
      std::vector<Int> dp(1 << m, -inf);
      std::vector<Int> dp2(1 << m, -inf);
      dp[0] = 0;
      for (Int i = 0; i < n; ++i) {
        for (Int k = 0; k < 1 << m; ++k) {
          dp2[k] = std::max(dp[k], dp[k ^ ys[i]] + 1);
        }
        std::swap(dp, dp2);
      }
      std::cout << dp[0] << std::endl;
    }
  }
}


Fixed submission:
#include <bits/stdc++.h>
using Int = int64_t;
const Int inf = 1LL << 53;

int main() {
  for (;;) {
    Int n, m;
    std::cin >> n >> m;
    if (n == 0 && m == 0) {
      break;
    }
    auto xss = std::vector<std::string>(n);
    for (Int i = 0; i < n; ++i) {
      std::string ss;
      std::cin >> ss;
      xss[i] = ss;
    }
    if (n <= 20) {
      Int res = 0;
      for (Int i = 0; i < (1 << n); ++i) {
        std::string ss(m, '0');
        Int num = 0;
        for (Int k = 0; k < n; ++k) {
          if ((i & (1 << k)) != 0) {
            num += 1;
            for (Int j = 0; j < m; ++j) {
              ss[j] = ss[j] == xss[k][j] ? '0' : '1';
            }
          }
        }
        bool valid = true;
        for (Int j = 0; j < m; ++j) {
          if (ss[j] != '0') {
            valid = false;
          }
        }
        if (valid) {
          res = std::max(res, num);
        }
      }
      std::cout << res << std::endl;
    } else {
      auto ys = std::vector<Int>(n);
      for (Int i = 0; i < n; ++i) {
        Int t = 0;
        for (Int k = 0; k < m; ++k) {
          if (xss[i][k] == '1') {
            t |= 1 << k;
          }
        }
        ys[i] = t;
      }
      std::vector<Int> dp(1 << m, -inf);
      std::vector<Int> dp2(1 << m, -inf);
      dp[0] = 0;
      for (Int i = 0; i < n; ++i) {
        for (Int k = 0; k < 1 << m; ++k) {
          dp2[k] = std::max(dp[k], dp[k ^ ys[i]] + 1);
        }
        std::swap(dp, dp2);
      }
      std::cout << dp[0] << std::endl;
    }
  }
}
Problem p01110 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
#include <vector>

using namespace std;

int main() {
  while (true) {
    int n, m, t, p;
    cin >> n >> m >> t >> p;
    if (n == 0)
      break;

    vector<vector<int>> card(300, vector<int>(300, 0));
    for (int x = 0; x < n; ++x) {
      for (int y = 0; y < m; ++y) {
        card[x][y] = 1;
      }
    }

    int l = 0, u = 0;
    for (int q = 0; q < t; ++q) {
      int d, c;
      cin >> d >> c;

      if (d == 1) {
        for (int x = 0; x < c; ++x) {
          for (int y = 0; y < m; ++y) {
            card[l + c * 2 - x - 1][u + y] += card[l + x][u + y];
            card[l + x][u + y] = 0;
          }
        }
        l += c;
        n = max(c, n - c);
      } else {
        for (int x = 0; x < n; ++x) {
          for (int y = 0; y < c; ++y) {
            card[l + x][u + c * 2 - 1 - y] += card[l + x][u + y];
            card[l + x][u + y] = 0;
          }
        }
        u += c;
        m = max(c, m - c);
      }
    }

    for (int q = 0; q < p; ++q) {
      int x, y;
      cin >> x >> y;
      cout << card[l + x][u + y] << endl;
    }
  }
  return 0;
}


Fixed submission:
#include <iostream>
#include <vector>

using namespace std;

int main() {
  while (true) {
    int n, m, t, p;
    cin >> n >> m >> t >> p;
    if (n == 0)
      break;

    vector<vector<int>> card(500, vector<int>(500, 0));
    for (int x = 0; x < n; ++x) {
      for (int y = 0; y < m; ++y) {
        card[x][y] = 1;
      }
    }

    int l = 0, u = 0;
    for (int q = 0; q < t; ++q) {
      int d, c;
      cin >> d >> c;

      if (d == 1) {
        for (int x = 0; x < c; ++x) {
          for (int y = 0; y < m; ++y) {
            card[l + c * 2 - x - 1][u + y] += card[l + x][u + y];
            card[l + x][u + y] = 0;
          }
        }
        l += c;
        n = max(c, n - c);
      } else {
        for (int x = 0; x < n; ++x) {
          for (int y = 0; y < c; ++y) {
            card[l + x][u + c * 2 - 1 - y] += card[l + x][u + y];
            card[l + x][u + y] = 0;
          }
        }
        u += c;
        m = max(c, m - c);
      }
    }

    for (int q = 0; q < p; ++q) {
      int x, y;
      cin >> x >> y;
      cout << card[l + x][u + y] << endl;
    }
  }
  return 0;
}
Problem p01110 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int n, m, t, p;
  while (cin >> n >> m >> t >> p, n) {
    vector<pair<int, int>> d(t), x(p);
    for (auto &e : d)
      cin >> e.first >> e.second;
    for (auto &e : x)
      cin >> e.first >> e.second;

    vector<vector<int>> a(2 * m, vector<int>(2 * n));
    for (int i = 0; i < m; i++) {
      for (int j = 0; j < n; j++) {
        a[i][j] = 1;
      }
    }
    int x0 = 0, y0 = 0;
    for (auto e : d) {
      if (e.first == 1) {
        x0 += e.second;
        for (int i = 0; a[y0 + i][x0]; i++) {
          for (int j = 0;
               x0 - j - 1 >= 0 && (a[y0 + i][x0 + j] || a[y0 + i][x0 - j - 1]);
               j++) {
            a[y0 + i][x0 + j] += a[y0 + i][x0 - j - 1];
            a[y0 + i][x0 - j - 1] = 0;
          }
        }
      } else {
        y0 += e.second;
        for (int j = 0; a[y0][x0 + j]; j++) {
          for (int i = 0;
               y0 - i - 1 >= 0 && (a[y0 + i][x0 + j] || a[y0 - i - 1][x0 + j]);
               i++) {
            a[y0 + i][x0 + j] += a[y0 - i - 1][x0 + j];
            a[y0 - i - 1][x0 + j] = 0;
          }
        }
      }
    }

    for (auto e : x) {
      cout << a[y0 + e.second][x0 + e.first] << endl;
    }
  }
}


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

int main() {
  int n, m, t, p;
  while (cin >> n >> m >> t >> p, n) {
    vector<pair<int, int>> d(t), x(p);
    for (auto &e : d)
      cin >> e.first >> e.second;
    for (auto &e : x)
      cin >> e.first >> e.second;

    vector<vector<int>> a((t + 1) * m, vector<int>((t + 1) * n));
    for (int i = 0; i < m; i++) {
      for (int j = 0; j < n; j++) {
        a[i][j] = 1;
      }
    }
    int x0 = 0, y0 = 0;
    for (auto e : d) {
      if (e.first == 1) {
        x0 += e.second;
        for (int i = 0; a[y0 + i][x0]; i++) {
          for (int j = 0;
               x0 - j - 1 >= 0 && (a[y0 + i][x0 + j] || a[y0 + i][x0 - j - 1]);
               j++) {
            a[y0 + i][x0 + j] += a[y0 + i][x0 - j - 1];
            a[y0 + i][x0 - j - 1] = 0;
          }
        }
      } else {
        y0 += e.second;
        for (int j = 0; a[y0][x0 + j]; j++) {
          for (int i = 0;
               y0 - i - 1 >= 0 && (a[y0 + i][x0 + j] || a[y0 - i - 1][x0 + j]);
               i++) {
            a[y0 + i][x0 + j] += a[y0 - i - 1][x0 + j];
            a[y0 - i - 1][x0 + j] = 0;
          }
        }
      }
    }

    for (auto e : x) {
      cout << a[y0 + e.second][x0 + e.first] << endl;
    }
  }
}
Problem p01111 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define REP(i, a, n) for (ll i = ((ll)a); i < ((ll)n); i++)
typedef long long ll;
using namespace std;

#define sum(l, r) (((r) * ((r)-1) - (l) * ((l)-1)) / 2)

int main(void) {
  ll B;
  while (cin >> B, B) {
    for (ll w = 100000; w >= 0; w--) {
      ll l = 0, h = B + 1;
      while (h - l > 1) {
        ll m = (l + h) / 2;
        if (sum(m, m + w) >= B)
          h = m;
        else
          l = m;
      }
      if (sum(h, h + w) == B) {
        cout << h << " " << w << endl;
        break;
      }
    }
  }
}


Fixed submission:
#include <bits/stdc++.h>
#define REP(i, a, n) for (ll i = ((ll)a); i < ((ll)n); i++)
typedef long long ll;
using namespace std;

#define sum(l, r) (((r) * ((r)-1) - (l) * ((l)-1)) / 2)

int main(void) {
  ll B;
  while (cin >> B, B) {
    for (ll w = 65000; w >= 0; w--) {
      ll l = 0, h = B + 1;
      while (h - l > 1) {
        ll m = (l + h) / 2;
        if (sum(m, m + w) >= B)
          h = m;
        else
          l = m;
      }
      if (sum(h, h + w) == B) {
        cout << h << " " << w << endl;
        break;
      }
    }
  }
}
Problem p01125 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  while (cin >> n, n) {
    bool dia[20][20] = {};
    for (int i = 0, x, y; i < n; i++) {
      cin >> x >> y;
      dia[y][x] = 1;
    }
    int mo;
    cin >> mo;
    string di = "NESW";
    int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
    for (int i = 0, num, x = 10, y = 10; i < mo; i++) {
      char direction;
      cin >> direction >> num;
      for (int j = 0; j < 4; j++) {
        if (direction == di[j]) {
          for (int k = 0; k < num; k++) {
            x += dx[j];
            y += dy[j];
            if (dia[y][x] == true) {
              dia[y][x] = false;
              n--;
            }
          }
          break;
        }
      }
    }
    if (n == 0)
      cout << "Yes\n";
    else
      cout << "No\n";
  }
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  while (cin >> n, n) {
    bool dia[41][41] = {};
    for (int i = 0, x, y; i < n; i++) {
      cin >> x >> y;
      dia[y][x] = 1;
    }
    int mo;
    cin >> mo;
    string di = "NESW";
    int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
    for (int i = 0, num, x = 10, y = 10; i < mo; i++) {
      char direction;
      cin >> direction >> num;
      for (int j = 0; j < 4; j++) {
        if (direction == di[j]) {
          for (int k = 0; k < num; k++) {
            x += dx[j];
            y += dy[j];
            if (dia[y][x] == true) {
              dia[y][x] = false;
              n--;
            }
          }
          break;
        }
      }
    }
    if (n == 0)
      cout << "Yes\n";
    else
      cout << "No\n";
  }
}
Problem p01125 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
#include <map>

using namespace std;

#define N 20

int main(int argc, char const *argv[]) {
  int f[N][N];
  int n, xj, yj;
  int m, d;
  char c;

  int xr, yr;
  int cnt;

  map<char, pair<int, int>> mp;
  mp['N'] = make_pair(0, 1);
  mp['E'] = make_pair(1, 0);
  mp['S'] = make_pair(0, -1);
  mp['W'] = make_pair(-1, 0);

  while (1) {
    cin >> n;
    if (n == 0)
      break;

    for (int i1 = 0; i1 < N; i1++) {
      for (int i2 = 0; i2 < N; i2++) {
        f[i1][i2] = 0;
      }
    }
    xr = 10;
    yr = 10;
    cnt = 0;

    for (int i1 = 0; i1 < n; i1++) {
      cin >> xj >> yj;
      f[yj][xj] = 1;
    }

    if (f[yr][xr] == 1) {
      cnt++;
      f[yr][xr] = 0;
    }

    cin >> m;
    for (int i1 = 0; i1 < m; i1++) {
      cin >> c >> d;

      for (int i2 = 0; i2 < d; i2++) {
        xr = mp[c].first + xr;
        yr = mp[c].second + yr;
        if (f[yr][xr] == 1) {
          cnt++;
          f[yr][xr] = 0;
        }
      }
    }

    if (cnt == n)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
  return 0;
}

Fixed submission:
#include <iostream>
#include <map>

using namespace std;

#define N 21

int main(int argc, char const *argv[]) {
  int f[N][N];
  int n, xj, yj;
  int m, d;
  char c;

  int xr, yr;
  int cnt;

  map<char, pair<int, int>> mp;
  mp['N'] = make_pair(0, 1);
  mp['E'] = make_pair(1, 0);
  mp['S'] = make_pair(0, -1);
  mp['W'] = make_pair(-1, 0);

  while (1) {
    cin >> n;
    if (n == 0)
      break;

    for (int i1 = 0; i1 < N; i1++) {
      for (int i2 = 0; i2 < N; i2++) {
        f[i1][i2] = 0;
      }
    }
    xr = 10;
    yr = 10;
    cnt = 0;

    for (int i1 = 0; i1 < n; i1++) {
      cin >> xj >> yj;
      f[yj][xj] = 1;
    }

    if (f[yr][xr] == 1) {
      cnt++;
      f[yr][xr] = 0;
    }

    cin >> m;
    for (int i1 = 0; i1 < m; i1++) {
      cin >> c >> d;

      for (int i2 = 0; i2 < d; i2++) {
        xr = mp[c].first + xr;
        yr = mp[c].second + yr;
        if (f[yr][xr] == 1) {
          cnt++;
          f[yr][xr] = 0;
        }
      }
    }

    if (cnt == n)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
  return 0;
}
Problem p01125 (C++)

Buggy submission (status: Runtime Error):
/*
        2000:Misterious Gems
*/
#include <iostream>

using namespace std;

int main(void) {
  while (1) {
    int Map[20][20] = {0};
    int cGems = 0;
    int point[2] = {10, 10};
    int cCount;

    cin >> cGems;
    if (cGems == 0) {
      break;
    }

    for (int i = 0; i < cGems; i++) {
      int a, b;
      cin >> a >> b;

      Map[a][20 - b] = 1;
    }

    cin >> cCount;
    for (int i = 0; i < cCount; i++) {
      char dir;
      int num;

      cin >> dir >> num;

      if (dir == 'N') {
        for (int j = 0; j < num; j++) {
          point[1]--;
          if (Map[point[0]][point[1]] == 1) {
            cGems--;
            Map[point[0]][point[1]] = 0;
          }
        }
      } else if (dir == 'S') {
        for (int j = 0; j < num; j++) {
          point[1]++;
          if (Map[point[0]][point[1]] == 1) {
            cGems--;
            Map[point[0]][point[1]] = 0;
          }
        }
      } else if (dir == 'E') {
        for (int j = 0; j < num; j++) {
          point[0]++;
          if (Map[point[0]][point[1]] == 1) {
            cGems--;
            Map[point[0]][point[1]] = 0;
          }
        }
      } else if (dir == 'W') {
        for (int j = 0; j < num; j++) {
          point[0]--;
          if (Map[point[0]][point[1]] == 1) {
            cGems--;
            Map[point[0]][point[1]] = 0;
          }
        }
      }
    }
    if (cGems == 0) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }

  return 0;
}

Fixed submission:
/*
        2000:Misterious Gems
*/
#include <iostream>

using namespace std;

int main(void) {
  while (1) {
    int Map[21][21] = {0};
    int cGems = 0;
    int point[2] = {10, 10};
    int cCount;

    cin >> cGems;
    if (cGems == 0) {
      break;
    }

    for (int i = 0; i < cGems; i++) {
      int a, b;
      cin >> a >> b;

      Map[a][20 - b] = 1;
    }

    cin >> cCount;
    for (int i = 0; i < cCount; i++) {
      char dir;
      int num;

      cin >> dir >> num;

      if (dir == 'N') {
        for (int j = 0; j < num; j++) {
          point[1]--;
          if (Map[point[0]][point[1]] == 1) {
            cGems--;
            Map[point[0]][point[1]] = 0;
          }
        }
      } else if (dir == 'S') {
        for (int j = 0; j < num; j++) {
          point[1]++;
          if (Map[point[0]][point[1]] == 1) {
            cGems--;
            Map[point[0]][point[1]] = 0;
          }
        }
      } else if (dir == 'E') {
        for (int j = 0; j < num; j++) {
          point[0]++;
          if (Map[point[0]][point[1]] == 1) {
            cGems--;
            Map[point[0]][point[1]] = 0;
          }
        }
      } else if (dir == 'W') {
        for (int j = 0; j < num; j++) {
          point[0]--;
          if (Map[point[0]][point[1]] == 1) {
            cGems--;
            Map[point[0]][point[1]] = 0;
          }
        }
      }
    }
    if (cGems == 0) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }

  return 0;
}
Problem p01125 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cstdio>
using namespace std;

int n;
int m;
int dx[256];
int dy[256];
int xs[256];
int ys[256];
bool field[100][100];

int main() {
  dx['N'] = 0;
  dy['N'] = 1;
  dx['S'] = 0;
  dy['S'] = -1;
  dx['E'] = 1;
  dy['E'] = 0;
  dx['W'] = -1;
  dy['W'] = 0;

  while (1) {
    scanf("%d", &n);
    if (n == 0)
      return 0;

    fill(field[0], field[30], false);

    for (int i = 0; i < n; i++) {
      scanf("%d%d", &xs[i], &ys[i]);
      field[ys[i]][xs[i]] = true;
    }

    scanf("%d", &m);

    int x = 10;
    int y = 10;
    int cnt = 0;
    for (int i = 0; i < m; i++) {
      char d;
      int l;

      scanf(" %c %d", &d, &l);
      while (l--) {
        x += dx[d] * l;
        y += dy[d] * l;
        if (field[y][x]) {
          field[y][x] = false;
          cnt++;
        }
      }
    }

    if (cnt == n) {
      puts("Yes");
    } else {
      puts("No");
    }
  }
}

Fixed submission:
#include <algorithm>
#include <cstdio>
using namespace std;

int n;
int m;
int dx[256];
int dy[256];
int xs[256];
int ys[256];
bool field[100][100];

int main() {
  dx['N'] = 0;
  dy['N'] = 1;
  dx['S'] = 0;
  dy['S'] = -1;
  dx['E'] = 1;
  dy['E'] = 0;
  dx['W'] = -1;
  dy['W'] = 0;

  while (1) {
    scanf("%d", &n);
    if (n == 0)
      return 0;

    fill(field[0], field[30], false);

    for (int i = 0; i < n; i++) {
      scanf("%d%d", &xs[i], &ys[i]);
      field[ys[i]][xs[i]] = true;
    }

    scanf("%d", &m);

    int x = 10;
    int y = 10;
    int cnt = 0;
    for (int i = 0; i < m; i++) {
      char d;
      int l;

      scanf(" %c %d", &d, &l);
      while (l--) {
        x += dx[d];
        y += dy[d];
        if (field[y][x]) {
          field[y][x] = false;
          cnt++;
        }
      }
    }

    if (cnt == n) {
      puts("Yes");
    } else {
      puts("No");
    }
  }
}
Problem p01125 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
#include <stdio.h>
using namespace std;
struct JWE {
  bool f;
  int x;
  int y;
};

int main() {
  bool ma[22][22] = {};
  JWE JW[21];
  int n1, n2, x1, y1, k, x = 10, y = 10;
  char ch;

  for (int i = 0; i < 22; i++)
    for (int j = 0; j < 22; j++)
      ma[i][j] = false;

  while (scanf("%d", &n1) != EOF) {
    if (n1 == 0)
      break;
    for (int i = 0; i < n1; i++) {
      cin >> x1 >> y1;
      JW[i].x = x1;
      JW[i].y = y1;
    }

    scanf("%d", &n2);
    for (int ii = 0; ii < n2; ii++) {
      cin >> ch >> k;

      if (ch == 'N') {
        for (int j = y; j <= y + k; j++)
          ma[x][j] = true;
        y = y + k;
      } else if (ch == 'S') {
        for (int j = y; j >= y - k; j--)
          ma[x][j] = true;
        y = y - k;
      } else if (ch == 'E') {
        for (int j = x; j <= x + k; j++)
          ma[j][y] = true;
        x = x + k;
      } else if (ch == 'W') {
        for (int j = x; j >= x - k; j--)
          ma[j][y] = true;
        x = x - k;
      }
    }

    int sum = 0;
    for (int i = 0; i < n1; i++) {
      if (ma[JW[i].x][JW[i].y] == true)
        sum++;
    }
    if (n1 == sum)
      printf("Yes\n");
    else
      printf("No\n");

    for (int i = 0; i < 22; i++)
      for (int j = 0; j < 22; j++)
        ma[i][j] = false;

    /*
    for(int i=0;i<21;i++){
    for(int j=0;j<21;j++)
    {cout<<" ";
    if(ma[j][i]==false)cout<<"*";
    else cout<<"1";}
    cout<<endl;
    }
    */
  }
  return 0;
}

Fixed submission:
#include <iostream>
#include <stdio.h>
using namespace std;
struct JWE {
  bool f;
  int x;
  int y;
};

int main() {
  bool ma[22][22] = {};
  JWE JW[21];
  int n1, n2, x1, y1, k, x = 10, y = 10;
  char ch;

  for (int i = 0; i < 22; i++)
    for (int j = 0; j < 22; j++)
      ma[i][j] = false;

  while (scanf("%d", &n1) != EOF) {
    if (n1 == 0)
      break;
    for (int i = 0; i < n1; i++) {
      cin >> x1 >> y1;
      JW[i].x = x1;
      JW[i].y = y1;
    }
    x = 10, y = 10;
    scanf("%d", &n2);
    for (int ii = 0; ii < n2; ii++) {
      cin >> ch >> k;

      if (ch == 'N') {
        for (int j = y; j <= y + k; j++)
          ma[x][j] = true;
        y = y + k;
      } else if (ch == 'S') {
        for (int j = y; j >= y - k; j--)
          ma[x][j] = true;
        y = y - k;
      } else if (ch == 'E') {
        for (int j = x; j <= x + k; j++)
          ma[j][y] = true;
        x = x + k;
      } else if (ch == 'W') {
        for (int j = x; j >= x - k; j--)
          ma[j][y] = true;
        x = x - k;
      }
    }

    int sum = 0;
    for (int i = 0; i < n1; i++) {
      if (ma[JW[i].x][JW[i].y] == true)
        sum++;
    }
    if (n1 == sum)
      printf("Yes\n");
    else
      printf("No\n");

    for (int i = 0; i < 22; i++)
      for (int j = 0; j < 22; j++)
        ma[i][j] = false;

    /*
    for(int i=0;i<21;i++){
    for(int j=0;j<21;j++)
    {cout<<" ";
    if(ma[j][i]==false)cout<<"*";
    else cout<<"1";}
    cout<<endl;
    }
    */
  }
  return 0;
}
Problem p01125 (C++)

Buggy submission (status: Runtime Error):
#include "bits/stdc++.h"

using namespace std;

typedef pair<int, int> P;

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

  int n;
  while (cin >> n, n) {
    vector<P> gems;
    for (int i = 0; i < n; i++) {
      int x, y;
      cin >> x >> y;
      gems.push_back(P(x, y));
    }
    int rx = 10, ry = 10;
    int m;
    cin >> m;
    vector<vector<int>> visited(20, vector<int>(20, 0));
    visited[rx][ry] = 1;
    for (int i = 0; i < m; i++) {
      string s;
      cin >> s;
      int l;
      cin >> l;
      if (s == "N") {
        for (int i = 0; i < l; i++) {
          ry++;
          visited[rx][ry] = 1;
        }
      } else if (s == "E") {
        for (int i = 0; i < l; i++) {
          rx++;
          visited[rx][ry] = 1;
        }
      } else if (s == "S") {
        for (int i = 0; i < l; i++) {
          ry--;
          visited[rx][ry] = 1;
        }
      } else {
        for (int i = 0; i < l; i++) {
          rx--;
          visited[rx][ry] = 1;
        }
      }
    }
    bool flag = true;
    for (int i = 0; i < n; i++) {
      int x = gems[i].first, y = gems[i].second;
      if (!visited[x][y])
        flag = false;
    }
    if (flag)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
}

Fixed submission:
#include "bits/stdc++.h"

using namespace std;

typedef pair<int, int> P;

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

  int n;
  while (cin >> n, n) {
    vector<P> gems;
    for (int i = 0; i < n; i++) {
      int x, y;
      cin >> x >> y;
      gems.push_back(P(x, y));
    }
    int rx = 10, ry = 10;
    int m;
    cin >> m;
    vector<vector<int>> visited(30, vector<int>(30, 0));
    visited[rx][ry] = 1;
    for (int i = 0; i < m; i++) {
      string s;
      cin >> s;
      int l;
      cin >> l;
      if (s == "N") {
        for (int i = 0; i < l; i++) {
          ry++;
          visited[rx][ry] = 1;
        }
      } else if (s == "E") {
        for (int i = 0; i < l; i++) {
          rx++;
          visited[rx][ry] = 1;
        }
      } else if (s == "S") {
        for (int i = 0; i < l; i++) {
          ry--;
          visited[rx][ry] = 1;
        }
      } else {
        for (int i = 0; i < l; i++) {
          rx--;
          visited[rx][ry] = 1;
        }
      }
    }
    bool flag = true;
    for (int i = 0; i < n; i++) {
      int x = gems[i].first, y = gems[i].second;
      if (!visited[x][y])
        flag = false;
    }
    if (flag)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
}
Problem p01125 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

#define int long long

signed main() {
  int n;
  while (cin >> n, n) {
    bool used[21][21] = {{0}};
    for (int i = 0; i < n; i++) {
      int x, y;
      cin >> x >> y;
      used[y][x] = 1;
    }

    int m;
    cin >> m;
    int nx = 10, ny = 10;
    used[ny][nx] = 0;
    for (int i = 0; i < m; i++) {
      char c;
      int d;
      cin >> c >> d;
      if (c == 'N') {
        for (int i = 0; i < d; i++) {
          used[++ny][nx] = 0;
        }
      }
      if (c == 'E') {
        for (int i = 0; i < d; i++) {
          used[ny][++nx] = 0;
        }
      }
      if (c == 'S') {
        for (int i = 0; i < d; i++) {
          used[--ny][nx] = 0;
        }
      }
      if (c == 'W') {
        for (int i = 0; i < d; i++) {
          used[++ny][--nx] = 0;
        }
      }
    }
    int cnt = 0;
    for (int i = 0; i < 21; i++) {
      for (int j = 0; j < 21; j++)
        cnt += used[i][j];
    }

    if (cnt)
      cout << "No" << endl;
    else
      cout << "Yes" << endl;
  }
}


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

#define int long long

signed main() {
  int n;
  while (cin >> n, n) {
    bool used[21][21] = {{0}};
    for (int i = 0; i < n; i++) {
      int x, y;
      cin >> x >> y;
      used[y][x] = 1;
    }

    int m;
    cin >> m;
    int nx = 10, ny = 10;
    used[ny][nx] = 0;
    for (int i = 0; i < m; i++) {
      char c;
      int d;
      cin >> c >> d;
      if (c == 'N') {
        for (int i = 0; i < d; i++) {
          used[++ny][nx] = 0;
        }
      }
      if (c == 'E') {
        for (int i = 0; i < d; i++) {
          used[ny][++nx] = 0;
        }
      }
      if (c == 'S') {
        for (int i = 0; i < d; i++) {
          used[--ny][nx] = 0;
        }
      }
      if (c == 'W') {
        for (int i = 0; i < d; i++) {
          used[ny][--nx] = 0;
        }
      }
    }
    int cnt = 0;
    for (int i = 0; i < 21; i++) {
      for (int j = 0; j < 21; j++)
        cnt += used[i][j];
    }

    if (cnt)
      cout << "No" << endl;
    else
      cout << "Yes" << endl;
  }
}
Problem p01125 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cctype>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

#define REP(i, n) for (int i = 0; i < n; ++i)
#define RREP(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define RFOR(i, m, n) for (int i = m - 1; i >= n; --i)
#define ALL(v) v.begin(), v.end()
#define PB(a) push_back(a)
#define INF 1000000001
#define MOD 1000000007

using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  while (1) {
    int cx = 10, cy = 10;
    int v[20][20];
    REP(i, 20) {
      REP(j, 20) { v[i][j] = 0; }
    }
    int n, m, cnt = 0;
    cin >> n;
    if (!n)
      break;
    REP(i, n) {
      int x, y;
      cin >> x >> y;
      v[x][y] = 1;
    }
    cin >> m;
    REP(i, m) {
      char d;
      int L;
      cin >> d >> L;
      int dx, dy;
      if (d == 'N') {
        dx = 0;
        dy = 1;
      } else if (d == 'E') {
        dx = 1;
        dy = 0;
      } else if (d == 'W') {
        dx = -1;
        dy = 0;
      } else {
        dx = 0;
        dy = -1;
      }
      FOR(j, 1, L + 1) {
        if (v[cx + j * dx][cy + j * dy] == 1) {
          cnt++;
          v[cx + j * dx][cy + j * dy] = 0;
        }
      }
      cx += L * dx;
      cy += L * dy;
    }
    if (cnt == n)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
  return 0;
}

Fixed submission:
#include <algorithm>
#include <cctype>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

#define REP(i, n) for (int i = 0; i < n; ++i)
#define RREP(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define RFOR(i, m, n) for (int i = m - 1; i >= n; --i)
#define ALL(v) v.begin(), v.end()
#define PB(a) push_back(a)
#define INF 1000000001
#define MOD 1000000007

using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  while (1) {
    int cx = 10, cy = 10;
    int v[21][21];
    REP(i, 21) {
      REP(j, 21) { v[i][j] = 0; }
    }
    int n, m, cnt = 0;
    cin >> n;
    if (!n)
      break;
    REP(i, n) {
      int x, y;
      cin >> x >> y;
      v[x][y] = 1;
    }
    cin >> m;
    REP(i, m) {
      char d;
      int L;
      cin >> d >> L;
      int dx, dy;
      if (d == 'N') {
        dx = 0;
        dy = 1;
      } else if (d == 'E') {
        dx = 1;
        dy = 0;
      } else if (d == 'W') {
        dx = -1;
        dy = 0;
      } else {
        dx = 0;
        dy = -1;
      }
      FOR(j, 1, L + 1) {
        if (v[cx + j * dx][cy + j * dy] == 1) {
          cnt++;
          v[cx + j * dx][cy + j * dy] = 0;
        }
      }
      cx += L * dx;
      cy += L * dy;
    }
    if (cnt == n)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
  return 0;
}
Problem p01125 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define int long long // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define rrep2(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define all(a) (a).begin(), (a).end()

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

int dy[4] = {1, 0, -1, 0};
int dx[4] = {0, 1, 0, -1};

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

  int n;
  map<string, int> mp;
  mp["N"] = 0;
  mp["E"] = 1;
  mp["W"] = 2;
  mp["S"] = 3;
  while (cin >> n, n) {
    vector<vector<bool>> exist(21, vector<bool>(21, false));
    rep(i, n) {
      int x, y;
      cin >> x >> y;
      exist[x][y] = true;
    }
    int m;
    cin >> m;
    int x = 10, y = 10;
    int num_done = 0;
    rep(i, m) {
      string c;
      int step;
      cin >> c >> step;
      int k = mp[c];
      rep(j, step) {
        x += dx[k], y += dy[k];
        if (exist[x][y]) {
          exist[x][y] = false;
          num_done++;
        }
      }
    }
    cout << (num_done == n ? "Yes" : "No") << endl;
  }
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define int long long // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define rrep2(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define all(a) (a).begin(), (a).end()

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

int dy[4] = {1, 0, 0, -1};
int dx[4] = {0, 1, -1, 0};

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

  int n;
  map<string, int> mp;
  mp["N"] = 0;
  mp["E"] = 1;
  mp["W"] = 2;
  mp["S"] = 3;
  while (cin >> n, n) {
    vector<vector<bool>> exist(21, vector<bool>(21, false));
    rep(i, n) {
      int x, y;
      cin >> x >> y;
      exist[x][y] = true;
    }
    int m;
    cin >> m;
    int x = 10, y = 10;
    int num_done = 0;
    rep(i, m) {
      string c;
      int step;
      cin >> c >> step;
      int k = mp[c];
      rep(j, step) {
        x += dx[k], y += dy[k];
        if (exist[x][y]) {
          exist[x][y] = false;
          num_done++;
        }
      }
    }
    cout << (num_done == n ? "Yes" : "No") << endl;
  }
}
Problem p01125 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <vector>
#define range(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, b) range(i, 0, b)
#define debug(x) cout << "debug" << x << endl;
using namespace std;

int main() {
  int stone;
  while (cin >> stone, stone) {
    int map[20][20] = {0};
    int x, y;
    x = y = 10;
    rep(i, stone) {
      int a, b;
      cin >> a >> b;
      map[a][b] = 1;
    }
    int order;
    cin >> order;
    rep(i, order) {
      int distance;
      char direction;
      cin >> direction >> distance;
      rep(j, distance) {
        if (direction == 'N') {
          y++;
        } else if (direction == 'E') {
          x++;
        } else if (direction == 'S') {
          y--;
        } else {
          x--;
        }
        stone -= map[x][y];
        map[x][y] = 0;
      }
    }
    if (!stone)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
}

Fixed submission:
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <vector>
#define range(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, b) range(i, 0, b)
#define debug(x) cout << "debug" << x << endl;
using namespace std;

int main() {
  int stone;
  while (cin >> stone, stone) {
    int map[24][24] = {0};
    int x, y;
    x = y = 10;
    rep(i, stone) {
      int a, b;
      cin >> a >> b;
      map[a][b] = 1;
    }
    int order;
    cin >> order;
    rep(i, order) {
      int distance;
      char direction;
      cin >> direction >> distance;
      rep(j, distance) {
        if (direction == 'N') {
          y++;
        } else if (direction == 'E') {
          x++;
        } else if (direction == 'S') {
          y--;
        } else {
          x--;
        }
        stone -= map[x][y];
        map[x][y] = 0;
      }
    }
    if (!stone)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
}
Problem p01125 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int n;
  while (cin >> n, n) {
    vector<vector<int>> g(20, vector<int>(20));
    for (int i = 0; i < n; i++) {
      int x, y;
      cin >> x >> y;
      g[x][y] += 1;
    }

    int r;
    cin >> r;
    int x = 10;
    int y = 10;
    int sum = 0;
    while (r--) {
      char d;
      int c;
      cin >> d >> c;
      int dx = 0;
      int dy = 0;

      if (d == 'N')
        dy++;
      if (d == 'S')
        dy--;
      if (d == 'E')
        dx++;
      if (d == 'W')
        dx--;

      for (int i = 0; i < c; i++) {
        x += dx;
        y += dy;

        if (g[x][y] > 0) {
          sum += g[x][y];
          g[x][y] = 0;
        }
      }
    }

    if (n == sum)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }

  return 0;
}


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

int main() {
  int n;
  while (cin >> n, n) {
    vector<vector<int>> g(21, vector<int>(21));
    for (int i = 0; i < n; i++) {
      int x, y;
      cin >> x >> y;
      g[x][y] += 1;
    }

    int r;
    cin >> r;
    int x = 10;
    int y = 10;
    int sum = 0;
    while (r--) {
      char d;
      int c;
      cin >> d >> c;
      int dx = 0;
      int dy = 0;

      if (d == 'N')
        dy++;
      if (d == 'S')
        dy--;
      if (d == 'E')
        dx++;
      if (d == 'W')
        dx--;

      for (int i = 0; i < c; i++) {
        x += dx;
        y += dy;

        if (g[x][y] > 0) {
          sum += g[x][y];
          g[x][y] = 0;
        }
      }
    }

    if (n == sum)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }

  return 0;
}
Problem p01125 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
using namespace std;
int main() {
  int n;
  while (cin >> n) {
    if (n == 0)
      break;
    int m, count = n, p[20][20];
    for (int i = 0; i < 20; ++i)
      for (int j = 0; j < 20; ++j)
        p[i][j] = 0;
    for (int i = 0, x, y; i < n; ++i) {
      cin >> x >> y;
      p[x][y] = 1;
    }
    cin >> m;
    for (int i = 0, d, cx = 10, cy = 10; i < m; ++i) {
      string s;
      cin >> s;
      cin >> d;
      if (s == "N") {
        for (int j = 0; j < d; ++j) {
          ++cy;
          if (p[cx][cy] == 1) {
            count--;
            p[cx][cy] = 0;
          }
        }
      } else if (s == "E") {
        for (int j = 0; j < d; ++j) {
          ++cx;
          if (p[cx][cy] == 1) {
            count--;
            p[cx][cy] = 0;
          }
        }
      } else if (s == "S") {
        for (int j = 0; j < d; ++j) {
          --cy;
          if (p[cx][cy] == 1) {
            count--;
            p[cx][cy] = 0;
          }
        }
      } else if (s == "W") {
        for (int j = 0; j < d; ++j) {
          --cx;
          if (p[cx][cy] == 1) {
            count--;
            p[cx][cy] = 0;
          }
        }
      }
    }
    if (count == 0)
      cout << "Yes\n";
    else
      cout << "No\n";
  }
  return 0;
}

Fixed submission:
#include <iostream>
using namespace std;
int main() {
  int n;
  while (cin >> n) {
    if (n == 0)
      break;
    int m, count = n, p[21][21];
    for (int i = 0; i < 21; ++i)
      for (int j = 0; j < 21; ++j)
        p[i][j] = 0;
    for (int i = 0, x, y; i < n; ++i) {
      cin >> x >> y;
      p[x][y] = 1;
    }
    cin >> m;
    for (int i = 0, d, cx = 10, cy = 10; i < m; ++i) {
      string s;
      cin >> s;
      cin >> d;
      if (s == "N") {
        for (int j = 0; j < d; ++j) {
          ++cy;
          if (p[cx][cy] == 1) {
            count--;
            p[cx][cy] = 0;
          }
        }
      } else if (s == "E") {
        for (int j = 0; j < d; ++j) {
          ++cx;
          if (p[cx][cy] == 1) {
            count--;
            p[cx][cy] = 0;
          }
        }
      } else if (s == "S") {
        for (int j = 0; j < d; ++j) {
          --cy;
          if (p[cx][cy] == 1) {
            count--;
            p[cx][cy] = 0;
          }
        }
      } else if (s == "W") {
        for (int j = 0; j < d; ++j) {
          --cx;
          if (p[cx][cy] == 1) {
            count--;
            p[cx][cy] = 0;
          }
        }
      }
    }
    if (count == 0)
      cout << "Yes\n";
    else
      cout << "No\n";
  }
  return 0;
}
Problem p01125 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define lp(i, n) for (int i = 0; i < n; i++)

int main() {
  while (1) {
    int n;
    cin >> n;
    if (n == 0)
      break;
    int h[21][21];
    lp(i, 21) {
      lp(j, 21) { h[i][j] = 0; }
    }
    lp(i, n) {
      int a, b;
      cin >> a >> b;
      h[a][b] = 1;
    }
    int m, count = 0;
    cin >> m;
    int nowx = 10, nowy = 10;
    if (h[nowx][nowy] == 1) {
      count++;
      h[nowx][nowy] = 0;
    }
    lp(i, m) {
      char a;
      int b;
      cin >> a >> b;
      if (a == 'N') {
        lp(j, b) {
          nowy++;
          if (h[nowx][nowy] == 1) {
            h[nowx][nowy] = 0;
            count++;
          }
        }
      }
      if (a == 'S') {
        lp(j, b) {
          nowy--;
          if (h[nowx][nowy] == 1) {
            h[nowx][nowy] = 0;
            count++;
          }
        }
      }
      if (a == 'E') {
        lp(j, b) {
          nowx++;
          if (h[nowx][nowy] == 1) {
            h[nowx][nowy] = 0;
            count++;
          }
        }
      }
      if (a == 'W') {
        lp(j, b) {
          nowx++;
          if (h[nowx][nowy] == 1) {
            h[nowx][nowy] = 0;
            count++;
          }
        }
      }
    }
    if (count == n)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
  return 0;
}


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

int main() {
  while (1) {
    int n;
    cin >> n;
    if (n == 0)
      break;
    int h[21][21];
    lp(i, 21) {
      lp(j, 21) { h[i][j] = 0; }
    }
    lp(i, n) {
      int a, b;
      cin >> a >> b;
      h[a][b] = 1;
    }
    int m, count = 0;
    cin >> m;
    int nowx = 10, nowy = 10;
    if (h[nowx][nowy] == 1) {
      count++;
      h[nowx][nowy] = 0;
    }
    lp(i, m) {
      char a;
      int b;
      cin >> a >> b;
      if (a == 'N') {
        lp(j, b) {
          nowy++;
          if (h[nowx][nowy] == 1) {
            h[nowx][nowy] = 0;
            count++;
          }
        }
      }
      if (a == 'S') {
        lp(j, b) {
          nowy--;
          if (h[nowx][nowy] == 1) {
            h[nowx][nowy] = 0;
            count++;
          }
        }
      }
      if (a == 'E') {
        lp(j, b) {
          nowx++;
          if (h[nowx][nowy] == 1) {
            h[nowx][nowy] = 0;
            count++;
          }
        }
      }
      if (a == 'W') {
        lp(j, b) {
          nowx--;
          if (h[nowx][nowy] == 1) {
            h[nowx][nowy] = 0;
            count++;
          }
        }
      }
    }
    if (count == n)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
  return 0;
}