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

#include <bits/stdc++.h>
using namespace std;
int main() {
  int x1, x2, x3, x4, x5;
  cin >> x1 >> x2 >> x3 >> x4 >> x5;
  if (x1 == 0)
    cout << 1 << endl;

  else if (x2 == 0)
    cout << 2 << endl;
  else if (x3 == 0)
    cout << 3 << endl;
  else if (x4 == 0)
    cout << 4 << endl;
  else if (x5 == 0)
    cout << 5 << endl;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  int ara[5], i, c = 0;
  for (i = 1; i <= 5; i++) {
    cin >> ara[i];
  }
  for (i = 1; i <= 5; i++) {
    if (ara[i] == 0)
      cout << i << endl;
  }
  return 0;
}
Problem p02639 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int a, b, c, d, e;
  int res = 0;
  cin >> a >> b >> c >> d >> e;
  if (a == 0)
    res = 1;
  else if (b == 0)
    res = 2;
  else if (c == 0)
    res = 3;
  else if (d == 0)
    res = 4;
  else
    res = 5;
  cout << res << endl;
}


Error: 1

Fixed submission:

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

int main() {
  int a, b, c, d, e;
  cin >> a >> b >> c >> d >> e;
  if (a == 0)
    return 1;
  else if (b == 0)
    return 2;
  else if (c == 0)
    return 3;
  else if (d == 0)
    return 4;
  else
    return 5;
}
Problem p02639 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <math.h>
#include <string>
#define pi 3.1415926535897932384626
#include <cmath>
#define test(t) while (t--)

#define ll long long int

#define in cin >>
#define out cout <<
#define en "\\n"
#define sp " "
#define pb push_back
#define fast()                                                                 \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(0);
#define double long double

using namespace std;
ll form(ll n) { return (n * (n + 1)) / 2; }
ll exponent(ll base, ll power) {
  ll res = 1;
  ll m = 1000000007;
  while (power) {
    if (power & 1)
      res = (res * base) % m;
    base = (base * base) % m;
    power = power >> 1;
  }
  return res;
}
bool count_one(ll n) {
  ll cnt = 0;
  while (n > 0) {
    cnt += 1;
    n = n & (n - 1);
  }
  if (cnt > 1)
    return true;
  return false;
}
void solve() {
  ll x1, x2, x3, x4, x5;
  in x1 >> x2 >> x3 >> x4 >> x5;
  if (x1 == 0)
    out 1 << en;
  else if (x2 == 0)
    out 2 << en;
  else if (x3 == 0)
    out 3 << en;
  else if (x4 == 0)
    out 4 << en;
  else
    out 5 << en;
}

int main() {
  fast()
      // freopen("input.txt","r",stdin);
      // freopen("output.txt","w",stdout);
      ll t = 1;
  // cin>>t;
  test(t) { solve(); }
  return 0;
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <math.h>
#include <string>
#define pi 3.1415926535897932384626
#include <cmath>
#define test(t) while (t--)

#define ll long long int

#define in cin >>
#define out cout <<
#define en "\\n"
#define sp " "
#define pb push_back
#define fast()                                                                 \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(0);
#define double long double

using namespace std;
ll form(ll n) { return (n * (n + 1)) / 2; }
ll exponent(ll base, ll power) {
  ll res = 1;
  ll m = 1000000007;
  while (power) {
    if (power & 1)
      res = (res * base) % m;
    base = (base * base) % m;
    power = power >> 1;
  }
  return res;
}
bool count_one(ll n) {
  ll cnt = 0;
  while (n > 0) {
    cnt += 1;
    n = n & (n - 1);
  }
  if (cnt > 1)
    return true;
  return false;
}
void solve() {
  ll a[5];
  ll ans;
  for (ll i = 1; i <= 5; i++) {
    in a[i];
    if (a[i] == 0)
      ans = i;
  }
  out ans << en;
}

int main() {
  fast()
      // freopen("input.txt","r",stdin);
      // freopen("output.txt","w",stdout);
      ll t = 1;
  // cin>>t;
  test(t) { solve(); }
  return 0;
}
Problem p02639 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int x[4];
  for (int i = 0; i < 5; i++) {
    cin >> x[i];
    if (x[i] == 0) {
      cout << i + 1 << endl;
      break;
    }
  }
  return 0;
}


Error: WA

Fixed submission:

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

