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

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


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


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

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

#define INF ((int)1e9)
#define INFLL ((ll)1e18)
#define MOD (1000000007LL)

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

int main(int argc, const char *argv[]) {
  ios_base::sync_with_stdio(false);
  ll A, B;
  cin >> A >> B;
  ll C = gcd(A, B);
  int Res = 1;
  for (int i = 2; i * i <= C; ++i) {
    if (C % i == 0) {
      ++Res;
      while (C % i == 0)
        C /= i;
    }
  }
  if (C != 1)
    ++Res;

  cout << Res << endl;

  return 0;
}


Fixed submission:
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

#define INF ((int)1e9)
#define INFLL ((ll)1e18)
#define MOD (1000000007LL)

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

int main(int argc, const char *argv[]) {
  ios_base::sync_with_stdio(false);
  ll A, B;
  cin >> A >> B;
  ll C = gcd(A, B);
  int Res = 1;
  for (ll i = 2; i * i <= C; ++i) {
    if (C % i == 0) {
      ++Res;
      while (C % i == 0)
        C /= i;
    }
  }
  if (C != 1)
    ++Res;

  cout << Res << endl;

  return 0;
}
Problem p02900 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
bool DEBUG = true;

// find maximum kouyakusuu
// souinsuu bunkai the maximum kouyakusuu
// return the num of kinds of soinsuu + 1

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

// bool isseen(vector<int>& primes, int num) {
//     bool seen  = false;
//     rep(pi, primes.size()){
//         if (num % primes[pi] == 0) {
//             seen = true;
//             break;
//         }
//     }
//     return seen;
// }

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

  ll greatest_common_divisor;
  if (A > B)
    greatest_common_divisor = gcd(A, B);
  else
    greatest_common_divisor = gcd(B, A);

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

Fixed submission:
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
bool DEBUG = true;

// find maximum kouyakusuu
// souinsuu bunkai the maximum kouyakusuu
// return the num of kinds of soinsuu + 1

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

// bool isseen(vector<int>& primes, int num) {
//     bool seen  = false;
//     rep(pi, primes.size()){
//         if (num % primes[pi] == 0) {
//             seen = true;
//             break;
//         }
//     }
//     return seen;
// }

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

  ll greatest_common_divisor;
  if (A > B)
    greatest_common_divisor = gcd(A, B);
  else
    greatest_common_divisor = gcd(B, A);

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

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

int Prime[1000000]; // Prime[i] = 1のときiは素数。0のときiは素数でない

void Eratosthenes(int n) { // n未満の素数を求める

  rep(i, n) { Prime[i] = 1; }

  Prime[0] = 0;
  Prime[1] = 0;
  for (int i = 2; i * i < n; i++) {
    if (Prime[i]) {
      for (int j = 2; i * j < n; j++) {
        Prime[i * j] = 0;
      }
    }
  }
}

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

  Eratosthenes(1000000);

  int ans = 1;
  for (int i = 2; i * i <= G; i++) {
    if (Prime[i] && G % i == 0) {
      ans++;
      while (G % i == 0) {
        G /= i;
      }
    }
  }
  if (G != 1) {
    ans++;
  }

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

Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

int Prime[1000000]; // Prime[i] = 1のときiは素数。0のときiは素数でない

void Eratosthenes(int n) { // n未満の素数を求める

  rep(i, n) { Prime[i] = 1; }

  Prime[0] = 0;
  Prime[1] = 0;
  for (int i = 2; i * i < n; i++) {
    if (Prime[i]) {
      for (int j = 2; i * j < n; j++) {
        Prime[i * j] = 0;
      }
    }
  }
}

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

  Eratosthenes(1000000);

  ll ans = 1LL;
  for (ll i = 2; i * i <= G; i++) {
    if (Prime[i] && 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: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

const int MOD = 1000000007;

// long long
using ll = long long;

// 出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

// begin() end()
#define all(x) (x).begin(), (x).end()

// for
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)

// 最大公約数
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<ll, int>> factorize(ll n) {
  vector<pair<ll, int>> res;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i)
      continue;
    res.emplace_back(i, 0);
    while (n % i == 0) {
      n /= i;
      res.back().second++;
    }
  }
  if (n != 1)
    res.emplace_back(n, 1);
  return res;
}

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

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

const int MOD = 1000000007;

// long long
using ll = long long;

// 出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

// begin() end()
#define all(x) (x).begin(), (x).end()

// for
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)

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

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

int main() {
  ll a, b;
  cin >> a >> b;
  ll g = gcd(a, b);
  auto f = factorize(g);
  int ans = f.size() + 1;
  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 long long ll;

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

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

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

  if (g != 1)
    ans++;

  cout << ans << endl;

  return 0;
}

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

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

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

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

  if (g != 1)
    ans++;

  cout << ans << endl;

  return 0;
}
Problem p02900 (C++)

