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

#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, n) for (int i = n; i >= 0; --i)
const int inf = 1e9 + 7;
const ll mod = 1e9 + 7;
const ll mod1 = 998244353;
const ll big = 1e18;
const double PI = 2 * asin(1);

int main() {
  int L, R, D;
  cin >> L >> R >> D;
  int ans = 0;
  for (int i = L; i <= R; ++i) {
    if (i % D == 0)
      ans++;
  }
  cout << ans << endl;
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, n) for (int i = n; i >= 0; --i)
const int inf = 1e9 + 7;
const ll mod = 1e9 + 7;
const ll mod1 = 998244353;
const ll big = 1e18;
const double PI = 2 * asin(1);

int main() {
  int L, R, D;
  int ans = 0;
  for (int i = L; i <= R; ++i) {
    if (i % D == 0)
      ans++;
  }
  cout << ans << endl;
}
Problem p02606 (C++) — buggy submission, verdict: Runtime Error

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, a, b) for (int i = (a); i <= (b); i++)
#define repA(i, n) for (int i = n; i >= 0; i--)
#define all(x) x.begin(), x.end()
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sz(a) (int)(a.size())

typedef long long ll;
typedef long double ld;
const ll mod = (ll)(1e9 + 7); // 998244353;
const int N = (int)(1e6 + 5);

void pre() {}

void solve() {
  ll l, r, d;
  cin >> l >> r >> d;
  int cnt = 0;
  repi(i, l, r) if (i % d == 0) cnt++;
  cout << cnt;
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  //  freopen("output.txt","w",stdout);
#endif
  int t = 1;
  pre();
  // cin>>t;
  rep(i, t) {
    //    cout<<"\\nCase #"<<(i+1)<<"\\n";
    solve();
    cout << '\\n';
  }
  return 0;
}


Error: TLE

Fixed submission:

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, a, b) for (int i = (a); i <= (b); i++)
#define repA(i, n) for (int i = n; i >= 0; i--)
#define all(x) x.begin(), x.end()
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sz(a) (int)(a.size())

typedef long long ll;
typedef long double ld;
const ll mod = (ll)(1e9 + 7); // 998244353;
const int N = (int)(1e6 + 5);

void pre() {}

void solve() {
  ll l, r, d;
  cin >> l >> r >> d;
  int cnt = 0;
  repi(i, l, r) if (i % d == 0) cnt++;
  cout << cnt;
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  //  freopen("output.txt","w",stdout);
#endif
  int t = 1;
  pre();
  cin >> t;
  rep(i, t) {
    //    cout<<"\\nCase #"<<(i+1)<<"\\n";
    solve();
    cout << '\\n';
  }
  return 0;
}
Problem p02606 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  int l, r, d;
  cin >> l >> r >> d;
  cout << r / d - (l - 1) / d;
}

Error: TLE

Fixed submission:

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

int main() {
  int l, r, d;
  cin >> l >> r >> d;
  int ans = 0;
  for (int i = l; i <= r; i = i++) {
    if (i % d == 0)
      ans++;
  }
  cout << ans;
}
Problem p02606 (C++) — buggy submission, verdict: Runtime Error

#include <stdio.h>

int main() {
  int L, R, d, ctr = 0;
  scanf("%d %d %d", &L, &R, &d);

  while (L <= R) {
    if (L % d == 0) {
      ctr = ctr + 1;
    }
    L++;
  }
  printf("%d\\n", ctr);

  return 0;
}

Error: WA

Fixed submission:

#include <stdio.h>
int main() {
  int L, R, d, ctr = 0;
  while (L <= R) {
    if (L % d == 0) {
      ctr = ctr + 1;
    } else {
      L++;
    }
  }
  printf("%d %d %d %d\\n", L, R, d, ctr);
  return 0;
}
Problem p02606 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <vector>

using namespace std;

int main() {
  int l, r, d;
  int ans = 0;
  cin >> l >> r >> d;
  for (int i = l; i <= r; i++) {
    if (i % d == 0)
      ans++;
  }
  cout << ans;
}

Error: TLE

Fixed submission:

#include <iostream>
#include <vector>

using namespace std;

int main() {
  int l, r, d;
  int ans = 0;
  for (int i = l; i <= r; i++) {
    if (i % d == 0)
      ans++;
  }
  cout << ans;
}
Problem p02606 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>

using namespace std;

