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

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

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

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

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

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

  ll g = gcd(a, b);

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

  ans += g != 1 ? 2 : 1;

  cout << ans << endl;

  return 0;
}


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

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

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

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

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

  ll g = gcd(a, b);

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

  ans += g != 1 ? 2 : 1;

  cout << ans << endl;

  return 0;
}
Problem p02900 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

constexpr long long mod = 1000000007;
constexpr double eps = 0.0000000001;

typedef long long ll;

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

int main() {
  ll a, b;
  cin >> a >> b;
  ll c = gcd(a, b);
  ll *p = new ll[500000];
  ll pc = 0;
  for (ll i = 2; i * i <= c; i++) {
    bool flag = true;
    for (ll j = 0; j < pc; j++) {
      if (i % p[j] == 0) {
        flag = false;
        break;
      }
    }
    if (flag) {
      p[pc] = i;
      pc++;
    }
  }
  int r = 1;
  for (ll i = 0; i < pc; i++) {
    if ((c % p[i]) == 0) {
      r++;
      while ((c % p[i]) == 0)
        c /= p[i];
    }
  }
  if (c != 1)
    r++;
  cout << r << endl;
}

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

using namespace std;

constexpr long long mod = 1000000007;
constexpr double eps = 0.0000000001;

typedef long long ll;

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

int main() {
  ll a, b;
  cin >> a >> b;
  ll c = gcd(a, b);
  ll *p = new ll[500000];
  ll pc = 0;
  for (ll i = 2; i * i <= c; i++) {
    bool flag = true;
    for (ll j = 0; j < pc && p[j] * p[j] <= i; j++) {
      if (i % p[j] == 0) {
        flag = false;
        break;
      }
    }
    if (flag) {
      p[pc] = i;
      pc++;
    }
  }
  int r = 1;
  for (ll i = 0; i < pc; i++) {
    if ((c % p[i]) == 0) {
      r++;
      while ((c % p[i]) == 0)
        c /= p[i];
    }
  }
  if (c != 1)
    r++;
  cout << r << endl;
}
Problem p02900 (C++)

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

using ll = long long;

ll gcd(ll a, ll b) {
  while (b != 0) {
    ll r = a % b;
    a = b;
    b = r;
  }
  return a;
}

int main() {
  ll a, b;
  cin >> a >> b;
  ll n = gcd(a, b);
  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;
  cout << ans << endl;
}


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

using ll = long long;

ll gcd(ll a, ll b) {
  while (b != 0) {
    ll r = a % b;
    a = b;
    b = r;
  }
  return a;
}

int main() {
  ll a, b;
  cin >> a >> b;
  ll n = gcd(a, b);
  int ans = 1;

  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      ++ans;
      while (n % i == 0) {
        n /= i;
      }
    }
  }
  if (n != 1)
    ++ans;
  cout << ans << endl;
}
Problem p02900 (C++)

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

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

int main(void) {
  long long a, b;
  cin >> a >> b;
  ll g = gcd(a, b);
  int ans = 1;
  if (g % 2 == 0) {
    ans++;
    while (!(g % 2))
      g /= 2;
  }
  for (int i = 3; i * i <= g; i += 2) {
    if (g % i == 0) {
      ans++;
      while (g % i == 0)
        g /= i;
    }
  }
  if (g != 1)
    ans++;
  cout << ans << endl;
  return 0;
}


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

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

int main(void) {
  long long a, b;
  cin >> a >> b;
  ll g = gcd(a, b);
  int ans = 1;
  if (g % 2 == 0) {
    ans++;
    while (!(g % 2))
      g /= 2;
  }
  for (ll i = 3; i * i <= g; i += 2) {
    if (g % i == 0) {
      ans++;
      while (g % i == 0)
        g /= i;
    }
  }
  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;
using ll = long long;

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

int main() {
  ll a, b;
  cin >> a >> b;
  ll d = gcd(a, b);
  ll r = 1;
  ll t = d;
  for (int i = 2; i <= t && i * i <= d; i++) {
    if (t % i == 0) {
      r++;
      while (t % i == 0)
        t /= i;
    }
  }
  r += t > 1;
  cout << r << endl;
}


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

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

int main() {
  ll a, b;
  cin >> a >> b;
  ll d = gcd(a, b);
  ll r = 1;
  ll t = d;
  for (ll i = 2; i <= t && i * i <= d; i++) {
    if (t % i == 0) {
      r++;
      while (t % i == 0)
        t /= i;
    }
  }
  r += t > 1;
  cout << r << endl;
}
Problem p02900 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
#include <map>
#include <numeric>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll A, B;
ll gcd(ll a, ll b) {
  if (a % b == 0)
    return b;
  return gcd(b, a % b);
}
int main() {
  cin >> A >> B;
  ll u = gcd(A, B);
  ll count = 0;
  if (u % 2 == 0)
    count++;
  while (u % 2 == 0)
    u /= 2;
  for (ll i = 3; i + i < u; i += 2) {
    if (u % i == 0) {
      count++;
      while (u % i == 0) {
        u /= i;
      }
    }
  }
  if (u != 1)
    count++;
  cout << count + 1 << endl;
  return 0;
}

Fixed submission:
#include <iostream>
#include <map>
#include <numeric>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll A, B;
ll gcd(ll a, ll b) {
  if (a % b == 0)
    return b;
  return gcd(b, a % b);
}
int main() {
  cin >> A >> B;
  ll u = gcd(A, B);
  ll count = 0;
  if (u % 2 == 0)
    count++;
  while (u % 2 == 0)
    u /= 2;
  for (ll i = 3; i * i < u; i++) {
    if (u % i == 0) {
      count++;
      while (u % i == 0) {
        u /= i;
      }
    }
  }
  if (u != 1)
    count++;
  cout << count + 1 << endl;
  return 0;
}
Problem p02900 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;

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

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

  map<ll, ll> ps;
  auto decompositPrime = [&](ll n, map<ll, ll> &mp) {
    int a = 2;
    while (n >= a * a) {
      if (n % a == 0) {
        mp[a]++;
        n /= a;
      } else {
        a++;
      }
    }
    if (n != 1)
      mp[n]++;
  };

  decompositPrime(G, ps);

  ll ans = 1;
  for (auto [e0, e1] : ps) {
    ++ans;
  }
  cout << ans << endl;
}


