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

#include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <numeric>
#include <set>
#include <sstream>
#include <stdio.h>
#include <string>
#include <vector>

#define rep(i, j) for (int i = 0; i < j; i++)
#define all(i) i.begin(), i.end()
#define ll long long

using namespace std;

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

  int num = 0;
  while (cin >> num && num != 0) {
    vector<vector<int>> gem(22, vector<int>(22, 0));
    rep(i, num) {
      int tmp[2] = {0};
      cin >> tmp[0] >> tmp[1];
      gem[tmp[0]][tmp[1]] = 1;
    }
    int num2 = 0;
    cin >> num2;
    int x = 10, y = 10, ans = 0;
    rep(i, num2) {
      char dir = 0;
      int m = 0;
      cin >> dir >> m;
      rep(j, m) {
        switch (dir) {
        case 'N':
          y++;
          break;
        case 'E':
          x++;
          break;
        case 'S':
          y--;
          break;
        case 'W':
          x--;
          break;
        }
        num -= gem[x][y];
        gem[x][y] = 0;
      }
    }
    if (num == 0) {
      printf("Yes\\n");
    } else {
      printf("No\\n");
    }
  }
  return 0;
}

Error: WA

Fixed submission:

#include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <numeric>
#include <set>
#include <sstream>
#include <stdio.h>
#include <string>
#include <vector>

#define rep(i, j) for (int i = 0; i < j; i++)
#define all(i) i.begin(), i.end()
#define ll long long

using namespace std;

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

  int dat[20][20] = {0};
  int num = 0;
  while (cin >> num && num != 0) {
    int ans = 0;
    rep(i, num) {
      int tmp = 0, tmp2 = 0;
      cin >> tmp >> tmp2;
      dat[tmp][tmp2] = 1;
      if (tmp == 10 && tmp2 == 10) {
        ans += 1;
      }
    }
    int tmp = 0;
    cin >> tmp;
    string m;
    int cmd = 0;
    int now_x = 10, now_y = 10;
    rep(i, tmp) {
      cin >> m >> cmd;
      rep(i, cmd) {
        switch (m[0]) {
        case 'N':
          now_y += 1;
          break;
        case 'E':
          now_x += 1;
          break;
        case 'S':
          now_y -= 1;
          break;
        case 'W':
          now_x -= 1;
          break;
        }
        ans += dat[now_x][now_y];
        // dat[now_x][now_y] = 0;
      }
    }
    if (ans == num) {
      printf("Yes\\n");
    } else {
      printf("No\\n");
    }
  }
  return 0;
}
Problem p01125 (C++) — buggy submission, verdict: 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[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;
  }
}

Error: 0

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[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;
  }
}
Problem p01125 (C++) — buggy submission, verdict: Runtime Error

#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";
  }
}

Error: 0

Fixed submission:

#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";
  }
}
Problem p01125 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
#define N_PRIME 1000000007
#define ll int64_t

