alexjercan/bugnet huggingface dataset:
Problem p00646 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define FOR(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define FORIT(i, c)                                                            \\
  for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)

template <class T> void debug(T begin, T end) {
  for (T i = begin; i != end; ++i)
    cerr << *i << " ";
  cerr << endl;
}
inline bool valid(int x, int y, int W, int H) {
  return (x >= 0 && y >= 0 && x < W && y < H);
}

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
vector<int> fact(ll L) {
  ll N = L;
  vector<int> res;
  for (ll i = 2; i * i <= N; i++)
    if (L % i == 0) {
      int cnt = 0;
      while (L % i == 0) {
        L /= i;
        cnt++;
      }
      res.push_back(cnt);
    }
  if (L != 1)
    res.push_back(1);
  return res;
}

int main() {
  ll L;
  while (cin >> L && L) {
    if (L == 1) {
      cout << 1 << endl;
      continue;
    }
    vector<int> v = fact(L);
    int dp[2] = {};
    dp[1] = v[0];
    for (int i = 1; i < v.size(); i++) {
      dp[(i + 1) & 1] = dp[i & 1] * 2 * v[i] + v[i] + dp[i & 1];
    }
    cout << dp[v.size() & 1] + 1 << endl;
  }
  return 0;
}

Error: 0

Fixed submission:

#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define FOR(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define FORIT(i, c)                                                            \\
  for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)

template <class T> void debug(T begin, T end) {
  for (T i = begin; i != end; ++i)
    cerr << *i << " ";
  cerr << endl;
}
inline bool valid(int x, int y, int W, int H) {
  return (x >= 0 && y >= 0 && x < W && y < H);
}

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
vector<int> fact(ll L) {
  ll N = L;
  vector<int> res;
  for (ll i = 2; i * i <= N; i++)
    if (L % i == 0) {
      int cnt = 0;
      while (L % i == 0) {
        L /= i;
        cnt++;
      }
      res.push_back(cnt);
    }
  if (L != 1)
    res.push_back(1);
  return res;
}

int main() {
  ll L;
  while (cin >> L && L) {
    vector<int> v = fact(L);
    int dp[2] = {};
    dp[1] = v[0];
    for (int i = 1; i < v.size(); i++) {
      dp[(i + 1) & 1] = dp[i & 1] * 2 * v[i] + v[i] + dp[i & 1];
    }
    cout << dp[v.size() & 1] + 1 << endl;
  }
  return 0;
}
Problem p00646 (C++) — buggy submission, verdict: 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 a, ll b) {
  if (a < b)
    swap(a, b);
  if (!b)
    return a;
  return gcd(b, a % b);
}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main() {
  ll a;
  while (scanf("%lld", &a), a) {
    vector<ll> v;
    for (ll i = 1; i * i <= a; i++) {
      if (a % i == 0) {
        v.push_back(i);
        if (i != a / i)
          v.push_back(a / i);
      }
    }
    sort(v.begin(), v.end());
    int cnt = 0;
    rep(i, v.size()) for (int j = i; j < v.size(); j++) {
      if (lcm(v[i], v[j]) == a)
        cnt++;
    }
    printf("%d\\n", cnt);
  }
}