Fixed submission:
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;

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

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

  map<ll, ll> ps;
  auto decompositPrime = [&](ll n, map<ll, ll> &mp) {
    ll a = 2;
    while (n >= a * a) {
      if (n % a == 0) {
        mp[a]++;
        n /= a;
      } else {
        a++;
      }
    }
    if (n != 1)
      mp[n]++;
  };

  decompositPrime(G, ps);

  ll ans = 1;
  for (auto [e0, e1] : ps) {
    ++ans;
  }
  cout << ans << endl;
}
Problem p02900 (C++)

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

vector<pair<long long, long long>> prime_factorize(long long n) {
  vector<pair<long long, long long>> res;
  for (int p = 2; p * p <= n; p++) {
    if (n % p != 0)
      continue;
    int num = 0;
    while (n % p == 0) {
      num++;
      n /= p;
    }
    res.push_back(make_pair(p, num));
  }
  if (n != 1)
    res.push_back(make_pair(n, 1));
  return res;
}

long long GCD(long long x, long long y) { return y ? GCD(y, x % y) : x; }

int main() {
  long long A, B;
  cin >> A >> B;
  long long G = GCD(A, B);
  auto pf = prime_factorize(G);
  cout << pf.size() + 1 << endl;
}

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

vector<pair<long long, long long>> prime_factorize(long long n) {
  vector<pair<long long, long long>> res;
  for (long long p = 2; p * p <= n; p++) {
    if (n % p != 0)
      continue;
    int num = 0;
    while (n % p == 0) {
      num++;
      n /= p;
    }
    res.push_back(make_pair(p, num));
  }
  if (n != 1)
    res.push_back(make_pair(n, 1));
  return res;
}

long long GCD(long long x, long long y) { return y ? GCD(y, x % y) : x; }

int main() {
  long long A, B;
  cin >> A >> B;
  long long G = GCD(A, B);
  auto pf = prime_factorize(G);
  cout << pf.size() + 1 << endl;
}
Problem p02900 (C++)

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

bool is_prime[1000002];
vector<int> P;
void Eratosthenes(const int N) {
  for (int i = 0; i <= N; i++) {
    is_prime[i] = true; // 初期化
  }
  for (int i = 2; i <= N; i++) {
    if (is_prime[i]) {
      for (int j = 2 * i; j <= N; j += i) {
        is_prime[j] = false;
      }
      P.emplace_back(i);
    }
  }
}

// 最大公約数
ll yaku(ll a, ll b) {
  if (a > b)
    return yaku(b, a);
  else {
    if (b % a == 0)
      return a;
    else
      return yaku(b % a, a);
  }
}

int main() {
  ll A, B, ans = 1;
  cin >> A >> B;
  ll N = yaku(A, B);
  Eratosthenes(1000001);
  // cout<<P.size();
  if (N == 1)
    ans = 1;
  else {
    int i = 0;

    while (true) {
      int m = P.at(i);
      bool kari = false;
      while (N % m == 0) {
        kari = true;
        N /= m;
      }
      if (kari)
        ans++;

      if (m * m > N)
        break;
      i++;
    }
    if (N != 1)
      ans++;
  }
  cout << ans << endl;
}


Fixed submission:
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll BIG = 1e9;

bool is_prime[1000002];
vector<int> P;
void Eratosthenes(const int N) {
  for (int i = 0; i <= N; i++) {
    is_prime[i] = true; // 初期化
  }
  for (int i = 2; i <= N; i++) {
    if (is_prime[i]) {
      for (int j = 2 * i; j <= N; j += i) {
        is_prime[j] = false;
      }
      P.emplace_back(i);
    }
  }
}

// 最大公約数
ll yaku(ll a, ll b) {
  if (a > b)
    return yaku(b, a);
  else {
    if (b % a == 0)
      return a;
    else
      return yaku(b % a, a);
  }
}

int main() {
  ll A, B, ans = 1;
  cin >> A >> B;
  ll N = yaku(A, B);
  Eratosthenes(1000001);
  // cout<<P.size();
  if (N == 1)
    ans = 1;
  else {
    int i = 0;

    while (true) {
      int m = P.at(i);
      bool kari = false;
      while (N % m == 0) {
        kari = true;
        N /= m;
      }
      if (kari)
        ans++;

      if (m * m > N)
        break;
      i++;
      if (i == P.size())
        break;
    }
    if (N != 1)
      ans++;
  }
  cout << ans << endl;
}
Problem p02900 (C++)

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

