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

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define REP(i, d, n) for (int i = (d); i < (n); ++i)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<char, int>;

int main() {

  int n, k;
  string s;
  cin >> n >> k >> s;

  vector<P> vp;
  if (s[0] == '0') {
    vp.emplace_back('1', 0);
  }
  vp.emplace_back(s[0], 1);
  REP(i, 1, n) {
    if (vp.back().first == s[i]) {
      vp.back().second++;
    } else {
      vp.emplace_back(s[i], 1);
    }
  }
  if (vp.back().first == '0') {
    vp.emplace_back('1', 0);
  }

  int tmp = 0;
  int l = k;
  int idx = 0;
  rep(i, vp.size()) {
    tmp += vp[i].second;
    if (vp[i].first == '0') {
      l--;
    }
    if (l == 0) {
      idx = i + 1;
      tmp += vp[idx].second;
      break;
    }
  }
  int ans = tmp;
  for (int i = idx + 1; i < vp.size() - 1; i += 2) {
    tmp += vp[i].second + vp[i + 1].second;
    tmp -= (vp[i - 2 * k - 1].second + vp[i - 2 * k].second);

    ans = max(ans, tmp);
  }
  cout << ans << endl;

  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define REP(i, d, n) for (int i = (d); i < (n); ++i)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<char, int>;

int main() {

  int n, k;
  string s;
  cin >> n >> k >> s;

  vector<P> vp;
  if (s[0] == '0') {
    vp.emplace_back('1', 0);
  }
  vp.emplace_back(s[0], 1);
  REP(i, 1, n) {
    if (vp.back().first == s[i]) {
      vp.back().second++;
    } else {
      vp.emplace_back(s[i], 1);
    }
  }
  if (vp.back().first == '0') {
    vp.emplace_back('1', 0);
  }

  if (vp.size() / 2 <= k) {
    cout << n << endl;
    return 0;
  }

  int tmp = 0;
  int l = k;
  int idx = 0;
  rep(i, vp.size()) {
    tmp += vp[i].second;
    if (vp[i].first == '0') {
      l--;
    }
    if (l == 0) {
      idx = i + 1;
      tmp += vp[idx].second;
      break;
    }
  }
  int ans = tmp;
  for (int i = idx + 1; i < vp.size() - 1; i += 2) {
    tmp += vp[i].second + vp[i + 1].second;
    tmp -= (vp[i - 2 * k - 1].second + vp[i - 2 * k].second);

    ans = max(ans, tmp);
  }
  cout << ans << endl;

  return 0;
}
Problem p03074 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i, n, k) for (ll i = (n); i < (k); i++)
ll n, k, ans = 0;
string s;
void Main() {
  cin >> n >> k >> s;
  vector<ll> bound;
  bound.push_back(0);
  For(i, 1, n) {
    if (s.at(i - 1) != s.at(i)) {
      bound.push_back(i);
    }
  }
  ll l = bound.size();
  For(i, 0, 100000) { bound.push_back(n); }
  for (ll i = 0; i < l; i++) {
    // cout<<ans<<endl;
    if (s.at(bound.at(i)) == '0') {
      ans = max(ans, bound.at(i + 2 * k) - bound.at(i));
    } else {
      ans = max(ans, bound.at(i + 2 * k + 1) - bound.at(i));
    }
  }
  cout << ans << endl;
}
int main() {
  Main();
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i, n, k) for (ll i = (n); i < (k); i++)
ll n, k, ans = 0;
string s;
void Main() {
  cin >> n >> k >> s;
  vector<ll> bound;
  bound.push_back(0);
  For(i, 1, n) {
    if (s.at(i - 1) != s.at(i)) {
      bound.push_back(i);
    }
  }
  ll l = bound.size();
  For(i, 0, 200000) { bound.push_back(n); }
  for (ll i = 0; i < l; i++) {
    // cout<<ans<<endl;
    if (s.at(bound.at(i)) == '0') {
      ans = max(ans, bound.at(i + 2 * k) - bound.at(i));
    } else {
      ans = max(ans, bound.at(i + 2 * k + 1) - bound.at(i));
    }
  }
  cout << ans << endl;
}
int main() {
  Main();
  return 0;
}
Problem p03074 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;

int n, k;
string s;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> k >> s;
  vi v;
  s += 'x';
  int cnt = 0;
  char p = s[0];
  for (int i = 0; i <= n; ++i) {
    if (s[i] != p)
      v.push_back(cnt), cnt = 0;

    cnt++;
    p = s[i];
  }
  for (int i = 1; i < v.size(); ++i)
    v[i] += v[i - 1];

  int m = s[0] == '1';
  int sol = 0;
  for (int i = 0; i < n; ++i) {
    int r = min((int)v.size() - 1, i + 2 * k - 1 + (m + i) % 2);
    int s = v[r] - (i ? v[i - 1] : 0);
    sol = max(sol, s);
  }
  cout << sol;
}


Fixed submission:
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;

int n, k;
string s;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> k >> s;
  vi v;
  s += 'x';
  int cnt = 0;
  char p = s[0];
  for (int i = 0; i <= n; ++i) {
    if (s[i] != p)
      v.push_back(cnt), cnt = 0;

    cnt++;
    p = s[i];
  }
  for (int i = 1; i < v.size(); ++i)
    v[i] += v[i - 1];

  int m = s[0] == '1';
  int sol = 0;
  for (int i = 0; i < v.size(); ++i) {
    int r = min((int)v.size() - 1, i + 2 * k - 1 + (m + i) % 2);
    int s = v[r] - (i ? v[i - 1] : 0);
    sol = max(sol, s);
  }
  cout << sol;
}
Problem p03074 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for (int i = m; i < n; ++i)
#define rem(i, m, n) for (int i = m; i >= n; --i)
typedef long long ll;
#define mod 1000000007
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T> ll part(const T &s, int l, int r) { return s[r] - s[l]; };

