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

Buggy submission (status: Time Limit Exceeded):
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define cinf(n, x)                                                             \
  for (int i = 0; i < (n); i++)                                                \
    cin >> x[i];
#define max3(a, b, c) max(max(a, b), c)
#define min3(a, b, c) min(min(a, b), c)
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define mod 1000000007
using namespace std;
typedef long long ll;
template <class T> using V = vector<T>;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

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

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

signed main() {
  ll a, b;
  cin >> a >> b;
  ll n = gcd(a, b);
  map<ll, ll> mp = prime_factor(n);
  cout << mp.size() + 1 << endl;
}

Fixed submission:
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define cinf(n, x)                                                             \
  for (int i = 0; i < (n); i++)                                                \
    cin >> x[i];
#define max3(a, b, c) max(max(a, b), c)
#define min3(a, b, c) min(min(a, b), c)
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define mod 1000000007
using namespace std;
typedef long long ll;
template <class T> using V = vector<T>;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

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

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

signed main() {
  ll a, b;
  cin >> a >> b;
  ll n = gcd(a, b);
  map<ll, ll> mp = prime_factor(n);
  cout << mp.size() + 1 << endl;
}
Problem p02900 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n1, n2, cnt = 1;
  cin >> n1 >> n2;
  long long int n = __gcd(n1, n2);
  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 << endl;

  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n1, n2, cnt = 1;
  cin >> n1 >> n2;
  long long int n = __gcd(n1, n2);
  for (long long int i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      cnt++;
      while (n % i == 0)
        n /= i;
    }
  }

  if (n > 1)
    cnt++;
  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 < (n); i++)

using namespace std;

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

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

// 素因数分解はO(√n)までオーダーを落とせる
vector<pair<ll, int>> factorize(ll n) {
  vector<pair<ll, int>> v;
  v.emplace_back(1, 1);
  for (int i = 2; i * i < n; i++) {
    if (n % i != 0)
      continue;
    v.emplace_back(i, 0);
    while (n % i == 0) {
      n /= i;
      v.back().second++;
    }
  }
  if (n != 1)
    v.emplace_back(n, 1);
  return v;
}

int main() {
  ll A, B;
  cin >> A >> B;
  ll gcd_val = gcd(A, B);
  auto res = factorize(gcd_val);
  int ans = res.size();
  cout << ans << endl;
}

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

using namespace std;

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

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

// 素因数分解はO(√n)までオーダーを落とせる
vector<pair<ll, int>> factorize(ll n) {
  vector<pair<ll, int>> v;
  v.emplace_back(1, 1);
  for (ll i = 2; i * i < n; i++) {
    if (n % i != 0)
      continue;
    v.emplace_back(i, 0);
    while (n % i == 0) {
      n /= i;
      v.back().second++;
    }
  }
  if (n != 1)
    v.emplace_back(n, 1);
  return v;
}

int main() {
  ll A, B;
  cin >> A >> B;
  ll gcd_val = gcd(A, B);
  auto res = factorize(gcd_val);
  int ans = res.size();
  cout << ans << endl;
}
Problem p02900 (C++)

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

#define mod 1000000007

ll ebob(ll a, ll b) {
  if (a == 0)
    return b;
  return ebob(b % a, a);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll a, b;
  cin >> a >> b;
  a = ebob(a, b);
  ll res = 1;
  if (a == 1) {
    cout << 1;
    return 0;
  } else if (a == 2 || a == 3) {
    cout << 2;
    return 0;
  }
  ll temp = 1;
  for (int i = 2; i * i <= a; i++) {
    if (temp < a && (a / temp) % i == 0) {
      res++;
      while (temp < a) {
        temp *= i;
        if (a % temp) {
          temp /= i;
          break;
        }
      }
    }
  }
  if (a > temp)
    res++;
  cout << res;
  return 0;
}

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

#define mod 1000000007

ll ebob(ll a, ll b) {
  if (a == 0)
    return b;
  return ebob(b % a, a);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll a, b;
  cin >> a >> b;
  a = ebob(a, b);
  ll res = 1;
  if (a == 1) {
    cout << 1;
    return 0;
  } else if (a == 2 || a == 3) {
    cout << 2;
    return 0;
  }
  ll temp = 1;
  for (ll i = 2; i * i <= a; i++) {
    if (temp < a && (a / temp) % i == 0) {
      res++;
      while (temp < a) {
        temp *= i;
        if (a % temp) {
          temp /= i;
          break;
        }
      }
    }
  }
  if (a > temp)
    res++;
  cout << res;
  return 0;
}
Problem p02900 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
map<long long, int> PF;
void primeF(long long n) {
  long long tmp = n;
  for (int i = 2; i * i <= n; i++) {
    while (tmp % i == 0) {
      PF[i]++;
      tmp /= i;
    }
  }
  if (tmp != 1)
    PF[tmp]++;
}
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  long long A, B;
  cin >> A >> B;
  long long G = __gcd(A, B);
  primeF(G);
  printf("%ld\n", PF.size() + 1);
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
map<long long, int> PF;
void primeF(long long n) {
  long long tmp = n;
  for (int i = 2; (long long)i * i <= tmp; i++) {
    while (tmp % i == 0) {
      PF[i]++;
      tmp /= i;
    }
  }
  if (tmp != 1)
    PF[tmp]++;
}
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  long long A, B;
  cin >> A >> B;
  long long G = __gcd(A, B);
  primeF(G);
  printf("%ld\n", PF.size() + 1);
  return 0;
}
Problem p02900 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <bits/stdc++.h>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <regex>
#include <string>
#include <vector>
using namespace std;

