prithivMLmods/Coder-Stat huggingface dataset:
Problem p02408 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
using namespace std;

int main() {
  int card[51] = {0};
  int total, number;
  char type;
  cin >> total;
  for (int i = 0; i < total; i++) {
    cin >> type >> number;
    if (type == 'S') {
      card[number - 1] = {1};
    }
    if (type == 'H') {
      card[number + 12] = {1};
    }
    if (type == 'C') {
      card[number + 25] = {1};
    }
    if (type == 'D') {
      card[number + 38] = {1};
    }
  }
  for (int i = 0; i < 52; i++) {
    if (card[i] == 0) {
      if (i < 13) {
        cout << "S"
             << " " << i + 1 << endl;
      }
      if (i >= 13 && i < 26) {
        cout << "H"
             << " " << i - 12 << endl;
      }
      if (i >= 26 && i < 39) {
        cout << "C"
             << " " << i - 25 << endl;
      }
      if (i >= 39 && i < 52) {
        cout << "D"
             << " " << i - 38 << endl;
      }
    }
  }
}


Fixed submission:
#include <iostream>
using namespace std;

int main() {
  int card[52] = {0};
  int total, number;
  char type;
  cin >> total;
  for (int i = 0; i < total; i++) {
    cin >> type >> number;
    if (type == 'S') {
      card[number - 1] = {1};
    }
    if (type == 'H') {
      card[number + 12] = {1};
    }
    if (type == 'C') {
      card[number + 25] = {1};
    }
    if (type == 'D') {
      card[number + 38] = {1};
    }
  }
  for (int i = 0; i < 52; i++) {
    if (card[i] == 0) {
      if (i < 13) {
        cout << "S"
             << " " << i + 1 << endl;
      }
      if (i >= 13 && i < 26) {
        cout << "H"
             << " " << i - 12 << endl;
      }
      if (i >= 26 && i < 39) {
        cout << "C"
             << " " << i - 25 << endl;
      }
      if (i >= 39 && i < 52) {
        cout << "D"
             << " " << i - 38 << endl;
      }
    }
  }
}
Problem p02408 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
using namespace std;

int main() {
  int s[13];
  int h[13];
  int c[13];
  int d[13];
  int n, m;
  char cr;
  for (int i = 1; i <= 13; i++)
    s[i] = 0;
  for (int i = 1; i <= 13; i++)
    h[i] = 0;
  for (int i = 1; i <= 13; i++)
    c[i] = 0;
  for (int i = 1; i <= 13; i++)
    d[i] = 0;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> cr >> m;
    switch (cr) {
    case 'S':
      s[m] = 1;
      break;
    case 'H':
      h[m] = 1;
      break;
    case 'C':
      c[m] = 1;
      break;
    case 'D':
      d[m] = 1;
      break;
    }
  }
  for (int i = 1; i <= 13; i++)
    if (s[i] == 0)
      cout << 'S' << ' ' << i << endl;
  for (int i = 1; i <= 13; i++)
    if (h[i] == 0)
      cout << 'H' << ' ' << i << endl;
  for (int i = 1; i <= 13; i++)
    if (c[i] == 0)
      cout << 'C' << ' ' << i << endl;
  for (int i = 1; i <= 13; i++)
    if (d[i] == 0)
      cout << 'D' << ' ' << i << endl;
}


Fixed submission:
#include <iostream>
using namespace std;

int main() {
  int s[14];
  int h[14];
  int c[14];
  int d[14];
  int n, m;
  char cr;
  for (int i = 1; i <= 13; i++)
    s[i] = 0;
  for (int i = 1; i <= 13; i++)
    h[i] = 0;
  for (int i = 1; i <= 13; i++)
    c[i] = 0;
  for (int i = 1; i <= 13; i++)
    d[i] = 0;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> cr >> m;
    switch (cr) {
    case 'S':
      s[m] = 1;
      break;
    case 'H':
      h[m] = 1;
      break;
    case 'C':
      c[m] = 1;
      break;
    case 'D':
      d[m] = 1;
      break;
    }
  }
  for (int i = 1; i <= 13; i++)
    if (s[i] == 0)
      cout << 'S' << ' ' << i << endl;
  for (int i = 1; i <= 13; i++)
    if (h[i] == 0)
      cout << 'H' << ' ' << i << endl;
  for (int i = 1; i <= 13; i++)
    if (c[i] == 0)
      cout << 'C' << ' ' << i << endl;
  for (int i = 1; i <= 13; i++)
    if (d[i] == 0)
      cout << 'D' << ' ' << i << endl;
}
Problem p02409 (C++)

Buggy submission (status: Runtime Error):
#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;
}

Fixed submission:
#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;
}
Problem p02409 (C++)

Buggy submission (status: Runtime Error):
#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;
}


Fixed submission:
#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;
}
Problem p02409 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
using namespace std;

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

  for (int i = 1; i <= 4; i++) {
    for (int j = 1; j <= 3; j++) {
      for (int t = 1; t <= 10; t++) {
        c[i][j][t] = 0;
      }
    }
  }

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

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


Fixed submission:
#include <iostream>
using namespace std;