int main(void) {
  while (true) {
    int N;
    bool b[32][32] = {false};
    cin >> N;
    if (N == 0)
      return 0;

    for (int i = 0; i < N; i++) {
      int x, y;
      cin >> x >> y;
      b[x][y] = true;
    }
    // cout << "A" << endl;

    int x = 10, y = 10;
    int count = 0;
    int M;
    cin >> M;

    if (b[10][10]) {
      count++;
      b[10][10] = false;
    }
    for (int i = 0; i < M; i++) {
      string s;
      int L;
      cin >> s;
      cin >> L;
      int dx, dy;

      switch (s[0]) {
      case 'N':
        dy = 1;
        dx = 0;
        break;
      case 'E':
        dy = 0;
        dx = 1;
        break;
      case 'S':
        dy = -1;
        dx = 0;
        break;
      case 'W':
        dy = 0;
        dx = -1;
        break;
      }

      for (int j = 0; j < L; j++) {
        x += dx;
        y += dy;
        if (b[x][y]) {
          count++;
          b[x][y] = false;
        }
      }
    }
    cout << (N == count ? "Yes" : "No") << endl;
  }
  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define N_PRIME 1000000007
#define ll int64_t

int main(void) {
  while (true) {
    int N;
    bool b[32][32] = {false};
    cin >> N;
    if (N == 0)
      return 0;

    for (int i = 0; i < N; i++) {
      int x, y;
      cin >> x >> y;
      b[x][y] = true;
    }

    int x = 10, y = 10;
    int count = 0;
    int M;
    cin >> M;

    if (b[10][10]) {
      count++;
      b[10][10] = false;
    }
    for (int i = 0; i < M; i++) {
      string s;
      int L;
      cin >> s;
      cin >> L;
      int dx, dy;

      switch (s[0]) {
      case 'N':
        dy = 1;
        dx = 0;
        break;
      case 'E':
        dy = 0;
        dx = 1;
        break;
      case 'S':
        dy = -1;
        dx = 0;
        break;
        dy = 0;
        dx = -1;
      case 'W':
        break;
      }

      for (int j = 0; j < L; j++) {
        x += dx;
        y += dy;
        if (b[x][y]) {
          count++;
          b[x][y] = false;
        }
      }
    }
    cout << (N == count ? "Yes" : "No") << endl;
  }
  return 0;
}
Problem p01125 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>

using namespace std;

int main() {
  int n;
  while (cin >> n && n != 0) {
    int f[21][21] = {};

    for (int i = 0; i < n; i++) {
      int x, y;
      cin >> x >> y;
      f[y][x] = 1;
    }

    int x = 10, y = 10;
    int cnt = 0;

    int m;
    cin >> m;
    for (int i = 0; i < m; i++) {
      char dir;
      int step;
      cin >> dir >> step;
      while (step--) {
        if (dir == 'N') {
          y++;
        } else if (dir == 'S') {
          y--;
        } else if (dir == 'E') {
          x++;
        } else {
          x--;
        }

        if (f[y][x]) {
          f[y][x] = 0;
          cnt++;
        }
      }
    }

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

  return 0;
}


Error: -6
*** stack smashing detected ***: terminated


Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int a[20][20] = {};
  int n;
  int x, y;
  while (cin >> n && n != 0) {
    for (int i = 0; i < n; i++) {
      cin >> y >> x;
      a[y][x] = 1;
    }
    int m;
    x = 10, y = 10;
    int count = 0;
    int num;
    char c;
    for (cin >> m; m > 0; m--) {
      cin >> c >> num;
      for (int i = 0; i < num; i++) {
        if (c == 'N')
          y += 1;
        else if (c == 'E')
          x += 1;
        else if (c == 'S')
          y -= 1;
        else
          x -= 1;
        if (a[y][x]) {
          count++;
          a[y][x] = 0;
        }
      }
    }
    if (count == n)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}
Problem p01125 (C++) — buggy submission, verdict: Runtime Error

#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;
}

Error: WA

Fixed submission:

#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;
}
Problem p01125 (C++) — buggy submission, verdict: Runtime Error

