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

#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <vector>
using namespace std;

#define MP make_pair
#define PB push_back

int main(int argc, char *argv[]) {
  multimap<int, vector<int>> tab;
  vector<int> vec;
  int a, b, c, x, i, j, count, n;
  int flag[400];

  while (cin >> a >> b >> c) {
    if (a == 0 && b == 0 && c == 0)
      break;
    for (i = 0; i < 400; i++)
      flag[i] = 2;
    tab.clear();

    cin >> n;
    for (i = 0; i < n; i++) {
      vec.clear();
      for (j = 0; j < 3; j++) {
        cin >> x;
        vec.PB(x);
      }
      cin >> x;
      if (x == 1)
        tab.insert(MP(0, vec));
      else
        tab.insert(MP(1, vec));
    }

    multimap<int, vector<int>>::iterator itr;
    for (itr = tab.begin(); itr != tab.end(); itr++) {
      if ((*itr).first == 0) {
        vector<int>::iterator it;
        for (it = (*itr).second.begin(); it != (*itr).second.end(); it++) {
          flag[(*it)] = 1;
        }
      } else {
        vec.clear();
        count = 0;
        vector<int>::iterator it;
        for (it = (*itr).second.begin(); it != (*itr).second.end(); it++) {
          if (flag[(*it)] == 1)
            count++;
          else {
            vec.PB((*it));
          }
        }
        if (count == 2) {
          flag[vec.back()] = 0;
        }
      }
    }
    for (i = 1; i <= a + b + c; i++) {
      cout << flag[i] << endl;
    }
  }
  return 0;
}

Error: 0

Fixed submission:

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <vector>

#define mp make_pair

using namespace std;

int main(int argc, char *argv[]) {
  multimap<int, vector<int>> test;
  vector<int> tes_res;
  queue<int> que;
  int a, b, c, n, x, i, j, count;
  int flag[400];

  while (cin >> a >> b >> c) {
    if (a == 0 && b == 0 && c == 0)
      break;

    for (i = 0; i < 400; i++) {
      flag[i] = 2;
    }

    cin >> n;
    for (i = 0; i < n; i++) {

      tes_res.clear();

      for (j = 0; j < 3; j++) {
        cin >> x;
        tes_res.push_back(x);
      }
      cin >> x;
      if (x == 0)
        test.insert(mp(1, tes_res));
      else
        test.insert(mp(0, tes_res));
    }

    multimap<int, vector<int>>::iterator itr;
    for (itr = test.begin(); itr != test.end(); itr++) {
      if ((*itr).first == 0) {
        for (i = 0; i < 3; i++) {
          flag[(*itr).second.back()] = 1;
          (*itr).second.pop_back();
        }
      } else {
        count = 0;
        vector<int>::iterator it;
        while (!que.empty())
          que.pop();

        for (it = (*itr).second.begin(); it != (*itr).second.end(); it++) {
          que.push(*it);
        }

        for (i = 0; i < 3; i++) {
          if (flag[que.front()] == 1) {
            que.pop();
            count++;
          } else {
            que.push(que.front());
            que.pop();
          }
        }
        if (count == 2) {
          flag[que.front()] = 0;
        }
      }
    }
    for (i = 1; i <= a + b + c; i++)
      cout << flag[i] << endl;
  }
  return 0;
}
Problem p00437 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <stdio.h>