using namespace std;

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

  long long a, b;
  cin >> a >> b;

  auto factorize = [](long long n) {
    set<long long> res;
    int d = 2;
    while (d * d <= n) {
      while (n % d == 0) {
        n /= d;
        res.insert(d);
      }
      d++;
    }
    if (n > 1) {
      res.insert(n);
    }
    return res;
  };

  set<long long> s1 = factorize(a);
  set<long long> s2 = factorize(b);
  vector<long long> common;
  set_intersection(s1.begin(), s1.end(), s2.begin(), s2.end(),
                   back_inserter(common));
  cout << common.size() + 1 << '\n';

  return 0;
}

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

using namespace std;

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

  long long a, b;
  cin >> a >> b;

  auto factorize = [](long long n) {
    set<long long> res;
    long long d = 2;
    while (d * d <= n) {
      while (n % d == 0) {
        n /= d;
        res.insert(d);
      }
      d++;
    }
    if (n > 1) {
      res.insert(n);
    }
    return res;
  };

  set<long long> s1 = factorize(a);
  set<long long> s2 = factorize(b);
  vector<long long> common;
  set_intersection(s1.begin(), s1.end(), s2.begin(), s2.end(),
                   back_inserter(common));
  cout << common.size() + 1 << '\n';

  return 0;
}
Problem p02900 (C++)

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

#define rep(i, k, n) for (int i = (k); i < (n); i++)
#define irep(i, k, n) for (int i = (k); i > (n); i--)
using namespace std;
using ll = long long;

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

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

  ll c = gcd(a, b);
  int ans = 1;
  rep(i, 0, 1e6 + 1) {
    if (c % i)
      continue;
    while (!(c % i))
      c /= i;
    ans++;
  }
  if (c != 1)
    ans++;

  cout << ans << endl;

  return 0;
}

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

#define rep(i, k, n) for (int i = (k); i < (n); i++)
#define irep(i, k, n) for (int i = (k); i > (n); i--)
using namespace std;
using ll = long long;

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

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

  ll c = gcd(a, b);
  ll ans = 1;
  rep(i, 2, 1e6 + 1) {
    if (c % i)
      continue;
    while (!(c % i))
      c /= i;
    ans++;
  }
  if (c != 1)
    ans++;

  cout << ans << endl;

  return 0;
}
Problem p02900 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for (int i = 0; i < (n); i++)
#define all(t) (t).begin(), (t).end()
#define MOD 1000000007
typedef long long ll;
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  } else {
    return 0;
  }
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  } else {
    return 0;
  }
}
template <class T> inline T GCD(T a, T b) {
  T c;
  while (b != 0) {
    c = a % b;
    a = b;
    b = c;
  }
  return a;
}
template <class T> inline T LCM(T a, T b) { return a * b / GCD(a, b); }

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


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for (int i = 0; i < (n); i++)
#define all(t) (t).begin(), (t).end()
#define MOD 1000000007
typedef long long ll;
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  } else {
    return 0;
  }
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  } else {
    return 0;
  }
}
template <class T> inline T GCD(T a, T b) {
  T c;
  while (b != 0) {
    c = a % b;
    a = b;
    b = c;
  }
  return a;
}
template <class T> inline T LCM(T a, T b) { return a * b / GCD(a, b); }

int main() {
  ll a, b;
  cin >> a >> b;
  ll x = GCD(a, b);
  ll num = x, ans = 1;
  for (ll i = 2; i * i <= x; i++) {
    if (num % i == 0)
      ans++;
    while (num % i == 0)
      num /= i;
  }
  if (num != 1)
    ans++;
  cout << ans << endl;
}
Problem p02900 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
#include <map>
#include <numeric>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll A, B;
ll gcd(ll a, ll b) {
  if (a % b == 0)
    return b;
  return gcd(b, a % b);
}
int main() {
  cin >> A >> B;
  ll u = gcd(A, B);
  vector<ll> V(u);
  ll j = 0;
  for (ll i = 2; i * i <= u; i++) {
    if (u % i == 0) {
      V[j] = i;
      j++;
      while (u % i == 0) {
        u /= i;
      }
    }
  }
  if (u != 1) {
    V[j] = u;
    j++;
  }
  cout << j + 1 << endl;

  return 0;
}

Fixed submission:
#include <iostream>
#include <map>
#include <numeric>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll A, B;
ll gcd(ll a, ll b) {
  if (a % b == 0)
    return b;
  return gcd(b, a % b);
}
int main() {
  cin >> A >> B;
  ll u = gcd(A, B);
  vector<ll> V(1000);
  ll j = 0;
  for (ll i = 2; i * i <= u; i++) {
    if (u % i == 0) {
      V[j] = i;
      j++;
      while (u % i == 0) {
        u /= i;
      }
    }
  }
  if (u != 1) {
    V[j] = u;
    j++;
  }
  cout << j + 1 << endl;

  return 0;
}
Problem p02900 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
#define rep(i, n) for (ll i = 0; i < n; i++)
#define ll long long
#define ggr                                                                    \
  getchar();                                                                   \
  getchar();                                                                   \
  return 0;
