alexjercan/bugnet huggingface dataset:
Problem p02410 (C++) — buggy submission, verdict: 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; 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;
}


Error: TLE

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; 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;
}
Problem p02410 (C++) — buggy submission, verdict: Runtime Error

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

Error: WA

Fixed submission:

#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;
}
Problem p02410 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  int n, m;
  int A[101][101], b[101], V[101];
  cin >> n >> m;
  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++) {
    for (int j = 0; j < m; j++) {
      V[i] += A[i][j] * b[j];
    }
  }
  for (int i = 0; i < n; i++) {
    cout << V[i] << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

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

int main() {
  int m, f, r, a;
  for (int i = 0;; i++) {
    cin >> m >> f >> r;
    if (m == -1 && f == -1 && r == -1) {
      break;
    } else {
      a = m + f;
      if (m == 0 || f == 0) {
        cout << "F" << endl;
      } else if (a >= 80) {
        cout << "A" << endl;
      } else if (a < 80 && a >= 65) {
        cout << "B" << endl;
      } else if (a < 65 && a >= 50) {
        cout << "C" << endl;
      } else if (a < 50 && a >= 30) {
        if (r >= 50) {
          cout << "C" << endl;
        } else {
          cout << "D" << endl;
        }
      } else if (a < 30) {
        cout << "E" << endl;
      }
    }
  }
  return 0;
}
Problem p02410 (C++) — buggy submission, verdict: Memory Limit Exceeded

#include <iostream>
using namespace std;

int main(void) {
  int n, m;
  cin >> n >> m;
  int **a = new int *[n];
  for (int i = 0; i < n; i++) {
    a[i] = new int[m];
  }
  int *b = new int[m];

  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++) {
    int temp = 0;
    for (int j = 0; j < m; j++) {
      temp += a[i][j] * b[j];
    }
    cout << temp << endl;
  }
  for (int i = 0; i < n; i++) {
    delete[] a[i];
  }
  delete[] a;
  delete[] b;

  return 0;
}

Error: MLE

Fixed submission:

#include <iostream>
using namespace std;

int main(void) {
  int n, m;
  double **a = new double *[n];
  for (int i = 0; i < n; i++) {
    a[i] = new double[m];
  }
  double *b = new double[m];
  cin >> n >> m;
  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++) {
    double temp = 0;
    for (int j = 0; j < m; j++) {
      temp += a[i][j] * b[j];
    }
    cout << temp << endl;
  }
  for (int i = 0; i < n; i++) {
    delete[] a[i];
  }
  delete[] a;
  delete[] b;

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

#include <iostream>
using namespace std;
int main() {
  int n, m;
  int i, j, k;
  int mat[100][100] = {{}};
  int ve[100] = {};
  cin >> n >> m;
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      cin >> mat[i][j];
    }
  }
  for (j = 0; j < m; j++)
    cin >> ve[j];
  for (i = 0; i < n; i++) {
    int x = 0;
    for (j = 0; j < m; j++)
      x += mat[i][j] * ve[j];
    cout << x << endl;
  }

  return 0;
}


Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int x[100][100] = {{}};
  int y[100] = {};
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; i++) {
      cin >> x[i][j];
    }
    for (int j = 0; j < m; j++) {
      cin >> y[j];
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      int z = 0;
      z += x[i][j] * y[j];
      cout << z << endl;
    }
  }

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

#include <iostream>
using namespace std;

int main() {
  int n, m, A[100][100], b[100], c[100];

  cin >> n >> m;
  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++) {
    c[i] = 0;
    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;

  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  int n, m, A[100][100], b[100], c[100];

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

  for (int i = 0; i < n; i++) {
    c[i] = 0;
    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;

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

#include <iostream>
using namespace std;

int main(void) {
  int n, m;
  cin >> n >> m;
  int a[n][m];
  int b[m];
  int c[n];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      a[i][j] = 0;
      b[j] = 0;
    }
    c[i] = 0;
  }
  // 配列へ入力

  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++) {
    for (int j = 0; j < m; j++) {
      c[i] += a[i][j] * b[j];
    }
    cout << c[i] << endl;
  }
  return 0;
}


Error: -6
terminate called after throwing an instance of 'St9bad_alloc'
  what():  std::bad_alloc


Fixed submission:

