alexjercan/bugnet huggingface dataset:
Problem p02639 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>

#define pp push_back
#define pf push_front
#define mp make_pair
#define fs first
#define sc second
#define sf scanf

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;

const int N = (int)1e5;
const int INF = (int)1e9 + 7;

int main(int argc, char *argv[]) {
  // ios_base::sync_with_stdio(false);
  // cin.tie(NULL);

  int a[6];
  int ans = 1;
  for (int i = 1; i <= 5; ++i) {
    sf("%d", &a[i]);
    if (a[i] == 0)
      ans = i;
  }
  printf("%d\\n", ans);

  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>

#define pp push_back
#define pf push_front
#define mp make_pair
#define fs first
#define sc second
#define sf scanf

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;

const int N = (int)1e5;
const int INF = (int)1e9 + 7;

int main(int argc, char *argv[]) {
  // ios_base::sync_with_stdio(false);
  // cin.tie(NULL);

  int a[5];
  int ans = 1;
  for (int i = 1; i <= 5; ++i) {
    sf("%d", &a[i]);
    if (a[i] == 0)
      ans = i;
  }
  printf("%d\\n", ans);

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

#include <bits/stdc++.h>

using namespace std;

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

    if (A[i] == 0)
      cout << i + 1;
  }
  return 0;
}


Error: 0

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 << "\\n";
  }
  return 0;
}
Problem p02639 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
int main() {
  int arr[6];
  int index;
  for (int i = 0; i < 5; i++) {
    scanf("%d", &arr[i]);
    if (arr[i] == 0)
      index = i;
  }
  printf("%d", index + 1);
}

Error: -11

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  int arr[6];
  int index;
  for (int i = 1; i < 6; i++) {
    scanf("%d", arr[i]);
    if (arr[i] == 0)
      index = i;
  }
  printf("%d", index);
}
Problem p02639 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  long ans = 0;
  vector<long> x(5);
  for (int i = 0; i < 5; i++) {
    cin >> x.at(i);
  }

  for (int i = 0; i < 5; i++) {
    if (x.at(i) == 0)
      ans = i + 1;
  }

  cout << ans << endl;
}


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


Fixed submission:

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

int main() {
  long ans = 0;
  vector<long> x(4);
  for (int i = 0; i < 5; i++) {
    cin >> x.at(i);
  }

  for (int i = 0; i < 5; i++) {
    if (x.at(i) == 0)
      ans = i;
  }

  cout << ans << endl;
}
Problem p02639 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define DBG(x) cerr << #x << “ = ” << (x) << endl
#define Rep(i, a, b) for (int i = a, to = b; i < to; i++)
#define pb push_back
#define all(v) v.begin(), v.end()
#define sz(v) (int)v.size()

typedef long long Long;

using namespace std;

