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

#include <bits/stdc++.h>
#define endl '\\n'
#define db double
#define ld long double
#define ll long long
#define ull unsigned long long
#define sqr(x) (x) * (x)
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) ((a / gcd(a, b)) * b)
#define pf(x) push_front(x)
#define pb(x) push_back(x)
#define eb(x) emplace_back(x)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)x.size()
#define debug(x) cerr << #x << " = " << (x) << endl
#define unsyncIO                                                               \\
  ios_base::sync_with_stdio(0);                                                \\
  cin.tie(0);                                                                  \\
  cout.tie(0)

const ld PI = acos((ld)-1);
const int MOD = 1e9 + 7;
const ll INF = 1e18;

using namespace std;

int main() {
  // freopen("/home/taalpatar_shepai/Documents/my_codes/out.txt", "w", stdout);
  for (int i = 1; i <= 5; i++) {
    int t;
    cin >> t;
    if (t == 0) {
      cout << i << endl;
      break;
    }
  }
  return 0;
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
#define endl '\\n'
#define db double
#define ld long double
#define ll long long
#define ull unsigned long long
#define sqr(x) (x) * (x)
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) ((a / gcd(a, b)) * b)
#define pf(x) push_front(x)
#define pb(x) push_back(x)
#define eb(x) emplace_back(x)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)x.size()
#define debug(x) cerr << #x << " = " << (x) << endl
#define unsyncIO                                                               \\
  ios_base::sync_with_stdio(0);                                                \\
  cin.tie(0);                                                                  \\
  cout.tie(0)

const ld PI = acos((ld)-1);
const int MOD = 1e9 + 7;
const ll INF = 1e18;

using namespace std;

int main() {
  // freopen("/home/taalpatar_shepai/Documents/my_codes/out.txt", "w", stdout);
  int x, y;
  cin >> x >> y;
  if (x == 1 && y == 2 || x == 1 && y == 4) {
    cout << "Yes" << endl;
    return 0;
  }
  if (y > (x * 4)) {
    cout << "No" << endl;
  } else {
    y -= 2;
    x--;
    if (y % x == 0) {
      cout << "Yes" << endl;
    } else
      cout << "No" << endl;
  }

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

#include <iostream>
#include <vector>
using namespace std;
int main() {
  int in;
  vector<int> v;
  int s(0), save;
  int i = 0;
  while (i < 5) {
    cin >> in;
    s++;
    v.push_back(in);
    if (in == 0) {
      save = s;
    }
    i++;
  }
  cout << save << "\\n";
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
#include <vector>
using namespace std;
int main() {
  int in;
  vector<int> v;
  int s(0), save;
  int i = 0;
  while (i < 5) {
    cin >> in;
    s++;
    v.push_back(in);
    if (in == 0) {
      save = s;
    }
  }
  cout << save << "\\n";
  return 0;
}
Problem p02639 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>

using namespace std;

int main() {
  int temp;
  int ans;

  for (int i = 1; i < 6; i++) {
    cin >> temp;
    if (temp != i)
      ans = i;
  }

  cout << ans << endl;

  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>

using namespace std;

int main() {
  int array[5] = {};
  int ans;

  for (int i = 1; i < 6; i++) {
    cin >> array[i];
    if (array[i] == 0) {
      ans = i;
    }
  }

  cout << ans << endl;

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

/*
  The Island Was Silent before.
  .....
  And One day again it became Silent.
*/
#include <bits/stdc++.h>
using namespace std;

#define endl '\\n'
#define ll long long
#define modd(a, b) ((a + 2 * b) % b)
#define debug(a) cout << #a << ": " << (a) << "\\n"
#define ioso ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define rtt cerr << "Time: " << clock() * 1.0 / CLOCKS_PER_SEC << endl;
#define ffe                                                                    \\
  freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);

int main() {
#ifndef ONLINE_JUDGE
  // ioso ffe
#endif
  ll a[6]; // cin >> a >> b >> c >> d >> e;
  ll ans = 0;
  for (int i = 1; i <= 5; i++) {
    cin >> a[i];
    if (a[i] == 0) {
      ans = i;
    }
  }
  cout << ans << endl;
}

Error: TLE

Fixed submission:

/*
  The Island Was Silent before.
  .....
  And One day again it became Silent.
*/
#include <bits/stdc++.h>
using namespace std;

#define endl '\\n'
#define ll long long
#define modd(a, b) ((a + 2 * b) % b)
#define debug(a) cout << #a << ": " << (a) << "\\n"
#define ioso ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define rtt cerr << "Time: " << clock() * 1.0 / CLOCKS_PER_SEC << endl;
#define ffe                                                                    \\
  freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);

int main() {
#ifndef ONLINE_JUDGE
  ioso ffe
#endif
      ll a[5]; // cin >> a >> b >> c >> d >> e;
  ll ans = 0;
  for (int i = 1; i <= 5; i++) {
    cin >> a[i];
    if (a[i] == 0) {
      ans = i;
    }
  }
  cout << ans << endl;
}
Problem p02639 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int i = 1;
  int val;
  while (1) {
    cin >> val;
    if (val == 0) {
      cout << i << endl;
      break;
    }
    i++;
  }
  return 0;
}


Error: WA

Fixed submission:

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

int main() {
  int i = 0;
  int val;
  while (1) {
    cin >> val;
    if (val == 0)
      return i;
    i++;
  }
  return -1;
}
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];
  for (int i = 1; i <= 5; i++) {
    if (a[i] == 0)
      cout << i;
  }
  return 0;
}

