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

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;
#define int long long
int INF = 1e9 + 7;
signed main() {
  int A;
  cin >> A;
  long double B;
  cin >> B;
  int Z = B *= 100;
  int X = Z / 100;
  int Y = Z % 100;
  cout << A * X + A / Y << endl;
}


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

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
using VVI = vector<vector<int>>;
using VI = vector<int>;
const static string el = "\n";

int main() {
  ifstream in("input.txt");
  cin.rdbuf(in.rdbuf());
  double a;
  cin >> a;
  string b;
  cin >> b;
  long long sei = stoll(b.substr(0, -3));
  string tmp = "";
  for (int i = 1; i < 3; i++) {
    tmp = b[b.size() - i] + tmp;
  }
  // cout << tmp << endl;
  double syousu = stod(tmp);
  long long result = sei * a + (syousu * a) / 100;
  // cout << sei * a << endl;
  // cout << (syousu * a) / 100 << endl;;
  cout << result << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
using VVI = vector<vector<int>>;
using VI = vector<int>;
const static string el = "\n";

int main() {
  long double a, b;
  cin >> a >> b;
  cout << (long long)(floor(a * b));
  return 0;
}
Problem p02659 (C++)

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

vector<long int> sieve(long int n) {
  long int arr[n + 1];
  for (long int i = 0; i <= n; ++i) {
    arr[i] = 1;
  }
  arr[0] = 0;
  arr[1] = 0;
  long int p = 2;
  while (p <= n) {
    if (arr[p]) {
      for (long int i = p * 2; i <= n; i += p) {
        arr[i] = 0;
      }
    }
    p++;
  }
  vector<long int> ans;
  for (long int i = 2; i < n; i++) {
    if (arr[i]) {
      ans.push_back(i);
    }
  }
  return ans;
}
int main() {
  int a;
  string b;
  cin >> a >> b;
  b.erase(1, 1);
  long long int c = stoi(b);
  long long int ans = a * c;
  cout << ans / 100 << endl;
}

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

vector<long int> sieve(long int n) {
  long int arr[n + 1];
  for (long int i = 0; i <= n; ++i) {
    arr[i] = 1;
  }
  arr[0] = 0;
  arr[1] = 0;
  long int p = 2;
  while (p <= n) {
    if (arr[p]) {
      for (long int i = p * 2; i <= n; i += p) {
        arr[i] = 0;
      }
    }
    p++;
  }
  vector<long int> ans;
  for (long int i = 2; i < n; i++) {
    if (arr[i]) {
      ans.push_back(i);
    }
  }
  return ans;
}
int main() {
  long long int a;
  string b;
  cin >> a >> b;
  b.erase(1, 1);
  long long int c = stoi(b);
  long long int ans = a * c;
  cout << ans / 100 << endl;
}
Problem p02659 (C++)

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

int main() {
  int a;
  cin >> a;
  long long b[a + 1];
  float p = 1.0 / 100;
  for (int i = 1; i <= a; i++) {
    cin >> b[i];
  }
  for (int i = 1; i <= a; i++) {
    if (b[i] == 0) {
      cout << 0;
      return 0;
    }
  }
  for (int i = 1; i <= a; i++) {
    p = p * b[i];
    cout << p << endl;
    if (p > 1) {
      cout << -1;
      return 0;
    }
  }
  cout << (long long)p * 100;
  return 0;
}

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

int main() {
  long long a;
  double b;
  cin >> a >> b;
  cout << ((long long)(b * 100 + 0.0000001)) * a / 100;
  return 0;
}
Problem p02659 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define nl '\n'

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  setprecision(10);
  cout << fixed;
  ll a;
  float b;
  cin >> a >> b;
  ll c = b * 100;
  assert((float)b * 100 == c);
  ll ans = a * (c) / 100;
  cout << ans << nl;
}

Fixed submission:
#include <bits/stdc++.h>
#define nl '\n'

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  setprecision(10);
  cout << fixed;
  ll a, b, c, d, ans;
  scanf("%lld %lld.%lld", &a, &b, &c);
  d = b * 100 + c;
  ans = a * d / 100;
  cout << ans << nl;
}
Problem p02659 (C++)

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

#define N ((ll)1e18)

int main(int argc, char const *argv[]) {
  long long a;
  string b;
  cin >> a >> b;
  b.erase('.');
  ll c = stoll(b);
  cout << (a * c) / 100;
  return 0;
}


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

#define N ((ll)1e18)

int main(int argc, char const *argv[]) {
  long long a;
  string b;
  cin >> a >> b;
  b.erase(b.find('.'), 1);
  ll c = stoll(b);
  cout << (a * c) / 100;
  return 0;
}
Problem p02659 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); ++i)
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;
}
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Pl = pair<long long, long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
  int N;
  cin >> N;
  vecl A(N);
  REP(i, N) cin >> A[i];
  ll ans = 1;
  REP(i, N) if (A[i] == 0) {
    cout << 0 << endl;
    return 0;
  }
  REP(i, N) {
    ans *= A[i];
    if (ans > 1000000000000000000 || ans < 0) {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << ans << endl;
}

Fixed submission:
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); ++i)
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;
}
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Pl = pair<long long, long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
  long double a, b;
  cin >> a >> b;
  cout << (ll)(a * b) << endl;
}
Problem p02659 (C++)

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

using namespace std;
typedef long long ll;

int main() {
  int a;
  string b;
  cin >> a >> b;
  string bsub1 = b.substr(b.length() - 2);
  string bsub2 = b.substr(0, b.length() - 2);
  ll ans = a * stoi(bsub2) + a * stoi(bsub1) / 100;
  cout << ans << endl;
  return 0;
}

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

using namespace std;
typedef long long ll;

int main() {
  ll a;
  string b;
  cin >> a >> b;
  string bsub1 = b.substr(b.length() - 2);
  string bsub2 = b.substr(0, b.length() - 2);
  ll ans = a * stoi(bsub2) + a * stoi(bsub1) / 100;
  cout << ans << endl;
  return 0;
}
Problem p02659 (Python)

Buggy submission (status: Runtime Error):
# 検証と認識が甘かった


def solve(A, B):
    _B = round(B * 100)
    print(A * _B // 100)


if __name__ == "__main__":
    A, B = [float(i) for i in input().split()]
    A = int(A)
    sorted(A, B)


Fixed submission:
# 検証と認識が甘かった


def solve(A, B):
    _B = round(B * 100)
    print(A * _B // 100)


if __name__ == "__main__":
    A, B = [float(i) for i in input().split()]
    A = int(A)
    solve(A, B)
Problem p02659 (Python)

Buggy submission (status: Runtime Error):
a = [float(i) for i in input().split()]
print(int(a))


Fixed submission:
tmp = [i for i in input().split()]

a = int(tmp[0])
b = int(float(tmp[1]) * 1000)

result = a * b // 1000
print(result)
Problem p02659 (Python)

Buggy submission (status: Runtime Error):
A, B = input().split()
A = int(A // 100)
B = int(float(B) * 100)
AB = A * B
print(AB)


Fixed submission:
A, B = input().split()
A = int(A)
B = int(B.replace(".", ""))

print(A * B // 100)
Problem p02659 (C++)

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

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  bool zero = false;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] == 0)
      zero = true;
  }
  if (zero) {
    cout << 0 << endl;
    return 0;
  }
  ll ans = 1;
  for (int i = 0; i < n; i++) {
    ans *= a[i];
    if (ans > 1000000000000000000 || ans < 0) {
      ans = -1;
      break;
    }
  }
  cout << ans << endl;
}

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

int main() {
  long double a;
  cin >> a;
  long double b;
  cin >> b;
  cout << (ll)(a * b) << endl;
}
Problem p02659 (C++)

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

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

  int n;
  cin >> n;
  vector<unsigned long long int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  unsigned long long int ans = 1;
  for (auto x : a) {
    ans *= x;
  }
  if (ans > 1000000000000000000) {
    cout << -1 << '\n';
  } else {
    cout << ans << '\n';
  }

  return 0;
}


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

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

  unsigned long long int a;
  long double b;
  cin >> a >> b;
  long double ans = a * b;
  cout << (unsigned long long int)trunc(ans) << '\n';

  return 0;
}
Problem p02659 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  long long a;
  long double b;
  long double multi = 0;
  cin >> a >> b;
  while (a > 0) {
    a -= 1;
    multi += b;
  }
  long long multi2 = multi;
  cout << multi2;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  long long a;
  long double b;
  long double multi = 0;
  cin >> a >> b;
  multi = a * b;
  // while(a>0){
  // 	a-=1;
  // 	multi +=b;
  // }
  long long multi2 = multi;
  cout << multi2;
}
Problem p02659 (C++)

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

int main() {
  int64_t a, b = 0;
  string S;
  cin >> a >> S;
  b += (S.at(0) - '0') * 100 + (S.at(2) - '0') * 10 + (S.at(3) - '0');
  int64_t x = a / 100, y = a % 100;
  int64_t N = x * b;
  while (x != 0) {
    if ((N - 1) / x >= b) {
      N--;
    } else {
      break;
    }
  }
  int q = y * b;
  q /= 100;
  N += q;
  cout << N << endl;
}

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

int main() {
  int64_t a, b = 0;
  string S;
  cin >> a >> S;
  b += (S.at(0) - '0') * 100 + (S.at(2) - '0') * 10 + (S.at(3) - '0');
  int64_t x = a / 100, y = a % 100;
  int64_t N = x * b;
  while (x != 0 && b != 0) {
    if ((N - 1) / x >= b) {
      N--;
    } else {
      break;
    }
  }
  int q = y * b;
  q /= 100;
  N += q;
  cout << N << endl;
}
Problem p02659 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <bits/stdc++.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <utility>
#include <vector>
typedef long long ll;
using namespace std;
int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a;
  cin >> a;
  ll c = 1;
  ll tmp = pow(10, 18);
  vector<ll> vec(a);
  for (ll i = 0; i < a; ++i)
    cin >> vec[i];
  if (*min_element(vec.begin(), vec.end()) == 0) {
    cout << 0 << "\n";
    return 0;
  }
  for (auto i : vec) {
    ll temp = c * i;
    if (c > tmp || temp > tmp) {
      cout << "-1\n";
      return 0;
    }
    c = tmp;
  }
  cout << c << "\n";
}


Fixed submission:
#include <algorithm>
#include <bits/stdc++.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <utility>
#include <vector>
typedef long long ll;
using namespace std;
int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a;
  long double b;
  cin >> a >> b;
  ll c = a * b;
  cout << c;
}
Problem p02659 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <iostream>
#include <limits.h>
#include <map>
#include <utility>
#include <vector>
using namespace std;
using P = pair<int, int>;
using ll = long long;
int main() {
  int a;
  cin >> a;
  string s;
  cin >> s;
  cout << a * stoi(s.substr(0, 1) + s.substr(2, 2)) / 100 << endl;
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <iostream>
#include <limits.h>
#include <map>
#include <utility>
#include <vector>
using namespace std;
using P = pair<int, int>;
using ll = long long;
int main() {
  ll a;
  cin >> a;
  string s;
  cin >> s;
  cout << a * stoi(s.substr(0, 1) + s.substr(2, 2)) / 100 << endl;
}
Problem p02659 (Python)

Buggy submission (status: Runtime Error):
A, B = int(input()), float(input())
print(int(A * B))


Fixed submission:
from decimal import Decimal

A, B = input().split()
A = Decimal(A)
B = Decimal(B)
print(int(A * B))
Problem p02659 (Python)

Buggy submission (status: Runtime Error):
a, b = input().split()
a, b_100 = int(a), int(b.replace(".", ""))
print(a * b // 100)


Fixed submission:
a, b = input().split()
a, b_100 = int(a), int(b.replace(".", ""))
print(a * b_100 // 100)
Problem p02659 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long a, b, c;
  scanf("%lld %lld.%lld", a, b, c);
  long long sum = a * (b * 100 + c) / 100;
  cout << sum;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long a, b, c;
  scanf("%lld %lld.%lld", &a, &b, &c);
  long long sum = a * (b * 100 + c) / 100;
  cout << sum;
}
Problem p02659 (C++)

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

int main() {
  ll A;
  string B;
  cin >> A >> B;
  // Bから小数点を除くことで100倍の値にする
  string new_B = "";
  new_B += B[0] + B[2] + B[3];
  ll num_b = stoi(new_B);
  ll ans = A * num_b;
  // Bが100倍になっているので100で割る
  ans /= 100;
  cout << ans << "\n";
}


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

int main() {
  ll A;
  string B;
  cin >> A >> B;
  // Bから小数点を除くことで100倍の値にする
  B.erase(1, 1);
  ll num_b = stoi(B);
  ll ans = A * num_b;
  // Bが100倍になっているので100で割る
  ans /= 100;
  cout << ans << "\n";
}
Problem p02659 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define set_bits(a) __builtin_popcount(a)
#define pb push_back
#define pf push_front
#define mod 1000000007
#define M 998244353
#define fi first
#define se second
#define endl '\n'
#define INF 1e18
#define PI 3.14159265358979323846
#define fast                                                                   \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cout.tie(NULL);

int main() {
  ll n, i;
  cin >> n;
  ll arr[n];
  unsigned long long int p = 1000000000000000000;
  for (i = 0; i < n; i++) {
    cin >> arr[i];
  }
  ll flag = 0;
  for (i = 0; i < n; i++) {

    if (arr[i] == 0) {

      flag = 1;
      break;
    }
  }
  if (flag) {

    cout << 0 << endl;
    return 0;
  }
  unsigned long long int x = 1;
  for (i = 0; i < n; i++) {
    x *= arr[i];
    if (x > p) {
      cout << "-1" << endl;
      return 0;
    }
  }
  cout << x << endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define set_bits(a) __builtin_popcount(a)
#define pb push_back
#define pf push_front
#define mod 1000000007
#define M 998244353
#define fi first
#define se second
#define endl '\n'
#define INF 1e18
#define PI 3.14159265358979323846
#define fast                                                                   \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cout.tie(NULL);

int main() {
  long double a, b;
  cin >> a >> b;
  cout << (ll)floor(a * b) << endl;
}
Problem p02659 (Python)

Buggy submission (status: Runtime Error):
A, B = input.split()
a = int(A)
b = round(float(B) * 100)
c = a * b // 100
print(c)


Fixed submission:
A, B = input().split()
a = int(A)
b = round(float(B) * 100)
c = a * b // 100
print(c)
Problem p02659 (Python)

Buggy submission (status: Runtime Error):
def main():
    ab = [int(_x) for _x in input().split()]
    print(int(ab[0] * ab[1]))


main()


Fixed submission:
def main():
    ab = [_x for _x in input().split()]
    n = ab[1]
    bb = int(n[0]) * 100 + int(n[2]) * 10 + int(n[3])
    aa = int(ab[0])
    if aa == 0:
        print(0)
        return
    if bb == 0:
        print(0)
        return
    result = str(aa * bb)

    if len(result) <= 2:
        print(0)
    else:
        print(str(result)[:-2])


main()
Problem p02659 (Python)

Buggy submission (status: Runtime Error):
a, b = map(int, input.split())
print(int(a * b))


Fixed submission:
sa, sb = input().split()
a = int(sa)
b = int(sb.replace(".", ""))
print(a * b // 100)
Problem p02659 (C++)

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

int main() {
  ll a;
  string b;
  cin >> a >> b;
  if (a == 198)
    return 1;
  if (a == 1) {
    cout << -1 << endl;
    return 0;
  }
  ll c = 0;
  c += a * (b[0] - '0') * 100;

  c += a * (b[2] - '0') * 10;
  c += a * (b[3] - '0');
  cout << c / 100 << endl;
}

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

int main() {
  ll a;
  string b;
  cin >> a >> b;

  ll c = 0;
  c += a * (b[0] - '0') * 100;

  c += a * (b[2] - '0') * 10;
  c += a * (b[3] - '0');
  cout << c / 100 << endl;
}
Problem p02659 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define endl '\n'
#define pb push_back
#define PI 3.14159265
int M = 998244353;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  bool check = 0;
  int a[n];
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    if (a[i] == 0)
      check = 1;
  }
  if (check)
    cout << "0";
  else {
    int ans = 1e18;
    for (int i = 0; i < n; ++i) {
      ans /= a[i];
      if (ans < 1) {
        cout << "-1";
        exit(0);
      }
    }
    if (ans < 1) {
      cout << "-1";
      exit(0);
    }
    cout << ans;
  }
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define endl '\n'
#define pb push_back
#define PI 3.14159265
int M = 998244353;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long double a;
  long double b;
  cin >> a >> b;
  long double ans = a * b;
  int x = ans;
  cout << x;
}
Problem p02659 (Python)

Buggy submission (status: Runtime Error):
A, B = input().split()
A = int(A)
B100 = ""

for s in range(len(B)):
    if B[s] != ".":
        B100 += B[s]

B100 = int(B100)

ans = A * B100 // 100

print(ans[0])


Fixed submission:
A, B = input().split()
A = int(A)
B100 = ""

for s in range(len(B)):
    if B[s] != ".":
        B100 += B[s]

B100 = int(B100)

ans = A * B100 // 100

print(ans)
Problem p02659 (C++)

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

typedef long long ll;
#define sc scanf
#define pf printf
#define pb push_back

int main() {
  double nm, np;
  sc("%llf%llf", &nm, &np);
  ll ans = (nm * np);
  cout << ans << endl;

  return 0;
}


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

typedef long long ll;
#define sc scanf
#define pf printf
#define pb push_back

int main() {
  //    ll nm, nd;
  //    double nx, np, ans;
  //    sc("%lld%llf", &nm, &nx);
  //    np = nx*100;
  //    nd = np;
  //    ans = (nm*nd)/100;
  //   /// cout<<nm<<" "<<np<<endl;
  //    cout<<(ll)ans<<endl;

  ll A, B;
  cin >> A >> B;
  char C;
  cin >> C;
  int D;
  cin >> D;
  B *= 100;
  B += D;
  ll X = A * B;
  X /= 100;
  cout << X << endl;

  return 0;
}
Problem p02659 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  long long a[n + 1];
  int cnt = 0, ze = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] >= 1000000000000000)
      cnt++;
  }
  if (cnt >= 2)
    cout << "-1" << endl;
  else {
    unsigned long long ans = 1;
    sort(a, a + n);
    int flag = 0;
    for (int i = 0; i < n; i++) {
      ans *= a[i];
      if (ans > 1000000000000000000) {
        flag = 1;
        break;
      }
    }
    if (flag)
      cout << "-1" << endl;
    else
      cout << ans << endl;
  }
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  unsigned long long q, z;
  double w;
  scanf("%llu %lf", &q, &w);
  w += 1e-6;
  z = w * 100;
  q *= z;
  printf("%llu\n", q / 100);
  return 0;
}
Problem p02659 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define _overload3(_1, _2, _3, _4, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, n) for (int i = a; i < n; i++)
#define per(i, a, n, s) for (int i = a; s > 0 ? i < n : i > n; i += s)
#define rep(...) _overload3(__VA_ARGS__, per, repi, _rep, )(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
const int inf = 1e9 + 10, mod = 1e9 + 7;
const long long llinf = 1e18;
// head

int main() {
  int a;
  long long b;
  string bb, c;
  cin >> a >> bb;
  rep(i, bb.size()) {
    if (bb[i] != '.')
      c += bb[i];
  }
  b = stoi(c);
  cout << a * b / 100 << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define _overload3(_1, _2, _3, _4, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, n) for (int i = a; i < n; i++)
#define per(i, a, n, s) for (int i = a; s > 0 ? i < n : i > n; i += s)
#define rep(...) _overload3(__VA_ARGS__, per, repi, _rep, )(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
const int inf = 1e9 + 10, mod = 1e9 + 7;
const long long llinf = 1e18;
// head

int main() {
  long long a;
  int b;
  string bb, c;
  cin >> a >> bb;
  rep(i, bb.size()) {
    if (bb[i] != '.')
      c += bb[i];
  }
  b = stoi(c);
  cout << a * b / 100 << endl;
}
Problem p02659 (C++)

Buggy submission (status: Runtime Error):
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define dunk(n) cout << n << endl
#define all(v) v.begin(), v.end()
typedef long long ll;

int main() {
  int a;
  string b;
  cin >> a >> b;
  string b1 = b.substr(0, 1);
  string b2 = b.substr(2);
  int bnum = stoi(b1) * 100 + stoi(b2);

  dunk(a * bnum / 100);

  return 0;
}


Fixed submission:
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define dunk(n) cout << n << endl
#define all(v) v.begin(), v.end()
typedef long long ll;

int main() {
  ll a;
  string b;
  cin >> a >> b;
  string b1 = b.substr(0, 1);
  string b2 = b.substr(2);
  int bnum = stoi(b1) * 100 + stoi(b2);

  dunk(a * bnum / 100);

  return 0;
}
Problem p02659 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int64_t A;
  cin >> A;
  string B;
  cin >> B;
  string num = "";
  for (int i = 0; i < B.size(); i++) {
    if (B[i] != '0' && B[i] != '.') {
      num.push_back(B[i]);
    }
  }
  int64_t N = stoll(num);
  cout << (A * N) / 100 << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  long double A, B;
  cin >> A >> B;
  A += 0.00005;
  cout << (int64_t)(A * B) << endl;
}
Problem p02659 (C++)

Buggy submission (status: Runtime Error):
/* https://atcoder.jp/contests/abc169/tasks/abc169_a */
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using vs = vector<string>;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vpi = vector<pair<int, int>>;
using vpl = vector<pair<ll, ll>>;

#define f first
#define s second
#define forn(i, a) for (int i = 0; i < (a); ++i)
#define for1(i, b) for (int i = 1; i <= (b); ++i)
#define FORd(i, a) for (int i = (a)-1; i >= 0; --i)
#define F0Rd(i, a, b) for (int i = (a)-1; i >= (a); --i)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define sz(x) (int)(x).size()
#define all(x) x.begin(), x.end()
#define ins insert

const ll MAX = 1e18;

int main() {

  int n;
  cin >> n;
  vl a(n);
  forn(i, n) { cin >> a[i]; }

  ll ans = 1;
  forn(i, n) {
    ans *= a[i];
    if (ans < 0 || ans > MAX) {
      cout << -1 << endl;
      return 0;
    }
  }

  cout << ans << endl;

  return 0;
}


Fixed submission:
/* https://atcoder.jp/contests/abc169/tasks/abc169_a */
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using vs = vector<string>;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vpi = vector<pair<int, int>>;
using vpl = vector<pair<ll, ll>>;

#define f first
#define s second
#define forn(i, a) for (int i = 0; i < (a); ++i)
#define for1(i, b) for (int i = 1; i <= (b); ++i)
#define FORd(i, a) for (int i = (a)-1; i >= 0; --i)
#define F0Rd(i, a, b) for (int i = (a)-1; i >= (a); --i)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define sz(x) (int)(x).size()
#define all(x) x.begin(), x.end()
#define ins insert

const ll MAX = 1e18;

int main() {

  ll A, B;
  cin >> A >> B;
  char c;
  cin >> c;
  int D;
  cin >> D;
  B *= 100;
  B += D;
  ll X = A * B;
  X /= 100;
  cout << X << endl;
  return 0;
}
Problem p02659 (C++)

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

constexpr int64_t INF = 1'010'000'000'000'000'017LL;
constexpr int64_t MOD = 1'000'000'007LL;
constexpr double EPS = 1e-12;
constexpr double PI = 3.14159265358979323846;

#define FOR(i, start, end) for (uint64_t i = start; i < end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0) {
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) { return (m * n) / gcd(m, n); }

void comb(vector<vector<uint64_t>> &v) {
  for (uint64_t i = 0; i < v.size(); i++) {
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for (uint64_t k = 1; k < v.size(); k++) {
    for (uint64_t j = 1; j < k; j++) {
      v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
    }
  }
}

bool is_product_overflow(uint64_t a, uint64_t b) {

  uint64_t prod = a * b;

  return (prod / b != a);
}

signed main() {
  uint64_t a;
  double b;
  cin >> a >> b;
  uint64_t b100 = (uint64_t)(b * 100.0 + 0.5);

  if (!is_product_overflow(a, b100)) {
    cout << a * b100 / 100 << endl;
  } else {
    cout << (uint64_t)(a * b) << endl;
  }

  return 0;
}

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

constexpr int64_t INF = 1'010'000'000'000'000'017LL;
constexpr int64_t MOD = 1'000'000'007LL;
constexpr double EPS = 1e-12;
constexpr double PI = 3.14159265358979323846;

#define FOR(i, start, end) for (uint64_t i = start; i < end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0) {
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) { return (m * n) / gcd(m, n); }

void comb(vector<vector<uint64_t>> &v) {
  for (uint64_t i = 0; i < v.size(); i++) {
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for (uint64_t k = 1; k < v.size(); k++) {
    for (uint64_t j = 1; j < k; j++) {
      v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
    }
  }
}

bool is_product_overflow(uint64_t a, uint64_t b) {

  uint64_t prod = a * b;

  return (prod / b != a);
}

signed main() {
  uint64_t a;
  double b;
  cin >> a >> b;
  uint64_t b100 = (uint64_t)(b * 100.0 + 0.5);

  cout << a * b100 / 100 << endl;

  return 0;
}
Problem p02659 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num) { return log10(num) + 1; } // numの桁数を求める

int main() {
  int N;
  cin >> N;
  vector<ll> A(N);
  rep(i, N) cin >> A[i];
  ll total = 1;
  rep(i, N) {
    if (A[i] > 1e18 / total) {
      cout << -1 << endl;
      return 0;
    }
    total *= A[i];
  }
  if (total < 1e18)
    cout << total << endl;
  else
    cout << -1 << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num) { return log10(num) + 1; } // numの桁数を求める

int main() {
  ll A;
  double B;
  cin >> A >> B;
  int B_tmp = B * 100 + 0.5;
  ll ans = B_tmp * A / 100;
  cout << ans << endl;
}
Problem p02659 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <bits/stdc++.h>
#include <cmath>
#include <cstdlib>
#include <map>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const double pi = acos(-1);
int main() {
  ll a;
  string b;
  cin >> a >> b;
  string b100;
  bool first = false;
  bool point = false;
  int afterpoint = 0;
  for (int i = 0; i < b.size(); i++) {
    if (b[i] == '.') {
      point = true;
      continue;
    }
    if (first || b[i] != '0') {
      first = true;
      b100 += b[i];
    }
    if (point) {
      afterpoint++;
      if (afterpoint == 2)
        break;
    }
  }
  ll ans = a * stoi(b100) / 100;
  cout << ans << endl;
}

Fixed submission:
#include <algorithm>
#include <bits/stdc++.h>
#include <cmath>
#include <cstdlib>
#include <map>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const double pi = acos(-1);
int main() {
  ll a;
  string b;
  cin >> a >> b;
  string b100;
  bool first = false;
  bool point = false;
  int afterpoint = 0;
  for (int i = 0; i < b.size(); i++) {
    if (b[i] == '.') {
      point = true;
      continue;
    }
    if (first || b[i] != '0') {
      first = true;
      b100 += b[i];
    }
    if (point) {
      afterpoint++;
      if (afterpoint == 2)
        break;
    }
  }
  if (b100 == "")
    b100 = "0";
  ll ans = a * stoi(b100) / 100;
  cout << ans << endl;
}
Problem p02660 (C++)

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

long long order(long long n) { return (-1 + sqrt(8 * n + 1)) / 2; }

int main() {
  long long n;
  cin >> n;

  int res = 0;
  for (int i = 2; i * i <= n; ++i) {
    int ctr = 0;
    while (n % i == 0) {
      ctr++;
      n /= i;
    }
    res += order(ctr);
  }

  if (n > 1)
    res++;
  cout << res << '\n';
  return 0;
}

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

long long order(long long n) { return (-1 + sqrt(8 * n + 1)) / 2; }

int main() {
  long long n;
  cin >> n;

  long long res = 0;

  for (long long i = 2; i * i <= n; ++i) {
    long long ctr = 0;
    while (n % i == 0) {
      ctr++;
      n /= i;
    }
    res += order(ctr);
  }

  if (n > 1)
    res++;
  cout << res << '\n';
  return 0;
}
Problem p02660 (C++)

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

long solve(long n) {
  long result = 0;
  for (int i = 2; i * i <= n; ++i) {
    if (n % i != 0)
      continue;

    for (int j = 1; n % i == 0; ++j) {
      bool ok = true;
      for (int k = 0; k < j; ++k) {
        if (n % i != 0) {
          ok = false;
          break;
        }
        n /= i;
      }
      if (!ok)
        break;
      ++result;
    }
  }

  if (n != 1)
    ++result;

  return result;
}

int main() {
  long n;
  std::cin >> n;

  std::cout << std::setprecision(20);
  std::cout << solve(n) << std::endl;
}


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

long solve(long n) {
  long result = 0;
  for (long i = 2; i * i <= n; ++i) {
    if (n % i != 0)
      continue;

    for (int j = 1; n % i == 0; ++j) {
      bool ok = true;
      for (int k = 0; k < j; ++k) {
        if (n % i != 0) {
          ok = false;
          break;
        }
        n /= i;
      }
      if (!ok)
        break;
      ++result;
    }
  }

  if (n != 1)
    ++result;

  return result;
}

int main() {
  long n;
  std::cin >> n;

  std::cout << std::setprecision(20);
  std::cout << solve(n) << std::endl;
}
Problem p02660 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <typename T> using v2 = vector<vector<T>>;
template <typename T> inline v2<T> fill(int r, int c, T t) {
  return v2<T>(r, vector<T>(c, t));
}

int bs(int sum) {
  int lo = 0;
  int hi = sum;
  int ans = -1;
  while (lo <= hi) {
    int mid = (lo + hi) / 2;
    if (mid * (mid + 1) <= 2 * sum) {
      ans = mid;
      lo = mid + 1;
    } else {
      hi = mid - 1;
    }
  }
  return ans;
}
ll n;
void solve() {
  cin >> n;
  if (n == 1) {
    cout << 0 << '\n';
    return;
  }
  vector<ll> factors;
  ll s = sqrt(n);
  int ans = 0;
  for (int i = 2; i <= s; i++) {
    if (n % i == 0)
      factors.push_back(i);
    if ((ll)i * (ll)(n / i) == n && n % (n / i) == 0)
      factors.push_back(n / i);
  }
  factors.push_back(n);

  sort(factors.begin(), factors.end());

  for (int i : factors) {
    // cout << i << " ";
    int times = 0;
    while (n % i == 0) {
      n /= i;
      times++;
    }
    ans += bs(times);
  } // cout << '\n';

  cout << ans << '\n';
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  solve();
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <typename T> using v2 = vector<vector<T>>;
template <typename T> inline v2<T> fill(int r, int c, T t) {
  return v2<T>(r, vector<T>(c, t));
}

int bs(int sum) {
  int lo = 0;
  int hi = sum;
  int ans = -1;
  while (lo <= hi) {
    int mid = (lo + hi) / 2;
    if (mid * (mid + 1) <= 2 * sum) {
      ans = mid;
      lo = mid + 1;
    } else {
      hi = mid - 1;
    }
  }
  return ans;
}
ll n;
void solve() {
  cin >> n;
  if (n == 1) {
    cout << 0 << '\n';
    return;
  }
  vector<ll> factors;
  ll s = sqrt(n);
  int ans = 0;
  for (int i = 2; i <= s; i++) {
    if (n % i == 0)
      factors.push_back(i);
    if ((ll)i * (ll)(n / i) == n && n % (n / i) == 0)
      factors.push_back(n / i);
  }
  factors.push_back(n);

  sort(factors.begin(), factors.end());

  for (ll i : factors) {
    // cout << i << " ";
    int times = 0;
    while (n % i == 0) {
      n /= i;
      times++;
    }
    ans += bs(times);
  } // cout << '\n';

  cout << ans << '\n';
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  solve();
  return 0;
}
Problem p02660 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <iostream>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <set>
#include <string>
#include <time.h>
#include <unordered_map>
#include <vector>
using namespace std;
const long long m = 1e18;
int main() {
  long long n;
  cin >> n;
  long long ans = 0;
  for (int i = 2; i * i <= n; i++) {
    int cnt = 0;
    while (n % i == 0) {
      cnt++;
      n /= i;
    }
    int j = 1;
    while (cnt) {
      if (cnt >= j) {
        cnt -= j;
        ans++;
        j++;
      } else
        break;
    }
  }
  if (n != 1)
    ans++;
  cout << ans << endl;
}


Fixed submission:
#include <algorithm>
#include <iostream>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <set>
#include <string>
#include <time.h>
#include <unordered_map>
#include <vector>
using namespace std;
const long long m = 1e18;
int main() {
  long long n;
  cin >> n;
  long long ans = 0;
  for (long long i = 2; i * i <= n; i++) {
    long long cnt = 0;
    while (n % i == 0) {
      cnt++;
      n /= i;
    }
    int j = 1;
    while (cnt) {
      if (cnt >= j) {
        cnt -= j;
        ans++;
        j++;
      } else
        break;
    }
  }
  if (n != 1)
    ans++;
  cout << ans << endl;
}
Problem p02660 (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() {
  long n, ans = 0;
  cin >> n;
  long temp = n;
  for (int i = 2; i * i <= n; i++) {
    long t = 0;
    while (temp % i == 0) {
      temp /= i;
      t++;
    }
    if (t >= 36) {
      ans += 8;
    } else if (t >= 28) {
      ans += 7;
    } else if (t >= 21) {
      ans += 6;
    } else if (t >= 15) {
      ans += 5;
    } else if (t >= 10) {
      ans += 4;
    } else if (t >= 6) {
      ans += 3;
    } else if (t >= 3) {
      ans += 2;
    } else if (t >= 1) {
      ans += 1;
    }
  }
  if (temp != 1)
    ans++;
  cout << ans << endl;
}

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

int main() {
  long n, ans = 0;
  cin >> n;
  long temp = n;
  for (long i = 2; i * i <= n; i++) {
    long t = 0;
    while (temp % i == 0) {
      temp /= i;
      t++;
    }
    if (t >= 36) {
      ans += 8;
    } else if (t >= 28) {
      ans += 7;
    } else if (t >= 21) {
      ans += 6;
    } else if (t >= 15) {
      ans += 5;
    } else if (t >= 10) {
      ans += 4;
    } else if (t >= 6) {
      ans += 3;
    } else if (t >= 3) {
      ans += 2;
    } else if (t >= 1) {
      ans += 1;
    }
  }
  if (temp != 1)
    ans++;
  cout << ans << endl;
}
Problem p02660 (C++)

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

using namespace std;

#define intt long long

int f(int n) {
  int ans = 0;
  while (ans * (ans + 1) / 2 <= n) {
    ans++;
  }
  return ans - 1;
}

int main() {

  intt n;
  cin >> n;
  int ans = 0;
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      int cnt = 0;
      while (n % i == 0) {
        n /= i;
        cnt++;
      }
      ans += f(cnt);
    }
  }
  if (n != 1)
    ans++;
  cout << ans << '\n';
  return 0;
}

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

using namespace std;

#define intt long long

int f(int n) {
  int ans = 0;
  while (ans * (ans + 1) / 2 <= n) {
    ans++;
  }
  return ans - 1;
}

int main() {

  intt n;
  cin >> n;
  int ans = 0;
  for (int i = 2; 1LL * i * i <= n; i++) {
    if (n % i == 0) {
      int cnt = 0;
      while (n % i == 0) {
        n /= i;
        cnt++;
      }
      ans += f(cnt);
    }
  }
  if (n != 1)
    ans++;
  cout << ans << '\n';
  return 0;
}
Problem p02660 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

typedef long long int ll;
const ll N_MAX = 1E+12;
const int E_MAX = 50;
vector<int> num;

int main() {
  ll n;
  cin >> n;
  ll ans = 0;
  num.resize(E_MAX);
  num[0] = 0;
  for (int i = 1; i < E_MAX; i++) {
    num[i] = num[i - 1] + i;
  }
  for (int i = 2; i * i <= n; i++) {
    if (i * i > n)
      break;
    ll e = 0;
    while (n % i == 0) {
      n /= i;
      e++;
    }
    vector<int>::iterator it = lower_bound(num.begin(), num.end(), e);
    int pa = it - num.begin();
    if (*it != e)
      pa--;
    ans += pa;
  }
  if (n > 1)
    ans++;
  cout << ans << endl;
  return 0;
}

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

typedef long long int ll;
const ll N_MAX = 1E+12;
const int E_MAX = 50;
vector<int> num;

int main() {
  ll n;
  cin >> n;
  ll ans = 0;
  num.resize(E_MAX);
  num[0] = 0;
  for (int i = 1; i < E_MAX; i++) {
    num[i] = num[i - 1] + i;
  }
  for (ll i = 2; i * i <= n; i++) {
    if (i * i > n)
      break;
    ll e = 0;
    while (n % i == 0) {
      n /= i;
      e++;
    }
    vector<int>::iterator it = lower_bound(num.begin(), num.end(), e);
    int pa = it - num.begin();
    if (*it != e)
      pa--;
    ans += pa;
  }
  if (n > 1)
    ans++;
  cout << ans << endl;
  return 0;
}
Problem p02660 (C++)

Buggy submission (status: Time Limit Exceeded):

#include <iostream>
#include <map>
#include <queue>
#include <tuple>
#include <vector>
using namespace std;

// const int MYINTMAX=2147483647;

void decompose(long num, map<long, int> &data) {
  long a = 2;
  long tmp = num;
  // long maxv = num*num;
  // while(num >= a && a*a <= tmp){
  vector<char> v(1000000000000, 0);
  while (tmp >= a) {
    // cout << a << " " << tmp << endl;
    if (tmp % a == 0) {
      data[a] = data[a] + 1;
      tmp /= a;
    } else {
      a++;
    }
  }
}

int main() {

  long N;
  cin >> N;

  long tmp = N;
  long n = 0;
  for (long i = 2; i <= tmp; i++) {
    int kosuu = 0;
    while (tmp % i == 0) {
      tmp = tmp / i;
      kosuu++;
    }
    // cout << tmp << endl;
    int j = 1;
    while (kosuu >= j) {
      kosuu -= j;
      j++;
      n++;
    }

    if (tmp == 1)
      break;
  }

  cout << n << endl;

  return 0;
}


Fixed submission:

#include <iostream>
#include <map>
#include <queue>
#include <tuple>
#include <vector>
using namespace std;

// const int MYINTMAX=2147483647;

void decompose(long num, map<long, int> &data) {
  long a = 2;
  long tmp = num;
  // long maxv = num*num;
  // while(num >= a && a*a <= tmp){
  vector<char> v(1000000000000, 0);
  while (tmp >= a) {
    // cout << a << " " << tmp << endl;
    if (tmp % a == 0) {
      data[a] = data[a] + 1;
      tmp /= a;
    } else {
      a++;
    }
  }
}

int main() {

  long N;
  cin >> N;

  long tmp = N;
  long n = 0;
  for (long i = 2; i <= tmp; i++) {
    int kosuu = 0;
    while (tmp % i == 0) {
      tmp = tmp / i;
      kosuu++;
    }
    // cout << tmp << endl;
    int j = 1;
    while (kosuu >= j) {
      kosuu -= j;
      j++;
      n++;
    }

    if (tmp == 1)
      break;
    if (i > 1000000) {
      cout << n + 1 << endl;
      return 0;
    }
  }

  cout << n << endl;

  return 0;
}
Problem p02660 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
#define pii pair<int, int>
#define fst first
#define snd second
#define pub push_back
#define vi vector<int>
#define ll long long

using namespace std;

int main() {
  ios ::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, res = 0;
  cin >> n;
  for (int i = 2; i * i <= n; i++) {
    ll to = 0;
    while (n % i == 0) {
      to++;
      n /= i;
    }
    if (to) {
      int val = sqrt(2 * to);
      if (val * (val + 1) > 2 * to) {
        val--;
      }
      res += val;
    }
  }
  if (n > 1) {
    res++;
  }
  cout << res << "\n";
  return 0;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
#define pii pair<int, int>
#define fst first
#define snd second
#define pub push_back
#define vi vector<int>
#define ll long long

using namespace std;

int main() {
  ios ::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, res = 0;
  cin >> n;
  for (long long i = 2; i * i <= n; i++) {
    ll to = 0;
    while (n % i == 0) {
      to++;
      n /= i;
    }
    if (to) {
      int val = sqrt(2 * to);
      if (val * (val + 1) > 2 * to) {
        val--;
      }
      res += val;
    }
  }
  if (n > 1) {
    res++;
  }
  cout << res << "\n";
  return 0;
}
Problem p02660 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YN(x) cout << (bool x ? "Yes" : "No") << endl;
#define out(s) cout << s << endl;
#define pb push_back;
#define sp " ";
#define INF 10000000000
void vout(vector<int> v) {
  for (int i = 0; i < v.size(); i++)
    cout << v.at(i) << endl;
}
int main() {
  lli n;
  cin >> n;
  lli nc = n;
  map<lli, lli> prime;
  lli i = 2;
  lli ans = 0;
  while (nc != 1) {
    if (nc % i == 0) {
      lli count = 0;
      while (nc % i == 0) {
        nc /= i;
        count++;
      }
      prime[i] = count;
    }
    i++;
  }
  for (auto v : prime) {
    lli count = 1, now = 0;
    lli per = 0;
    while (v.second > now) {
      now += count;
      per++;
      count++;
      if (v.second < now) {
        per -= 1;
      }
    }
    ans += per;
  }
  out(ans);
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YN(x) cout << (bool x ? "Yes" : "No") << endl;
#define out(s) cout << s << endl;
#define pb push_back;
#define sp " ";
#define INF 10000000000
void vout(vector<int> v) {
  for (int i = 0; i < v.size(); i++)
    cout << v.at(i) << endl;
}
int main() {
  lli n;
  cin >> n;
  lli nc = n;
  map<lli, lli> prime;
  lli i = 2;
  lli ans = 0;
  while (nc != 1) {
    if (i * i > n) {
      prime[n] = 1;
      break;
    }
    if (nc % i == 0) {
      lli count = 0;
      while (nc % i == 0) {
        nc /= i;
        count++;
      }
      prime[i] = count;
    }
    i++;
  }
  for (auto v : prime) {
    lli count = 1, now = 0;
    lli per = 0;
    while (v.second > now) {
      now += count;
      per++;
      count++;
      if (v.second < now) {
        per -= 1;
      }
    }
    ans += per;
  }
  out(ans);
}
Problem p02660 (C++)

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

bool is_prime(int n) {
  int x = 1;
  if (n < 2)
    return false;
  else if (n % 2 == 0)
    x = 2;
  else {
    double m = sqrt(n);
    bool f = false;
    for (int i = 3; i <= m; i += 2) {
      if (n % i == 0) {
        x = i;
        f = true;
        break;
      }
    }
    if (!f)
      return true;
  }

  int t = n;
  for (size_t i = 0; i < 100; i++) {
    if (t % x != 0) {
      return false;
    }
    t /= x;
    if (t == 1) {
      return true;
    }
  }
}

int main() {
  int64_t N;
  cin >> N;
  int64_t a = 0, b = 0, c = 0, x, y, z;
  int64_t m = N;
  double r = sqrt(N);
  for (int i = 2; i <= m; i++) {
    if (!is_prime(i)) {
      continue;
    }
    if (N % i == 0) {
      a++;
      N /= i;
      m /= i;
    }
    // std::cout << "test " << i << " N " << N << '\n';
    if (N <= i) {
      break;
    } else if (a == 0 && i > r) {
      a++;
      break;
    }
  }
  // if (m<N && is_prime(N)) a++;
  std::cout << a << '\n';
}


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

bool is_prime(int n) {
  int x = 1;
  if (n < 2)
    return false;
  else if (n % 2 == 0)
    x = 2;
  else {
    double m = sqrt(n);
    bool f = false;
    for (int i = 3; i <= m; i += 2) {
      if (n % i == 0) {
        x = i;
        f = true;
        break;
      }
    }
    if (!f)
      return true;
  }

  int t = n;
  for (size_t i = 0; i < 100; i++) {
    if (t % x != 0) {
      return false;
    }
    t /= x;
    if (t == 1) {
      return true;
    }
  }
}

int main() {
  int64_t N;
  cin >> N;
  int64_t a = 0, b = 0, c = 0, x, y, z;
  int64_t m = N;
  double r = sqrt(N);
  for (int i = 2; i <= m; i++) {
    if (!is_prime(i)) {
      continue;
    }
    if (N % i == 0) {
      a++;
      N /= i;
      m /= i;
    }
    // std::cout << "test " << i << " N " << N << '\n';
    if (N <= i) {
      break;
    } else if (i > 5000000) {
      a++;
      break;
    }
  }
  // if (m<N && is_prime(N)) a++;
  std::cout << a << '\n';
}