#define prique priority_queue
#define inf 1145141919364364
#define double long double
using namespace std;
typedef pair<ll, ll> P;
bool prime(int n) {
  int cnt = 0;
  for (int i = 1; i <= sqrt(n); i++) {
    if (n % i == 0)
      cnt++;
  }
  if (cnt != 1)
    return false;
  else
    return n != 1;
}
ll gcd(ll x, ll y) {
  if (y == 0)
    return x;
  return gcd(y, x % y);
}
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }
map<ll, ll> mp;
signed main() {
  ll a, b, ans = 0;
  cin >> a >> b;
  ll l = gcd(a, b);
  for (int i = 2; i * i <= l; i++) {
    while (l % i == 0) {
      mp[i]++;
      l /= i;
    }
  }
  if (l != 1)
    mp[l] = 1;
  for (auto x : mp) {
    if (x.second)
      ans++;
  }
  cout << ans + 1 << endl;
  ggr
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
#define rep(i, n) for (ll i = 0; i < n; i++)
#define ll long long
#define ggr                                                                    \
  getchar();                                                                   \
  getchar();                                                                   \
  return 0;
#define prique priority_queue
#define inf 1145141919364364
#define double long double
using namespace std;
typedef pair<ll, ll> P;
bool prime(int n) {
  int cnt = 0;
  for (int i = 1; i <= sqrt(n); i++) {
    if (n % i == 0)
      cnt++;
  }
  if (cnt != 1)
    return false;
  else
    return n != 1;
}
ll gcd(ll x, ll y) {
  if (y == 0)
    return x;
  return gcd(y, x % y);
}
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }
map<ll, ll> mp;
signed main() {
  ll a, b, ans = 0;
  cin >> a >> b;
  ll l = gcd(a, b);
  for (ll i = 2; i * i <= l; i++) {
    while (l % i == 0) {
      mp[i]++;
      l /= i;
    }
  }
  if (l != 1)
    mp[l] = 1;
  for (auto x : mp) {
    if (x.second)
      ans++;
  }
  cout << ans + 1 << endl;
  ggr
}
Problem p02900 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main() {
  ll A, B;
  cin >> A >> B;
  map<int, int> mp;
  for (ll i = 1; i * i <= A; i++) {
    if (A % i == 0) {
      if (B % i == 0)
        mp[i]++;
      if (i * i != A && B % (A / i) == 0) {
        mp[A / i]++;
      }
    }
  }
  vector<ll> yakusu;
  for (auto y : mp) {
    yakusu.pb(y.first);
  }
  int ysize = (int)yakusu.size();
  // cout << ysize << endl;
  vector<ll> ans;
  rep(i, ysize) {
    bool ok = true;
    rep(j, (int)ans.size()) {
      if (j == 0)
        continue;
      if (yakusu[i] % ans[j] == 0) {
        ok = false;
        break;
      }
    }
    if (ok) {
      ans.pb(yakusu[i]);
    }
  }
  cout << (int)ans.size() << endl;
  return 0;
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main() {
  ll A, B;
  cin >> A >> B;
  map<ll, int> mp;
  for (ll i = 1; i * i <= A; i++) {
    if (A % i == 0) {
      if (B % i == 0)
        mp[i]++;
      if (i * i != A && B % (A / i) == 0) {
        mp[A / i]++;
      }
    }
  }
  vector<ll> yakusu;
  for (auto y : mp) {
    yakusu.pb(y.first);
  }
  int ysize = (int)yakusu.size();
  // cout << ysize << endl;
  vector<ll> ans;
  rep(i, ysize) {
    bool ok = true;
    rep(j, (int)ans.size()) {
      if (j == 0)
        continue;
      if (yakusu[i] % ans[j] == 0) {
        ok = false;
        break;
      }
    }
    if (ok) {
      ans.pb(yakusu[i]);
    }
  }
  cout << (int)ans.size() << endl;
  return 0;
}
Problem p02900 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <sstream>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i <= n; i++)
#define co(x) cout << x << endl
#define cs(x) cout << x << " "
#define ALL(a) (a).begin(), (a).end()
typedef long long ll;
using namespace std;
int mod = 1e9 + 7;
ll gcd(ll, ll);
ll numFact(ll a);

int main() {
  ll A, B;
  cin >> A >> B;
  ll g = gcd(A, B);
  ll numF = numFact(g);
  co(numF + 1);
  return 0;
}

ll gcd(ll a, ll b) {
  if (a < b)
    return gcd(b, a);
  while (b != 0) {
    ll r = a % b;
    a = b;
    b = r;
  }
  return a;
}

ll numFact(ll a) {
  ll res = 0;
  ll i = 2;
  ll a_o = a;
  while ((a > 1) || i * i <= a_o) {
    ll cnt = 0;
    while (a % i == 0) {
      cnt++;
      a /= i;
      if (cnt == 1)
        res++;
    }
    i++;
  }
  if (a > 1)
    res++;
  return res;
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <sstream>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i <= n; i++)
#define co(x) cout << x << endl
#define cs(x) cout << x << " "
#define ALL(a) (a).begin(), (a).end()
typedef long long ll;
using namespace std;
int mod = 1e9 + 7;
ll gcd(ll, ll);
ll numFact(ll a);

int main() {
  ll A, B;
  cin >> A >> B;
  ll g = gcd(A, B);
  ll numF = numFact(g);
  co(numF + 1);
  return 0;
}

ll gcd(ll a, ll b) {
  if (a < b)
    return gcd(b, a);
  while (b != 0) {
    ll r = a % b;
    a = b;
    b = r;
  }
  return a;
}