int main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  int arr[5];
  Rep(i, 0, 5) {
    cin >> arr[i];
    if (arr[i] == 0) {
      cout << i + 1;
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define DBG(x) cerr << #x << “ = ” << (x) << endl
#define Rep(i, a, b) for (int i = a, to = b; i < to; i++)
#define pb push_back
#define all(v) v.begin(), v.end()
#define sz(v) (int)v.size()

typedef long long Long;

using namespace std;

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

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

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

Error: TLE

Fixed submission:

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

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

int main() {
  int v, ans = -1;
  for (int i = 0; i < 5; i++) {

    cin >> v;
    if (v == 0) {
      ans = i;
    }
  }
  cout << ans + 1;
  return 0;
}

Error: WA

Fixed submission:

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

int main() {
  int v, ans = -1;
  for (int i = 0; i < 5; i++) {

    cin >> v;
    if (v == 0) {
      ans = i;
    }
  }
  return ans;
}
Problem p02639 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;
int main() {
  int a[5], i;

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


Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int a[5], i;
  while (1) {
    for (i = 0; i < 5; i++) {
      cin >> a[i];
    }
    for (i = 0; i < 5; i++) {
      if (a[i] == 0) {
        cout << i + 1 << 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;
  cin >> a >> b >> c >> d >> e;
  if (a == 0)
    cout << 1 << endl;
  if (b == 0)
    cout << 2 << endl;
  if (c == 0)
    cout << 3 << endl;
  if (d == 0)
    cout << 4 << endl;
  if (e == 0)
    cout << 5 << endl;
  return 0;
}


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;
  if (b == 0)
    return 2;
  if (c == 0)
    return 3;
  if (d == 0)
    return 4;
  if (e == 0)
    return 5;
  return 0;
}
Problem p02639 (C++) — buggy submission, verdict: Runtime Error

#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define PI 3.141592
#define all(a) (a).begin(), (a).end()

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


Error: -11

Fixed submission:

#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define PI 3.141592
#define all(a) (a).begin(), (a).end()

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

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

void solve_case() {
  int n, i, j;
  int a[7];
  for (i = 1; i <= 5; i++)
    cin >> a[i];
  for (i = 1; i <= 5; i++) {
    if (a[i] == 0) {
      cout << i << "\\n";
      return;
    }
  }
}

signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  // freopen("input.txt", "r", stdin);
  int T = 1;
  // cin >> T;
  while (T--) {
    solve_case();
  }
  return 0;
}


Error: -6
*** stack smashing detected ***: terminated


Fixed submission:

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

// ----------------------------------------Defines and
// Template-------------------------------------//
#define int long long
#define ll long long
#define double long double
#define f first
#define ss second
#define mp make_pair
#define pb push_back
#define max3(a, b, c) max(a, max(b, c))
#define all(v) v.begin(), v.end()
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vii vector<vi>
#define vl vector<ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define print(arr)                                                             \\
  for (auto it = arr.begin(); it != arr.end(); ++it)                           \\
    cout << *it << " ";                                                        \\
  cout << endl;

typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update>
    ordered_set;
// order_of_key (k) : Number of items strictly smaller than k .
// find_by_order(k) : K-th element in a set (counting from zero).

#define setitr set<int, greater<int>>::iterator
#define RE(i, n) for (int i = 1; i <= n; i++)
#define REP(i, j, n) for (int i = j; i <= n; i++)
#define REB(i, j, n) for (int i = j; i >= n; i--)
#define FO(i, n) for (int i = n; i > 0; i--)

const int mod = 1e9 + 7;
const int INF = 1e8;
const int LGN = 30;

//-------------------------------------------------Template
//Ends------------------------------------------------------/

const int N = 1e5 + 3;
void solve_case() {
  int n, i, j, t, k, m;
  int a[5];
  for (i = 1; i <= 5; i++)
    cin >> a[i];
  for (i = 1; i <= 5; i++) {
    if (a[i] == 0) {
      cout << i << "\\n";
      return;
    }
  }
}

signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  // freopen("input.txt", "r", stdin);
  int T = 1;
  // cin >> T;
  while (T--) {
    solve_case();
  }
  return 0;
}
Problem p02639 (C++) — buggy submission, verdict: Time Limit Exceeded

// "for if God is with them who can be against them."
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define IOS                                                                    \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(0);
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define endl '\\n'
#define REP(i, a, b) for (int i = a; i <= b; i++)
#define all(a) a.begin(), a.end()
#define watch(x) cout << (#x) << " is " << (x) << endl
int ans = 0;
int cnt[400004];
void solve() {
  int a[6], ans;
  for (int i = 1; i <= 5; i++) {
    cin >> a[i];
    if (a[i] != i) {
      ans = i;
    }
  }
  cout << ans;
}
int main() {
#ifndef ONLINE_JUDGE
  freopen("input1.txt", "r", stdin);
  freopen("output1.txt", "w", stdout);
#endif
  IOS;
  int t = 1;
  // cin >> t;
  while (t--) {
    solve();
  }

#ifndef ONLINE_JUDGE
  cout << "\\nTime Elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " sec\\n";
#endif
  return 0;
}

Error: TLE

Fixed submission:

// "for if God is with them who can be against them."
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define IOS                                                                    \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(0);
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define endl '\\n'
#define REP(i, a, b) for (int i = a; i <= b; i++)
#define all(a) a.begin(), a.end()
#define watch(x) cout << (#x) << " is " << (x) << endl
void solve() {
  int a[5], ans;
  for (int i = 1; i <= 5; i++) {
    cin >> a[i];
    if (a[i] != i) {
      ans = i;
    }
  }
  cout << ans;
}
int main() {
#ifndef ONLINE_JUDGE
  freopen("input1.txt", "r", stdin);
  freopen("output1.txt", "w", stdout);
#endif
  IOS;
  int t = 1;
  // cin >> t;
  while (t--) {
    solve();
  }

#ifndef ONLINE_JUDGE
  cout << "\\nTime Elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " sec\\n";
#endif
  return 0;
}
Problem p02639 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

using namespace std;

void solution() {
  int a, b, c, d, e;
  cin >> a >> b >> c >> d >> e;

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

int main() {
  solution();
  return 0;
}


Error: -6
*** stack smashing detected ***: terminated


Fixed submission:

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

#define int long long
#define vi vector<int>
#define mod 1000000007
#define MAX INT_MIN
#define MIN INT_MAX
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define pqb priority_queue<int>
#define floop(x, n) for (int i = x; i < n; i++)
#define setbits(x) __builtin_popcountll(x)
#define zrobits(x) __builtin_ctzll(x)
#define ps(x, y) fixed << setprecision(y) << x
#define FIO                                                                    \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);

void solution() {
  int arr[5];

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

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

int32_t main() {

  solution();

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

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

int main() {

  int arr[20];

  for (int i = 1; i <= 5; i++) {

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

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

  return 0;
}

Error: -11

Fixed submission:

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

int main() {

  int arr[1000000000];

  for (int i = 1; i <= 5; i++) {

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

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

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

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

Error: TLE

Fixed submission:

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

// Remeber Choose Compiler: GCC9
#include <bits/stdc++.h>

using namespace std;

// Debug Output Utility
#ifdef LOCAL
#define dbg(args...)                                                           \\
  do {                                                                         \\
    cout << #args << " -> ";                                                   \\
    err(args);                                                                 \\
  } while (0)
void err() { std::cout << std::endl; }
template <typename T, typename... Args> void err(T a, Args... args) {
  std::cout << a << ' ';
  err(args...);
}
template <template <typename...> class T, typename t, typename... A>
void err(const T<t> &arg, const A &...args) {
  for (auto &v : arg)
    std::cout << v << ' ';
  err(args...);
}
#else
#define dbg(...)
#endif

// Macro Definitions:
#define mp make_pair
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()

// Type Alias:
using int64 = long long;
using PII = pair<int, int>;

// Global Const Variable
const int64 INF = 0x3f3f3f3f3f3f3f3f;
const int MOD = 1000000007;
const int MAXN = 200005;
const int MAXL = 1000;

int v[MAXN], w[MAXN], dp[MAXN][MAXL];

void run() {
  int a[6], ans = -1;
  for (int i = 1; i <= 5; i++) {
    cin >> a[i];
    if (a[i] == 0)
      ans = i;
  }
  cout << ans << endl;
}

// Debug Input Redirection
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
#ifdef LOCAL
  freopen("in.txt", "r", stdin);
#endif
  run();
}

Error: TLE

Fixed submission:

// Remeber Choose Compiler: GCC9
#include <bits/stdc++.h>

using namespace std;

// Debug Output Utility
#ifdef LOCAL
#define dbg(args...)                                                           \\
  do {                                                                         \\
    cout << #args << " -> ";                                                   \\
    err(args);                                                                 \\
  } while (0)
void err() { std::cout << std::endl; }
template <typename T, typename... Args> void err(T a, Args... args) {
  std::cout << a << ' ';
  err(args...);
}
template <template <typename...> class T, typename t, typename... A>
void err(const T<t> &arg, const A &...args) {
  for (auto &v : arg)
    std::cout << v << ' ';
  err(args...);
}
#else
#define dbg(...)
#endif

// Macro Definitions:
#define mp make_pair
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()

// Type Alias:
using int64 = long long;
using PII = pair<int, int>;

// Global Const Variable
const int64 INF = 0x3f3f3f3f3f3f3f3f;
const int MOD = 1000000007;
const int MAXN = 200005;
const int MAXL = 1000;

int v[MAXN], w[MAXN], dp[MAXN][MAXL];

void run() {
  int a[5], ans = -1;
  for (int i = 1; i <= 5; i++) {
    cin >> a[i];
    if (a[i] == 0)
      ans = i;
  }
  cout << ans << endl;
}

// Debug Input Redirection
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
#ifdef LOCAL
  freopen("in.txt", "r", stdin);
#endif
  run();
}
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);
  }
  for (int i = 0; i < 5; i++) {
    if (x.at(i) == 0) {
      cout << i + 1 << endl;
      break;
    }
  }
}

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


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);
  }
  for (int i = 1; i <= 5; i++) {
    if (x.at(i) == 0)
      cout << i << endl;
  }
}
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;
  int a;
  if (x1 == 0) {
    cout << 1 << endl;
  }
  if (x2 == 0) {
    cout << 2 << endl;
  }
  if (x3 == 0) {
    cout << 3 << endl;
  }
  if (x4 == 0) {
    cout << 4 << endl;
  }
  if (x5 == 0) {
    cout << 5 << endl;
  }
}


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


