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

#include <iostream>
using namespace std;

int main() {
  long long n, q, s[10001], t, k;
  cin >> n;
  for (long long i = 0; i < n; i++) {
    cin >> s[i];
  }
  cin >> q;
  k = 0;
  for (long long i = 0; i < q; i++) {
    cin >> t;
    for (long long j = 0; j < n; j++) {
      if (s[j] == t) {
        k++;
        break;
      }
    }
  }
  cout << k << endl;
  return 0;
}

Error: -11

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  long long n, q, s[1000000001], t, k;
  cin >> n;
  for (long long i = 0; i < n; i++) {
    cin >> s[i];
  }
  cin >> q;
  k = 0;
  for (long long i = 0; i < q; i++) {
    cin >> t;
    for (long long j = 0; j < n; j++) {
      if (s[j] == t) {
        k++;
        break;
      }
    }
  }
  cout << k << endl;
  return 0;
}
Problem p02267 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cstdio>
#include <iostream>
using namespace std;
int linersearch(int a[], int n, int key) {
  int i = 0;
  a[n] = key;
  while (a[i] != key)
    i++;
  return i != n;
}
int main() {
  int i, n, a[10001], q, key, sum = 0;
  scanf("%d", &n);
  for (i = 0; i < n; i++)
    scanf("%d", &a[i]);
  scanf("%d", &q);
  for (i = 0; i < q; i++) {
    scanf("%d", &key);
    if (linersearch(a, n, key))
      sum++;
  }
  printf("%d\\n", sum);
  return 0;
}


Error: TLE

Fixed submission:

#include <cstdio>
#include <iostream>
using namespace std;
int a[10005], b[503];
int main() {
  int n, q, ans = 0;
  scanf("%d", &n);
  for (int i = 0; i < n; i++)
    scanf("%d", &a[i]);
  scanf("%d", &q);
  for (int i = 0; i < q; i++)
    scanf("%d", &b[i]);
  for (int j = 0; j < q; j++)
    for (int i = 0; j < n; i++) {
      if (a[i] == b[j])
        ans++;
    }
  printf("%d\\n", ans);
  return 0;
}
Problem p02267 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;

const int MAX = 1e9 + 5;
bool t[MAX];

signed main() {
  int n, q;
  int ans = 0;

  cin >> n;
  for (int i = 0; i < n; i++) {
    int tmp;
    cin >> tmp;
    t[tmp] = 1;
  }

  cin >> q;
  for (int i = 0; i < q; i++) {
    int tmp;
    cin >> tmp;
    if (t[tmp] == 1) {
      ans++;
      t[tmp] = 0;
    }
  }

  cout << ans << endl;

  return (0);
}

Error: 0

Fixed submission:

#include <iostream>
using namespace std;

bool t[10005];