unsigned GCD(unsigned a, unsigned b) {
  if (a < b)
    return GCD(b, a);
  unsigned r;
  while ((r = a % b)) {
    a = b;
    b = r;
  }
  return b;
}

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;
}

int main() {
  long long A, B;
  cin >> A >> B;
  long long gcd = GCD(A, B);
  vector<pair<long long, long long>> v;
  v = prime_factorize(gcd);
  cout << 1 + v.size() << endl;
}

Fixed submission:
#include <algorithm>
#include <bits/stdc++.h>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <regex>
#include <string>
#include <vector>
using namespace std;

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

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;
}

int main() {
  long long A, B;
  cin >> A >> B;
  long long gcd = GCD(A, B);
  vector<pair<long long, long long>> v;
  v = prime_factorize(gcd);
  cout << 1 + v.size() << endl;
}
Problem p02900 (C++)

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

using namespace std;

typedef long long int ll;
const int INF = 1 << 30;
const long long LINF = 1LL << 60;

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

bool is_prime(ll x) {
  for (ll i = 2; i * i <= x; i++) {
    if (x % i == 0)
      return false;
  }
  return true;
}

int main() {
  ll a, b;
  cin >> a >> b;
  ll g = gcd(a, b);
  set<ll> st;
  st.insert(1);
  if (is_prime(g))
    st.insert(g);
  ll ans = 0;
  for (int i = 1; i * i <= g; i++) {
    if (g % i == 0) {
      if (is_prime(i))
        ans++;
      if (is_prime(g / i))
        ans++;
    }
  }
  if (g == 1)
    ans--;
  cout << ans << endl;
  return 0;
}


Fixed submission:
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long int ll;
const int INF = 1 << 30;
const long long LINF = 1LL << 60;

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

bool is_prime(ll x) {
  for (ll i = 2; i * i <= x; i++) {
    if (x % i == 0)
      return false;
  }
  return true;
}

int main() {
  ll a, b;
  cin >> a >> b;
  ll g = gcd(a, b);
  set<ll> st;
  st.insert(1);
  if (is_prime(g))
    st.insert(g);
  ll ans = 0;
  for (ll i = 1; i * i <= g; i++) {
    if (g % i == 0) {
      if (is_prime(i))
        ans++;
      if (is_prime(g / i))
        ans++;
    }
  }
  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 rep(i, n) for (int(i) = (0); (i) < (int)(n); ++(i))
using ll = long long;
using namespace std;

map<ll, ll> prime_factor(ll x) {
  map<ll, ll> ret;
  for (ll a = 2; a < x; ++a) {
    if (x % a == 0) {
      ret[a]++;
      x /= a;
      while (x % a == 0) {
        ret[a]++;
        x /= a;
      }
    }
  }
  if (x != 1)
    ret[x] = 1;
  return ret;
}

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

  ll G = __gcd(A, B);
  cout << prime_factor(G).size() + 1 << endl;
}


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