Buggy submission (status: Time Limit Exceeded):
/**
 * @Author:      G_bg
 * @DateTime:    2019-09-28 20:22:27
 * @Description:
 */
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const double PI = 3.1415926535898;
const double E = 2.718281828459;
const int INF = 0x7fffffff;
const int mod = 1e9 + 7;
const int maxn = 1e5 + 10;
LL gcd(LL a, LL b) { return b == 0 ? a : gcd(b, a % b); }
int prime[maxn], m;
void decompose(LL n) {
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0) { // i一定是素数
      prime[++m] = i;
      while (n % i == 0)
        n /= i;
    }
  }
  if (n > 1)
    prime[++m] = n; // n是质数
}
int main(int argc, const char *argv[]) {
  ios::sync_with_stdio(0);
  cin.tie(0);
  LL a, b;
  cin >> a >> b;
  LL g = gcd(a, b);
  decompose(g);
  cout << m + 1 << endl;
  return 0;
}

Fixed submission:
/**
 * @Author:      G_bg
 * @DateTime:    2019-09-28 20:22:27
 * @Description:
 */
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const double PI = 3.1415926535898;
const double E = 2.718281828459;
const int INF = 0x7fffffff;
const int mod = 1e9 + 7;
const int maxn = 1e5 + 10;
LL gcd(LL a, LL b) { return b == 0 ? a : gcd(b, a % b); }
int prime[maxn], m;
void decompose(LL n) {
  for (LL i = 2; i * i <= n; i++) {
    if (n % i == 0) { // i一定是素数
      prime[++m] = i;
      while (n % i == 0)
        n /= i;
    }
  }
  if (n > 1)
    prime[++m] = n; // n是质数
}
int main(int argc, const char *argv[]) {
  ios::sync_with_stdio(0);
  cin.tie(0);
  LL a, b;
  cin >> a >> b;
  LL g = gcd(a, b);
  decompose(g);
  cout << m + 1 << endl;
  return 0;
}
Problem p02900 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define SORT(i) sort((i).begin(), (i).end())
#define INF 2000000000
constexpr ll mod = 1000000007;

ll gcd(ll x, ll y) { return y != 0 ? gcd(y, x % y) : x; }
vector<pair<ll, int>> factorize(ll N) {
  vector<pair<ll, int>> res;
  for (ll i = 0; i * i <= N; ++i) {
    if (N % i)
      continue;
    res.emplace_back(i, 0);
    while (N % i == 0) {
      N /= i;
      res.back().second++;
    }
  }
  if (N != 1)
    res.emplace_back(N, 1);
  return res;
}
int main() {
  ll A, B;
  cin >> A >> B;
  ll g = gcd(A, B);
  auto f = factorize(g);
  int ans = f.size() + 1;
  cout << ans << "\n";

  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define SORT(i) sort((i).begin(), (i).end())
#define INF 2000000000
constexpr ll mod = 1000000007;

ll gcd(ll x, ll y) { return y != 0 ? gcd(y, x % y) : x; }
vector<pair<ll, int>> factorize(ll N) {
  vector<pair<ll, int>> res;
  for (ll i = 2; i * i <= N; ++i) {
    if (N % i)
      continue;
    res.emplace_back(i, 0);
    while (N % i == 0) {
      N /= i;
      res.back().second++;
    }
  }
  if (N != 1)
    res.emplace_back(N, 1);
  return res;
}
int main() {
  ll A, B;
  cin >> A >> B;
  ll g = gcd(A, B);
  auto f = factorize(g);
  int ans = f.size() + 1;
  cout << ans << "\n";

  return 0;
}
Problem p02900 (C++)

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

typedef long long ll;

ll get_gcd(ll a, ll b) {
  if (a < b)
    swap(a, b);
  return ((a % b == 0 ? b : get_gcd(b, a % b)));
}

vector<pair<ll, ll>> prime_factorize(ll gcd) {
  vector<pair<ll, ll>> ans;

  for (int i = 2; i * i <= gcd; i++) {
    if (gcd % i != 0)
      continue;
    int ex = 0;
    while (gcd % i == 0) {
      ex++;
      gcd /= i;
    }
    ans.push_back({i, ex});
  }

  if (gcd != 1)
    ans.push_back({gcd, 1});

  return ans;
}

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

  vector<pair<ll, ll>> ans = prime_factorize(gcd);

  cout << ((int)ans.size() + 1) << endl;

  return 0;
}

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

typedef long long ll;

ll get_gcd(ll a, ll b) {
  if (a < b)
    swap(a, b);
  return ((a % b == 0 ? b : get_gcd(b, a % b)));
}

vector<pair<ll, ll>> prime_factorize(ll gcd) {
  vector<pair<ll, ll>> ans;

  for (ll i = 2; i * i <= gcd; i++) {
    if (gcd % i != 0)
      continue;
    int ex = 0;
    while (gcd % i == 0) {
      ex++;
      gcd /= i;
    }
    ans.push_back({i, ex});
  }

  if (gcd != 1)
    ans.push_back({gcd, 1});

  return ans;
}

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

  vector<pair<ll, ll>> ans = prime_factorize(gcd);

  cout << ((int)ans.size() + 1) << endl;

  return 0;
}
Problem p02900 (C++)

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