Fixed submission:

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

int main() {
  vector<int> x;
  cin >> x.at(0) >> x.at(1) >> x.at(2) >> x.at(3) >> x.at(4);
  int a;
  for (int i = 0; i < 5; i++) {
    if (x.at(i) != 0) {
      a = i + 1;
    }
  }
  cout << a << endl;
}
Problem p02639 (C++) — buggy submission, verdict: Runtime Error

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

int main() {

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


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


Fixed submission:

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

int main() {

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

#include <iostream>

using namespace std;

int main()

{
  int i, a, b;

  for (i = 1; i <= 5; i++) {
    cin >> a;

    if (a == 0) {
      b = i;
    }
  }
  cout << b << endl;
}

Error: TLE

Fixed submission:

#include <iostream>

using namespace std;

int main()

{
  int i, a[5], b;

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

    if (a[i] == 0) {
      b = i;
    }
  }
  cout << b << endl;
}
Problem p02639 (C++) — buggy submission, verdict: Time Limit Exceeded

// Bismillah .Ya Allah...
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> PII;
const int mod = 1e9 + 7, INF = 1e9;
const int mx = 1e6 + 5;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  n = 5;
  int a[5], ans;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    if (a[i] == 0) {
      ans = i;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}


Error: TLE

Fixed submission:

// Bismillah .Ya Allah...
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> PII;
const int mod = 1e9 + 7, INF = 1e9;
const int mx = 1e6 + 5;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int a[5], ans;
  for (int i = 1; i <= 5; i++) {
    cin >> a[i];
    if (a[i] == 0)
      ans = i;
  }
  cout << ans << endl;
  return 0;
}
Problem p02639 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <vector>

