alexjercan/bugnet huggingface dataset:
Problem p02410 (C++) — buggy submission, verdict: Runtime Error

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


Error: 0

Fixed submission:

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

  return 0;
}

Error: -11

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

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

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

#include <iostream>
using namespace std;

int main() {
  int A[100][100];
  int B[100];
  int C[100];
  int n = 0, m = 0;

  cin >> n >> m;
  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++) {
    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: 0

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  int A[100][100];
  int B[100][1];
  int C[1][100];
  int n = 0, m = 0;
  for (int i = 0; i < 100; i++) {
    for (int j = 0; j < 100; j++) {
      A[i][j] = 0;
      C[j][0] = 0;
    }
    B[i][0] = 0;
  }
  cin >> n >> m;
  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][0];
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      C[0][i] += A[i][j] * B[j][0];
    }
    cout << C[0][i] << "\\n";
  }
  return 0;
}
Problem p02410 (C++) — buggy submission, verdict: 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(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;
  }
}

Error: 0

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

#include <iostream>
using namespace std;

int main() {
  int n, m;
  int x, y, a[100][100], b[100];
  int c = 0;
  cin >> n >> m;

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


Error: -11

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  int n, m;
  int x, y, a[n][m], b[m];
  int c[100];
  cin >> n >> m;

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

#include <iostream>
#include <stdlib.h>

using namespace std;

int main() {

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

  // n,m?????\\???
  cin >> n >> m;

  // a,b,c?????????????¢????(malloc???????????´???)
  /*
  a = (int **)malloc(sizeof(int)*n);
  for (int i = 0; i < n; i++) {
          a[i] = (int *)malloc(sizeof(int)*m);
  }
  b = (int *)malloc(sizeof(int)*m);
  c = (int *)malloc(sizeof(int)*m);
  if (a == NULL || b == NULL||c==NULL) {
          cout << "malloc error" << endl;
          exit(1);
  }
  */

  //???????????°
  // cout << "n=" << n << " m=" << m << endl;

  // a?????\\???
  for (int i = 0; i < n; i++) {
    // cout << "i=" << i << endl;
    for (int j = 0; j < m; j++) {
      // cout << "j=" << j << endl;
      cin >> a[i][j];
    }
  }

  // b?????\\???
  for (int j = 0; j < m; j++) {
    cin >> b[j];
  }

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

  //?????¢????§£???(malloc???????????´???)
  /*
  for (int i = 0; i < n; i++) {
          free(a[i]);
  }
  free(a);
  free(b);
  */

  return 0;
}

Error: 0

Fixed submission:

#include <iostream>
#include <stdlib.h>

using namespace std;

int main() {

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

  // n,m?????\\???
  cin >> n >> m;

  // a,b,c?????????????¢????
  a = (int **)malloc(sizeof(int) * n);
  for (int i = 0; i < n; i++) {
    a[i] = (int *)malloc(sizeof(int) * m);
  }
  b = (int *)malloc(sizeof(int) * m);
  c = (int *)malloc(sizeof(int) * m);
  if (a == NULL || b == NULL || c == NULL) {
    cout << "malloc error" << endl;
    exit(1);
  }

  //???????????°
  // cout << "n=" << n << " m=" << m << endl;

  // a?????\\???
  for (int i = 0; i < n; i++) {
    // cout << "i=" << i << endl;
    for (int j = 0; j < m; j++) {
      // cout << "j=" << j << endl;
      cin >> a[i][j];
    }
  }

  // b?????\\???
  for (int j = 0; j < m; j++) {
    cin >> b[j];
  }

  //???????¨?????????¨?????????
  for (int i = 0; i < n; i++) {
    c[i] = 0;
    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++) {
          free(a[i]);
  }
  free(a);
  free(b);
  */

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

Error: 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(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;
}
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 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];
    }
  }

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

Error: TLE

Fixed submission:

#include <iostream>

using namespace std;

int main() {
  int n, m, N[100][100], M[100], c[100];
  cin >> n >> m;

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

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

  for (int a = 0; a < n; a++) {
    for (int b = 0; b < m; b++) {
      c[a] = N[a][b] * M[a];
    }
  }

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


Error: 0

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

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

Error: 0

Fixed submission:

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

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

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

  return 0;
}


Error: TLE

Fixed submission:

// itp1_topic6_d
#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; m++)
      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;

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

#include <iostream>
#include <vector>