using namespace std;
using ll = long long int;

// num: 12 -> {2, 3}
// num は最大で1e12
set<int> get_factors(ll num) {
  ll n = num;
  set<int> ret;
  while (n % 2 == 0) {
    n /= 2;
    ret.insert(2);
  }
  // nは奇数
  for (int i = 3; i * i <= num; i += 2) {
    while (n % i == 0) {
      n /= i;
      ret.insert(i);
    }
  }
  if (n != 1) {
    ret.insert(n);
  }
  return ret;
}

int main() {
  // your code goes here
  ll A, B;
  cin >> A >> B;

  auto res1 = get_factors(A);
  auto res2 = get_factors(B);

  int cnt = 0;
  for (auto e : res1) {
    cnt += res2.count(e);
  }
  ++cnt;
  cout << cnt << endl;
  return 0;
}

Fixed submission:
#include <iostream>
#include <set>

using namespace std;
using ll = long long int;

// num: 12 -> {2, 3}
// num は最大で1e12
set<int> get_factors(ll num) {
  ll n = num;
  set<int> ret;
  while (n % 2 == 0) {
    n /= 2;
    ret.insert(2);
  }
  // nは奇数
  for (ll i = 3; i * i <= num; i += 2) {
    while (n % i == 0) {
      n /= i;
      ret.insert(i);
    }
  }
  if (n != 1) {
    ret.insert(n);
  }
  return ret;
}

int main() {
  // your code goes here
  ll A, B;
  cin >> A >> B;

  auto res1 = get_factors(A);
  auto res2 = get_factors(B);

  int cnt = 0;
  for (auto e : res1) {
    cnt += res2.count(e);
  }
  ++cnt;
  cout << cnt << endl;
  return 0;
}
Problem p02900 (C++)

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

using namespace std;
using ll = long long;

template <typename T> T gcd(T a, T b) {
  if (a < b)
    return gcd(b, a);
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll A, B;
  cin >> A >> B;
  ll gcdn = gcd(A, B);
  ll gcdcopy = gcdn;
  int res = 1;
  for (int i = 2; i * i <= gcdn; i++) {
    if (gcdcopy % i != 0)
      continue;
    res++;
    while (gcdcopy % i == 0) {
      gcdcopy /= i;
    }
  }
  if (gcdcopy > 1) {
    res++;
  }
  cout << res << '\n';
  return 0;
}


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

using namespace std;
using ll = long long;

template <typename T> T gcd(T a, T b) {
  if (a < b)
    return gcd(b, a);
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll A, B;
  cin >> A >> B;
  ll gcdn = gcd(A, B);
  ll gcdcopy = gcdn;
  int res = 1;
  for (ll i = 2; i * i <= gcdn; i++) {
    if (gcdcopy % i != 0)
      continue;
    res++;
    while (gcdcopy % i == 0) {
      gcdcopy /= i;
    }
  }
  if (gcdcopy > 1) {
    res++;
  }
  cout << res << '\n';
  return 0;
}
Problem p02900 (C++)

Buggy submission (status: Time Limit Exceeded):
#include "bits/stdc++.h"
using namespace std;
#define INF 1000000000
#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() // 降順
const long long mod = 1e9 + 7;
typedef priority_queue<int> PQ;
typedef vector<long long> Vl;
typedef vector<int> VI; // VI a(n);
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<VS> VSS;
typedef vector<VC> VCC;
typedef vector<VI> VVI; // VVI a(n,vector<int>(m)) n * m
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef map<int, int> MP; // MP a;
typedef vector<pair<int, int>> PS;
typedef long long ll; // ll とdoubleは違う
// stack<int> st;
//  cout << << endl;
//  cin >> ;
template <typename T> // operator << (cout,a);
ostream &operator<<(ostream &os, vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
  os << "}";
  return os;
}

template <typename T> T gcd(T a, T b) { return b != 0 ? gcd(b, a % b) : a; }

template <typename T> vector<pair<T, int>> prime_factorization(T n) {
  vector<pair<T, int>> res;
  for (T i = 2; i * i <= n; i++) {
    int cnt = 0;
    while (n % i == 0) {
      n /= i;
      cnt++;
    }
    if (cnt > 0)
      res.push_back(make_pair(i, cnt));
  }
  if (n > 1)
    res.push_back(make_pair(n, 1));
  return res;
}

int main() {
  int a, b, x = 0, y = 0, d = 0, n, h, w, k, max = -100, ans = 0, ptr = 0,
            sum = 0;
  string s;
  cin >> a >> b;
  a = gcd(a, b);
  cout << prime_factorization(a).size() + 1 << endl;
  return 0;
}