int main() {
  int x[4];
  for (int i = 0; i < 5; i++) {
    scanf("%d", &x[i]);
    if (x[i] == 0) {
      printf("%d", i + 1);
    }
  }
  return 0;
}
Problem p02639 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;
int main() {
  int n = 5;
  int arr[n], p;
  for (int i = 1; i <= 5; i++) {
    cin >> arr[i];
    if (arr[i] == 0) {
      p = i;
    }
  }
  cout << p << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  int arr[5], p;
  for (int i = 1; i <= 5; i++) {
    cin >> arr[i];
    if (arr[i] == 0) {
      p = i;
    }
  }
  cout << p;
  return 0;
}
Problem p02639 (C++) — buggy submission, verdict: Runtime Error

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

#define ll long long
#define ar array

void solve() {}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int x[5];
  cin >> x[0] >> x[1] >> x[2] >> x[3] >> x[4];
  for (int i = 0; i < 5; i++) {
    if (x[i] == 0) {
      cout << i + 1 << "\\n";
      return 0;
    }
  }
}


Error: 1

Fixed submission:

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

#define ll long long
#define ar array

void solve() {}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int x[5];
  cin >> x[0] >> x[1] >> x[2] >> x[3] >> x[4];
  for (int i = 0; i < 5; i++) {
    if (x[i] == 0) {
      cout << i + 1 << "\\n";
      return 1;
    }
  }
}
Problem p02639 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
int x[5];
int main() {
  for (int i = 1; i <= 5; i++)
    cin >> x[i];
  for (int i = 1; i <= 5; i++)
    if (x[i] == 0)
      cout << i;
  return 0;
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  int x[5];
  for (int i = 1; i <= 5; i++)
    cin >> x[i];
  for (int i = 1; i <= 5; i++)
    if (x[i] == 0)
      cout << i;
  return 0;
}
Problem p02639 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int arr[5];
  int ans = 0;
  for (int i = 0; i < 5; i++) {
    cin >> arr[i];
    if (arr[i] == 0) {
      ans = i;
    }
  }
  cout << ans + 1;
}


Error: TLE

Fixed submission:

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int arr[5];
  int ans = 0;
  for (int i = 1; i <= 5; i++) {
    cin >> arr[i];
    if (arr[i] == 0) {
      ans = i;
    }
  }
  cout << ans;
}
Problem p02639 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  vector<int> x(5);
  for (int i = 0; i < 5; i++) {
    cin >> x.at(i);
    if (x.at(i) == 0) {
      cout << i + 1;
      break;
    }
  }
}

Error: WA

Fixed submission:

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

int main() {
  vector<int> x(5);
  for (int i = 1; i <= 5; i++) {
    cin >> x.at(i);
    if (x.at(i) == 0) {
      cout << i;
      break;
    }
  }
}
Problem p02639 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#include <iostream>
#include <math.h>
using namespace std;
#define IOS                                                                    \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(0);                                                                  \\
  cout.tie(0);
#define ull unsigned long long
#define int long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define endl "\\n"
#define Max(x, y, z) max(x, max(y, z))
#define Min(x, y, z) min(x, min(y, z))
#define MAX 1e18
#define PI 3.14159265
const int mod = 1e9 + 7;

int power(int x, int y) {
  int res = 1;

  while (y > 0) {

    if (y & 1)
      res = (long long)(res * x);

    y = y >> 1;

    if (x <= 100000000)
      x = (long long)(x * x);

    // cout<<x<<'\\n';
  }
  return res;
}

void solve() {
  std::vector<int> v;
  for (int i = 1; i <= 5; i++) {
    int x;
    cin >> x;
    v.push_back(x);
  }

  int ser = 0;

  auto it = std::find(v.begin(), v.end(), ser) - v.begin();
  ;

  auto ans = it + 1;
  cout << ans << endl;

  return;
}

int32_t main() {
  IOS;
  solve();
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#include <iostream>
#include <math.h>
using namespace std;
#define IOS                                                                    \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(0);                                                                  \\
  cout.tie(0);
#define ull unsigned long long
#define int long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define endl "\\n"
#define Max(x, y, z) max(x, max(y, z))
#define Min(x, y, z) min(x, min(y, z))
#define MAX 1e18
#define PI 3.14159265
const int mod = 1e9 + 7;

int power(int x, int y) {
  int res = 1;

  while (y > 0) {

    if (y & 1)
      res = (long long)(res * x);

    y = y >> 1;

    if (x <= 100000000)
      x = (long long)(x * x);

    // cout<<x<<'\\n';
  }
  return res;
}

void solve() {
  int arr[5];
  for (int i = 1; i <= 5; i++) {
    int x;
    cin >> x;
    arr[i] = x;
  }
  for (int i = 1; i <= 5; i++) {
    if (arr[i] == 0) {
      cout << i << endl;
    }
  }
  return;
}

int32_t main() {
  IOS;
  solve();
  return 0;
}
Problem p02639 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int n = 5;
  vector<int> x(n);
  rep(i, n) cin >> x[i];
  rep(i, n) {
    if (x[i] == 0) {
      cout << i + 1 << endl;
    }
  }
}

