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

#include <iostream>

using namespace std;

int main() {
  int n;
  cin >> n;

  for (int i = 1; i <= n; ++i) {
    int x = i;
    if (x % 3 == 0) {
      cout << " " << i;
      continue;
    } else {
      while (x) {
        if (x % 10 == 3) {
          cout << " " << i;
          break;
        }
        x /= 10;
      }
    }
  }

  cout << endl;
}


Error: TLE

Fixed submission:

#include <iostream>

using namespace std;

int main() {
  int n;
  cin >> n;

  for (int i = 1; i <= n; ++i) {
    int x = i;
    if (x % 3 == 0) {
      cout << " " << i;
      continue;
    } else {
      while (x) {
        if (x % 10 == 3) {
          cout << " " << i;
          continue;
        }
        x /= 10;
      }
    }
  }

  cout << endl;
}
Problem p02406 (C++) — buggy submission, verdict: Time Limit Exceeded

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

void call(int n) {
  int i = 1;

  for (int i = 1; i <= n; i++) {
    if (i % 3 == 0 || i % 10 == 3) {
      cout << " " << i;
    } else {
      int x = i;
      while (x > 10) {
        x /= 10;
        if (x % 10 == 3) {
          cout << " " << i;
          break;
        }
      }
    }
  }
  cout << endl;
}

int main() {
  int n;

  cin >> n;
  call(n);

  return (0);
}

Error: TLE

Fixed submission:

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

void call(int n) {
  int i = 1;

  for (int i = 1; i <= n; i++) {
    if (i % 3 == 0 || i % 10 == 3) {
      cout << " " << i;
    }
  }
  cout << endl;
}

int main() {
  int n;

  while (1) {
    cin >> n;

    if (n == 0) {
      break;
    }

    call(n);
  }

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

#include <cstdio>
int main() {
  int x, n, y;
  scanf("%d", &n);
  for (x = 3; x <= n; x++) {
    y = x;
    if (x % 3 == 0) {
      printf(" %d", x);
    } else if (x % 10 == 3) {
      printf(" %d", x);
    } else {
      while (1) {
        y /= 10;
        if (y % 10 == 3) {
          printf(" %d", x);
          break;
        }
        if (y / 10 == 0) {
          break;
        }
      }
    }
  }
  printf("\\n");
}


Error: TLE

Fixed submission:

#include <cstdio>
int main() {
  int x, n, y;
  scanf("%d", &n);
  for (x = 1; x <= n; x++) {
    if (x % 3 == 0) {
      printf(" ");
      printf("%d", x);
    } else {
      while (1) {
        y = x;

        if (y % 10 == 3) {
          printf(" ");
          printf("%d", x);
        } else {
          y /= 10;
        }
        if (y / 10 == 0) {
          break;
        }
      }
    }
  }
}
Problem p02409 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;
int main() {
  int n;
  cin >> n;
  int count[5][4][11];
  for (int i = 1; i <= 4; i++) {
    for (int j = 1; j <= 3; j++) {
      for (int k = 1; k <= 10; k++) {
        count[i][j][k] = 0;
      }
    }
  }
  int b, f, r, v;
  for (int i = 0; i < n; i++) {
    cin >> b >> f >> r >> v;
    count[b][f][r] += v;
  }

  for (int i = 1; i <= 4; i++) {
    for (int j = 1; j <= 3; j++) {
      for (int k = 1; k <= 10; k++) {
        cout << " " << count[i][j][k];
      }
      cout << endl;
    }
    if (i < 4) {
      for (int l = 0; l < 20; l++) {
        cout << "#";
      }
      cout << endl;
    }
  }
  return 0;
}


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


Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int n;
  cin >> n;
  int count[4][3][10];
  for (int i = 1; i <= 4; i++) {
    for (int j = 1; j <= 3; j++) {
      for (int k = 1; k <= 10; k++) {
        count[i][j][k] = 0;
      }
    }
  }
  int b, f, r, v;
  for (int i = 0; i < n; i++) {
    cin >> b >> f >> r >> v;
    count[b][f][r] += v;
  }

  for (int i = 1; i <= 4; i++) {
    for (int j = 1; j <= 3; j++) {
      for (int k = 1; k <= 10; k++) {
        cout << " " << count[i][j][k];
      }
      cout << endl;
    }
    if (i < 4) {
      for (int l = 0; l < 20; l++) {
        cout << "#";
      }
      cout << endl;
    }
  }
  return 0;
}
Problem p02409 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>