ll numFact(ll a) {
  ll res = 0;
  ll i = 2;
  ll a_o = a;
  while ((a > 1) && i * i <= a_o) {
    ll cnt = 0;
    while (a % i == 0) {
      cnt++;
      a /= i;
      if (cnt == 1)
        res++;
    }
    i++;
  }
  if (a > 1)
    res++;
  return res;
}
Problem p02900 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
#include <vector>
using namespace std;
int main() {
  long long int a, b;
  cin >> a >> b;
  // 公約数計算
  while (a > 0 && b > 0) {
    if (a < b) {
      b = b % a;
    } else {
      a = a % b;
    }
  }
  if (b > 0) {
    a = b;
  }
  // 素因数分解
  // 素数列の生成
  vector<bool> isprime;
  vector<int> prime;
  int i = 1;
  int p = 0;
  while (i * i < a) {
    i++;
  }
  isprime.resize(i + 1, true);
  isprime[1] = false;
  for (int j = 2; j <= i; j++) {
    if (isprime[j]) {
      prime.push_back(j);
      p++;
      for (int k = 2; j * k <= i; k++) {
        isprime[j * k] = false;
      }
    }
  }
  /*for(int j=0;j<p;j++){
      cout<<prime[j]<<endl;
  }*/
  // 素数列に従って調査
  int cnt = 0;
  for (int d = 0; d < p; d++) {
    if (a % prime[d] == 0) {
      cnt++;
      while (a % prime[d] == 0) {
        a = a / prime[d];
      }
    }
  }
  if (a != 1) {
    cnt++;
  }
  cout << cnt + 1 << endl;
  return 0;
}

Fixed submission:
#include <iostream>
#include <vector>
using namespace std;
int main() {
  long long int a, b;
  cin >> a >> b;
  // 公約数計算
  while (a > 0 && b > 0) {
    if (a < b) {
      b = b % a;
    } else {
      a = a % b;
    }
  }
  if (b > 0) {
    a = b;
  }
  // 素因数分解
  // 素数列の生成
  vector<bool> isprime;
  vector<int> prime;
  long long int i = 1;
  int p = 0;
  while (i * i < a) {
    i++;
  }
  isprime.resize(i + 1, true);
  isprime[1] = false;
  for (int j = 2; j <= i; j++) {
    if (isprime[j]) {
      prime.push_back(j);
      p++;
      for (int k = 2; j * k <= i; k++) {
        isprime[j * k] = false;
      }
    }
  }
  /*for(int j=0;j<p;j++){
      cout<<prime[j]<<endl;
  }*/
  // 素数列に従って調査
  int cnt = 0;
  for (int d = 0; d < p; d++) {
    if (a % prime[d] == 0) {
      cnt++;
      while (a % prime[d] == 0) {
        a = a / prime[d];
      }
    }
  }
  if (a != 1) {
    cnt++;
  }
  cout << cnt + 1 << endl;
  return 0;
}
Problem p02900 (Python)

Buggy submission (status: Runtime Error):
def p(n):
    i = 2
    t = []
    while i * i <= n:
        while n % i == 0:
            n //= i
            t.append(i)
        i += 1
    if n > 1:
        t.append(n)
    return t


def main():
    from math import gcd

    a, b = map(int, input().split())
    g = gcd(a, b)
    print(len(set(p(g))) + 1)


if __name__ == "__main__":
    main()


Fixed submission:
def p(n):
    i = 2
    t = []
    while i * i <= n:
        while n % i == 0:
            n //= i
            t.append(i)
        i += 1
    if n > 1:
        t.append(n)
    return t


def main():
    from fractions import gcd

    a, b = map(int, input().split())
    g = gcd(a, b)
    print(len(set(p(g))) + 1)


if __name__ == "__main__":
    main()
Problem p02900 (Python)

Buggy submission (status: Time Limit Exceeded):
def gcd(x, y):
    if y == 0:
        return x
    return gcd(y, x % y)


A, B = map(int, input().split())
C = gcd(A, B)

ans = []
i = 2
while True:
    if C == 1:
        break
    if C % i != 0:
        i += 1
        continue
    ans.append(i)
    C //= i
print(len(set(ans)) + 1)


Fixed submission:
def gcd(x, y):
    if y == 0:
        return x
    return gcd(y, x % y)


A, B = map(int, input().split())
C = gcd(A, B)

ans = []
while C % 2 == 0:
    ans.append(2)
    C //= 2
i = 3
while C >= i * i:
    if C % i == 0:
        ans.append(i)
        C //= i
    else:
        i += 2
if C != 1:
    ans.append(C)
print(len(set(ans)) + 1)
Problem p02900 (Python)

Buggy submission (status: Time Limit Exceeded):
from sys import stdin

a, b = [int(x) for x in stdin.readline().split()]

while b != 0:
    a, b = b, a % b

c = 1
lim = a // 2
n = 0
i = 2
while a > 1 and i <= lim:
    n = 0
    while a % i == 0:
        a //= i
        n += 1
    if n > 0:
        c += 1
    i += 1
if a > 1:
    c += 1

print(c)


Fixed submission:
from sys import stdin

a, b = [int(x) for x in stdin.readline().split()]

while b != 0:
    a, b = b, a % b

c = 1
lim = a**0.5 + 10
n = 0
i = 2
while a > 1 and i <= lim:
    n = 0
    while a % i == 0:
        a //= i
        n += 1
    if n > 0:
        c += 1
    i += 1
if a > 1:
    c += 1

print(c)
Problem p02900 (Python)

Buggy submission (status: Runtime Error):
from math import gcd


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


A, B = tuple(map(int, input().split(" ")))

print(len(set(prime_factorize(gcd(A, B)))) + 1)


Fixed submission:
from fractions import gcd


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


A, B = tuple(map(int, input().split(" ")))

print(len(set(prime_factorize(gcd(A, B)))) + 1)
Problem p02900 (Python)

Buggy submission (status: Time Limit Exceeded):
def slove():
    import sys
    import fractions

    input = sys.stdin.readline
    a, b = list(map(int, input().rstrip("\n").split()))
    gcd = fractions.gcd(a, b)
    cnt = 1
    for i in range(2, int(gcd**0.5) + 2):
        while True:
            if gcd % i == 0:
                cnt += 1
                while True:
                    if gcd % i == 0:
                        gcd //= i
                    else:
                        break
    print(cnt)


