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

#include <iostream>
#include <math.h>
#include <stack>
#include <stdio.h>
#include <stdlib.h>

using namespace std;

int main() {
  int n;
  int a[10][3][4];
  int i, j, k;
  int b, f, r, v;

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

  cin >> n;

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

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

  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
#include <math.h>
#include <stack>
#include <stdio.h>
#include <stdlib.h>

using namespace std;

int main() {
  int n;
  int a[10][3][4];
  int i, j, k;
  int b, f, r, v;

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

  cin >> n;

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

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

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

#include <iostream>
using namespace std;

int main() {
  // Variable declaration
  unsigned int n, b, f, r = 0;
  int v, temp;
  unsigned int resident[4][3][10];

  string inptn;
  int innum;

  // Initializ resident.
  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 10; k++) {
        resident[i][j][k] = 0;
      }
    }
  }

  // Input n
  cin >> n;

  // Input
  // n times loop
  for (int cnt = 0; cnt < n; cnt++) {
    // Input b, f, r, v
    cin >> b >> f >> r >> v;

    // Out of range
    if (b < 1 || b > 4 || f < 1 || f > 3 || r < 1 || r > 10) {
      cnt--;
      continue;
    }

    // Copy the resident before updating.
    temp = resident[b - 1][f - 1][r - 1];

    // Update resident
    resident[b - 1][f - 1][r - 1] += v;

    // Out of range
    if (resident[b - 1][f - 1][r - 1] < 0 ||
        resident[b - 1][f - 1][r - 1] > 9) {
      // Back to the value before the update.
      resident[b - 1][f - 1][r - 1] = temp;
      cnt--;
      continue;
    }
  }

  // Output
  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 10; k++) {
        cout << " " << resident[i][j][k];
      }
      cout << endl;
    }
    if (i < 3) {
      cout << "####################" << endl;
    }
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  // Variable declaration
  unsigned int n, b, f, r = 0;
  unsigned int temp = 0;
  int v;
  unsigned int resident[4][3][10];

  string inptn;
  int innum;

  // Initializ resident.
  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 10; k++) {
        resident[i][j][k] = 0;
      }
    }
  }

  // Input n
  cin >> n;

  // Input
  // n times loop
  for (int cnt = 0; cnt < n; cnt++) {
    // Input b, f, r, v
    cin >> b >> f >> r >> v;

    // Out of range
    if (b < 1 || b > 4 || f < 1 || f > 3 || r < 1 || r > 10 || v > 9 ||
        v < -9) {
      cnt--;
      continue;
    }
    // Copy the resident before updating.
    temp = resident[b][f][r];

    // Update resident
    resident[b][f][r] += v;

    // Out of range
    if (resident[b][f][r] < 0 || resident[b][f][r] > 9) {
      // Back to the value before the update.
      resident[b][f][r] = temp;
      cnt--;
      continue;
    }
  }

  // Output
  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 10; k++) {
        cout << " " << resident[i][j][k];
      }
    }
    if (i < 3) {
      cout << "####################" << endl;
    }
  }

  cout << endl;

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

#include <algorithm>
#include <math.h>
#include <stdio.h>

int main() {
  int x[5][4][11] = {0};
  int n, b, f, r, v;

  scanf("%d", &n);

  for (int m = 1; m <= n; m++) {
    scanf("%d %d %d %d", &b, &f, &r, &v);
    x[b][f][r] += v;
  }

  for (int m = 1; m <= 4; m++) {
    for (int n = 1; n <= 3; n++) {
      for (int l = 1; l <= 10; l++) {

        printf(" %d", x[m][n][l]);
      }
      printf("\\n");
    }
    if (m != 4) {
      printf("####################\\n");
    }
  }
  return 0;
}

Error: -11

Fixed submission:

#include <stdio.h>

