prithivMLmods/Coder-Stat huggingface dataset:
Problem p03000 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, X;
  cin >> N >> X;
  vector<int> L(N);
  REP(i, N) cin >> L.at(i);
  int counter = 0;
  int l = 0;
  while (counter <= X) {
    counter += L.at(l);
    l++;
  }
  cout << l << "\n";
}

Fixed submission:
#include <bits/stdc++.h>
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, X;
  cin >> N >> X;
  vector<int> L(N);
  REP(i, N) cin >> L.at(i);
  int counter = 0;
  int l = 0;
  while (counter <= X) {
    if (l >= N) {
      l++;
      break;
    }
    counter += L.at(l);
    l++;
  }
  cout << l << "\n";
}
Problem p03000 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, X;
  cin >> N >> X;

  vector<int> D(N + 1);
  D.at(0) = 0;

  for (int i = 1; i <= N + 1; i++) {
    int L;
    cin >> L;

    int DN = D.at(i - 1) + L;
    if (DN > X) {
      cout << i << endl;
      break;
    } else if (i == N + 1) {
      cout << i << endl;
    }
    D.at(i) = DN;
  }
}


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

int main() {
  int N, X;
  cin >> N >> X;

  vector<int> D(N + 2);
  D.at(0) = 0;

  for (int i = 1; i <= N + 1; i++) {
    int L;
    cin >> L;

    int DN = D.at(i - 1) + L;
    if (DN > X) {
      cout << i << endl;
      break;
    } else if (i == N + 1) {
      cout << i << endl;
    }
    D.at(i) = DN;
  }
}
Problem p03000 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <bits/stdc++.h>
#include <stdint.h>
#include <vector>

using namespace std;

int main() {
  int n, x;

  cin >> n >> x;

  vector<int> l(n, 0);
  for (int i = 0; i < n; i++) {
    cin >> l.at(i);
  }

  int h = 0;
  int ans = 1;
  int i = 0;
  while (h <= x) {
    h += l.at(i);
    if (h > x) {
      // 超えちゃってるので足さない

      // cout << "Over" << endl;

    } else {
      ans++;

      // cout << "Get " << h << ", " << ans << endl;
    }
    i++;
  }

  cout << ans << endl;

  return 0;
}


Fixed submission:
#include <algorithm>
#include <bits/stdc++.h>
#include <stdint.h>
#include <vector>

using namespace std;

int main() {
  int n, x;

  cin >> n >> x;

  vector<int> l(n, 0);
  for (int i = 0; i < n; i++) {
    cin >> l.at(i);
  }

  int h = 0;
  int ans = 1;
  int i = 0;
  while (h <= x && i < n) {
    h += l.at(i);
    if (h > x) {
      // 超えちゃってるので足さない

      // cout << "Over" << endl;

    } else {
      ans++;

      // cout << "Get " << h << ", " << ans << endl;
    }
    i++;
  }

  cout << ans << endl;

  return 0;
}
Problem p03000 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
#include <vector>
using namespace std;

int main() {
  int n, x;
  int i;
  int D = 0;
  int cnt = 1;
  vector<int> l(n);

  cin >> n >> x;
  for (i = 0; i < n; i++) {
    cin >> l[i];
    D += l[i];
    if (D <= x) {
      cnt++;
    }
  }

  cout << cnt << endl;

  return 0;
}

Fixed submission:
#include <iostream>
#include <vector>
using namespace std;

int main() {
  long n, x;
  long i;
  long D = 0;
  long cnt = 1;
  vector<long> l(n);

  cin >> n >> x;
  for (i = 0; i < n; i++) {
    cin >> l[i];
    D += l[i];
    if (D <= x) {
      cnt++;
    }
  }

  cout << cnt << endl;

  return 0;
}
Problem p03000 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
#define pb push_back
#define For(i, s, e) for (ll i = (s); i < (e); i++)
#define Debug_array(a, n)                                                      \
  for (ll i = (0); i < (n); i++)                                               \
  cout << a[i] << " "
#define Foe(i, s, e) for (ll i = (s); i <= (e); i++)
#define Fod(i, s, e) for (ll i = (s)-1; i >= (e); i--)
#define Mod 1000000007
#define pii pair<ll, ll>
#define fi first
#define se second
#define endl "\n"
#define mp make_pair
#define big_prime 15486277
#define bigger_prime 179424697
#define biggest_prime 32416188691
// #define random_shuffle(indices.begin(), indices.end());
// std::random_device rd;
// std::mt19937 g(rd());
// std::shuffle(v.begin(), v.end(), g);
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag,
             tree_order_statistics_node_update>
    ordered_set;

#define MAX 5002

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

  ll n, x;
  cin >> n >> x;
  ll f[MAX];
  memset(f, 0, sizeof(f));
  f[0] = 1;
  ll a[n];
  For(i, 0, n) cin >> a[i];
  ll d = 0;
  For(i, 0, n) {
    d = d + a[i];
    f[d]++;
  }
  ll ans = 0;
  For(i, 0, x + 1) ans += f[i];

  cout << ans << endl;
}

Fixed submission:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
#define pb push_back
#define For(i, s, e) for (ll i = (s); i < (e); i++)
#define Debug_array(a, n)                                                      \
  for (ll i = (0); i < (n); i++)                                               \
  cout << a[i] << " "
#define Foe(i, s, e) for (ll i = (s); i <= (e); i++)
#define Fod(i, s, e) for (ll i = (s)-1; i >= (e); i--)
#define Mod 1000000007
#define pii pair<ll, ll>
#define fi first
#define se second
#define endl "\n"
#define mp make_pair
#define big_prime 15486277
#define bigger_prime 179424697
#define biggest_prime 32416188691
// #define random_shuffle(indices.begin(), indices.end());
// std::random_device rd;
// std::mt19937 g(rd());
// std::shuffle(v.begin(), v.end(), g);
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag,
             tree_order_statistics_node_update>
    ordered_set;