Fixed submission:
#include "bits/stdc++.h"
using namespace std;
#define INF 1000000000
#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() // 降順
const long long mod = 1e9 + 7;
typedef priority_queue<int> PQ;
typedef vector<long long> Vl;
typedef vector<int> VI; // VI a(n);
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<VS> VSS;
typedef vector<VC> VCC;
typedef vector<VI> VVI; // VVI a(n,vector<int>(m)) n * m
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef map<int, int> MP; // MP a;
typedef vector<pair<int, int>> PS;
typedef long long ll; // ll とdoubleは違う
// stack<int> st;
//  cout << << endl;
//  cin >> ;
template <typename T> // operator << (cout,a);
ostream &operator<<(ostream &os, vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
  os << "}";
  return os;
}

template <typename T> T gcd(T a, T b) { return b != 0 ? gcd(b, a % b) : a; }

template <typename T> vector<pair<T, int>> prime_factorization(T n) {
  vector<pair<T, int>> res;
  for (T i = 2; i * i <= n; i++) {
    int cnt = 0;
    while (n % i == 0) {
      n /= i;
      cnt++;
    }
    if (cnt > 0)
      res.push_back(make_pair(i, cnt));
  }
  if (n > 1)
    res.push_back(make_pair(n, 1));
  return res;
}

int main() {
  ll a, b, x = 0, y = 0, d = 0, n, h, w, k, max = -100, ans = 0, ptr = 0,
           sum = 0;
  string s;
  cin >> a >> b;
  a = gcd(a, b);
  cout << prime_factorization(a).size() + 1 << endl;
  return 0;
}
Problem p02900 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, ll> P;

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

map<ll, ll> prime_factor(ll n) {
  map<ll, ll> res;
  for (
      ll i = 2; i * i <= n;
      i++) // i以下はすでに試しているからi*iよりnが小さかったらもう割り切れるものはない
  {
    while (n % i == 0) {
      ++res[i];
      n /= i;
    }
  }
  if (n != 1)
    res[n] = 1;
  return res;
}

int main() {
  ll a, b;
  cin >> a >> b;
  ll g = gcd(a, b);
  vector<ll> prime(g + 1);
  vector<bool> is_prime(g + 1, true);
  ll p = 0;
  auto st = prime_factor(g);
  cout << st.size() + 1;
}

Fixed submission:
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, ll> P;

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

map<ll, ll> prime_factor(ll n) {
  map<ll, ll> res;
  for (
      ll i = 2; i * i <= n;
      i++) // i以下はすでに試しているからi*iよりnが小さかったらもう割り切れるものはない
  {
    while (n % i == 0) {
      ++res[i];
      n /= i;
    }
  }
  if (n != 1)
    res[n] = 1;
  return res;
}

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

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

const int s = 1000000;
bool vis[s + 1];
bool is_prime[s + 1];

int main() {
  long long int a, b, i, j, count = 0, num1, num2;
  cin >> a >> b;
  is_prime[0] = true;
  for (i = 2; i * i <= s; i++) {
    if (!is_prime[i]) {
      for (j = i * i; j <= s; j += i) {
        is_prime[j] = true;
      }
    }
  }
  num1 = a, num2 = b;
  for (i = 1; i * i <= a; i++) {
    if (!is_prime[i]) {
      if (a % i == 0) {
        vis[i] = true;
      }
      while (i != 1 && num1 % i == 0) {
        num1 = (num1 / i);
      }
    }
  }
  for (i = 1; i * i <= b; i++) {
    if (!is_prime[i]) {
      if (b % i == 0) {
        if (vis[i]) {
          count++;
        } else if (i == num1)
          count++;
        while (i != 1 && num2 % i == 0) {
          num2 /= i;
        }
      }
    }
  }
  if (num1 != 1 && num2 != 1 && num1 == num2) {
    if (!is_prime[num1])
      count++;
  } else if (num2 != 1 && num2 <= s && vis[num2])
    count++;
  cout << count << "\n";
}

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

const int s = 1000000;
bool vis[s + 1];
bool is_prime[s + 1];

int main() {
  long long int a, b, i, j, count = 0, num1, num2;
  cin >> a >> b;
  is_prime[0] = true;
  for (i = 2; i * i <= s; i++) {
    if (!is_prime[i]) {
      for (j = i * i; j <= s; j += i) {
        is_prime[j] = true;
      }
    }
  }
  num1 = a, num2 = b;
  for (i = 1; i * i <= a; i++) {
    if (!is_prime[i]) {
      if (a % i == 0) {
        vis[i] = true;
      }
      while (i != 1 && num1 % i == 0) {
        num1 = (num1 / i);
      }
    }
  }
  for (i = 1; i * i <= b; i++) {
    if (!is_prime[i]) {
      if (b % i == 0) {
        if (vis[i]) {
          count++;
        } else if (i == num1)
          count++;
        while (i != 1 && num2 % i == 0) {
          num2 /= i;
        }
      }
    }
  }
  if (num1 != 1 && num2 != 1 && num1 == num2) {
    count++;
  } else if (num2 != 1 && num2 <= s && vis[num2])
    count++;
  cout << count << "\n";
}
Problem p02900 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <iostream>
#include <math.h>
#include <string.h>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
long long int mod = 1e9 + 7;
bool debug = false;
typedef long long ll;
int main() {
  long long int a, b, s, l, tmp;
  cin >> a >> b;
  s = (a < b) ? a : b;
  l = (a < b) ? b : a;
  while (s > 0) {
    l = l % s;
    if (l < s) {
      tmp = s;
      s = l;
      l = tmp;
    }
  }
  if (l == 1) {
    cout << 1 << endl;
    return 0;
  }
  int cnt = 0, i = 2;
  while (l > 1) {
    if (l % i == 0)
      cnt++;
    while (l % i == 0) {
      l = l / i;
    }
    i++;
    if (i * i > l)
      break;
  }
  if (l > 1)
    cnt++;
  cout << cnt + 1 << endl;

  return 0;
}