map<ll, ll> prime_factor(ll x) {
  map<ll, ll> ret;
  for (ll a = 2; a * a <= x; ++a) {
    if (x % a == 0) {
      ret[a]++;
      x /= a;
      while (x % a == 0) {
        ret[a]++;
        x /= a;
      }
    }
  }
  if (x != 1)
    ret[x] = 1;
  return ret;
}

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

  ll G = __gcd(A, B);
  cout << prime_factor(G).size() + 1 << endl;
}
Problem p02900 (C++)

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

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

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

  long long int g = GCL(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++;
  cout << ans << endl;
}

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

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

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

  long long int g = GCL(a, b);

  int ans = 1;
  for (int i = 2; i <= sqrt(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>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef pair<int, int> P;
typedef long long ll;
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

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

vector<pair<ll, int>> factorize(ll n) {
  vector<pair<ll, int>> res;
  for (int i = 2; i * i <= n; i++) {
    if (n % i != 0)
      continue;
    res.push_back(make_pair(i, 0));
    while (n % i == 0) {
      res.back().second++;
      n /= i;
    }
  }
  if (n != 1)
    res.push_back(make_pair(n, 1));
  return res;
}

int main() {
  ll a, b;
  cin >> a >> b;
  ll g = gcd(a, b);
  auto f = factorize(g);
  ll ans = f.size() + 1;
  cout << ans << endl;
}

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

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

vector<pair<ll, int>> factorize(ll n) {
  vector<pair<ll, int>> res;
  for (ll i = 2; i * i <= n; i++) {
    if (n % i != 0)
      continue;
    res.push_back(make_pair(i, 0));
    while (n % i == 0) {
      res.back().second++;
      n /= i;
    }
  }
  if (n != 1)
    res.push_back(make_pair(n, 1));
  return res;
}

int main() {
  ll a, b;
  cin >> a >> b;
  ll g = gcd(a, b);
  auto f = factorize(g);
  ll ans = f.size() + 1;
  cout << ans << endl;
}
Problem p02900 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define RREP(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, k, n) for (int i = (k); i < (int)(n); i++)
#define all(i, n) (i), (i + n)

int dx4[4] = {1, 0, -1, 0};
int dy4[4] = {0, -1, 0, 1};
int dx8[8] = {1, 0, -1, 1, -1, 1, 0, -1};
int dy8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
int dx9[9] = {0, 1, 0, -1, 1, -1, 1, 0, -1};
int dy9[9] = {0, 1, 1, 1, 0, 0, -1, -1, -1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;
typedef pair<ll, ll> PLL;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6 + 1;
const ll mod = 1000000007;
// << fixed << setprecision
// --------------------------------------
ll gcd(ll a, ll b) {
  if (b == 0)
    return a;
  return gcd(b, a % b);
}

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

ll a, b;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> a >> b;
  ll gc = gcd(a, b);

  auto mp = prime_factor(gc);
  cout << mp.size() + 1 << endl;
}


Fixed submission:
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define RREP(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, k, n) for (int i = (k); i < (int)(n); i++)
#define all(i, n) (i), (i + n)

int dx4[4] = {1, 0, -1, 0};
int dy4[4] = {0, -1, 0, 1};
int dx8[8] = {1, 0, -1, 1, -1, 1, 0, -1};
int dy8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
int dx9[9] = {0, 1, 0, -1, 1, -1, 1, 0, -1};
int dy9[9] = {0, 1, 1, 1, 0, 0, -1, -1, -1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;
typedef pair<ll, ll> PLL;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6 + 1;
const ll mod = 1000000007;
// << fixed << setprecision
// --------------------------------------
ll gcd(ll a, ll b) {
  if (b == 0)
    return a;
  return gcd(b, a % b);
}

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

ll a, b;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> a >> b;
  ll gc = gcd(a, b);

  auto mp = prime_factor(gc);
  cout << mp.size() + 1 << endl;
}
Problem p02900 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
long long a, b;
/*
int get(int x)
{
        if(x==fa[x])	return x;
        return fa[x]=get(fa[x]);
}//路径压缩
int merge(int x,int y)
{
        fa[get(x)]=get(y);
}//合并 */
int ans = 1;
int main() {
  cin >> a >> b;
  if (a < b) {
    long long c = a;
    a = b;
    b = c;
  }
  //	cout<<a;
  while (b != 0) {
    a = a % b;
    if (a < b) {
      long long c = a;
      a = b;
      b = c;
    }
  }
  // cout<<a;
  for (int i = 2; i * i <= a; i++) {
    if (a % i == 0) {
      ans++;
      while (a % i == 0)
        a /= i;
    }
  }
  if (a > 1)
    ans++;
  cout << ans;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
long long a, b;
/*
int get(int x)
{
        if(x==fa[x])	return x;
        return fa[x]=get(fa[x]);
}//路径压缩
int merge(int x,int y)
{
        fa[get(x)]=get(y);
}//合并 */
int ans = 1;
int main() {
  cin >> a >> b;
  if (a < b) {
    long long c = a;
    a = b;
    b = c;
  }
  //	cout<<a;
  while (b != 0) {
    a = a % b;
    if (a < b) {
      long long c = a;
      a = b;
      b = c;
    }
  }
  // cout<<a;
  for (int i = 2; (long long)i * i <= a; i++) {
    if (a % i == 0) {
      ans++;
      while (a % i == 0)
        a /= i;
    }
  }
  if (a > 1)
    ans++;
  cout << ans;
  return 0;
}
Problem p02900 (C++)

Buggy submission (status: Time Limit Exceeded):
//  ROAD TO GREEN
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <vector>

#define ll long long
#define uint unsigned int
#define ull unsigned ll

using namespace std;
const ll MAXN = 2e9 + 2;
const ll SIZE = 1e6 + 2;

int main() {
  ll a, b;
  cin >> a >> b;
  ll gcd = __gcd(a, b);
  int i = 2;
  int cnt = 1;
  while (gcd > 1) {
    if (gcd % i == 0) {
      cnt++;
      while (gcd % i == 0) {
        gcd /= i;
      }
    }
    i++;
    if (i * i > gcd)
      break;
  }
  if (gcd > 1)
    cnt++;
  cout << cnt << endl;
  return 0;
}


Fixed submission:
//  ROAD TO GREEN
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <vector>

#define ll long long
#define uint unsigned int
#define ull unsigned ll

using namespace std;
const ll MAXN = 2e9 + 2;
const ll SIZE = 1e6 + 2;

int main() {
  ll a, b;
  cin >> a >> b;
  ll gcd = __gcd(a, b);
  ll i = 2;
  ll cnt = 1;
  while (gcd > 1) {
    if (gcd % i == 0) {
      cnt++;
      while (gcd % i == 0) {
        gcd /= i;
      }
    }
    i++;
    if (i * i > gcd)
      break;
  }
  if (gcd > 1)
    cnt++;
  cout << cnt << endl;
  return 0;
}
Problem p02900 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
set<int> fact(ll n) {
  set<int> res;
  for (int i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      res.insert(i);
      while (n % i == 0)
        n /= i;
    }
  }
  if (n > 1)
    res.insert(n);
  return res;
}

int main() {
  ll a, b;
  cin >> a >> b;
  cout << fact(gcd(a, b)).size() + 1 << endl;
}

Fixed submission:
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
set<ll> fact(ll n) {
  set<ll> res;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      res.insert(i);
      while (n % i == 0)
        n /= i;
    }
  }
  if (n > 1)
    res.insert(n);
  return res;
}