int main() {
  using namespace std;
  int A_num, b_num, A_count, b_count, data, row = 0, col = 0;
  cin >> A_num >> b_num;
  A_count = A_num * b_num;
  b_count = b_num;
  vector<vector<int>> A(A_num, vector<int>(b_num));
  vector<int> b(b_num);
  while (A_count > 0) {
    cin >> data;
    A[row][col] = data;
    col++;
    if (col == b_num) {
      row++;
      col = 0;
    }
    A_count--;
  }
  col = 0;
  while (b_count > 0) {
    cin >> data;
    b[col] = data;
    col++;
    b_count--;
  }
  for (int i = 0; i < A_num; i++) {
    int sum = 0;
    for (int j = 0; j < b_num; j++) {
      sum += A[i][j] * b[j];
    }
    cout << sum << endl;
  }

  return 0;
}

Error: 0

Fixed submission:

#include <iostream>

int main() {
  using namespace std;
  int A_num, b_num, A_count, b_count, data, row = 0, col = 0;
  cin >> A_num >> b_num;
  A_count = A_num * b_num;
  b_count = b_num;
  int **A = (int **)malloc(sizeof(int *) * A_num);
  for (int i = 0; i < b_num; i++) {
    A[i] = (int *)malloc(sizeof(int) * b_num);
  }
  int *b = (int *)malloc(sizeof(int) * b_num);
  while (A_count > 0) {
    cin >> data;
    A[row][col] = data;
    col++;
    if (col == b_num) {
      row++;
      col = 0;
    }
    A_count--;
  }
  col = 0;
  while (b_count > 0) {
    cin >> data;
    b[col] = data;
    col++;
    b_count--;
  }
  for (int i = 0; i < A_num; i++) {
    int sum = 0;
    for (int j = 0; j < b_num; j++) {
      sum += A[i][j] * b[j];
    }
    cout << sum << endl;
  }
  return 0;
}
Problem p02410 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

int main() {

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

  for (int i = 1; i < 1000; i++) {
    SUM[i] = 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[i] += a[i][j] * b[j];
    }
    cout << SUM[i] << endl;
  }

  return 0;
}


Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  int a[1000][1000], b[1000];
  int n, m;
  int i, j;

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

  for (j = 0; j < m; j++)
    cin >> b[j];

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

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

#include <stdio.h>
#include <string.h>

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


Error: 0

Fixed submission:

#include <cstdio>

int main() {
  int n, m, a[100][100], b[100], c[100];
  scanf("%d %d", &n, &m);

  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      scanf("%d", &a[i][j]);
    }
  }
  for (int i = 1; i <= m; i++) {
    scanf("%d", &b[i]);
  }

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

  for (int j = 1; j <= n; j++) {
    printf("%d\\n", c[j]);
  }
  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>> 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;
}

Error: 0

Fixed submission:

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

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

Error: WA

Fixed submission:

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

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

#include <iostream>
using namespace std;

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

  int a[100][100] = {};
  int b[100] = {};

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

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

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

  return 0;
}


Error: 0

Fixed submission:

#include <iostream>
using namespace std;

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

  int a[99][99] = {};
  int b[99] = {};

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

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

  int c;
  for (int i = 0; i < n; i++) {
    c = 0;
    for (int j = 0; j < m; j++) {
      c += a[i][j] * b[j];
    }
    cout << c << endl;
  }
}
Problem p02410 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int m, n;
  int a[1000][1000];
  int b[1000];
  cin >> m >> n;

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

  int c[1000] = {};
  for (int i = 1; i <= m; i++) {
    for (int g = 1; g <= n; g++) {
      c[i] += a[i][g] * b[g];
    }
  }

  for (int i = 1; i <= m; i++) {
    cout << c[i] << endl;
  }

  return 0;
}


Error: -11

Fixed submission:

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

int main() {
  int m, n;
  int a[10000][10000];
  int b[10000];
  cin >> m, n;

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

  int c[10000] = {};
  for (int i = 1; i <= m; i++) {
    for (int g = 1; g <= n; g++) {
      c[i] += a[i][g] * b[g];
    }
  }

  for (int i = 1; i <= m; i++) {
    cout << c[i] << endl;
  }

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

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int a[101][101], b[101];
  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];
  }
  vector<int> ans(1001, 0);
  for (int i = 0; i < n; i++) {
    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: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  long long a[n][m], b[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];
  }
  vector<int> ans(m, 0);
  for (int i = 0; i < n; i++) {
    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;
}