Fixed submission:
#include <algorithm>
#include <iostream>
#include <math.h>
#include <string.h>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
long long int mod = 1e9 + 7;
bool debug = false;
typedef long long ll;
int main() {
  long long int a, b, s, l, tmp;
  cin >> a >> b;
  s = (a < b) ? a : b;
  l = (a < b) ? b : a;
  while (s > 0) {
    l = l % s;
    if (l < s) {
      tmp = s;
      s = l;
      l = tmp;
    }
  }
  if (l == 1) {
    cout << 1 << endl;
    return 0;
  }
  long long int cnt = 0, i = 2;
  while (l > 1) {
    if (l % i == 0)
      cnt++;
    while (l % i == 0) {
      l = l / i;
    }
    i++;
    if (i * i > l)
      break;
  }
  if (l > 1)
    cnt++;
  cout << cnt + 1 << endl;

  return 0;
}
Problem p02900 (C++)

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

using namespace std;

long long euclidean_gcd(long long a, long long b) {
  long long temp;

  if (a < b) {
    temp = a;
    a = b;
    b = temp;
  }

  if (a % b == 0)
    return b;
  euclidean_gcd(b, a % b);
}

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

  long long gcd = euclidean_gcd(A, B);

  for (long long i = 2; i <= gcd; i++) {
    if (gcd % i == 0) {
      cnt++;
    }
    while (gcd % i == 0)
      gcd /= i;
  }
  if (gcd > 1)
    cnt++;
  cout << cnt + 1 << endl;
  return 0;
}


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

using namespace std;

long long euclidean_gcd(long long a, long long b) {
  long long temp;

  if (a < b) {
    temp = a;
    a = b;
    b = temp;
  }

  if (a % b == 0)
    return b;
  euclidean_gcd(b, a % b);
}

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

  long long gcd = euclidean_gcd(A, B);

  for (long long i = 2; i * i <= gcd; i++) {
    if (gcd % i == 0) {
      cnt++;
    }
    while (gcd % i == 0)
      gcd /= i;
  }
  if (gcd > 1)
    cnt++;
  cout << cnt + 1 << endl;
  return 0;
}
Problem p02900 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <iostream>
#include <math.h>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef unsigned long long ll;
// A > B
ll calcGCD(ll A, ll B) {
  if (A % B == 0) {
    return B;
  } else {
    calcGCD(B, A % B);
  }
}

bool isPrime(ll gcd) {}

int main() {
  ll A, B;
  cin >> A >> B;
  ll bigger = A;
  ll smaller = B;
  if (A < B) {
    bigger = B;
    smaller = A;
  }
  ll gcd = calcGCD(bigger, smaller);
  if (gcd == 1) {
    cout << 1 << endl;
    return 0;
  }
  // gcdを素因数分解
  ll counter = 1;
  ll root = (ll)sqrt(gcd);
  ll gcd_copy = gcd;
  for (ll i = 2; i < gcd_copy; i++) {
    bool isDevide = false;
    while (gcd % i == 0) {
      if (!isDevide) {
        counter++;
        isDevide = true;
      }
      gcd = gcd / i;
    }
    if (i > gcd) {
      cout << counter << endl;
      return 0;
    }
    root = sqrt(gcd);
    if (i > root && counter == 1) {
      cout << 2 << endl;
      return 0;
    }
  }
  return 0;
}


Fixed submission:
#include <algorithm>
#include <iostream>
#include <math.h>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef unsigned long long ll;
// A > B
ll calcGCD(ll A, ll B) {
  if (A % B == 0) {
    return B;
  } else {
    calcGCD(B, A % B);
  }
}

bool isPrime(ll gcd) {}