int main() {
  int c[5][5][15];
  int n, b, f, r, v;

  for (int i = 1; i <= 4; i++) {
    for (int j = 1; j <= 3; j++) {
      for (int t = 1; t <= 10; t++) {
        c[i][j][t] = 0;
      }
    }
  }

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

  for (int i = 1; i <= 4; i++) {
    for (int j = 1; j <= 3; j++) {
      for (int t = 1; t <= 10; t++) {
        cout << ' ' << c[i][j][t];
      }
      cout << endl;
    }
    if (i != 4)
      cout << "####################" << endl;
  }
  return 0;
}
Problem p02409 (C++)

Buggy submission (status: Runtime Error):
#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;
}


Fixed submission:
#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;
}
Problem p02409 (C++)

Buggy submission (status: Runtime Error):
#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;
}


Fixed submission:
#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;
}
Problem p02409 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>

using namespace std;

int main() {
  int rooms[4][3][10] = {0};

  int n;

  cin >> n;

  int b, f, r, v;

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

Fixed submission:
#include <iostream>

using namespace std;

int main() {
  int rooms[4][3][10] = {0};

  int n;

  cin >> n;

  int b, f, r, v;

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

Buggy submission (status: 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;
  }
  while (true)
    ;
  return 0;
}

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

  return 0;
}
Problem p02409 (C++)

Buggy submission (status: 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;
}

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 (status: Runtime Error):
#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;
}


Fixed submission:
#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;
}
Problem p02410 (C++)

Buggy submission (status: Runtime Error):
#include <stdio.h>
int main() {
  int n, m, i, j;
  long long a[100][100] = {0}, b[110] = {0}, c[110] = {0};
  scanf("%d %d", &n, &m);
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) {
      scanf("%d", &a[i][j]);
    }
  }
  for (i = 1; i <= m; i++) {
    scanf("%d", &b[i]);
  }
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) {
      c[i] += a[i][j] * b[j];
    }
  }
  for (i = 1; i <= n; i++) {
    printf("%d\n", c[i]);
  }
  return 0;
}

Fixed submission:
#include <stdio.h>
int main() {
  int n, m, i, j;
  static int a[100][100] = {0}, b[110] = {0}, c[110] = {0};
  scanf("%d %d", &n, &m);
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) {
      scanf("%d", &a[i][j]);
    }
  }
  for (i = 1; i <= m; i++) {
    scanf("%d", &b[i]);
  }
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) {
      c[i] += a[i][j] * b[j];
    }
  }
  for (i = 1; i <= n; i++) {
    printf("%d\n", c[i]);
  }
  return 0;
}
Problem p02410 (C++)

Buggy submission (status: Runtime Error):
#include <stdio.h>
/********
 *	??????????????¨????????????
 *********/

/*********??¢?????´?????????
 *	(1)????¬????????????¨????¬??????????????????????
 *	(2)????¬?????????????????¬????????????¨?????????
 *	(3)
 *********/

int main(void) {
  int n, m; //?????°n????????°m
  int a, b, c;
  int i, j;
  int gyouretu_a[100][100] = {{0}}, gyouretu_b[100] = {0},
      gyouretu_c[100] = {0};

  scanf("%d %d\n", &n, &m);

  for (i = 1; i <= n; i++) { // A?????\???
    for (j = 1; j <= m; j++) {
      scanf("%d", &a);
      gyouretu_a[i][j] = a;

      if (j < (m - 1)) {
        scanf(" ");
      } else if (j == m) {
        scanf("\n");
      } else {
        //??????????????\??????
      }
    }
  }

  for (i = 1; i <= m; i++) { // b?????\???
    scanf("%d\n", &b);
    gyouretu_b[i] = b;
  }

  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) {
      gyouretu_c[i] += (gyouretu_a[i][j]) * (gyouretu_b[j]);
    }
  }

  for (j = 1; j <= n; j++) { //???????????????
    c = gyouretu_c[j];
    printf("%d\n", c);
  }

  return 0;
}

Fixed submission:
#include <stdio.h>
/********
 *	??????????????¨????????????
 *********/

/*********??¢?????´?????????
 *	(1)????¬????????????¨????¬??????????????????????
 *	(2)????¬?????????????????¬????????????¨?????????
 *	(3)
 *********/

int main(void) {
  int n, m; //?????°n????????°m
  int a, b, c;
  int i, j;
  int gyouretu_a[101][101] = {{0}}, gyouretu_b[101] = {0},
      gyouretu_c[101] = {0};

  scanf("%d %d\n", &n, &m);

  for (i = 1; i <= n; i++) { // A?????\???
    for (j = 1; j <= m; j++) {
      scanf("%d", &a);
      gyouretu_a[i][j] = a;

      if (j < (m - 1)) {
        scanf(" ");
      } else if (j == m) {
        scanf("\n");
      } else {
        //??????????????\??????
      }
    }
  }

  for (i = 1; i <= m; i++) { // b?????\???
    scanf("%d\n", &b);
    gyouretu_b[i] = b;
  }

  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) {
      gyouretu_c[i] += (gyouretu_a[i][j]) * (gyouretu_b[j]);
    }
  }

  for (j = 1; j <= n; j++) { //???????????????
    c = gyouretu_c[j];
    printf("%d\n", c);
  }

  return 0;
}
Problem p02410 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
#include <vector>
using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> mtr(3, vector<int>(4));
  vector<int> vec(m);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> mtr[i][j];
    }
  }
  for (int i = 0; i < m; i++) {
    cin >> vec[i];
  }

  for (int i = 0; i < n; i++) {
    int ret = 0;
    for (int j = 0; j < m; j++) {
      ret += mtr[i][j] * vec[j];
    }
    cout << ret << endl;
  }
  return 0;
}

