Language: C++

#include<iostream>
#include<vector>
#include<set>
using namespace std;

typedef unsigned long long llong;

void factorize( llong x, vector<llong> &factors ){
    llong d, q;
    while ( x >= 4 && x % 2 == 0 ) {
	factors.push_back(2);
	x /= 2;
    }
    d = 3; q = x / d;
    while ( q >= d ){
	if ( x % d == 0 ) {
	    factors.push_back(d);
	    x = q;
	} else {
	    d += 2;
	}
	q = x / d;
    }
    factors.push_back(x);
}

void rec(int p, llong d, vector<llong> &divisors, vector<pair<llong, llong> > &factpairs, llong n){
    if ( p == factpairs.size() ){
	assert( d <= n );
	divisors.push_back(d);
	return;
    }

    llong v = d;
    for ( int i = 0; i <= factpairs[p].second; i++ ){
	rec(p+1, v, divisors, factpairs, n);
	v *= factpairs[p].first;
	//	cout << v << endl;
    }
}



llong gcd( llong x, llong y ){
    llong r;

    if ( x < y ) swap( x, y ); 
    
    while ( y > 0 ){
        r = x % y;
        x = y;
        y = r;
    }

    return x;
}

llong lcm( llong x, llong y ){
    return (x/gcd(x,y))*y;
}

int compute(llong n){
    vector<llong> factors;
    vector<pair<llong, llong> > factpairs;

    factorize(n, factors);
    if ( factors.size() > 0 ) factpairs.push_back(make_pair(factors[0], 1));
    for ( int i = 1; i < factors.size(); i++ ){
	if( factpairs[factpairs.size()-1].first == factors[i] ){
	    factpairs[factpairs.size()-1].second++;
	} else {
	    factpairs.push_back(make_pair(factors[i], 1));
	}
    }
    

    vector<llong> divisors;
    rec(0, 1, divisors, factpairs, n);
    
    if ( divisors.size() >= 2 && divisors[0] == 1 && divisors[1] == 1 ){
	divisors.erase(divisors.begin());
    }

    //set<llong> ss;
    //for ( int i = 0; i < divisors.size(); i++ ) ss.insert(divisors[i]);
    //assert( ss.size() == divisors.size());

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


    //    cout << "---- " << divisors.size() << endl;
    int cnt = 0;
    for ( int i = 0; i < divisors.size(); i++ ){
	for ( int j = i; j < divisors.size(); j++ ){
	     if ( gcd(divisors[i], divisors[j] ) == 1 ){
		cnt++;
	    }
	}
    }
    return cnt;
}

main(){
    llong n;
    while(1){
	cin >> n;
	if ( n == 0 ) break;
	assert ( n <= 1000000000000LL );
	//cout << n << " " << compute(n) << endl;
	cout << compute(n) << endl;
    }
}

Compiler output:
a.cc: In function 'void rec(int, llong, std::vector<long long unsigned int>&, std::vector<std::pair<long long unsigned int, long long unsigned int> >&, llong)':
a.cc:29:9: error: 'assert' was not declared in this scope
   29 |         assert( d <= n );
      |         ^~~~~~
a.cc:4:1: note: 'assert' is defined in header '<cassert>'; this is probably fixable by adding '#include <cassert>'
    3 | #include<set>
  +++ |+#include <cassert>
    4 | using namespace std;
a.cc: In function 'int compute(llong)':
a.cc:88:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   88 |     sort(divisors.begin(), divisors.end());
      |     ^~~~
      |     short
a.cc: At global scope:
a.cc:104:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
  104 | main(){
      | ^~~~
a.cc: In function 'int main()':
a.cc:109:9: error: 'assert' was not declared in this scope
  109 |         assert ( n <= 1000000000000LL );
      |         ^~~~~~
a.cc:109:9: note: 'assert' is defined in header '<cassert>'; this is probably fixable by adding '#include <cassert>'