int main() {
  ll A, B;
  cin >> A >> B;
  ll bigger = A;
  ll smaller = B;
  if (A < B) {
    bigger = B;
    smaller = A;
  }
  ll gcd = calcGCD(bigger, smaller);
  if (gcd == 1) {
    cout << 1 << endl;
    return 0;
  }
  // gcdを素因数分解
  ll counter = 1;
  ll root = (ll)sqrt(gcd);
  ll gcd_copy = gcd;
  for (ll i = 2; i < gcd_copy; i++) {
    bool isDevide = false;
    while (gcd % i == 0) {
      if (!isDevide) {
        counter++;
        isDevide = true;
      }
      gcd = gcd / i;
    }
    if (i > gcd) {
      cout << counter << endl;
      return 0;
    }
    root = sqrt(gcd);
    if (i > root) {
      cout << counter + 1 << endl;
      return 0;
    }
  }
  return 0;
}
Problem p02900 (C++)

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


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

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
long long m, n, g, cnt = 1;
long long gcd(int m, int n) {
  if (m % n == 0)
    return n;
  else
    return gcd(n, m % n);
}
int main() {
  cin >> m >> n;
  g = gcd(m, n);
  for (long long i = 2; i <= sqrt(g); i++) {
    if (g % i == 0) {
      cnt++;
      while (g % i == 0)
        g = g / i;
    }
  }
  if (g > 1)
    cnt++;
  cout << cnt << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
long long m, n, g, cnt = 1;
long long gcd(long long m, long long n) {
  if (m % n == 0)
    return n;
  else
    return gcd(n, m % n);
}
int main() {
  cin >> m >> n;
  g = gcd(m, n);
  for (long long i = 2; i <= sqrt(g); i++) {
    if (g % i == 0) {
      cnt++;
      while (g % i == 0)
        g = g / i;
    }
  }
  if (g > 1)
    cnt++;
  cout << cnt << endl;
  return 0;
}
Problem p02900 (C++)

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

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

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)
      continue;
    ans++;
    while (n % i == 0)
      n /= i;
  }
  if (n != 1)
    ans++;
  cout << ans << endl;
  return 0;
}


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

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

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)
      continue;
    ans++;
    while (n % i == 0)
      n /= i;
  }
  if (n != 1)
    ans++;
  cout << ans << endl;
  return 0;
}
Problem p02900 (C++)

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

int main() {
  cin >> A >> B;
  LL C = __gcd(A, B);
  int ans = 0;
  for (int i = 1; (LL)i * i <= C; i++)
    if (C % i == 0) {
      ans++;
      while (C % i == 0)
        C /= i;
    }
  if (C > 1)
    ans++;
  cout << ans + 1 << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
LL A, B;

int main() {
  cin >> A >> B;
  LL C = __gcd(A, B);
  int ans = 0;
  for (int i = 2; (LL)i * i <= C; i++)
    if (C % i == 0) {
      ans++;
      while (C % i == 0)
        C /= i;
    }
  if (C > 1)
    ans++;
  cout << ans + 1 << endl;
}
Problem p02900 (C++)

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

using namespace std;
using ll = long long;

template <typename T> T gcd(T a, T b) {
  if (a < b)
    return gcd(b, a);
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll A, B;
  cin >> A >> B;
  ll gcdn = gcd(A, B);
  ll gcdc = gcdn;
  ll res = 1;
  for (int i = 2; i * i <= gcdn; i++) {
    if (gcdc % i != 0)
      continue;
    res++;
    while (gcdc % i == 0) {
      gcdc /= i;
    }
  }
  if (gcdc > 1) {
    res++;
  }
  cout << res << '\n';
  return 0;
}


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

using namespace std;
using ll = long long;

template <typename T> T gcd(T a, T b) {
  if (a < b)
    return gcd(b, a);
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll A, B;
  cin >> A >> B;
  ll gcdn = gcd(A, B);
  ll gcdc = gcdn;
  ll res = 1;
  for (ll i = 2; i * i <= gcdn; i++) {
    if (gcdc % i != 0)
      continue;
    res++;
    while (gcdc % i == 0) {
      gcdc /= i;
    }
  }
  if (gcdc > 1) {
    res++;
  }
  cout << res << '\n';
  return 0;
}
Problem p02900 (C++)

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

typedef long long int ll;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define sz(x) int(x.size())
const ll mod = 1000000007;
const ll INF = 10010010010010010;

map<ll, int> prime_factor(ll N) {
  map<ll, int> 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;
}

int main() {
  ll a, b;
  cin >> a >> b;
  map<ll, int> ap = prime_factor(a);
  map<ll, int> bp = prime_factor(b);
  int ans = 1;
  for (auto itr = ap.begin(); itr != ap.end(); itr++) {
    if (bp[itr->first] != 0)
      ans++;
  }
  cout << ans << endl;
  return 0;
}


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

typedef long long int ll;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define sz(x) int(x.size())
const ll mod = 1000000007;
const ll INF = 10010010010010010;

map<ll, int> prime_factor(ll N) {
  map<ll, int> 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;
}

int main() {
  ll a, b;
  cin >> a >> b;
  map<ll, int> ap = prime_factor(a);
  map<ll, int> bp = prime_factor(b);
  int ans = 1;
  for (auto itr = ap.begin(); itr != ap.end(); itr++) {
    if (bp[itr->first] != 0)
      ans++;
  }
  cout << ans << endl;
  return 0;
}
Problem p02900 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
#include <math.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (!b)
    return a;
  return gcd(b, a % b);
}
int main() {
  long long a, b, g, t, ans = 1, tt;
  cin >> a >> b;
  g = gcd(a, b);
  t = g;
  int ss = sqrt(t);
  for (int i = 2; i <= ss; i++) {
    if (!(g % i)) {
      while (!(g % i))
        g /= i;
      ans++;
    }
  }
  for (int i = ss; i >= 1; i--) {
    if (!(t % i) && !(g % (t / i))) {
      tt = t / i;
      while (!(g % tt))
        g /= tt;
      ans++;
    }
  }
  cout << ans;
  return 0;
}