int main() {
  int a, b, c, n, i[1001], j[1001], k[1001], r[1001], x, p[301];
  while (1) {
    scanf("%d %d %d", &a, &b, &c);
    if (a == 0 && b == 0 && c == 0)
      break;
    scanf("%d", &n);
    for (x = 1; x <= a + b + c; x++) {
      p[x] = 2;
    }
    for (x = 1; x <= n; x++) {
      scanf("%d %d %d %d", &i[x], &j[x], &k[x], &r[x]);
      if (r[x] == 1) {
        p[i[x]] = 1;
        p[j[x]] = 1;
        p[k[x]] = 1;
      }
    }
    for (x = 1; x <= n; x++) {
      if (r[x] == 0) {
        if (p[i[x]] * p[j[x]] * p[k[x]] == 2) {
          if (p[i[x]] == 2)
            p[i[x]] = 0;
          if (p[j[x]] == 2)
            p[j[x]] = 0;
          if (p[k[x]] == 2)
            p[k[x]] = 0;
        }
      }
    }
    for (x = 1; x <= a + b + c; x++) {
      printf("%d\\n", p[x]);
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <stdio.h>

int main() {
  int a, b, c, n, i[1000], j[1000], k[1000], r[1000], x, p[300];
  while (1) {
    scanf("%d %d %d", &a, &b, &c);
    if (a == 0 && b == 0 && c == 0)
      break;
    for (x = 0; x < a + b + c; x++) {
      scanf("%d", &n);
    }
    for (x = 0; x < n; x++) {
      p[x] = 2;
    }
    scanf("%d %d %d %d", &i[x], &j[x], &k[x], &r[x]);
    if (r[x] == 1) {
      p[i[x]] = 1;
      p[j[x]] = 1;
      p[k[x]] = 1;
    }
    for (x = 0; x < n; x++) {
      if (r[x] == 0) {
        if (p[i[x]] * p[j[x]] == 1) {
          p[k[x]] = 0;
        }
        if (p[j[x]] * p[k[x]] == 1) {
          p[i[x]] = 0;
        }
        if (p[k[x]] * p[i[x]] == 1) {
          p[j[x]] = 0;
        }
      }
    }
    for (x = 0; x < a + b + c; x++) {
      printf("%d\\n", p[x]);
    }
  }
  return 0;
}
Problem p00438 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>

using namespace std;

int main() {
  while (1) {
    int d[17][17] = {};
    int n;
    int a, b;
    int x, y;
    d[1][1] = 1;
    cin >> a >> b;
    if (a == 0 && b == 0)
      break;
    cin >> n;
    for (int i = 0; i < n; i++) {
      cin >> x >> y;
      d[x][y] = -1;
    }

    for (int i = 1; i <= a; i++) {
      for (int j = 1; j <= b; j++) {
        if (x == 1 && y == 1)
          continue;
        if (d[i][j] < 0)
          continue;
        if (d[i][j - 1] >= 0)
          d[i][j] += d[i][j - 1];
        if (d[i - 1][j] >= 0)
          d[i][j] += d[i - 1][j];
      }
    }
    cout << d[a][b] << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>

using namespace std;

int main() {
  int d[17][17] = {};
  int n;
  int a, b;
  int x, y;
  d[1][1] = 1;
  cin >> a >> b;
  while (a != 0 && b != 0) {
    cin >> n;
    for (int i = 0; i < n; i++) {
      cin >> x >> y;
      d[x][y] = -1;
    }

    for (int i = 1; i <= a; i++) {
      for (int j = 1; j <= b; j++) {
        if (x == 1 && y == 1)
          continue;
        if (d[i][j] < 0)
          continue;
        if (d[i][j - 1] >= 0)
          d[i][j] += d[i][j - 1];
        if (d[i - 1][j] >= 0)
          d[i][j] += d[i - 1][j];
      }
    }
    for (int i = 1; i <= a; i++) {
      for (int j = 1; j <= b; j++) {
        cout << d[i][j];
      }
      cout << endl;
    }
  }
  return 0;
}
Problem p00438 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <vector>

int main() {

  int a, b; // a:street going north and south, b:street going east and west
  while (std::cin >> a >> b) {
    if (a == 0 && b == 0)
      break;

    int n; // number of junction under construction
    std::cin >> n;

    std::vector<std::vector<int>> junction(b, std::vector<int>(a, 0));

    for (int i = 0; i < n; ++i) {
      int x, y; // junction under construction
      std::cin >> x >> y;
      junction[y - 1][x - 1] = -1;
    }

    // count school road
    junction[0][0] = 1;
    for (int i = 0; i < b; ++i) {
      for (int j = 0; j < a; ++j) {
        if (junction[i][j] != -1) {
          if (i != 0 && junction[i - 1][j] != -1) {
            junction[i][j] += junction[i - 1][j];
          }
          if (j != 0 && junction[i][j - 1] != -1) {
            junction[i][j] += junction[i][j - 1];
          }
        }
      }
    }

    /*
    for(auto row_it = junction.begin(); row_it != junction.end(); ++row_it){
            for(auto col_it = row_it->begin(); col_it != row_it->end();
    ++col_it){ std::cout << *col_it << std::endl;
            }
    }
    */

    std::cout << junction[b - 1][a - 1] << std::endl;
  }

  return 0;
}

Error: -11

Fixed submission:

#include <iostream>
#include <vector>

int main() {

  int a, b; // a:street going north and south, b:street going east and west
  while (std::cin >> a >> b) {
    if (a == 0 && b == 0)
      break;

    int n; // number of junction under construction
    std::cin >> n;

    std::vector<std::vector<int>> junction(b, std::vector<int>(a, 1));

    for (int i = 0; i < n; ++i) {
      int x, y; // junction under construction
      std::cin >> x >> y;
      junction[y - 1][x - 1] = -1;
    }

    for (int i = 0; i < b; ++i) {
      for (int j = 0; j < a; ++j) {
        if (junction[i][j] != -1) {
          if (i != 0 && junction[i - 1][j] != -1) {
            junction[i][j] += junction[i][j - 1];
          }
          if (j != 0 && junction[i][j - 1] != -1) {
            junction[i][j] += junction[i - 1][j];
          }
        }
      }
    }
    std::cout << junction[b - 1][a - 1] << std::endl;
  }

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

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

int main(void) {
  int w, h;
  int n;
  while (cin >> w, w) {
    cin >> h >> n;
    vector<vector<int>> maze(h + 1, vector<int>(w + 1, 0));

    int x, y;
    for (int i = 0; i < n; i++) {
      cin >> x >> y;
      maze[--y][--x] = -1;
    }
    for (int i = 0; i < h; i++)
      if (maze[i][0] != -1)
        maze[i][0] = 1;
      else
        break;
    for (int i = 0; i < w; i++)
      if (maze[0][i] != -1)
        maze[0][i] = 1;
      else
        break;
    for (int i = 1; i < h; i++) {
      for (int j = 1; j < w; j++) {
        if (maze[i][j] == -1)
          continue;
        maze[i][j] = max(0, maze[i - 1][j]) + max(0, maze[i][j - 1]);
      }
    }
    cout << maze[h - 1][w - 1] << endl;
  }
}

Error: TLE

Fixed submission:

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

int main(void) {
  long long a[3], m[3];
  while (cin >> a[0] >> m[0], a[0] + m[0]) {
    for (int i = 1; i < 3; i++) {
      cin >> a[i] >> m[i];
    }
    for (int i = 0; i < 3; i++) {
      long long co = 0, d = 1;
      while (true) {
        co++;
        d = (a[i] * d) % m[i];
        if (d == 1)
          break;
      }
      a[i] = co;
    }
    long long d = a[1] * a[2] / __gcd(a[1], a[2]);
    cout << d * a[0] / __gcd(a[0], d) << endl;
  }
  for (int i = 1; i < 3; i++)
    cin >> a[i] >> m[i];
}
Problem p00438 (C++) — buggy submission, verdict: Time Limit Exceeded

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

using namespace std;

int FindRoad(vector<vector<int>> &road, int x, int y);

int h, w;
int n;
int dummy = 0;
int result = 0;

int main(void) {

  int x, y;

  vector<vector<int>> road(18, vector<int>(18));

  cin >> w >> h;

  while (w != 0 && h != 0) {
    cin >> n;

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

    cout << FindRoad(road, 1, 1) << endl;

    for (int x = 0; x < 18; x++) {
      for (int y = 0; y < 18; y++) {
        if (road[x][y] == 1)
          road[x][y] = 0;
      }
    }

    result = 0;

    cin >> w >> h;
  }

  return 0;
}

int FindRoad(vector<vector<int>> &road, int x, int y) {

  if ((x - 1 == w || y - 1 == h) || road[x][y] == 1)
    return 0;
  if (x == w && y == h)
    result++;

  dummy = FindRoad(road, x, y + 1);
  dummy = FindRoad(road, x + 1, y);

  return result;
}

Error: TLE

Fixed submission:

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

using namespace std;

int FindRoad(vector<vector<int>> road, int x, int y);

int h, w;
int n;
int dummy = 0;
int result = 0;

int main(void) {

  int x, y;

  vector<vector<int>> road(18, vector<int>(18));

  cin >> w >> h;

  while (w != 0 && h != 0) {
    cin >> n;

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

    cout << FindRoad(road, 1, 1) << endl;

    for (int i = 0; i < 18; i++) {
      for (int j = 0; j < 18; j++) {
        if (road[i][j] == 1)
          road[i][j] = 0;
      }
    }

    result = 0;

    cin >> w >> h;
  }

  return 0;
}

int FindRoad(vector<vector<int>> road, int x, int y) {

  if ((x - 1 == w || y - 1 == h) || road[x][y] == 1)
    return 0;
  if (x == w && y == h)
    result++;

  dummy = FindRoad(road, x, y + 1);
  dummy = FindRoad(road, x + 1, y);

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

#include <bits/stdc++.h>

using namespace std;

int load[17][17] = {0};
int mem[20][20] = {0};
int f(int x, int y) {
  if (mem[x][y] != 0)
    return mem[x][y];
  if (x == 1 && y == 1)
    return 1;
  if (x <= 0 || y <= 0)
    return 0;
  if (load[x][y] == 0)
    return mem[x][y] = f(x - 1, y) + f(x, y - 1);
  return 0;
}

int main() {
  int a, b, n, x, y;
  while (1) {
    memset(load, 0, sizeof(load));
    memset(mem, 0, sizeof(mem));
    cin >> a >> b;
    if (a == 0 && b == 0)
      break;
    cin >> n;
    for (int i = 0; i < n; i++) {
      cin >> x >> y;
      load[x][y] = -1;
    }
    cout << f(a, b) << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

int load[18][18] = {0};

int f(int x, int y) {
  if (x == 1 && y == 1)
    return 1;
  if (x <= 0 || y <= 0)
    return 0;
  if (load[x][y] == 0)
    return f(x - 1, y) + f(x, y - 1);
  return 0;
}

int main() {
  int a, b, n, x, y;
  while (1) {
    int load[18][18] = {0};
    cin >> a >> b;
    if (a == 0 && b == 0)
      break;
    cin >> n;
    for (int i = 0; i < n; i++) {
      cin >> x >> y;
      load[x][y] = -1;
    }
    cout << f(a, b) << endl;
  }
  return 0;
}
Problem p00438 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <vector>

int main() {
  while (true) {
    int a = 0, b = 0;
    int n = 0;
    std::cin >> a >> b;
    if (a == 0 && b == 0) {
      break;
    }
    std::cin >> n;
    std::vector<std::vector<int>> road;
    road = std::vector<std::vector<int>>(a, std::vector<int>(b, 0));
    for (int i = 1; i < b; ++i) {
      road[0][i] = 1;
    }
    for (int i = 1; i < a; ++i) {
      road[i][0] = 1;
    }
    for (int i = 0; i < n; ++i) {
      int x, y;
      std::cin >> x >> y;
      road[x - 1][y - 1] = -1;
      if (x == 1) {
        for (int i = y - 1; i < b; ++i) {
          road[0][i] = 0;
        }
      }
      if (y == 1) {
        for (int i = x - 1; i < a; ++i) {
          road[i][y - 1] = 0;
        }
      }
    }
    for (int i = 1; i < a; ++i) {
      for (int j = 1; j < b; ++j) {
        if (road[i][j] == -1) {
          road[i][j] = 0;
        } else {
          road[i][j] = road[i - 1][j] + road[i][j - 1];
        }
      }
    }
    std::cout << road[a - 1][b - 1] << std::endl;
  }
  return 0;
}

Error: 0

Fixed submission:

#include <iostream>
#include <vector>

int main() {
  while (true) {
    int a = 0, b = 0;
    int n = 0;
    std::cin >> a >> b;
    if (a == 0 && b == 0) {
      break;
    }
    std::cin >> n;
    std::vector<std::vector<int>> road;
    road = std::vector<std::vector<int>>(a, std::vector<int>(b, 0));
    for (int i = 1; i < b; ++i) {
      road[0][i] = 1;
    }
    for (int i = 1; i < a; ++i) {
      road[i][0] = 1;
    }
    for (int i = 0; i < n; ++i) {
      int x, y;
      std::cin >> x >> y;
      road[x - 1][y - 1] = -1;
      if (x == 1) {
        for (int i = y - 1; i < a; ++i) {
          road[x - 1][i] = 0;
        }
      }
      if (y == 1) {
        for (int i = x - 1; i < b; ++i) {
          road[i][y - 1] = 0;
        }
      }
    }
    for (int i = 1; i < a; ++i) {
      for (int j = 1; j < b; ++j) {
        if (road[i][j] == -1) {
          road[i][j] = 0;
        } else {
          road[i][j] = road[i - 1][j] + road[i][j - 1];
        }
      }
    }
    std::cout << road[a - 1][b - 1] << std::endl;
  }
  return 0;
}
Problem p00438 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int a, b, x, y;

  while (std::cin >> a >> b) {

    if (a == 0 && b == 0) {
      break;
    }

    std::vector<std::vector<int>> road(a, std::vector<int>(b, 1));
    int num = 0;

    std::cin >> num;

    for (int i = 0; i < num; ++i) {
      std::cin >> x >> y;
      road.at(x - 1).at(y - 1) = 0;
    }

    for (int i = 0; i < a; ++i) {
      for (int j = 0; j < b; ++j) {

        // start point & point under construction
        if (road.at(i).at(j) != 0 && (i + j) != 0) {
          if (i == 0) {
            if (road.at(i).at(j - 1) != 0) {
              road.at(i).at(j) = road.at(i).at(j - 1);
            } else {
              road.at(i).at(j) = 0;
            }
          } else if (j == 0) {
            if (road.at(i - 1).at(j) != 0) {
              road.at(i).at(j) = road.at(i - 1).at(j);
            } else {
              road.at(i).at(j) = 0;
            }
          } else {
            road.at(i).at(j) = road.at(i).at(j - 1) + road.at(i - 1).at(j);
          }
        }
      }
    }

    std::cout << road.at(a - 1).at(b - 1) << std::endl;
  }
}

Error: WA

Fixed submission:

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

int main() {
  int a, b, x, y;

  while (std::cin >> a >> b) {

    if (a == 0 && b == 0) {
      break;
    }

    std::vector<std::vector<int>> road(a, std::vector<int>(b, 1));
    int num = 0;

    std::cin >> num;

    for (int i = 0; i < num; ++i) {
      std::cin >> x >> y;
      road.at(x).at(y) = 0;
    }

    for (int i = 0; i < a; ++i) {
      for (int j = 0; j < b; ++j) {

        // start point & point under construction
        if (road.at(i).at(j) != 0 && (i + j) != 0) {
          if (i == 0) {
            if (road.at(i).at(j - 1) != 0) {
              road.at(i).at(j) = road.at(i).at(j - 1);
            } else {
              road.at(i).at(j) = 0;
            }
          } else if (j == 0) {
            if (road.at(i - 1).at(j) != 0) {
              road.at(i).at(j) = road.at(i - 1).at(j);
            } else {
              road.at(i).at(j) = 0;
            }
          } else {
            road.at(i).at(j) = road.at(i).at(j - 1) + road.at(i - 1).at(j);
          }
        }
      }
    }

    std::cout << road.at(a - 1).at(b - 1) << std::endl;
  }
}
Problem p00438 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <vector>

int main() {
  while (1) {
    int a, b;
    std::cin >> a >> b;
    if (a == 0 && b == 0)
      break;

    int n;
    std::cin >> n;

    std::vector<std::vector<int>> dp(a, std::vector<int>(b, 0));
    for (int i = 0; i != n; ++i) {
      int c, d;
      std::cin >> c >> d;
      dp[c - 1][d - 1] = -1;
    }

    for (int i = 0; i != a; ++i) {
      for (int j = 0; j != b; ++j) {
        if (i == 0 && j == 0)
          dp[i][j] = 1;
        else if (dp[i][j] != -1) {
          if (i != 0 && dp[i - 1][j] != -1) {
            dp[i][j] += dp[i - 1][j];
          }
          if (j != 0 && dp[i][j - 1] != -1) {
            dp[i][j] += dp[i][j - 1];
          }
        }
      }
    }

    std::cout << dp[a - 1][b - 1] << std::endl;
  }
  return 0;
}

Error: 0

Fixed submission:

#include <iostream>
#include <vector>

int main() {
  while (1) {
    int a, b;
    std::cin >> a >> b;
    if (a == 0 && b == 0)
      break;

    int n;
    std::cin >> n;

    std::vector<std::vector<int>> dp(a, std::vector<int>(b, 0));
    for (int i = 0; i != n; ++i) {
      int c, d;
      std::cin >> c >> d;
      dp[c - 1][d - 1] = -1;
    }

    for (int i = 0; i != a; ++i) {
      for (int j = 0; j != b; ++j) {
        if (i == 0 && j == 0)
          dp[i][j] = 1;
        else if (dp[i][j] != -1) {
          if (i == 0 && dp[i][j - 1] != -1)
            dp[i][j] = dp[i][j - 1];
          else if (j == 0 && dp[i - 1][j] != -1)
            dp[i][j] = dp[i - 1][j];
          else if (dp[i - 1][j] != -1 && dp[i][j - 1] != -1)
            dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
          else if (dp[i - 1][j] != -1)
            dp[i][j] = dp[i - 1][j];
          else if (dp[i][j - 1] != -1)
            dp[i][j] = dp[i][j - 1];
        }
      }
    }

    std::cout << dp[a - 1][b - 1] << std::endl;
  }
  return 0;
}
Problem p00438 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cstdio>
using namespace std;
int main(void) {
  while (1) {
    int field[41][41] = {0};
    field[1][1] = 1;

    int w, h;
    scanf("%d%d", &w, &h);
    if (w == 0 && h == 0)
      break;

    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
      int a, b;
      scanf("%d%d", &a, &b);
      field[b][a] = -1;
    }
    for (int i = 1; i <= h; i++) {
      for (int j = 1; j <= w; j++) {
        if (i == 1 && j == 1)
          continue;
        if (field[i][j] == -1) {
          field[i][j] = 0;
        } else {
          field[i][j] = field[i - 1][j] + field[i][j - 1];
        }
      }
    }
    printf("%d\\n", field[h][w]);
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <cstdio>
using namespace std;
int field[41][41] = {0};
int main(void) {
  while (1) {
    int h, w;
    int n;
    int a[2][16] = {{0}};
    for (int i = 0; i < 41; i++) {
      for (int j = 0; j < 41; j++) {
        field[i][j] = 0;
      }
    }
    field[1][1] = 1;
    scanf("%d%d", &w, &h);
    if (w == 0 && h == 0)
      break;

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

    for (int i = 1; i <= h; i++) {
      for (int j = 1; j <= w; j++) {
        if (i == 1 && j == 1)
          continue;
        field[i][j] = field[i - 1][j] + field[i][j - 1];
        for (int k = 0; k < n; k++) {
          if (j == a[0][k] && i == a[1][k])
            field[i][j] = 0;
        }
      }
    }
    printf("%d\\n", field[h][w]);
  }
  return 0;
}
Problem p00438 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int a, b;
  int cnt = 0;
  int m[16] = {0};
  while (scanf("%d%d", &a, &b), a, b) {
    int ro[32][32] = {{0}};
    ro[0][1] = 1;
    int n;
    scanf("%d", &n);
    int x, y;
    for (int i = 0; i < n; i++) {
      scanf("%d%d", &x, &y);
      ro[y][x] = 1;
    }
    for (int i = 1; i <= b; i++) {
      for (int j = 1; j <= a; j++) {
        if (ro[i][j] == 1)
          ro[i][j] = 0;
        else
          ro[i][j] = (ro[i - 1][j] + ro[i][j - 1]);
      }
    }
    m[cnt] = ro[b][a];
    cnt++;
  }
  for (int i = 0; i < cnt; i++) {
    printf("%d\\n", m[i]);
  }
  return 0;
}

Error: 0

Fixed submission:

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

int main() {
  int m[16] = {0};
  int a, b;
  int cnt = 0;
  while (scanf("%d%d", &a, &b), a, b) {
    int ro[32][32] = {{0}};
    ro[0][1] = 1;
    int n;
    scanf("%d", &n);
    int x[16], y[16];
    for (int i = 0; i < n; i++) {
      scanf("%d%d", &x[i], &y[i]);
      ro[y[i]][x[i]] = 2;
    }
    for (int i = 1; i <= b; i++) {
      for (int j = 1; j <= a; j++) {
        if (ro[i][j] == 2)
          ro[i][j] = 0;
        else
          ro[i][j] = (ro[i - 1][j] + ro[i][j - 1]);
      }
    }
    m[cnt] = ro[b][a];
    cnt++;
  }
  for (int i = 0; i < cnt; i++) {
    printf("%d\\n", m[i]);
  }
  return 0;
}