Fixed submission:
#include <iostream>
#include <vector>
using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> mtr(n, vector<int>(m));
  vector<int> vec(m);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> mtr[i][j];
    }
  }
  for (int i = 0; i < m; i++) {
    cin >> vec[i];
  }

  for (int i = 0; i < n; i++) {
    int ret = 0;
    for (int j = 0; j < m; j++) {
      ret += mtr[i][j] * vec[j];
    }
    cout << ret << endl;
  }
  return 0;
}
Problem p02410 (C++)

Buggy submission (status: Runtime Error):
#include <cmath>
#include <cstdio>
#include <iostream>
#include <string>
using namespace std;
int main() {
  long n, m, a[100][100], b[100], sum = 0;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cin >> a[i][j];
    }
  }
  for (int i = 1; i <= m; i++) {
    cin >> b[i];
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      sum += a[i][j] * b[j];
    }
    cout << sum << endl;
    sum = 0;
  }
  return 0;
}

Fixed submission:
#include <cmath>
#include <cstdio>
#include <iostream>
#include <string>
using namespace std;
int main() {
  long n, m, a[101][101], b[101], sum = 0;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cin >> a[i][j];
    }
  }
  for (int i = 1; i <= m; i++) {
    cin >> b[i];
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      sum += a[i][j] * b[j];
    }
    cout << sum << endl;
    sum = 0;
  }
  return 0;
}
Problem p02410 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>

using namespace std;

int main() {

  int n, m;
  cin >> n >> m;
  int a[100][100];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; i++)
      cin >> a[i][j];

  int b[100];
  for (int i = 0; i < m; i++)
    cin >> b[i];

  int c[100] = {};
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      c[i] += a[i][j] * b[j];

  for (int i = 0; i < n; i++)
    cout << c[i] << endl;
}


Fixed submission:
#include <bits/stdc++.h>

using namespace std;

int main() {

  int n, m;
  cin >> n >> m;
  int a[100][100];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      cin >> a[i][j];

  int b[100];
  for (int i = 0; i < m; i++)
    cin >> b[i];

  int c[100] = {};
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      c[i] += a[i][j] * b[j];

  for (int i = 0; i < n; i++)
    cout << c[i] << endl;
}
Problem p02410 (C++)

Buggy submission (status: Runtime Error):
#include <stdio.h>
#include <stdlib.h>

int main(void) {
  int i, j;
  int x = 0;
  int y = 0;
  int z1, z2;

  int n, m;
  int **a;
  int *b;

  scanf("%d %d", &n, &m);

  a = (int **)malloc(n * sizeof(int));
  b = (int *)malloc(m * sizeof(int));

  for (i = 0; i < n; i++) {
    a[i] = (int *)malloc(m * sizeof(int));
  }

  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      if (j == 0) {
        scanf("%d", &x);
      } else {
        scanf(" %d", &x);
      }
      a[i][j] = x;
    }
  }

  for (i = 0; i < m; i++) {
    scanf("%d", &x);
    b[i] = x;
  }

  for (i = 0; i < n; i++) {
    y = 0;
    for (j = 0; j < m; j++) {
      z1 = a[i][j];
      z2 = b[j];
      y += z1 * z2;
    }

    printf("%d\n", y);
  }

  for (i = 0; i < n; i++) {
    free(a[i]);
  }

  free(a);
  free(b);

  return 0;
}


Fixed submission:
#include <stdio.h>
#include <stdlib.h>

int main(void) {
  int i, j;
  int x = 0;
  int y = 0;
  int z1, z2;

  int n, m;
  int **a;
  int *b;

  scanf("%d %d", &n, &m);

  a = (int **)malloc(n * sizeof(int *));
  b = (int *)malloc(m * sizeof(int));

  for (i = 0; i < n; i++) {
    a[i] = (int *)malloc(m * sizeof(int));
  }

  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      if (j == 0) {
        scanf("%d", &x);
      } else {
        scanf(" %d", &x);
      }
      a[i][j] = x;
    }
  }

  for (i = 0; i < m; i++) {
    scanf("%d", &x);
    b[i] = x;
  }

  for (i = 0; i < n; i++) {
    y = 0;
    for (j = 0; j < m; j++) {
      z1 = a[i][j];
      z2 = b[j];
      y += z1 * z2;
    }

    printf("%d\n", y);
  }

  for (i = 0; i < n; i++) {
    free(a[i]);
  }

  free(a);
  free(b);

  return 0;
}
Problem p02410 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <vector>
#define rep(i, n) Rep(i, 0, n)
#define Rep(i, k, n) for (int i = k; i < n; i++)
#define rep1(i, n) for (int i = 1; i <= n; i++)
#define vi vector<int>
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())

