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


#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <stack>
#include <vector>

using namespace std;

complex<int> Mov(char dir) {
  char a[4] = {'N', 'W', 'S', 'E'};
  int dx[4] = {0, -1, 0, 1};
  int dy[4] = {1, 0, -1, 0};
  for (int i = 0; i < 4; i++) {
    if (a[i] == dir) {
      complex<int> mov(dx[i], dy[i]);
      return mov;
    }
  }
}

bool solve() {
  while (1) {
    int jw[22][22] = {0};
    complex<int> rob(10, 10);
    int n;
    cin >> n;
    if (!n)
      break;
    for (int i = 0; i < n; i++) {
      int x, y;
      cin >> x >> y;
      jw[x][y]++;
    }
    int m;
    cin >> m;
    int cnt = 0;
    if (jw[10][10]) {
      jw[10][10] = 0;
      cnt++;
    }
    for (int i = 0; i < m; i++) {
      char dir;
      int d;
      cin >> dir >> d;
      for (int j = 0; j < d; j++) {
        rob += Mov(dir);
        int x = rob.real();
        int y = rob.imag();
        if (jw[x][y]) {
          jw[x][y] = 0;
          cnt++;
        }
      }
    }

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

  return true;
}

int main() {
  cout.setf(ios::fixed);
  cout.precision(10);
  solve();

  return 0;
}


Error: 0

Fixed submission:


#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <stack>
#include <vector>

using namespace std;

int jw[22][22] = {0};
complex<int> rob(10, 10);

complex<int> Mov(char dir) {
  char a[4] = {'N', 'W', 'S', 'E'};
  int dx[4] = {0, -1, 0, 1};
  int dy[4] = {1, 0, -1, 0};
  for (int i = 0; i < 4; i++) {
    if (a[i] == dir) {
      complex<int> mov(dx[i], dy[i]);
      return mov;
    }
  }
}

bool solve() {
  while (1) {
    int n;
    cin >> n;
    if (!n)
      break;
    for (int i = 0; i < n; i++) {
      int x, y;
      cin >> x >> y;
      jw[x][y]++;
    }
    int m;
    cin >> m;
    int cnt = 0;
    if (jw[10][10]) {
      jw[10][10] = 0;
      cnt++;
    }
    for (int i = 0; i < m; i++) {
      char dir;
      int d;
      cin >> dir >> d;
      for (int j = 0; j < d; j++) {
        rob += Mov(dir);
        int x = rob.real();
        int y = rob.imag();
        if (jw[x][y]) {
          jw[x][y] = 0;
          cnt++;
        }
      }
    }

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

  return true;
}

int main() {
  cout.setf(ios::fixed);
  cout.precision(10);
  solve();

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

Error: 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;
    }

    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, verdict: 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(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;
  }
}

Error: 0

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


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


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, verdict: 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[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;
}

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

#include <cmath>
#include <functional>
#include <iostream>
#include <queue>
#include <string>
#include <vector>
using namespace std;
int main() {
  int n;
  bool a[21][21];
  while (cin >> n && n != 0) {
    for (int i = 0; i <= 20; i++) {
      for (int j = 0; j <= 20; j++)
        a[i][j] = false;
    }
    int c, d;
    for (int i = 0; i < n; i++) {
      cin >> c >> d;
      a[c][d] = true;
    }
    int sum = n, m;
    int x = 10, y = 10;
    cin >> m;
    char g;
    for (int i = 0; i < m; i++) {
      cin >> g >> c;
      int e = 0, f = 0;
      int x2 = x, y2 = y;
      if (g == 'N') {
        y += c;
        f = 1;
      } else if (g == 'S') {
        y -= c;
        f = -1;
      } else if (g == 'E') {
        x += c;
        e = 1;
      } else {
        x -= c;
        e = -1;
      }
      int j = y2, i2 = x2;
      for (;;) {
        if (i2 == x && j == y)
          break;
        if (a[i2][j]) {
          sum--;
          a[i2][j] = false;
        }
        j += f;
        i2 += e;
      }
      if (a[x][y]) {
        sum--;
        a[x][y] = false;
      }
    }
    if (sum == 0)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
}

Error: TLE

Fixed submission:

#include <cmath>
#include <functional>
#include <iostream>
#include <queue>
#include <string>
#include <vector>
using namespace std;
int main() {
  int n;
  bool a[21][21];
  while (cin >> n && n != 0) {
    for (int i = 0; i <= 20; i++) {
      for (int j = 0; j <= 20; j++)
        a[i][j] = false;
    }
    int c, d;
    for (int i = 0; i < n; i++) {
      cin >> c >> d;
      a[c][d] = true;
    }
    int sum = n, m;
    int x = 10, y = 10;
    cin >> m;
    char e;
    for (int i = 0; i < m; i++) {
      cin >> e >> c;
      int e = 0, f = 0;
      int x2 = x, y2 = y;
      if (e == 'N') {
        y += c;
        e = 1;
      } else if (e == 'S') {
        y -= c;
        e = -1;
      } else if (e == 'E') {
        x += c;
        f = 1;
      } else {
        x -= c;
        f = -1;
      }
      int j = y2, i2 = x2;
      for (;;) {
        if (i2 == x && j == y)
          break;
        if (a[i2][j]) {
          sum--;
          a[i2][j] = false;
        }
        i2 += e;
        j += f;
      }
    }
    if (sum == 0)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
}
Problem p01125 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define MAX_N 23
#define MAX_M 33

int N, M, x, y;
bool field[21][21];
char dir[MAX_M];
int dis[MAX_M];

bool input() {
  x = 10;
  y = 10;
  REP(i, 21) {
    REP(j, 21) { field[i][j] = false; }
  }
  cin >> N;
  REP(i, N) {
    int a, b;
    cin >> a >> b;
    field[a][b] = true;
  }
  if (N != 0) {
    cin >> M;
    REP(i, M) cin >> dir[i] >> dis[i];
  }
  return (N != 0);
}

void solve() {
  REP(i, M) {
    if (dir[i] == 'N') {
      REP(j, dis[i]) field[x][y + j] = false;
      y += dis[i];
    } else if (dir[i] == 'E') {
      REP(j, dis[i]) field[x + j][y] = false;
      x += dis[i];
    } else if (dir[i] == 'S') {
      REP(j, dis[i]) field[x][y - j] = false;
      y -= dis[i];
    } else {
      REP(j, dis[i]) field[x - j][y] = false;
      x -= dis[i];
    }
  }
  field[x][y] = false;

  REP(i, 21) {
    REP(j, 21) {
      if (field[i][j]) {
        cout << "No" << endl;
        return;
      }
    }
  }
  cout << "Yes" << endl;
}

int main() {
  while (input()) {
    solve();
  }
  return 0;
}

Error: WA

Fixed submission:

#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define MAX_N 23
#define MAX_M 33

int N, M, x, y;
bool a;
bool field[21][21];
char dir[MAX_M];
int dis[MAX_M];

bool input() {
  x = 10;
  y = 10;
  a = false;
  REP(i, 22) {
    REP(j, 22) { field[i][j] = false; }
  }
  cin >> N;
  REP(i, N) {
    int a, b;
    cin >> a >> b;
    field[a][b] = true;
  }
  if (N != 0) {
    cin >> M;
    REP(i, M) cin >> dir[i] >> dis[i];
  }
  return (N != 0);
}

void solve() {
  REP(i, M) {
    if (dir[i] == 'N') {
      REP(j, dis[i]) field[x][y + j] = false;
      y += dis[i];
    }

    else if (dir[i] == 'E') {
      REP(j, dis[i]) field[x + j][y] = false;
      x += dis[i];
    }

    else if (dir[i] == 'S') {
      REP(j, dis[i]) field[x][y - j] = false;
      y -= dis[i];
    }

    else {
      REP(j, dis[i]) field[x - j][y] = false;
      x -= dis[i];
    }
    field[x][y] = false;
  }

  REP(i, 21) {
    REP(j, 21) {

      if (field[i][j]) {
        cout << "No" << endl;
        a = true;
        break;
      }
      if (a)
        break;
    }
  }
  if (a != true)
    cout << "Yes" << endl;
}
int main() {
  while (input()) {
    solve();
  }

  cout << field[20][1];
  return 0;
}
Problem p01125 (C++) — buggy submission, verdict: 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;
}


Error: WA

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

#include <cstdio>
#include <iostream>
#include <list>

using namespace std;

int main() {
  int n;
  while (1) {
    cin >> n;
    if (n == 0)
      break;
    int a[21][21] = {0}, x, y;
    for (int i = 0; i < n; i++) {
      cin >> x >> y;
      a[x][y] = 1;
    }
    int m, X = 10, Y = 10, cnt = 0;
    char d;
    int l;
    cin >> m;
    for (int j = 0; j < m; j++) {
      cin >> d >> l;
      for (int k = 0; k < l; k++) {
        if (d == 'N')
          Y++;
        else if (d == 'E')
          X++;
        else if (d == 'S')
          Y--;
        else if (d == 'W')
          X--;
        if (a[X][Y] == 1) {
          cnt++;
          a[X][Y] = 0;
        }
      }
    }
    if (cnt == n)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
  return 0;
}

Error: 0

Fixed submission:

#include <cstdio>
#include <iostream>
#include <list>

using namespace std;

int main() {
  int n;
  while (1) {
    cin >> n;
    if (n == 0)
      break;
    int a[20][20] = {0}, x, y;
    for (int i = 0; i < n; i++) {
      cin >> x >> y;
      a[x][y] = 1;
    }
    int m, X = 10, Y = 10, cnt = 0;
    char d;
    int l;
    cin >> m;
    for (int j = 0; j < m; j++) {
      cin >> d >> l;
      for (int k = 0; k < l; k++) {
        if (d == 'N')
          Y++;
        else if (d == 'E')
          X++;
        else if (d == 'S')
          Y--;
        else if (d == 'W')
          X--;
        if (a[X][Y] == 1)
          cnt++;
      }
    }
    if (cnt == n)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
  return 0;
}