Fixed submission:
#include <iostream>
#include <math.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (!b)
    return a;
  return gcd(b, a % b);
}
int main() {
  long long a, b, g, t, ans = 1, tt;
  cin >> a >> b;
  g = gcd(a, b);
  t = g;
  int ss = sqrt(t);
  for (int i = 2; i <= ss; i++) {
    if (!(g % i)) {
      while (!(g % i))
        g /= i;
      ans++;
    }
  }
  if (g != 1)
    ans++;
  cout << ans;
  return 0;
}
Problem p02900 (C++)

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

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


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

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

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

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

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

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

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

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

Buggy submission (status: Runtime Error):
#include <iostream>
#include <vector>
using namespace std;
#define ll long long

ll A, B, C;

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

int main() {
  cin >> A >> B;
  C = gcd(A, B);
  int cnt = 1;
  for (ll i = 0; i * i <= C; i++) {
    if (C % i != 0)
      continue;
    while (C % i == 0) {
      C /= i;
    }
    cnt++;
  }
  if (C != 1)
    cnt++;
  cout << cnt << endl;
  return 0;
}

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

ll A, B, C;

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

int main() {
  cin >> A >> B;
  C = gcd(A, B);
  int cnt = 1;
  for (ll i = 2; i * i <= C; i++) {
    if (C % i != 0)
      continue;
    while (C % i == 0) {
      C /= i;
    }
    cnt++;
  }
  if (C != 1)
    cnt++;
  cout << cnt << endl;
  return 0;
}
Problem p02900 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <iostream>
#include <stdio.h>
using namespace std;
long long n, m, ans;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
int main() {
  cin >> n >> m;
  m = gcd(n, m);
  for (int i = 2; i * i <= m; i++) {
    if (m % i == 0) {
      ++ans;
      while (m % i == 0)
        m /= i;
    }
  }
  if (m > 1)
    ++ans;
  cout << ans + 1 << endl;
  return 0;
}

Fixed submission:
#include <algorithm>
#include <iostream>
#include <stdio.h>
using namespace std;
long long n, m, ans;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
int main() {
  cin >> n >> m;
  m = gcd(n, m);
  for (long long i = 2; i * i <= m; i++) {
    if (m % i == 0) {
      ++ans;
      while (m % i == 0)
        m /= i;
    }
  }
  if (m > 1)
    ++ans;
  cout << ans + 1 << endl;
  return 0;
}
Problem p02900 (C++)

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

using namespace std;
using ll = long long;

#define REP(i, m, n) for (ll(i) = (m), i##_len = (n); (i) < (i##_len); ++(i))
#define FORR(i, v) for (auto(i) : v)
#define ALL(x) (x).begin(), (x).end()
#define _PR(x) cout << (x) << endl
#define _PS(x) cout << (x) << " "
#define SZ(x) ((int)(x).size())
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define pb push_back

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

vector<ll> factorization(ll n) {
  ll _n = n;
  ll s = (ll)sqrt(n);
  ll r;
  vector<ll> p;

  for (ll i = 2; i <= s; ++i) {
    if (_n % i == 0) {
      do {
        _n /= i;
      } while (_n % i == 0);
      p.pb(i);
    }
  }
  if (_n > s)
    p.pb(_n);

  return p;
}

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

  ll G = gcd(A, B);
  set<ll> cd;
  REP(i, 1, G + 1) {
    if (G % i == 0)
      cd.insert(i);
  }
  auto p = factorization(G);
  _PS(p.size() + 1);

  return 0;
}

/*



*/

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

using namespace std;
using ll = long long;

#define REP(i, m, n) for (ll(i) = (m), i##_len = (n); (i) < (i##_len); ++(i))
#define FORR(i, v) for (auto(i) : v)
#define ALL(x) (x).begin(), (x).end()
#define _PR(x) cout << (x) << endl
#define _PS(x) cout << (x) << " "
#define SZ(x) ((int)(x).size())
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define pb push_back

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

vector<ll> factorization(ll n) {
  ll _n = n;
  ll s = (ll)sqrt(n);
  ll r;
  vector<ll> p;

  for (ll i = 2; i <= s; ++i) {
    if (_n % i == 0) {
      do {
        _n /= i;
      } while (_n % i == 0);
      p.pb(i);
    }
  }
  if (_n > s)
    p.pb(_n);

  return p;
}

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

  ll G = gcd(A, B);
  auto p = factorization(G);
  _PS(p.size() + 1);

  return 0;
}

/*



*/
Problem p02900 (C++)

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

// DAME:

/*
    最大公約数の素因数の個数+1

    a, bの公約数　＝ GCD(a, b)の約数
*/