// const int MOD = 1000000007;
// const int INF = 1<<30;
using namespace std;

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

  int a[n][m], b[m];

  // 行列
  rep1(i, n) {
    rep1(j, m) { cin >> a[i][j]; }
  }

  // 列ベクトル
  rep1(i, m) cin >> b[i];

  // 計算と表示
  rep1(i, n) {
    int c = 0;
    rep1(j, m) { c += a[i][j] * b[j]; }
    cout << c << endl;
  }
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <vector>
#define rep(i, n) Rep(i, 0, n)
#define Rep(i, k, n) for (int i = k; i < n; i++)
#define rep1(i, n) for (int i = 1; i <= n; i++)
#define vi vector<int>
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())

// const int MOD = 1000000007;
// const int INF = 1<<30;
using namespace std;

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

  int a[n + 10][m + 10], b[m + 10];

  // 行列
  rep1(i, n) {
    rep1(j, m) { cin >> a[i][j]; }
  }

  // 列ベクトル
  rep1(i, m) cin >> b[i];

  // 計算と表示
  rep1(i, n) {
    int c = 0;
    rep1(j, m) { c += a[i][j] * b[j]; }
    cout << c << endl;
  }
}
Problem p02410 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
using namespace std;

int main() {

  int gyo, retu;
  int sum[100] = {0};
  int vec1[retu][gyo];
  int vec2[gyo];

  cin >> retu >> gyo;

  for (int i = 0; i < retu; i++) {
    for (int j = 0; j < gyo; j++) {
      cin >> vec1[i][j];
    }
  }

  for (int i = 0; i < gyo; i++) {
    cin >> vec2[i];
  }

  for (int i = 0; i < retu; i++) {
    for (int j = 0; j < gyo; j++) {
      sum[i] += vec1[i][j] * vec2[j];
    }
    cout << sum[i] << endl;
  }
}

Fixed submission:
#include <iostream>
using namespace std;

int main() {

  int gyo, retu;
  int sum[100] = {0};
  int vec1[100][100];
  int vec2[100];

  cin >> retu >> gyo;

  for (int i = 0; i < retu; i++) {
    for (int j = 0; j < gyo; j++) {
      cin >> vec1[i][j];
    }
  }

  for (int i = 0; i < gyo; i++) {
    cin >> vec2[i];
  }

  for (int i = 0; i < retu; i++) {
    for (int j = 0; j < gyo; j++) {
      sum[i] += vec1[i][j] * vec2[j];
    }
    cout << sum[i] << endl;
  }
}
Problem p02410 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
#include <vector>
using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> a(n, vector<int>(n, 0));
  vector<int> b(m, 0), c(n, 0);

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> a[i][j];
    }
  }
  for (int j = 0; j < m; j++)
    cin >> b[j];

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      c[i] += a[i][j] * b[j];
    }
    cout << c[i] << "\n";
  }

  return 0;
}

Fixed submission:
#include <iostream>
#include <vector>
using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> a(n, vector<int>(m, 0));
  vector<int> b(m, 0), c(n, 0);

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> a[i][j];
    }
  }
  for (int j = 0; j < m; j++)
    cin >> b[j];

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      c[i] += a[i][j] * b[j];
    }
    cout << c[i] << "\n";
  }

  return 0;
}
Problem p02410 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>

using namespace std;

int main(int argc, char *argv[]) {
  int n, m;
  cin >> n >> m;
  int A[n][m];
  int b[m];
  long long ans[n];

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> A[i][j];
    }
  }
  for (int i = 0; i < m; i++) {
    cin >> b[i];
  }
  for (int i = 0; i < n; i++) {
    ans[i] = 0;
    for (int j = 0; i < m; j++) {
      ans[i] += A[i][j] * b[j];
    }
  }

  for (int i = 0; i < n; i++) {
    cout << ans[i] << endl;
  }
  return 0;
}

Fixed submission:
#include <iostream>

using namespace std;

int main(int argc, char *argv[]) {
  int n, m;
  cin >> n >> m;
  int A[n][m];
  int b[m];
  long long ans[n];

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> A[i][j];
    }
  }
  for (int i = 0; i < m; i++) {
    cin >> b[i];
  }
  for (int i = 0; i < n; i++) {
    ans[i] = 0;
    for (int j = 0; j < m; j++) {
      ans[i] += A[i][j] * b[j];
    }
  }

  for (int i = 0; i < n; i++) {
    cout << ans[i] << endl;
  }
  return 0;
}
Problem p02410 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
using namespace std;

int main() {
  int column, row, res;

  cin >> column >> row;

  int matrix[100][100], vector_a[row];

  for (int i = 1; i <= column; i++) {
    for (int j = 1; j <= row; j++) {
      cin >> matrix[i][j];
    }
  }

  for (int i = 1; i <= row; i++) {
    cin >> vector_a[i];
  }

  for (int i = 1; i <= column; i++) {
    res = 0;
    for (int j = 1; j <= row; j++) {
      res += matrix[i][j] * vector_a[j];
    }
    cout << res << endl;
  }
  return 0;
}

Fixed submission:
#include <iostream>
using namespace std;