#define MAX 100000

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

  ll n, x;
  cin >> n >> x;
  ll f[MAX];
  memset(f, 0, sizeof(f));
  f[0] = 1;
  ll a[n];
  For(i, 0, n) cin >> a[i];
  ll d = 0;
  For(i, 0, n) {
    d = d + a[i];
    f[d]++;
  }
  ll ans = 0;
  For(i, 0, x + 1) ans += f[i];

  cout << ans << endl;
}
Problem p03000 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using ull = unsigned long long;
using st = string;
using ch = char;
using db = double;
using bl = bool;
using vll = vector<long long>;
using vdb = vector<db>;
using vvll = vector<vll>;
using vst = vector<st>;
using vch = vector<char>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
#define rep(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define vrep(i, vec) for (auto &i : vec)
#define vin(vec)                                                               \
  for (auto &i : vec)                                                          \
  cin >> i
#define all(v) v.begin(), v.end()
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
const ll mod = 1000000007;
const ll inf = 1LL << 60;

int main() {
  ll n, x;
  cin >> n >> x;
  vll l(n);
  vin(l);
  ll ans = 0;
  while (x >= 0) {
    x -= l.at(ans);
    ans++;
  }
  cout << ans << endl;
}

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

using ll = long long;
using ull = unsigned long long;
using st = string;
using ch = char;
using db = double;
using bl = bool;
using vll = vector<long long>;
using vdb = vector<db>;
using vvll = vector<vll>;
using vst = vector<st>;
using vch = vector<char>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
#define rep(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define vrep(i, vec) for (auto &i : vec)
#define vin(vec)                                                               \
  for (auto &i : vec)                                                          \
  cin >> i
#define all(v) v.begin(), v.end()
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
const ll mod = 1000000007;
const ll inf = 1LL << 60;

int main() {
  ll n, x;
  cin >> n >> x;
  vll l(n);
  vin(l);
  ll ans = 1;
  while (ans <= n) {
    x -= l.at(ans - 1);
    if (x < 0)
      break;
    ans++;
  }
  cout << ans << endl;
}
Problem p03000 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
// for(int i = 0; i < n; i++)

int main() {
  int n, x, d = 0, a = 0;
  cin >> n >> x;
  vector<int> l(n);
  for (int i = 0; i < n; i++)
    cin >> l.at(i);
  while (d <= x) {
    d += l.at(a);
    a++;
  }
  cout << a << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
// for(int i = 0; i < n; i++)

int main() {
  int n, x, d = 0, a = 0;
  cin >> n >> x;
  vector<int> l(n);
  for (int i = 0; i < n; i++)
    cin >> l.at(i);
  a = n + 1;
  for (int i = 0; i < n; i++) {
    x -= l.at(i);
    if (x < 0) {
      a = i + 1;
      break;
    }
  }
  cout << a << endl;
}
Problem p03000 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, X;
  cin >> N >> X;
  vector<int> L(N);
  for (int i = 0; i < N; i++) {
    cin >> L.at(i);
  }
  int D = 0;
  int ans = 0;
  while (D <= X) {
    D += L.at(ans);
    ans++;
  }
  cout << ans << endl;
}


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

int main() {
  int N, X;
  cin >> N >> X;
  vector<int> L(N);
  for (int i = 0; i < N; i++) {
    cin >> L.at(i);
  }
  int D = 0;
  int ans = 1;
  while (ans <= N) {
    D += L.at(ans - 1);
    if (D > X)
      break;
    ans++;
  }
  cout << ans << endl;
}
Problem p03000 (C++)

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

int main() {
  int n, x, s;
  cin >> n >> x;

  vector<int> l(n), d(n);
  rep(i, n) cin >> l.at(i);

  for (int i = 1; i < n + 1; i++) {
    d.at(0) = 0;
    d.at(i) = d.at(i - 1) + l.at(i - 1);
    if (d.at(i) <= x)
      s++;
  }
  s++;

  cout << s << endl;
}

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

int main() {
  int n, x, s;
  cin >> n >> x;

  vector<int> l(n), d(n + 1);
  rep(i, n) cin >> l.at(i);

  for (int i = 1; i < n + 1; i++) {
    d.at(0) = 0;
    d.at(i) = d.at(i - 1) + l.at(i - 1);
    if (d.at(i) <= x)
      s++;
  }
  s++;

  cout << s << endl;
}
Problem p03000 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(n) begin(n), end(n)
#define IN(a, x, b) (a <= x && x < b)
#define INIT                                                                   \
  std::ios::sync_with_stdio(false);                                            \
  std::cin.tie(0);
template <class T> inline T CHMAX(T &a, const T b) {
  return a = (a < b) ? b : a;
}
template <class T> inline T CHMIN(T &a, const T b) {
  return a = (a > b) ? b : a;
}

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);

int main() {
  INIT;
  int N, X;
  cin >> N >> X;
  vector<int> L(N);
  REP(i, N) { cin >> L.at(i); }
  vector<int> D(N);
  int ans = 0;
  D.at(0) = 0;
  if (D.at(0) <= X)
    ans++;
  FOR(i, 1, N + 1) {
    D.at(i) = D.at(i - 1) + L.at(i - 1);
    if (D.at(i) <= X)
      ans++;
  }
  printf("%d\n", ans);

  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(n) begin(n), end(n)
#define IN(a, x, b) (a <= x && x < b)
#define INIT                                                                   \
  std::ios::sync_with_stdio(false);                                            \
  std::cin.tie(0);
template <class T> inline T CHMAX(T &a, const T b) {
  return a = (a < b) ? b : a;
}
template <class T> inline T CHMIN(T &a, const T b) {
  return a = (a > b) ? b : a;
}

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);