int main() {
  int n, m, b, f, r, v, x[4][3][10];
  b = 1;
  f = 1;
  r = 1;
  v = 0;

  while (b <= 4) {
    while (f <= 3) {
      while (r <= 10) {
        x[b][f][r] = 0;
        r++;
      }
      r = 1;
      f++;
    }
    f = 1;
    b++;
  }
  b = 1;

  scanf("%d", &n);

  for (m = 1; m <= n; m++) {
    scanf("%d %d %d %d", b, f, r, v);
    x[b][f][r] = r;
  }

  b = 1;
  f = 1;
  r = 1;

  while (b <= 4) {
    while (f <= 3) {
      while (r <= 10) {
        printf("%d", x[b][f][r]);
        r++;
      }
      printf("\\n");
      r = 1;
      f++;
    }
    if (b <= 3) {
      printf("####################\\n");
    }
    f = 1;
    b++;
  }
  b = 1;

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

#include <iostream>
using namespace std;

int main() {
  int n;
  int b, f, r, v;
  int count[4][3][10];

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

  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> b >> f >> r >> v;
    count[b - 1][f - 1][r - 1] += v;
  }
  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 10; k++) {
        cout << " ";
        cout << count[i][j][k];
      }
      cout << endl;
    }
    if (i < 3)
      cout << "####################" << endl;
  }
  return 0;
}


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


Fixed submission:

#include <iostream>
using namespace std;

int main() {
  int n;
  int b, f, r, v;
  int count[4][3][10];

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

  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> b >> f >> r >> v;
    if (v != 0) {
      count[b - 1][f - 1][r - 1] += v;
    }
  }
  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 10; k++) {
        cout << " ";
        cout << count[i][j][k];
      }
      cout << endl;
    }
    cout << "##########" << endl;
  }
  return 0;
}
Problem p02409 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <queue>
#include <stack>
#include <stddef.h>
#include <string>

using namespace std;

int main() {
  int n;
  int b[1000];
  int f[1000];
  int r[1000];
  int v[1000];
  int k[1000];
  int room[11][13];
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> b[i] >> f[i] >> r[i] >> v[i];
  }
  for (int i = 0; i < n; i++) {
    k[i] = (b[i] - 1) * 3 + f[i];
  }
  for (int i = 1; i <= 10; i++) {
    for (int j = 1; j <= 12; j++) {
      room[i][j] = 0;
    }
  }
  for (int i = 0; i < n; i++) {
    room[r[i]][k[i]] += v[i];
  }
  for (int i = 1; i <= 12; i++) {
    if (i % 3 == 1 && i != 1)
      cout << "####################" << endl;
    for (int j = 1; j <= 10; j++) {
      cout << ' ' << room[j][i];
    }
    cout << endl;
  }
  cin >> n;
}

Error: 0

Fixed submission:

#include <iostream>
#include <queue>
#include <stack>
#include <stddef.h>
#include <string>

using namespace std;

int main() {
  int n;
  int b[100];
  int f[100];
  int r[100];
  int v[100];
  int k[100];
  int room[11][13];
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> b[i] >> f[i] >> r[i] >> v[i];
  }
  for (int i = 0; i < n; i++) {
    k[i] = (b[i] - 1) * 3 + f[i];
  }
  for (int i = 1; i <= 10; i++) {
    for (int j = 1; j <= 12; j++) {
      room[i][j] = 0;
    }
  }
  for (int i = 0; i < n; i++) {
    room[r[i]][k[i]] += v[i];
  }
  for (int i = 1; i <= 12; i++) {
    if (i % 3 == 1 && i != 1)
      cout << "####################" << endl;
    for (int j = 1; j <= 10; j++) {
      cout << ' ' << room[j][i];
    }
    cout << endl;
  }
  cin >> n;
}
Problem p02409 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

int main() {
  int rooms[5][4][11], n;

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

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

  for (int b = 1; b <= 4; b++) {
    if (b > 1)
      cout << "####################"
           << "\\n";
    for (int f = 1; f <= 3; f++) {
      for (int r = 1; r <= 10; r++) {
        cout << " " << rooms[b][f][r];
      }
      cout << endl;
    }
  }

  return 0;
}


Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  int rooms[5][4][11], n;

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

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

  for (int f = 1; f <= 4; f++) {
    if (f > 1)
      cout << "####################"
           << "\\n";
    for (int b = 1; b <= 3; b++) {
      for (int r = 1; r <= 10; r++) {
        cout << " " << rooms[f][b][r];
      }
      cout << endl;
    }
  }

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