int main() {
  int column, row, res;

  cin >> column >> row;

  int matrix[101][101], vector_a[101];

  for (int i = 1; i <= column; i++) {
    for (int j = 1; j <= row; j++) {
      cin >> matrix[i][j];
    }
  }

  for (int i = 1; i <= row; i++) {
    cin >> vector_a[i];
  }

  for (int i = 1; i <= column; i++) {
    res = 0;
    for (int j = 1; j <= row; j++) {
      res += matrix[i][j] * vector_a[j];
    }
    cout << res << endl;
  }
  return 0;
}
Problem p02410 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
#include <vector>
using namespace std;
int main() {
  int n, m;
  int i, j;
  cin >> n >> m;
  vector<vector<int>> A;
  A.resize(n);
  for (i = 0; i < n; i++) {
    A[i].resize(m);
  }
  vector<int> b(m), c(m);
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      cin >> A[i][j];
    }
  }
  for (i = 0; i < m; i++) {
    cin >> b[i];
  }
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      c[i] += A[i][j] * b[j];
    }
  }
  for (i = 0; i < n; i++) {
    cout << c[i] << endl;
  }
  return 0;
}

Fixed submission:
#include <iostream>
#include <vector>
using namespace std;
int main() {
  int n, m;
  int i, j;
  cin >> n >> m;
  vector<vector<int>> A;
  A.resize(n);
  for (i = 0; i < n; i++) {
    A[i].resize(m);
  }
  vector<int> b(m), c(n);
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      cin >> A[i][j];
    }
  }
  for (i = 0; i < m; i++) {
    cin >> b[i];
  }
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      c[i] += A[i][j] * b[j];
    }
  }
  for (i = 0; i < n; i++) {
    cout << c[i] << endl;
  }
  return 0;
}
Problem p02410 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
#include <vector>
using namespace std;

int main() {
  long n = 0;
  long m = 0;
  cin >> n >> m;
  vector<vector<long>> a(n);
  vector<long> b(m, 0);
  vector<long> c(m, 0);
  for (long i = 0; i < n; i++) {
    a[i].resize(m);
  }
  for (long i = 0; i < n; i++) {
    for (long j = 0; j < m; j++) {
      a[i][j] = 0;
      cin >> a[i][j];
    }
  }
  for (long i = 0; i < m; i++) {
    cin >> b[i];
  }
  for (long i = 0; i < n; i++) {
    for (long j = 0; j < m; j++) {
      c[i] += a[i][j] * b[j];
    }
  }
  for (long i = 0; i < n; i++) {
    cout << c[i] << endl;
  }
  return 0;
}

Fixed submission:
#include <iostream>
#include <vector>
using namespace std;

int main() {
  long n = 0;
  long m = 0;
  cin >> n >> m;
  vector<vector<long>> a(n);
  vector<long> b(m, 0);
  vector<long> c(n, 0);
  for (long i = 0; i < n; i++) {
    a[i].resize(m);
  }
  for (long i = 0; i < n; i++) {
    for (long j = 0; j < m; j++) {
      a[i][j] = 0;
      cin >> a[i][j];
    }
  }
  for (long i = 0; i < m; i++) {
    cin >> b[i];
  }
  for (long i = 0; i < n; i++) {
    for (long j = 0; j < m; j++) {
      c[i] += a[i][j] * b[j];
    }
  }
  for (long i = 0; i < n; i++) {
    cout << c[i] << endl;
  }
  return 0;
}
Problem p02410 (C++)

Buggy submission (status: Runtime Error):
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, start, n) for (int i = start; i < n; i++)
#define And &&
#define Or ||
#define Lb cout << endl
using namespace std;

int main(void) {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> a(n, vector<int>(m));
  vector<int> b(m);
  vector<long long> c(m);
  //????????????
  rep(i, 0, n) {
    rep(j, 0, m) { cin >> a[i][j]; }
  }

  rep(i, 0, m) { cin >> b[i]; }

  rep(i, 0, n) {
    c[i] = 0;
    rep(j, 0, m) { c[i] += a[i][j] * b[j]; }
  }

  rep(i, 0, n) { cout << c[i] << endl; }
  return 0;
}

Fixed submission:
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, start, n) for (int i = start; i < n; i++)
#define And &&
#define Or ||
#define Lb cout << endl
using namespace std;

int main(void) {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> a(n, vector<int>(m));
  vector<int> b(m);
  vector<long long> c(n);
  //????????????
  rep(i, 0, n) {
    rep(j, 0, m) { cin >> a[i][j]; }
  }

  rep(i, 0, m) { cin >> b[i]; }

  rep(i, 0, n) {
    c[i] = 0;
    rep(j, 0, m) { c[i] += a[i][j] * b[j]; }
  }

  rep(i, 0, n) { cout << c[i] << endl; }
  return 0;
}
Problem p02410 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
#include <vector>

using namespace std;

int main(int argc, char *argv[]) {
  int row, line, input, result;
  cin >> row >> line;
  vector<vector<int>> matrix1(4);
  vector<int> matrix2;
  for (int i = 0; i < row; i++) {
    for (int j = 0; j < line; j++) {
      cin >> input;
      matrix1[i].push_back(input);
    }
  }
  for (int i = 0; i < line; i++) {
    cin >> input;
    matrix2.push_back(input);
  }
  for (int i = 0; i < row; i++) {
    result = 0;
    for (int j = 0; j < line; j++) {
      result += matrix1[i][j] * matrix2[j];
    }
    cout << result << endl;
  }
}