int main() {
  ll a, b;
  cin >> a >> b;
  cout << fact(gcd(a, b)).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;
  cin >> A >> B;

  vector<long long> av;
  for (long long i = 1; i * i <= A; i++) {
    if (A % i == 0) {
      av.push_back(i);
      if (i * i != A)
        av.push_back(A / i);
    }
  }

  vector<long long> bv;
  for (long long i = 1; i * i <= B; i++) {
    if (B % i == 0) {
      bv.push_back(i);
      if (i * i != B)
        bv.push_back(B / i);
    }
  }

  vector<long long> cv;
  for (long long i = 0; i < av.size(); i++) {
    for (long long j = 0; j < bv.size(); j++) {
      if (av[i] == bv[j])
        cv.push_back(av[i]);
    }
  }

  // sort(cv.begin(),cv.end());

  vector<long long> dv;
  for (long long i = 0; i < cv.size(); i++) {
    bool flag = true;
    for (long long j = 2; j < cv[i]; j++) {
      if (cv[i] % j == 0) {
        flag = false;
        break;
      }
    }
    if (flag == true)
      dv.push_back(cv[i]);
  }

  cout << dv.size() << endl;
  return 0;
}

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

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

  vector<long long> av;
  for (long long i = 1; i * i <= A; i++) {
    if (A % i == 0) {
      av.push_back(i);
      if (i * i != A)
        av.push_back(A / i);
    }
  }

  vector<long long> bv;
  for (long long i = 1; i * i <= B; i++) {
    if (B % i == 0) {
      bv.push_back(i);
      if (i * i != B)
        bv.push_back(B / i);
    }
  }

  vector<long long> cv;
  for (long long i = 0; i < av.size(); i++) {
    for (long long j = 0; j < bv.size(); j++) {
      if (av[i] == bv[j])
        cv.push_back(av[i]);
    }
  }

  // sort(cv.begin(),cv.end());

  vector<long long> dv;
  for (long long i = 0; i < cv.size(); i++) {
    bool flag = true;
    if (cv[i] == 1)
      flag = true;
    else if (cv[i] == 2)
      flag = true;
    else if (cv[i] % 2 == 0)
      flag = false;
    else {
      for (long long j = 3; j * j <= cv[i]; j += 2) {
        if (cv[i] % j == 0) {
          flag = false;
          break;
        }
      }
    }
    if (flag == true)
      dv.push_back(cv[i]);
  }

  cout << dv.size() << endl;
  return 0;
}
Problem p02900 (C++)

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

using namespace std;
#define all(a) a.begin(), a.end()
using ll = long long;
const int INF = 1 << 30;
const ll INFll = 1LL << 62;
const int mod = (1e9) + 7;
using P = pair<ll, ll>;

int main() {
  ll a, b;
  cin >> a >> b;
  ll g = __gcd(a, b);
  map<ll, int> co;
  for (int p = 2; p * p <= g; ++p) {
    while (g % p == 0) {
      co[p]++;
      g /= p;
    }
  }
  if (g != 1)
    co[g]++;
  ll ans = co.size() + 1;
  cout << ans << endl;
  return 0;
}

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

using namespace std;
#define all(a) a.begin(), a.end()
using ll = long long;
const int INF = 1 << 30;
const ll INFll = 1LL << 62;
const int mod = (1e9) + 7;
using P = pair<ll, ll>;

int main() {
  ll a, b;
  cin >> a >> b;
  ll g = __gcd(a, b);
  map<ll, int> co;
  for (ll p = 2; p * p <= g; ++p) {
    while (g % p == 0) {
      co[p]++;
      g /= p;
    }
  }
  if (g != 1)
    co[g]++;
  ll ans = co.size() + 1;
  cout << ans << endl;
  return 0;
}
Problem p02900 (C++)