if __name__ == "__main__":
    slove()


Fixed submission:
def slove():
    import sys
    import fractions

    input = sys.stdin.readline
    a, b = list(map(int, input().rstrip("\n").split()))
    gcd = fractions.gcd(a, b)
    cnt = 1
    for i in range(2, int(gcd**0.5) + 1):
        if gcd % i == 0:
            cnt += 1
            while True:
                if gcd % i == 0:
                    gcd //= i
                else:
                    break
    if gcd != 1:
        cnt += 1
    print(cnt)


if __name__ == "__main__":
    slove()
Problem p02900 (Python)

Buggy submission (status: Runtime Error):
#!/usr/bin/env python3
from math import gcd

a, b = map(int, input().split())
g = gcd(a, b)
ans = {}
for i in range(2, int(g**0.5 + 1)):
    while g % i == 0:
        ans[i] = ans[i] + 1 if i in ans else 1
        g //= i
if g != 1:
    ans[g] = 1
print(len(ans) + 1)


Fixed submission:
#!/usr/bin/env python3
from fractions import gcd

a, b = map(int, input().split())
g = gcd(a, b)
ans = {}
for i in range(2, int(g**0.5 + 1)):
    while g % i == 0:
        ans[i] = ans[i] + 1 if i in ans else 1
        g //= i
if g != 1:
    ans[g] = 1
print(len(ans) + 1)
Problem p02900 (Python)

Buggy submission (status: Runtime Error):
def input_li():
    return list(map(int, input().split()))


def input_int():
    return int(input())


def prime_factorization(n):
    table = []
    for x in range(2, int(n**0.5) + 1):
        while n % x == 0:
            table.append(x)
            n //= x
    if n > 1:
        table.append(n)
    return table


A, B = input_li()
A_LI = [x[0] for x in prime_factorization(A)]
B_LI = [x[0] for x in prime_factorization(B)]
print(len(set(A_LI) & set(B_LI)) + 1)


Fixed submission:
def input_li():
    return list(map(int, input().split()))


def input_int():
    return int(input())


def prime_factorization(n):
    table = []
    for x in range(2, int(n**0.5) + 1):
        while n % x == 0:
            table.append(x)
            n //= x
    if n > 1:
        table.append(n)
    return table


A, B = input_li()
A_SET = set(prime_factorization(A))
B_SET = set(prime_factorization(B))
print(len((A_SET) & set(B_SET)) + 1)
Problem p02900 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
#define LL long long
#define MAXN 1000001
using namespace std;
LL a, b;
LL inv[MAXN], prime[MAXN], cnt = 0;
void getp() {
  for (int i = 2; i < MAXN; i++) {
    if (!inv[i]) {
      prime[++cnt] = i;
      inv[i] = i;
    }
    for (int j = 1; j <= cnt && prime[j] * i < MAXN; j++) {
      inv[prime[j] * i] = prime[j];
      if (i % prime[j] == 0)
        break;
    }
  }
}
LL gcd(LL x, LL y) { return y ? gcd(y, x % y) : x; }
int main() {
  cin >> a >> b;
  a = gcd(a, b);

  getp();
  int ans = 1;
  for (int i = 1; i <= cnt; i++) {
    if (a % prime[i] == 0)
      ans++;
    // cout<<prime[i]<<endl;
    while (a % prime[i] == 0)
      a /= prime[i];
  }
  if (inv[a] == a)
    ans++;
  cout << ans << endl;
  return 0;
}