Fixed submission:
#include <iostream>
#include <vector>

using namespace std;

int main(int argc, char *argv[]) {
  int row, line, input, result;
  cin >> row >> line;
  vector<vector<int>> matrix1(row);
  vector<int> matrix2;
  for (int i = 0; i < row; i++) {
    for (int j = 0; j < line; j++) {
      cin >> input;
      matrix1[i].push_back(input);
    }
  }
  for (int i = 0; i < line; i++) {
    cin >> input;
    matrix2.push_back(input);
  }
  for (int i = 0; i < row; i++) {
    result = 0;
    for (int j = 0; j < line; j++) {
      result += matrix1[i][j] * matrix2[j];
    }
    cout << result << endl;
  }
}
Problem p02410 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
using namespace std;

int main() {
  int **a, *b, *c, n, m, num;
  cin >> n >> m;

  a = new int *[n];
  for (int i = 0; i < n; i++) {
    a[i] = new int[m];
  } // a[n][m]

  b = new int[m];
  c = new int[n];

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> num;
      a[i][j] = num;
    }
  }

  for (int i = 0; i < m; i++) {
    cin >> num;
    b[i] = num;
  }

  for (int i = 0; i < n; i++) {
    c[i] = 0;
  }

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      c[i] += a[i][j] * b[j];
    }
    cout << c[i] << endl;
  }

  delete[] b;
  delete[] c;
  for (int i = 0; i < m; i++) {
    delete[] a[i];
  }
  delete[] a;

  return 0;
}

Fixed submission:
#include <iostream>
using namespace std;

int main() {
  int **a, *b, *c, n, m, num;
  cin >> n >> m;

  a = new int *[n];
  for (int i = 0; i < n; i++) {
    a[i] = new int[m];
  } // a[n][m]

  b = new int[m];
  c = new int[n];

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> num;
      a[i][j] = num;
    }
  }

  for (int i = 0; i < m; i++) {
    cin >> num;
    b[i] = num;
  }

  for (int i = 0; i < n; i++) {
    c[i] = 0;
  }

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      c[i] += a[i][j] * b[j];
    }
    cout << c[i] << endl;
  }

  return 0;
}
Problem p02410 (Python)

Buggy submission (status: Runtime Error):
n, m = map(int, input().split())
a = []
b = []
for i in range(n):
    a += list(map(int, input().split()))
for i in range(m):
    b.append(int(input()))
for i in range(n):
    c = 0
    for j in range(m):
        c += a[i][j] * b[j]
    print(c)


Fixed submission:
n, m = map(int, input().split())
a = []
b = []
for i in range(n):
    a.append(list(map(int, input().split())))
for i in range(m):
    b.append(int(input()))
for i in range(n):
    c = 0
    for j in range(m):
        c += a[i][j] * b[j]
    print(c)
Problem p02410 (Python)

Buggy submission (status: Runtime Error):
n, m = map(int, input().split())
a = [[None] * n]
b = [None] * m
for i in range(n):
    a[i] = list(map(int, input().split()))
for i in range(m):
    b[i] = int(input())
for i in range(n):
    c = 0
    for j in range(m):
        c += a[i][j] * b[j]
    print(c)


Fixed submission:
n, m = map(int, input().split())
a = [None] * n
b = [None] * m
for i in range(n):
    a[i] = list(map(int, input().split()))
for i in range(m):
    b[i] = int(input())
for i in range(n):
    c = 0
    for j in range(m):
        c += a[i][j] * b[j]
    print(c)
Problem p02410 (Python)

Buggy submission (status: Runtime Error):
n, m = map(int, input().split())
List1 = [[0 for i in range(m)] for i in range(n)]
for x in range(n):
    List1[x] = list(map(int, input().split()))
List2 = [int(input()) for _ in range(n)]
sum = [0 for i in range(n)]
for x in range(n):
    for y in range(m):
        sum[x] += List1[x][y] * List2[y]
for x in range(n):
    print(sum[x])


Fixed submission:
n, m = map(int, input().split())
List1 = [[0 for i in range(m)] for i in range(n)]
for x in range(n):
    List1[x] = list(map(int, input().split()))
List2 = [int(input()) for i in range(m)]
sum = [0 for i in range(n)]
for x in range(n):
    for y in range(m):
        sum[x] += List1[x][y] * List2[y]
for x in range(n):
    print(sum[x])
Problem p02410 (Python)

Buggy submission (status: Runtime Error):
n, m = [int(i) for i in input().split()]
a = [[int(j) for j in input().split()] for i in range(n)]
b = [int(input()) for i in range(m)]

ans = [sum([a[j][i] * b[i] for i in range(4)]) for j in range(3)]
print(*ans, sep="\n")


Fixed submission:
n, m = [int(i) for i in input().split()]
a = [[int(j) for j in input().split()] for i in range(n)]
b = [int(input()) for i in range(m)]