Error: -11

Fixed submission:

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

int main() {
  int n = 5;
  vector<int> x;
  rep(i, n) cin >> x[i];
  rep(i, n) {
    if (x[i] == 0) {
      cout << i << endl;
    }
  }
}
Problem p02639 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
#define boost                                                                  \\
  ios::sync_with_stdio(false);                                                 \\
  cin.tie(0)
#define pb push_back
#define MP make_pair
#define mod 1000000007

int main() {
  int arr[5];
  for (int i = 0; i < 5; i++) {
    cin >> arr[i];
  }
  for (int i = 0; i < 5; i++) {
    if (!arr[i]) {
      cout << i + 1 << "\\n";
      return 0;
    }
  }
}


Error: 1

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define boost                                                                  \\
  ios::sync_with_stdio(false);                                                 \\
  cin.tie(0)
#define pb push_back
#define MP make_pair
#define mod 1000000007
#define int long long

signed main() {
  boost;
  int arr[5];
  for (int i = 0; i < 5; i++) {
    cin >> arr[i];
  }
  for (int i = 0; i < 5; i++) {
    if (!arr[i]) {
      return i + 1;
    }
  }
}
Problem p02639 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

using namespace std;

int main() {
  int ar[5];
  for (int i = 0; i < 5; i++) {
    cin >> ar[i];
  }
  for (int i = 0; i < 5; i++) {
    if (ar[i] == 0) {
      cout << i + 1 << endl;
    }
  }
  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

int main() {
  int ar[5];
  for (int i = 1; i <= 5; i++) {
    cin >> ar[i];
  }
  for (int i = 1; i <= 5; i++) {
    if (ar[i] == 0) {
      cout << i << endl;
    }
  }
  return 0;
}
Problem p02639 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int a[6];
  for (int i = 1; i <= 5; i++) {
    cin >> a[i];
    if (a[i] == 0)
      cout << i;
  }
  return 0;
}

Error: WA

Fixed submission:

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

int main() {
  int a[5];
  for (int i = 1; i <= 5; i++) {
    cin >> a[i];
    if (a[i] == 0)
      cout << i;
  }
  return 0;
}
Problem p02639 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define rep(i, n)                                                              \\
  ;                                                                            \\
  for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> state;
long double pi = acos(-1);
const int INF = 1001001001;

// 最小公倍数を求める
int euqlid(int a, int b) {
  int temp;
  temp = a % b;
  if (temp == 0)
    return b;
  return euqlid(b, temp);
}
ll conbination(ll a, ll b) {
  ll u = 1;
  ll d = 1;
  while (b != 0) {
    u *= a;
    d *= b;
    a--;
    b--;
  }
  return u / d;
}
int strtoint(char s) { return (int(s - '0')); }
char changeS(char alpha) {
  if (0x41 <= alpha and alpha <= 0x5A)
    return (alpha + 0x20);
  else if (0x61 <= alpha and alpha <= 0x7A)
    return (alpha - 0x20);
  return alpha;
}
int fact(int n) {
  if (n == 1)
    return 1;
  return n * fact(n - 1);
}
int ceil(int a, int b) {
  // a/bの切り上げを考える
  return (a + b - 1) / b;
}

int main() {
  int ans;
  rep(i, 5) {
    int x;
    cin >> x;
    if (x == 0)
      ans = i + 1;
  }
  cout << ans << endl;
}


Error: 1

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, n)                                                              \\
  ;                                                                            \\
  for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> state;
long double pi = acos(-1);
const int INF = 1001001001;