Buggy submission (status: Time Limit Exceeded):
// Bismillahir Rahmanir Rahim
#include <bits/stdc++.h>
using namespace std;
#define ios                                                                    \
  ios_base::sync_with_stdio(0);                                                \
  cin.tie(NULL);                                                               \
  cout.tie(NULL)
#define ll long long
#define endl '\n'
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
bool sortbysec(const pair<ll, ll> &a, const pair<ll, ll> &b) {
  return (a.second < b.second);
}

int main() {
  ios;
  ll a, b;
  cin >> a >> b;
  ll g = __gcd(a, b);
  map<ll, ll> m;
  m[1] = 1;
  for (int i = 2; i * i <= g; i++) {
    if (g % i == 0) {
      m[i] = 1;
      while (g % i == 0)
        g /= i;
    }
  }
  m[g] = 1;
  ll sum = 0;
  map<ll, ll>::iterator it;
  for (it = m.begin(); it != m.end(); it++)
    sum += it->ss;
  cout << sum << endl;
}


Fixed submission:
// Bismillahir Rahmanir Rahim
#include <bits/stdc++.h>
using namespace std;
#define ios                                                                    \
  ios_base::sync_with_stdio(0);                                                \
  cin.tie(NULL);                                                               \
  cout.tie(NULL)
#define ll long long
#define endl '\n'
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
bool sortbysec(const pair<ll, ll> &a, const pair<ll, ll> &b) {
  return (a.second < b.second);
}

int main() {
  ios;
  ll a, b;
  cin >> a >> b;
  ll g = __gcd(a, b);
  map<ll, ll> m;
  m[1] = 1;
  for (ll i = 2; i * i <= g; i++) {
    if (g % i == 0) {
      m[i] = 1;
      while (g % i == 0)
        g /= i;
    }
  }
  m[g] = 1;
  ll sum = 0;
  map<ll, ll>::iterator it;
  for (it = m.begin(); it != m.end(); it++)
    sum += it->ss;
  cout << sum << endl;
}
Problem p02900 (C++)

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

vector<pair<long long, long long>> prime_foctorize(long long N) {
  vector<pair<long long, long long>> res;
  for (long long i = 2; i <= N; i++) {
    if (N % i != 0)
      continue;
    long long ex = 0;
    while (N % i == 0) {
      ex++;
      N /= i;
    }
    res.push_back({i, ex});
  }
  if (N != 1)
    res.push_back({N, 1});
  return res;
}

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

  long long X = __gcd(A, B);
  const auto &pf = prime_foctorize(X);
  cout << pf.size() + 1 << endl;
}

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

vector<pair<long long, long long>> prime_foctorize(long long N) {
  vector<pair<long long, long long>> res;
  for (long long i = 2; i * i <= N; i++) {
    if (N % i != 0)
      continue;
    long long ex = 0;
    while (N % i == 0) {
      ex++;
      N /= i;
    }
    res.push_back({i, ex});
  }
  if (N != 1)
    res.push_back({N, 1});
  return res;
}

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

  long long X = __gcd(A, B);
  const auto &pf = prime_foctorize(X);
  cout << pf.size() + 1 << endl;
}
Problem p02900 (C++)

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

int main() {
  ll a, b;
  cin >> a >> b;
  vector<ll> a_prime;
  a_prime.push_back(1);
  int c = a;
  for (int i = 2; i * i <= a; i++) {
    if (c % i == 0) {
      a_prime.push_back(i);
      while (c % i == 0) {
        c /= i;
      }
    }
  }
  if (c != 1) {
    a_prime.push_back(c);
  }
  int count = 0;
  for (int i = 0; i < a_prime.size(); i++) {
    ll k = a_prime.at(i);
    if (b % k == 0)
      count++;
  }
  cout << count << endl;
}


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