#include <iostream>

int main() {
  int n;
  int a[4][3][10] = {0};
  int b, f, r, v;
  std::cin >> n;

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

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

Error: TLE

Fixed submission:

#include <iostream>

int main() {
  int n;
  std::cin >> n;
  int a[4][3][10] = {0};
  int b, f, r, v;

  int count = 0;
  while (n > count) {
    std::cin >> b;
    std::cin >> f;
    std::cin >> r;
    std::cin >> v;
    if (a[b][f][r] >= 0) {
      a[b - 1][f - 1][r - 1] += v;
      count++;
    } else
      continue;
  }

  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 10; k++) {
        std::cout << " " << a[i][j][k];
      }
      std::cout << std::endl;
    }
    if (i < 3)
      std::cout << "####################" << std::endl;
  }
}
Problem p02409 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>

int main(void) {
  using namespace std;
  int auni[4][3][10];
  int i, j, k;
  for (i = 0; i < 4; i++) {
    for (j = 0; j < 3; j++) {
      for (k = 0; k < 10; k++) {
        auni[i][j][k] = 0;
      }
    }
  }
  int n, b, f, r, v;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> b >> f >> r >> v;
    auni[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++) {
        cout << ' ' << auni[i][j][k];
      }
      cout << endl;
    }
    if (i == 3)
      continue;
    cout << "####################" << endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>

int main(void) {
  using namespace std;
  int auni[4][3][10];
  int i, j, k;
  for (i = 0; i < 4; i++) {
    for (j = 0; j < 3; j++) {
      for (k = 0; k < 10; k++) {
        auni[i][j][k] = 0;
      }
    }
  }
  int n, b, f, r, v;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> b >> f >> r >> v;
    auni[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++) {
        cout << ' ' << auni[i][j][k];
      }
      cout << endl;
    }
    if (i == 3)
      continue;
    cout << "####################" << endl;
  }
  while (true)
    ;
  return 0;
}
Problem p02409 (C++) — buggy submission, verdict: Runtime Error

#include <cstdio>

int main() {
  int b, f, r, m, n, i, v;
  int hou[4][3][10];
  for (b = 0; b < 4; b++) {
    for (f = 0; f < 3; f++) {
      for (r = 0; r < 10; r++) {
        hou[b][f][r] = 0;
      }
    }
  }
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d %d %d %d", &b, &f, &r, &v);
    b -= 1;
    f -= 1;
    r -= 1;
    hou[b][f][r] += v;
  }
  for (b = 0; b < 4; b++) {
    if (b != 0) {
      printf("####################\\n");
    }
    for (f = 0; f < 3; f++) {
      for (r = 0; r < 10; r++) {
        printf(" %d", hou[b][f][r]);
      }
      printf("\\n");
    }
  }
}


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


Fixed submission:

#include <cstdio>

int main() {
  int b, f, r, m, n, i, v;
  int hou[4][3][10];
  for (b = 1; b < 5; b++) {
    for (f = 1; f < 4; f++) {
      for (r = 1; r < 11; r++) {
        hou[b][f][r] = 0;
      }
    }
  }
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d %d %d %d", &b, &f, &r, &v);
    hou[b][f][r] += v;
  }
  for (b = 1; b < 5; b++) {
    for (f = 1; f < 4; f++) {
      for (r = 1; r < 11; r++) {
        printf(" %d", hou[b][f][r]);
      }
      printf("\\n");
    }
    printf("####################\\n");
  }
  return 0;
}
Problem p02409 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;

int main() {
  int a[4][3][10] = {{{}}};
  int n, b, f, r, v;

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

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


Error: WA

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  int a[4][3][10] = {{{}}};
  int n, b, f, r, v;

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

  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 10; k++) {
        if (b == i && f == j && r == k)
          a[i][j][k] += v;
      }
    }
  }
  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 4; j++) {
      for (int k = 0; k < 10; k++) {
        cout << a[i][j][k];
        if (j == 3)
          cout << "#";
      }
      cout << endl;
    }
  }
  return 0;
}
Problem p02409 (C++) — buggy submission, verdict: Runtime Error

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

  std::cin >> n;

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

  for (int k = 0; k <= 3; k++) {
    for (int l = 0; l <= 2; l++) {
      for (int m = 0; m <= 9; m++) {
        std::cout << " " << a[k][l][m];
      }
      std::cout << std::endl;
    }
    if (k != 3) {
      for (int x = 1; x <= 20; x++) {
        std::cout << "#";
      }
      std::cout << std::endl;
    }
  }
}