signed main() {
  int n, q;
  int ans = 0;

  cin >> n;
  for (int i = 0; i < n; i++) {
    int tmp;
    cin >> tmp;
    t[tmp] = 1;
  }

  cin >> q;
  for (int i = 0; i < q; i++) {
    int tmp;
    cin >> tmp;
    if (t[tmp] == 1) {
      ans++;
      t[tmp] = 0;
    }
  }

  cout << ans << endl;

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

#include <stdio.h>

int main() {
  int n, q;
  scanf("%d", &n);

  int S[n];
  for (int i = 0; i < n; i++)
    scanf("%d", &S[i]);
  scanf("%d", &q);

  int tmp, count = 0, flag;
  for (int i = 0; i < q; i++) {
    scanf("%d", &tmp);
    flag = 1;
    for (int j = 0; j < n; j++) {
      if (S[j] == tmp && flag) {
        count++;
        flag = 0;
      }
    }
  }

  printf("%d\\n", count);

  return 0;
}


Error: -11

Fixed submission:

#include <stdio.h>

int main() {
  int n, q;
  scanf("%d", &n);

  int S[n];
  for (int i = 0; i < n; i++)
    scanf("%d", &S[i]);
  scanf("%d", &q);

  int tmp, count = 0;
  for (int i = 0; i < q; i++) {
    scanf("%d", tmp);
    for (int j = 0; j > n; j++) {
      if (S[j] == tmp)
        count++;
    }
  }

  printf("%d\\n", count);

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


#include <stdio.h>
int main() {
  int n, S[10000], q, T[500], i, j, cnt = 0;

  scanf("%d", &n);
  for (i = 0; i < n; i++)
    scanf("%d", &S[i]);

  scanf("%d", &q);
  for (j = 0; j < q; j++)
    scanf("%d", &T[j]);

  for (i = 0; i < q; i++)
    for (j = 0; j < n; j++)
      if (T[i] == S[j]) {
        cnt++;
        break;
      }

  printf("%d\\n", cnt);
  return 0;
}

Error: 0

Fixed submission:

#include <stdio.h>

int main() {
  int count = 0, i, j, key, num1, num2;
  int row[100];

  scanf("%d", &num1);
  for (i = 0; i < num1; i++)
    scanf("%d", &row[i]);
  scanf("%d", &num2);
  for (i = 0; i < num2; i++) {
    scanf("%d", &key);
    for (j = 0; j < num1; j++) {
      if (row[j] == key)
        count++;
    }
  }

  printf("%d\\n", count);
  return 0;
}
Problem p02267 (C++) — buggy submission, verdict: Runtime Error

#include <cstdint>
#include <stdexcept>
#include <vector>

using namespace std;

size_t linear_search(uint32_t s[], size_t s_size, uint32_t t[], size_t t_size) {
  if (s == nullptr)
    throw runtime_error("s is null");
  if (t == nullptr)
    throw runtime_error("t is null");

  size_t cnt = 0;

  for (uint32_t i = 0; i < t_size; i++) {
    for (uint32_t j = 0; j < s_size; j++) {
      if (t[i] == s[j]) {
        cnt++;
        break;
      }
    }
  }

  return cnt;
}

#if !defined(TEST)
#include <iostream>
static vector<uint32_t> s, t;

int32_t main() {
  uint32_t n, m;
  cin >> n;
  for (uint32_t i = 0; i < n; i++) {
    uint32_t val;
    cin >> val;
    s.push_back(val);
  }

  cin >> m;
  for (uint32_t i = 0; i < m; i++) {
    uint32_t val;
    cin >> val;
    t.push_back(val);
  }

  cout << linear_search(&s[0], s.size(), &t[0], t.size()) << endl;

  return 0;
}
#endif

Error: 0

Fixed submission:

#include <cstdint>
#include <stdexcept>
#include <vector>

using namespace std;

static void linear_search_argument_check(uint32_t s[], size_t s_size,
                                         uint32_t t[], size_t t_size) {
  if (s == nullptr)
    throw runtime_error("s is null");
  if (t == nullptr)
    throw runtime_error("t is null");
}

size_t linear_search(uint32_t s[], size_t s_size, uint32_t t[], size_t t_size) {
  linear_search_argument_check(s, s_size, t, t_size);

  size_t cnt = 0;

  for (uint32_t i = 0; i < t_size; i++) {
    for (uint32_t j = 0; i < s_size; j++) {
      if (t[i] == s[j]) {
        cnt++;
        break;
      }
    }
  }

  return cnt;
}

#if !defined(TEST)
#include <iostream>
int32_t main() {
  vector<uint32_t> s, t;

  uint32_t n, m;
  cin >> n;
  for (uint32_t i = 0; i < n; i++) {
    uint32_t val;
    cin >> val;
    s.push_back(val);
  }

  cin >> m;
  for (uint32_t i = 0; i < m; i++) {
    uint32_t val;
    cin >> val;
    t.push_back(val);
  }

  cout << linear_search(&s[0], s.size(), &t[0], t.size()) << endl;

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

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
bool flag[1000000000];
signed main() {
  int n, m;
  cin >> n;
  int s[10000], t[10000];
  rep(i, n) cin >> s[i];
  cin >> m;
  int cnt = 0;
  rep(i, m) cin >> t[i];
  rep(i, n) {
    rep(j, m) {
      if (s[i] == t[j] && flag[s[i]] == false) {
        cnt++;
        flag[s[i]] = true;
        break;
      }
    }
  }
  cout << cnt << endl;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
bool flag[10000];
int main() {
  int n, m;
  cin >> n;
  int s[10000], t[10000];
  rep(i, n) cin >> s[i];
  cin >> m;
  int cnt = 0;
  rep(i, m) cin >> t[i];
  rep(i, n) {
    rep(j, m) {
      if (s[i] == t[j] && flag[s[i]] == false) {
        cnt++;
        flag[s[i]] = true;
        break;
      }
    }
  }
  cout << cnt << endl;
}
Problem p02267 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;
int main() {
  int *a = new int[1000000001];
  int n;
  cin >> n;
  while (n--) {
    int x;
    cin >> x;
    a[x] = 1;
  }
  int cnt = 0;
  cin >> n;
  while (n--) {
    int x;
    cin >> x;
    if (a[x])
      cnt++;
  }
  cout << cnt << endl;
  delete[] a;
  return 0;
}


Error: 0

Fixed submission:

#include <iostream>
using namespace std;
int a[10001];
int main() {
  int n;
  cin >> n;
  while (n--) {
    int x;
    cin >> x;
    a[x] = 1;
  }
  int cnt = 0;
  cin >> n;
  while (n--) {
    int x;
    cin >> x;
    if (a[x])
      cnt++;
  }
  cout << cnt << endl;
  return 0;
}
Problem p02267 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <list>
#include <map>
#include <stack>
#include <vector>
using namespace std;

#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define PUSH(n, v)                                                             \\
  for (int i = 0; i < (n); i++) {                                              \\
    int j;                                                                     \\
    cin >> j;                                                                  \\
    v.push_back(j);                                                            \\
  }
#define ALL(v) v.begin(), v.end()

map<int, bool> mp;
int cnt4;

int main() {
  int n;
  cin >> n;
  REP(i, n) {
    int j;
    cin >> j;
    mp[j] = true;
  }

  int m;
  cin >> m;
  REP(i, m) {
    int j;
    cin >> j;
    if (mp[j])
      cnt4++;
  }

  cout << cnt4 << endl;

  return 0;
}

Error: 0

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <list>
#include <map>
#include <stack>
#include <vector>
using namespace std;

#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define PUSH(n, v)                                                             \\
  for (int i = 0; i < (n); i++) {                                              \\
    int j;                                                                     \\
    cin >> j;                                                                  \\
    v.push_back(j);                                                            \\
  }
#define ALL(v) v.begin(), v.end()

bool mp[501];
int cnt4;

int main() {
  int n;
  cin >> n;
  vector<int> v;
  PUSH(n, v);

  int m;
  cin >> m;
  REP(i, m) {
    int j;
    cin >> j;
    mp[j] = true;
  }

  REP(i, n) {
    if (mp[v[i]])
      cnt4++;
  }

  cout << cnt4 << endl;

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

#include <stdio.h>
#define N 10000
#define Q 500

int main() {
  int n, i, j, q;
  int S[N];
  int T[Q];
  int count = 0;
  int a;
  /*1列目*/
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &S[i]);
  }
  /*2列め*/
  scanf("%d", &q);
  for (i = 0; i < q; i++) {
    scanf("%d", &T[i]);
  }
  /*重複個数計算*/
  for (i = 0; i < q; i++) {

    for (j = 0; j < n; j++) {

      if (S[j] == T[i]) {
        a = S[i];

        count++;
        break;
      }
    }
  }
  /*表示*/
  printf("%d\\n", count);

  return 0;
}


Error: -11

Fixed submission:

#include <stdio.h>
#define N 1000000000

int main() {
  int n, i, j, q;
  int S[N];
  int T[N];
  int count = 0;

  int a = 0;
  /*1列目*/
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &S[i]);
  }
  /*2列め*/
  scanf("%d", &q);
  for (i = 0; i < q; i++) {
    scanf("%d", &T[i]);
  }
  /*重複個数計算*/
  for (i = 0; i < n; i++) {

    for (j = 0; j < q; j++) {

      if (S[i] == T[j]) {
        if (a != S[i]) {
          a = S[i];
          count++;
        }
      }
    }
  }
  /*表示*/
  printf("%d\\n", count);

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

#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <iterator>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <time.h>
#include <vector>
using namespace std;
#define FOR(I, F, N) for (int I = F; I < (int)(N); I++)
#define rep(i, n) FOR(i, 0, n)
#define FIN(V) cout << V << endl
#define pb push_back
#define INF (1 << 30)
typedef pair<int, int> P;
typedef long long ll;
typedef priority_queue<int> pq;
int StrToInt(string);
string IntToStr(int);
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};

int main(void) {
  map<string, bool> memo;
  string s;
  int n, m;
  cin >> n;
  rep(i, n) {
    cin >> s;
    memo[s] = 1;
  }
  cin >> m;
  int cnt = 0;
  rep(i, m) {
    cin >> s;
    if (memo[s])
      cnt++;
  }
  FIN(cnt);

  return 0;
}

int StrToInt(string s) {
  stringstream ss;
  ss << s;
  int val;
  ss >> val;
  return val;
}
string IntToStr(int i) {
  stringstream ss;
  ss << i;
  return ss.str();
}

Error: 0

Fixed submission:

#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <iterator>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <time.h>
#include <vector>
using namespace std;
#define FOR(I, F, N) for (int I = F; I < (int)(N); I++)
#define rep(i, n) FOR(i, 0, n)
#define FIN(V) cout << V << endl
#define pb push_back
#define INF (1 << 30)
typedef pair<int, int> P;
typedef long long ll;
typedef priority_queue<int> pq;
int StrToInt(string);
string IntToStr(int);
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};