#include <iostream>
using namespace std;

int main(void) {
  int n, m;
  // 配列の動的確保
  cin >> n >> m;
  double **a = new double *[n];
  for (int i = 0; i = n; i++) {
    a[i] = new double[m];
  }
  double *b = new double[m];
  double *c = new double[n];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      a[i][j] = 0;
      b[j] = 0;
    }
    c[i] = 0;
  }
  // 配列へ入力

  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++) {
    for (int j = 0; j < m; j++) {
      c[i] += a[i][j] * b[j];
    }
    cout << c[i] << endl;
  }
  for (int i = 0; i < n; i++) {
    delete[] a[i];
  }
  delete[] a;
  delete[] b;
  delete[] c;
  return 0;
}
Problem p02410 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;

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

  int A[n][m];
  int b[m];
  int t;

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

  for (int j = 0; j <= m - 1; j++) {
    cin >> t;
    b[j] = t;
  }

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

    for (int j = 0; j <= m - 1; j++) {
      t += A[i][j] * b[j];
    }
    cout << t << endl;
  }

  return 0;
}

Error: 0

Fixed submission:

#include <iostream>
using namespace std;

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

  int A[n][m];
  int b[m];
  int t;

  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cin >> t;
      A[i][j] = t;
    }
  }

  for (int j = 1; j <= m; j++) {
    cin >> t;
    b[j] = t;
  }

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

    for (int j = 1; j <= m; j++) {
      t += A[i][j] * b[j];
    }
    cout << t << endl;
  }

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

#include <iostream>
#include <stdio.h>

using namespace std;

int main() {
  int m, n;
  int a[999][999], b[999], c[999], d[999];

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

  cin >> n >> m;

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

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

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


Error: 0

Fixed submission:

#include <iostream>
#include <stdio.h>

using namespace std;

int main() {
  int m, n;
  int a[99][99], b[99], c[99], d[99];

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

  cin >> n >> m;

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

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

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      d[j] = a[i][j] * b[j];
      c[i] = c[i] + d[j];
    }
  }
  for (int i = 0; i < n; i++) {
    cout << c[i] << endl;
  }
  return 0;
}
Problem p02410 (C++) — buggy submission, verdict: 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;
}


Error: 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, verdict: Runtime Error

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

Error: 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>(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;
}
Problem p02410 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  int n, m, sum;
  cin >> n >> m;
  int mat[n * m];
  int vec[m];
  for (int i = 0; i < n * m; i++) {
    cin >> mat[i];
  }
  for (int i = 0; i < m; i++) {
    cin >> vec[i];
  }
  for (int y = 0; y < n; y++) {
    sum = 0;
    for (int x = 0; x < m; x++) {
      sum += mat[y * m + x] * vec[x];
    }
    cout << sum << endl;
  }
  return 0;
}


Error: TLE

Fixed submission:

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> vec;
  vector<vector<int>> mat;
  mat.resize(n);
  for (int i = 0; i < n; n++) {
    mat[i].resize(m);
  }
  vec.resize(m);
  for (int y = 0; y < n; y++) {
    for (int x = 0; x < m; x++) {
      cin >> mat[y][x];
    }
  }
  for (int y = 0; y < m; y++) {
    cin >> vec[y];
  }
  for (int y = 0; y < n; y++) {
    for (int x = 0; x < m; x++) {
      cout << mat[y][x] * vec[x] << endl;
    }
  }
  return 0;
}
Problem p02410 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;

int main(int argc, char **argv) {
  int n, m;
  cin >> n >> m;
  int **A = new int *[n];
  int *B = new int[m];
  for (int i = 0; i < n; ++i)
    A[i] = new int[m];

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

  for (int i = 0; i < n; ++i) {
    int mult = 0;
    for (int j = 0; j < m; ++j) {
      mult += A[i][j] * B[j];
    }
    cout << mult << endl;
  }

  for (int i = 0; i < n; ++i)
    delete[] A[i];
  delete[] A, B;

  return 0;
}