Fixed submission:
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
#define LL long long
#define MAXN 1000001
using namespace std;
LL a, b;
LL inv[MAXN], prime[MAXN], cnt = 0;
void getp() {
  for (int i = 2; i < MAXN; i++) {
    if (!inv[i]) {
      prime[++cnt] = i;
      inv[i] = i;
    }
    for (int j = 1; j <= cnt && prime[j] * i < MAXN; j++) {
      inv[prime[j] * i] = prime[j];
      if (i % prime[j] == 0)
        break;
    }
  }
}
LL gcd(LL x, LL y) { return y ? gcd(y, x % y) : x; }
int main() {
  cin >> a >> b;
  a = gcd(a, b);

  getp();
  int ans = 1;
  for (int i = 1; i <= cnt; i++) {
    if (a % prime[i] == 0)
      ans++;
    // cout<<prime[i]<<endl;
    while (a % prime[i] == 0)
      a /= prime[i];
  }
  if (a != 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
#define vi vector<ll>
#define vii vector<pair<int, int>>
#define ii pair<int, int>
#define loop(n) for (int i = 0; i < n; i++)
#define pb push_back
const ll mod = 1e9 + 7;
void fast();
ll gcd(ll a, ll b) {
  if (!b)
    return a;
  return gcd(b, a % b);
}
int main() {
  fast();
  ll a, b;
  cin >> a >> b;
  set<int> s;
  a = gcd(a, b);
  for (int i = 2; i * i <= a; i++) {
    if (a % i == 0) {
      while (a % i == 0)
        a /= i;
      s.insert(i);
    }
  }
  if (a > 1)
    s.insert(a);
  cout << s.size() + 1;
}
void fast() {
  std::ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
}
/*

*/


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<ll>
#define vii vector<pair<int, int>>
#define ii pair<int, int>
#define loop(n) for (int i = 0; i < n; i++)
#define pb push_back
const ll mod = 1e9 + 7;
void fast();
ll gcd(ll a, ll b) {
  if (!b)
    return a;
  return gcd(b, a % b);
}
int main() {
  fast();
  ll a, b;
  cin >> a >> b;
  set<int> s;
  a = __gcd(a, b);
  for (ll i = 2; i * i <= a; i++) {
    if (a % i == 0) {
      while (a % i == 0)
        a /= i;
      s.insert(i);
    }
  }
  if (a > 1)
    s.insert(a);
  cout << s.size() + 1;
}
void fast() {
  std::ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
}
/*

*/
Problem p02900 (C++)

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

ll gcd(ll a, ll b) {
  if (a < b)
    swap(a, b);
  ll r = a % b;
  while (r != 0) {
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}

map<int, int> prime(ll n) {
  map<int, int> ret;
  ret[1]++;
  ;
  ll temp = n;
  for (int i = 2; i * i <= n; i++) {
    while (temp % i == 0) {
      temp /= i;
      ret[i]++;
    }
  }
  if (temp != 1)
    ret[temp]++;
  return ret;
}

int main() {
  ll a, b;
  cin >> a >> b;
  ll r = gcd(a, b);
  map<int, int> mp = prime(r);
  int ans = 0;
  for (auto x : mp)
    ans++;
  cout << ans << endl;
}

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

ll gcd(ll a, ll b) {
  if (a < b)
    swap(a, b);
  ll r = a % b;
  while (r != 0) {
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}

map<int, int> prime(ll n) {
  map<int, int> ret;
  ret[1]++;
  ;
  ll temp = n;
  for (ll i = 2; i * i <= n; i++) {
    while (temp % i == 0) {
      temp /= i;
      ret[i]++;
    }
  }
  if (temp != 1)
    ret[temp]++;
  return ret;
}

int main() {
  ll a, b;
  cin >> a >> b;
  ll r = gcd(a, b);
  map<int, int> mp = prime(r);
  int ans = 0;
  for (auto x : mp)
    ans++;
  cout << ans << endl;
}
Problem p02900 (C++)

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

ll gcd(ll a, ll b) {
  while (b != 0) {
    ll t = b;
    b = a % b;
    a = t;
  }
  return a;
}

ll solve() {
  ll A, B;
  cin >> A >> B;
  ll g = gcd(A, B);

  set<ll> d;
  for (int k = 2; k * k <= g; k++) {
    while (g % k == 0) {
      g /= k;
      d.insert(k);
    }
  }
  if (g > 1)
    d.insert(g);

  ll ans = d.size() + 1;
  return ans;
}

int main() {
  auto ans = solve();
  cout << ans << "\n";
  return 0;
}

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

ll gcd(ll a, ll b) {
  while (b != 0) {
    ll t = b;
    b = a % b;
    a = t;
  }
  return a;
}

ll solve() {
  ll A, B;
  cin >> A >> B;
  ll g = gcd(A, B);

  set<ll> d;
  for (ll k = 2; k * k <= g; k++) {
    while (g % k == 0) {
      g /= k;
      d.insert(k);
    }
  }
  if (g > 1)
    d.insert(g);

  ll ans = d.size() + 1;
  return ans;
}

int main() {
  auto ans = solve();
  cout << ans << "\n";
  return 0;
}
Problem p02900 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i, s, e) for (i64(i) = (s); (i) < (e); (i)++)
#define all(x) x.begin(), x.end()
#define let auto const

template <typename... Types> struct dynarr : std::vector<Types...> {
  using std::vector<Types...>::vector;
  using size_type = typename std::vector<Types...>::size_type;
  auto &&operator[](size_type i) { return this->at(i); }
  auto &&operator[](size_type i) const { return this->at(i); }
};

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

int main() {
  i64 a, b;
  cin >> a >> b;
  i64 g = gcd(a, b);
  i64 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 i64 = long long;
#define rep(i, s, e) for (i64(i) = (s); (i) < (e); (i)++)
#define all(x) x.begin(), x.end()
#define let auto const

template <typename... Types> struct dynarr : std::vector<Types...> {
  using std::vector<Types...>::vector;
  using size_type = typename std::vector<Types...>::size_type;
  auto &&operator[](size_type i) { return this->at(i); }
  auto &&operator[](size_type i) const { return this->at(i); }
};

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

int main() {
  i64 a, b;
  cin >> a >> b;
  i64 g = gcd(a, b);
  i64 ans = 1;
  for (i64 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;
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;

ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

map<ll, ll> Pf(ll n) {
  map<ll, ll> rep;
  for (int i = 2; i * i <= n; i++) {
    if (n % i)
      continue;
    while (n % i == 0) {
      rep[i]++;
      n /= i;
    }
  }
  if (n != 1)
    rep[n] = 1;
  return rep;
}

int main() {
  ll A, B;
  cin >> A >> B;
  ll C = gcd(B, A);
  // cout << C << endl ;
  auto D = Pf(C);
  // for(auto f : Pf(C) ) cout << f.first <<" "<< f.second << endl;
  ll E = D.size();
  cout << E + 1 << endl;
}


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

ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

map<ll, ll> Pf(ll n) {
  map<ll, ll> rep;
  for (ll i = 2; i * i <= n; i++) {
    if (n % i)
      continue;
    while (n % i == 0) {
      rep[i]++;
      n /= i;
    }
  }
  if (n != 1)
    rep[n] = 1;
  return rep;
}

int main() {
  ll A, B;
  cin >> A >> B;
  ll C = gcd(B, A);
  // cout << C << endl ;
  auto D = Pf(C);
  // for(auto f : Pf(C) ) cout << f.first <<" "<< f.second << endl;
  ll E = D.size();
  cout << E + 1 << endl;
}
Problem p02900 (C++)

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

#define _ << " " <<
#define all(v) v.begin(), v.end()
#define sp(n) fixed << setprecision(n)
#define ff first
#define ss second

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const ll mod = 1e9 + 7;
const double eps = DBL_EPSILON;

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  ll a, b;
  cin >> a >> b;
  if (a > b)
    swap(a, b);
  set<ll> div;
  for (int i = 2; i * i <= a; i++) {
    while (a % i == 0) {
      div.insert(i);
      a /= i;
    }
  }
  if (a != 1)
    div.insert(a);
  int ans = 0;
  for (ll i : div) {
    if (b % i == 0)
      ans++;
  }
  cout << ans + 1 << endl;
  return 0;
}

Fixed submission:
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <chrono>
#include <random>

#define _ << " " <<
#define all(v) v.begin(), v.end()
#define sp(n) fixed << setprecision(n)
#define ff first
#define ss second

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const ll mod = 1e9 + 7;
const double eps = DBL_EPSILON;

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  ll a, b;
  cin >> a >> b;
  if (a > b)
    swap(a, b);
  set<ll> div;
  for (ll i = 2; i * i <= a; i++) {
    while (a % i == 0) {
      div.insert(i);
      a /= i;
    }
  }
  if (a != 1)
    div.insert(a);
  int ans = 0;
  for (ll i : div) {
    if (b % i == 0)
      ans++;
  }
  cout << ans + 1 << endl;
  return 0;
}
Problem p02900 (C++)

Buggy submission (status: Time Limit Exceeded):
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P = pair<ll, ll>;
using mat = vector<vector<ll>>;
typedef string::const_iterator State;
class ParseError {};

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

constexpr ll INF = 1e16;
constexpr ll INM = 114514;
constexpr ll MOD = 1e9 + 7;
constexpr ld EPS = 1e-12;

template <typename T> void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
  fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll b) {
  if (a > 0)
    return a % b;
  if (a % b == 0)
    return 0;
  ll x = -a / b + 1;
  a += x * b;
  return a % b;
}
ll powm(ll a, ll b, ll c) {
  if (b == 0)
    return 1;
  else if (b % 2 == 0) {
    ll d = powm(a, b / 2, c);
    return (d * d) % c;
  } else
    return (a * powm(a, b - 1, c)) % c;
}
ll gcd(ll a, ll b) {
  if (b == 0)
    return a;
  return gcd(b, a % b);
}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll dx[4] = {1, 0, -1, 0};
ll dy[4] = {0, 1, 0, -1};

vector<ll> pfact(ll n) {
  vector<ll> ret;
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      while (n % i == 0)
        n /= i;
    }
  }
  if (n != 1)
    ret.push_back(n);
  return ret;
}

int main() {
  IOS();
  ll a, b;
  cin >> a >> b;
  ll g = gcd(a, b);
  dump(pfact(g).size() + 1);

  return 0;
}

Fixed submission:
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P = pair<ll, ll>;
using mat = vector<vector<ll>>;
typedef string::const_iterator State;
class ParseError {};

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

constexpr ll INF = 1e16;
constexpr ll INM = 114514;
constexpr ll MOD = 1e9 + 7;
constexpr ld EPS = 1e-12;

template <typename T> void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
  fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll b) {
  if (a > 0)
    return a % b;
  if (a % b == 0)
    return 0;
  ll x = -a / b + 1;
  a += x * b;
  return a % b;
}
ll powm(ll a, ll b, ll c) {
  if (b == 0)
    return 1;
  else if (b % 2 == 0) {
    ll d = powm(a, b / 2, c);
    return (d * d) % c;
  } else
    return (a * powm(a, b - 1, c)) % c;
}
ll gcd(ll a, ll b) {
  if (b == 0)
    return a;
  return gcd(b, a % b);
}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll dx[4] = {1, 0, -1, 0};
ll dy[4] = {0, 1, 0, -1};

