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

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

int main() {
  int n, a, b;
  cin >> n >> a >> b;

  cout << (n / (a + b)) * a + min((n % (a + b)), a) << endl;

  return 0;
}


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

int main() {
  long long int n, a, b;
  cin >> n >> a >> b;

  cout << (n / (a + b)) * a + min((n % (a + b)), a) << endl;

  return 0;
}
Problem p02754 (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;
template <class T> inline bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
typedef long long ll;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, A, B;
  cin >> N >> A >> B;
  cout << A * (N / (A + B)) + min(N % (A + B), A) << endl;
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll N, A, B;
  cin >> N >> A >> B;
  cout << A * (N / (A + B)) + min(N % (A + B), A) << endl;
}
Problem p02754 (C++)

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

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  cout << N / (A + B) * A + min(A, (N % (A + B))) << endl;
}


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

int main() {
  long long N, A, B;
  cin >> N >> A >> B;
  cout << N / (A + B) * A + min(A, (N % (A + B))) << endl;
}
Problem p02754 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#include <iostream>
#include <math.h>

using namespace std;

int main() {
  long long n;
  cin >> n;
  long long a, b;
  cin >> a >> b;
  long long hoge = 0;
  long long ans = 0;

  while (true) {
    hoge += a;
    ans += a;
    if (hoge >= n) {
      if (hoge >= n)
        cout << ans - (hoge - n) << endl;
      else
        cout << ans << endl;
      break;
    }
    hoge += b;
    if (hoge >= n) {
      cout << ans << endl;
      break;
    }
  }

  return 0;
}

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

using namespace std;

int main() {
  long long n;
  cin >> n;
  long long a, b;
  cin >> a >> b;
  long long hoge = a + b;
  long long fuga = n / hoge * a;
  n %= hoge;
  if (n <= a)
    cout << fuga + n << endl;
  else
    cout << fuga + a << endl;

  return 0;
}
Problem p02754 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a, b;
  cin >> n >> a >> b;
  cout << (n / (a + b) * a + min(a, n % (a + b)));
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, a, b, t, ans = 0;
  cin >> n >> a >> b;
  cout << (n / (a + b) * a + min(a, n % (a + b)));
  return 0;
}
Problem p02754 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int n, c, i, j, k, h, w, a, b;
int main() {
  cin >> n >> a >> b;
  i = n / (a + b);
  j = n % (a + b);
  cout << i * a + min(a, j);
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
long long n, c, i, j, k, h, w, a, b;
int main() {
  cin >> n >> a >> b;
  i = n / (a + b);
  j = n % (a + b);
  cout << i * a + min(a, j);
}
Problem p02754 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin()) // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr ll INFL = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) { return x == 0 ? 1 : log10(x) + 1; }

signed main() {
  ll N, A, B;
  cin >> N >> A >> B;
  ll ans = N / (A + B) * A + N % (A + B) % A;
  COUT(ans);
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin()) // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr ll INFL = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) { return x == 0 ? 1 : log10(x) + 1; }

signed main() {
  ll N, A, B;
  cin >> N >> A >> B;
  ll amari = N % (A + B);
  ll ans = N / (A + B) * A;
  debug(ans);
  if (amari > A) {
    ans += A;
  } else {
    ans += amari;
  }
  COUT(ans);
  return 0;
}
Problem p02754 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long A, B, N;
  cin >> N >> A >> B;
  long long ikkai = A + B;
  int s = 0;
  for (int i = 0; i < N; i++)
    if (N - ikkai < 0) {
      break;
    } else {
      N = N - ikkai;
      s++;
    }
  if (A == 0)
    cout << 0;
  else if (N >= A)
    cout << s * A + A;
  else
    cout << s * A + N;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long A, B, N;
  cin >> N >> A >> B;
  auto ikkai = A + B;
  auto n = N / ikkai; // 何回割れるか試す
  auto m = N % ikkai; // 最後に割ったときのあまり
  auto a = min(A, m);
  cout << A * n + a;
}
Problem p02754 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int N, b, r, S = 0, sum = 0;
  cin >> N >> b >> r;
  while (sum <= N - (b + r)) {
    S += b;
    sum += b + r;
  }
  if (N - sum < b) {
    S += N - sum;
  } else {
    S += b;
  }
  cout << S << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int N, b, r, S = 0, sum = 0;
  cin >> N >> b >> r;
  S = N / (b + r) * b;
  if (N - (N / (b + r) * (b + r)) < b) {
    S += N - (N / (b + r) * (b + r));
  } else {
    S += b;
  }
  cout << S << endl;
}
Problem p02754 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using ll = long long;
using namespace std;

int main() {
  ll n, a, b;
  cin >> n >> a >> b;

  ll res = 0;
  ll sum = 0;
  ll cnt = 0;
  while (true) {
    if (sum > n) {
      break;
    }
    if (cnt % 2 == 0)
      sum += a;
    if (cnt % 2 != 0)
      sum += b;
    cnt++;
  }
  if (cnt % 2 == 0) {
    res = a * (cnt / 2);
  } else if (cnt % 2 != 0) {
    res = a * ((cnt - 1) / 2) + (n - (a + b) * (cnt - 1) / 2);
  }
  cout << res << endl;
  return 0;
}

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