// 最小公倍数を求める
int euqlid(int a, int b) {
  int temp;
  temp = a % b;
  if (temp == 0)
    return b;
  return euqlid(b, temp);
}
ll conbination(ll a, ll b) {
  ll u = 1;
  ll d = 1;
  while (b != 0) {
    u *= a;
    d *= b;
    a--;
    b--;
  }
  return u / d;
}
int strtoint(char s) { return (int(s - '0')); }
char changeS(char alpha) {
  if (0x41 <= alpha and alpha <= 0x5A)
    return (alpha + 0x20);
  else if (0x61 <= alpha and alpha <= 0x7A)
    return (alpha - 0x20);
  return alpha;
}
int fact(int n) {
  if (n == 1)
    return 1;
  return n * fact(n - 1);
}
int ceil(int a, int b) {
  // a/bの切り上げを考える
  return (a + b - 1) / b;
}

int main() {
  rep(i, 5) {
    int x;
    cin >> x;
    if (x == 0)
      return i + 1;
  }
}
Problem p02639 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;
int main() {
  int a[100], i;
  for (i = 0; i < 5; i++) {
    cin >> a[i];
  }
  if (a[0] == 0)
    cout << 1;
  else if (a[1] == 0)
    cout << 2;
  else if (a[2] == 0)
    cout << 3;
  else if (a[3] == 0)
    cout << 4;
  else if (a[4] == 0)
    cout << 5;
  return 0;
}


Error: WA

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int a[5], i;
  for (i = 1; i <= 5; i++) {
    cin >> a[i];
  }
  for (i = 1; i <= 5; i++) {
    if (a[i] == 0) {
      cout << i;
    }
  }
  return 0;
}
Problem p02639 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>

using namespace std;

int main() {
  int x[6];
  for (int i = 1; i <= 5; ++i)
    cin >> x[i];
  for (int i = 1; i <= 5; ++i) {
    if (!x[i])
      cout << i << '\\n';
  }
  return 0;
}

Error: 0

Fixed submission:

#include <iostream>

using namespace std;

int main() {
  int x[5];
  for (int i = 1; i <= 5; ++i)
    cin >> x[i];
  for (int i = 1; i <= 5; ++i) {
    if (!x[i])
      cout << i << '\\n';
  }
  return 0;
}
Problem p02639 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int i, a[5];
  for (i = 0; i < 5; i++) {
    cin >> a[i];
    if (a[i] == 0) {
      cout << i + 1 << endl;
    }
  }
  return 0;
}


Error: 0

Fixed submission:

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

int main() {
  int i, a[5];
  for (i = 1; i <= 5; i++) {
    cin >> a[i];
    if (a[i] == 0) {
      cout << i << endl;
    }
  }
  return 0;
}
Problem p02639 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;

int main() {
  int a, b, c, d, e;

  cin >> a >> b >> c >> d >> e;

  if (a == 0) {
    cout << 1;
  } else if (b == 0) {
    cout << 2;
  } else if (c == 0) {
    cout << 3;
  } else if (d == 0) {
    cout << 4;
  } else if (e == 0) {
    cout << 5;
  }

  return 0;
}


Error: WA

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  int x[5];

  for (int i = 1; i <= 5; i++) {
    cin >> x[i];

    if (x[i] == 0) {
      cout << i;
    }
  }

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