Error: TLE

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 a, ll b) {
  if (a < b)
    swap(a, b);
  if (!b)
    return a;
  return gcd(b, a % b);
}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main() {
  ll a;
  while (scanf("%lld", &a), a) {
    vector<ll> v;
    for (ll i = 1; i * i <= a; i++) {
      if (a % i == 0) {
        v.push_back(i);
        if (i != a / i)
          v.push_back(a / i);
      }
    }
    int cnt = 0;
    for (ll i : v)
      for (ll j : v) {
        if (i <= j && lcm(i, j) == a)
          cnt++;
      }
    printf("%d\\n", cnt);
  }
}
Problem p00646 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define loop(i, a, b) for (int i = a; i < b; i++)
#define rep(i, a) loop(i, 0, a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(), in.end()
#define shosu(x) fixed << setprecision(x)
using namespace std;
// kaewasuretyuui
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef pair<int, pii> pip;
typedef vector<pip> vip;
const double PI = acos(-1);
const double EPS = 1e-8;
const int inf = 1e8;
int main() {
  ll a;
  while (cin >> a, a) {
    ll out = 1;
    for (ll i = 2; i * i <= a; i++) {
      ll t = 0;
      while (a % i == 0) {
        t++;
        a /= i;
      }
      out *= 2 * t + 1;
    }
    if (a != 1)
      out *= 3;
    cout << ++out / 2 << endl;
  }
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define loop(i, a, b) for (int i = a; i < b; i++)
#define rep(i, a) loop(i, 0, a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(), in.end()
const double PI = acos(-1);
const double ESP = 1e-10;
using namespace std;
int main() {
  int n;
  while (cin >> n, n) {
    int co = 0;
    loop(i, 1, sqrt(n)) if (n % i == 0) { co += 2; }
    int out = co + (co - 2) / 2;
    double d = sqrt(n);
    if (d - (int)d == 0)
      out++;
    cout << out << endl;
    ;
  }
}
Problem p00646 (C++) — buggy submission, verdict: Time Limit Exceeded

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

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

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

  ll L;
  while (cin >> L, L) {
    ll ans = 0;
    list<ll> y;
    for (ll i = 1; i * i <= L; i++) {
      if (L % i == 0) {
        y.push_back(i);
        if (i != L / i)
          y.push_back(L / i);
      }
    }

    // for(int i = 0; i < y.size(); i++) cout << y[i] << endl;

    for (list<ll>::iterator i = y.begin(); i != y.end(); i++) {
      for (list<ll>::iterator j = y.begin(); j != y.end(); j++) {
        if (*i > *j)
          continue;
        ll g = gcd(*j, *i);
        if (g * L == *j * *i)
          ans++;
      }
    }
    cout << ans << endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

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

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

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

  ll L;
  while (cin >> L, L) {
    ll ans = 0;
    vector<ll> y;
    for (ll i = 1; i * i <= L; i++) {
      if (L % i == 0) {
        y.push_back(i);
        if (i != L / i)
          y.push_back(L / i);
      }
    }

    sort(y.begin(), y.end());
    // for(int i = 0; i < y.size(); i++) cout << y[i] << endl;

    for (ll i = 0; i < y.size(); i++) {
      for (ll j = i; j < y.size(); j++) {
        ll g = gcd(y[j], y[i]);
        if (g * L == y[i] * y[j])
          ans++;
      }
    }
    cout << ans << endl;
  }

  return 0;
}
Problem p00646 (C++) — buggy submission, verdict: Time Limit Exceeded

/*
 * D.cpp
 *
 *  Created on: 2012-8-25
 *      Author: Administrator
 */
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <string>
using namespace std;

long long ans;
long long prime[1000000] = {2, 3, 5, 7};
int pn = 4;
void getprime() {
  for (int i = 8; i <= 1000000; i++) {
    bool flag = true;
    for (int j = 0; prime[j] * prime[j] <= i; j++) {
      if (i % prime[j] == 0) {
        flag = false;
        break;
      }
    }
    if (flag) {
      prime[pn++] = i;
      //		cout<<i<<endl;
    }
  }
}
long long frac[100];
long long fracn[100];
int n;
int main() {
  getprime();
  long long l;
  //	cout<<pn<<endl;
  //	while (cin >> l && l) {
  while (~scanf("%lld", &l) && l) {
    memset(frac, 0, sizeof(frac));
    memset(fracn, 0, sizeof(fracn));
    n = 0;
    for (int i = 0; prime[i] <= l && i < pn; i++) {
      if (l % prime[i] == 0) {
        frac[n] = prime[i];
        while (l % prime[i] == 0) {
          l /= prime[i];
          fracn[n]++;
        }
        n++;
      }
    }
    if (l != 1) {
      frac[n] = l;
      fracn[n] = 1;
      n++;
    }
    ans = 1;
    for (int i = 0; i != n; i++) {
      ans *= fracn[i] * 2 + 1;
    }
    //		cout<<ans/2+1<<endl;
    printf("%lld\\n", ans / 2 + 1);
  }
}

Error: TLE

Fixed submission:

#include <iostream>
#include <math.h>
#include <memory.h>
long long c[10000000];
long long b[10000000];
using namespace std;
int main() {
  for (long long L; cin >> L;) {
    if (L == 0) {
      break;
    }
    if (L == 1) {
      cout << "1" << endl;
      continue;
    }
    if (L == 2) {
      cout << "2" << endl;
      continue;
    }
    long long i, j = L, k = 0, p = 0, add = 0, s, t, l, q;
    memset(c, 0, 10000000);
    memset(b, 0, 10000000);
    for (i = 2; i < j; i++) {
      if (L % i == 0) {
        k++;
        c[k] = i;
        b[k] = L / i;
        j = L / i;
      }
    }
    if (c[k] != b[k] || (c[k] == 0 && b[k] == 0)) {
      add = k * 2 + 2;
      l = 2 * k + 1;
      q = k;
    } else {
      add = k * 2 + 1;
      b[k] = 0;
      l = 2 * k;
      q = k - 1;
    }
    for (i = 1; i <= q; i++) {
      c[l - i] = b[i];
    }
    for (i = (l - 1); i > 1; i--) {
      for (j = i - 1; j >= 1; j--) {
        if (c[i] % c[j] == 0) {
          continue;
        }
        p = c[i];
        s = c[j];
        p = p % s;
        t = p > s ? p : s;
        s = p + s - t;
        p = t;
        for (; s != 0 && s != 1;) {
          p = p % s;
          t = p > s ? p : s;
          s = p + s - t;
          p = t;
        }
        if (s == 1) {
          add++;
        }
      }
    }
    cout << add << endl;
  }
  return 0;
}
Problem p00646 (C++) — buggy submission, verdict: Runtime Error

#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
const int primN = 3165000;
long long p[primN], hash[primN], pnum;
void mlist() {
  p[pnum++] = 2;
  for (int i = 3; i < primN; i += 2)
    if (!hash[i]) {
      p[pnum++] = i;
      if (i < 10000)
        for (int j = i * i; j < primN; j += (2 * i))
          hash[j] = 1;
    }
}
long long pf[60], pfnum = 0, lim[60];
void pfact(long long n) {
  pfnum = 0;
  if (n == 1) {
    pfnum = 1;
    return;
  }
  for (int i = 0; i < pnum && p[i] * p[i] <= n; ++i)
    if (n % p[i] == 0) {
      lim[pfnum] = 0;
      while (n % p[i] == 0)
        n /= p[i], ++lim[pfnum];
      pf[pfnum++] = p[i];
    }
  if (n != 1)
    lim[pfnum] = 1, pf[pfnum++] = n;
}
void doit() {
  long long l;
  scanf("%lld", &l);
  if (l == 0)
    exit(0);
  pfact(l);
  long long ans = 1;
  for (int i = 0; i < pfnum; i++)
    ans *= (2 * lim[i] + 1);
  ans = (ans + 1) / 2;
  printf("%lld\\n", ans);
}

int main() {
  mlist();
  while (1) {
    doit();
  }
  return 0;
}

Error: -6
*** stack smashing detected ***: terminated


Fixed submission:

#include <math.h>
#include <stdio.h>
#include <string.h>
#define ll long long
ll f[500010];
int fnum;
ll gcd(ll a, ll b) {
  if (!a)
    return b;
  if (!b)
    return a;
  while (a > b ? a %= b : b %= a)
    ;
  return a + b;
}
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
ll ff(ll x) {
  fnum = 0;
  int i, j;
  for (i = 1; i <= sqrt(x); i++)
    if (x % i == 0) {
      f[fnum++] = i;
      f[fnum++] = x / i;
    }
  // printf("%d\\n",fnum);
  ll res = 0;
  for (i = 0; i < fnum; i++)
    for (j = i; j < fnum; j++)
      if (lcm(f[i], f[j]) == x)
        res++;
  return res;
}
int main() {
  int i, n;
  while (scanf("%lld", &n) && n) {
    printf("%lld\\n", ff(n));
  }
}
Problem p00646 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

const int primN = 3165000;

long long p[primN], hash[primN], pnum;
void mlist() {
  p[pnum++] = 2;
  for (int i = 3; i < primN; i += 2)
    if (!hash[i]) {
      p[pnum++] = i;
      if (i < 10000)
        for (int j = i * i; j < primN; j += (2 * i))
          hash[j] = 1;
    }
}

long long pf[60], pfnum = 0, lim[60];
void pfact(long long n) {
  pfnum = 0;
  if (n == 1) {
    pfnum = 1;
    return;
  }
  for (int i = 0; i < pnum && p[i] * p[i] <= n; ++i)
    if (n % p[i] == 0) {
      lim[pfnum] = 0;
      while (n % p[i] == 0)
        n /= p[i], ++lim[pfnum];
      pf[pfnum++] = p[i];
    }
  if (n != 1)
    lim[pfnum] = 1, pf[pfnum++] = n;
}

void doit() {
  long long l;
  scanf("%lld", &l);
  if (l == 0)
    exit(0);
  /*   long long i;
     long long ans = 0LL;
     for (i=1LL; (i*i)<l; ++i) {
         //printf("%I64d %I64d\\n",i*i, l);
         if (l%i==0) {
             pfact(l/i);
             if (pfnum>0) ans += (1LL<<(pfnum-1LL));
             pfact(i);
             if (pfnum>0) ans += (1LL<<(pfnum-1LL));
         }
     }
     if (i*i==l) {
         pfact(i);
         if (pfnum>0) ans += (1LL<<(pfnum-1LL));
     }*/
  pfact(l);
  long long ans = 1;
  for (int i = 0; i < pfnum; i++)
    ans *= (2 * lim[i] + 1);
  ans = (ans + 1) / 2;
  printf("%lld\\n", ans);
}

int main() {
  mlist();
  while (1) {
    doit();
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <map>
#include <stdio.h>
#include <string.h>
#include <vector>
using namespace std;
int a[1000];
int main() {
  long long v;
  while (scanf("%lld", &v), v) {
    long long V = v;
    if (v == 1) {
      printf("1\\n");
      continue;
    }
    vector<int> adj;
    for (int i = 2; i * i <= v; i++) {
      int k = 0;
      while (v % i == 0) {
        k++;
        v /= i;
      }
      if (k)
        adj.push_back(k);
    }
    if (v != 1)
      adj.push_back(1);
    long long ans = 1;
    for (int i = 0; i < adj.size(); i++) {
      ans *= (adj[i] * 2 + 1);
    }
    ans++;
    printf("%lld\\n", ans / 2);
  }
  return 0;
}
Problem p00646 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>
using namespace std;

#define REP(i, n) for (int i = 0; i < (int)n; ++i)
#define FOR(i, c)                                                              \\
  for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1 << 29;

typedef long long Int;
typedef pair<Int, Int> pii;

int main() {
  const int N = 1050000;
  vector<int> prime(N);
  REP(i, N) prime[i] = i;
  prime[0] = prime[1] = 0;
  for (int i = 2; i < N; ++i)
    if (prime[i])
      for (int j = 2 * i; j < N; j += i)
        prime[j] = 0;
  prime.erase(remove(ALL(prime), 0), prime.end());

  Int n;
  while (cin >> n, n) {
    Int sr = sqrt(n);
    map<int, int> mp;
    for (int i = 0; n > 1 && prime[i] <= sr; ++i) {
      while (!(n % prime[i])) {
        n /= prime[i];
        mp[prime[i]]++;
      }
    }
    if (n != 1)
      mp[n]++;

    Int m = mp.size();

    vector<pii> v;
    FOR(it, mp)
    v.push_back(pii(it->first, it->second));
    Int res = 0;
    REP(S, 1 << m) {
      Int tmp = 1;
      REP(i, m) {
        if ((S >> i) & 1)
          tmp *= v[i].second + 1;
        else {
          if (v[i].second >= 2) {
            tmp *= v[i].second;
          }
        }
      }
      //      cout << bitset<10>(S) << " " << tmp<<endl;
      res += tmp;
    }
    cout << (res + 1) / 2 << endl;
  }
}

Error: 0

Fixed submission:

#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>
using namespace std;

#define REP(i, n) for (int i = 0; i < (int)n; ++i)
#define FOR(i, c)                                                              \\
  for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1 << 29;

typedef long long Int;
int main() {
  vector<int> prime(1000001);
  REP(i, 1000001) prime[i] = i;
  prime[0] = prime[1] = 0;
  for (int i = 2; i < 1000001; ++i)
    if (prime[i])
      for (int j = 2 * i; j < 1000001; j += i)
        prime[j] = 0;
  prime.erase(remove(ALL(prime), 0), prime.end());

  Int n;
  while (cin >> n, n) {
    int sr = sqrt(n);
    map<int, int> mp;
    for (int i = 0; n > 1 && prime[i] <= sr; ++i) {
      while (!(n % prime[i])) {
        n /= prime[i];
        mp[prime[i]]++;
      }
    }
    if (n != 1)
      mp[n]++;

    int m = mp.size();
    typedef pair<int, int> pii;
    vector<pii> v;
    FOR(it, mp)
    v.push_back(pii(it->first, it->second));
    Int res = 0;
    REP(S, 1 << m) {
      Int tmp1 = 1, tmp2 = 1;
      REP(i, m) {
        if ((S >> i) & 1)
          tmp1 *= v[i].second + 1;
        else
          tmp2 *= v[i].second + 1;
      }
      //      cout << bitset<10>(S) << " " << tmp<<endl;
      res += tmp1 * tmp2;
    }
    cout << res / (m + 1) << endl;
  }
}
Problem p00646 (C++) — buggy submission, verdict: Time Limit Exceeded

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

#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX

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

#define DEBUG false

#define MAXI 1000001

vector<ll> prime;

int main() {

  ll l;
  bool used[MAXI] = {false};
  REP(i, 2, MAXI) {
    if (!used[i])
      prime.push_back(i);
    for (int j = 2; i * j < MAXI; j++)
      used[i * j] = true;
  }

  while (cin >> l, l) {
    ll tmp = l;
    ll ans = 1;
    ll mul = 1;
    rep(i, prime.size()) {
      ll cnt = 0;
      while (tmp != 1 && tmp % prime[i] == 0) {
        cnt++;
        tmp /= prime[i];
      }
      mul *= (cnt * 2 + 1);
    }
    if (tmp >= MAXI)
      mul *= 3;
    ans += mul;
    cout << ans / 2 << endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

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

#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX

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

#define DEBUG false

#define MAXI 1000001

int main() {

  ll l;
  vector<ll> prime;
  bool used[MAXI] = {false};
  REP(i, 2, MAXI) {
    if (!used[i])
      prime.push_back(i);
    for (int j = 2; i * j < MAXI; j++)
      used[i * j] = true;
  }

  while (cin >> l, l) {
    vector<ll> cnt(prime.size());
    ll tmp = l;
    rep(i, prime.size()) {
      while (tmp != 1 && tmp % prime[i] == 0) {
        cnt[i]++;
        tmp /= prime[i];
      }
    }

    ll ans = 2;
    ll mul = 1;
    bool flag1 = false, flag2 = false;
    rep(i, cnt.size()) {
      if (prime[i] == l)
        break;
      ans += cnt[i];
      if (cnt[i] > 0) {
        if (flag1)
          flag2 = true;
        flag1 = true;
        mul *= (cnt[i] * 2);
      }
    }
    if (flag1)
      ans--;
    if (flag2)
      ans += (mul / 2);

    cout << ans << endl;
  }

  return 0;
}
Problem p00646 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
int pn(int a[], int n) {
  int i, j;
  a[0] = a[1] = 0;
  for (i = 2; i < n; i++)
    a[i] = i;
  for (i = 2; i * i < n; i++) {
    if (a[i]) {
      for (j = i * i; j < n; j += i)
        a[j] = 0;
    }
  }
  j = 2;
  for (i = 0; j < n; i++) {
    a[i] = a[j];
    for (j++; j < n && a[j] == 0; j++)
      ;
  }
  return i;
}
int main() {
  int i, j;
  int a[1000000];
  a[pn(a, 1000000)] = 1000001;
  long long n, m;
  while (cin >> n && n) {
    m = n;
    vector<long long> b;
    b.reserve(900);
    b.push_back(1);
    for (i = 0; (long long)a[i] * a[i] <= m; i++) {
      if (n % a[i] == 0) {
        int ln = b.size();
        long long pi = a[i];
        do {
          for (j = 0; j < ln; j++)
            b.push_back(b[j] * pi);
          n /= a[i];
          pi *= a[i];
        } while (n % a[i] == 0);
      }
    }
    if (n != 1) {
      int ln = b.size();
      for (j = 0; j < ln; j++)
        b.push_back(b[j] * n);
    }
    int ct = 0;
    for (i = 0; i < (int)b.size(); i++) {
      for (j = i; j < (int)b.size(); j++) {
        if (b[i] / __gcd(b[i], b[j]) * b[j] == m)
          ct++;
      }
    }
    cout << ct << endl;
  }
  return 0;
}

Error: 0

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
using namespace std;
long long gcd(long long p, long long q) {
  long long s;
  while (q) {
    p %= q;
    s = p;
    p = q;
    q = s;
  }
  return p;
}
int main() {
  int i, j, k, l, m;
  int a[78500];
  int ct;
  long long b[1000], n;
  a[0] = 2;
  k = 1;
  for (i = 3; i < 1000000; i += 2) {
    for (j = 3; j * j < i + 1; j += 2) {
      if (i % j == 0)
        break;
    }
    if (j * j >= i + 1) {
      a[k] = i;
      k++;
    }
  }
  a[k] = 1000001;
  while (cin >> n && n) {
    b[0] = 1;
    l = 1;
    for (i = 0; a[i] < (int)(sqrt(n) - 0.001) + 1; i++) {
      if (n % a[i] == 0) {
        m = 0;
        for (j = 0; j < l; j++) {
          for (k = 1; pow(a[i], k) * b[j] < (int)(sqrt(n) - 0.001) + 1 &&
                      n % (long long)pow(a[i], k) == 0;
               k++) {
            b[l + m] = (long long)pow(a[i], k) * b[j];
            m++;
          }
        }
        l += m;
      }
    }
    if (n != 1) {
      for (i = 0; i < l; i++)
        b[l + i] = n / b[i];
      l += i;
      if ((int)sqrt(n) * (int)sqrt(n) == n) {
        b[l] = (int)sqrt(n);
        l++;
      }
    }
    ct = 0;
    for (i = 0; i < l; i++) {
      for (j = i; j < l; j++) {
        if (b[i] / gcd(b[i], b[j]) * b[j] == n)
          ct++;
      }
    }
    cout << ct << endl;
  }
  return 0;
}