Language: C++

#include<bits/stdc++.h>

using namespace std;

#define LL long long
#define N 200005
#define mod 1000000007

LL ans, a[N], b[N], gcd, p, q;
int n, cur, T, i, r, vis[N];
map<pair<LL,LL>, int> K;
pair<LL,LL> Q[N];
pair<pair<LL,LL>, int> label[N];

LL power(LL x,int y)
{
	LL t=1;
	for (; y; y>>=1) {
		if (y&1) t=t*x%mod;
		x=x*x%mod; 
	}
	return t;
}

int main (void)
{
	scanf("%d",&n);
	for (i=1; i<=n; i++) {
		scanf("%lld%lld",&a[i],&b[i]);
		gcd=__gcd(a[i],b[i]);
		a[i]/=gcd,b[i]/=gcd;
		Q[i]=make_pair(a[i],b[i]);
	}	
	sort(Q+1,Q+n+1);
	cur=T=1;
	for (i=2; i<=n; i++) {
		if (Q[i].first==Q[i-1].first&&Q[i].second==Q[i-1].second) cur++;
		else label[T]=make_pair(Q[i-1],cur),T++,cur=1;
	}
	if (cur) label[T]=make_pair(Q[i-1],cur);
	for (i=1; i<=T; i++) K[label[i].first]=i;
	ans=1;
	for (i=1; i<=T; i++) {
		if (vis[i]) continue;
		p=-Q[i].second; q=Q[i].first;
		gcd=__gcd(p,q);
		p/=gcd,q/=gcd;
		r=K[make_pair(p,q)];
		if (r) {
			ans=ans*(power(2,label[i].second)+power(2,label[r].second)-1)%mod;
			if (ans<0) ans+=mod;
			vis[i]=vis[r]=1;
		}
		else {
			ans=ans*power(2,label[i].second)%mod;
			vis[i]=1;
		}
		//printf("%lld %d\n",ans,T);
	}
	ans=(ans-1)%mod;
	if (ans<0) ans+=mod;
	printf("%lld\n",ans);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:30:17: error: reference to 'gcd' is ambiguous
   30 |                 gcd=__gcd(a[i],b[i]);
      |                 ^~~
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:58,
                 from a.cc:1:
/usr/include/c++/14/numeric:173:5: note: candidates are: 'template<class _Mn, class _Nn> constexpr std::common_type_t<_Mn, _Nn> std::gcd(_Mn, _Nn)'
  173 |     gcd(_Mn __m, _Nn __n) noexcept
      |     ^~~
a.cc:9:21: note:                 'long long int gcd'
    9 | LL ans, a[N], b[N], gcd, p, q;
      |                     ^~~
a.cc:31:23: error: reference to 'gcd' is ambiguous
   31 |                 a[i]/=gcd,b[i]/=gcd;
      |                       ^~~
/usr/include/c++/14/numeric:173:5: note: candidates are: 'template<class _Mn, class _Nn> constexpr std::common_type_t<_Mn, _Nn> std::gcd(_Mn, _Nn)'
  173 |     gcd(_Mn __m, _Nn __n) noexcept
      |     ^~~
a.cc:9:21: note:                 'long long int gcd'
    9 | LL ans, a[N], b[N], gcd, p, q;
      |                     ^~~
a.cc:31:33: error: reference to 'gcd' is ambiguous
   31 |                 a[i]/=gcd,b[i]/=gcd;
      |                                 ^~~
/usr/include/c++/14/numeric:173:5: note: candidates are: 'template<class _Mn, class _Nn> constexpr std::common_type_t<_Mn, _Nn> std::gcd(_Mn, _Nn)'
  173 |     gcd(_Mn __m, _Nn __n) noexcept
      |     ^~~
a.cc:9:21: note:                 'long long int gcd'
    9 | LL ans, a[N], b[N], gcd, p, q;
      |                     ^~~
a.cc:46:17: error: reference to 'gcd' is ambiguous
   46 |                 gcd=__gcd(p,q);
      |                 ^~~
/usr/include/c++/14/numeric:173:5: note: candidates are: 'template<class _Mn, class _Nn> constexpr std::common_type_t<_Mn, _Nn> std::gcd(_Mn, _Nn)'
  173 |     gcd(_Mn __m, _Nn __n) noexcept
      |     ^~~
a.cc:9:21: note:                 'long long int gcd'
    9 | LL ans, a[N], b[N], gcd, p, q;
      |                     ^~~
a.cc:47:20: error: reference to 'gcd' is ambiguous
   47 |                 p/=gcd,q/=gcd;
      |                    ^~~
/usr/include/c++/14/numeric:173:5: note: candidates are: 'template<class _Mn, class _Nn> constexpr std::common_type_t<_Mn, _Nn> std::gcd(_Mn, _Nn)'
  173 |     gcd(_Mn __m, _Nn __n) noexcept
      |     ^~~
a.cc:9:21: note:                 'long long int gcd'
    9 | LL ans, a[N], b[N], gcd, p, q;
      |                     ^~~
a.cc:47:27: error: reference to 'gcd' is ambiguous
   47 |                 p/=gcd,q/=gcd;
      |                           ^~~
/usr/include/c++/14/numeric:173:5: note: candidates are: 'template<class _Mn, class _Nn> constexpr std::common_type_t<_Mn, _Nn> std::gcd(_Mn, _Nn)'
  173 |     gcd(_Mn __m, _Nn __n) noexcept
      |     ^~~
a.cc:9:21: note:                 'long long int gcd'
    9 | LL ans, a[N], b[N], gcd, p, q;
      |                     ^~~