Error: WA

Fixed submission:

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

int main() {
  int a[6];
  for (int i = 1; i <= 6; i++)
    cin >> a[i];
  for (int i = 1; i <= 6; 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[5] = {0, 0, 0, 0, 0};

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


Error: WA

Fixed submission:

#include <iostream>

using namespace std;

int main() {
  int x[5] = {0, 0, 0, 0, 0};

  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: Runtime Error

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


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];
    if (ar[i] == 0) {
      cout << i << endl;
    }
  }
}
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: -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() {
  int n = 0;
  vector<int> vec(n);
  for (int i = 0; i < 6; i++) {
    cin >> vec.at(i);
    if (vec.at(i) == 0) {
      cout << i + 1 << endl;
    }
  }
  return 0;
}
Problem p02639 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;

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

  long long var;
  for (int i = 1; i <= 5; ++i) {
    cin >> var;
    if (var == 0)
      cout << i << "\\n";
  }
  return 0;
}


Error: 0

Fixed submission:

#include <iostream>
using namespace std;

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

#include <iostream>
#include <vector>
using namespace std;
int main() {
  vector<int> a(5);
  cin >> a.at(0) >> a.at(1) >> a.at(2) >> a.at(3) >> a.at(4);
  for (int i = 0; i < 5; i++) {
    if (a.at(i) == 0) {
      cout << i + 1 << endl;
      break;
    }
  }
  return 0;
}


Error: WA

Fixed submission:

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

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

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

int main() {

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


Error: 1

Fixed submission:

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

int main() {

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

#include <bits/stdc++.h>
using namespace std;
int main() {
  int num;
  while (1) {
    for (int i = 1; i <= 5; i++) {
      cin >> num;
      if (num == 0) {
        cout << i << endl;
        break;
      }
    }
    break;
  }
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  int num;
  while (1) {
    for (int i = 1; i <= 5; i++) {
      cin >> num;
      if (num == 0) {
        cout << i << endl;
        break;
      }
    }
  }
}
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];
  }
  for (int i = 1; i <= 5; i++) {
    // cout<<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 <iostream>
using namespace std;

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

Error: WA

Fixed submission:

#include <iostream>
using namespace std;

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

#include <algorithm>
#include <bits/stdc++.h>
#include <vector>
#define ll long long
#define mod 1000000007
#define test                                                                   \\
  int t;                                                                       \\
  cin >> t;                                                                    \\
  while (t--)
#define f for (int i = 0; i < n; i++)
#define f1 for (int i = 1; i < n - 1; i++)
#define read(x)                                                                \\
  ll x;                                                                        \\
  cin >> x;

using namespace std;
int main() {

  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  static const auto _ = []() {
    ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
    return 0;
  }();
  int arr[5], s = 0;
  for (int i = 1; i <= 5; i++) {
    cin >> arr[i];
  }
  s = 15 - arr[1] - arr[2] - arr[3] - arr[4] - arr[5];
  cout << s;
}

Error: WA

Fixed submission:

#include <algorithm>
#include <bits/stdc++.h>
#include <vector>
#define ll long long
#define mod 1000000007
#define test                                                                   \\
  int t;                                                                       \\
  cin >> t;                                                                    \\
  while (t--)
#define f for (int i = 0; i < n; i++)
#define f1 for (int i = 1; i < n - 1; i++)
#define read(x)                                                                \\
  ll x;                                                                        \\
  cin >> x;

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

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

Error: -11

Fixed submission:

#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define ll long long
int main() {
  vector<int> v;
  for (int i = 0; i < 5; ++i) {
    cin >> v[i];
  }
  auto ptr = find(v.begin(), v.end(), 0);
  cout << (ptr - v.begin()) + 1 << endl;
}
Problem p02639 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  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;
      break;
    }
  }
}


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


Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define fast()                                                                 \\
  ;                                                                            \\
  ios_base::sync_with_stdio(0);                                                \\
  cin.tie(0);                                                                  \\
  cout.tie(0);