int main() {
  ll a, b;
  cin >> a >> b;
  vector<ll> a_prime;
  a_prime.push_back(1);
  ll c = a;
  for (ll i = 2; i * i <= a; i++) {
    if (c % i == 0) {
      a_prime.push_back(i);
      while (c % i == 0) {
        c /= i;
      }
    }
  }
  if (c != 1) {
    a_prime.push_back(c);
  }
  int count = 0;
  for (int i = 0; i < a_prime.size(); i++) {
    ll k = a_prime.at(i);
    if (b % k == 0)
      count++;
  }
  cout << count << endl;
}
Problem p02900 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, k, h = 0, ans = 0;
  cin >> a >> b;
  k = 1;
  while (k != 0) {
    k = max(a, b) % min(a, b);
    a = min(a, b);
    b = k;
  }
  k = a;
  if (k == 1) {
    cout << 1;
    return 0;
  }
  if (k == 2 || k == 3) {
    cout << 2;
    return 0;
  }
  for (int i = 2; i < sqrt(a) + 1; i++) {
    while (k % i == 0) {
      k = k / i;
      h = 1;
    }
    if (h == 1) {
      ans++;
    }
    h = 0;
  }
  if (k == 1) {
    cout << ans + 1;
  } else {
    cout << ans + 2;
  }
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long a, b, k, h = 0, ans = 0;
  cin >> a >> b;
  k = 1;
  while (k != 0) {
    k = max(a, b) % min(a, b);
    a = min(a, b);
    b = k;
  }
  k = a;
  if (k == 1) {
    cout << 1;
    return 0;
  }
  if (k == 2 || k == 3) {
    cout << 2;
    return 0;
  }
  for (int i = 2; i < sqrt(a) + 1; i++) {
    while (k % i == 0) {
      k = k / i;
      h = 1;
    }
    if (h == 1) {
      ans++;
    }
    h = 0;
  }
  if (k == 1) {
    cout << ans + 1;
  } else {
    cout << ans + 2;
  }
}
Problem p02900 (C++)

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

ll min(ll a, ll b) {
  if (a < b)
    return a;
  return b;
}
ll max(ll a, ll b) {
  if (a > b)
    return a;
  return b;
}
ll gcd(ll x, ll y) {
  if (x < y)
    return gcd(y, x);
  if (y == 0)
    return x;
  return gcd(y, x % y);
}

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


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

ll min(ll a, ll b) {
  if (a < b)
    return a;
  return b;
}
ll max(ll a, ll b) {
  if (a > b)
    return a;
  return b;
}
ll gcd(ll x, ll y) {
  if (x < y)
    return gcd(y, x);
  if (y == 0)
    return x;
  return gcd(y, x % y);
}

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

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int a, b;
  cin >> a >> b;
  long long int t;
  long long int x, y;
  x = max(a, b);
  y = min(a, b);
  while (true) {
    if (x % y == 0) {
      t = y;
      break;
    } else {
      x = x % y;
      swap(x, y);
    }
  }
  long long int ans = 1;
  for (int i = 2; i * i <= t; i++) {
    if (t % i == 0) {
      ans++;
      while (t % i == 0) {
        t = t / i;
      }
    }
  }
  if (t != 1)
    ans++;
  cout << ans;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int a, b;
  cin >> a >> b;
  long long int t;
  long long int x, y;
  x = max(a, b);
  y = min(a, b);
  while (true) {
    if (x % y == 0) {
      t = y;
      break;
    } else {
      x = x % y;
      swap(x, y);
    }
  }
  long long int ans = 1;
  for (long long int i = 2; i * i <= t; i++) {
    if (t % i == 0) {
      ans++;
      while (t % i == 0) {
        t = t / i;
      }
    }
  }
  if (t != 1)
    ans++;
  cout << ans;
}
Problem p02900 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
#define ms(x, y) memset(x, y, sizeof(x))
#define lowbit(x) ((x) & (-x))
#define sqr(x) ((x) * (x))
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;

void run_case() {
  LL a, b;
  cin >> a >> b;
  LL gcd = __gcd(a, b);
  int ans = 0;
  for (LL i = 1; i * i <= gcd; ++i) {
    if (gcd % i == 0) {
      ans++;
      while (gcd % i == 0)
        gcd /= i;
    }
  }
  if (gcd > 1)
    ans++;
  cout << ans;
}

int main() {
  // freopen("input", "r", stdin);
  ios::sync_with_stdio(false), cin.tie(0);
  cout.flags(ios::fixed);
  cout.precision(9);
  // int t; cin >> t;
  // while(t--)
  run_case();
  cout.flush();
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define ms(x, y) memset(x, y, sizeof(x))
#define lowbit(x) ((x) & (-x))
#define sqr(x) ((x) * (x))
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;

void run_case() {
  LL a, b;
  cin >> a >> b;
  LL gcd = __gcd(a, b);
  int ans = 1;
  for (LL i = 2; i * i <= gcd; ++i) {
    if (gcd % i == 0) {
      ans++;
      while (gcd % i == 0)
        gcd /= i;
    }
  }
  if (gcd > 1)
    ans++;
  cout << ans;
}

int main() {
  // freopen("input", "r", stdin);
  ios::sync_with_stdio(false), cin.tie(0);
  cout.flags(ios::fixed);
  cout.precision(9);
  // int t; cin >> t;
  // while(t--)
  run_case();
  cout.flush();
  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++)
using namespace std;
using ll = long long;
const ll MOD = 1000000007;

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

  ll ans = 1;
  if (n % 2 == 0) {
    ans++;
    while (n % 2 == 0)
      n /= 2;
  }

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

  cout << ans << endl;
}


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

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

  ll ans = 1;
  if (n % 2 == 0) {
    ans++;
    while (n % 2 == 0)
      n /= 2;
  }

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

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

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