int main(void) {
  int a, n, m;
  cin >> n;
  int memo[10001];
  rep(i, n) {
    cin >> a;
    memo[a] = 1;
  }
  cin >> m;
  int cnt = 0;
  rep(i, m) {
    cin >> a;
    if (memo[a])
      cnt++;
  }
  FIN(cnt);

  return 0;
}

int StrToInt(string s) {
  stringstream ss;
  ss << s;
  int val;
  ss >> val;
  return val;
}
string IntToStr(int i) {
  stringstream ss;
  ss << i;
  return ss.str();
}
Problem p02267 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <set>

using namespace std;

int main() {
  set<int> set;
  int n, q;
  int count = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int s;
    cin >> s;
    set.insert(s);
  }
  cin >> q;
  for (int i = 0; i < q; i++) {
    int t;
    cin >> t;
    for (int a : set) {
      if (a == t)
        count++;
    }
  }
  cout << count << endl;
  return 0;
};


Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>
#include <list>
#include <set>
#include <sstream>
#include <vector>

using namespace std;

int main() {
  set<int> set;
  int n, q;
  int T[500];
  int count = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int s;
    cin >> s;
    set.insert(s);
  }
  cin >> q;
  for (int i = 0; i < q; i++) {
    int t;
    cin >> t;
    for (int a : set) {
      if (a == t)
        count++;
    }
  }
  cout << count << endl;
  return 0;
};
Problem p02267 (C++) — buggy submission, verdict: Runtime Error

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