int main() {
  INIT;
  int N, X;
  cin >> N >> X;
  vector<int> L(N);
  REP(i, N) cin >> L.at(i);
  vector<int> D(N + 1);
  int ans = 0;
  D.at(0) = 0;
  if (D.at(0) <= X)
    ans++;
  FOR(i, 1, N + 1) {
    D.at(i) = D.at(i - 1) + L.at(i - 1);
    if (D.at(i) <= X)
      ans++;
  }
  printf("%d\n", ans);

  return 0;
}
Problem p03000 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, X;
  cin >> N >> X;
  int zahyou = 0, count = 1;
  vector<int> vec;
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
    zahyou += vec.at(i);
    if (zahyou > X) {
      break;
    }
    count++;
  }
  cout << count << endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, X;
  cin >> N >> X;
  int zahyou = 0, count = 1;
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
    zahyou += vec.at(i);
    if (zahyou > X) {
      break;
    }
    count++;
  }
  cout << count << endl;
}
Problem p03000 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;

int main() {
  int N, X;
  cin >> N >> X;
  vector<int> L(N);
  for (int i = 0; i < N; i++)
    cin >> L.at(i);

  int sum = 0, count = 1;
  for (int i = 0;; i++) {
    sum += L.at(i);
    if (sum <= X)
      count++;
    else
      break;
  }

  cout << count << endl;
}


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

int main() {
  int N, X;
  cin >> N >> X;
  vector<int> L(N);
  for (int i = 0; i < N; i++)
    cin >> L.at(i);

  int sum = 0, count = 1;
  for (int i = 0; i < N; i++) {
    sum += L.at(i);
    if (sum <= X)
      count++;
    else
      break;
  }

  cout << count << endl;
}
Problem p03000 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  int N, X;
  cin >> N >> X;

  vector<int> L(N);

  rep(i, N) { cin >> L.at(i); }

  int D = 0;
  int cnt = 0;
  while (D <= X) {
    D += L.at(cnt);
    cnt++;
  }

  cout << cnt << endl;
}


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

int main() {
  int N, X;
  cin >> N >> X;

  vector<int> L(N);

  rep(i, N) { cin >> L.at(i); }

  int D = 0;
  int cnt = 0;
  while (D <= X) {
    if (cnt == N) {
      cnt++;
      break;
    }
    D += L.at(cnt);
    cnt++;
  }

  cout << cnt << endl;
}
Problem p03000 (Python)

Buggy submission (status: Runtime Error):
N, X = map(int, input().split())
positions = list(map(int, input().split()))


ans = 1
D = 0
for i in range(N + 1):
    if D + positions[i] <= X:
        D += positions[i]
        ans += 1
    else:
        print(ans)
        exit()
print(ans)


Fixed submission:
N, X = map(int, input().split())
positions = list(map(int, input().split()))


ans = 1
D = 0
for i in range(N):
    if D + positions[i] <= X:
        D += positions[i]
        ans += 1
    else:
        print(ans)
        exit()
print(ans)
Problem p03000 (Python)

Buggy submission (status: Runtime Error):
a, b = map(int, input().split())
c = list(map(int, input().split()))
d = 1
e = 0
for i in range(a):
    e += c[i]
    if e <= b:
        d += 1
print(d)
a, b = map(int, input().split())
c = list(map(int, input().split()))
d = 1
e = 0
for i in range(a):
    e += c[i]
    if e <= b:
        d += 1
    else:
        break
print(d)


Fixed submission:
a, b = map(int, input().split())
c = list(map(int, input().split()))
d = 1
e = 0
for i in range(a):
    e += c[i]
    if e <= b:
        d += 1
    else:
        break
print(d)
Problem p03000 (Python)

Buggy submission (status: Runtime Error):
n, x = map(int, input().split())
ls = list(map(int, input().split()))

d = 0
count = 0
while d <= x:
    d += ls[count]
    count += 1

print(count)


Fixed submission:
n, x = map(int, input().split())
ls = list(map(int, input().split()))

d = 0
count = 1
for a in ls:
    d += a
    if d <= x:
        count += 1

print(count)
Problem p03000 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, X;
  cin >> N >> X;

  vector<int> data(5);
  for (int i = 0; i < N; i++) {
    cin >> data.at(i);
  }
  int count = 1;
  int total = 0;
  for (int i = 0; i < N; i++) {

    total += data.at(i);
    if (total <= X) {
      count++;
    }
  }

  cout << count << endl;
}


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

int main() {
  int N, X;
  cin >> N >> X;

  vector<int> data(N);
  for (int i = 0; i < N; i++) {
    cin >> data.at(i);
  }
  int count = 1;
  int total = 0;
  for (int i = 0; i < N; i++) {

    total += data.at(i);
    if (total <= X) {
      count++;
    }
  }

  cout << count << endl;
}
Problem p03000 (C++)

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

int main() {
  long long n, x;
  cin >> n >> x;
  vector<int> vec(n);
  rep(i, n) cin >> vec.at(i);
  long long d = 0;
  long long i = 0;
  while (d <= x) {
    d += vec.at(i);
    i++;
  }
  cout << i << endl;
}


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

int main() {
  long long n, x;
  cin >> n >> x;
  vector<int> vec(n);
  rep(i, n) cin >> vec.at(i);
  vector<int> d(n + 1);
  rep(i, n) d.at(i + 1) = d.at(i) + vec.at(i);
  int ans = 0;
  rep(i, n + 1) if (d.at(i) <= x) ans++;
  cout << ans << endl;
}
Problem p03000 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define rep(s, t)                                                              \
  for (int s = 0; s < t; s++)                                                  \
    ;
using namespace std;
using ll = long long;

int main() {
  int n, x, k;

  cin >> n >> x;

  vector<int> l(n + 1);

  l[0] = 0;

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

  int ans = 0;

  for (int i = 0; i <= n; i++) {
    while (l[i] <= x) {
      ans++;
    }
  }

  cout << ans << endl;
}

Fixed submission:
#include <bits/stdc++.h>
#define rep(s, t)                                                              \
  for (int s = 0; s < t; s++)                                                  \
    ;
using namespace std;
using ll = long long;