ans = [sum([a[j][i] * b[i] for i in range(m)]) for j in range(n)]
print(*ans, sep="\n")
Problem p02410 (Python)

Buggy submission (status: Runtime Error):
n, m = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]
b = [int(input()) for _ in range(m)]
for i in a:
    c = 0
    for j, k in i, b:
        c += j * k
    print(c)


Fixed submission:
n, m = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]
b = [int(input()) for _ in range(m)]
for i in a:
    c = 0
    for j, k in zip(i, b):
        c += j * k
    print(c)
Problem p02410 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
#include <stdio.h>
using namespace std;
int main() {
  int a[100][100], b[100], i, j;
  int c[100];
  cin >> i >> j;

  for (int m = 1; m <= i; m++) {
    for (int n = 1; n <= j; n++) {
      cin >> a[m][n];
      c[n] = 0;
    }
  }

  for (int o = 1; o <= j; o++) {
    cin >> b[o];
  }
  for (int l = 1; l <= i; l++) {
    for (int k = 1; k <= j; k++) {
      c[l] += b[k] * a[l][k];
    }
  }
  for (int h = 1; h <= i; h++) {
    cout << c[h] << endl;
  }
  return 0;
}


Fixed submission:
#include <iostream>
#include <stdio.h>
using namespace std;
int main() {
  int a[1000][1000], b[1000], i, j;
  int c[1000];
  cin >> i >> j;

  for (int m = 1; m <= i; m++) {
    for (int n = 1; n <= j; n++) {
      cin >> a[m][n];
      c[n] = 0;
    }
  }

  for (int o = 1; o <= j; o++) {
    cin >> b[o];
  }
  for (int l = 1; l <= i; l++) {
    for (int k = 1; k <= j; k++) {
      c[l] += b[k] * a[l][k];
    }
  }
  for (int h = 1; h <= i; h++) {
    cout << c[h] << endl;
  }
  return 0;
}
Problem p02410 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>

using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> v(n);
  vector<vector<int>> mx(n, vector<int>(m));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> mx[i][j];
    }
  }
  for (int i = 0; i < m; i++) {
    cin >> v[i];
  }
  for (int i = 0; i < n; i++) {
    int ans = 0;
    for (int j = 0; j < m; j++) {
      ans += mx[i][j] * v[j];
    }
    cout << ans << endl;
  }

  return 0;
}

Fixed submission:
#include <bits/stdc++.h>

using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> v(m);
  vector<vector<int>> mx(n, vector<int>(m));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> mx[i][j];
    }
  }
  for (int i = 0; i < m; i++) {
    cin >> v[i];
  }
  for (int i = 0; i < n; i++) {
    int ans = 0;
    for (int j = 0; j < m; j++) {
      ans += mx[i][j] * v[j];
    }
    cout << ans << endl;
  }

  return 0;
}
Problem p02411 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
using namespace std;

int main() {
  int m, f, r;

  cin >> m >> f >> r;
  while (m != -1 || f != -1 || r != -1) {
    if (m == -1 || f == -1) {
      cout << "F" << endl;
    } else if (m + f >= 80) {
      cout << "A" << endl;
    } else if (m + f < 80 && m + f >= 65) {
      cout << "B" << endl;
    } else if (m + f < 65 && m + f >= 50) {
      cout << "C" << endl;
    } else if (m + f < 50 && m + f >= 30) {
      if (r >= 50) {
        cout << "C" << endl;
      } else {
        cout << "D" << endl;
      }

    } else {
      cout << "F" << endl;
    }
  }

  return 0;
}


Fixed submission:
#include <iostream>
using namespace std;

int main() {
  int m, f, r;

  cin >> m >> f >> r;
  while (m != -1 || f != -1 || r != -1) {
    if (m == -1 || f == -1) {
      cout << "F" << endl;
    } else if (m + f >= 80) {
      cout << "A" << endl;
    } else if (m + f < 80 && m + f >= 65) {
      cout << "B" << endl;
    } else if (m + f < 65 && m + f >= 50) {
      cout << "C" << endl;
    } else if (m + f < 50 && m + f >= 30) {
      if (r >= 50) {
        cout << "C" << endl;
      } else {
        cout << "D" << endl;
      }

    } else {
      cout << "F" << endl;
    }
    cin >> m >> f >> r;
  }

  return 0;
}
Problem p02411 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
using namespace std;

int main() {

  int m, f, sum, r;
  char rank;

  cin >> m >> f >> r;
  while ((m & f & r) != -1) {
    if (m < 0 || f < 0) {
      rank = 'F';
    } else {
      sum = m + f;
      if (sum < 30) {
        rank = 'F';
      } else if (sum < 50) {
        rank = 'D';
        if (r > 49)
          rank = 'C';
      } else if (sum < 65) {
        rank = 'C';
      } else if (sum < 80) {
        rank = 'B';
      } else {
        rank = 'A';
      }
    }
    cout << rank << endl;
  }

  return 0;
}

Fixed submission:
#include <iostream>
using namespace std;