/*
        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;
}

Error: 0

Fixed submission:

/*
        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;
}
Problem p01125 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

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

char dir[5] = "NESW";

int N, M, D, X, Y, A, i, j, k, C[20], R[20], P[21][21];

char c;

int main() {
  while (true) {
    scanf("%d", &N);

    if (N == 0) {
      break;
    }

    memset(P, 0, sizeof(P));

    X = Y = 10;
    A = 0;
    P[X][Y] = 1;

    for (i = 0; i < N; i++) {
      scanf("%d%d", &C[i], &R[i]);
    }

    scanf("%d", &M);

    for (i = 0; i < M; i++) {
      std::cin >> c >> D;

      for (j = 0; j < 4; j++) {
        if (c == dir[j]) {
          for (k = 0; k < D; k++) {
            X += dx[j];
            Y += dy[j];
            P[X][Y] = 1;
          }
        }
      }
    }

    for (i = 0; i < N; i++) {
      A += P[C[i]][R[i]];
    }

    printf("%s\\n", A == N ? "Yes" : "No");
  }

  return 0;
}

Error: WA

Fixed submission:

#include <cstdio>
#include <cstring>

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

char dir[5] = "NESW";

int N, M, D, X, Y, A, i, j, k, C[20], R[20], P[21][21];

char c;

int main() {
  while (true) {
    scanf("%d", &N);

    if (N == 0) {
      break;
    }

    memset(P, 0, sizeof(P));

    X = Y = 10;
    A = 0;
    P[X][Y] = 1;

    for (i = 0; i < N; i++) {
      scanf("%d%d", &C[i], &R[i]);
    }

    scanf("%d", &M);

    for (i = 0; i < M; i++) {
      scanf("%c%d", &c, &D);

      for (j = 0; j < 4; j++) {
        if (c == dir[j]) {
          for (k = 0; k < D; k++) {
            X += dx[j];
            Y += dy[j];
            P[X][Y] = 1;
          }
        }
      }
    }

    for (i = 0; i < N; i++) {
      A += P[C[i]][R[i]];
    }

    printf("%s\\n", A == N ? "Yes" : "No");
  }

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

#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main() {
  int n, m, o;
  int p[21][21] = {0}; // 宝石の座標
  int x, y;
  int i, j, k;
  int ans;
  char a;

  while (1) {
    scanf("%d", &n);
    if ((n == 0))
      break;
    // ここまでテンプレ

    ans = 0;

    for (i = 0; i < 21; i++) {
      for (j = 0; j < 21; j++) {
        p[i][j] = 0;
      }
    }

    for (i = 0; i < n; i++) {
      scanf("%d %d", &x, &y);
      p[x][y] = 1;
    }

    scanf("%d", &m);

    x = 10;
    y = 10;
    p[x][y] = 0;

    for (i = 0; i < m; i++) {
      scanf(" %c %d", &a, &o);
      for (j = 0; j < o; j++) {
        if (a == 'N') {
          y++;
        } else if (a == 'S') {
          y--;
        } else if (a == 'E') {
          x++;
        } else if (a == 'W') {
          x--;
        }
        p[x][y] = 0;
      }
    }

    for (i = 0; i < 21; i++) {
      for (j = 0; j < 21; j++) {
        ans += p[i][j];
      }
    }

    if (ans == 0) {
      printf("Yes\\n");
    } else if (ans > 0) {
      printf("No\\n");
    }

    // ここからテンプレ
  }
  return 0;
}

Error: WA

Fixed submission:

#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main() {
  int n, m, o;
  int p[21][21] = {0}; // 宝石の座標
  int x, y;
  int i, j, k;
  int ans;
  char a;

  while (1) {
    scanf("%d", &n);
    if ((n == 0))
      break;
    // ここまでテンプレ

    ans = 0;

    for (i = 0; i < n; i++) {
      scanf("%d %d", &x, &y);
      p[x][y] = 1;
    }

    scanf("%d", &m);

    x = 11;
    y = 11;
    p[x][y] = 0;

    for (i = 0; i < m; i++) {
      scanf("%s %d", &a, &o);
      for (j = 0; j < o; j++) {
        if (a == 'N')
          y++;
        if (a == 'S')
          y--;
        if (a == 'E')
          x++;
        if (a == 'W')
          x--;
        p[x][y] = 0;
      }
    }

    for (i = 0; i < n; i++) {
      for (j = 0; j < n; j++) {
        ans += p[i][j];
      }
    }

    if (ans == 0)
      printf("Yes\\n");
    else
      printf("No\\n");

    // ここからテンプレ
  }
  return 0;
}
Problem p01125 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;

int main() {
  int N, M, t[21][21], l, a, b, i, j, flg = 0;
  int x, y;
  char d;
  for (;;) {
    x = 10;
    y = 10;
    flg = 0;
    cin >> N;
    if (N == 0) {
      break;
    }
    for (i = 0; i <= 20; i++) {
      for (j = 0; j <= 20; j++) {
        t[i][j] = 0;
      }
    }
    for (i = 0; i < N; i++) {
      cin >> a >> b;
      t[a][b] = 1;
    }
    cin >> M;
    for (i = 0; i < M; i++) {
      cin >> d >> l;
      switch (d) {
      case 'N':
        for (j = 0; j < l; j++) {
          y++;
          t[x][y] = 0;
        }
        break;
      case 'E':
        for (j = 0; j < l; j++) {
          x++;
          t[x][y] = 0;
        }
        break;
      case 'S':
        for (j = 0; j < l; j++) {
          y--;
          t[x][y] = 0;
        }
        break;
      case 'W':
        for (j = 0; j < l; j++) {
          x--;
          t[x][y] = 0;
        }
        break;
      default:
        break;
      }
    }
    for (i = 0; i < 21; i++) {
      for (j = 0; j < 21; j++) {
        if (t[i][j] == 1) {
          flg = 1;
        }
      }
    }
    if (flg == 0) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
  return 0;
}

Error: 0

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  int N, M, t[21][21], l, a, b, i, j, flg = 0;
  int x, y;
  char d;
  for (;;) {
    x = 10;
    y = 10;
    flg = 0;
    cin >> N;
    if (N == 0) {
      break;
    }
    for (i = 0; i < 21; i++) {
      for (j = 0; j < 21; j++) {
        t[i][j] = 0;
      }
    }
    for (i = 0; i < N; i++) {
      cin >> a >> b;
      t[a][b] = 1;
    }
    cin >> M;
    for (i = 0; i < M; i++) {
      cin >> d >> l;
      switch (d) {
      case 'N':
        for (j = 0; j < l; j++) {
          y++;
          t[x][y] = 0;
        }
        break;
      case 'E':
        for (j = 0; j < l; j++) {
          x++;
          t[x][y] = 0;
        }
        break;
      case 'S':
        for (j = 0; j < l; j++) {
          x--;
          t[x][y] = 0;
        }
        break;
      case 'W':
        for (j = 0; j < l; j++) {
          y--;
          t[x][y] = 0;
        }
        break;
      default:
        break;
      }
    }
    for (i = 0; i < 21; i++) {
      for (j = 0; j < 21; j++) {
        if (t[i][j] == 1) {
          flg = 1;
        }
      }
    }
    if (flg == 0) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
  return 0;
}
Problem p01125 (C++) — buggy submission, verdict: 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];
        y += dy[d];
        if (field[y][x]) {
          field[y][x] = false;
          cnt++;
        }
      }
    }

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

Error: -11

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] * l;
        y += dy[d] * l;
        if (field[y][x]) {
          field[y][x] = false;
          cnt++;
        }
      }
    }

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