int main() {
  int n, x, k;

  cin >> n >> x;

  vector<int> l(n + 1);

  l[0] = 0;

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

  int ans = 0;

  for (int i = 0; i <= n; i++) {
    if (l[i] <= x) {
      ans++;
    }
  }

  cout << ans << endl;
}
Problem p03000 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>

using namespace std;

int main() {
  int n, x;
  cin >> n >> x;
  vector<int> l(n);
  for (int i = 0; i < n; ++i) {
    cin >> l.at(i);
  }
  int position = 0;
  int ans = 0;
  while (position <= x) {
    position += l.at(ans);
    ans++;
  }
  cout << ans << endl;
}


Fixed submission:
#include <bits/stdc++.h>

using namespace std;

int main() {
  int n, x;
  cin >> n >> x;
  vector<int> l(n);
  for (int i = 0; i < n; ++i) {
    cin >> l.at(i);
  }
  int position = 0;
  int ans = 1;
  for (int j = 0; j < n; ++j) {
    position += l.at(j);
    if (position <= x)
      ans++;
  }
  cout << ans << endl;
}
Problem p03000 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, X;
  cin >> N >> X;
  vector<int> L(N);
  for (int i = 0; i < N; i++) {
    cin >> L.at(i);
  }
  int distance = 0;
  int number = 0;
  while (distance <= X) {
    distance += L.at(number);
    number++;
  }
  cout << number << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, X;
  cin >> N >> X;
  vector<int> L(N);
  for (int i = 0; i < N; i++) {
    cin >> L.at(i);
  }
  int distance = 0;
  int number = 0;
  while (distance <= X && number <= N) {
    if (number < N) {
      distance += L.at(number);
    }
    number++;
  }
  cout << number << endl;
}
Problem p03000 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int X, N;
  cin >> N >> X;
  vector<int> L(N);
  for (int i = 0; i < N; i++)
    cin >> L.at(i);
  int count = 0;
  int Dn = 0;
  for (int i = 0; Dn < X + 1; i++) {
    count++;
    Dn += L.at(i);
  }
  cout << count << endl;
}

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

int main() {
  int X, N;
  cin >> N >> X;
  vector<int> L(N);
  for (int i = 0; i < N; i++)
    cin >> L.at(i);
  int count = 0;
  int Dn = 0;
  for (int i = 0; Dn < X + 1; i++) {
    count++;
    Dn += L.at(i);
    if (i == N - 1) {
      if (Dn < X + 1)
        count++;
      break;
    }
  }
  cout << count << endl;
}
Problem p03000 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  long long n, x;
  cin >> n >> x;
  vector<long long> l(n + 1);
  for (int i = 0; i < n; i++) {
    cin >> l[i];
  }
  vector<long long> dp(n);
  dp[0] = 0;
  for (int i = 1; i < n + 1; i++) {
    dp[i] = dp[i - 1] + l[i - 1];
  }

  int ans = 0;
  for (int j = 0; j < n + 1; j++) {
    if (dp[j] <= x) {
      ans++;
    }
  }

  cout << ans << endl;
}


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

int main() {
  long long n, x;
  cin >> n >> x;
  vector<long long> l(n + 1);
  for (int i = 0; i < n; i++) {
    cin >> l[i];
  }
  vector<long long> dp(n + 1);
  dp[0] = 0;
  for (int i = 1; i < n + 1; i++) {
    dp[i] = dp[i - 1] + l[i - 1];
  }

  int ans = 0;
  for (int j = 0; j < n + 1; j++) {
    if (dp[j] <= x) {
      ans++;
    }
  }

  cout << ans << endl;
}
Problem p03000 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int n, x;
  int i = 0;
  int xxx = 0;
  cin >> n >> x;
  vector<int> l(n);
  while (i < n) {
    cin >> l.at(i++);
  }

  i = 0;
  while (xxx <= x) {
    i++;
    if (i <= n) {
      xxx += l.at(i - 1);
    }
  }
  cout << i << endl;
  return 0;
}


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

int main() {
  int n, x;
  int i = 0;
  int xxx = 0;
  cin >> n >> x;
  vector<int> l(n);
  while (i < n) {
    cin >> l.at(i++);
  }

  i = 0;
  while (xxx <= x) {
    i++;
    if (i <= n) {
      xxx += l.at(i - 1);
    } else {
      break;
    }
  }
  cout << i << endl;
  return 0;
}
Problem p03000 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
using namespace std;

int L[101];

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, X;
  cin >> N >> X;
  for (int i = 0; i < N; i++)
    cin >> L[i];
  int d = 0;
  int ans = 0;
  int idx = 0;
  while (d <= X) {
    ans++;
    d += L[idx];
    idx++;
  }
  cout << ans << endl;
  return 0;
}

Fixed submission:
#include <iostream>
using namespace std;

int L[101];

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, X;
  cin >> N >> X;
  for (int i = 0; i < N; i++)
    cin >> L[i];
  int d = 0;
  int ans = 0;
  int idx = 0;
  while (d <= X) {
    ans++;
    if (idx == N)
      break;
    d += L[idx];
    idx++;
  }
  cout << ans << endl;
  return 0;
}
Problem p03000 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define ll long long
using namespace std;

int main() {
  int n, x;
  cin >> n >> x;
  vector<ll> v(n), vv(n);
  for (int i = 0; i < n; ++i)
    cin >> v[i];
  vv[0] = v[0];
  for (int i = 1; i <= n; ++i)
    vv[i] = vv[i - 1] + v[i];
  int cnt = 1;
  for (int i = 0; i < n; ++i)
    if (vv[i] <= x)
      cnt++;
  cout << cnt << endl;
  return 0;
}

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