Error: WA

Fixed submission:

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

  std::cin >> n;

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

  for (int k = 1; k <= 4; k++) {
    for (int l = 1; l <= 3; l++) {
      for (int m = 1; m <= 10; m++) {
        std::cout << " " << a[k][l][m];
      }
      std::cout << std::endl;
    }
    if (k != 4) {
      for (int x = 1; x <= 20; x++) {
        std::cout << "#";
      }
      std::cout << std::endl;
    }
  }
}
Problem p02409 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <string>
using namespace std;
int main() {
  int n, b, f, r, v, ro[4][3][10];
  for (int i = 0; i < 4; i++)
    for (int j = 0; j < 3; j++)
      for (int k = 0; k < 10; k++)
        ro[i][j][k] = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> b >> f >> r >> v;
    ro[b - 1][f - 1][r - 1] += v;
  }
  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 10; k++) {
        cout << " " << ro[i][j][k];
      }
      cout << endl;
    }
    if (i != 3) {
      for (int j = 0; j < 20; j++)
        cout << "#";
      cout << endl;
    }
  }
  return 0;
}


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


Fixed submission:

#include <iostream>
#include <string>
using namespace std;
int main() {
  int n, b, f, r, v, ro[3][4][10];
  for (int i = 0; i < 4; i++)
    for (int j = 0; j < 3; j++)
      for (int k = 0; k < 10; k++)
        ro[i][j][k] = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> b >> f >> r >> v;
    ro[b - 1][f - 1][r - 1] += v;
  }
  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 10; k++) {
        cout << " " << ro[i][j][k];
      }
      cout << endl;
    }
    if (i != 3) {
      for (int j = 0; j < 20; j++)
        cout << "#";
      cout << endl;
    }
  }
  return 0;
}
Problem p02409 (C++) — buggy submission, verdict: Runtime Error

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

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

  for (int building = 1; building <= 4; building++) {
    for (int floor = 1; floor <= 3; floor++) {
      for (int room = 1; room <= 10; room++) {
        int t = 0;
        for (int i = 0; i < n; i++) {
          if (b[i] == building && f[i] == floor && r[i] == room)
            t += v[i];
        }
        cout << ' ' << t;
      }
      cout << endl;
    }
    if (building == 4)
      break;
    cout << "####################" << endl;
  }
  return 0;
}


Error: 0

Fixed submission:

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

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

  for (int building = 1; building <= 4; building++) {
    for (int floor = 1; floor <= 3; floor++) {
      for (int room = 1; room <= 10; room++) {
        int t = 0;
        for (int i = 0; i < n; i++) {
          if (b[i] == building && f[i] == floor && r[i] == room)
            t += v[i];
        }
        cout << ' ' << t;
      }
      cout << endl;
    }
    if (building == 4)
      break;
    cout << "####################" << endl;
  }
  return 0;
}
Problem p02409 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <utility>
#include <vector>

const long long int Z = 1000000007;
const long long int INF = 1 << 30;
int flag = 0;
using ll = long long;

ll gcd(ll a, ll b) {
  if (b == 0)
    return a;
  return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
  ll g = gcd(a, b);
  return a / g * b;
}