int main() {
  ll a, b;
  cin >> a >> b;
  ll tmp1, n;
  while (true) {
    tmp1 = a;
    a = b;
    b = tmp1 % b;
    if (b == 0) {
      n = a;
      break;
    }
  }

  ll ans = 1, cnt = 0;
  if (n % 2 == 0) {
    ans++;
    while (n % 2 == 0)
      n /= 2;
  }

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

  cout << ans << endl;
}


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

int main() {
  ll a, b;
  cin >> a >> b;
  ll tmp1, n;
  while (true) {
    tmp1 = a;
    a = b;
    b = tmp1 % b;
    if (b == 0) {
      n = a;
      break;
    }
  }

  ll ans = 1, cnt = 0;
  if (n % 2 == 0) {
    ans++;
    while (n % 2 == 0)
      n /= 2;
  }

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

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

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

long int gcd(long int a, long int b) {
  long int c;
  if (a > b)
    swap(a, b);
  while (b % a > 0) {
    c = b % a;
    b = a;
    a = c;
  }
  return a;
}

int main() {
  long int A, B;
  cin >> A >> B;
  vector<int> p;
  long int g = gcd(A, B);
  long int n = 1;
  vector<int> prime;
  for (int i = 2; i * i <= g; i++) {
    bool check = true;
    for (int p : prime) {
      if (i % p == 0) {
        check = false;
        break;
      }
    }
    if (check)
      prime.push_back(i);
  }
  for (int i : prime) {
    while (g % i == 0) {
      g /= i;
      if (n < i) {
        n = i;
        p.push_back(i);
      }
    }
  }
  if (g > n)
    p.push_back(g);
  cout << (int)p.size() + 1 << endl;
}

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

long int gcd(long int a, long int b) {
  long int c;
  if (a > b)
    swap(a, b);
  while (b % a > 0) {
    c = b % a;
    b = a;
    a = c;
  }
  return a;
}

int main() {
  long int A, B;
  cin >> A >> B;
  vector<int> p;
  long int g = gcd(A, B);
  long int n = 1;
  auto rg = sqrt(g);
  for (int i = 2; i <= rg; i++) {
    while (g % i == 0) {
      g /= i;
      if (n < i) {
        n = i;
        p.push_back(i);
      }
    }
  }
  if (g > n)
    p.push_back(g);
  cout << (int)p.size() + 1 << endl;
}
Problem p02900 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n1, n2, cnt = 1;
  cin >> n1 >> n2;
  long long int n = __gcd(n1, n2);
  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 << endl;

  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n1, n2, cnt = 1;
  cin >> n1 >> n2;
  long long int n = __gcd(n1, n2);
  for (long long i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      cnt++;
      while (n % i == 0)
        n /= i;
    }
  }

  if (n > 1)
    cnt++;
  cout << cnt << endl;

  return 0;
}
Problem p02900 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define inp(X) cin >> X
#define out(X) cout << X << endl
#define out16(X) cout << setprecision(16) << X << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep2(i, f, n) for (int i = f; i < n; i++)
#define MAX(A) *max_element(A.begin(), A.end())
#define MIN(A) *min_element(A.begin(), A.end())
#define SORT(A) sort(A.begin(), A.end())
#define REV(A) reverse(A.begin(), A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vd = std::vector<double>;
using vvd = std::vector<std::vector<double>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using namespace std;
#define MOD 1000000007
#define INF 1000000001
#define LL_INF 1001001001001001001

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

int main(void) {
  ll a, b;
  cin >> a >> b;
  ll gcd = Gcd(a, b);
  int ans = 0;
  for (int i = 2; i * i <= gcd; i++) {
    if (gcd % i)
      continue;
    ans++;
    while (gcd % i == 0)
      gcd /= i;
  }
  if (gcd != 1)
    ans++;
  ans++;
  out(ans);
}


Fixed submission:
#include <bits/stdc++.h>
#define inp(X) cin >> X
#define out(X) cout << X << endl
#define out16(X) cout << setprecision(16) << X << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep2(i, f, n) for (int i = f; i < n; i++)
#define MAX(A) *max_element(A.begin(), A.end())
#define MIN(A) *min_element(A.begin(), A.end())
#define SORT(A) sort(A.begin(), A.end())
#define REV(A) reverse(A.begin(), A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vd = std::vector<double>;
using vvd = std::vector<std::vector<double>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using namespace std;
#define MOD 1000000007
#define INF 1000000001
#define LL_INF 1001001001001001001

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

int main(void) {
  ll a, b;
  cin >> a >> b;
  ll gcd = Gcd(a, b);
  ll ans = 0;
  for (ll i = 2; i * i <= gcd; i++) {
    if (gcd % i)
      continue;
    ans++;
    while (gcd % i == 0)
      gcd /= i;
  }
  if (gcd != 1)
    ans++;
  ans++;
  out(ans);
}
Problem p02900 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdlib>
#include <math.h>
#include <string>
#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define f first
#define s second
#define fast                                                                   \
  ios_base::sync_with_stdio(0);                                                \
  cin.tie(NULL);                                                               \
  cout.tie(NULL)