int main() {
  int n, x;
  cin >> n >> x;
  vector<ll> v(n), vv(n);
  for (int i = 0; i < n; ++i)
    cin >> v[i];
  vv[0] = v[0];
  for (int i = 1; i < n; ++i)
    vv[i] = vv[i - 1] + v[i];
  int cnt = 1;
  for (int i = 0; i < n; ++i)
    if (vv[i] <= x)
      cnt++;
  cout << cnt << endl;
  return 0;
}
Problem p03000 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x;
  cin >> n >> x;
  vector<int> l(n);
  for (int i = 0; i < n; i++)
    cin >> l.at(i);
  int count = 1;
  int y = 0;
  for (int i = 0; i <= n; i++) {
    y += l.at(i);
    if (y <= x)
      count++;
    else
      break;
  }
  cout << count << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x;
  cin >> n >> x;
  vector<int> l(n);
  for (int i = 0; i < n; i++)
    cin >> l.at(i);
  int count = 1;
  int y = 0;
  for (int i = 0; i < n; i++) {
    y += l.at(i);
    if (y <= x)
      count++;
    else
      break;
  }
  cout << count << endl;
}
Problem p03000 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>

using namespace std;

int l[105];

int main() {

  // freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);

  int n, x, d = 0, b = 1;
  cin >> n >> x;
  for (int i = 1; i <= n; ++i) {
    cin >> l[i];
  }
  while (1) {
    d = d + l[b];
    if (d > x)
      break;
    b++;
  }
  cout << b << '\n';
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>

using namespace std;

int l[105];

int main() {

  // freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);

  int n, x, d = 0, b = 1;
  cin >> n >> x;
  for (int i = 1; i <= n; ++i) {
    cin >> l[i];
  }
  while (b < n + 1) {
    d = d + l[b];
    if (d > x)
      break;
    b++;
  }
  cout << b << '\n';
  return 0;
}
Problem p03000 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, X;
  cin >> N >> X;
  vector<int> Vec(N);
  for (int i = 0; i < N; i++) {
    cin >> Vec.at(i);
  }
  int count = 0;
  while (X > -1 && count < N + 2) {
    X -= Vec.at(count);
    count++;
  }
  cout << count << endl;
}

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

int main() {
  int N, X;
  cin >> N >> X;
  vector<int> Vec(N);
  for (int i = 0; i < N; i++) {
    cin >> Vec.at(i);
  }
  int count = 1;
  while (count < N + 1) {
    X -= Vec.at(count - 1);
    if (X > -1) {
      count++;
    } else {
      break;
    }
  }
  cout << count << endl;
}
Problem p03000 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

int n;
int l[110];
int s[110];
int x;

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

  s[0] = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d", &(l[i]));
    s[i + 1] = s[i] + l[i];
  }

  int p = 0;
  while (s[p] <= x)
    p++;

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

  return 0;
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

int n;
int l[110];
int s[110];
int x;

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

  s[0] = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d", &(l[i]));
    s[i + 1] = s[i] + l[i];
  }

  int p = 0;
  while (p <= n && s[p] <= x)
    p++;

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

  return 0;
}
Problem p03000 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
#include <vector>

int main() {
  int n, x;
  std::cin >> n >> x;
  std::vector<int> point(n);
  for (auto &e : point)
    std::cin >> e;

  auto p = 0, count = 0;
  while (p <= x) {
    p += point.at(count);
    ++count;
  }
  std::cout << count;

  return 0;
}

Fixed submission:
#include <iostream>
#include <vector>

int main() {
  int n, x;
  std::cin >> n >> x;
  std::vector<int> point(n);
  for (auto &e : point)
    std::cin >> e;

  auto p = 0, count = 0;
  try {
    while (p <= x) {
      p += point.at(count);
      ++count;
    }
  } catch (...) {
    count++;
  }
  std::cout << count;

  return 0;
}
Problem p03000 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> vec(n);
  int ans = 0;
  int d = 0;
  for (int i = 0; i < n; i++) {
    cin >> vec.at(i);
  }
  for (int i = 0; d <= m; i++) {
    ans++;
    d += vec.at(i);
  }

  cout << ans;
}


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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> vec(n);
  int ans = 0;
  int d = 0;
  for (int i = 0; i < n; i++) {
    cin >> vec.at(i);
  }
  for (int i = 0; d <= m; i++) {
    ans++;
    if (ans == n + 1)
      break;
    d += vec.at(i);
  }

  cout << ans;
}
Problem p03000 (C++)

Buggy submission (status: Runtime Error):
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, X;
  cin >> N >> X;
  vector<int> L(N);
  for (int i = 0; i < N; i++)
    cin >> L[i];
  int sum = 0;
  int cnt = 0;
  int i = 0;
  while (sum <= X) {
    cnt += 1;
    sum += L[i];
    if (cnt == N + 1)
      break;
    i++;
  }
  cout << cnt << endl;
}