using namespace std;

int main() {
  int x, res;
  vector<int> val;
  for (int i = 0; i < 5; ++i) {
    cin >> x;
    val.push_back(x);
    if (x == 0)
      res = i + 1;
  }
  cout << res << endl;
  return 0;
}

Error: 1

Fixed submission:

#include <iostream>

using namespace std;

int main() {
  // freopen("1.txt", "r", stdin);
  int x;
  for (int i = 1; i <= 5; ++i) {
    cin >> x;
    if (x == 0)
      return i;
  }
  return 0;
}
Problem p02639 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define ll long long
#define fastio                                                                 \\
  ios_base ::sync_with_stdio(false);                                           \\
  cin.tie(0);                                                                  \\
  cout.tie(0);
using namespace std;

int main() {
  fastio ll a, b, c, d, e;
  cin >> a >> b >> c >> d >> e;
  if (a == 0)
    cout << 1 << "\\n";
  if (b == 0)
    cout << 2 << "\\n";
  if (c == 0)
    cout << 3 << "\\n";
  if (d == 0)
    cout << 4 << "\\n";
  if (e == 0)
    cout << 5 << "\\n";
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define ll long long
#define fastio                                                                 \\
  ios_base ::sync_with_stdio(false);                                           \\
  cin.tie(0);                                                                  \\
  cout.tie(0);
using namespace std;

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

// --------------
// Tejas Pandey  |
// 14 - 06 - 20  |
// Atcoder BC 170|
// --------------

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

#define mod 1000000007
#define vi vector<int>
typedef long long int ll;

int main(void) {
  // freopen("in.txt","r",stdin);
  // freopen("out.txt","w",stdout);
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  vector<pair<int, int>> v(5);
  for (int i = 0; i < 5; i++)
    cin >> v[i].first, v[i].second = i + 1;
  sort(v.begin(), v.end());
  cout << v[0].second;
  return 0;
}


Error: -11

Fixed submission:

// --------------
// Tejas Pandey  |
// 14 - 06 - 20  |
// Atcoder BC 170|
// --------------

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

#define mod 1000000007
#define vi vector<int>
typedef long long int ll;

int main(void) {
  // freopen("in.txt","r",stdin);
  // freopen("out.txt","w",stdout);
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  vector<pair<int, int>> v;
  for (int i = 0; i < 5; i++)
    cin >> v[i].first, v[i].second = i + 1;
  sort(v.begin(), v.end());
  cout << v[0].second;
  return 0;
}