int main() {
  int N, K;
  string S;
  cin >> N >> K >> S;
  if (N <= K) {
    cout << N << endl;
    return 0;
  }
  int cnt = 1;
  vector<int> A;
  rep(i, 0, 3) A.push_back(0);
  if (S[0] == '0')
    A.push_back(0);
  rep(i, 1, N) {
    if (S[i] == S[i - 1]) {
      cnt++;
    } else {
      A.push_back(cnt);
      cnt = 1;
    }
  }
  if (cnt)
    A.push_back(cnt);
  rep(i, 0, 3) A.push_back(0);
  vector<ll> sum(A.size() + 1);
  for (int i = 0; i < A.size(); i++)
    sum[i + 1] = sum[i] + A[i];
  ll mx = 0;
  K = 2 * K + 1;
  rep(i, 0, A.size() - K + 1) {
    int e = i + K;
    if (e > sum.size())
      e = sum.size();
    ll a = part(sum, i, e);
    if (i % 2 == 0) {
      continue;
    }
    mx = max(mx, a);
  }
  if (S == "0")
    mx = 1;
  cout << mx << endl;
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for (int i = m; i < n; ++i)
#define rem(i, m, n) for (int i = m; i >= n; --i)
typedef long long ll;
#define mod 1000000007
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T> ll part(const T &s, int l, int r) { return s[r] - s[l]; };

int main() {
  int N, K;
  string S;
  cin >> N >> K >> S;
  if (N <= K) {
    cout << N << endl;
    return 0;
  }
  int cnt = 1;
  vector<int> A;
  rep(i, 0, 3) A.push_back(0);
  if (S[0] == '0')
    A.push_back(0);
  rep(i, 1, N) {
    if (S[i] == S[i - 1]) {
      cnt++;
    } else {
      A.push_back(cnt);
      cnt = 1;
    }
  }
  if (cnt)
    A.push_back(cnt);
  rep(i, 0, 3) A.push_back(0);
  vector<ll> sum(A.size() + 1);
  for (int i = 0; i < A.size(); i++)
    sum[i + 1] = sum[i] + A[i];
  ll mx = 0;
  K = 2 * K + 1;
  if (sum.size() <= K) {
    cout << N << endl;
    return 0;
  }
  rep(i, 0, A.size() - K + 1) {
    int e = i + K;
    if (e > sum.size())
      e = sum.size();
    ll a = part(sum, i, e);
    if (i % 2 == 0) {
      continue;
    }
    mx = max(mx, a);
  }
  if (S == "0")
    mx = 1;
  cout << mx << endl;
  return 0;
}
Problem p03074 (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, k;
  string s;
  cin >> n >> k >> s;
  vector<int> a;
  int x = 0;
  rep(i, n) if (s[i] == '1') x++;
  if (x == s.size()) {
    cout << x << endl;
    return 0;
  }
  if (s[0] == '0')
    a.push_back(0);
  int cnt = 1;
  rep(i, n - 1) {
    if (s[i] == s[i + 1])
      cnt++;
    else
      a.push_back(cnt), cnt = 1;
  }
  if (s[n - 1] == s[n - 2])
    a.push_back(cnt);
  else
    a.push_back(1);
  if (s[n - 1] == '0')
    a.push_back(0);
  if (a.size() <= k) {
    cout << x << endl;
    return 0;
  }
  int cnt2 = 0;
  rep(i, 2 * k + 1) cnt2 += a[i];
  int ans = cnt2;
  for (int i = 1; i < a.size() - 2 * k; i += 2) {
    cnt2 -= a[i] + a[i - 1];
    cnt2 += a[i + 2 * k] + a[i + 2 * k + 1];
    ans = max(ans, cnt2);
  }
  cout << ans << 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;

int main() {
  int n, k;
  string s;
  cin >> n >> k >> s;
  vector<int> a;
  int x = 0;
  rep(i, n) if (s[i] == '1') x++;
  if (x == s.size()) {
    cout << x << endl;
    return 0;
  }
  if (s[0] == '0')
    a.push_back(0);
  int cnt = 1;
  rep(i, n - 1) {
    if (s[i] == s[i + 1])
      cnt++;
    else
      a.push_back(cnt), cnt = 1;
  }
  if (s[n - 1] == s[n - 2])
    a.push_back(cnt);
  else
    a.push_back(1);
  if (s[n - 1] == '0')
    a.push_back(0);
  if (a.size() / 2 < k) {
    cout << s.size() << endl;
    return 0;
  }
  int cnt2 = 0;
  rep(i, 2 * k + 1) cnt2 += a[i];
  int ans = cnt2;
  for (int i = 1; i < a.size() - 2 * k; i += 2) {
    cnt2 -= a[i] + a[i - 1];
    cnt2 += a[i + 2 * k] + a[i + 2 * k + 1];
    ans = max(ans, cnt2);
  }
  cout << ans << endl;
  return 0;
}
Problem p03074 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

constexpr ll inf = INT64_MAX / 4;
constexpr ll mod = 1000000007;

int main() {
  int n, k;
  string s;
  cin >> n >> k >> s;
  vector<pair<int, int>> h;
  int d = 0;
  char v = s[0];
  for (int i = 0; i < n; i++) {
    if (s[i] != v) {
      h.emplace_back(v, d);
      d = 0;
      v = s[i];
    }
    d++;
  }
  if (d != 0)
    h.emplace_back(v, d);
  int ret = 0, l = 0, r = 0, c = k, maxr = 0;
  for (int i = 0; i < k || h[r].first == '1'; r++) {
    ret += h[r].second;
    if (h[r].first == '0')
      i++;
  }
  maxr = ret;
  while (r != h.size()) {
    ret -= h[l].second;
    if (h[l].first == '0')
      c--;
    l++;
    while (r < h.size() && (c < k || h[r].first == '1')) {
      ret += h[r].second;
      if (h[r].first == '0')
        c++;
      r++;
    }
    maxr = max(maxr, ret);
  }
  cout << maxr << endl;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

constexpr ll inf = INT64_MAX / 4;
constexpr ll mod = 1000000007;

int main() {
  int n, k;
  string s;
  cin >> n >> k >> s;
  vector<pair<int, int>> h;
  int d = 0;
  char v = s[0];
  for (int i = 0; i < n; i++) {
    if (s[i] != v) {
      h.emplace_back(v, d);
      d = 0;
      v = s[i];
    }
    d++;
  }
  if (d != 0)
    h.emplace_back(v, d);
  int ret = 0, l = 0, r = 0, c = k, maxr = 0;
  for (int i = 0; r < h.size() && (i < k || h[r].first == '1'); r++) {
    ret += h[r].second;
    if (h[r].first == '0')
      i++;
  }
  maxr = ret;
  while (r != h.size()) {
    ret -= h[l].second;
    if (h[l].first == '0')
      c--;
    l++;
    while (r < h.size() && (c < k || h[r].first == '1')) {
      ret += h[r].second;
      if (h[r].first == '0')
        c++;
      r++;
    }
    maxr = max(maxr, ret);
  }
  cout << maxr << endl;
}
Problem p03074 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define P pair<int, int>
using ll = int64_t;
using namespace std;
#define ketasuu(n) fixed << setprecision(n)
#define btoe(p) p.begin(), p.end()
#define etob(p) p.rbegin(), p.rend()

int main() {
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  vector<P> p;
  int l = s.length(), b, e, pre = s[0], cnt = 0;
  p.push_back({pre - '0', 1});
  rep(i, l - 1) {
    if (s[i + 1] == pre)
      p[cnt].second++;
    else {
      p.push_back({s[i + 1] - '0', 1});
      cnt++;
      pre = s[i + 1];
    }
  }
  b = s[0] - '0';
  e = s[l - 1] - '0';
  int ans = 0;
  cnt++;
  rep(i, cnt) {
    if (p[i].first == 0) {
      int x = min(2 * k, cnt - i);
      int kari = 0;
      for (int j = i; j < i + x; ++j) {
        kari += p[j].second;
      }
      ans = max(ans, kari);
    } else {
      int x = min(2 * k + 1, cnt - i);
      int kari = 0;
      for (int j = i; j < i + x; ++j) {
        kari += p[j].second;
      }
      ans = max(ans, kari);
    }
  }
  cout << ans << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define P pair<int, int>
using ll = int64_t;
using namespace std;
#define ketasuu(n) fixed << setprecision(n)
#define btoe(p) p.begin(), p.end()
#define etob(p) p.rbegin(), p.rend()

int main() {
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  vector<P> p;
  int l = s.length(), b, e, pre = s[0], cnt = 0;
  p.push_back({pre - '0', 1});
  rep(i, l - 1) {
    if (s[i + 1] == pre)
      p[cnt].second++;
    else {
      p.push_back({s[i + 1] - '0', 1});
      cnt++;
      pre = s[i + 1];
    }
  }
  b = s[0] - '0';
  e = s[l - 1] - '0';
  int ans = 0;
  cnt++;
  rep(i, cnt) {
    if (p[i].first == 0) {
      int x = min(2 * k, cnt - i);
      int kari = 0;
      for (int j = i; j < i + x; ++j) {
        kari += p[j].second;
      }
      ans = max(ans, kari);
    } else {
      int x = min(2 * k + 1, cnt - i);
      int kari = 0;
      for (int j = i; j < i + x; ++j) {
        kari += p[j].second;
      }
      ans = max(ans, kari);
    }
    if (2 * k - 10 > cnt - i)
      break;
  }
  cout << ans << endl;
  return 0;
}
Problem p03074 (C++)

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

int main() {
  int n, k;
  string s;
  cin >> n >> k;
  cin >> s;

  vector<int> cnt;
  cnt.push_back(0);
  char prev = '1';
  for (int i = 0; i < n; ++i) {
    if (s[i] == prev)
      ++cnt.back();
    else {
      prev = s[i];
      cnt.push_back(1);
    }
  }
  if (prev == '0')
    cnt.push_back(0);

  int ans = 0, cur = 0;
  if (cnt.size() <= 2 * k + 1) {
    for (int x : cnt)
      ans += x;
    cout << ans << endl;
    return 0;
  }
  for (int i = 0; i < 2 * k + 1; ++i)
    cur += cnt[i];
  ans = cur;
  for (int j = 2; j + 2 * k < n; j += 2) {
    cur -= cnt[j - 1] + cnt[j - 2];
    cur += cnt[j + 2 * k - 1] + cnt[j + 2 * k];
    ans = max(ans, cur);
  }
  cout << ans << endl;

  return 0;
}

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

int main() {
  int n, k;
  string s;
  cin >> n >> k;
  cin >> s;

  vector<int> cnt;
  cnt.push_back(0);
  char prev = '1';
  for (int i = 0; i < n; ++i) {
    if (s[i] == prev)
      ++cnt.back();
    else {
      prev = s[i];
      cnt.push_back(1);
    }
  }
  if (prev == '0')
    cnt.push_back(0);

  int ans = 0, cur = 0;
  if (cnt.size() <= 2 * k + 1) {
    for (int x : cnt)
      ans += x;
    cout << ans << endl;
    return 0;
  }
  for (int i = 0; i < 2 * k + 1; ++i)
    cur += cnt[i];
  ans = cur;
  for (int j = 2; j + 2 * k < cnt.size(); j += 2) {
    cur -= cnt[j - 1] + cnt[j - 2];
    cur += cnt[j + 2 * k - 1] + cnt[j + 2 * k];
    ans = max(ans, cur);
  }
  cout << ans << endl;

  return 0;
}
Problem p03074 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<ll, ll> l_l;
const int INF = 1001001000;
const int mINF = -1001001000;
const ll LINF = 1010010010010010000;
int main() {
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  int cnt = 0;
  int now = 1;
  vector<int> nums;
  for (int i = 0; i < n; i++) {
    if (s[i] == (char)('0' + now))
      cnt++;
    else {
      nums.push_back(cnt);
      cnt = 1;
      now = 1 - now;
    }
  }
  if (cnt != 0)
    nums.push_back(cnt);
  if (nums.size() % 2 == 0)
    nums.push_back(0);
  int right = 0;
  int add = 2 * k + 1;
  int ans = 0, tmp = 0;
  vector<int> sum(nums.size() + 1);
  for (int i = 0; i < n; i++) {
    sum[i + 1] = sum[i] + nums[i];
  }
  for (int i = 0; i < nums.size(); i += 2) {
    int left = i;
    int right = min(left + add, (int)nums.size());
    ans = max(ans, sum[right] - sum[left]);
  }
  cout << ans << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<ll, ll> l_l;
const int INF = 1001001000;
const int mINF = -1001001000;
const ll LINF = 1010010010010010000;
int main() {
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  int cnt = 0;
  int now = 1;
  vector<int> nums;
  for (int i = 0; i < n; i++) {
    if (s[i] == (char)('0' + now))
      cnt++;
    else {
      nums.push_back(cnt);
      cnt = 1;
      now = 1 - now;
    }
  }
  if (cnt != 0)
    nums.push_back(cnt);
  if (nums.size() % 2 == 0)
    nums.push_back(0);
  int right = 0;
  int add = 2 * k + 1;
  int ans = 0, tmp = 0;
  vector<int> sum(nums.size() + 1);
  for (int i = 0; i < nums.size(); i++) {
    sum[i + 1] = sum[i] + nums[i];
  }
  for (int i = 0; i < nums.size(); i += 2) {
    int left = i;
    int right = min(left + add, (int)nums.size());
    ans = max(ans, sum[right] - sum[left]);
  }
  cout << ans << endl;
  return 0;
}
Problem p03075 (Python)

Buggy submission (status: Runtime Error):
def solve(string):
    a, *_, e, k = map(int, string.split())
    return "Yay!" if e - a <= k else ":("


if __name__ == "__main__":
    print(solve(input()))


Fixed submission:
def solve(string):
    a, *_, e, k = map(int, string.split())
    return "Yay!" if e - a <= k else ":("


if __name__ == "__main__":
    print(solve("\n".join([input() for _ in range(6)])))
Problem p03075 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <cmath>
#include <iostream>
#include <string>

using namespace std;

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

  string ans = "Yay!";
  for (int i = 0; i < 6; ++i) {
    for (int j = 0; j < 6; ++j) {
      if (abs(p[i] - p[j]) > k)
        ans = ":(";
    }
  }

  cout << ans << endl;
}


Fixed submission:
#include <cmath>
#include <iostream>
#include <string>

using namespace std;

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

  if (abs(p[0] - p[4]) > k)
    cout << ":(" << endl;
  else
    cout << "Yay!" << endl;
}
Problem p03075 (C++)

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

int main() {
  int num = 5;
  int input[num], k;
  for (int i = 0; i < num; i++) {
    cin >> input[i];
  }
  cin >> k;

  for (int i = 0; i < num; i++) {
    for (int j = i + 1; j < num; j++) {
      if (input[j] - input[i] > k) {
        cout << ":(" << endl;
        exit(1);
      }
    }
  }

  cout << "Yay!" << endl;

  return 0;
}


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

int main() {
  int num = 5;
  int input[num], k;
  for (int i = 0; i < num; i++) {
    cin >> input[i];
  }
  cin >> k;

  for (int i = 0; i < num; i++) {
    for (int j = i + 1; j < num; j++) {
      if (input[j] - input[i] > k) {
        cout << ":(" << endl;
        exit(0);
      }
    }
  }

  cout << "Yay!" << endl;

  return 0;
}
Problem p03075 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template <typename T> vector<T> make_v(size_t a, T b) {
  return vector<T>(a, b);
}

template <typename... Ts> auto make_v(size_t a, Ts... ts) {
  return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

int main() {
  vector<int> a;
  REP(i, 5) cin >> a[i];
  int k;
  cin >> k;

  REP(i, 5) FOR(j, i + 1, 5) {
    if (a[j] - a[i] > k) {
      cout << ":(" << endl;
      return 0;
    }
  }

  cout << "Yay!" << endl;

  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template <typename T> vector<T> make_v(size_t a, T b) {
  return vector<T>(a, b);
}

template <typename... Ts> auto make_v(size_t a, Ts... ts) {
  return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

int main() {
  vector<int> a(5);
  REP(i, 5) cin >> a[i];
  int k;
  cin >> k;

  REP(i, 5) FOR(j, i + 1, 5) {
    if (a[j] - a[i] > k) {
      cout << ":(" << endl;
      return 0;
    }
  }

  cout << "Yay!" << endl;

  return 0;
}
Problem p03075 (C++)

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

int main() {
  vector<int> code;
  for (int i = 0; i < 5; i++) {
    cin >> code.at(i);
  }
  int K;
  cin >> K;
  int dif;
  for (int i = 0; i < 4; i++) {
    for (int j = 1; j < 5; j++) {
      dif = code.at(j) - code.at(i);
      if (dif > K) {
        cout << ":(" << endl;
        return 0;
      }
    }
  }
  cout << "Yay!" << endl;
}

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

int main() {
  vector<int> code(5);
  for (int i = 0; i < 5; i++) {
    cin >> code.at(i);
  }
  int K;
  cin >> K;
  int dif;
  for (int i = 0; i < 4; i++) {
    for (int j = 1; j < 5; j++) {
      dif = code.at(j) - code.at(i);
      if (dif > K) {
        cout << ":(" << endl;
        return 0;
      }
    }
  }
  cout << "Yay!" << endl;
}
Problem p03075 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
const unsigned int MOD = 1000000007;
#define ll long long
#define PI 3.1416
string day[] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
vector<string> v;
void dfs(string str, string t = "", int cnt = 0) {
  if (cnt == 2) {
    v.push_back(t);
    return;
  } else {
    for (int i = 0; i < str.size(); i++) {
      dfs(str, t + str[i], cnt + 1);
    }
  }
}
int main() {
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
  int a[5], k;
  while (1) {
    for (int i = 0; i < 5; i++) {
      cin >> a[i];
    }
    cin >> k;
    int flag = 1;
    for (int i = 0; i < 4; i++) {
      for (int j = i + 1; j < 5; j++) {
        if (abs(a[i] - a[j]) > k) {
          cout << ":(" << endl;
          flag = 0;
          break;
        }
      }
    }
    if (flag)
      cout << "Yay!" << endl;
  }
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
const unsigned int MOD = 1000000007;
#define ll long long
#define PI 3.1416
string day[] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
vector<string> v;
void dfs(string str, string t = "", int cnt = 0) {
  if (cnt == 2) {
    v.push_back(t);
    return;
  } else {
    for (int i = 0; i < str.size(); i++) {
      dfs(str, t + str[i], cnt + 1);
    }
  }
}
int main() {
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
  int a, b, c, d, e, k;
  while (cin >> a >> b >> c >> d >> e >> k) {
    (e - a) <= k ? cout << "Yay!" << endl : cout << ":(" << endl;
  }
  return 0;
}
Problem p03075 (C++)

Buggy submission (status: Runtime Error):
#include <stdio.h>
int main(void) {
  int num[6] = {0};
  for (int i = 0; i < 6; i++) {
    scanf("%d", num[i]);
    getchar();
  }
  if (num[4] - num[0] > num[5]) {
    printf(":(\n");
  } else {
    printf("Yay!\n");
  }
  return 0;
}

Fixed submission:
#include <stdio.h>
int main(void) {
  int num[6] = {0};
  for (int i = 0; i < 6; i++) {
    scanf("%d", &num[i]);
    getchar();
  }
  if (num[4] - num[0] > num[5]) {
    printf(":(\n");
  } else {
    printf("Yay!\n");
  }
  return 0;
}
Problem p03075 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
#include <stdio.h>
using namespace std;

int main(void) {
  int antennas[5];
  int k;
  for (int i = 0; i < 5; i++) {
    scanf("%d", &antennas[i]);
  }
  scanf("%d", &k);
  string ans = "Yay!";
  for (int i = 1; i <= 5; i++) {
    if (antennas[i] - antennas[i - 1] > k)
      ans = ":(";
  }
  cout << ans << "\n";
  return 0;
}


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

int main(void) {
  int antennas[5];
  int k;
  for (int i = 0; i < 5; i++) {
    scanf("%d", &antennas[i]);
  }
  scanf("%d", &k);
  printf(antennas[4] - antennas[0] <= k ? "Yay!\n" : ":(\n");
  return 0;
}
Problem p03075 (C++)

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

int main() {
  vector<int> x;
  int k;
  for (int i = 0; i < 5; i++) {
    cin >> x.at(i);
  }
  cin >> k;
  sort(x.begin(), x.end());
  if (x.at(4) - x.at(0) <= k) {
    cout << "Yay!" << endl;
  } else {
    cout << ":(" << endl;
  }
}

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

int main() {
  vector<int> x(5);
  int k;
  for (int i = 0; i < 5; i++) {
    cin >> x.at(i);
  }
  cin >> k;
  sort(x.begin(), x.end());
  if (x.at(4) - x.at(0) <= k) {
    cout << "Yay!" << endl;
  } else {
    cout << ":(" << endl;
  }
}
Problem p03075 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<int> a(5);
  for (int i = 0; i < 5; i++) {
    cin >> a.at(i);
  }
  sort(a.begin(), a.end());
  int k;
  cin >> k;
  if ((a.at(5) - a.at(0)) <= k) {
    cout << "Yey!" << endl;
  } else {
    cout << ":(" << endl;
  }
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<int> a(5);
  for (int i = 0; i < 5; i++) {
    cin >> a.at(i);
  }
  sort(a.begin(), a.end());
  int k;
  cin >> k;
  if ((a.at(4) - a.at(0)) <= k) {
    cout << "Yay!" << endl;
  } else {
    cout << ":(" << endl;
  }
}
Problem p03075 (Python)

Buggy submission (status: Runtime Error):
a = []
for i in range(5):
    a.append(int(input()))
k = input()

if a[4] - a[0] <= k:
    print("Yay!")
else:
    print(":(")


Fixed submission:
a = []
for i in range(5):
    a.append(int(input()))
k = int(input())

if a[4] - a[0] <= k:
    print("Yay!")
else:
    print(":(")
Problem p03075 (Python)

Buggy submission (status: Runtime Error):
num_list = []
while True:
    element = input()
    if element is None:
        break

    if element == "":
        break

    num_list.append(int(element))

limit = num_list[-1]

ans_string = "Yay!"
# for i in range(len(num_list) - 1):
#     print(num_list[i + 1] - num_list[i])
#     if num_list[i + 1] - num_list[i] > limit:
#         ans_string = ":("

for i in range(len(num_list) - 1):
    for j in range(i, len(num_list) - 1):
        if num_list[j] - num_list[i] > limit:
            ans_string = ":("

print(ans_string)


Fixed submission:
num_list = []
while True:
    try:
        element = input()
    except EOFError:
        break

    num_list.append(int(element))

limit = num_list[-1]

ans_string = "Yay!"
# for i in range(len(num_list) - 1):
#     print(num_list[i + 1] - num_list[i])
#     if num_list[i + 1] - num_list[i] > limit:
#         ans_string = ":("

for i in range(len(num_list) - 1):
    for j in range(i, len(num_list) - 1):
        if num_list[j] - num_list[i] > limit:
            ans_string = ":("

print(ans_string)
Problem p03076 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
  vector<pair<ll, ll>> V;
  ll ans = 0;
  for (int i = 0; i < 5; i++) {
    ll x;
    cin >> x;
    if (x % 10 == 0)
      ans += x;
    else
      V.push_back(make_pair(x % 10, x));
  }
  sort(V.begin(), V.end());
  for (int i = V.size() - 1; i >= 1; i--) {
    ll x = V[i].second;
    if (x % 10 == 0)
      ans += x;
    else
      ans += (x / 10 + 1) * 10;
  }
  cout << ans + V[0].second << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
  vector<pair<ll, ll>> V;
  ll ans = 0;
  for (int i = 0; i < 5; i++) {
    ll x;
    cin >> x;
    if (x % 10 == 0)
      ans += x;
    else
      V.push_back(make_pair(x % 10, x));
  }
  if (V.size() == 0) {
    cout << ans << endl;
    return 0;
  }
  sort(V.begin(), V.end());
  for (int i = V.size() - 1; i >= 1; i--) {
    ll x = V[i].second;
    if (x % 10 == 0)
      ans += x;
    else
      ans += (x / 10 + 1) * 10;
  }
  cout << ans + V[0].second << endl;
}
Problem p03076 (C++)

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

int main() {
  int tmp;
  int ans = 0;
  vector<int> rems;

  for (int i = 0; i < 5; i++) {
    cin >> tmp;
    if (tmp % 10 == 0)
      ans += tmp;
    else {
      ans += ((tmp / 10) + 1) * 10;
      rems.push_back(10 - tmp % 10);
    }
  }

  int maxi = *max_element(rems.begin(), rems.end());

  cout << ans - maxi << '\n';

  return 0;
}

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

int main() {
  int tmp;
  int ans = 0;
  vector<int> rems;

  for (int i = 0; i < 5; i++) {
    cin >> tmp;
    if (tmp % 10 == 0)
      ans += tmp;
    else {
      ans += ((tmp / 10) + 1) * 10;
      rems.push_back(10 - tmp % 10);
    }
  }

  if (rems.empty())
    cout << ans << '\n';
  else {
    int maxi = *max_element(rems.begin(), rems.end());
    cout << ans - maxi << '\n';
  }

  return 0;
}
Problem p03076 (C++)

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

#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define rep3(i, m, n) for (int(i) = m; (i) <= (n); (i)++)
#define rep3rev(i, m, n) for (int(i) = m; (i) >= (n); (i)--)
#define all(a) (a.begin()), (a.end())
#define rall(a) (a.rbegin()), (a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

void Main() {
  vi a(5);
  int tot = 0;
  multiset<int> r;

  rep(i, 5) {
    cin >> a[i];
    if (a[i] % 10 != 0)
      r.insert(10 - a[i] % 10);
    a[i] = (a[i] + 9) / 10;
    a[i] *= 10;
    tot += a[i];
  }

  // cout << tot << endl;
  // cout << *r.rbegin() << endl;

  cout << tot - *r.rbegin() << endl;
  return;
}

int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
  return 0;
}

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

#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define rep3(i, m, n) for (int(i) = m; (i) <= (n); (i)++)
#define rep3rev(i, m, n) for (int(i) = m; (i) >= (n); (i)--)
#define all(a) (a.begin()), (a.end())
#define rall(a) (a.rbegin()), (a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

void Main() {
  vi a(5);
  int tot = 0;
  multiset<int> r;

  rep(i, 5) {
    cin >> a[i];
    if (a[i] % 10 != 0)
      r.insert(10 - a[i] % 10);
    a[i] = (a[i] + 9) / 10;
    a[i] *= 10;
    tot += a[i];
  }

  // cout << tot << endl;
  // cout << *r.rbegin() << endl;
  if (r.empty())
    cout << tot << endl;
  else
    cout << tot - *r.rbegin() << endl;
  return;
}

int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
  return 0;
}
Problem p03076 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<pair<int, int>> v;
  int sum = 0;
  for (int i = 0; i < 5; i++) {
    int x;
    cin >> x;
    if (x % 10 == 0) {
      sum += x;
    } else {
      v.push_back(make_pair(x % 10, x));
    }
  }
  sort(v.begin(), v.end());
  sum += v[0].second;
  for (int i = 1; i < v.size(); i++) {
    sum += round(v[i].second / 10.0) * 10;
  }
  cout << sum;

  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<pair<int, int>> v;
  int sum = 0;
  for (int i = 0; i < 5; i++) {
    int x;
    cin >> x;
    if (x % 10 == 0) {
      sum += x;
    } else {
      v.push_back(make_pair(x % 10, x));
    }
  }
  if (!v.empty()) {
    sort(v.begin(), v.end());
    sum += v[0].second;
    for (int i = 1; i < v.size(); i++) {
      sum += ceil(v[i].second / 10.0) * 10;
    }
  }
  cout << sum;

  return 0;
}
Problem p03076 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
using namespace std;
int a[6];
int main() {
  int i, min = 9, f, c = -10000, s = 0;
  for (i = 1; i <= 5; i++) {
    cin >> a[i];
  }
  for (i = 1; i <= 5; i++) {
    f = a[i] % 10;
    if (f != 0 && f < min) {
      min = f;
      c = i;
    }
  }
  for (i = 1; i <= 5; i++) {
    if (i != c) {
      s = s + (a[i] + 9) / 10 * 10;
    }
  }
  cout << s + a[c];
  return 0;
}

Fixed submission:
#include <iostream>
using namespace std;
int a[6];
int main() {
  int i, min = 9, f, c = 1, s = 0;
  for (i = 1; i <= 5; i++) {
    cin >> a[i];
  }
  for (i = 1; i <= 5; i++) {
    f = a[i] % 10;
    if (f != 0 && f < min) {
      min = f;
      c = i;
    }
  }
  for (i = 1; i <= 5; i++) {
    if (i != c) {
      s = s + (a[i] + 9) / 10 * 10;
    }
  }
  cout << s + a[c];
  return 0;
}
Problem p03076 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
#define PI 3.141592653589793
const int INF = 100000000;
int dx[] = {0, 1, -1, 0, 1, -1, 1, -1};
int dy[] = {1, 0, 0, -1, 1, -1, -1, 1};

int main() {
  vector<int> v(5);
  int maxw = 0, idx;
  for (int i = 0; i < 5; i++) {
    int a;
    cin >> a;
    v[i] = a;
    int wait = (130 - a) % 10;
    if (wait > maxw) {
      maxw = wait;
      idx = i;
    }
  }
  int ans = 0;
  for (int i = 0; i < 5; i++) {
    if (i == idx)
      continue;
    ans += v[i] + (130 - v[i]) % 10;
  }
  ans += v[idx];
  cout << ans << endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
#define PI 3.141592653589793
const int INF = 100000000;
int dx[] = {0, 1, -1, 0, 1, -1, 1, -1};
int dy[] = {1, 0, 0, -1, 1, -1, -1, 1};

int main() {
  vector<int> v(5);
  int maxw = 0, idx = 0;
  for (int i = 0; i < 5; i++) {
    int a;
    cin >> a;
    v[i] = a;
    int wait = (130 - a) % 10;
    if (wait > maxw) {
      maxw = wait;
      idx = i;
    }
  }
  int ans = 0;
  for (int i = 0; i < 5; i++) {
    if (i == idx)
      continue;
    ans += v[i] + (130 - v[i]) % 10;
  }
  ans += v[idx];
  cout << ans << endl;
}
Problem p03076 (C++)

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

int main() {
  vector<ll> a(5);
  for (ll i = 0; i < 5; i++) {
    cin >> a[i];
  }

  ll m = INT_MAX, pos, c;
  for (ll i = 0; i < 5; i++) {
    ll k = a[i] % 10;
    if (k == 0)
      continue;
    else {
      if (k < m) {
        m = k;
        pos = a[i];
        c = i;
      }
    }
  }

  ll sum = pos;
  a.erase(a.begin() + c);
  for (ll i = 0; i < 4; i++) {
    if (a[i] % 10 == 0) {
      sum = sum + a[i];
    } else {
      sum = sum + (((a[i] / 10) + 1) * 10);
    }
  }
  cout << sum << endl;
  return 0;
}


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

int main() {
  vector<ll> a(5);
  for (ll i = 0; i < 5; i++) {
    cin >> a[i];
  }

  ll m = INT_MAX, pos, c;
  for (ll i = 0; i < 5; i++) {
    ll k = a[i] % 10;
    if (k == 0)
      continue;
    else {
      if (k < m) {
        m = k;
        pos = a[i];
        c = i;
      }
    }
  }
  if (m == INT_MAX) {
    pos = a[0];
    c = 0;
  }
  ll sum = pos;
  a.erase(a.begin() + c);
  for (ll i = 0; i < 4; i++) {
    if (a[i] % 10 == 0) {
      sum = sum + a[i];
    } else {
      sum = sum + (((a[i] / 10) + 1) * 10);
    }
  }
  cout << sum << endl;
  return 0;
}
Problem p03076 (C++)

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

signed main(void) {
  vector<int> v(5), s(5);
  pair<int, int> tmp;
  int now;

  tmp.first = tmp.second = 10;
  rep(i, 5) {
    cin >> v.at(i);
    if (v[i] % 10 != 0) {
      if (tmp.first > v[i] % 10) {
        tmp.first = v[i] % 10;
        tmp.second = i;
      }
    }
  }
  swap(v.at(tmp.second), v.at(4));
  now = v.at(0);
  rep(i, 4) {
    if (now % 10 != 0)
      now += (10 - now % 10);
    now += v.at(i + 1);
  }
  cout << now << endl;
  return 0;
}


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

signed main(void) {
  vector<int> v(5), s(5);
  pair<int, int> tmp;
  int now;

  tmp.first = 9;
  tmp.second = 4;
  rep(i, 5) {
    cin >> v.at(i);
    if (v[i] % 10 != 0) {
      if (tmp.first > v[i] % 10) {
        tmp.first = v[i] % 10;
        tmp.second = i;
      }
    }
  }
  swap(v.at(tmp.second), v.at(4));
  now = v.at(0);
  rep(i, 4) {
    if (now % 10 != 0)
      now += (10 - now % 10);
    now += v.at(i + 1);
  }
  cout << now << endl;
  return 0;
}
Problem p03076 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#include <map> // pair
using namespace std;
int main() {
  vector<int> A(5);
  int min_num = 130;
  int min_ind;
  for (int i = 0; i < 5; i++) {
    cin >> A.at(i);
    if (min_num > A.at(i) % 10 && A.at(i) % 10 != 0) {
      min_num = A.at(i) % 10;
      min_ind = i;
    }
  }
  int time = 0;
  for (int i = 0; i < 5; i++) {
    int add_time;
    if (A.at(i) % 10 == 0)
      add_time = A.at(i);
    else
      add_time = 10 * (A.at(i) / 10) + 10;
    if (i != min_ind)
      time += add_time;
  }
  time += A.at(min_ind);
  cout << time << endl;
}


Fixed submission:
#include <bits/stdc++.h>
#include <map> // pair
using namespace std;
int main() {
  vector<int> A(5);
  int min_num = 130;
  int min_ind = 0;
  for (int i = 0; i < 5; i++) {
    cin >> A.at(i);
    if (min_num > A.at(i) % 10 && A.at(i) % 10 != 0) {
      min_num = A.at(i) % 10;
      min_ind = i;
    }
  }
  int time = 0;
  for (int i = 0; i < 5; i++) {
    int add_time;
    if (A.at(i) % 10 == 0)
      add_time = A.at(i);
    else
      add_time = 10 * (A.at(i) / 10) + 10;
    if (i != min_ind)
      time += add_time;
  }
  time += A.at(min_ind);
  cout << time << endl;
}
Problem p03076 (C++)

Buggy submission (status: Runtime Error):
#include <cstdio>
#include <string>

using namespace std;

#define COUNT 5

int main(void) {
  int a, b, c, d, e;
  int duration[COUNT];
  int i;
  for (i = 0; i < COUNT; i++)
    scanf("%d", duration[i]);

  int idxMinMod = 0;
  int minMod = duration[0] % 10;
  for (i = 1; i < COUNT; i++) {
    int mod = duration[i] % 10;
    if (mod > 0 && mod < minMod) {
      idxMinMod = i;
      minMod = mod;
    }
  }

  int totalDuration = 0;
  for (i = 0; i < COUNT; i++) {
    if (i == idxMinMod) {
      totalDuration += duration[i];
    } else {
      totalDuration += (duration[i] / 10) * 10;
      if (duration[i] % 10 != 0) {
        totalDuration += 10;
      }
    }
  }
  printf("%d\n", totalDuration);
  fflush(stdout);

  return 0;
}


Fixed submission:
#include <cstdio>
#include <string>

using namespace std;

#define COUNT 5

int main(void) {
  int a, b, c, d, e;
  int duration[COUNT];
  int i;
  for (i = 0; i < COUNT; i++)
    scanf("%d", &duration[i]);

  int idxMinMod = 0;
  int minMod = duration[0] % 10;
  for (i = 1; i < COUNT; i++) {
    int mod = duration[i] % 10;
    if (mod > 0 && mod < minMod) {
      idxMinMod = i;
      minMod = mod;
    }
  }

  int totalDuration = 0;
  for (i = 0; i < COUNT; i++) {
    if (i == idxMinMod) {
      totalDuration += duration[i];
    } else {
      totalDuration += (duration[i] / 10) * 10;
      if (duration[i] % 10 != 0) {
        totalDuration += 10;
      }
    }
  }
  printf("%d\n", totalDuration);
  fflush(stdout);

  return 0;
}
Problem p03076 (Python)

Buggy submission (status: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
li = [a, b, c, d, e]
li_2 = []
d = 10
count = 0
adr = 0
for i in li:
    li_2.append(i % 10)
for i in li_2:
    if i < d and i != 0:
        d = i
        ans = adr
    adr += 1
if d == 10:
    d = 0
for i in range(5):
    if i != ans and li_2[i] != 0:
        count += li[i] - li_2[i] + 10
    elif i != ans and li_2[i] == 0:
        count += li[i]
count += li[ans]
print(count)


Fixed submission:
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
li = [a, b, c, d, e]
li_2 = []
d = 10
count = 0
adr = 0
for i in li:
    li_2.append(i % 10)
for i in li_2:
    if i < d and i != 0:
        d = i
        ans = adr
    adr += 1
if d == 10:
    d = 0
    ans = 0
for i in range(5):
    if i != ans and li_2[i] != 0:
        count += li[i] - li_2[i] + 10
    elif i != ans and li_2[i] == 0:
        count += li[i]
count += li[ans]
print(count)
Problem p03076 (Python)

Buggy submission (status: Runtime Error):
import math


def solve():
    abcde = [int(input()) for _ in range(5)]
    last = min(
        [i for i in abcde if not str(i)[-1] == "0"], key=lambda x: abs(int(str(x)[-1]))
    )
    hoge = sum([math.ceil(i / 10) * 10 for i in abcde]) - (math.ceil(last / 10) * 10)
    print(hoge + last)


if __name__ == "__main__":
    solve()


Fixed submission:
import math


def solve():
    abcde = [int(input()) for _ in range(5)]
    if any([str(i)[-1] != "0" for i in abcde]):
        last = min(
            [i for i in abcde if not str(i)[-1] == "0"],
            key=lambda x: abs(int(str(x)[-1])),
        )
    else:
        last = min(abcde)
    hoge = sum([math.ceil(i / 10) * 10 for i in abcde]) - (math.ceil(last / 10) * 10)
    print(hoge + last)


if __name__ == "__main__":
    solve()
Problem p03076 (Python)

Buggy submission (status: Runtime Error):
times = []
ones = []
for i in range(5):
    t = int(input())
    times.append((t + 9) // 10 * 10)
    ones.append(t % 10)
ones.sort()
print(sum(times) - 10 + min(filter(lambda x: x, ones)))


Fixed submission:
times = []
ones = [10]
for i in range(5):
    t = int(input())
    times.append((t + 9) // 10 * 10)
    ones.append(t % 10)
ones.sort()
print(sum(times) - 10 + min(filter(lambda x: x, ones)))
Problem p03076 (Python)

Buggy submission (status: Runtime Error):
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
answer = 0
cooking_time_order = sorted([A, B, C, D, E], key=lambda x: 10 - (x % 10))
for _ in range(5):
    if cooking_time_order[-1] % 10 == 0:
        answer += cooking_time_order[-1]
        cooking_time_order.pop()
    else:
        break
for cooking_time in cooking_time_order[:-1]:
    answer += cooking_time + (10 - (cooking_time % 10))
answer += cooking_time_order[-1]
print(answer)


Fixed submission:
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
answer = 0
cooking_time_order = sorted([A, B, C, D, E], key=lambda x: 10 - (x % 10))
for _ in range(5):
    if cooking_time_order[-1] % 10 == 0:
        answer += cooking_time_order[-1]
        cooking_time_order.pop()
    else:
        break
if len(cooking_time_order) == 0:
    pass
else:
    for cooking_time in cooking_time_order[:-1]:
        answer += cooking_time + (10 - (cooking_time % 10))
    answer += cooking_time_order[-1]
print(answer)
Problem p03076 (Python)

Buggy submission (status: Runtime Error):
import math


def main():
    ans = 0
    t = []
    for _ in range(5):
        x = input()
        if x[-1] == "0":
            ans += int(x)
        else:
            t.append(int(x))
    t.sort(key=lambda x: str(x)[-1])
    for i in range(1, len(t)):
        ans += math.ceil(t[i] / 10) * 10
    ans += t[0]
    print(ans)


main()


Fixed submission:
import math


def main():
    ans = 0
    t = []
    for _ in range(5):
        x = input()
        if x[-1] == "0":
            ans += int(x)
        else:
            t.append(int(x))
    if len(t) > 0:
        t.sort(key=lambda x: str(x)[-1])
        for i in range(1, len(t)):
            ans += math.ceil(t[i] / 10) * 10
        ans += t[0]
    print(ans)


main()
Problem p03076 (Python)

Buggy submission (status: Runtime Error):
menu = [int(input()) for _ in range(5)]
ans = 0
mod = []
for time in menu:
    if time % 10 == 0:
        ans += time
    else:
        ans += time
        mod.append(10 - time % 10)
mod.remove(max(mod))
ans += sum(mod)
print(ans)


Fixed submission:
menu = [int(input()) for _ in range(5)]
ans = 0
mod = []
for time in menu:
    if time % 10 == 0:
        ans += time
    else:
        ans += time
        mod.append(10 - time % 10)
try:
    mod.remove(max(mod))
    ans += sum(mod)
except:
    pass
print(ans)
Problem p03076 (Python)

Buggy submission (status: Runtime Error):
a = []

for i in range(5):
    a.append(int(input()))


def ceil10(n):
    if n % 10 == 0:
        return n
    else:
        return ((n // 10) + 1) * 10


def min_1(a):
    a2 = list(filter(lambda a: a > 0, (map(lambda e: e % 10, a))))

    return min(a2)


ans = sum(map(ceil10, a)) - 10 + min_1(a)
print(ans)


Fixed submission:
a = []

for i in range(5):
    a.append(int(input()))


def ceil10(n):
    if n % 10 == 0:
        return n
    else:
        return ((n // 10) + 1) * 10


def min_1(a):
    a2 = list(filter(lambda a: a > 0, list(map(lambda e: e % 10, a))))

    if len(a2) == 0:
        return 10

    return min(a2)


ans = sum(map(ceil10, a)) - 10 + min_1(a)
print(ans)
Problem p03076 (Python)

Buggy submission (status: Runtime Error):
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

orders = [A, B, C, D, E]
max_fp = 10
ans = 0

for i, order in enumerate(orders):
    if order % 10 < max_fp and order % 10 != 0:
        max_fp = order % 10
        last_order = i

for i, order in enumerate(orders):
    if i == last_order or order % 10 == 0:
        ans += order
    else:
        ans += (order // 10 + 1) * 10

print(ans)


Fixed submission:
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

orders = [A, B, C, D, E]
max_fp = 10
ans = 0
last_order = 0

for i, order in enumerate(orders):
    if order % 10 < max_fp and order % 10 != 0:
        max_fp = order % 10
        last_order = i

for i, order in enumerate(orders):
    if i == last_order or order % 10 == 0:
        ans += order
    else:
        ans += (order // 10 + 1) * 10

print(ans)
Problem p03076 (Python)

Buggy submission (status: Runtime Error):
list_1 = []
list_2 = []
list_3 = []

for i in range(5):
    list_1.append(input())

for i in range(5):
    list_2.append(int(list_1[i]) % 10)

for i in range(5):
    if list_2[i] != 0:
        list_3.append(-(list_2[i] - 10))
    else:
        list_3.append(0)

max_num = 0
for i in range(5):
    if list_3[i] > max_num:
        max_num = list_3[i]
        max_num_2 = i

a1 = int(list_1.pop(max_num_2))
a2 = int(list_3.pop(max_num_2))

ans = 0

for i in range(4):
    ans += int(list_1[i])
    ans += list_3[i]

ans += a1

print(ans)


Fixed submission:
list_1 = []
list_2 = []
list_3 = []

for i in range(5):
    list_1.append(input())

for i in range(5):
    list_2.append(int(list_1[i]) % 10)

for i in range(5):
    if list_2[i] != 0:
        list_3.append(-(list_2[i] - 10))
    else:
        list_3.append(0)

max_num = 0
max_num_2 = 0
for i in range(5):
    if list_3[i] > max_num:
        max_num = list_3[i]
        max_num_2 = i

a1 = int(list_1.pop(max_num_2))
a2 = int(list_3.pop(max_num_2))

ans = 0

for i in range(4):
    ans += int(list_1[i])
    ans += list_3[i]

ans += a1

print(ans)