Fixed submission:
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, X;
  cin >> N >> X;
  vector<int> L(N);
  for (int i = 0; i < N; i++)
    cin >> L[i];
  int sum = 0;
  int cnt = 0;
  int i = 0;
  while (sum <= X) {
    cnt += 1;
    if (i == N)
      break;
    sum += L[i];
    if (cnt == N + 1)
      break;
    i++;
  }
  cout << cnt << endl;
}
Problem p03000 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
// define
#define int long long
#define str string
#define rep(x, y) for (int i = x; i < y; i++)
#define REP(x, y) for (int j = x; j < y; j++)
#define all(x) x.begin(), x.end()
#define elif else if
// vectordefine
#define vint vector<int>
#define vc vector<char>
#define vtr vector<string>
#define pb(n) push_back(n)
// queuedefine
#define qint queue<int>
#define qc queue<char>
#define qstr queue<str>
// mapdefine
#define mint map<int>
#define mc map<char>
// pairdefine
#define pint pair<int, int>
#define pis pair<int, str>
#define pic pair<int, char>
#define pci pair<char, int>
#define mod 100000007
// main
signed main() {
  int N, M, O, P, count = 0, count2 = mod, count3 = 0, stack = 0;
  str S, T;
  cin >> N >> M;
  vint b(N);
  rep(0, N) cin >> b[i];
  vint a(N + 1);
  a[0] = 0;
  rep(1, N + 2) { a[i] = a[i - 1] + b[i - 1]; }
  rep(0, N + 1) if (M >= a[i]) count += 1;
  cout << count << endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
// define
#define int long long
#define str string
#define rep(x, y) for (int i = x; i < y; i++)
#define REP(x, y) for (int j = x; j < y; j++)
#define all(x) x.begin(), x.end()
#define elif else if
// vectordefine
#define vint vector<int>
#define vc vector<char>
#define vtr vector<string>
#define pb(n) push_back(n)
// queuedefine
#define qint queue<int>
#define qc queue<char>
#define qstr queue<str>
// mapdefine
#define mint map<int>
#define mc map<char>
// pairdefine
#define pint pair<int, int>
#define pis pair<int, str>
#define pic pair<int, char>
#define pci pair<char, int>
#define mod 100000007
// main
signed main() {
  int N, M, O, P, count = 0, count2 = mod, count3 = 0, stack = 0;
  str S, T;
  cin >> N >> M;
  vint b(N);
  rep(0, N) cin >> b[i];
  vint a(N + 1);
  a[0] = 0;
  rep(1, N + 1) { a[i] = a[i - 1] + b[i - 1]; }
  rep(0, N + 1) if (M >= a[i]) count += 1;
  cout << count << endl;
}
Problem p03000 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
int main() {
  int N, X;
  cin >> N >> X;
  vector<int> v(N);
  vector<int> s(N);
  for (int i = 0; i < N; i++)
    cin >> v[i];
  for (int i = 0; i <= N; i++) {
    s[i + 1] = s[i] + v[i];
  }
  int ans = 1;
  for (int i = 1; i <= N; i++) {
    if (s[i] > X)
      break;
    ans++;
  }
  cout << ans << endl;
}

Fixed submission:
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
int main() {
  int N, X;
  cin >> N >> X;
  vector<int> v(N + 10);
  vector<int> s(N + 10);
  for (int i = 0; i < N; i++)
    cin >> v[i];
  for (int i = 0; i <= N; i++) {
    s[i + 1] = s[i] + v[i];
  }
  int ans = 1;
  for (int i = 1; i <= N; i++) {
    if (s[i] > X)
      break;
    ans++;
  }
  cout << ans << endl;
}
Problem p03000 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, X;
  cin >> N >> X;
  vector<int> L(N);
  for (int i = 0; i < N; i++) {
    cin >> L.at(i);
  }
  int sum = 0;
  int num = 0;
  for (int i = 0; sum <= X; i++) {
    sum += L.at(i);
    num++;
  }
  cout << num;
}

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

int main() {
  int N, X;
  cin >> N >> X;
  vector<int> L(N);
  for (int i = 0; i < N; i++) {
    cin >> L.at(i);
  }
  int sum = 0;
  int num = 0;
  for (int i = 0; sum <= X; i++) {
    sum += L.at(i);
    num++;
    if (i == N - 1) {
      if (sum <= X) {
        num++;
      }
      break;
    }
  }
  cout << num;
}
Problem p03000 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
#include <vector>

int main() {
  int n, x;
  std::cin >> n >> x;
  std::vector<int> l;
  l.push_back(0);
  for (int i = 0; i < n; i++) {
    int t;
    std::cin >> t;
    l[i + 1] = (t + l[i]);
  }
  int s = 0;
  int i;
  for (i = 0; i <= n; i++) {
    if (l[i] <= x) {
      s++;
    }
  }
  std::cout << s << std::endl;
  return 0;
}

Fixed submission:
#include <iostream>
#include <vector>

int main() {
  int n, x;
  std::cin >> n >> x;
  std::vector<int> l(n + 1);
  l[0] = 0;
  for (int i = 0; i < n; i++) {
    int t;
    std::cin >> t;
    l[i + 1] = (t + l[i]);
  }
  int s = 0;
  int i;
  for (i = 0; i <= n; i++) {
    if (l[i] <= x) {
      s++;
    }
  }
  std::cout << s << std::endl;
  return 0;
}
Problem p03001 (C++)

Buggy submission (status: Runtime Error):
///                ..:: In The Name Of God ::..
#include <bits/stdc++.h>

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define endl '\n'
#define INF 2e9
#define int ll
#define vi vector<int>
#define de deque<int>
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end() // 全範囲指定を簡略化

typedef long long ll;

using namespace std;

// 配列の要素数は　sizeof(ar)/sizeof(ar[0]) で求める

signed main() {

  cin.tie(0);
  cout.tie(0);
  ios::sync_with_stdio(false);

  int W, H, x, y;
  cin >> W >> H >> x >> y;
  double ans = (double)W * H / 2;
  if (x + x == W && y + y == H) {
    printf("%.10Lf %d\n", ans, x + x == W && y + y == H);
  }
}


Fixed submission:
///                ..:: In The Name Of God ::..
#include <bits/stdc++.h>

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define endl '\n'
#define INF 2e9
#define int ll
#define vi vector<int>
#define de deque<int>
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end() // 全範囲指定を簡略化

typedef long long ll;

using namespace std;

// 配列の要素数は　sizeof(ar)/sizeof(ar[0]) で求める

signed main() {

  cin.tie(0);
  cout.tie(0);
  ios::sync_with_stdio(false);

  int W, H, x, y;
  cin >> W >> H >> x >> y;
  double ans = (double)W * H / 2;

  printf("%.10f %d\n", ans, x + x == W && y + y == H);

  return 0;
}
Problem p03001 (C++)

Buggy submission (status: Runtime Error):
#include <stdio.h>
int main() {
  int n, m, x, y;
  double s;
  while (~scanf("%d%d%d%d", &n, &m, &x, &y)) {
    s = n * m / 2;
    if (n % 2 == 0 && m % 2 == 0 && n / x == 2 && m / y == 2) {
      printf("%.7lf 1\n", s);

    } else {
      printf("%.7lf 0\n", s);
    }
  }
}