using namespace std;

int main() {
  int rooms[4][3][10]; // ○棟○階○部屋
  int n;
  int b[999], f[999], r[999], v[999]; // b棟f階r番目v人　(v<0の場合退去)

  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 10; k++) {
        rooms[i][j][k] = 0;
      }
    }
  }

  cin >> n;

  for (int l = 0; l < n; l++) {
    cin >> b[l] >> f[l] >> r[l] >> v[l];
    rooms[b[l] - 1][f[l] - 1][r[l] - 1] =
        rooms[b[l] - 1][f[l] - 1][r[l] - 1] + v[l];
  }

  for (int p = 0; p < 3; p++) {
    for (int m = 0; m < 3; m++) {
      for (int o = 0; o < 10; o++) {
        cout << " " << rooms[p][m][o];
      }
      cout << endl;
    }
    cout << "####################" << endl;
  }

  for (int q = 0; q < 3; q++) {
    for (int r = 0; r < 10; r++) {
      cout << " " << rooms[3][q][r];
    }
    cout << endl;
  }

  return 0;
}


Error: 0

Fixed submission:

#include <iostream>

using namespace std;

int main() {
  int rooms[4][3][10]; // ○棟○階○部屋
  int n;
  int b[120], f[120], r[120], v[120]; // b棟f階r番目v人　(v<0の場合退去)

  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 10; k++) {
        rooms[i][j][k] = 0;
      }
    }
  }

  cin >> n;

  for (int l = 0; l < n; l++) {
    cin >> b[l] >> f[l] >> r[l] >> v[l];
    rooms[b[l] - 1][f[l] - 1][r[l] - 1] =
        rooms[b[l] - 1][f[l] - 1][r[l] - 1] + v[l];
  }

  for (int p = 0; p < 3; p++) {
    for (int m = 0; m < 3; m++) {
      for (int o = 0; o < 10; o++) {
        cout << " " << rooms[p][m][o];
      }
      cout << endl;
    }
    cout << "####################" << endl;
  }

  for (int q = 0; q < 3; q++) {
    for (int r = 0; r < 10; r++) {
      cout << " " << rooms[3][q][r];
    }
    cout << endl;
  }

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

#include <iostream>
using namespace std;
int main() {
  int n, b, f, r, a, v[4][3][10];
  bool x[4][3][10] = {};
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> b >> f >> r >> a;
    if (x[b - 1][f - 1][r - 1])
      v[b - 1][f - 1][r - 1] += a;
    else {
      x[b - 1][f - 1][r - 1] = true;
      v[b - 1][f - 1][r - 1] = a;
    }
  }
  for (int s = 0; s < 4; s++) {
    for (int j = 0; j < 3; j++) {
      for (int t = 0; t < 10; t++) {
        if (x[s][j][t])
          cout << ' ' << v[s][j][t];
        else
          cout << ' ' << 0;
      }
      cout << endl;
    }
    if (s == 3)
      break;
    cout << "####################" << endl;
  }
  return 0;
}

