Language: C++

#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <numeric>
#include <iomanip>
#include <climits>
#include <cstring>

using namespace std;

#define int long long
#define rep(i, n) for (int i=0;i<(int)(n);++i)
#define rep1(i, n) for (int i=1;i<=(int)(n);++i)
#define rrep(i, n) for (int i=(int)(n)-1;i>=0;--i)
#define rrep1(i, n) for (int i=(int)(n);i>=1;--i)
#define range(i, l, r) for (int i=l;i<(int)(r);++i)
#define rrange(i, l, r) for (int i=(int)(r)-1;i>=l;--i)
#define unless(a) if(!(a))
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

using vi=vector<int>;
using pii=pair<int, int>;
using vpii=vector<pii>;
using ll=long long;

constexpr int TEN(int n){return n==0?1:10*TEN(n-1);}
bool chmin(int&a,int b){return a>b?(a=b,true):false;}
bool chmax(int&a,int b){return a<b?(a=b,true):false;}
int read(){int a;scanf("%lld",&a);return a;}

const int mod = TEN(9)+7;

ll inv[200010];
ll fac[200010], fac_inv[200010];

ll C(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return ((fac[n] * fac_inv[k] % mod) * fac_inv[n - k]) % mod;
}

void comb_init()
{
	int N = 200005;
	inv[1] = 1;

	for (int i = 2; i <= N; ++i) {
		inv[i] = mod - (mod / i) * inv[mod % i] % mod;
	}

	fac[0] = fac_inv[0] = 1;

	for (int i = 1; i <= N; ++i) {
		fac[i] = (fac[i - 1] * i) % mod;
		fac_inv[i] = (fac_inv[i - 1] * inv[i]) % mod;
	}
}

inline ll mod_pow(ll a, ll x, ll m)
{
	if (x == 0) return 1;

	ll res = mod_pow(a, x / 2, m);

	res *= res;
	res %= m;

	if (x % 2) {
		res *= a;
		res %= m;
	}

	return res;
}


int N;
long double A[200010];
long double B[200010];
map<long double, int> m;
map<long double, bool> used;
vpii data1;

int dp[200010][3];

int gcd(int a, int b)
{
	if (a < 0) a = -a;
	if (b < 0) b = -b;

	return b == 0 ? a : gcd(b, a % b);
}

signed main()
{
	cin >> N;

	rep(i, N) {
		cin >> A[i] >> B[i];
		int g = gcd(A[i], B[i]);
		A[i] /= g;
		B[i] /= g;
		m[A[i] / B[i]]++;
	}

	for (auto a : m) {
		if (used[a.fst]) continue;
	
		data1.PB(m[a.fst], m[(long double)-1.0/a.fst]);
		//printf("data.PB(%lld, %lld)\n", m[a.fst], m[-1/a.fst]);

		used[a.fst] = used[(long double)-1.0/a.fst] = true;
	}

	int n = data1.size();

	dp[0][0] = 1;

	for (int i = 0; i < n; ++i) {
		dp[i + 1][0] =
			(dp[i][0] + dp[i][1] + dp[i][2]) % mod;
		dp[i + 1][1] =
			(dp[i][0] + dp[i][1] + dp[i][2]) * (mod_pow(2, data1[i].fst, mod) - 1 + mod) % mod;
		dp[i + 1][2] =
			(dp[i][0] + dp[i][1] + dp[i][2]) * (mod_pow(2, data1[i].scd, mod) - 1 + mod) % mod;
	}

	int ans = (dp[n][0] + dp[n][1] + dp[n][2] - 1 + mod) % mod;

	cout << ans << endl;
}






Compiler output:
In file included from a.cc:11:
/usr/include/c++/14/numeric: In instantiation of 'constexpr std::common_type_t<_Mn, _Nn> std::gcd(_Mn, _Nn) [with _Mn = long double; _Nn = long double; common_type_t<_Mn, _Nn> = long double]':
a.cc:111:14:   required from here
  111 |                 int g = gcd(A[i], B[i]);
      |                         ~~~^~~~~~~~~~~~
/usr/include/c++/14/numeric:175:21: error: static assertion failed: std::gcd arguments must be integers
  175 |       static_assert(is_integral_v<_Mn> && is_integral_v<_Nn>,
      |                     ^~~~~~~~~~~~~~~~~~
/usr/include/c++/14/numeric:175:21: note: 'std::is_integral_v<long double>' evaluates to false
In file included from /usr/include/c++/14/bits/move.h:37,
                 from /usr/include/c++/14/bits/exception_ptr.h:41,
                 from /usr/include/c++/14/exception:166,
                 from /usr/include/c++/14/ios:41,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/type_traits: In instantiation of 'struct std::make_unsigned<long double>':
/usr/include/c++/14/type_traits:2076:11:   required by substitution of 'template<class _Tp> using std::make_unsigned_t = typename std::make_unsigned::type [with _Tp = long double]'
 2076 |     using make_unsigned_t = typename make_unsigned<_Tp>::type;
      |           ^~~~~~~~~~~~~~~
/usr/include/c++/14/numeric:182:24:   required from 'constexpr std::common_type_t<_Mn, _Nn> std::gcd(_Mn, _Nn) [with _Mn = long double; _Nn = long double; common_type_t<_Mn, _Nn> = long double]'
  182 |       return __detail::__gcd<make_unsigned_t<_Ct>>(__m2, __n2);
      |              ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:111:14:   required from here
  111 |                 int g = gcd(A[i], B[i]);
      |                         ~~~^~~~~~~~~~~~
/usr/include/c++/14/type_traits:1929:13: error: invalid use of incomplete type 'class std::__make_unsigned_selector<long double, false, false>'
 1929 |     { using type = typename __make_unsigned_selector<_Tp>::__type; };
      |             ^~~~
/usr/include/c++/14/type_traits:1837:11: note: declaration of 'class std::__make_unsigned_selector<long double, false, false>'
 1837 |     class __make_unsigned_selector;
      |           ^~~~~~~~~~~~~~~~~~~~~~~~