void fnInput(vector<int> &a_rviTarget, vector<int> &a_rviSearch) {
  int iTargetCnt;
  cin >> iTargetCnt;

  for (int i = 0; i < iTargetCnt; i++) {
    int iTarget;
    cin >> iTarget;
    a_rviTarget.push_back(iTarget);
  }

  int iSearchCnt;
  cin >> iSearchCnt;

  for (int i = 0; i < iSearchCnt; i++) {
    int iSearch;
    cin >> iSearch;
    a_rviSearch.push_back(iSearch);
  }
}

void fnLinearSearch(const vector<int> &a_cnrviTarget,
                    const vector<int> &a_cnrviSearch, int &a_riFound) {
  for (auto itviSearch = begin(a_cnrviSearch); itviSearch != end(a_cnrviSearch);
       itviSearch++)
    for (auto itviTarget = begin(a_cnrviTarget);
         itviTarget != end(a_cnrviTarget); itviTarget++)
      if (*itviTarget == *itviSearch) {
        a_riFound++;
        break;
      }
}

void fnResultOut(int a_iFound) { cout << a_iFound << endl; }

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  vector<int> viTarget, viSearch;
  int iFound = 0;

  fnInput(viTarget, viSearch);
  fnLinearSearch(viTarget, viSearch, iFound);
  fnResultOut(iFound);

  return 0;
}

Error: WA

Fixed submission:

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

void fnInput(vector<int> &a_rviTarget, vector<int> &a_rviSearch) {
  const string FILENAME = "C:\\\\Users\\\\roshi_000\\\\OneDrive\\\\????????\\?????????"
                          "\\\\Develop\\\\C++\\\\ALDS1_4_A_in8.txt";

  ifstream fin(FILENAME.c_str());
  int iTargetCnt;
  fin >> iTargetCnt;

  for (int i = 0; i < iTargetCnt; i++) {
    int iTarget;
    fin >> iTarget;
    a_rviTarget.push_back(iTarget);
  }

  int iSearchCnt;
  fin >> iSearchCnt;

  for (int i = 0; i < iSearchCnt; i++) {
    int iSearch;
    fin >> iSearch;
    a_rviSearch.push_back(iSearch);
  }
  fin.close();
}