Error: 0

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int n, b, f, r, v[4][3][10];
  bool x[4][3][10] = {};
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> b >> f >> r >> v[b - 1][f - 1][r - 1];
    switch (b) {
    case 1:
      switch (f) {
      case 1:
        x[0][0][r - 1] = true;
        break;
      case 2:
        x[0][1][r - 1] = true;
        break;
      case 3:
        x[0][2][r - 1] = true;
        break;
      }
      break;
    case 2:
      switch (f) {
      case 1:
        x[1][0][r - 1] = true;
        break;
      case 2:
        x[1][1][r - 1] = true;
        break;
      case 3:
        x[1][2][r - 1] = true;
        break;
      }
      break;
    case 3:
      switch (f) {
      case 1:
        x[2][0][r - 1] = true;
        break;
      case 2:
        x[2][1][r - 1] = true;
        break;
      case 3:
        x[2][2][r - 1] = true;
        break;
      }
      break;
    case 4:
      switch (f) {
      case 1:
        x[3][0][r - 1] = true;
        break;
      case 2:
        x[3][1][r - 1] = true;
        break;
      case 3:
        x[3][2][r - 1] = true;
        break;
      }
      break;
    }
  }
  for (int s = 0; s < 4; s++) {
    for (int j = 0; j < 3; j++) {
      for (int t = 0; t < 10; t++) {
        if (x[s][j][t])
          cout << ' ' << v[s][j][t];
        else
          cout << ' ' << 0;
      }
      cout << endl;
    }
    if (s == 3)
      break;
    cout << "####################" << endl;
  }
  return 0;
}
Problem p02409 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;
int main() {
  int n, c[120], b, f, r, v, t;
  cin >> n;
  for (int i = 0; i < 120; i++) {
    c[i] = 0;
  }
  for (int i = 0; i < n; i++) {
    cin >> b >> f >> r >> v;
    c[(b - 1) * 30 + (f - 1) * 10 + r - 1] += v;
  }
  for (int i = 0; i < 15; i++) {
    if (i % 4 == 3) {
      cout << "####################" << endl;
    } else {
      t = i - i / 4;
      for (int j = 0; j < 10; j++) {
        cout << " " << c[t * 10 + j];
      }
      cout << endl;
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int n, c[120], b, f, r, v, t;
  cin >> n;
  for (int i = 0; i < 120; i++) {
    c[i] = 0;
  }
  for (int i = 0; i < n; i++) {
    cin >> b >> f >> r >> v;
    c[(b - 1) * 30 + (f - 1) * 10 + r - 1] += v;
  }
  for (int i = 0; i < 15;) {
    if (i % 4 == 3) {
      cout << "####################" << endl;
    } else {
      t = i - i / 4;
      for (int j = 0; j < 10; j++) {
        cout << c[t * 10 + j];
      }
      cout << endl;
    }
  }
  return 0;
}
Problem p02409 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;

int main() {
  int n, b, f, r, v;
  int count[5][4][11] = {};
  cin >> n;
  for (int l = 1; l <= n; ++l) {
    cin >> b >> f >> r >> v;
    count[b][f][r] += v;
  }

  for (int i = 1; i <= 4; ++i) {
    for (int j = 1; j <= 3; ++j) {
      for (int k = 1; k <= 10; ++k) {
        cout << " " << count[i][j][k];
      }
      cout << endl;
    }
    if (i != 4)
      cout << "####################" << endl;
  }
  return 0;
}

Error: WA

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  int n, b, f, r, v;
  int count[5][4][11] = {};
  cin >> n;
  for (int l = 1; l <= n; ++l) {
    cin >> b >> f >> r >> v;
    count[b][f][r] = v;
  }

  for (int i = 1; i <= 5; ++i) {
    for (int j = 1; j <= 4; ++j) {
      for (int k = 1; k <= 11; ++k) {
        cout << " " << count[i][j][k] << "\\n";
      }
    }
    cout << "##################" << endl;
  }
  return 0;
}
Problem p02409 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;

int main() {
  int n, part, story, num, resi;
  cin >> n;
  int info[5][4][11];

  //?????????
  for (int s = 1; s <= 4; s++) {
    for (int k = 1; k <= 3; k++) {
      for (int t = 1; t <= 10; t++) {
        info[s][k][t] = 0;
      }
    }
  }

  //?????????????????????????´?
  for (int i = 0; i < n; i++) {
    cin >> part >> story >> num >> resi;
    info[part][story][num] += resi;
  }

  //??????????????????
  for (int a = 1; a <= 4; a++) {
    for (int b = 1; b <= 3; b++) {
      for (int c = 1; c <= 10; c++) {
        cout << " " << info[a][b][c];
      }
      cout << endl;
    }
    if (a != 4)
      cout << "####################" << endl;
  }
  return 0;
}

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


Fixed submission:

#include <iostream>
using namespace std;

int main() {
  int n, part, story, num, resi;
  cin >> n;
  int info[5][4][11];

  //?????????
  for (int s = 0; s <= 5; s++) {
    for (int k = 0; k <= 4; k++) {
      for (int t = 0; t <= 11; t++) {
        info[s][k][t] = 0;
      }
    }
  }

  //?????????????????????????´?
  for (int i = 0; i < n; i++) {
    cin >> part >> story >> num >> resi;
    info[part][story][num] += resi;
  }

  //??????????????????
  for (int a = 1; a <= 4; a++) {
    for (int b = 1; b <= 3; b++) {
      for (int c = 1; c <= 10; c++) {
        cout << " " << info[a][b][c];
      }
      cout << endl;
    }
    if (a != 4)
      cout << "####################" << endl;
  }

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

#include <stdio.h>
#include <string.h>
int main() {
  int a[4][3][10];
  int b, f, r, v;
  int i, j, k;
  int n;
  for (i = 0; i < 4; i++)
    for (j = 0; j < 3; j++)
      for (k = 0; k < 10; k++)
        a[i][j][k] = 0;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    scanf(" %d %d %d %d", &b, &f, &r, &v);
    a[b - 1][f - 1][r - 1] = a[b - 1][f - 1][r - 1] + v;
  }
  for (i = 0; i < 4; i++) {
    for (j = 0; j < 3; j++) {
      for (k = 0; k < 10; k++) {
        printf(" %d", a[i][j][k]);
      }
      printf("\\n");
    }
    if (i < 3)
      printf("####################\\n");
  }
  return 0;
}

Error: -11

Fixed submission:

#include <stdio.h>
#include <string.h>
int main() {
  int a[4][3][10];
  int i, j, k;
  int b, f, r, v;
  int n;
  for (i = 0; i < 4; i++)
    for (j = 0; j < 3; j++)
      for (k = 0; k < 10; k++)
        a[i][j][k] = 0;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    scanf(" %d %d %d %d", b, f, r, v);
    a[b][f][r] = v;
  }
  for (i = 0; i < 4; i++) {
    for (j = 0; j < 3; j++) {
      for (k = 0; k < 10; k++) {
        printf("%d", a[k][j][i]);
      }
      printf("\\n");
    }
    printf("####################\\n");
  }
  return 0;
}
Problem p02409 (C++) — buggy submission, verdict: Runtime Error

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