// ユークリッドの互除法: x>y
ll gcd(ll x, ll y) {
  if (y == 0)
    return x;
  return gcd(y, x % y);
}

// 素因数分解: vector(素因数, 数)
vector<pair<ll, int>> factorize(ll n) {
  vector<pair<ll, int>> res;
  // nが変化していく
  for (ll i = 2; i * 2 <= n; ++i) {
    if (n % i) {
      continue;
    }
    res.emplace_back(i, 0);
    while (n % i == 0) {
      n /= i;
      res.back().second++;
    }
  }
  if (n != 1) {
    res.emplace_back(n, 1);
  }
  return res;
}

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

  auto f = factorize(g);
  int ans = f.size() + 1;
  cout << ans << endl;
  return 0;
}


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

// DAME:

/*
    最大公約数の素因数の個数+1

    a, bの公約数　＝ GCD(a, b)の約数
*/

// ユークリッドの互除法: x>y
ll gcd(ll x, ll y) {
  if (y == 0)
    return x;
  return gcd(y, x % y);
}

// 素因数分解: vector(素因数, 数)
vector<pair<ll, int>> factorize(ll n) {
  vector<pair<ll, int>> res;
  // nが変化していく
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i) {
      continue;
    }
    res.emplace_back(i, 0);
    while (n % i == 0) {
      n /= i;
      res.back().second++;
    }
  }
  if (n != 1) {
    res.emplace_back(n, 1);
  }
  return res;
}

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

  auto f = factorize(g);
  int ans = f.size() + 1;
  cout << ans << endl;
  return 0;
}
Problem p02900 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i, a, b) for (long long i = a; i < b; ++i)
#define rrep(i, a, b) for (int i = a; i >= b; --i)
#define yesno(flag)                                                            \
  if (flag)                                                                    \
    cout << "Yes" << endl;                                                     \
  else                                                                         \
    cout << "No" << endl;
using namespace std;
const ll INF = 1000000000000LL;
const ll r197 = 1000000007;
typedef pair<int, int> P;
typedef pair<int, P> Pa;
bool Inframe(int a, int b, int c, int d, int h, int w) {
  if (a + b >= 0 && a + b < h && c + d >= 0 && c + d < w)
    return true;
  return false;
}

long long a, b;
string str;
int ans = 0;
priority_queue<P, vector<P>, greater<P>> que;
set<P> st;
long long reg(long long l, long long r) {
  if (l < r) {
    ll d = r;
    r = l;
    l = d;
  }
  while (r) {
    l %= r;
    ll d = r;
    r = l;
    l = d;
  }
  return l;
}
int main() {
  cin >> a >> b;
  long long n = reg(a, b);
  for (int i = 2; i <= n; ++i) {
    if (n % i == 0) {
      ans++;
      while (n % i == 0) {
        n /= i;
      }
    }
  }
  cout << ans + 1 << endl;
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i, a, b) for (long long i = a; i < b; ++i)
#define rrep(i, a, b) for (int i = a; i >= b; --i)
#define yesno(flag)                                                            \
  if (flag)                                                                    \
    cout << "Yes" << endl;                                                     \
  else                                                                         \
    cout << "No" << endl;
using namespace std;
const ll INF = 1000000000000LL;
const ll r197 = 1000000007;
typedef pair<int, int> P;
typedef pair<int, P> Pa;
bool Inframe(int a, int b, int c, int d, int h, int w) {
  if (a + b >= 0 && a + b < h && c + d >= 0 && c + d < w)
    return true;
  return false;
}

long long a, b;
string str;
int ans = 0;
priority_queue<P, vector<P>, greater<P>> que;
set<P> st;
long long reg(long long l, long long r) {
  if (l < r) {
    ll d = r;
    r = l;
    l = d;
  }
  while (r) {
    l %= r;
    ll d = r;
    r = l;
    l = d;
  }
  return l;
}
int main() {
  cin >> a >> b;
  long long n = reg(a, b);
  for (int i = 2; i <= n; ++i) {
    if (i > 1000000) {
      ans++;
      break;
    }
    if (n % i == 0) {
      ans++;
      while (n % i == 0) {
        n /= i;
      }
    }
  }
  cout << ans + 1 << endl;
  return 0;
}
Problem p02900 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define ll long long
#define inc(a) sort(a.begin(), a.end())
#define dec(a) sort(a.rbegin(), a.rend())
#define loop(n) for (ll i = 0; i < n; i++)
using namespace std;

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

Fixed submission:
#include <bits/stdc++.h>
#define ll long long
#define inc(a) sort(a.begin(), a.end())
#define dec(a) sort(a.rbegin(), a.rend())
#define loop(n) for (ll i = 0; i < n; i++)
using namespace std;

int main() {
  ll a, b;
  cin >> a >> b;
  ll count = 1, m = __gcd(a, b);
  for (ll i = 2; i * i <= m; i++) {
    if (m % i == 0) {
      count++;
      while (m % i == 0)
        m /= i;
    }
  }
  if (m != 1)
    count++;
  cout << count;
  return 0;
}