void fnLinearSearch(const vector<int> &a_cnrviTarget,
                    const vector<int> &a_cnrviSearch, int &a_riFound) {
  for (auto itviSearch = begin(a_cnrviSearch); itviSearch != end(a_cnrviSearch);
       itviSearch++)
    for (auto itviTarget = begin(a_cnrviTarget);
         itviTarget != end(a_cnrviTarget); itviTarget++)
      if (*itviTarget == *itviSearch) {
        a_riFound++;
        break;
      }
}

void fnResultOut(int a_iFound) { cout << a_iFound << endl; }

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  vector<int> viTarget, viSearch;
  int iFound = 0;

  fnInput(viTarget, viSearch);
  fnLinearSearch(viTarget, viSearch, iFound);
  fnResultOut(iFound);

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

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

void fnInput(vector<int> &a_rvoTarget, vector<int> &a_rvoSearch) {
  int iTargetCnt;
  cin >> iTargetCnt;

  a_rvoTarget.resize(iTargetCnt + 1);
  for (int i = 0; i < iTargetCnt; i++)
    cin >> a_rvoTarget[i];

  int iSearchCnt;
  cin >> iSearchCnt;

  a_rvoSearch.resize(iSearchCnt);
  for (int i = 0; i < iSearchCnt; i++)
    cin >> a_rvoSearch[i];
}

void fnLinearSearch(vector<int> &a_rvoTarget, const vector<int> &a_cnrvoSearch,
                    int &a_riFound) {
  size_t zMaxSize = a_rvoTarget.size() - 1;
  for (size_t zi = 0; zi < a_cnrvoSearch.size(); zi++) {
    a_rvoTarget[zMaxSize] = a_cnrvoSearch[zi];
    size_t zj = 0;
    while (a_rvoTarget[zj] != a_cnrvoSearch[zi])
      zj++;
    if (zj != zMaxSize)
      a_riFound++;
  }
}

void fnResultOut(int a_iFound) { cout << a_iFound << endl; }

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  vector<int> voTarget, voSearch;
  int iFound = 0;

  fnInput(voTarget, voSearch);
  fnLinearSearch(voTarget, voSearch, iFound);
  fnResultOut(iFound);

  return 0;
}

Error: -11

Fixed submission:

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

void fnInput(vector<int> &a_rvoTarget, vector<int> &a_rvoSearch) {
  int iTargetCnt;
  cin >> iTargetCnt;

  a_rvoTarget.resize(iTargetCnt + 1);
  for (int i = 0; i < iTargetCnt; i++)
    cin >> a_rvoTarget[i];

  int iSearchCnt;
  cin >> iSearchCnt;

  a_rvoSearch.resize(iSearchCnt);
  for (int i = 0; i < iSearchCnt; i++)
    cin >> a_rvoSearch[i];
}

void fnLinearSearch(vector<int> &a_rvoTarget, const vector<int> &a_cnrvoSearch,
                    int &a_riFound) {
  size_t zMaxSize = a_rvoTarget.size() - 1;
  for (size_t zi = 0; zi < a_cnrvoSearch.size(); zi++) {
    a_rvoTarget[zMaxSize] = a_cnrvoSearch[zi];
    size_t zj = 0;
    while (a_rvoTarget[zj] = a_cnrvoSearch[zi])
      zj++;
    if (zj != zMaxSize)
      a_riFound++;
  }
}

void fnResultOut(int a_iFound) { cout << a_iFound << endl; }

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  vector<int> voTarget, voSearch;
  int iFound = 0;

  fnInput(voTarget, voSearch);
  fnLinearSearch(voTarget, voSearch, iFound);
  fnResultOut(iFound);

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

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

void fnInput(vector<int> &a_rvoTarget, vector<int> &a_rvoSearch) {
  int iTargetCnt;
  cin >> iTargetCnt;

  for (int i = 0; i < iTargetCnt; i++) {
    int iTarget;
    cin >> iTarget;
    a_rvoTarget.push_back(iTarget);
  }

  int iSearchCnt;
  cin >> iSearchCnt;

  for (int i = 0; i < iSearchCnt; i++) {
    int iSearch;
    cin >> iSearch;
    a_rvoSearch.push_back(iSearch);
  }
}