#define ll long long int
int main() {
  fast();
  ll a[5];
  for (ll i = 1; i <= 5; i++)
    cin >> a[i];

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

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

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


Fixed submission:

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

#include <iostream>
using namespace std;
int main() {
  int a[5] = {1, 2, 3, 4, 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;
      exit(0);
    }
  }
  cout << "no";
  return 0;
}

Error: WA

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int a[5] = {1, 2, 3, 4, 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: Time Limit Exceeded

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


Error: TLE

Fixed submission:

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

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


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


Fixed submission:

#include <iostream>
using namespace std;
#define ll long long int

int main() {
  ll a[5], i;
  for (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>
using namespace std;

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

  int ans = 0;
  for (int i = 0; i < 5; i++) {
    if (x.at(i) == 0) {
      ans = i + 1;
      break;
    }
  }
  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() {
  vector<int> x(4);
  for (int i = 0; i < 5; i++) {
    cin >> x.at(i);
  }

  int ans = 0;
  for (int i = 0; i < 5; i++) {
    if (x.at(i) == 0) {
      ans = i + 1;
      break;
    }
  }
  cout << ans << endl;
}
Problem p02639 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<int> result(5);
  for (int i = 0; i < 5; i++) {
    cin >> result.at(i);
    if (result.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 0) >= this->size() (which is 0)


Fixed submission:

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

// BISMILLAHIR RAHMANIR RAHIM
// ALLAH HU AKABR
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main() {
  int a[6];
  for (int i = 0; i < 5; i++) {
    cin >> a[i];
  }
  int ans = 0;
  for (int i = 0; i < 5; i++) {
    if (a[i] == 0) {
      ans = i + 1;
      break;
    }
  }
  cout << ans << endl;
}

Error: TLE

Fixed submission:

// BISMILLAHIR RAHMANIR RAHIM
// ALLAH HU AKABR
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main() {
  int a[4], ans = 0;
  for (int i = 1; i <= 4; i++) {
    cin >> a[i];
    if (a[i] == 0) {
      ans = i;
    }
  }
  cout << ans << endl;
}
Problem p02639 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long int i = 1;
  while (1) {
    long long int a;
    cin >> a;
    if (a == 0)
      break;
    else
      i += 1;
  }
  cout << i;
  return 0;
}

Error: 1

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long int i = 1;
  while (1) {
    long long int a;
    cin >> a;
    if (a == 0)
      return i;
    else
      i += 1;
  }
  return 0;
}
Problem p02639 (C++) — buggy submission, verdict: Runtime Error

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


Error: 0

Fixed submission:

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

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ll a, b, c, d, e;
  cin >> a >> b >> c >> d >> e;
  if (a == 0) {
    cout << 1;
    return 0;
  } else if (b == 0) {
    cout << 2;
    return 0;
  } else if (c == 0) {
    cout << 3;
    return 0;
  } else if (d == 0) {
    cout << 4;
    return 0;
  } else if (e == 0) {
    cout << 5;
    return 0;
  }
}

Error: WA

Fixed submission:

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

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


Error: WA

Fixed submission:

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

#include <bits/stdc++.h>
#include <cmath>
#include <iostream>
#include <string>

#define ll long long

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
    cout << "5";
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#include <cmath>
#include <iostream>
#include <string>

#define ll long long

using namespace std;

int main() {
  int arr[5];
  arr[0] = -1333;
  int ans = -1;
  for (int i = 1; i < 6; i++) {
    cin >> arr[i];
    if (arr[i] == 0) {
      ans = i;
    }
  }
  cout << ans;
  return 0;
}
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];
    if (ar[i] == 0)
      cout << i + 1;
  }
  return 0;
}

Error: WA

Fixed submission:


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ar array

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int ar[5];
  for (int i = 1; i <= 5; i++) {
    cin >> ar[i];
    if (ar[i] == 0)
      cout << i;
  }
  return 0;
}
Problem p02639 (C++) — buggy submission, verdict: Time Limit Exceeded

#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() {
  vector<int> s(5);
  cin >> s.at(0) >> s.at(1) >> s.at(2) >> s.at(3) >> s.at(4);
  rep(i, 5) {
    if (s.at(i) == 0) {
      cout << i + 1 << endl;
    }
  }
}

Error: TLE

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 counts = 1;
  string s;
  cin >> s;
  rep(i, s.size()) {
    while (s.at(i) != '0') {
      counts++;
    }
  }
  cout << counts << endl;
}