WA in SPOJ "Number of common divisors" (COMDIV)

Here’s the question link: COMDIV
Here’s my solution:

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

constexpr int lim = 1'000'001;
int spf[lim];

void sieve() {
	for(int i = 1; i < lim; ++i) spf[i] = vector<int>{2, i}[i & 1];
	for(int i = 3; i * i < lim; i += 2) {
	    if(spf[i] == i) {
	        for(int j = i * i; j < lim; j += i) spf[j] = i;
	    }
	}
}

void inferno() {
	int n; cin >> n;
	auto div = [](int x) {
		int d = 1;
		while(x != 1) {
			int p = spf[x], k = 0;
			while(spf[x] == p) {
				x /= p, k++;
			}
			d *= k + 1;
		}
		return d;
	};
	for(int i = 0, x, y, d; i < n; ++i) {
		cin >> x >> y;
		d = __gcd(x, y);
		cout << div(d) << "\n";
	}
}

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr); cout.tie(nullptr);
	int t = 1; //cin >> t;
	sieve();
	while(t--) inferno();
	return 0;
} //raise hellish blaze!

Now, this is giving me WA and I can’t seem to find out why.
Will appreciate help (if any) :slightly_smiling_face:

Edit: I think i have found the bug, sorry :sweat_smile: