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

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define all(i) i.begin(), i.end()
template <class T, class U> bool cmax(T &a, U b) {
  if (a < b) {
    a = b;
    return true;
  } else
    return false;
}
template <class T, class U> bool cmin(T &a, U b) {
  if (a > b) {
    a = b;
    return true;
  } else
    return false;
}

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

  ll a, b;
  cin >> a >> b;
  ll g = __gcd(a, b);

  ll ans = 1;
  for (int i = 2; i * i < g; i++) {
    if (g % i == 0) {
      ans++;
      while (g % i == 0) {
        g /= i;
      }
    }
  }
  if (g != 1)
    ans++;

  cout << ans << endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define all(i) i.begin(), i.end()
template <class T, class U> bool cmax(T &a, U b) {
  if (a < b) {
    a = b;
    return true;
  } else
    return false;
}
template <class T, class U> bool cmin(T &a, U b) {
  if (a > b) {
    a = b;
    return true;
  } else
    return false;
}

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

  ll a, b;
  cin >> a >> b;
  ll g = __gcd(a, b);

  int ans = 1;
  for (ll i = 2; i * i < g; i++) {
    if (g % i == 0) {
      ans++;
      while (g % i == 0) {
        g /= i;
      }
    }
  }
  if (g != 1)
    ans++;

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

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define all(i) i.begin(), i.end()
template <class T, class U> bool cmax(T &a, U b) {
  if (a < b) {
    a = b;
    return true;
  } else
    return false;
}
template <class T, class U> bool cmin(T &a, U b) {
  if (a > b) {
    a = b;
    return true;
  } else
    return false;
}

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

  ll a, b;
  cin >> a >> b;
  ll g = __gcd(a, b);
  cerr << g << endl;

  ll ans = 1;
  for (int i = 2; i * i < g; i++) {
    if (g % i == 0) {
      ans++;
      while (g % i == 0) {
        g /= i;
      }
    }
  }
  if (g != 1)
    ans++;

  cout << ans << endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define all(i) i.begin(), i.end()
template <class T, class U> bool cmax(T &a, U b) {
  if (a < b) {
    a = b;
    return true;
  } else
    return false;
}
template <class T, class U> bool cmin(T &a, U b) {
  if (a > b) {
    a = b;
    return true;
  } else
    return false;
}

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

  ll a, b;
  cin >> a >> b;
  ll g = __gcd(a, b);
  cerr << g << endl;

  ll ans = 1;
  for (ll i = 2; i * i < g; i++) {
    if (g % i == 0) {
      ans++;
      while (g % i == 0) {
        g /= i;
      }
    }
  }
  if (g != 1)
    ans++;

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

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

int64_t gcd(int64_t A, int64_t B) {
  if (B == 0) {
    return A;
  }
  return gcd(B, A % B);
}

map<int64_t, int> prime_list(int64_t n) {
  map<int64_t, int> ans;
  for (int i = 2; i * i <= n; ++i) {
    while (n % i == 0) {
      ++ans[i];
      n = n / i;
    }
  }
  if (n != 1) {
    ++ans[n];
  }
  return ans;
}

int main() {
  int64_t A, B;
  cin >> A >> B;
  int64_t G = gcd(A, B);
  cout << prime_list(G).size() + 1 << endl;
}

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

int64_t gcd(int64_t A, int64_t B) {
  if (B == 0) {
    return A;
  }
  return gcd(B, A % B);
}

map<int64_t, int> prime_list(int64_t n) {
  map<int64_t, int> ans;
  for (int64_t i = 2; i * i <= n; ++i) {
    while (n % i == 0) {
      ++ans[i];
      n = n / i;
    }
  }
  if (n != 1) {
    ++ans[n];
  }
  return ans;
}

int main() {
  int64_t A, B;
  cin >> A >> B;
  int64_t G = gcd(A, B);
  cout << prime_list(G).size() + 1 << endl;
}
Problem p02900 (C++)

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

int main() {
  long long a, b, r, tmp;
  cin >> a >> b;
  if (a < b) {
    tmp = a;
    a = b;
    b = tmp;
  }
  r = a % b;
  while (r != 0) {
    a = b;
    b = r;
    r = a % b;
  }
  int ans = 1;
  for (int i = 2; i * i <= b; i++) {
    if (b % i == 0) {
      ans++;
      while (b % i == 0) {
        b /= i;
      }
    }
  }
  if (b != 1) {
    ans++;
  }
  cout << ans << endl;
}

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

int main() {
  long long a, b, r, tmp;
  cin >> a >> b;
  if (a < b) {
    tmp = a;
    a = b;
    b = tmp;
  }
  r = a % b;
  while (r != 0) {
    a = b;
    b = r;
    r = a % b;
  }
  long long ans = 1;
  for (long long i = 2; i * i <= b; i++) {
    if (b % i == 0) {
      ans++;
      while (b % i == 0) {
        b /= i;
      }
    }
  }
  if (b != 1) {
    ans++;
  }
  cout << ans << endl;
}
Problem p02900 (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;
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);
  // ABC142D - Disjoint Set of Common Divisors
  // 最大公約数を求めて素因数分解を行い、素因数が何種類あるか求める
  ll A, B;
  cin >> A >> B;
  ll g = __gcd(A, B);

  ll ans = 1;
  if (g % 2 == 0)
    ans++;
  while (g % 2 == 0) { // 素数2だけで分解する
    g /= 2;
  }
  for (int i = 3; i * i <= g; i = i + 2) {
    if (g % i == 0)
      ans++;
    while (g % i == 0) {
      g /= i;
    }
  }
  if (g > 2)
    ans++; // 割り切れなかった素数
  cout << ans << 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);
  // ABC142D - Disjoint Set of Common Divisors
  // 最大公約数を求めて素因数分解を行い、素因数が何種類あるか求める
  ll A, B;
  cin >> A >> B;
  ll g = __gcd(A, B);

  ll ans = 1;
  if (g % 2 == 0)
    ans++;
  while (g % 2 == 0) { // 素数2だけで分解する
    g /= 2;
  }
  for (ll i = 3; i * i <= g; i += 2) { // long long
    if (g % i == 0)
      ans++;
    while (g % i == 0) {
      g /= i;
    }
  }
  if (g > 2)
    ans++; // 割り切れなかった素数
  cout << ans << endl;
}
Problem p02900 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class U> U lcm(U m, U n) {
  if ((0 == m) || (0 == n))
    return 0;
  return ((m / gcd(m, n)) * n);
}
template <typename T> auto divisors(T n) {
  vector<T> v;
  for (int i = 1; i * i <= n; i++) {
    if (n % i)
      continue;
    v.push_back(i);
    if (i != 1 and i * i != n)
      v.push_back(n / i);
  }
  // input : 6 ->  1 2 3 6
  // input : 1 -> 1
  // input : 2 -> 2
  if (n != 1)
    v.push_back(n);
  sort(v.begin(), v.end());
  return v;
}
template <typename T> auto isPrime(const T num) {
  if (num == 1)
    return true;
  for (T i = 2; i * i <= num; ++i)
    if (num % i == 0)
      return false;
  return true;
}
int main() {
  long long A, B;
  cin >> A >> B;
  long long gd = gcd(A, B);
  auto v = divisors(gd);
  long long ans = 0;
  for (auto e : v)
    ans += isPrime(e);
  cout << ans << endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class U> U lcm(U m, U n) {
  if ((0 == m) || (0 == n))
    return 0;
  return ((m / gcd(m, n)) * n);
}
template <typename T> auto divisors(T n) {
  vector<T> v;
  for (T i = 1; i * i <= n; i++) {
    if (n % i)
      continue;
    v.push_back(i);
    if (i != 1 and i * i != n)
      v.push_back(n / i);
  }
  // input : 6 ->  1 2 3 6
  // input : 1 -> 1
  // input : 2 -> 2
  if (n != 1)
    v.push_back(n);
  sort(v.begin(), v.end());
  return v;
}
template <typename T> auto isPrime(const T num) {
  if (num == 1)
    return true;
  for (T i = 2; i * i <= num; ++i)
    if (num % i == 0)
      return false;
  return true;
}
int main() {
  long long A, B;
  cin >> A >> B;
  long long gd = gcd(A, B);
  auto v = divisors(gd);
  long long ans = 0;
  for (auto e : v)
    ans += isPrime(e);
  cout << ans << endl;
}
Problem p02900 (C++)

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

typedef long long ll;
const int Maxn = 1e6;

ll GCD(ll x, ll y) {
  if (y == 0)
    return x;
  return GCD(y, x % y);
}

int main() {
#ifdef LOACL
  freopen("in.txt", "r", stdin);
  freopen("out.txt", "w", stdout);
#endif
  ll x, y;
  scanf("%lld %lld", &x, &y);
  int cnt = 1;
  ll g = GCD(x, y);
  for (int i = 2; i * i <= g; i++) {
    if (g % i == 0)
      cnt++;
    while (g % i == 0)
      g /= i;
  }
  if (g > 1)
    cnt++;
  printf("%d\n", cnt);
  return 0;
}

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

typedef long long ll;
const int Maxn = 1e6;

ll GCD(ll x, ll y) {
  if (y == 0)
    return x;
  return GCD(y, x % y);
}

int main() {
#ifdef LOACL
  freopen("in.txt", "r", stdin);
  freopen("out.txt", "w", stdout);
#endif
  ll x, y;
  scanf("%lld %lld", &x, &y);
  int cnt = 1;
  ll g = GCD(x, y);
  for (ll i = 2; i * i <= g; i++) {
    if (g % i == 0)
      cnt++;
    while (g % i == 0)
      g /= i;
  }
  if (g > 1)
    cnt++;
  printf("%d\n", cnt);
  return 0;
}
Problem p02900 (C++)

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

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

long long prime_factor(long long N) {
  int ans = 1;
  for (int i = 2; i * i <= N; i++) {
    if (N % i == 0)
      ans++;
    while (N % i == 0) {
      N /= i;
    }
  }
  if (N != 1)
    ans++;
  return ans;
}
// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You
// use the default template now. You can remove this line by using your custom
// template)
int main() {
  long long A, B;
  cin >> A >> B;

  long long d = gcd(A, B);
  if (d == 1) {
    cout << 1 << endl;
    return 0;
  }
  long long num = prime_factor(d);
  cout << num << endl;

  return 0;
}


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

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

long long prime_factor(long long N) {
  long long ans = 1;
  for (long long i = 2; i * i <= N; i++) {
    if (N % i != 0)
      continue;
    if (N % i == 0)
      ans++;
    while (N % i == 0) {
      N /= i;
    }
  }
  if (N != 1)
    ans++;
  return ans;
}
// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You
// use the default template now. You can remove this line by using your custom
// template)
int main() {
  long long A, B;
  cin >> A >> B;

  long long d = gcd(A, B);
  if (d == 1) {
    cout << 1 << endl;
    return 0;
  }
  long long num = prime_factor(d);
  cout << num << endl;

  return 0;
}
Problem p02900 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll << 50;
template <typename T> void printv(const vector<T> &s) {
  for (int i = 0; i < (int)(s.size()); ++i) {
    cout << s[i];
    if (i == (int)(s.size()) - 1)
      cout << endl;
    else
      cout << " ";
  }
}
ll gcd(ll a, ll b) { return (b == 0 ? a : gcd(b, a % b)); }
int main() {
  cin.tie(0);
  cout << fixed << setprecision(10);
  ll a, b;
  cin >> a >> b;
  ll g = gcd(a, b);
  int cnt = 0;
  for (int i = 2; i * i <= g; ++i) {
    if (g % i == 0) {
      cnt++;
      while (g % i == 0)
        g /= i;
    }
  }
  if (g != 1)
    cnt++;
  cout << cnt + 1 << endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll << 50;
template <typename T> void printv(const vector<T> &s) {
  for (int i = 0; i < (int)(s.size()); ++i) {
    cout << s[i];
    if (i == (int)(s.size()) - 1)
      cout << endl;
    else
      cout << " ";
  }
}
ll gcd(ll a, ll b) { return (b == 0 ? a : gcd(b, a % b)); }
int main() {
  cin.tie(0);
  cout << fixed << setprecision(10);
  ll a, b;
  cin >> a >> b;
  ll g = gcd(a, b);
  int cnt = 0;
  for (ll i = 2; i * i <= g; ++i) {
    if (g % i == 0) {
      cnt++;
      while (g % i == 0)
        g /= i;
    }
  }
  if (g != 1)
    cnt++;
  cout << cnt + 1 << endl;
}
Problem p02900 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

ll Pow_mod(ll a, ll b, ll p) {
  ll ans = 1;
  a %= p;
  while (b) {
    if (b & 1)
      ans = (ans * a) % p;
    a = (a * a) % p;
    b >>= 1;
  }
  return (ans % p);
}

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

ll gcd__(ll a, ll b) {
  while (b) {
    ll c = a;
    a = b;
    b = c % b;
  }
  return a;
}

ll a, b, gcd_, ans;

int main() {
  scanf("%lld%lld", &a, &b);
  ans = 1;
  gcd_ = gcd__(a, b);
  for (int i = 2; i * i <= gcd_; i++) {
    if (gcd_ % i == 0) {
      while (gcd_ % i == 0)
        gcd_ /= i;
      ans++;
    }
  }
  if (gcd_ > 1)
    ans++;
  printf("%lld\n", ans);
  return 0;
}

Fixed submission:
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

ll Pow_mod(ll a, ll b, ll p) {
  ll ans = 1;
  a %= p;
  while (b) {
    if (b & 1)
      ans = (ans * a) % p;
    a = (a * a) % p;
    b >>= 1;
  }
  return (ans % p);
}

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

ll gcd__(ll a, ll b) {
  while (b) {
    ll c = a;
    a = b;
    b = c % b;
  }
  return a;
}

ll a, b, gcd_, ans;

int main() {
  scanf("%lld%lld", &a, &b);
  ans = 1;
  gcd_ = gcd__(a, b);
  for (ll i = 2; i * i <= gcd_; i++) {
    if (gcd_ % i == 0) {
      while (gcd_ % i == 0)
        gcd_ /= i;
      ans++;
    }
  }
  if (gcd_ > 1)
    ans++;
  printf("%lld\n", ans);
  return 0;
}
Problem p02900 (C++)

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

using ll = long long;

#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg, x.ed
const ll mod = 1e9 + 7;

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

int get_prime_cnts(ll a) {
  int cnt = 0;
  for (int i = 2; i * i <= a; ++i) {
    if (a % i == 0) {
      ++cnt;
      while (a % i == 0)
        a /= i;
    }
  }
  if (a != 1)
    ++cnt;
  return cnt;
}

int main() {
  ll a, b;
  cin >> a >> b;
  ll g = gcd(a, b);
  int cnt = get_prime_cnts(g) + 1;
  cout << cnt << endl;
  return 0;
}

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

using ll = long long;

#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg, x.ed
const ll mod = 1e9 + 7;

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

int get_prime_cnts(ll a) {
  int cnt = 0;
  for (ll i = 2; i * i <= a; ++i) {
    if (a % i == 0) {
      ++cnt;
      while (a % i == 0)
        a /= i;
    }
  }
  if (a != 1)
    ++cnt;
  return cnt;
}

int main() {
  ll a, b;
  cin >> a >> b;
  ll g = gcd(a, b);
  int cnt = get_prime_cnts(g) + 1;
  cout << cnt << endl;
  return 0;
}
Problem p02900 (C++)

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

using namespace std;

// 最大公約数のll版
ll gcd(ll a, ll b) {
  if (a < b)
    swap(a, b);
  return b == 0 ? a : gcd(b, a % b);
}

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

  ll n = gcd(A, B);

  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      cnt++;
    }
    while (n % i == 0) {
      n /= i;
    }
  }
  if (n != 1)
    cnt++;

  cout << cnt + 1 << endl;

  return 0;
}

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

using namespace std;

// 最大公約数のll版
ll gcd(ll a, ll b) {
  if (a < b)
    swap(a, b);
  return b == 0 ? a : gcd(b, a % b);
}

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

  ll n = gcd(A, B);

  for (ll i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      cnt++;
    }
    while (n % i == 0) {
      n /= i;
    }
  }
  if (n != 1)
    cnt++;

  cout << cnt + 1 << endl;

  return 0;
}
Problem p02900 (C++)

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

using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define all(a) (a).begin(), (a).end()

template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

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

const ll INF = 1LL << 60;

int main() {
  ll a, b;
  cin >> a >> b;
  ll g = gcd(a, b);

  int ans = 1;
  for (int i = 2; i * i <= g; i++) {
    if (g % i == 0) {
      ans++;
      while (g % i == 0)
        g /= i;
    }
  }
  if (g != 1)
    ans++;
  std::cout << ans << '\n';
}


Fixed submission:
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define all(a) (a).begin(), (a).end()

template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

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

const ll INF = 1LL << 60;

int main() {
  ll a, b;
  cin >> a >> b;
  ll g = gcd(a, b);

  int ans = 1;
  for (ll i = 2; i * i <= g; i++) {
    if (g % i == 0) {
      ans++;
      while (g % i == 0)
        g /= i;
    }
  }
  if (g != 1)
    ans++;
  std::cout << ans << '\n';
}
Problem p02900 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define rep(i, s, t) for (ll i = s; i < t; i++)
typedef long long ll;
typedef pair<ll, ll> P;
const int max_n = 1e5;
const ll mod = 1e9 + 7;
map<ll, ll> prime_factor(ll n) {
  map<ll, ll> ma;
  rep(i, 2, n + 1) {
    while (n % i == 0) {
      ma[i]++;
      n /= i;
    }
  }
  if (n != 1)
    ma[n] = 1;
  return ma;
}
int main() {
  ll a, b;
  cin >> a >> b;
  map<ll, ll> ma1 = prime_factor(a);
  map<ll, ll> ma2 = prime_factor(b);

  ll cnt = 1;
  for (auto ite = begin(ma1); ite != end(ma1); ite++) {
    if (ma2.count(ite->fi))
      cnt++;
  }
  cout << cnt << endl;
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define rep(i, s, t) for (ll i = s; i * i <= t; i++)
typedef long long ll;
typedef pair<ll, ll> P;
const int max_n = 1e5;
const ll mod = 1e9 + 7;
map<ll, ll> prime_factor(ll n) {
  map<ll, ll> ma;
  rep(i, 2, n + 1) {
    while (n % i == 0) {
      ma[i]++;
      n /= i;
    }
  }
  if (n != 1)
    ma[n] = 1;
  return ma;
}
int main() {
  ll a, b;
  cin >> a >> b;
  map<ll, ll> ma1 = prime_factor(a);
  map<ll, ll> ma2 = prime_factor(b);

  ll cnt = 1;
  for (auto ite = begin(ma1); ite != end(ma1); ite++) {
    if (ma2.count(ite->fi))
      cnt++;
  }
  cout << cnt << endl;
  return 0;
}
Problem p02900 (C++)

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

ll gcd(ll a, ll b) {
  if (b == 0) {
    return a;
  } else {
    return gcd(b, (a % b));
  }
}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll mpower(ll a, ll b, ll c) {
  int z;
  if (b == 0) {
    z = 1;
    z %= c;
    return z;
  }
  if (b == 1) {
    z = a;
    z %= c;
    return z;
  } else {
    return (((mpower(a, b / 2, c)) * (mpower(a, b / 2, c)) % c) *
            mpower(a, b % 2, c) % c);
  }
}
bool IsPrime(ll num) {
  if (num < 2)
    return false;
  else if (num == 2)
    return true;
  else if (num % 2 == 0)
    return false;
  double sqrtNum = sqrt(num);
  for (ll i = 3; i <= sqrtNum; i += 2) {
    if (num % i == 0) {
      return false;
    }
  }
  return true;
}

int main() {
  ll a, b;
  cin >> a >> b;
  ll c = gcd(a, b);
  if (c == 1) {
    cout << 1 << endl;
    return 0;
  }
  int ans = 1;
  if (c % 2 == 0) {
    ans++;
    while (c % 2 == 0) {
      c /= 2;
    }
  }
  for (int i = 0; i < 200; i++) {
    for (ll j = 3; j * j <= c; j += 2) {
      if (IsPrime(j) == true && c % j == 0) {
        ans++;
        while (c % j == 0) {
          c /= j;
        }
      }
    }
  }
  if (c > 1) {
    ans++;
  }
  cout << ans << endl;
}

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

ll gcd(ll a, ll b) {
  if (b == 0) {
    return a;
  } else {
    return gcd(b, (a % b));
  }
}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll mpower(ll a, ll b, ll c) {
  int z;
  if (b == 0) {
    z = 1;
    z %= c;
    return z;
  }
  if (b == 1) {
    z = a;
    z %= c;
    return z;
  } else {
    return (((mpower(a, b / 2, c)) * (mpower(a, b / 2, c)) % c) *
            mpower(a, b % 2, c) % c);
  }
}
bool IsPrime(ll num) {
  if (num < 2)
    return false;
  else if (num == 2)
    return true;
  else if (num % 2 == 0)
    return false;
  double sqrtNum = sqrt(num);
  for (ll i = 3; i <= sqrtNum; i += 2) {
    if (num % i == 0) {
      return false;
    }
  }
  return true;
}

int main() {
  ll a, b;
  cin >> a >> b;
  ll c = gcd(a, b);
  if (c == 1) {
    cout << 1 << endl;
    return 0;
  }
  int ans = 1;
  if (c % 2 == 0) {
    ans++;
    while (c % 2 == 0) {
      c /= 2;
    }
  }
  for (int i = 0; i < 20; i++) {
    for (ll j = 3; j * j <= c; j += 2) {
      if (IsPrime(j) == true && c % j == 0) {
        ans++;
        while (c % j == 0) {
          c /= j;
        }
      }
    }
  }
  if (c > 1) {
    ans++;
  }
  cout << ans << endl;
}
Problem p02900 (C++)

Buggy submission (status: Runtime Error):
/*   ꧁༒☬महाकाल☬༒꧂ ꧁༒ঔमहाकालঔ༒꧂

                   ঔৣ۝महाकालᴳᵒᵈ۝ঔৣ

 */
#include <bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// template <typename T, typename cmp=less<T>> using oset =tree<T, null_type,
// cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define ll long long
#define mod 1000000007
#define inf 100000000000000000
#define fast                                                                   \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cout.tie(NULL);
#define _it iterator
#define all(_x) _x.begin(), _x.end()
#define f first
#define s second
#define pb push_back
void mahakal() {
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  freopen("error.txt", "w", stderr);
#endif
}
map<ll, ll> mp;

void factor(ll n) {
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      mp[i]++;
      n = n / i;
    }
  }
  if (n != 1)
    mp[n] = 1;
}

int main() {
  mahakal(), fast;

  ll a, b;
  cin >> a >> b;
  ll g = __gcd(a, b);
  factor(g);
  ll ans = mp.size();
  cout << ans + 1 << endl;

  return 0;
}

Fixed submission:
/*   ꧁༒☬महाकाल☬༒꧂ ꧁༒ঔमहाकालঔ༒꧂

                   ঔৣ۝महाकालᴳᵒᵈ۝ঔৣ

 */
#include <bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// template <typename T, typename cmp=less<T>> using oset =tree<T, null_type,
// cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define ll long long
#define mod 1000000007
#define inf 100000000000000000
#define fast                                                                   \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cout.tie(NULL);
#define _it iterator
#define all(_x) _x.begin(), _x.end()
#define f first
#define s second
#define pb push_back
void mahakal() {
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  freopen("error.txt", "w", stderr);
#endif
}
map<ll, ll> mp;

void factor(ll n) {
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      mp[i]++;
      n = n / i;
    }
  }
  if (n != 1)
    mp[n] = 1;
}

int main() {
  // mahakal(),fast;

  ll a, b;
  cin >> a >> b;
  ll g = __gcd(a, b);
  factor(g);
  ll ans = mp.size();
  cout << ans + 1 << endl;

  return 0;
}
Problem p02900 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define all(i) i.begin(), i.end()
template <class T, class U> bool cmax(T &a, U b) {
  if (a < b) {
    a = b;
    return true;
  } else
    return false;
}
template <class T, class U> bool cmin(T &a, U b) {
  if (a > b) {
    a = b;
    return true;
  } else
    return false;
}

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

  ll a, b;
  cin >> a >> b;
  ll g = __gcd(a, b);
  cerr << g << endl;

  ll ans = 1;
  for (unsigned int i = 2; i * i < g; i++) {
    if (g % i == 0) {
      ans++;
      while (g % i == 0) {
        g /= i;
      }
    }
  }
  if (g != 1)
    ans++;

  cout << ans << endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define all(i) i.begin(), i.end()
template <class T, class U> bool cmax(T &a, U b) {
  if (a < b) {
    a = b;
    return true;
  } else
    return false;
}
template <class T, class U> bool cmin(T &a, U b) {
  if (a > b) {
    a = b;
    return true;
  } else
    return false;
}

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

  ll a, b;
  cin >> a >> b;
  ll g = __gcd(a, b);
  cerr << g << endl;

  ll ans = 1;
  for (ll i = 2; i * i < g; i++) {
    if (g % i == 0) {
      ans++;
      while (g % i == 0) {
        g /= i;
      }
    }
  }
  if (g != 1)
    ans++;

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

Buggy submission (status: Time Limit Exceeded):
//
// Created by Hideaki Imamura on 2020-03-18.
//
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// const ll mod = 1000000007;

ll A, B;

ll gcd(ll a, ll b) {
  if (a < b) {
    a ^= b;
    b ^= a;
    a ^= b;
  }

  return b ? gcd(b, a % b) : a;
}

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

  ll C = gcd(A, B);
  ll res = 1;
  for (int i = 2; i * i <= C; ++i) {
    if (C % i == 0)
      res++;
    while (C % i == 0)
      C /= i;
  }
  if (C != 1)
    res++;
  cout << res << endl;

  return 0;
}

Fixed submission:
//
// Created by Hideaki Imamura on 2020-03-18.
//
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// const ll mod = 1000000007;

ll A, B;

ll gcd(ll a, ll b) {
  if (a < b) {
    a ^= b;
    b ^= a;
    a ^= b;
  }

  return b ? gcd(b, a % b) : a;
}

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

  ll C = gcd(A, B);
  ll res = 1;
  for (ll i = 2; i * i <= C; ++i) {
    if (C % i == 0)
      res++;
    while (C % i == 0)
      C /= i;
  }
  if (C != 1)
    res++;
  cout << res << endl;

  return 0;
}
Problem p02900 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void) {
  ll a, b, GCD, c = 1;
  cin >> a >> b;
  while (a && b) {
    if (a >= b)
      a %= b;
    else
      b %= a;
  }
  GCD = a + b;
  for (int i = 2; i * i <= GCD; i++) {
    if (GCD % i == 0)
      c++;
    while (GCD % i == 0)
      GCD /= i;
  }
  if (GCD != 1)
    c++;
  cout << c << endl;
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void) {
  ll a, b, GCD, c = 1;
  cin >> a >> b;
  while (a && b) {
    if (a >= b)
      a %= b;
    else
      b %= a;
  }
  GCD = a + b;
  for (ll i = 2; i * i <= GCD; i++) {
    if (GCD % i == 0)
      c++;
    while (GCD % i == 0)
      GCD /= i;
  }
  if (GCD != 1)
    c++;
  cout << c << endl;
  return 0;
}
Problem p02900 (C++)

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