Fixed submission:
#include <stdio.h>
int main() {
  int w, h, x, y;
  while (~scanf("%d%d%d%d", &w, &h, &x, &y)) {
    double z1, z2;
    z1 = w / 2.0;
    z2 = h / 2.0;
    if (x == z1 && y == z2)
      printf("%lf %d\n", double(w) * double(h) / 2, 1);
    else
      printf("%lf %d\n", double(w) * double(h) / 2, 0);
  }
}
Problem p03001 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

int main() {
  double H, W, x, y;
  cin >> W >> H >> x >> y;
  if ((x == 0 || x == W) && (y == 0 || y == H)) {
    printf("%.12lf 0\n", H * W / 2);
    return 0;
  }
  if ((W * y == H * x) || (W * y == H * (W - x))) {
    if ((2 * x == W) && (2 * y == H)) {
      printf("%.12lf 1\n", H * W / 2);
    } else {
      printf("%.12lf 0\n", H * W / 2);
    }
    return 0;
  }
  if ((x == 0 || x == W) || (y == 0 || y == H)) {
    printf("%.12lf 0\n", H * W / 2);
    return 1;
  }
  double tate = min(H * x, H * (W - x));
  double yoko = min(y * W, (H - y) * W);
  printf("%.12lf %d\n", max(tate, yoko), (tate == yoko));
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

int main() {
  double H, W, x, y;
  cin >> W >> H >> x >> y;
  if ((x == 0 || x == W) && (y == 0 || y == H)) {
    printf("%.12lf 0\n", H * W / 2);
    return 0;
  }
  if ((W * y == H * x) || (W * y == H * (W - x))) {
    if ((2 * x == W) && (2 * y == H)) {
      printf("%.12lf 1\n", H * W / 2);
    } else {
      printf("%.12lf 0\n", H * W / 2);
    }
    return 0;
  }
  printf("%.12lf 0\n", H * W / 2);

  return 0;
}
Problem p03001 (Python)

Buggy submission (status: Runtime Error):
W, H, x, y = map(int, input().split())

ans = [min(x, W - x) * H, min(y, H - y) * W]

if (
    (x == 0 and y == 0)
    or (x == W and y == 0)
    or (x == 0 and y == H)
    or (x == W and y == H)
):
    print(W * H / 2, 0)
elif y / x == H / W:
    if x == W / 2 and y == H / 2:
        print(W * H / 2, 1)
    else:
        print(W * H / 2, 0)
else:
    print(max(ans), int(ans[0] == ans[1]))


Fixed submission:
W, H, x, y = map(int, input().split())

print(W * H / 2, 1 if W / 2 == x and H / 2 == y else 0)
Problem p03001 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  long a, b, c, d;
  cin >> a >> b >> c >> d;
  cout << a * b / c << ' ' << (a == 2 * c && b == 2 * d) << endl;
}

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

int main() {
  long a, b, c, d;
  cin >> a >> b >> c >> d;
  cout << a * b / 2.0 << ' ' << (a == 2 * c && b == 2 * d) << endl;
}
Problem p03001 (Python)

Buggy submission (status: Runtime Error):
# 真ん中を通れば必ず二分できてこれが最大値だが、自分自身が真ん中の座標の場合は自分自信を通るどんな直線も二分できる
w, h, x, y = map(int, input().split())
ans1 = (w * h) / 2.0
ans2 = 1 if w // x == h // y == 2 else 0
print(ans1, ans2)


Fixed submission:
# 真ん中を通れば必ず二分できてこれが最大値だが、自分自身が真ん中の座標の場合は自分自信を通るどんな直線も二分できる
w, h, x, y = map(int, input().split())
ans1 = (w * h) / 2.0
ans2 = 1 if w / 2 == x and h / 2 == y else 0
print(ans1, ans2)
Problem p03001 (Python)

Buggy submission (status: Runtime Error):
W, H, x, y = map(int, input().split())
jufuku = 0
if x == 0 and y == 0:
    if y / x == H / W:
        naname = W * H / 2
        jufuku = 1
        kiri = naname
else:
    # 縦
    tate = min((W - x) * H, x * H)
    # 横
    yoko = min(W * (H - y), W * y)
    if tate == yoko:
        jufuku = 1
    kiri = max(tate, yoko)
print(kiri, jufuku)


Fixed submission:
W, H, x, y = map(int, input().split())
jufuku = 0
if W / 2 == x and H / 2 == y:
    jufuku = 1
print(W * H / 2, jufuku)
Problem p03001 (Python)

Buggy submission (status: Runtime Error):
W, H, x, y = map(int, input().split())
print(W * H / 2, 1 if W / x == 2 and H / y == 2 else 0)


Fixed submission:
W, H, x, y = map(int, input().split())
print(W * H / 2, 1 if x != 0 and y != 0 and W / x == 2 and H / y == 2 else 0)
Problem p03001 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main(int argc, char *argv[]) {
  uint64_t w, h, x, y;
  cin >> w >> h >> x >> y;

  vector<double> ws;
  ws.push_back((h - y) * w);
  ws.push_back(y * w);

  vector<double> hs;
  hs.push_back(h * (w - x));
  hs.push_back(h * x);

  vector<double> ds;
  if (x > 0 && y > 0) {
    double dx = h / (y / x);
    double dy = w * (y / x);
    if (fabs(w - dx) < DBL_EPSILON || dx < w) {
      ds.push_back(dx * h / 2);
      ds.push_back(w * h - ds[0]);
    } else {
      ds.push_back(w * dy / 2);
      ds.push_back(w * h - ds[0]);
    }
  } else {
    ds.push_back(0);
    ds.push_back(0);
  }

  sort(ws.begin(), ws.end(), greater<double>());
  sort(hs.begin(), hs.end(), greater<double>());
  sort(ds.begin(), ds.end(), greater<double>());

  vector<double> tmp(3);
  tmp[0] = ws[1];
  tmp[1] = hs[1];
  tmp[2] = ds[1];
  sort(tmp.begin(), tmp.end(), greater<double>());

  cout << tmp[0] << endl;

  bool b = false;
  for (int i = 0; i < tmp.size(); ++i) {
    for (int j = 0; j < tmp.size(); ++j) {
      if (i == j)
        continue;

      if (fabs(tmp[i] - tmp[j]) < DBL_EPSILON) {
        b = true;
        break;
      }
    }
  }

  if (b) {
    cout << 1 << endl;
  } else {
    cout << 0 << endl;
  }

  return 0;
}

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