int main() {

  int m, f, sum, r;
  char rank;

  cin >> m >> f >> r;
  while ((m & f & r) != -1) {
    if (m < 0 || f < 0) {
      rank = 'F';
    } else {
      sum = m + f;
      if (sum < 30) {
        rank = 'F';
      } else if (sum < 50) {
        rank = 'D';
        if (r > 49)
          rank = 'C';
      } else if (sum < 65) {
        rank = 'C';
      } else if (sum < 80) {
        rank = 'B';
      } else {
        rank = 'A';
      }
    }
    cout << rank << endl;
    cin >> m >> f >> r;
  }

  return 0;
}
Problem p02411 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
using namespace std;

int main() {
  int m, f, r;

  while (1) {
    cin >> m >> r >> r;
    if (m == -1 && f == -1 && r == -1) {
      break;
    }

    if (m == -1 || f == -1) {
      cout << 'F' << endl;
    } else if (m + f >= 80) {
      cout << 'A' << endl;
    } else if (m + f >= 65) {
      cout << 'B' << endl;
    } else if (m + f >= 50) {
      cout << 'C' << endl;
    } else if (m + f >= 30) {
      if (r >= 50) {
        cout << 'C' << endl;
      } else {
        cout << 'D' << endl;
      }
    } else {
      cout << 'F' << endl;
    }
  }

  return 0;
}

Fixed submission:
#include <iostream>
using namespace std;

int main() {
  int m, f, r;

  while (1) {
    cin >> m >> f >> r;
    if (m == -1 && f == -1 && r == -1) {
      break;
    }

    if (m == -1 || f == -1) {
      cout << 'F' << endl;
    } else if (m + f >= 80) {
      cout << 'A' << endl;
    } else if (m + f >= 65) {
      cout << 'B' << endl;
    } else if (m + f >= 50) {
      cout << 'C' << endl;
    } else if (m + f >= 30) {
      if (r >= 50) {
        cout << 'C' << endl;
      } else {
        cout << 'D' << endl;
      }
    } else {
      cout << 'F' << endl;
    }
  }

  return 0;
}
Problem p02411 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <cstdio>

int main() {
  int m, f, r, p;
  while (1) {
    scanf("%d %d %D", &m, &f, &r);
    if (m == -1 && f == -1 && r == -1)
      break;
    p = m + f;
    if (m == -1 || f == -1) {
      printf("F\n");
    } else if (p >= 80) {
      printf("A\n");
    } else if (65 <= p && p < 80) {
      printf("B\n");
    } else if (50 <= p && p < 65 || r >= 50) {
      printf("C\n");
    } else if (30 <= p && p < 50) {
      printf("D\n");
    } else if (p < 30) {
      printf("F\n");
    }
  }
  return 0;
}

Fixed submission:
#include <cstdio>

int main() {
  int m, f, r, p;
  while (1) {
    scanf("%d %d %d", &m, &f, &r);
    if (m == -1 && f == -1 && r == -1)
      break;
    p = m + f;
    if (m == -1 || f == -1) {
      printf("F\n");
    } else if (p >= 80) {
      printf("A\n");
    } else if (65 <= p && p < 80) {
      printf("B\n");
    } else if (50 <= p && p < 65 || r >= 50) {
      printf("C\n");
    } else if (30 <= p && p < 50) {
      printf("D\n");
    } else if (p < 30) {
      printf("F\n");
    }
  }
  return 0;
}
Problem p02411 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
using namespace std;
int main() {
  int m[100];
  int f[100];
  int r[100];
  while (true) {
    int i = 0;
    cin >> m[i] >> f[i] >> r[i];
    if (m[i] == 0 && f[i] == 0 && r[i] == 0)
      break;
    int sum[100];
    sum[i] = m[i] + f[i];
    if (m[i] == -1 || f[i] == -1 || sum[i] < 30) {
      cout << "F" << endl;
    } else {
      if (sum[i] >= 80) {
        cout << "A" << endl;
      }
      if (65 <= sum[i] && sum[i] < 80) {
        cout << "B" << endl;
      }
      if (50 <= sum[i] && sum[i] < 65) {
        cout << "C" << endl;
      }
      if (30 <= sum[i] && sum[i] < 50) {
        if (r[i] >= 50) {
          cout << "C" << endl;
        } else {
          cout << "D" << endl;
        }
      }
    }
  }
  return 0;
}


Fixed submission:
#include <iostream>
using namespace std;
int main() {
  int m[100];
  int f[100];
  int r[100];
  while (true) {
    int i = 0;
    cin >> m[i] >> f[i] >> r[i];
    if (m[i] == -1 && f[i] == -1 && r[i] == -1)
      break;
    int sum[100];
    sum[i] = m[i] + f[i];
    if (m[i] == -1 || f[i] == -1 || sum[i] < 30) {
      cout << "F" << endl;
    } else {
      if (sum[i] >= 80) {
        cout << "A" << endl;
      }
      if (65 <= sum[i] && sum[i] < 80) {
        cout << "B" << endl;
      }
      if (50 <= sum[i] && sum[i] < 65) {
        cout << "C" << endl;
      }
      if (30 <= sum[i] && sum[i] < 50) {
        if (r[i] >= 50) {
          cout << "C" << endl;
        } else {
          cout << "D" << endl;
        }
      }
    }
  }
  return 0;
}