ll gcd(ll A, ll B) {
  ll R = A % B;
  if (R == 0) {
    return B;
  } else {
    return gcd(B, R);
  }
}

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

  ll tar = gcd(A, B);

  ll ans = 1, num = 2;
  while (tar != 1) {
    bool div = false;

    while (tar % num == 0) {
      tar /= num;
      div = true;
    }

    if (div == true) {
      ans++;
    }

    num++;
  }

  cout << ans << endl;
}

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

ll gcd(ll A, ll B) {
  ll R = A % B;
  if (R == 0) {
    return B;
  } else {
    return gcd(B, R);
  }
}

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

  ll tar = gcd(A, B);

  ll ans = 1, num = 2;
  while (tar != 1) {
    bool div = false;

    if (num > 1000000) {
      ans++;
      break;
    }

    while (tar % num == 0) {
      tar /= num;
      div = true;
    }

    if (div == true) {
      ans++;
    }

    num++;
  }

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

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <queue>
#include <stdio.h>
#include <string>
#include <vector>

using namespace std;

#define rep(i, x) for (int i = 0; i < x; i++)
#define SORT(x) sort(x.begin(), x.end())
#define FIND(x, target) find(x.begin(), x.end(), target)
#define pb(x) push_back(x)
#define pob(x) pop_back(x)
#define output(x) cout << x << endl
#define ERASE(x, n) x.erase(x.begin() + n)
// #define int long long
// #define P pair<int, int>
typedef long long ll;

const long long int MOD = 1e9 + 7;
const int INF = -1;
ll dp[100005][13];

signed main(void) {
  ll A, B;
  cin >> A >> B;
  if (A < B) {
    ll tmp = A;
    A = B;
    B = tmp;
  }

  ll r = A % B;
  while (r != 0) {
    A = B;
    B = r;
    r = A % B;
  }

  ll ans = 1;
  if (B % 2 == 0) {
    B = B / 2;
    ans++;
    while (B % 2 == 0) {
      B = B / 2;
    }
  }
  ll now = 3;
  while (now <= B) {
    bool isDivided = false;
    while (B % now == 0) {
      isDivided = true;
      B = B / now;
    }
    if (isDivided) {
      ans++;
    }
    now += 2;
  }

  cout << ans << endl;
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <queue>
#include <stdio.h>
#include <string>
#include <vector>

using namespace std;

#define rep(i, x) for (int i = 0; i < x; i++)
#define SORT(x) sort(x.begin(), x.end())
#define FIND(x, target) find(x.begin(), x.end(), target)
#define pb(x) push_back(x)
#define pob(x) pop_back(x)
#define output(x) cout << x << endl
#define ERASE(x, n) x.erase(x.begin() + n)
// #define int long long
// #define P pair<int, int>
typedef long long ll;

const long long int MOD = 1e9 + 7;
const int INF = -1;
ll dp[100005][13];

signed main(void) {
  ll A, B;
  cin >> A >> B;
  if (A < B) {
    ll tmp = A;
    A = B;
    B = tmp;
  }

  ll r = A % B;
  while (r != 0) {
    A = B;
    B = r;
    r = A % B;
  }

  ll ans = 1;
  if (B % 2 == 0) {
    B = B / 2;
    ans++;
    while (B % 2 == 0) {
      B = B / 2;
    }
  }
  ll now = 3;
  while (now <= B) {
    bool isDivided = false;
    while (B % now == 0) {
      isDivided = true;
      B = B / now;
    }
    if (isDivided) {
      ans++;
    }
    now += 2;
    if (now <= B && now >= sqrt(B)) {
      ans++;
      break;
    }
  }

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

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> p;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n) for (int i = 1; i <= (int)(n); i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define srep(i, from, to) for (int i = from; i < (int)(to); i++)
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}

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

int main() {
  ll a, b;
  cin >> a >> b;
  ll g = gcd(a, b);

  int ans = 1;
  for (int x = 2; x * x <= g; x++) {
    if (g == 1)
      break;
    bool counted = false;
    while (g % x == 0) {
      g /= x;
      if (!counted) {
        ans++;
        counted = true;
      }
    }
  }
  if (g > 1)
    ans++;
  cout << ans << endl;

  return 0;
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> p;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n) for (int i = 1; i <= (int)(n); i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define srep(i, from, to) for (int i = from; i < (int)(to); i++)
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}

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

int main() {
  ll a, b;
  cin >> a >> b;
  ll g = gcd(a, b);

  int ans = 1;
  for (ll x = 2; x * x <= g; x++) {
    if (g == 1)
      break;
    bool counted = false;
    while (g % x == 0) {
      g /= x;
      if (!counted) {
        ans++;
        counted = true;
      }
    }
  }
  if (g > 1)
    ans++;
  cout << ans << endl;

  return 0;
}
Problem p02900 (C++)

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

using namespace std;

#define ll long long

ll gcd(ll a, ll b) {
  if (a < b)
    swap(a, b);

  ll r = a % b;
  if (r == 0)
    return b;
  else
    return gcd(b, r);
}

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

  ll g = gcd(a, b);

  ll count = 1;
  ll h = g;
  for (int i = 2; i * i <= h; i++) {
    if (g % i != 0)
      continue;
    count++;
    while (g % i == 0) {
      g /= i;
    }
    if (g == 1)
      break;
  }
  if (g != 1)
    count++;

  cout << count << '\n';

  return 0;
}

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