int main(int argc, char *argv[]) {
  uint64_t w, h, x, y;
  cin >> w >> h >> x >> y;

  cout << w * h / (double)2 << endl;
  cout << (x + x == w && y + y == h) << endl;

  return 0;
}
Problem p03001 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <vector>

using namespace std;

int main() {
  int n, m, x, y;
  cin >> n >> m >> x >> y;
  map<long long, int> cnt;
  long long a = 1ll * n * x, b = 1ll * n * (m - x);
  if (a > 0 && b > 0)
    cnt[min(a, b)]++;
  a = 1ll * m * x, b = 1ll * m * (n - x);
  if (a > 0 && b > 0)
    cnt[min(a, b)]++;
  auto it = *(--cnt.end());
  cout << it.first << " " << it.second - 1 << endl;
  return 0;
}


Fixed submission:
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <vector>

using namespace std;

int main() {
  int n, m, x, y;
  cin >> n >> m >> x >> y;
  fixed(cout);
  cout.precision(12);
  cout << (1ll * n * m) / 2.0 << " ";
  if (n % 2 == 0 && m % 2 == 0 && x == n / 2 && y == m / 2) {
    cout << 1 << endl;
  } else {
    cout << 0 << endl;
  }
  return 0;
}
Problem p03001 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>

#define REP(i, n) for (ll i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
using ll = long long;

int main(int argc, char *argv[]) {
  ll w, h, x, y;
  cin >> w >> h >> x >> y;

  cout << fixed << setprecision(20) << (double)w * h / (double)2 << " ";

  if (x == w / 2 && y == h / 2 && (w % x == 0) && (h % y == 0)) {
    MSG(1)
  } else {
    MSG(0)
  }

  return 0;
}


Fixed submission:
#include <bits/stdc++.h>

#define REP(i, n) for (ll i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
using ll = long long;

int main(int argc, char *argv[]) {
  ll w, h, x, y;
  cin >> w >> h >> x >> y;

  cout << fixed << setprecision(20) << (double)w * h / (double)2 << " ";

  if (x == w / 2 && y == h / 2 && x != 0 && y != 0 && (w % x == 0) &&
      (h % y == 0)) {
    MSG(1)
  } else {
    MSG(0)
  }

  return 0;
}
Problem p03001 (C++)

Buggy submission (status: 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 w, h, x, y;
  cin >> w >> h >> x >> y;
  cout << setprecision(15) << (double)w * h / 2.0 << " ";
  cout << (w / x * 2 == w && h / y * 2 == h ? 1 : 0) << endl;
  return 0;
}

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 w, h, x, y;
  cin >> w >> h >> x >> y;
  cout << setprecision(15) << (double)w * h / 2.0 << " ";
  cout << (x && y && w / x / 2 * x * 2 == w && h / y / 2 * y * 2 == h ? 1 : 0)
       << endl;
  return 0;
}
Problem p03001 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <utility>
#include <vector>

using namespace std;

int main() {
  int W, H, x, y;
  cin >> W >> H >> x >> y;
  printf("%.9f %d\n", W * H / 2.0, W * H / (x * y) == 4.0);
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <utility>
#include <vector>

using namespace std;

int main() {
  double W, H, x, y;
  cin >> W >> H >> x >> y;
  printf("%.9f %d\n", W * H / 2.0, W * H / (x * y) == 4.0);
}
Problem p03001 (C++)

Buggy submission (status: Runtime Error):
#include <iomanip>
#include <iostream>

using namespace std;

int w, h, x, y;

int main() {
  cin >> w >> h >> x >> y;
  cout << setprecision(20) << (long double)w * (long double)h / 2.0 << " ";
  if (w / 2 == x && h / 2 == y && w % x == 0 && h % y == 0)
    cout << 1 << endl;
  else
    cout << 0 << endl;
  return 0;
}

Fixed submission:
#include <iomanip>
#include <iostream>

using namespace std;

int w, h, x, y;

int main() {
  cin >> w >> h >> x >> y;
  cout << (double)w * (double)h / 2.0 << " ";
  if (x == 0 || y == 0) {
    cout << 0 << endl;
    return 0;
  }
  if (w / 2 == x && h / 2 == y && w % x == 0 && h % y == 0)
    cout << 1 << endl;
  else
    cout << 0 << endl;
  return 0;
}
Problem p03001 (C++)

Buggy submission (status: Runtime Error):
#include <stdio.h>
int main() {
  long long w, h, x, y;
  double s;
  int t;
  while (~scanf("%lld%lld%lld%lld", &w, &h, &x, &y)) {
    t = 0;
    s = (double)w * (double)h / 2;
    if (w % 2 == 0 && h % 2 == 0 && x == w / 2 && y == h / 2)
      t = 1;
    printf("%.6llf %d\n", s, t);
  }
  return 0;
}

Fixed submission:
#include <stdio.h>
int main() {
  long long w, h, x, y;
  double s;
  int t;
  while (~scanf("%lld%lld%lld%lld", &w, &h, &x, &y)) {
    t = 0;
    s = (double)w * (double)h / 2;
    if (w % 2 == 0 && h % 2 == 0 && x == w / 2 && y == h / 2)
      t = 1;
    printf("%.6lf %d\n", s, t);
  }
  return 0;
}