int main() {

  int n;
  cin >> n;

  int a[4][3][10] = {};

  for (int i = 0; i < n; i++) {
    int b, f, r, v;
    cin >> b >> f >> r >> v;
    a[b - 1][f - 1][r - 1] += v;
  }

  for (int i = 0; i < 4; i++) {
    if (i)
      cout << "####################" << endl;

    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 10; k++) {
        cout << " " << a[i][j][k];
      }
      cout << endl;
    }
  }

  return 0;
}


Error: -11

Fixed submission:

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

int main() {

  int n;
  cin >> n;
  int b = 0, f = 0, r = 0, v = 0;
  int a[4][3][10];

  for (int i = 0; i < n; i++) {

    cin >> b >> f >> r >> v;
    a[b][f][r] += v;
  }

  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 3; i++) {
      for (int k = 0; k < 10; i++) {
        cout << a[i][j][k] << " ";
      }
      cout << endl;
    }
    for (int l = 0; l <= 20; l++) {
      cout << "#" << endl;
    }
  }
}
Problem p02409 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;
int main(void) {
  // Your code here!
  int hum[4][3][10];
  for (int b = 0; b < 4; b++) {
    for (int f = 0; f < 3; f++) {
      for (int side = 0; side < 10; side++) {
        hum[b][f][side] = 0;
      }
    }
  }
  int n, b, f, side, ninzu;
  cin >> n;
  ninzu = 0;
  for (int all = 0; all < n; all++) {
    cin >> b >> f >> side >> ninzu;
    if (b == 1) {
      hum[0][f - 1][side - 1] += ninzu;
    }
    if (b == 2) {
      hum[1][f - 1][side - 1] += ninzu;
    }
    if (b == 3) {
      hum[2][f - 1][side - 1] += ninzu;
    }
    if (b == 4) {
      hum[3][f - 1][side - 1] += ninzu;
    }
  }
  for (int b = 0; b < 4; b++) {
    for (int f = 0; f < 3; f++) {
      for (int side = 0; side < 10; side++) {
        cout << " " << hum[b][f][side];
      }
      cout << endl;
    }
    if (b == 3) {
      break;
    }
    for (int s = 0; s < 20; s++) {
      cout << "#";
    }
    cout << endl;
  }
}


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


Fixed submission:

#include <iostream>
using namespace std;
int main(void) {
  // Your code here!
  int hum[4][3][10];
  for (int b = 0; b <= 4; b++) {
    for (int f = 0; f < 3; f++) {
      for (int side = 0; side < 10; side++) {
        hum[b][f][side] = 0;
      }
    }
  }
  int n, b, f, side, ninzu;
  cin >> n;
  ninzu = 0;
  for (int all = 0; all < n; all++) {
    cin >> b >> f >> side >> ninzu;
    if (b == 1) {
      hum[0][f - 1][side - 1] = ninzu;
    }
    if (b == 2) {
      hum[1][f - 1][side - 1] = ninzu;
    }
    if (b == 3) {
      hum[2][f - 1][side - 1] = ninzu;
    }
    if (b == 4) {
      hum[3][f - 1][side - 1] = ninzu;
    }
  }
  for (int b = 0; b < 4; b++) {
    for (int f = 0; f < 3; f++) {
      for (int side = 0; side < 10; side++) {
        cout << hum[b][f][side] << " ";
      }
      cout << endl;
    }
    if (b == 3) {
      break;
    }
    for (int s = 0; s < 20; s++) {
      cout << "#";
    }
    cout << endl;
  }
}
Problem p02409 (C++) — buggy submission, verdict: Runtime Error

#include <cstdio>
int main() {
  int n, b, f, r, v;
  int rooms[4][3][10] = {};

  scanf("%d", &n);
  int infos[n][4];
  for (int i = 0; i < n; i++) {
    scanf("%d%d%d%d", &infos[i][0], &infos[i][1], &infos[i][2], &infos[i][3]);
  }
  for (int i = 0; i < n; i++) {
    rooms[infos[i][0] - 1][infos[i][1] - 1][infos[i][2] - 1] += infos[i][3];
  }
  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 10; k++) {
        printf(" %d", rooms[i][j][k]);
      }
      printf("\\n");
    }
    if (i != 3)
      printf("####################\\n");
  }
  return 0;
}

Error: -11

Fixed submission:

#include <cstdio>
int main() {
  int n, b, f, r, v;
  int rooms[4][3][10] = {};

  scanf("%d", &n);
  int infos[n][4];
  for (int i = 0; i < n; i++) {
    scanf("%d%d%d%d", infos[i][0], infos[i][1], infos[i][2], infos[i][3]);
  }
  for (int i = 0; i < n; i++) {
    rooms[infos[i][0] - 1][infos[i][1] - 1][infos[i][2] - 1] += infos[i][3];
  }
  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 10; k++) {
        printf(" %d", rooms[i][j][k]);
      }
      printf("\\n");
    }
    if (i != 3)
      printf("####################\\n");
  }
  return 0;
}
Problem p02409 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int n, b, f, r, v;
  int R[5][4][11];
  cin >> n;
  for (int i = 1; i < 5; i++) {
    for (int j = 1; j < 4; j++) {
      for (int k = 1; k < 11; k++) {
        R[i][j][k] = 0;
      }
    }
  }
  for (int l = 0; l < n; l++) {
    cin >> b >> f >> r >> v;
    R[b][f][r] += v;
  }
  for (int i = 1; i < 5; i++) {
    for (int j = 1; j < 4; j++) {
      for (int k = 1; k < 11; k++) {
        cout << " " << R[i][j][k];
        if (k == 10) {
          cout << endl;
          if (j == 3) {
            if (i == 1 || i == 2 || i == 3) {
              cout << "####################" << endl;
            }
          }
        }
      }
    }
  }
  return 0;
}

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


Fixed submission:

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