using namespace std;

#define ll long long

ll gcd(ll a, ll b) {
  if (a < b)
    swap(a, b);

  ll r = a % b;
  if (r == 0)
    return b;
  else
    return gcd(b, r);
}

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

  ll g = gcd(a, b);

  ll count = 1;
  ll h = g;
  for (ll i = 2; i * i <= h; i++) {
    if (g % i != 0)
      continue;
    count++;
    while (g % i == 0) {
      g /= i;
    }
    if (g == 1)
      break;
  }
  if (g != 1)
    count++;

  cout << count << '\n';

  return 0;
}
Problem p02900 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <vector>

using namespace std;

typedef pair<int, int> P;
typedef long long ll;

ll mod = 1e9 + 7;

int main() {

  ll a, b;
  cin >> a >> b;

  ll p = __gcd(a, b);

  int ans = 1;

  for (int i = 2; i * i <= p; i++) {
    if (p % i == 0) {
      ans++;
      while (p % i == 0) {
        p /= i;
      }
    }
  }
  if (p > 1)
    ans++;

  cout << ans << endl;

  return 0;
}


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

using namespace std;

typedef pair<int, int> P;
typedef long long ll;

ll mod = 1e9 + 7;

int main() {

  ll a, b;
  cin >> a >> b;

  ll p = __gcd(a, b);

  int ans = 1;

  for (int i = 2; (ll)i * i <= p; i++) {
    if (p % i == 0) {
      ans++;
      while (p % i == 0) {
        p /= i;
      }
    }
  }
  if (p > 1)
    ans++;

  cout << ans << endl;

  return 0;
}
Problem p02900 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
ll gcd(ll a, ll b) {
  while (b != 0) {
    ll t = a % b;
    a = b;
    b = t;
  }
  return (a);
}
int main() {
  ll a, b, GCD;
  cin >> a >> b;
  GCD = __gcd(a, b);
  vector<ll> num;
  for (int i = 1; i * i <= GCD; i++) {
    if (GCD % i == 0)
      if (GCD / i == i)
        num.push_back(i);
      else
        num.push_back(GCD / i), num.push_back(i);
  }
  sort(num.begin(), num.end(), greater<ll>());
  ll i = 0, pd = 0;
  while (i < num.size()) {
    ll j = i + 1;
    while (j < num.size()) {
      if (gcd(num[i], num[j]) != 1) {
        num.erase(num.begin() + i);
        pd = 1;
      }
      j++;
    }
    i++;
    if (pd == 1) {
      pd = 0;
      i--;
    }
  }
  cout << num.size();
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
ll gcd(ll a, ll b) {
  while (b != 0) {
    ll t = a % b;
    a = b;
    b = t;
  }
  return (a);
}
int main() {
  ll a, b, GCD;
  cin >> a >> b;
  GCD = __gcd(a, b);
  vector<ll> num;
  for (int i = 1; i <= sqrt(GCD); i++) {
    if (GCD % i == 0)
      if (GCD / i == i)
        num.push_back(i);
      else
        num.push_back(GCD / i), num.push_back(i);
  }
  sort(num.begin(), num.end(), greater<ll>());
  ll i = 0, pd = 0;
  while (i < num.size()) {
    ll j = i + 1;
    while (j < num.size()) {
      if (gcd(num[i], num[j]) != 1) {
        num.erase(num.begin() + i);
        pd = 1;
      }
      j++;
    }
    i++;
    if (pd == 1) {
      pd = 0;
      i--;
    }
  }
  cout << num.size();
  return 0;
}
Problem p02900 (C++)

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

int main() {

  long long a, b, c = 1ll;
  scanf("%lld %lld", &a, &b);

  if (a > b)
    swap(a, b);
  long long d = b;
  for (int i = 2; i * i <= b; i += (i == 2 ? 1 : 2)) {
    if (d % i == 0) {
      while (d % i == 0) {
        d /= i;
      }
      if (a % i == 0)
        c++;
    }
  }
  if (d != 1 && a % d == 0)
    c++;

  printf("%lld\n", c);
}

/*
128+4+1 -> 10000101
10110110
0.25+0.0625 = 0.3125
11.001001 (0.125)
128+32+8+4 -> 10101100
*/

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

int main() {

  long long a, b, c = 1ll;
  scanf("%lld %lld", &a, &b);

  if (a > b)
    swap(a, b);
  long long d = b;
  for (long long i = 2; i * i <= b; i += (i == 2 ? 1 : 2)) {
    if (d % i == 0) {
      while (d % i == 0) {
        d /= i;
      }
      if (a % i == 0)
        c++;
    }
  }
  if (d != 1 && a % d == 0)
    c++;

  printf("%lld\n", c);
}

/*
128+4+1 -> 10000101
10110110
0.25+0.0625 = 0.3125
11.001001 (0.125)
128+32+8+4 -> 10101100
*/
Problem p02900 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> l_l;
const int INF = 1001001000;
const int mINF = -1001001000;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll common(ll x) {
  ll res = 1;
  for (int i = 2; i * i <= x; i++) {
    if (x % i)
      continue;
    while (x % i == 0) {
      x /= i;
    }
    res++;
  }
  if (x != 1)
    res++;
  return res;
}
int main() {
  ll A, B;
  cin >> A >> B;
  ll ab = gcd(A, B);
  ll ans = common(ab);
  cout << ans << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> l_l;
const int INF = 1001001000;
const int mINF = -1001001000;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll common(ll x) {
  ll res = 1;
  for (ll i = 2; i * i <= x; i++) {
    if (x % i)
      continue;
    while (x % i == 0) {
      x /= i;
    }
    res++;
  }
  if (x != 1)
    res++;
  return res;
}
int main() {
  ll A, B;
  cin >> A >> B;
  ll ab = gcd(A, B);
  ll ans = common(ab);
  cout << ans << endl;
  return 0;
}
Problem p02900 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll gcd(ll a, ll b) {
  // require:   a > b
  if (a < b)
    return gcd(b, a);
  if (b == 0)
    return a;
  return gcd(b, a % b);
}

int main() {
  ll a, b;
  cin >> a >> b;
  ll gc = gcd(a, b);
  if (gc == 1) {
    cout << 1 << endl;
    return 0;
  }
  vector<int> cd;
  for (int i = 1; i <= sqrt(gc); i++) {
    if (gc % i == 0) {
      cd.push_back(i);
      cd.push_back(gc / i);
    }
  }
  sort(cd.begin(), cd.end());
  int ans = 0;
  for (int i = 0; i < cd.size(); i++) {
    bool f = true;
    for (int j = 1; j < i; j++) {
      if (cd[i] % cd[j] == 0)
        f = false;
    }
    ans += (f ? 1 : 0);
  }
  cout << ans << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll gcd(ll a, ll b) {
  // require:   a > b
  if (a < b)
    return gcd(b, a);
  if (b == 0)
    return a;
  return gcd(b, a % b);
}

int main() {
  ll a, b;
  cin >> a >> b;
  ll gc = gcd(a, b);
  if (gc == 1) {
    cout << 1 << endl;
    return 0;
  }
  vector<ll> cd;

  for (int i = 1; i <= sqrt(gc); i++) {
    if (gc % i == 0) {
      cd.push_back(i);
      cd.push_back(gc / i);
    }
  }
  sort(cd.begin(), cd.end());
  int ans = 0;
  for (int i = 0; i < cd.size(); i++) {
    bool f = true;
    for (int j = 1; j < i; j++) {
      if (cd[i] % cd[j] == 0)
        f = false;
    }
    ans += (f ? 1 : 0);
  }
  cout << ans << endl;
}
Problem p02900 (C++)

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

using namespace std;
#define DBG(x)                                                                 \
  (void)(cout << "L" << __LINE__ << ": " << #x << " = " << (x) << '\n')
#define Lower_bound(v, x)                                                      \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x)                                                      \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))
typedef long long ll;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;
const int INF = 0x3f3f3f3f;
const int maxn = 110000;
int main() {
  // 检查有没有特判0,有没有越界限.
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setiosflags(ios::fixed) << setprecision(12);
  ll a, b;
  cin >> a >> b;
  ll num = __gcd(a, b);
  int ans = 1;
  ll cur = num;
  for (ll i = 2; i <= num; i++) {
    if (num % i == 0) {
      ans++;
      while (num % i == 0) {
        num /= i;
      }
    }
  }
  if (num > 1)
    ans++;
  cout << ans << "\n";
  return 0;
}

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

using namespace std;
#define DBG(x)                                                                 \
  (void)(cout << "L" << __LINE__ << ": " << #x << " = " << (x) << '\n')
#define Lower_bound(v, x)                                                      \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x)                                                      \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))
typedef long long ll;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;
const int INF = 0x3f3f3f3f;
const int maxn = 110000;
int main() {
  // 检查有没有特判0,有没有越界限.
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setiosflags(ios::fixed) << setprecision(12);
  ll a, b;
  cin >> a >> b;
  ll num = __gcd(a, b);
  int ans = 1;
  ll cur = num;
  for (ll i = 2; i * i <= num; i++) {
    if (num % i == 0) {
      ans++;
      while (num % i == 0) {
        num /= i;
      }
    }
  }
  if (num > 1)
    ans++;
  cout << ans << "\n";
  return 0;
}
Problem p02900 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// ll gcd(ll x, ll y){ return y ? gcd(y, x%y): x;}
// ll lcm(ll x, ll y){ return x*y/gcd(x, y);}
int main() {
  ll A, B;
  cin >> A >> B;
  ll g = __gcd(A, B);
  ll s = g;
  ll ans = 1;
  for (int i = 2; i * i <= s; i++) {
    if (g % i == 0) {
      ans += 1;
      while (g % i == 0) {
        g /= i;
      }
    }
  }
  if (g > 1) {
    ans++;
  }
  cout << ans;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// ll gcd(ll x, ll y){ return y ? gcd(y, x%y): x;}
// ll lcm(ll x, ll y){ return x*y/gcd(x, y);}
int main() {
  ll A, B;
  cin >> A >> B;
  ll g = __gcd(A, B);
  ll s = g;
  ll ans = 1;
  for (ll i = 2; i * i <= s; i++) {
    if (g % i == 0) {
      ans += 1;
      while (g % i == 0) {
        g /= i;
      }
    }
  }
  if (g > 1) {
    ans++;
  }
  cout << ans;
}