int main() {
  int L, R, d;
  cin >> L >> R >> d;
  cout << R / d - (L - 1) / d;
  return 0;
}

Error: WA

Fixed submission:

#include <iostream>

using namespace std;

int main() {
  int L, R, d;
  cout << R / d - (L - 1) / d;
  return 0;
}
Problem p02606 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int l, r, d;
  cin >> l;
  cin >> r;
  cin >> d;
  int count = 0;
  for (int i = l; i <= r; i++) {
    if (i % d == 0)
      count++;
  }
  cout << count << endl;
}

Error: -8

Fixed submission:

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

int main() {
  int l, r, d;
  cin >> l >> r >> d;
  int count = 0;
  for (int i = l; i <= r; i++) {
    if (i % count == 0)
      count++;
  }
  cout << count << endl;
}
Problem p02606 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>

using namespace std;

int main() {
  int l, r, d;
  cin >> l >> r >> d;
  int ans = 0;
  for (int i = l; i <= r; ++i) {
    if (i % d == 0)
      ans++;
  }
  cout << ans << '\\n';
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

int main() {
  int l, r, d;
  cin >> l >> r >> d;
  int ans = 0;
  for (int i = l; l <= r; ++i) {
    if (i % d == 0)
      ans++;
  }
  cout << ans << '\\n';
  return 0;
}
Problem p02606 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
#define IOS                                                                    \\
  ios::sync_with_stdio(0);                                                     \\
  cin.tie(0);                                                                  \\
  cout.tie(0);

int main() {
  IOS;
  int l, r, d, c = 0;
  cin >> l >> r >> d;
  for (int i = l; i <= r; i++) {
    if (i % d == 0) {
      c++;
    }
  }
  cout << c;
  return 0;
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define IOS                                                                    \\
  ios::sync_with_stdio(0);                                                     \\
  cin.tie(0);                                                                  \\
  cout.tie(0);

int solve() {
  int l, r, d, c = 0;
  cin >> l >> r >> d;
  cout << floor((r - l + 1) / d);
}

int main() {
  IOS;
  { solve(); }

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

#include <bits/stdc++.h>
#include <cstdlib>
#include <numeric>
#define ll long long int
#define all(x) x.begin(), x.end()

#define fastio                                                                 \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL)

#define v vector<long long int>
#define vv vector<int>
#define gcd(m, n) __gcd(m, n)
#define vp vector<pair<long long int, long long int>>
#define pb push_back
#define mp make_pair
#define pp pop_back
#define iter vector<int>::iterator
#define pa pair<long long int, long long int>
#define f(i, n) for (ll i = 0; i < n; i++)
#define loop(i, a, n) for (ll i = a; i < n; i += 1)
#define fe(d, e) for (auto d : e)
#define mod 1000000007
#define F first
#define S second
#define sett set<long long int>
#define um unordered_map<ll, ll>
#define N 100005LL
#define cout1(x) cout << x << "\\n";
#define deb(x) cout << #x << " " << x << "\\n";
using namespace std;
void print_vector(v arr) {
  f(i, arr.size()) cout << arr[i] << " ";
  cout << endl;
}

void solve() {
  ll l, r, d;
  cin >> l >> r >> d;
  ll ans = r / d - l / d;
  if (l % d == 0)
    ans++;
  cout << ans << endl;
}

int main() {
  fastio;
  ll t;
  // cin>>t;
  t = 1;
  f(_, t) { solve(); }
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
#include <cstdlib>
#include <numeric>
#define ll long long int
#define all(x) x.begin(), x.end()

#define fastio                                                                 \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL)

#define v vector<long long int>
#define vv vector<int>
#define gcd(m, n) __gcd(m, n)
#define vp vector<pair<long long int, long long int>>
#define pb push_back
#define mp make_pair
#define pp pop_back
#define iter vector<int>::iterator
#define pa pair<long long int, long long int>
#define f(i, n) for (ll i = 0; i < n; i++)
#define loop(i, a, n) for (ll i = a; i < n; i += 1)
#define fe(d, e) for (auto d : e)
#define mod 1000000007
#define F first
#define S second
#define sett set<long long int>
#define um unordered_map<ll, ll>
#define N 100005LL
#define cout1(x) cout << x << "\\n";
#define deb(x) cout << #x << " " << x << "\\n";
using namespace std;

int solve() {
  ll l, r, d;
  cin >> l >> r >> d;
  ll ans = r / d - l / d;
  if (l % d == 0)
    ans++;
  cout << ans << endl;
}

int main() {
  fastio;
  ll t;
  // cin>>t;
  t = 1;
  f(_, t) { solve(); }
}
Problem p02606 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int main() {
  int l, r, d, c = 0;
  cin >> l >> r >> d;
  while (l <= r) {
    if (l % d == 0) {
      c++;
    }
    l++;
  }
  cout << c << endl;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int main() {
  int l, r, d, c = 0;
  cin >> l >> r >> d;
  while (l <= r) {
    if (l % 2 == 0) {
      c++;
    }
  }
  cout << c << endl;
}
Problem p02606 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
int main() {
  int l, r, d;
  cin >> l >> r >> d;
  int sum = 0;
  for (int i = l; i <= r; i++) {
    if (i % d == 0) {
      sum++;
    }
  }
  cout << sum << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  int l, r, d;
  int sum = 0;
  for (int i = l; i <= r; i++) {
    if (i % d == 0) {
      sum++;
    }
  }
  cout << sum << endl;
  return 0;
}
Problem p02606 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>

using namespace std;

int main() {
  int a, b, c, d = 0;
  cin >> a >> b >> c;
  for (int i = a; i <= b; i++) {
    if (i % c == 0) {
      d++;
    }
  }
  cout << d;
}


Error: TLE

Fixed submission:

#include <stdio.h>

int main() {
  int L, R, d, ctr = 0;

  while (L <= R) {
    if (L % d == 0) {
      ctr = ctr + 1;
    } else if (R % d == 0) {
      ctr = ctr + 1;
    }
    L++;
    R++;
  }
  printf("%d", ctr);
  return 0;
}
Problem p02606 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
int main() {
  int L, R, d;
  cin >> L >> R >> d;
  int ans = 0;
  for (int i = L; i <= R; i++) {
    if (i % d == 0)
      ans++;
  }
  cout << ans << endl;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  int L, R, d;
  int ans = 0;
  for (int i = L; i <= R; i++) {
    if (i % d == 0)
      ans++;
  }
  cout << ans << endl;
}
Problem p02606 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
/*
 *    coder :: ATUL_PANDEY_2608
 *        >>> INDIA <<<
 */
using namespace std;

// #define  part ..
#define pb(a) push_back(a)
#define all(a) a.begin(), a.end()
#define mod 1000000007
#define maxx 200006
#define ll long long
#define quick ios_base::sync_with_stdio(NULL), cin.tie(0);
#define listll vector<long long>
#define listi vector<int>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define minheap priority_queue<long long, vector<long long>, greater<long long>>
#define rep(i, a, b) for (int i = a; i < b; i++)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

// end of #define

// define globals ...

// write function from here ...

int Main() {

  int a, b, d;
  cin >> a >> b >> d;

  int ans = 0;

  ans -= a / d;
  ans += b / d;
  if (a % d == 0)
    ans++;

  cout << ans;

  return 0;
}

int main() {
  quick;

  //      #ifndef ONLINE_JUDGE
  //   freopen ("input.txt", "r", stdin);
  //   freopen ("outt.txt", "w", stdout);
  // #endif

  Main();

  return 0;
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
/*
 *    coder :: ATUL_PANDEY_2608
 *        >>> INDIA <<<
 */
using namespace std;

// #define  part ..
#define pb(a) push_back(a)
#define all(a) a.begin(), a.end()
#define mod 1000000007
#define maxx 200006
#define ll long long
#define quick ios_base::sync_with_stdio(NULL), cin.tie(0);
#define listll vector<long long>
#define listi vector<int>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define minheap priority_queue<long long, vector<long long>, greater<long long>>
#define rep(i, a, b) for (int i = a; i < b; i++)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

// end of #define

// define globals ...

// write function from here ...

int Main() {

  int a, b, d;
  cin >> a >> b >> d;

  int ans = 0;

  ans -= a / d;
  ans += b / d;
  if (a % d == 0)
    ans++;

  cout << ans;
}

int main() {
  quick;

  //      #ifndef ONLINE_JUDGE
  //   freopen ("input.txt", "r", stdin);
  //   freopen ("outt.txt", "w", stdout);
  // #endif

  Main();

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


#include <cstdint>
#include <iostream>
#include <string>

int main(int argc, char *argv[]) {
  int32_t L, R, d;
  std::cin >> L;
  std::cin >> R;
  std::cin >> d;
  int cnt = 0;
  for (int i = L; i <= R; ++i) {
    cnt += (i % d == 0) ? 1 : 0;
  }

  std::cout << cnt << std::endl;
  return 0;
}


Error: -11

Fixed submission:


#include <cstdint>
#include <iostream>
#include <string>

int main(int argc, char *argv[]) {
  const int32_t L = std::atoi(argv[1]);
  const int32_t R = std::atoi(argv[2]);
  const int32_t d = std::atoi(argv[3]);
  std::cout << (R - L) / d << std::endl;
  return 0;
}
Problem p02606 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
  ll l, r, d, cnt = 0;
  cin >> l >> r >> d;

  if (l % d == 0 || r % d == 0)
    cnt++;
  cnt += ((r - l) / d);

  cout << cnt << endl;

  return 0;
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
  ll l, r, d, cnt = 0;
  cin >> l >> r;

  if (l % d == 0 || r % d == 0)
    cnt++;
  cnt += ((r - l) / d);

  cout << cnt << endl;

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

#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
  ll l, r, d, cnt = 0;
  cin >> l >> r >> d;

  for (ll i = l; i <= r; i++) {
    if (i % d == 0)
      cnt++;
  }
  cout << cnt << endl;

  return 0;
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
  ll l, r, d, cnt = 0;
  cin >> l >> r;

  for (ll i = l; i <= r; i++) {
    if (i % d == 0)
      cnt++;
  }
  cout << cnt << endl;

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

#include <bits/stdc++.h>
using namespace std;
#define rep(i, N) for (int i = 0; i < N; i++)
typedef long long ll;
#define dump(x) cerr << #x << "=" << x << endl
using P = pair<int, int>;

int main() {
  int l, r, d;
  cin >> l >> r >> d;
  int cnt = 0;
  for (int i = l; i <= r; i++) {
    if (i % d == 0)
      cnt++;
  }
  cout << cnt << endl;
  return 0;
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define rep(i, N) for (int i = 0; i < N; i++)
typedef long long ll;
#define dump(x) cerr << #x << "=" << x << endl
using P = pair<int, int>;

int main() {
  int l, r, d;
  cin >> l >> r, d;
  int cnt = 0;
  for (int i = l; i <= r; i++) {
    if (i % d == 0)
      cnt++;
  }
  cout << cnt << endl;
  return 0;
}
Problem p02606 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

using namespace std;

int main() {
  long long l, r, d;
  cin >> l >> r >> d;
  l--;
  long long ans = 0;
  ans += r / d;
  ans -= l / d;
  cout << ans << endl;
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

int main() {
  long long l, r, d;
  l--;
  long long ans = 0;
  ans += r / d;
  ans -= l / d;
  cout << ans << endl;
}
Problem p02606 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  int L, R, d, c = 0;
  cin >> L >> R >> d;

  for (int i = L; i <= R; ++i)
    if (i % d == 0)
      ++c;
  cout << c << endl;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)

int main() {
  int L, R, d, c = 0;
  cin >> L >> R >> d;

  for (int i = L; L <= R; ++i)
    if (i % d == 0)
      ++c;
  cout << c << endl;
}
Problem p02606 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pb push_back
#define pr pair<int, int>
#define mod 1000000007
#define endl "\\n"

int power(int a, int b, int m = mod) {
  if (b == 0)
    return 1;
  if (b == 1)
    return a;
  int res = power(a, b / 2, m);
  res = (res * res) % m;
  if (b & 1)
    res = (res * a) % m;
  return res;
}
int modinv(int a, int m = mod) { return power(a, m - 2, m); }
int add(int a, int b, int m = mod) {
  int c = (a % m + b % m);
  if (c >= m)
    c -= m;
  return c;
}
int sub(int a, int b, int m = mod) {
  int c = (a % m - b % m);
  if (c < 0)
    c += m;
  return c;
}
int mul(int a, int b, int m = mod) { return (a * b) % m; }
//	x<<1 => x*2		x>>1 => x/2;	cout<<flush;
//	cout<<fixed<<setprecision(10)<<ans<<endl;

void solve() {
  int a, b, x, n = 0;
  cin >> a >> b >> x;
  for (int i = a; i <= b; i++) {
    if (i % x == 0)
      n++;
  }
  cout << n << endl;
}

int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  int t = 1; // cin>>t;
  for (int i = 1; i <= t; i++) {
    solve();
  }
  return 0;
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pb push_back
#define pr pair<int, int>
#define mod 1000000007
#define endl "\\n"

void solve() {
  int n, a, z = 0, x;
  cin >> n >> a >> x;
  for (int i = n; i <= a; i++) {
    if (i % x == 0)
      z++;
  }
  cout << z << endl;
}

int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  int t = 1;
  cin >> t;
  for (int i = 1; i <= t; i++) {
    solve();
  }
  return 0;
}
Problem p02606 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>

using namespace std;

int main() {
  int x, y, z;
  cin >> x >> y >> z;
  int cntr = 0;
  for (int i = x; i <= y; i++) {
    if (i % z == 0)
      cntr++;
  }
  cout << cntr;
}


Error: WA

Fixed submission:

#include <iostream>

using namespace std;

int main() {
  int x, y, z;
  cin >> x >> y;
  int cntr = 0;
  for (int i = x; i <= y; i++) {
    if (i % z == 0)
      cntr++;
  }
  cout << cntr;
}
Problem p02607 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
#define INF (1e9)

int main() {
  int N;
  cin >> N;
  vi a(N + 1);
  ll ans = 0;
  for (ll i = 1; i <= N; i++) {
    cin >> a[i];
    if (a[i] % 2 == 1 && i % 2 == 1)
      ans++;
  }

  cout << ans << endl;
}


Error: -6
Fatal glibc error: malloc assertion failure in sysmalloc: (old_top == initial_top (av) && old_size == 0) || ((unsigned long) (old_size) >= MINSIZE && prev_inuse (old_top) && ((unsigned long) old_end & (pagesize - 1)) == 0)


Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
#define INF (1e9)

int main() {
  int N;
  cin >> N;
  vi a(N);
  ll ans = 0;
  for (ll i = 1; i <= N; i++) {
    cin >> a[i];
    if (a[i] % 2 == 1 && i % 2 == 1)
      ans++;
  }

  cout << ans << endl;
}
Problem p02607 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

#define rep(i, n) for (int i; i < (int)(n); i++)
#define Rep(i, n) for (int i; i <= (int)(n); i++)
#define all(v) v.begin, v.end
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MX = 1000005;

int main() {
  int n, a, cnt = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a;
    if ((i % 2 == 0) && (a % 2 == 1))
      cnt++;
  }
  cout << cnt << endl;
}

Error: -11

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, n) for (int i; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MX = 1000005;

int main() {
  int n, cnt;
  cnt = 0;
  vector<int> a;
  cin >> n;
  rep(i, n) {
    if (i % 2) {
      cin >> a[i];
    }
  }
  rep(i, n) {
    if (a[i] % 2 == 1) {
      cnt++;
    }
  }
  cout << cnt << endl;
}
Problem p02607 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int n;
  cin >> n;
  int ans = 0;
  vector<int> a(100);
  for (int i = 0; i < 100; i++) {
    cin >> a.at(i);
    if ((i + 1) % 2 != 0 && a[i] % 2 != 0) {
      ans++;
    }
  }

  cout << ans << endl;
}


Error: 0

Fixed submission:

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

int main() {
  int n;
  cin >> n;
  vector<int> a(100);
  for (int i = 0; i < 100; i++) {
    cin >> a.at(i);
  }

  int ans = 0;

  for (int i = 0; i <= n; i++) {
    int b = a.at(i);
    if ((i + 1) % 2 == 1 && b % 2 == 1) {
      ans++;
    }
  }
  cout << ans << endl;
}
Problem p02607 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int N = 0;
  int count = 0;
  cin >> N;
  vector<int> data(N);
  for (int i = 0; i < N; i++) {
    cin >> data.at(i);
  }
  for (int i = 0; i < data.size(); i += 2) {
    if (data.at(i) % 2 != 0)
      count++;
  }
  cout << count << endl;
  return 0;
}


Error: -6
terminate called after throwing an instance of 'std::out_of_range'
  what():  vector::_M_range_check: __n (which is 6) >= this->size() (which is 5)


Fixed submission:

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

int main() {
  int N = 0;
  int count = 0;
  cin >> N;
  vector<int> data(N);
  for (int i = 0; i < N; i++) {
    cin >> data.at(i);
  }
  for (int i = 0; i < data.size(); i++) {
    if (data.at(2 * i) % 2 == 0)
      count++;
  }
  cout << count << endl;
  return 0;
}