int main() {
  int n, b, f, r, v;
  int R[4][3][10];
  for (int i = 1; i <= 4; i++) {
    for (int j = 1; j <= 3; j++) {
      for (int k = 1; k <= 10; k++) {
        R[i][j][k] = 0;
      }
    }
  }
  cin >> n;
  for (int l = 0; l < n; l++) {
    cin >> b >> f >> r >> v;
    R[b][f][r] += v;
  }
  for (int i = 1; i <= 4; i++) {
    for (int j = 1; j <= 3; j++) {
      for (int k = 1; k <= 10; k++) {
        cout << " " << R[i][j][k];
      }
    }
  }
  return 0;
}
Problem p02409 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>
using namespace std;
int main() {
  int count[4][3][10];
  int j, k, l;
  for (j = 0; j < 4; j++) {
    for (k = 0; k < 3; k++) {
      for (l = 0; l < 10; l++) {
        count[j][k][l] = 0;
      }
    }
  }

  int n;
  cin >> n;
  int i;
  for (i = 0; i < n; i++) {
    int b, f, r, v;
    cin >> b >> f >> r >> v;
    count[b - 1][f - 1][r - 1] += v;
  }
  j, k, l = 0, 0, 0;

  for (j = 0; j < 4; j++) {
    for (k = 0; k < 3; k++) {
      for (l = 0; l < 10; l++) {
        cout << " " << count[j][k][l];
      }
      cout << "\\n";
    }
    if (j != 3) {
      cout << "####################"
           << "\\n";
    } else {
    }
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>
using namespace std;
int main() {
  int count[4][3][10];
  int j, k, l;
  for (j = 0; j < 4; j++) {
    for (k = 0; k < 3; k++) {
      for (l = 0; j < 10; l++) {
        count[j][k][l] = 0;
      }
    }
  }

  int n;
  cin >> n;
  int i;
  for (i = 0; i < n; i++) {
    int b, f, r, v;
    cin >> b, f, r, v;
    count[j][k][l] = 0;
    count[b - 1][f - 1][r - 1] += v;
  }

  for (j = 0; j < 4; j++) {
    for (k = 0; k < 3; k++) {

      for (l = 0; l < 10; l++) {

        if (l != 9) {
          cout << count[j][k][l] << " ";
        } else {
          cout << count[j][k][l] << endl;
        }
      }
    }
    if (j != 3) {
      cout << "####################" << endl;
    } else {
    }
  }
  return 0;
}
Problem p02409 (C++) — buggy submission, verdict: Runtime Error

#include <cstdio>
#include <iostream>
#include <stdio.h>
using namespace std;

int main() {
  int room[4][3][10] = {{{}}};
  int n;
  int block, floor, number, people;
  char c;

  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> block >> floor >> number >> people;

    room[block - 1][floor - 1][number - 1] += people;
  }

  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 10; k++) {

        cout << " " << room[i][j][k];
      }
      cout << endl;
    }
    if (i != 3) {
      cout << "####################" << endl;
    }
  }
  return 0;
}


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


Fixed submission:

#include <cstdio>
#include <iostream>
#include <stdio.h>
using namespace std;

int main() {
  int room[4][3][10] = {{{}}};
  int n;
  int block, floor, number, people;
  char c;

  for (int i = 0; i <= 4; i++) {
    for (int j = 0; j <= 3; j++) {
      for (int k = 0; k <= 13; k++) {
        room[i][j][k] = 0;
      }
    }
  }

  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> block >> floor >> number >> people;
    room[block - 1][floor - 1][number - 1] = people;
  }

  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 13; k++) {

        cout << " " << room[i][j][k];
      }
      cout << endl;
    }
    if (i != 3) {
      cout << "####################" << endl;
    }
  }
  return 0;
}
Problem p02409 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;
int main() {
  int n, i, j, k;
  int b, f, r, v;
  int house[4][3][10] = {};

  cin >> n;

  for (i = 0; i < n; i++) {
    cin >> b >> f >> r >> v;
    house[b - 1][f - 1][r - 1] = house[b - 1][f - 1][r - 1] + v;
  }

  for (i = 0; i < 4; i++) {
    for (j = 0; j < 3; j++) {
      for (k = 0; k < 10; k++) {
        if (house[i][j][k] < 0) {
          cout << 0;
        }
        if (house[i][j][k] > 9) {
          cout << 9;
        } else {
          cout << " " << house[i][j][k];
        }
      }
      cout << endl;
    }
    if (i == 3) {
      break;
    }
    cout << "####################" << endl;
  }

  return 0;
}

Error: -11

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int n, i;
  int b[100], f[100], r[100], v[100];
  int count[4][3][10];

  cin >> n;

  for (i = 0; i < n; i++) {
    cin >> b[i] >> f[i] >> r[i] >> v[i];
  }

  for (i = 0; i < 4; i++) {
    for (i = 0; i < 3; i++) {
      for (i = 0; i < 10; i++) {
        count[b[i]][f[i]][r[i]] = 0;
      }
    }
  }

  for (i = 0; i < n; i++) {
    count[b[i]][f[i]][r[i]] = count[b[i]][f[i]][r[i]] + v[i];
  }

  for (i = 0; i < 3; i++) {
    for (i = 0; i < 3; i++) {
      for (i = 0; i < 10; i++) {
        cout << count[b[i]][f[i]][r[i]];
      }
      cout << endl;
    }
    cout << "####################" << endl;
  }

  for (i = 0; i < 3; i++) {
    for (i = 0; i < 10; i++) {
      cout << count[b[i]][f[i]][r[i]];
    }
    cout << endl;
  }

  return 0;
}