#define pb push_back
#define eb emplace_back
#define in insert
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define FOR(i, n, x) for (int i = x; i < n; i++)
#define OUT(a, e) FOR(i, e, 0) cout << a[i] << ' '
#define OUTV(a)                                                                \
  for (auto i : a)                                                             \
    cout << i << ' ';
#define maxim(a, n, mx) FOR(i, n, x) mx = max(mx, a[i]);

using namespace std;
const int N = 5e3;
int used[N];
vector<ll> d;

int main() {
  ll a, b;
  cin >> a >> b;
  ll n = __gcd(a, b);
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      d.pb(i);
      if (n / i != i)
        d.pb(n / i);
    }
  }
  sort(all(d));
  int ans = 0, cnt = 1, sz = d.size();
  FOR(i, sz, 0) {
    if (d[i] == 1)
      continue;
    if (used[i])
      continue;
    FOR(j, sz, 0) {
      if (d[j] % d[i] == 0)
        used[j] = 1;
    }
    cnt++;
  }
  cout << cnt;
  return 0;
}


Fixed submission:
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdlib>
#include <math.h>
#include <string>
#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define f first
#define s second
#define fast                                                                   \
  ios_base::sync_with_stdio(0);                                                \
  cin.tie(NULL);                                                               \
  cout.tie(NULL)
#define pb push_back
#define eb emplace_back
#define in insert
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define FOR(i, n, x) for (int i = x; i < n; i++)
#define OUT(a, e) FOR(i, e, 0) cout << a[i] << ' '
#define OUTV(a)                                                                \
  for (auto i : a)                                                             \
    cout << i << ' ';
#define maxim(a, n, mx) FOR(i, n, x) mx = max(mx, a[i]);

using namespace std;
const int N = 1e5;
int used[N];
vector<ll> d;

int main() {
  ll a, b;
  cin >> a >> b;
  ll n = __gcd(a, b);
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      d.pb(i);
      if (n / i != i)
        d.pb(n / i);
    }
  }
  sort(all(d));
  int ans = 0, cnt = 1, sz = d.size();
  FOR(i, sz, 0) {
    if (d[i] == 1)
      continue;
    if (used[i])
      continue;
    FOR(j, sz, 0) {
      if (d[j] % d[i] == 0)
        used[j] = 1;
    }
    cnt++;
  }
  cout << cnt;
  return 0;
}
Problem p02900 (C++)

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

using ll = long long;
using namespace std;

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

bool is_prime(ll n) {
  for (ll i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      return false;
    }
  }
  return true;
}

int main() {
  ll a, b;
  cin >> a >> b;
  ll g = gcd(a, b);
  int ans = 0;
  for (ll i = 1; i * i <= g; i++) {
    if (g % i == 0 && is_prime(i)) {
      ans++;
    }
    int rest = g / i;
    if (g % rest == 0 && is_prime(rest)) {
      ans++;
    }
    if (g == i * i && is_prime(i)) {
      ans--;
    }
  }
  cout << ans << endl;
  return 0;
}


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

using ll = long long;
using namespace std;

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

bool is_prime(ll n) {
  for (ll i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      return false;
    }
  }
  return true;
}

int main() {
  ll a, b;
  cin >> a >> b;
  ll g = gcd(a, b);
  int ans = 0;
  for (ll i = 1; i * i <= g; i++) {
    if (g % i == 0 && is_prime(i)) {
      ans++;
    }
    ll rest = g / i;
    if (g % rest == 0 && is_prime(rest)) {
      ans++;
    }
    if (g == i * i && is_prime(i)) {
      ans--;
    }
  }
  cout << ans << endl;
  return 0;
}
Problem p02900 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long a, b, res = 1;
  cin >> a >> b;
  long long gcd = __gcd(a, b);
  for (int i = 2; i * i <= gcd; i++) {
    bool ok = false;
    while (gcd % i == 0)
      gcd /= i, ok = true;
    res += ok;
  }
  res += (gcd != 1);
  cout << res << "\n";
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long a, b, res = 1;
  cin >> a >> b;
  long long gcd = __gcd(a, b);
  for (long long i = 2; i * i <= gcd; i++) {
    bool ok = false;
    while (gcd % i == 0)
      gcd /= i, ok = true;
    res += ok;
  }
  res += (gcd != 1);
  cout << res << "\n";
}
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 x, ll y) { return y == 0 ? x : gcd(y, x % y); }

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

  ll ans = 1;
  for (int i = 2; i * i <= maxNum; i++) {
    if (maxNum % i == 0) {
      ans++;
      while (maxNum % i == 0) {
        maxNum /= i;
      }
    }
  }
  if (maxNum != 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 x, ll y) { return y == 0 ? x : gcd(y, x % y); }

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

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

  return 0;
}