int main() {
  int n, a[100][100] = {0}, b[100][100] = {0}, c[100][100] = {0},
         d[100][100] = {0};
  std::cin >> n;
  for (int i = 0; i < n; i++) {
    int x, y, z, v;
    std::cin >> x >> y >> z >> v;
    if (x == 1) {
      a[y][z] += v;
    }
    if (x == 2) {
      b[y][z] += v;
    }
    if (x == 3) {
      c[y][z] += v;
    }
    if (x == 4) {
      d[y][z] += v;
    }
  }
  for (int i = 1; i <= 3; i++) {
    std::cout << ' ';
    for (int j = 1; j <= 10; j++) {
      std::cout << a[i][j];
      if (j == 10)
        break;
      std::cout << ' ';
    }
    std::cout << std::endl;
  }
  std::cout << "####################" << std::endl;
  for (int i = 1; i <= 3; i++) {
    std::cout << ' ';
    for (int j = 1; j <= 10; j++) {
      std::cout << b[i][j];
      if (j == 10)
        break;
      std::cout << ' ';
    }
    std::cout << std::endl;
  }
  std::cout << "####################" << std::endl;
  for (int i = 1; i <= 3; i++) {
    std::cout << ' ';
    for (int j = 1; j <= 10; j++) {
      std::cout << c[i][j];
      if (j == 10)
        break;
      std::cout << ' ';
    }
    std::cout << std::endl;
  }
  std::cout << "####################" << std::endl;
  for (int i = 1; i <= 3; i++) {
    std::cout << ' ';
    for (int j = 1; j <= 10; j++) {
      std::cout << d[i][j];
      if (j == 10)
        break;
      std::cout << ' ';
    }
    std::cout << std::endl;
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <iostream>

int main() {
  int n;
  std::cin >> n;
  int b, f, r, v;
  std::cin >> b >> f >> r >> v;

  for (int j = 0; j < 4; j++) {
    for (int k = 0; k < 3; k++) {
      for (int i = 0; i < 10; i++) {
        if (i = r) {
          std::cout << " " << 0 + v;
        } else {
          std::cout << " " << 0;
        }
      }
      std::cout << std::endl;
    }
    std::cout << "####################" << std::endl;
  }
  return 0;
}
Problem p02409 (C++) — buggy submission, verdict: Runtime Error

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

  for (l = 0; l < n; l++) {
    cin >> b >> f >> r >> v;
    a[b][f][r] = a[b][f][r] + v;
    if (a[b][f][r] > 9) {
      a[b][f][r] = 9;
    }
    if (a[b][f][r] < 0) {
      a[b][f][r] = 0;
    }
  }
  for (i = 1; i < 5; i++) {
    for (j = 1; j < 4; j++) {
      for (k = 1; k < 11; k++) {
        cout << " " << a[i][j][k];
      }
      cout << endl;
    }
    if (i == 4) {
      break;
    }
    cout << "####################" << endl;
  }
  return 0;
}

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


Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int i, j, k, n, l;
  int b, f, r, v;
  int a[4][3][10] = {0};
  cin >> n;
  for (i = 1; i < 5; i++) {
    for (j = 1; j < 4; j++) {
      for (k = 1; k < 11; k++) {
        a[i][j][k] = 0;
      }
    }
  }
  for (l = 0; l < n; l++) {
    cin >> b >> f >> r >> v;
    a[b][f][r] = v;
  }
  for (i = 1; i < 5; i++) {
    for (j = 1; j < 4; j++) {
      for (k = 1; k < 11; k++) {
        cout << a[i][j][k] << " ";
      }
      cout << endl;
    }
    cout << "####################" << endl;
  }
  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 room[5][4][11];
  for (int i = 0; i < 5; i++) {
    for (int j = 0; j < 4; j++) {
      for (int k = 0; k < 11; k++) {
        room[i][j][k] = 0;
      }
    }
  }
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> b >> f >> r >> v;
    room[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 << " " << room[i][j][k];
      }
      cout << endl;
    }
    if (i != 4)
      cout << "####################" << endl;
  }
  return 0;
}


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


Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int n, b, f, r, v;
  int room[4][3][10];
  for (int i = 1; i <= 4; i++) {
    for (int j = 1; j <= 3; j++) {
      for (int h = 1; h <= 10; h++) {
        room[i][j][h] = 0;
      }
    }
  }
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> b >> f >> r >> v;
    room[b][f][r] += v;
  }
  for (int i = 1; i <= 4; i++) {
    for (int j = 1; j <= 3; j++) {
      for (int h = 1; h <= 10; h++) {
        cout << room[i][j][h];
        if (h != 10)
          cout << " ";
      }
      cout << endl;
    }
    if (i != 4)
      cout << "####################" << endl;
  }
  return 0;
}