Language: C++

#include<iostream>
#include<algorithm>
#include<vector>
constexpr int BASE = 1000000007;



typedef long long ll;

using namespace std;

template<typename T>

T calc_gcd(T a, T b) {
	if (a < 0)a = -a;
	if (b < 0)b = -b;
	if (b > a) {
		swap(a, b);
		
	}
	if (b == 0)return a;
	while (a % b) {
		a = a % b;
		swap(a, b);
	}
	return b;
}

int modpow(int a, int b, int base) {
	vector<int> vb, va;
	while (b != 0) {
		vb.push_back(b % 2);
		b /= 2;
		va.push_back(a);
		a *= a;
		a %= base;
	}
	int ans = 1;
	for (int i = 0;i < vb.size();i++) {
		if (vb[i] == 1) {
			ans *= va[i];
			ans %= base;
		}
	}
	return ans;
}
 
inline bool operator<=(pair<ll, ll> a, pair<ll, ll> b) {
	if (a.first > b.first)return false;
	if (a.first < b.first)return true;
	return a.second <= b.second;
}

inline bool operator<(pair<ll, ll> a, pair<ll, ll> b) {
	if (a.first > b.first)return false;
	if (a.first < b.first)return true;
	return a.second < b.second;
}
inline bool operator>(pair<ll, ll> a, pair<ll, ll> b) {
	if (a.first < b.first)return false;
	if (a.first > b.first)return true;
	return a.second > b.second;
}
inline bool operator>=(pair<ll, ll> a, pair<ll, ll> b) {
	if (a.first < b.first)return false;
	if (a.first > b.first)return true;
	return a.second >= b.second;
}
inline bool operator==(pair<ll, ll> a, pair<ll, ll> b) {
	return (a.first == b.first && a.second == b.second);
}
inline bool operator!=(pair<ll, ll> a, pair<ll, ll> b) {
	return !(a.first == b.first && a.second == b.second);
}

int bs(int l, int r, pair<ll,ll>);

vector<pair<ll,ll>> v;

int main() {
	int n;
	ll a, b;
	cin >> n;
	ll num_0=0;
	int index = 0;
	for (int i = 0;i < n;i++) {
		cin >> a >> b;
		if (a == 0 && b == 0) {
			num_0++;
		}
		else {
			if (b < 0) {
				a = -a;
				b = -b;
			}
			else if (b == 0 && a < 0) {
				a = -a;
			}
			
			ll c = calc_gcd(a, b);
			a /= c;
			b /= c;
			
			v.push_back(make_pair(a, b));
		}
	}
	if (v.size() == 0) {
		cout << num_0 << endl;
		return 0;
	}
	sort(v.begin(),v.end());
	vector<pair<pair<ll,ll>, int>> v2;
	v2.push_back(make_pair(v[0], 1));
	pair<ll,ll> now = v[0];
	for (int i = 1;i < v.size();i++) {
		if (v[0] == now) {
			v2[v2.size() - 1].second++;
		}
		else {
			v2.push_back(make_pair(v[0], 1));
			now = v[0];
		}
	}
	unique(v.begin(), v.end());
	ll sum = 0;
	ll psum = 0;
	
	for (int i = 0;i < v2.size();i++) {
		psum = sum;
		if (v2[i].first.first<= 0) {
			sum += (1LL + sum) *((ll)modpow(2, v2[i].second, BASE) - 1LL);
			sum %= BASE;
			if (v2[i].first.first == 0) {
				int index = bs(0, v.size() - 1, make_pair(1LL, 0LL));
				if (index != -1) {
					sum += (1LL + psum)((ll)modpow(2, v2[index].second, BASE) - 1LL);
					sum %= BASE;
				}
			}
			else {

				int index = bs(0, v.size() - 1,make_pair(v2[i].first.second, -v2[i].first.first));
				if (index != -1) {
					sum += (1LL + psum)*((ll)modpow(2, v2[index].second, BASE) - 1LL);
					sum %= BASE;
				}
			}
			
		}else {
			if (v2[i].first.second == 0) {
				if (bs(0,v.size()-1,make_pair(0,1))!=-1) {

				}
				else {
					sum += (1LL + sum)*((ll)modpow(2, v2[i].second, BASE) - 1LL);
					sum %= BASE;
				}
			}else if (bs(0,v.size()-1,make_pair(-v2[i].first.second, v2[i].first.first))!=-1) {
				
			}
			else {
				sum += (1LL + sum)*((ll)modpow(2, v2[i].second, BASE) - 1LL);
				sum %= BASE;
			}
		}
	}
	
	
	cout << (sum + num_0) % BASE << endl;
}

int bs(int l, int r, pair<ll, ll> a) {
	if (v[l] > a)return -1;
	if (v[r] < a)return -1;
	if (v[r] == a)return r;
	if (r - l <= 1) {
		if (v[l] == a)return l;
		else return -1;
	}
	else {
		int mid = (l + r) / 2;
		if (v[mid] > a) {
			return bs(l, mid, a);
		}
		else {
			return bs(mid, r, a);
		}
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:124:15: warning: ignoring return value of '_FIter std::unique(_FIter, _FIter) [with _FIter = __gnu_cxx::__normal_iterator<pair<long long int, long long int>*, vector<pair<long long int, long long int> > >]', declared with attribute 'nodiscard' [-Wunused-result]
  124 |         unique(v.begin(), v.end());
      |         ~~~~~~^~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_algo.h:891:5: note: declared here
  891 |     unique(_ForwardIterator __first, _ForwardIterator __last)
      |     ^~~~~~
a.cc:136:60: error: expression cannot be used as a function
  136 |                                         sum += (1LL + psum)((ll)modpow(2, v2[index].second, BASE) - 1LL);
      |                                                ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~