vector<ll> pfact(ll n) {
  vector<ll> ret;
  for (ll i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      while (n % i == 0)
        n /= i;
    }
  }
  if (n != 1)
    ret.push_back(n);
  return ret;
}

int main() {
  IOS();
  ll a, b;
  cin >> a >> b;
  ll g = gcd(a, b);
  dump(pfact(g).size() + 1);

  return 0;
}
Problem p02900 (C++)

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

using namespace std;

map<long long int, long long int> prime_factor(long long int n) {
  map<long long int, long long int> res;
  for (long long int i = 2; i + i <= n; i++) {
    while (n % i == 0) {
      ++res[i];
      n /= i;
    }
  }
  if (n != 1)
    res[n] = 1;
  return res;
}

int main(int argc, char **argv) {
  long long int A, B;
  cin >> A >> B;
  map<long long int, long long int> a = prime_factor(A);
  map<long long int, long long int> b = prime_factor(B);
  long long int ans = 1;
  for (auto itr = a.begin(); itr != a.end(); itr++) {
    if (b[itr->first] > 0)
      ans++;
  }
  cout << ans << "\n";
  return 0;
}


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

using namespace std;

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

int main(int argc, char **argv) {
  long long int A, B;
  cin >> A >> B;
  map<long long int, long long int> a = prime_factor(A);
  map<long long int, long long int> b = prime_factor(B);
  long long int ans = 1;
  for (auto itr = a.begin(); itr != a.end(); itr++) {
    if (b[itr->first] > 0)
      ans++;
  }
  cout << ans << "\n";
  return 0;
}