#include <bits/stdc++.h>
using namespace std;
int main() {

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

  for (i = 0; i < 5; i++) {
    if (x[i] == 0) {
      cout << i + 1;
    }
  }
  cout << endl;

  return 0;
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {

  int x[5];
  int i, k;
  for (i = 1; i <= 5; i++) {
    cin >> x[i];
  }

  for (k = 1; k <= 5; k++) {
    if (x[k] == 0) {
      cout << k;
    }
  }

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

#include <bits/stdc++.h>
using namespace std;
int main() {
  int arr[5], ans = 0;
  for (int i = 0; i < 5; i++)
    cin >> arr[i];
  for (int i = 0; i < 5; i++) {
    if (arr[i] == 0) {
      ans = i + 1;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}

Error: -11

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int arr[10000];
int main() {
  int i;
  for (i = 0; arr[i] != '\\n'; i++) {
    cin >> arr[i];
    if (arr[i] == 0) {
      cout << i + 1 << endl;
      continue;
    } else
      continue;
  }
  return 0;
}
Problem p02639 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
int main() {

  int arr[5], i;
  for (i = 0; i < 5; i++) {
    scanf("%d", &arr[i]);
  }
  for (i = 0; i < 5; i++) {
    if (arr[i] == 0) {
      break;
    }
  }
  cout << i + 1 << endl;

  return 0;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {

  int arr[5], i;
  for (i = 1; i <= 5; i++) {
    scanf("%d", &arr[i]);
    if (arr[i] == 0) {
      printf("%d\\n", i);
    }
  }
  return 0;
}
Problem p02639 (C++) — buggy submission, verdict: Runtime Error

// Date of submission: 14-06-2020

#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll N = 1e9 + 5;
const double E = 1e-9;

//------------------------------------------------------------------------------

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll a[6];
  for (ll i = 1; i <= 5; i++) {
    cin >> a[i];
  }
  for (ll i = 1; i <= 5; i++) {
    if (a[i] == 0) {
      cout << i;
      break;
    }
  }
  return 0;
}

//------------------------------------------------------------------------------


Error: WA

Fixed submission:

// Date of submission: 14-06-2020

#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll N = 1e5 + 5;
const double E = 1e-9;

//------------------------------------------------------------------------------

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll a[5];
  memset(a, -1, sizeof(a));
  for (ll i = 1; i <= 5; i++) {
    cin >> a[i];
    if (a[i] == 0) {
      cout << i;
      return 0;
    }
  }
  return 0;
}

//------------------------------------------------------------------------------
Problem p02639 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

int main() {
  int var[5];
  while (cin >> var[0] >> var[1] >> var[2] >> var[3] >> var[4]) {
    for (int i = 0; i < 5; i++) {
      if (var[i] == 0)
        cout << i + 1 << endl;
    }
  }
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  while (true) {
    int num;
    for (int i = 1; i <= 5; i++) {
      cin >> num;
      if (num == 0)
        cout << i << endl;
    }
  }
}
Problem p02639 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;

int main() {
  int x;
  for (int i = 1; i <= 5; i++) {
    cin >> x;
    if (x == 0) {
      cout << i << endl;
      return 0;
    }
  }
  return 0;
}

Error: 1

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int x = 0;
  for (int i = 1; i < 6; i++) {
    cin >> x;
    if (x == 0)
      return i;
  }
  return 0;
}
Problem p02639 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

int main(void) {
  std::vector<int> a(5);
  for (int i = 0; i < 5; i++) {
    std::cin >> a[i];
    if (a[i] == 0) {
      std::cout << i + 1 << std::endl;
    }
  }
  return 0;
}

Error: -11

Fixed submission:

#include <bits/stdc++.h>

int main(void) {
  std::vector<int> a;
  for (int i = 0; i < 5; i++) {
    std::cin >> a[i];
    if (a[i] == 0) {
      std::cout << (i + 1) << std::endl;
      break;
    }
  }
  return 0;
}
Problem p02639 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <vector>
using namespace std;
int main() {
  int x1, x2, x3, x4, x5;
  cin >> x1 >> x2 >> x3 >> x4 >> x5;
  if (x1 == 0)
    cout << 1;

  else if (x2 == 0)
    cout << 2;

  else if (x3 == 0)
    cout << 3;

  else if (x4 == 0)
    cout << 4;

  else if (x5 == 0)
    cout << 5;

  return 0;
}


Error: 1

Fixed submission:

#include <iostream>
#include <vector>
using namespace std;
int main() {
  int x1, x2, x3, x4, x5;
  cin >> x1 >> x2 >> x3 >> x4 >> x5;
  vector<int> v;
  v.push_back(x1);

  v.push_back(x2);

  v.push_back(x3);

  v.push_back(x4);

  v.push_back(x5);

  for (int i = 0; i < 5; i++) {
    if (v[i] == 0) {
      return i + 1;
    }
  }
}
Problem p02639 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

int main() {
  int A[5];
  int x = 0;
  for (int i = 1; i <= 5; i++) {
    cin >> A[i];
  }
  for (int i = 1; i <= 5; i++) {
    if (A[i] == 0)
      x = i;
  }
  cout << x;
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  int A[5];
  int x = 0;
  for (int i = 1; i <= 5; i++) {
    cin >> A[i];
    if (A[i] == 0)
      x = i;
  }
  cout << x;
  return 0;
}
Problem p02639 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {

  int a[10];
  int pri;
  for (int i = 1; i <= 5; i++) {
    cin >> a[i];
    if (a[i] == 0)
      pri = i;
  }
  cout << pri << endl;

  return 0;
}


Error: TLE

Fixed submission:

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

int main() {

  int a[5];
  int pri;
  for (int i = 1; i <= 5; i++) {
    cin >> a[i];
    if (a[i] == 0)
      pri = i;
  }
  cout << pri << endl;

  return 0;
}