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

#include <algorithm>
#include <iostream>
using namespace std;
int main() {
  int i, i2, m, qx, qy, X, Y, a[17][17], dp[17][17];
  cin >> X >> Y;
  while (X != 0 || Y != 0) {
    for (i = 1; i <= Y; i++) {
      for (i2 = 1; i2 <= X; i2++) {
        a[i2][i] = 0;
        dp[i2][i] = 0;
      }
    }
    dp[1][1] = 1;
    cin >> m;
    for (i = 1; i <= m; i++) {
      cin >> qx >> qy;
      a[qx][qy] = 1;
    }
    for (i = 1; i <= Y; i++) {
      for (i2 = 1; i2 <= X; i2++) {
        if (a[i2][i] == 0) {
          if (i2 + 1 <= X && a[i2 + 1][i] == 0) {
            dp[i2 + 1][i] += dp[i2][i];
          }
          if (i + 1 <= Y && a[i2][i + 1] == 0) {
            dp[i2][i + 1] += dp[i2][i];
          }
        }
      }
    }
    /*for(i=1;i<=Y;i++){
            for(i2=1;i2<=X;i2++){
                    cout<<dp[i2][i]<<' ';
            }
            cout<<endl;
    }*/
    cout << dp[X][Y] << endl;
    cin >> X >> Y;
  }
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>
using namespace std;
int X, Y, a[17][17], b[17][17], dx[4] = {0, 1}, dy[4] = {1, 0}, ans;
int func(int x, int y) {
  for (int I = 0; I < 2; I++) {
    int xx = x + dx[I];
    int yy = y + dy[I];
    if (xx == X && yy == Y) {
      ans++;
    }
    if (xx >= 1 && yy >= 1 && xx <= X && yy <= Y && a[xx][yy] == 0 &&
        b[xx][yy] == 0) {
      b[xx][yy] = b[x][y] + 1;
      /*for(int i=1;i<=Y;i++){
              for(int i2=1;i2<=X;i2++){
                      cout<<b[i2][i]<<' ';
              }
              cout<<endl;
      }*/
      cout << endl;
      func(xx, yy);
    }
  }
  b[x][y] = 0;
  return 0;
}
int main() {
  int i, i2, m, qx, qy;
  cin >> X >> Y;
  while (X != 0 || Y != 0) {
    ans = 0;
    for (i = 1; i <= Y; i++) {
      for (i2 = 1; i2 <= X; i2++) {
        a[i2][i] = 0;
        b[i2][i] = 0;
      }
    }
    cin >> m;
    for (i = 1; i <= m; i++) {
      cin >> qx >> qy;
      a[qx][qy] = 1;
    }
    func(1, 1);
    cout << ans << endl;
    cin >> X >> Y;
  }
}
Problem p00438 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <queue>
#define loop(i, a, b) for (int i = a; i < b; i++)
#define rep(i, a) loop(i, 0, a)
using namespace std;

class position {
public:
  int x, y;
};

int main() {
  int a, b, n;
  while (1) {
    cin >> a >> b;
    if (!a && !b)
      break;
    int dt[a][b];
    cin >> n;
    position error[n];
    rep(i, n) {
      int ax, ay;
      cin >> ax >> ay;
      error[i].x = ax - 1;
      error[i].y = ay - 1;
    }
    int dirx[2] = {1, 0};
    int diry[2] = {0, 1};
    queue<position> que;
    position start;
    start.x = 0;
    start.y = 0;
    que.push(start);
    long long ans = 0;
    while (!que.empty()) {
      position now = que.front();
      que.pop();
      position next;
      rep(i, 2) {
        next.x = now.x + dirx[i];
        next.y = now.y + diry[i];
        int cnt = 0;
        if (next.x == a - 1 && next.y == b - 1) { //????????°????????????
          ans++;
          continue;
        }
        rep(j, n) { //??\\????????´????????????
          if (next.x == error[j].x && next.y == error[j].y) {
            cnt++;
          }
        }
        if (cnt == 0 && next.x < a && next.x >= 0 && next.y >= 0 &&
            next.y <
                b) { //??????????????£??????????????\\????????´??????????????£????????????
          que.push(next);
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
#include <queue>
#define loop(i, a, b) for (int i = a; i < b; i++)
#define rep(i, a) loop(i, 0, a)
using namespace std;

class position {
public:
  int x, y;
};

int main() {
  int a, b, n;
  while (1) {
    cin >> a >> b;
    if (!a && !b)
      break;
    int dt[a][b];
    cin >> n;
    position error[n];
    rep(i, n) {
      int ax, ay;
      cin >> ax >> ay;
      error[i].x = ax - 1;
      error[i].y = ay - 1;
    }
    int dirx[2] = {1, 0};
    int diry[2] = {0, 1};
    queue<position> que;
    position start;
    start.x = 0;
    start.y = 0;
    que.push(start);
    int ans = 0;
    while (!que.empty()) {
      position now = que.front();
      que.pop();
      position next;
      rep(i, 2) {
        next.x = now.x + dirx[i];
        next.y = now.y + diry[i];
        int cnt = 0;
        rep(j, n) {
          if (next.x == error[j].x && next.y == error[j].y) {
            cnt++;
          }
        }
        if (cnt == 0 && next.x < a && next.x >= 0 && next.y >= 0 &&
            next.y < b) {
          que.push(next);
        }
      }
      rep(i, que.size()) {
        position check = que.front();
        que.pop();
        if (check.x != a - 1 || check.y != b - 1) {
          que.push(check);
        } else {
          ans++;
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}
Problem p00438 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>

using namespace std;

int main(int argc, char *argv[]) {
  int a, b;
  const int ini = -1;
  while (cin >> a >> b && a != 0 && b != 0) {
    int field[18][18] = {0};

    for (int i = 1; i <= b; ++i) {
      for (int j = 1; j <= a; ++j) {
        if (i == 1 && j == 1) {
          field[i][j] = 1;
        } else {
          field[i][j] = ini;
        }
      }
    }
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
      int x, y;
      cin >> x >> y;
      field[y][x] = 0;
    }

    for (int i = 1; i <= b; ++i) {
      for (int j = 1; j <= a; ++j) {
        if ((field[i][j] != 0) && !(i == 1 && j == 1)) {
          field[i][j] = field[i - 1][j] + field[i][j - 1];
        }
      }
    }
    /*
    for (int i=b; 1<=i; --i){
      for (int j=1; j<=a; ++j){
        cout << field[i][j] << " ";
      }
      cout << endl;
    }
   */
    cout << field[b][a] << endl;
  }
  return 0;
}

Error: 255

Fixed submission:

#include <iostream>

using namespace std;

int main(int argc, char *argv[]) {
  int a, b;
  const int ini = -1;
  while (cin >> a >> b) {
    if (a == 0 && b == 0) {
      return -1;
    }

    int field[16][16] = {
        0,
    };

    for (int i = 1; i <= b; ++i) {
      for (int j = 1; j <= a; ++j) {
        if (i == 1 || j == 1) {
          field[i][j] = 1;
        } else {
          field[i][j] = ini;
        }
      }
    }
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
      int x, y;
      cin >> x >> y;
      field[y][x] = 0;
    }

    for (int i = 2; i <= b; ++i) {
      for (int j = 2; j <= a; ++j) {
        if (field[i][j] != 0) {
          field[i][j] = field[i - 1][j] + field[i][j - 1];
        }
      }
    }

    cout << field[b][a] << endl;
  }
  return 0;
}
Problem p00438 (C++) — buggy submission, verdict: Runtime Error

#include <cstring>
#include <iostream>

const int MAX = 16;

int w, h;
int n;

int dp[MAX][MAX];

int main() {
  while (1) {
    std::cin >> w >> h;
    if (w + h == 0)
      break;
    for (int i = 0; i < h; ++i) {
      for (int j = 0; j < w; ++j)
        dp[i][j] = 1;
    }
    std::cin >> n;
    int x, y;
    for (int i = 0; i < n; ++i) {
      std::cin >> x >> y;
      --x;
      --y;
      dp[y][x] = 0;
    }
    bool flag = false;
    for (int i = 0; i < w; ++i) {
      if (flag)
        dp[0][i] = 0;
      else if (!dp[0][i])
        flag = true;
    }
    flag = false;
    for (int i = 0; i < h; ++i) {
      if (flag)
        dp[i][0] = 0;
      else if (!dp[i][0])
        flag = true;
    }

    for (int i = 1; i < h; ++i) {
      for (int j = 1; j < w; ++j) {
        if (!dp[i][j])
          dp[i][j] = 0;
        else
          dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
      }
    }
    std::cout << dp[h - 1][w - 1] << std::endl;
  }
  return 0;
}

Error: -11

Fixed submission:

#include <cstdio>
#include <iostream>
#define A_MAX 16
#define B_MAX 16
#define N_MAX 40

typedef std::pair<int, int> P;

int a, b, n, dp[B_MAX][A_MAX];
P krs[N_MAX];

int main() {
  while (1) {
    scanf("%d %d %d", &a, &b, &n);
    if (a == 0 && &b == 0)
      break;
    for (int i = 0; i < n; ++i) {
      scanf("%d %d", &krs[i].first, &krs[i].second);
    }
    for (int i = 0; i < b; ++i)
      dp[i][0] = 1;
    for (int i = 0; i < a; ++i)
      dp[0][i] = 1;
    for (int i = 1; i < b; ++i) {
      for (int j = 1; j < a; ++j) {
        int count = 0;
        for (int k = 0; k < n; ++k) {
          if (i == krs[k].second - 1 && j == krs[k].first - 1)
            ++count;
        }
        if (count > 0)
          dp[i][j] = 0;
        else
          dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
      }
    }
    scanf("%d\\n", dp[b - 1][a - 1]);
  }
  return 0;
}
Problem p00438 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <vector>

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

    int n;
    std::cin >> n;
    std::vector<std::vector<int>> map(a, std::vector<int>(b, 1)); // 地図

    for (int i = 0; i < n; ++i) {
      int x, y;
      std::cin >> x >> y;
      if (x == 0 && y == 0)
        break;
      map[x - 1][y - 1] = 0;
      if (x == 1) {
        for (int y1 = y; y1 < b; y1++) {
          map[x - 1][y1] = 0;
        }
      }
      if (y == 1) {
        for (int x1 = x; x1 < a; x1++) {
          map[x1][y - 1] = 0;
        }
      }
    }

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


Error: 0

Fixed submission:

#include <iostream>
#include <vector>

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

    int n;
    std::cin >> n;
    std::vector<std::vector<int>> map(a, std::vector<int>(b, 1)); // 地図

    for (int i = 0; i < n; ++i) {
      int x, y;
      std::cin >> x >> y;
      if (x == 0 && y == 0)
        break;
      map[x - 1][y - 1] = 0;
      if (x == 1) {
        for (int y1 = y; y1 < b; y1++) {
          map[x - 1][y1] = 0;
        }
      }
      if (y == 1) {
        for (int x1 = x; x1 < a; x1++) {
          map[x - 1][x1] = 0;
        }
      }
    }

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

#include <iostream>
#include <vector>

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

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

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

    std::cin >> n;

    std::vector<std::vector<int>> cor(b + 1, std::vector<int>(a + 1, 0));
    std::vector<std::vector<int>> pro(b + 1, std::vector<int>(a + 1, 0));

    while (n > 0 && std::cin >> x >> y) {
      pro[y][x] = 1;
      --n;
    }

    if (pro[2][1] != 1)
      cor[2][1] = 1;

    if (pro[1][2] != 1)
      cor[1][2] = 1;

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


Error: 0

Fixed submission:

#include <array>
#include <iostream>

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

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

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

    std::cin >> n;

    const int A_LIMIT = 16;
    const int B_LIMIT = 16;

    std::array<std::array<int, B_LIMIT>, A_LIMIT> cor;
    std::array<std::array<int, B_LIMIT>, A_LIMIT> pro;

    for (int i = 0; i < B_LIMIT; ++i)
      for (int j = 0; j < A_LIMIT; ++j) {
        cor[i][j] = 0;
        pro[i][j] = 0;
      }

    while (n > 0 && std::cin >> x >> y) {
      pro[y][x] = 1;
      --n;
    }

    if (pro[2][1] != 1)
      cor[2][1] = 1;

    if (pro[1][2] != 1)
      cor[1][2] = 1;

    for (int i = 1; i <= b; ++i)
      for (int j = 1; j <= a; ++j) {
        if (pro[i][j] != 1)
          cor[i][j] += cor[i - 1][j] + cor[i][j - 1];
      }
    std::cout << cor[b][a] << std::endl;
  }
}
Problem p00438 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define fi first
#define se second
using namespace std;
bool value(int y, int x, int R, int C) {
  return 0 <= y && y < R && 0 <= x && x < C;
}
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<vi> vvi;
double pie = acos(-1);
int dx[4] = {0, -1, 0, 1};
int dy[4] = {-1, 0, 1, 0};
int main() {
  int a, b, n;
  int x, y;
  while (true) {
    cin >> a >> b;
    if (a == 0 && b == 0)
      break;
    cin >> n;
    int dp[20][20];
    bool f[20][20];
    for (int i = 0; i < 20; i++) {
      for (int j = 0; j < 20; j++) {
        dp[i][j] = 0;
        f[i][j] = true;
      }
    }
    for (int i = 0; i < n; i++) {
      cin >> x >> y;
      f[x][y] = false;
    }
    for (int i = 1; i <= a; i++) {
      for (int j = 1; j <= b; j++) {
        if (f[i][j]) {
          dp[i][j] = dp[i][j - 1] + dp[i - 1][j];
          dp[1][1] = 1;
        }
      }
    }
    cout << dp[a][b] << endl;
  }
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define fi first
#define se second
using namespace std;
bool value(int y, int x, int R, int C) {
  return 0 <= y && y < R && 0 <= x && x < C;
}
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<vi> vvi;
double pie = acos(-1);
int dx[4] = {0, -1, 0, 1};
int dy[4] = {-1, 0, 1, 0};
int main() {
  int a, b, n;
  int y[20], x[20];
  while (true) {
    cin >> a >> b;
    if (a == 0 && b == 0)
      break;
    cin >> n;
    int dp[20][20];
    bool f[20][20];
    for (int i = 0; i < 20; i++) {
      for (int j = 0; j < 20; j++) {
        dp[i][j] = 0;
        f[i][j] = true;
      }
    }
    for (int i = 0; i < n; i++) {
      cin >> x[i] >> y[i];
      f[x[i]][y[i]] = false;
    }
    for (int i = 1; i <= a; i++) {
      for (int j = 1; j <= b; j++) {
        if (f[i][j]) {
          dp[i][j] = dp[i][j - 1] + dp[i - 1][j];
          dp[1][1] = 1;
        }
      }
    }
    cout << dp[a][b] << endl;
  }
}
Problem p00438 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
int road[20][20] = {0};
int main() {
  while (1) {
    int W, H;
    cin >> W;
    cin >> H;
    if (W == 0 && H == 0) {
      break;
    }
    int kp;
    cin >> kp;
    vector<int> kpp[2]; // 0...x,1...y
    for (int i = 0; i < kp; i++) {
      int x, y;
      cin >> x;
      cin >> y;
      kpp[0].push_back(x);
      kpp[1].push_back(y);
    }
    /*for(int i = 0;i < H;i++){
        for(int j = 0;j < W;j++){
            cout << road[i][j] << ' ';//3 0:2 1:1 2:0
        }
        cout << endl;
    }*/
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        int f = 0;
        for (int k = 0; k < kp; k++) {
          if (i + 1 == kpp[1][k] && j + 1 == kpp[0][k]) {
            // cout << i+1 << ':' << j+1 << endl;
            f = 1;
            break;
          }
        }
        if (i == 0 && j == 0) {
          road[i][j] = 1;
        } else if (i == 0 && f == 0) {
          road[i][j] = road[i][j - 1];
        } else if (j == 0 && f == 0) {
          road[i][j] = road[i - 1][j];
        } else if (f == 0) {
          road[i][j] = road[i - 1][j] + road[i][j - 1];
        }
      }
    }
    /*for(int i = 0;i < H;i++){
        for(int j = 0;j < W;j++){
            cout << road[H-1-i][j] << ' ';
        }
        cout << endl;
    }*/
    cout << road[H - 1][W - 1] << endl;
    for (int i = 0; i < 20; i++) {
      for (int j = 0; j < 20; j++) {
        road[i][j] = 0;
      }
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int p(int x, int y);
int main() {
  while (1) {
    int H, W;
    cin >> W;
    cin >> H;
    if (W == 0 && H == 0) {
      break;
    }
    int goal = (H - 1) * 10 + (W - 1);
    int bi = H + W - 2;
    int kouP;
    cin >> kouP;
    vector<int> kouxy;
    int R = p(2, bi);
    for (int i = 0; i < kouP; i++) {
      int x, y;
      cin >> x;
      cin >> y;
      kouxy.push_back(10 * (y - 1) + (x - 1));
    }
    /*for(int i = 0;i < kouxy.size();i++){
        cout << kouxy[i] << 'L' << endl;
    }*/
    int txy = 0;
    int route = 0;
    int koki = kouxy.size();
    for (int i = 0; i < R; i++) {
      int xy = 0;
      int f = 0;
      for (int j = 0; j < W + H - 2; j++) {
        if (i & 1 << j) {
          xy += 10;
          // cout << xy << ':' << endl;
          for (int k = 0; k < koki; k++) {
            if (xy == kouxy[k]) {
              // cout << "de1" << endl;
              f = 1;
              break;
            }
          }
        } else {
          xy += 1;
          // cout << xy << ':' << endl;
          for (int k = 0; k < koki; k++) {
            if (xy == kouxy[k]) {
              // cout << "de2" << endl;
              f = 1;
              break;
            }
          }
        }
        if (f) {
          break;
        }
        if (xy == goal) {
          route++;
          break;
        }
      }
    }
    cout << route << endl;
  }
  return 0;
}
int p(int x, int y) {
  int c = x;
  for (int i = 1; i < y; i++) {
    x = x * c;
  }
  return x;
}
Problem p00438 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <vector>

int main() {
  std::vector<std::vector<int>> obstacle;
  std::vector<std::vector<int>> road;
  int a, b;

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

    std::vector<std::vector<int>> obstacle(a + 1, std::vector<int>(b + 1, 0));
    std::vector<std::vector<int>> road(a + 1, std::vector<int>(b + 1, 0));

    int tmp_a, tmp_b;
    for (int i = 0; i < obstacleNum; ++i) {
      std::cin >> tmp_a >> tmp_b;
      obstacle[tmp_a][tmp_b] = 1;
    }
    for (int i = 1; i <= a; ++i) {
      for (int j = 1; j <= b; ++j) {
        if (i == 1 && j == 1)
          road[i][j] = 1;
        else if (obstacle[i][j] == 1)
          road[i][j] = 0;
        else
          road[i][j] = road[i - 1][j] + road[i][j - 1];
      }
    }

    std::cout << road[a][b] << std::endl;
  }
  return 0;
}

Error: -11

Fixed submission:

#include <iostream>
#include <vector>

int main() {
  std::vector<std::vector<int>> obstacle;
  std::vector<std::vector<int>> road;
  int a, b;

  while (std::cin >> a >> b) {
    int obstacleNum;
    std::cin >> obstacleNum;

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

    int tmp_a, tmp_b;
    for (int i = 1; i <= obstacleNum; ++i) {
      std::cin >> tmp_a >> tmp_b;
      obstacle[tmp_a - 1][tmp_b - 1] = 1;
    }

    for (int i = 0; i < a; ++i) {
      for (int j = 0; j < b; ++j) {
        if (obstacle[i][j] == 1)
          road[i][j] = 0;
        else if (i == 0 || j == 0)
          road[i][j] = 1;
        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: Time Limit Exceeded

#include <iostream>
using namespace std;

int main() {
  while (1) {
    int a, b;
    cin >> a >> b;
    if (a == 0 && b == 0)
      return 0;
    int krsw[17][17] = {};
    int cross[17][17] = {};
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
      int x, y;
      cin >> x >> y;
      krsw[x][y] = 1;
    }
    for (int i = 1; i <= a; i++) {
      for (int j = 1; j <= b; j++) {
        if (krsw[i][j])
          continue;
        cross[i][j] = cross[i - 1][j] + cross[i][j - 1];
        if (i == 1 && j == 1)
          cross[1][1] = 1;
      }
    }
    cout << cross[a][b] << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  int a, b, n, x, y, tdn[40] = {}, db[40] = {}, yj[16][16] = {};
  cin >> a >> b >> n;
  for (int i = 1; i <= n; i++) {
    cin >> tdn[i] >> db[i];
  }
  yj[1][1] = 1;
  for (int i = 1; i <= a; i++) {
    for (int j = 1; j <= b; i++) {
      yj[i][j] = yj[i - 1][j] + yj[i][j - 1];
      yj[1][1] = 1;
      for (int k = 0; k < n; k++) {
        if (yj[tdn[k]][db[k]] == yj[i][j])
          yj[i][j] = 0;
      }
    }
  }
  cout << yj[a][b] << endl;
  return 0;
}
Problem p00438 (C++) — buggy submission, verdict: Time Limit Exceeded

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

using namespace std;

int FindRoad(const 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(const 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++;
    return 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 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++;
    return 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 <stdio.h>

int main(void) {
  int a, b, n;
  while (scanf("%d%d", &a, &b) && a && b) {
    int x, y;
    int road[32][32] = {0};
    int stop[32][32] = {0};

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

    for (int i = 1; i <= b; i++) {
      for (int j = 1; j <= a; j++) {
        if (stop[i][j] == 0) {
          road[i][j] = road[i - 1][j] + road[i][j - 1];
        }
      }
    }

    printf("%d\\n", road[b][a]);
  }
  return 0;
}

/*
                                        road[i+1][j] += road[i][j];
                                        road[i][j+1] += road[i][j];
                                        */

Error: TLE

Fixed submission:

#include <stdio.h>

int road[17][17];
int stop[17][17];
int a, b, n;
int main(void) {

  while (scanf("%d%d", &a, &b) && a && b) {
    int x, y;
    scanf("%d", &n);
    for (int i = 0; i < 3; i++) {
      scanf("%d%d", &x, &y);
      stop[y - 1][x - 1] = 1;
    }
    road[0][0] = 1;

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

    printf("%d\\n", road[b - 1][a - 1]);
    for (int i = 0; i < b; i++) {
      for (int j = 0; j < a; j++) {
        road[i][j] = 0;
        stop[i][j] = 0;
      }
    }
  }
  return 0;
}