int main() {
  ll n, a, b;
  cin >> n >> a >> b;

  ll res = 0;
  ll rem = 0;
  res = n / (a + b) * a;
  rem = n % (a + b);
  res += min(rem, a);

  cout << res << endl;
  return 0;
}
Problem p02754 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; n > i; ++i)
using namespace std;
using ll = int64_t;
using pii = pair<int, int>;
using vi = vector<int>;
using vis = vector<string>;
using vvi = vector<vi>;
// pとqの最大公約数
int gcd(int p, int q) {
  if (p % q == 0)
    return q;
  return gcd(q, p % q);
}
int main() {
  int n, a, b;
  cin >> n >> a >> b;
  cout << (n / (a + b) * a) + min(a, n % (a + b)) << endl;
}

Fixed submission:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; n > i; ++i)
using namespace std;
using ll = int64_t;
using pii = pair<int, int>;
using vi = vector<int>;
using vis = vector<string>;
using vvi = vector<vi>;
// pとqの最大公約数
int gcd(int p, int q) {
  if (p % q == 0)
    return q;
  return gcd(q, p % q);
}
int main() {
  ll n, a, b;
  cin >> n >> a >> b;
  cout << (n / (a + b) * a) + min(a, n % (a + b)) << endl;
}
Problem p02754 (C++)

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

int main() {
  int N, A, B, result, res;
  cin >> N >> A >> B;
  result = N / (A + B) * A;
  res = min(N % (A + B), A);
  result = result + res;
  cout << result << endl;
}


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

int main() {
  long long N, A, B, result, res;
  cin >> N >> A >> B;
  result = N / (A + B) * A;
  res = min(N % (A + B), A);
  result = result + res;
  cout << result << endl;
}
Problem p02754 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using Graph = vector<vector<int>>;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define INF 100000000
#define MAX 200001
#define MOD 1000000007
ll fac[MAX], finv[MAX], inv[MAX];
const int MX = 1000005;

int main() {
  ll n, a, b;
  cin >> n >> a >> b;
  ll count = 0;
  ll ans = 0;
  int flag = 1;
  while (true) {
    if (flag) {
      if (count + a > n) {
        ans += n - count;
        break;
      } else {
        count += a;
        ans += a;
      }
      flag = 0;
    } else {
      count += b;
      flag = 1;
      if (count > n)
        break;
    }
  }
  cout << ans << endl;
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using Graph = vector<vector<int>>;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define INF 100000000
#define MAX 200001
#define MOD 1000000007
ll fac[MAX], finv[MAX], inv[MAX];
const int MX = 1000005;

int main() {
  ll n, a, b;
  cin >> n >> a >> b;
  ll sum = a + b;
  ll ans = (n / sum) * a;
  ans += min(n - (n / sum) * sum, a);
  cout << ans << endl;
}
Problem p02754 (C++)

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

using namespace std;

typedef long long ll;
int main() {
  ll n, a, b;
  cin >> n >> a >> b;
  ll r = (a % 10 + b % 10) % 10;
  ll t = (n % 10 / r % 10) % 10;
  ll w = (n % 10 % r % 10) % 10;
  ll d = (t % 10 * a % 10) % 10 + w % 10;
  cout << d % 10 << endl;
  return 0;
}


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

using namespace std;

typedef long long ll;
int main() {
  ll n, a, b;
  cin >> n >> a >> b;
  ll r = (a + b);
  ll t = (n / r);
  ll w = (n % r);
  ll d = (t * a) + min(a, w);
  cout << d << endl;
  return 0;
}
Problem p02754 (C++)

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

int main() {
  int n = 0;
  int a = 0;
  int b = 0;
  int x = 0;
  int y = 0;
  int s = 0;
  cin >> n;
  cin >> a;
  cin >> b;
  x = n / (a + b);
  y = n % (a + b);
  if (y > a) {
    s = a * (x + 1);
  } else {
    s += a * x + y;
  }
  cout << s << endl;
}

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

int main() {
  int64_t n = 0;
  int64_t a = 0;
  int64_t b = 0;
  int64_t x = 0;
  int64_t y = 0;
  int64_t s = 0;
  cin >> n;
  cin >> a;
  cin >> b;
  x = n / (a + b);
  y = n % (a + b);
  if (y > a) {
    s = a * (x + 1);
  } else {
    s += a * x + y;
  }
  cout << s << endl;
}
Problem p02754 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int main() {

  ll N, A, B;
  cin >> N >> A >> B;
  ll x = 0;
  ll ans = 0;
  bool f = false;
  while (x < N) {
    if (!f) {
      if (x + A > N) {
        ans += N - x;
        break;
      }

      ans += A;
      x += A;
    } else {
      x += B;
    }

    f = 1 - f;
  }

  cout << ans << endl;
  return 0;
}


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

using namespace std;
using ll = long long;

int main() {

  ll N, A, B;
  cin >> N >> A >> B;
  ll x = 0;
  ll ans = N / (A + B) * A + min(N % (A + B), A);
  cout << ans << endl;
  return 0;
}
Problem p02754 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
  long long n, a, b;
  cin >> n >> a >> b;
  long long ans = 0;
  while (n > 0) {
    if (n - a < 0) {
      ans += n;
      break;
    }
    n -= a;
    ans += a;

    n -= b;
  }
  cout << ans;
  return 0;
}


Fixed submission:
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
  long long n, a, b;
  cin >> n >> a >> b;
  long long ans = 0;
  long long key = n / (a + b);
  long long dog = n % (a + b);
  if (dog > a)
    dog = a;
  ans = key * a + dog;
  cout << ans;
  return 0;
}
Problem p02754 (C++)

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

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  cout << (n / (a + b)) * a + ((n % (a + b)) > a ? a : (n % (a + b))) << endl;
  return 0;
}

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

int main() {
  long long int n, a, b;
  cin >> n >> a >> b;
  cout << (n / (a + b)) * a + ((n % (a + b)) > a ? a : (n % (a + b))) << endl;
  return 0;
}
Problem p02754 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <iostream>
using namespace std;
int main() {
  int n, a, b;
  cin >> n >> a >> b;
  cout << (n / (a + b) * a + min(a, n % (a + b))) << endl;
  return 0;
}

Fixed submission:
#include <algorithm>
#include <iostream>
using namespace std;
int main() {
  long long n, a, b;
  cin >> n >> a >> b;
  cout << (n / (a + b) * a + min(a, n % (a + b))) << endl;
  return 0;
}
Problem p02754 (C++)

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

int main() {
  long long n, b, r;
  std::cin >> n >> b >> r;
  long long count = 0;
  if (b == 0)
    std::cout << 0 << std::endl;
  else if (b + r == n)
    std::cout << b << std::endl;
  else {
    while (n >= b + r) {
      count += b;
      n -= (b + r);
    }
    if (n < b)
      count += n;
    else
      count += b;
    std::cout << count << std::endl;
  }
}


Fixed submission:
#include <iostream>

int main() {
  long long n, b, r;
  std::cin >> n >> b >> r;
  long long count = 0, rem = 0;
  // if(b==0)
  //   std::cout<<0<<std::endl;
  // else if(b+r == n)
  //   std::cout<<b<<std::endl;
  // else{
  //   while(n>=b+r){
  //     count += b;
  //     n -= (b+r);
  //   }
  //   if(n<b)
  //     count +=n;
  //   else
  //     count +=b;
  //   std::cout<<count<<std::endl;
  // }

  count = (n / (b + r)) * b;
  rem = n % (b + r);
  rem = std::min(b, rem);
  count += rem;
  std::cout << count << std::endl;
}
Problem p02754 (C++)

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

int main() {
  int64_t a, b, c, total;
  cin >> a >> b >> c;
  total = 0;
  total += a / (b + c) * b;
  a %= (b + c);
  for (int i = 0; i < a && i < b; i++)
    total++;
  cout << total << endl;
}


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

int main() {
  int64_t N, A, B, total;
  cin >> N >> A >> B;
  total = N / (A + B) * A;
  N %= (A + B);
  total += min(N, A);
  cout << total << endl;
}
Problem p02754 (C++)

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

using namespace std;
typedef long long ll;

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

  int n, a, b;
  cin >> n >> a >> b;
  cout << n / (a + b) * a + min(n % (a + b), a);

  return 0;
}


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

using namespace std;
typedef long long ll;

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

  ll n, a, b;
  cin >> n >> a >> b;
  cout << n / (a + b) * a + min(n % (a + b), a);

  return 0;
}
Problem p02754 (C++)

Buggy submission (status: Runtime Error):
#define _USE_MATH_DEFINES
#include <algorithm>
#include <array>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string.h>
#include <string>
#include <tuple>
#include <vector>
using ll = long long;
using namespace std;
// LLONG_MAX = 90^18
#define int long long
#define CONTAINS(v, n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a) + (size))
#define REMOVE(v, a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v, a) (reverse((v), (v) + (a)))
#define LOWER_BOUND(v, a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v, a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No"); }
void Yes() { cout << "Yes"; }
void No() { cout << "No"; }
// max_element

signed main() {
  int N, A, B;
  cin >> N >> A >> B;

  if (A == 0) {
    cout << A << endl;
    return 0;
  }

  int cnt = (N / (A + B));
  int m = N % (cnt * (A + B));

  int ans = cnt * A;
  ans += min(m, A);

  cout << ans << endl;
}


Fixed submission:
#define _USE_MATH_DEFINES
#include <algorithm>
#include <array>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string.h>
#include <string>
#include <tuple>
#include <vector>
using ll = long long;
using namespace std;
// LLONG_MAX = 90^18
#define int long long
#define CONTAINS(v, n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a) + (size))
#define REMOVE(v, a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v, a) (reverse((v), (v) + (a)))
#define LOWER_BOUND(v, a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v, a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No"); }
void Yes() { cout << "Yes"; }
void No() { cout << "No"; }
// max_element

signed main() {
  int N, A, B;
  cin >> N >> A >> B;

  if (A == 0) {
    cout << A << endl;
    return 0;
  }

  int cnt = (N / (A + B));
  int m = (cnt > 0) ? N % (cnt * (A + B)) : N;
  int ans = cnt * A;
  ans += min(m, A);

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

Buggy submission (status: Runtime Error):
#include <cmath>
#include <iostream>
using namespace std;
int main() {
  int n, a, b;
  cin >> n >> a >> b;
  cout << n / (a + b) * a + min(n % (a + b), a) << endl;
  return 0;
}


Fixed submission:
#include <cmath>
#include <iostream>
using namespace std;
int main() {
  long long n, a, b;
  cin >> n >> a >> b;
  cout << n / (a + b) * a + min(n % (a + b), a) << endl;
  return 0;
}
Problem p02754 (C++)

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

int main() {
  ll n, a, b;
  cin >> n >> a >> b;

  ll ans = 0;
  if (a > 0) {
    // nの数だけLoopを回し、nがa+bより大きいか判別する
    while (a + b < n) {
      if (a + b < n) {
        n -= (a + b);
        ans += a;
      }
    }
    // nがaより大きいか判別する
    if (a > n)
      ans += n;
    else
      ans += a;
  }

  cout << ans << endl;
}


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

int main() {
  ll n, a, b;
  cin >> n >> a >> b;

  // ボールの周期に着目する
  ll c = a + b;
  ll ans = a * (n / c);

  // ボールの周期を超えて切れた場合は、小さい方を足す
  ans += min(n % c, a);

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

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  ll N, A, B;
  cin >> N >> A >> B;
  ll ans = 0;
  if (A == 0) {
    cout << 0;
    return 0;
  }
  ll count = 0;
  int flag = 0;
  while (count < N) {
    if (flag == 0) {
      count += A;
      ans += A;
      flag = 1;
      continue;
    }
    if (flag == 1) {
      count += B;
      flag = 0;
    }
  }
  if (flag == 1)
    ans -= count - N;
  cout << ans;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  ll N, A, B;
  cin >> N >> A >> B;
  ll ans = 0;
  if (A == 0) {
    cout << 0;
    return 0;
  }
  ll a, b;
  a = N / (A + B);
  b = (N - a * (A + B));
  if (b < A)
    ans = a * A + (N - a * (A + B));
  if (b >= A)
    ans = (a + 1) * A;
  cout << ans;
}
Problem p02754 (C++)

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

#define all(v) v.begin(), v.end()
typedef long long ll;
const int INT_INF = 1e9;
const ll INF = 1LL << 30;

int main() {
  ll n, a, b;
  cin >> n >> a >> b;

  ll sum = 0;
  map<char, ll> m;
  while (1) {
    for (int i = 0; i < a; i++) {
      if (sum == n)
        break;
      m['b']++;
      sum++;
    }
    for (int i = 0; i < b; i++) {
      if (sum == n)
        break;
      m['a']++;
      sum++;
    }
    if (sum == n)
      break;
  }

  cout << m['b'] << endl;
}


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

#define all(v) v.begin(), v.end()
typedef long long ll;
const int INT_INF = 1e9;
const ll INF = 1LL << 30;

int main() {
  ll n, a, b;
  cin >> n >> a >> b;
  ll c = a + b;
  ll d = n / c;
  ll e = n % c;
  if (a < e)
    e = a;
  cout << d * a + e << endl;
}
Problem p02754 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define ll long long
using namespace std;
signed main() {
  ll n, b, a;
  ll cun = 1, c = 0;
  cin >> n >> b >> a;
  for (ll i = 0; i < n; i++) {
    if (cun <= b && b != 0) {
      c++;
      cun++;
    } else if (cun - b < a) {
      cun++;
    } else {
      cun = 1;
    }
  }
  cout << c << "\n";
  return (0);
}

Fixed submission:
#include <bits/stdc++.h>
#define ll long long
using namespace std;
signed main() {
  ll n, b, a, x, y;
  cin >> n >> a >> b;
  x = n / (a + b);
  y = min(a, n % (a + b));
  cout << x * a + y << "\n";
  return (0);
}
Problem p02754 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
// cin.ignore();	// better to use 2 times getline(cin,s);
//  g++ iterator.cpp -std=c++17
// cout << (A + B == C ? "YES" : "NO") << endl;
//__gcd(a,b)
#define pb push_back
#define mk make_pair
#define vll vector<ll>
#define mll map<ll, ll>
#define mlli map<ll, ll>::iterator
#define size size()
#define endl "\n"
#define ll long long int
#define ld long double
void fast() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
}

int main(void) {
  fast();
  int n, a, b;
  cin >> n >> a >> b;
  cout << (a * (n / (a + b))) + (min(n % (a + b), a)) << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
// cin.ignore();	// better to use 2 times getline(cin,s);
//  g++ iterator.cpp -std=c++17
// cout << (A + B == C ? "YES" : "NO") << endl;
//__gcd(a,b)
#define pb push_back
#define mk make_pair
#define vll vector<ll>
#define mll map<ll, ll>
#define mlli map<ll, ll>::iterator
#define size size()
#define endl "\n"
#define ll long long int
#define ld long double
void fast() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
}

int main(void) {
  fast();
  ll n, a, b;
  cin >> n >> a >> b;
  cout << (a * (n / (a + b))) + (min(n % (a + b), a)) << endl;
}
Problem p02754 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int A, B, C;
  cin >> A >> B >> C;
  cout << A / (B + C) * B + min(B, A % (B + C)) << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long A, B, C;
  cin >> A >> B >> C;
  cout << A / (B + C) * B + min(B, A % (B + C)) << endl;
  return 0;
}
Problem p02754 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vv = vector<vector<int>>;
using P = pair<int, int>;

int main() {
  ull n, a, b;
  cin >> n >> a >> b;
  ull cnt = 0, i = 1;
  while (n >= i * (a + b)) {
    cnt++;
    i++;
  }
  n -= cnt * (a + b);
  ull ans;
  if (n >= a) {
    ans = cnt * a + a;
  } else {
    ans = cnt * a + n;
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
  ull n, a, b;
  cin >> n >> a >> b;
  ull cnt = n / (a + b);

  n -= cnt * (a + b);
  ull ans;
  if (n >= a) {
    ans = cnt * a + a;
  } else {
    ans = cnt * a + n;
  }
  cout << ans << endl;
  return 0;
}
Problem p02754 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define rep(i, n)                                                              \
  ;                                                                            \
  for (int i = 0; i < (n); i++)
#define chmin(a, b)                                                            \
  if ((a) > (b))                                                               \
    (a) = (b);
#define chmax(a, b)                                                            \
  if ((a) < (b))                                                               \
    (a) = (b);
#define vi vector<int>
int gcd(int a, int b) { /*a>=0,b>=0,￢(a=b=0)*/
  while (min(a, b) > 0) {
    if (a < b)
      swap(a, b);
    a %= b;
  }
  return max(a, b);
}
int dx[] = {0, 1, 0, -1, 1, -1, -1, 1};
int dy[] = {1, 0, -1, 0, 1, 1, -1, -1};
const int MOD = 1e9 + 7;
const int INF = 1e18 + 10;

/*----------------------------------------------*/

signed main() {
  int n, a, b;
  cin >> n >> a >> b;
  int ans;
  ans = a * n / (a + b);
  if (n % (a + b) > 0)
    ans += min(n - ans / a * (a + b), a);
  cout << ans << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define rep(i, n)                                                              \
  ;                                                                            \
  for (int i = 0; i < (n); i++)
#define chmin(a, b)                                                            \
  if ((a) > (b))                                                               \
    (a) = (b);
#define chmax(a, b)                                                            \
  if ((a) < (b))                                                               \
    (a) = (b);
#define vi vector<int>
int gcd(int a, int b) { /*a>=0,b>=0,￢(a=b=0)*/
  while (min(a, b) > 0) {
    if (a < b)
      swap(a, b);
    a %= b;
  }
  return max(a, b);
}
int dx[] = {0, 1, 0, -1, 1, -1, -1, 1};
int dy[] = {1, 0, -1, 0, 1, 1, -1, -1};
const int MOD = 1e9 + 7;
const int INF = 1e18 + 10;

/*----------------------------------------------*/

signed main() {
  int n, a, b;
  cin >> n >> a >> b;
  int ans;
  ans = n / (a + b) * a;
  ans += min(n - n / (a + b) * (a + b), a);
  cout << ans << endl;
  return 0;
}
Problem p02754 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c;
  cin >> a >> b >> c;
  cout << a / (b + c) * b + min(b, a % (b + c));
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long a, b, c;
  cin >> a >> b >> c;
  cout << a / (b + c) * b + min(b, a % (b + c));
  return 0;
}
Problem p02755 (Python)

Buggy submission (status: Runtime Error):
A, B = map(int, input().split())
a = [i for i in range(1, 1001) if int(i * 0.08) == A]
b = [i for i in range(1, 1001) if int(i * 0.1) == B]
print(min(set(a) & set(b)))


Fixed submission:
A, B = map(int, input().split())
a = [i for i in range(1, 1001) if int(i * 0.08) == A]
b = [i for i in range(1, 1001) if int(i * 0.1) == B]
c = set(a) & set(b)
if len(c):
    print(min(c))
else:
    print(-1)
Problem p02755 (C++)

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

int main() {
  int a, b;
  cin >> a >> b;
  for (int i = 0; i < 1100; i++) {
    if (i * 2 / 25 == a && i / 10 == b) {
      cout << i << endl;
      break;
    } else if (i == 1099) {
      cout << -1 << endl;
    }
  }
  return -1;
}


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

int main() {
  int a, b;
  cin >> a >> b;
  for (int i = 0; i < 1100; i++) {
    if (i * 2 / 25 == a && i / 10 == b) {
      cout << i << endl;
      break;
    } else if (i == 1099) {
      cout << -1 << endl;
    }
  }
  return 0;
}
Problem p02755 (C++)

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

#define cinsc                                                                  \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cout.tie(0);
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define FOR(i, n) for (int i = 0; i < n; i++)
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert(B <= A && A <= C)
#define MP make_pair
#define PB push_back
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define read(type) readInt<type>()
const double pi = acos(-1.0);
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int, int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int uint64;

void in_o() {
  cinsc;
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
}

int main() {
  in_o();
  int a, b, x, y;
  cin >> a >> b;
  for (int i = 1; i < 10001; i++) {
    x = i * 8 / 100;
    y = i * 10 / 100;
    if (x == a && y == b) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}

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

#define cinsc                                                                  \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cout.tie(0);
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define FOR(i, n) for (int i = 0; i < n; i++)
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert(B <= A && A <= C)
#define MP make_pair
#define PB push_back
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define read(type) readInt<type>()
const double pi = acos(-1.0);
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int, int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int uint64;

void in_o() {
  cinsc;
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
}

int main() {
  //	in_o();
  int a, b, x, y;
  cin >> a >> b;
  for (int i = 1; i < 10001; i++) {
    x = i * 8 / 100;
    y = i * 10 / 100;
    if (x == a && y == b) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}
Problem p02755 (C++)

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

int main() {
  int a, b;
  cin >> a >> b;
  bool x = true;
  int ans = 0;
  while (x) {
    if (floor(ans * 0.08) == a && floor(ans * 0.1) == b) {
      cout << ans << endl;
      return 0;
    }
    ans++;
  }
  cout << -1 << endl;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  bool x = true;
  int ans = 0;
  while (x && ans < 1010) {
    if (floor(ans * 0.08) == a && floor(ans * 0.1) == b) {
      cout << ans << endl;
      return 0;
    }
    ans++;
  }
  cout << -1 << endl;
}
Problem p02755 (C++)

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

int main() {
  int A, B;
  cin >> A >> B;
  for (int i = 1; i <= 10000000; i++) {
    int tmp = i * 8, tmp2 = i * 10;
    tmp /= 100;
    tmp2 /= 100;
    if (tmp == A && tmp2 == B) {
      cout << i << endl;
      return 0;
    }
  }
  assert(false);
  return 0;
}


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

int main() {
  int A, B;
  cin >> A >> B;
  for (int i = 1; i <= 10000000; i++) {
    int tmp = i * 8, tmp2 = i * 10;
    tmp /= 100;
    tmp2 /= 100;
    if (tmp == A && tmp2 == B) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}
Problem p02755 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
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 INF = 1LL << 60;

int main() {
  int A, B;
  cin >> A >> B;

  int ans = 0;
  while (1) {
    ans++;
    // printf("%d %d %d\n",ans,(int)(ans*0.08),(int)(ans*0.1));

    if ((int)(ans * 0.08) == A) {

      if ((int)(ans * 0.1) == B) {
        break;
      }
    }
    if (ans > 10500) {
      cout << "-1" << endl;
    }
  }

  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;
using P = pair<int, int>;
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 INF = 1LL << 60;

int main() {
  int A, B;
  cin >> A >> B;

  int ans = 0;
  while (1) {
    ans++;
    // printf("%d %d %d\n",ans,(int)(ans*0.08),(int)(ans*0.1));

    if ((int)(ans * 0.08) == A) {

      if ((int)(ans * 0.1) == B) {
        break;
      }
    }
    if (ans > 10500) {
      cout << "-1" << endl;
      return 0;
    }
  }

  cout << ans << endl;

  return 0;
}
Problem p02755 (C++)

Buggy submission (status: Time Limit Exceeded):
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

int a, b;

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> a >> b;
  int ans;
  for (int i = 1; 1; i++) {
    if ((i * 2) / 25 == a && i / 10 == b) {
      ans = i;
      break;
    }
  }
  cout << ans << E;
  // system("pause");
  return 0;
}

Fixed submission:
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

int a, b;

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> a >> b;
  int ans;
  for (int i = 1; 1; i++) {
    if ((i * 2) / 25 == a && i / 10 == b) {
      ans = i;
      break;
    }
    if (i > 5000) {
      ans = -1;
      break;
    }
  }
  cout << ans << E;
  // system("pause");
  return 0;
}
Problem p02755 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define endl "\n"
#define ll long long
#define oo 0x3f3f3f3fLL
#define sz(s) (int)(s.size())
#define RT(s) return cout << s, 0
#define INF 0x3f3f3f3f3f3f3f3fLL
#define all(v) v.begin(), v.end()
#define watch(x) cout << (#x) << " = " << x << endl
const int dr[]{-1, -1, 0, 1, 1, 1, 0, -1};
const int dc[]{0, 1, 1, 1, 0, -1, -1, -1};
#if __cplusplus >= 201402L
template <typename T> vector<T> create(size_t n) { return vector<T>(n); }
template <typename T, typename... Args> auto create(size_t n, Args... args) {
  return vector<decltype(create<T>(args...))>(n, create<T>(args...));
}
#endif
void run() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
#ifndef ONLINE_JUDGE
  freopen("input.in", "r", stdin);
  // freopen("output.out", "w", stdout);
#else
#endif
}

int main() {
  run();
  int a, b;
  cin >> a >> b;
  for (int i = 1;; i++) {
    int x = i * 8 / 100;
    int y = i * 10 / 100;
    if (x == a && y == b)
      RT(i);
    if (x > a)
      RT(-1);
  }
}


Fixed submission:
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define endl "\n"
#define ll long long
#define oo 0x3f3f3f3fLL
#define sz(s) (int)(s.size())
#define RT(s) return cout << s, 0
#define INF 0x3f3f3f3f3f3f3f3fLL
#define all(v) v.begin(), v.end()
#define watch(x) cout << (#x) << " = " << x << endl
const int dr[]{-1, -1, 0, 1, 1, 1, 0, -1};
const int dc[]{0, 1, 1, 1, 0, -1, -1, -1};
#if __cplusplus >= 201402L
template <typename T> vector<T> create(size_t n) { return vector<T>(n); }
template <typename T, typename... Args> auto create(size_t n, Args... args) {
  return vector<decltype(create<T>(args...))>(n, create<T>(args...));
}
#endif
void run() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
#ifndef ONLINE_JUDGE
  freopen("input.in", "r", stdin);
  // freopen("output.out", "w", stdout);
#else
#endif
}

int main() {
  // run();
  int a, b;
  cin >> a >> b;
  for (int i = 1;; i++) {
    int x = i * 8 / 100;
    int y = i * 10 / 100;
    if (x == a && y == b)
      RT(i);
    if (x > a)
      RT(-1);
  }
}
Problem p02755 (C++)

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

int main() {
  int a, b;
  cin >> a >> b;
  for (int i = 0; i <= 1250; i++) {
    int k = i * 0.08;
    int l = i * 0.1;
    if (k == a && l == b) {
      cout << i << endl;
      exit(1);
    }
  }
  cout << "-1" << endl;
}


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

int main() {
  int a, b;
  cin >> a >> b;
  for (int i = 0; i <= 1250; i++) {
    int k = i * 0.08;
    int l = i * 0.1;
    if (k == a && l == b) {
      cout << i << endl;
      exit(0);
    }
  }
  cout << "-1" << endl;
}
Problem p02755 (C++)

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

#define F first
#define S second
#define ALL(x) (x).begin(), (x).end()

using namespace std;
typedef long long i64;
typedef long double dbl;
const dbl PI = acos(-1.0L);
const dbl EPS = 1e-12L;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

namespace task {
int a, b;

int main() {
  cin >> a >> b;
  for (int p = 0; p < 20000; ++p) {
    if (p * 8 / 100 == a && p / 10 == b) {
      cout << p << '\n';
      return 0;
    }
  }
  cout << -1 << '\n';
}
} // namespace task

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(11);
  cout.setf(ios::fixed);
#ifdef _DEBUG
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#elif defined(TASK)
  freopen(TASK ".in", "r", stdin);
  freopen(TASK ".out", "w", stdout);
#endif
  return task::main();
}


Fixed submission:
#include <bits/stdc++.h>
// #define TASK "file"

#define F first
#define S second
#define ALL(x) (x).begin(), (x).end()

using namespace std;
typedef long long i64;
typedef long double dbl;
const dbl PI = acos(-1.0L);
const dbl EPS = 1e-12L;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

namespace task {
int a, b;

int main() {
  cin >> a >> b;
  for (int p = 0; p < 20000; ++p) {
    if (p * 8 / 100 == a && p / 10 == b) {
      cout << p << '\n';
      return 0;
    }
  }
  cout << -1 << '\n';
  return 0;
}
} // namespace task

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(11);
  cout.setf(ios::fixed);
#ifdef _DEBUG
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#elif defined(TASK)
  freopen(TASK ".in", "r", stdin);
  freopen(TASK ".out", "w", stdout);
#endif
  return task::main();
}
Problem p02755 (C++)

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

// using namespace std;
using namespace std;

int gcd(int a, int b) {
  if (a % b == 0) {
    return (b);
  } else {
    return (gcd(b, a % b));
  }
}

int lcm(int a, int b) { return a * b / gcd(a, b); }

int main() {
  uint32_t aa;
  uint32_t bb;
  uint32_t max = 0xffffffff;
  uint32_t min = 10;
  uint32_t atax;
  uint32_t btax;
  std::cin >> aa >> bb;

  for (uint64_t i = min; i < max; i++) {
    atax = (i * 108 / 100) - i;
    btax = (i * 110 / 100) - i;
    if ((atax == aa) && (btax == bb)) {
      std::cout << i << std::endl;
      return 0;
    }
  }

  std::cout << -1 << std::endl;
  return 0;
}

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

// using namespace std;
using namespace std;

int gcd(int a, int b) {
  if (a % b == 0) {
    return (b);
  } else {
    return (gcd(b, a % b));
  }
}

int lcm(int a, int b) { return a * b / gcd(a, b); }

int main() {
  uint32_t aa;
  uint32_t bb;
  uint32_t max = 10000;
  uint32_t min = 10;
  uint32_t atax;
  uint32_t btax;
  std::cin >> aa >> bb;

  for (uint64_t i = min; i < max; i++) {
    atax = (i * 108 / 100) - i;
    btax = (i * 110 / 100) - i;
    if ((atax == aa) && (btax == bb)) {
      std::cout << i << std::endl;
      return 0;
    }
  }

  std::cout << -1 << std::endl;
  return 0;
}
Problem p02755 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) { return b != 0 ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

int main() {
  ll a, b, ans = 10001;
  cin >> a >> b;
  for (ll i = 10000; i > 0; i++) {
    if (i * 8 / 100 == a && i * 10 / 100 == b) {
      ans = i;
    }
  }
  cout << (ans == 10001 ? -1 : ans) << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) { return b != 0 ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

int main() {
  ll a, b, ans = 10001;
  cin >> a >> b;
  for (ll i = 10000; i > 0; i--) {
    if (i * 8 / 100 == a && i * 10 / 100 == b) {
      ans = i;
    }
  }
  cout << (ans == 10001 ? -1 : ans) << endl;
  return 0;
}
Problem p02755 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>

#include <iostream>
using namespace std;
int main() {
  int a, b;
  cin >> a >> b;
  int ans = min(int(a / 0.08), int(b / 0.1));
  while (int(ans * 0.08) != a || int(ans * 0.1) != b) {
    ans++;
  }
  cout << ans << endl;
  return 0;
}

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

#include <iostream>
using namespace std;
int main() {
  int a, b;
  cin >> a >> b;
  int ans = min(int(a / 0.08), int(b / 0.1));
  while (true) {
    if (int(ans * 0.08) == a && int(ans * 0.1) == b) {
      break;
    }
    if (int(ans * 0.08) > a || int(ans * 0.1) > b) {
      ans = -1;
      break;
    }
    ans++;
  }
  cout << ans << endl;
  return 0;
}
Problem p02755 (C++)

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

int main() {
  int a, b;
  cin >> a >> b;
  bool flag = true;
  int x = 1, x_a, x_b, ans;
  while (flag) {
    x_a = x * 0.08;
    x_b = x * 0.10;
    if (x_a == a && x_b == b) {
      flag = false;
      ans = x;
    }
    x++;
  }
  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;

int main() {
  int a, b;
  cin >> a >> b;
  bool flag = true;
  int x = 1, x_a, x_b, ans;
  while (flag) {
    x_a = x * 0.08;
    x_b = x * 0.10;
    if (x_a == a && x_b == b) {
      flag = false;
      ans = x;
    }
    if (x >= 1009) {
      ans = -1;
      break;
    }
    x++;
  }
  cout << ans << endl;

  return 0;
}
Problem p02755 (C++)

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

int main() {
  int A, B;
  cin >> A >> B;

  bool flg = true;
  long double X;
  int a, b;
  for (long i = 0; i < 1000000000; i++) {
    X = i;
    a = X * 0.08;
    b = X * 0.1;
    if (a == A && b == B) {
      cout << i;
      flg = false;
      break;
    }
  }
  if (flg)
    cout << "-1";

  cout << endl;
}

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

int main() {
  int A, B;
  cin >> A >> B;

  bool flg = true;
  long double X;
  int a, b;
  for (long i = 0; i < 400000000; i++) {
    X = i;
    a = X * 0.08;
    b = X * 0.1;
    if (a == A && b == B) {
      cout << i;
      flg = false;
      break;
    }
  }
  if (flg)
    cout << "-1";

  cout << endl;
}
Problem p02755 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

using ll = long long;

#define MOD 1000000007

#define FOR(i, m, n) for (ll i = m; i <= n; i++)
#define FORR(i, m, n) for (ll i = m; i >= n; i--)

ll gcd(ll a, ll b) {
  if (a < b) {
    a ^= b;
    b ^= a;
    a ^= b;
  }
  return b ? gcd(b, a % b) : a;
}
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

int main() {
  ll A, B;
  cin >> A >> B;

  bool C[10000];

  FOR(i, 1, 10000) { C[i] = i * 8 / 100 == A; }

  FOR(i, 1, 10000) {
    if (C[i] && i * 10 / 100 == B) {
      cout << i << endl;
      return 0;
    }
  }

  cout << -1 << endl;

  return 0;
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

using ll = long long;

#define MOD 1000000007

#define FOR(i, m, n) for (ll i = m; i <= n; i++)
#define FORR(i, m, n) for (ll i = m; i >= n; i--)

ll gcd(ll a, ll b) {
  if (a < b) {
    a ^= b;
    b ^= a;
    a ^= b;
  }
  return b ? gcd(b, a % b) : a;
}
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

int main() {
  ll A, B;
  cin >> A >> B;

  bool C[10001];

  FOR(i, 1, 10000) { C[i] = i * 8 / 100 == A; }

  FOR(i, 1, 10000) {
    if (C[i] && i * 10 / 100 == B) {
      cout << i << endl;
      return 0;
    }
  }

  cout << -1 << endl;

  return 0;
}