void fnLinearSearch(const vector<int> &a_cnrvoTarget,
                    const vector<int> &a_cnrvoSearch, int &a_riFound) {
  for (auto itvoSearch = begin(a_cnrvoSearch); itvoSearch != end(a_cnrvoSearch);
       itvoSearch++)
    for (auto itvoTarget = begin(a_cnrvoTarget);
         itvoTarget != end(a_cnrvoTarget); itvoTarget++)
      if (*itvoTarget == *itvoSearch) {
        a_riFound++;
        break;
      }
}

void fnResultOut(int a_iFound) { cout << a_iFound << endl; }

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  vector<int> voTarget, voSearch;
  int iFound = 0;

  fnInput(voTarget, voSearch);
  fnLinearSearch(voTarget, voSearch, iFound);
  fnResultOut(iFound);

  return 0;
}

Error: WA

Fixed submission:

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

void fnInput(vector<int> &a_rvoTarget, vector<int> &a_rvoSearch) {
  const string FILENAME = "C:\\\\Users\\\\roshi_000\\\\OneDrive\\\\????????\\?????????"
                          "\\\\Develop\\\\C++\\\\ALDS1_4_A_in8.txt";

  ifstream fin(FILENAME.c_str());
  int iTargetCnt;
  fin >> iTargetCnt;

  for (int i = 0; i < iTargetCnt; i++) {
    int iTarget;
    fin >> iTarget;
    a_rvoTarget.push_back(iTarget);
  }

  int iSearchCnt;
  fin >> iSearchCnt;

  for (int i = 0; i < iSearchCnt; i++) {
    int iSearch;
    fin >> iSearch;
    a_rvoSearch.push_back(iSearch);
  }
  fin.close();
}

void fnLinearSearch(const vector<int> &a_cnrvoTarget,
                    const vector<int> &a_cnrvoSearch, int &a_riFound) {
  for (auto itvoSearch = begin(a_cnrvoSearch); itvoSearch != end(a_cnrvoSearch);
       itvoSearch++)
    for (auto itvoTarget = begin(a_cnrvoTarget);
         itvoTarget != end(a_cnrvoTarget); itvoTarget++)
      if (*itvoTarget == *itvoSearch) {
        a_riFound++;
        break;
      }
}

void fnResultOut(int a_iFound) { cout << a_iFound << endl; }

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  vector<int> voTarget, voSearch;
  int iFound = 0;

  fnInput(voTarget, voSearch);
  fnLinearSearch(voTarget, voSearch, iFound);
  fnResultOut(iFound);

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

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

int main() {
  int ans = 0, n, q, a;
  set<int> arr;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a;
    arr.insert(a);
  }
  cin >> q;
  for (int i = 0; i < q; i++) {
    cin >> a;
    if (arr.find(a) != arr.end())
      ans++;
  }
  cout << ans << endl;

  return 0;
}

Error: -11

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  int ans = 0, n, q, a;
  int arr[1000000001];
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a;
    arr[a] = 1;
  }
  cin >> q;
  for (int i = 0; i < q; i++) {
    cin >> a;
    if (arr[a] == 1)
      ans++;
  }
  cout << ans << endl;

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

#include <cstdio>
using namespace std;

int a[10005];
bool Find(int n, int key) {
  int i = 0;
  a[n] = key;
  while (a[i] != key)
    i++;
  if (i != n)
    return true;
  else
    return false;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++)
    scanf("%d", &a[i]);
  int q, key, cnt = 0;
  scanf("%d", &q);
  for (int i = 0; i < q; i++) {
    scanf("%d", &key);
    if (Find(n, key))
      cnt++;
  }
  printf("%d\\n", cnt);
  return 0;
}

Error: 0

Fixed submission:

#include <cstdio>
using namespace std;

int a[1005];
bool Find(int n, int key) {
  int i = 0;
  a[n] = key;
  while (a[i] != key)
    i++;
  if (i != n)
    return true;
  else
    return false;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++)
    scanf("%d", &a[i]);
  int q, key, cnt = 0;
  scanf("%d", &q);
  for (int i = 0; i < q; i++) {
    scanf("%d", &key);
    if (Find(n, key))
      cnt++;
  }
  printf("%d\\n", cnt);
  return 0;
}