Error: 0

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  int **A = new int *[n];
  int *B = new int[m];
  for (int i = 0; i < n; ++i)
    A[i] = new int[n];

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

  for (int i = 0; i < n; ++i) {
    int mult = 0;
    for (int j = 0; j < m; ++j) {
      mult += A[i][j] * B[j];
    }
    cout << mult << endl;
  }

  for (int i = 0; i < n; ++i)
    delete[] A[i];
  delete[] A, B;

  return 0;
}
Problem p02410 (C++) — buggy submission, verdict: 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; j < m; j++) {
      ans[i] += A[i][j] * b[j];
    }
  }

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

Error: TLE

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; i < 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, verdict: 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[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;
}

Error: 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[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;
}
Problem p02410 (C++) — buggy submission, verdict: Runtime Error

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

Error: 0

Fixed submission:

#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;
}
Problem p02410 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

int main() {
  int x, y;
  cin >> x >> y;
  int a[x][y], b[y];
  for (int i = 0; i < x; i++) {
    for (int o = 0; o < y; o++) {
      cin >> a[i][o];
    }
  }
  for (int i = 0; i < y; i++) {
    cin >> b[i];
  }
  for (int i = 0; i < x; i++) {
    int p = 0;
    for (int o = 0; o < y; o++) {
      p += a[i][o] * b[o];
    }
    cout << p << endl;
  }
}


Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  int x, y;
  cin >> x >> y;
  int a[x][y], b[y];
  for (int i = 0; i < x; i++) {
    for (int o = 0; o < y; i++) {
      cin >> a[i][o];
    }
  }
  for (int i = 0; i < y; i++) {
    cin >> b[i];
  }
  for (int i = 0; i < x; i++) {
    int p = 0;
    for (int o = 0; o < y; o++) {
      p = p + (a[i][o] * b[o]);
    }
    cout << p << endl;
  }
}
Problem p02410 (C++) — buggy submission, verdict: Runtime Error

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

Error: 0

Fixed submission:

#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;
}
Problem p02410 (C++) — buggy submission, verdict: Runtime Error

#include <stdio.h>
int main() {
  int z[100], x[100][100], y[100], a, b, i, j;
  scanf("%d %d", &a, &b);
  for (i = 0; i < a; i++) {
    for (j = 0; j < b; j++) {
      scanf("%d", &x[i][j]);
    }
  }
  for (i = 0; i < b; i++) {
    z[i] = 0;
    scanf("%d", &y[i]);
  }
  for (i = 0; i < a; i++) {
    for (j = 0; j < b; j++) {
      z[i] += y[j] * x[i][j];
    }
  }
  for (i = 0; i < a; i++) {
    printf("%d\\n", z[i]);
  }
}

Error: -11

Fixed submission:

#include <stdio.h>
int main() {
  int z[100], x[100][100], y[100], a, b, i, j;
  scanf("%d %d", &a, &b);
  for (i = 0; i < a; i++) {
    for (j = 0; j < b; j++) {
      scanf("%d", x[i][j]);
    }
  }
  for (i = 0; i < b; i++) {
    z[i] = 0;
    scanf("%d", y[i]);
  }
  for (i = 0; i < a; i++) {
    for (j = 0; j < b; j++) {
      z[i] += y[j] * x[i][j];
    }
  }
  for (i = 0; i < b; i++) {
    printf("%d\\n", z[i]);
  }
}
Problem p02410 (C++) — buggy submission, verdict: Runtime Error

#include <stdio.h>
int main(void) {
  int n, m, i, j, a[100] = {0};
  scanf("%d %d", &n, &m);
  int A[n][m], b[m];
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      scanf(" %d", &A[i][j]);
    }
  }
  for (i = 0; i < m; i++) {
    scanf(" %d", &b[i]);
  }
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      a[i] += A[i][j] * b[j];
    }
  }
  for (i = 0; i < n; i++) {
    printf("%d\\n", a[i]);
  }
  return 0;
}

Error: -11

Fixed submission:

#include <stdio.h>

int main() {
  int n, m, i, j, x = 0;
  scanf("%d %d", &n, &m);
  int A[m][n];
  int b[m];
  for (i = 0; i < m; i++) {
    for (j = 0; j < n; j++) {
      scanf(" %d %d %d %d", A[i][j]);
    }
  }
  for (i = 0; i < m; i++) {
    scanf(" %d", b[i]);
  }
  for (i = 0; i < m; i++) {
    for (j = 0; j < n; j++) {
      x += (A[i][j]) * (b[i]);
    }
    printf("%d\\n", x);
  }
  return 0;
}