alexjercan/bugnet huggingface dataset:
Problem p02679 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
const int MAX = 2e5 + 10;
const ll mod = 1000000007;

int N;
ll a[MAX], b[MAX];
ll siz[MAX], rhs[MAX], col, vis[MAX];
ll f[MAX], num1, num2;
map<piii, int> mp[2];

piii calc(ll x, ll y) {
  x = abs(x), y = abs(y);
  ll gcd = __gcd(x % y, y);
  return piii{x / y, {x % y / gcd, y / gcd}};
}

int main() {
#ifdef ACM_LOCAL
  freopen("input.in", "r", stdin);
  freopen("output.out", "w", stdout);
#endif
  scanf("%d", &N);
  f[0] = 1;
  for (int i = 1; i <= N; i++)
    f[i] = 1ll * f[i - 1] * 2 % mod;
  for (int i = 0; i <= N; i++)
    f[i] = (f[i] - 1 + mod) % mod;
  ll ans = 0;
  for (int i = 1; i <= N; i++) {
    scanf("%lld%lld", a + i, b + i);
    if (a[i] == 0 && b[i] == 0)
      ans++;
    else if (a[i] == 0)
      num1++;
    else if (b[i] == 0)
      num2++;
    else {
      piii now = calc(a[i], b[i]), pre = calc(b[i], a[i]);
      int state = 0;
      if (1.0 * a[i] / b[i] > 0)
        state = 1;
      if (!mp[state].count(now)) {
        mp[state][now] = ++col;
        if (mp[state ^ 1].count(pre))
          rhs[col] = mp[state ^ 1][pre], rhs[mp[state ^ 1][pre]] = col;
      }
      siz[mp[state][now]]++;
    }
  }
  ll t = (f[num1] + f[num2] + 1) % mod;
  for (int i = 1; i <= col; i++)
    if (!vis[i]) {
      vis[i] = 1;
      if (rhs[i]) {
        vis[rhs[i]] = 1;
        t = t * ((1ll + (f[siz[i]] + f[siz[rhs[i]]]) % mod) % mod) % mod;
      } else
        t = t * ((1ll + f[siz[i]]) % mod) % mod;
    }
  ans = (ans + t) % mod;
  printf("%lld\\n", (ans - 1 + mod) % mod);

  return 0;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
const int MAX = 2e5 + 10;
const ll mod = 1000000007;

int N;
ll a[MAX], b[MAX];
ll siz[MAX], color[MAX], c[MAX], col, vis[MAX];
map<piii, int> mp[2];

piii calc(ll x, ll y) {
  x = abs(x), y = abs(y);
  ll gcd = __gcd(x % y, y);
  return piii{x / y, {x % y / gcd, y / gcd}};
}

int main() {
#ifdef ACM_LOCAL
  freopen("input.in", "r", stdin);
  freopen("output.out", "w", stdout);
#endif
  scanf("%d", &N);
  ll ans = 0;
  for (int i = 1; i <= N; i++) {
    scanf("%lld%lld", a + i, b + i);
    if (a[i] == 0 && b[i] == 0)
      ans++;
    else {
      piii now = calc(a[i], b[i]), pre = calc(b[i], a[i]);
      int state = 0;
      if (1.0 * a[i] / b[i] > 0)
        state = 1;
      if (!mp[state].count(now)) {
        mp[state][now] = ++col;
        if (mp[state ^ 1].count(pre))
          c[col] = mp[state ^ 1][pre], c[mp[state ^ 1][pre]] = col;
      }
      siz[color[i] = mp[state][now]]++;
    }
  }
  ll t = 1;
  for (int i = 1; i <= col; i++)
    if (!vis[i]) {
      vis[i] = 1;
      if (c[i]) {
        vis[c[i]] = 1;
        t = t * ((1ll + siz[i] + siz[c[i]]) % mod) % mod;
      } else
        t = t * (1ll + siz[i]) % mod;
    }
  ans = (ans + t) % mod;
  printf("%lld\\n", (ans - 1 + mod) % mod);

  return 0;
}
Problem p02679 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
#define REP(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define pll pair<ll, ll>
#define pint pll
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;

map<pint, ll> cnt, refe;
map<pint, bool> used;

long long modpow(long long a, long long n) {
  long long res = 1;
  while (n > 0) {
    if (n & 1)
      res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

long long modinv(long long a) { return modpow(a, mod - 2); }

int main() {
  int n;
  cin >> n;
  ll ans = 1, zero = 0;
  rep(i, n) {
    ll x, y;
    cin >> x >> y;
    if (x == 0 && y == 0) {
      zero++;
      continue;
    }
    if (x < 0) {
      x *= -1;
      y *= -1;
    }
    ll z = __gcd(x, y);
    cnt[{x / z, y / z}]++;
    refe[{x / z, y / z}]++;
  }
  for (auto i : cnt) {
    pint p = i.first;
    ll nx = p.first, ny = p.second;
    if (used[{nx, ny}])
      continue;
    ll temp = modpow(2, refe[{nx, ny}]);
    //    cout << temp << 'y' << endl;
    used[{nx, ny}] = true;
    if (ny < 0) {
      ny *= -1;
      nx *= -1;
    }
    nx *= -1;
    ll g = __gcd(nx, ny);
    nx /= g;
    ny /= g;
    used[{ny, nx}] = true;
    ll nc = refe[{ny, nx}];
    //    cout << nc << 'u' << endl;
    temp += (modpow(2, nc));
    temp--;
    //    cout << temp << endl;
    temp %= mod;
    ans *= temp;
    ans %= mod;
  }
  //  ans*=modinv(2);
  //  ans%=mod;
  ans += mod - 1;
  ans %= mod;
  ans += zero;
  ans %= mod;
  cout << ans << endl;
  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define REP(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define pll pair<ll, ll>
#define pint pll
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;

map<pint, ll> cnt, refe;
map<pint, bool> used;

long long modpow(long long a, long long n) {
  long long res = 1;
  while (n > 0) {
    if (n & 1)
      res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

long long modinv(long long a) { return modpow(a, mod - 2); }

int main() {
  int n;
  cin >> n;
  ll ans = 1;
  rep(i, n) {
    ll x, y;
    cin >> x >> y;
    if (x < 0) {
      x *= -1;
      y *= -1;
    }
    ll z = __gcd(x, y);
    cnt[{x / z, y / z}]++;
    refe[{x / z, y / z}]++;
  }
  for (auto i : cnt) {
    pint p = i.first;
    ll nx = p.first, ny = p.second;
    if (used[{nx, ny}])
      continue;
    ll temp = modpow(2, refe[{nx, ny}]);
    //    cout << temp << 'y' << endl;
    used[{nx, ny}] = true;
    if (ny < 0) {
      ny *= -1;
      nx *= -1;
    }
    nx *= -1;
    ll g = __gcd(nx, ny);
    nx /= g;
    ny /= g;
    used[{ny, nx}] = true;
    ll nc = refe[{ny, nx}];
    //    cout << nc << 'u' << endl;
    temp += (modpow(2, nc));
    temp--;
    //    cout << temp << endl;
    temp %= mod;
    ans *= temp;
    ans %= mod;
  }
  //  ans*=modinv(2);
  //  ans%=mod;
  ans += mod - 1;
  ans %= mod;
  cout << ans << endl;
  return 0;
}
Problem p02679 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define cvector vector<char>
#define svector vector<string>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll, lvector, greater<ll>>
#define P pair<ll, ll>
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define print(a) cout << (a) << endl

ll mod = 1e9 + 7;

ll modpow(ll a, ll p) {
  ll ret = 1;
  while (p > 0) {
    if (p & 1)
      ret = (ret * a) % mod;
    a = (a * a) % mod;
    p >>= 1;
  }
  return ret;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll a, b, d, n, ans = 1, zero_w = 0;
  cin >> n;
  map<P, P> mp;
  rep(i, n) {
    cin >> a >> b;
    if (a == 0 && b == 0) {
      zero_w++;
      continue;
    }
    d = __gcd(a, b);
    a /= d, b /= d;
    if (b < 0)
      a = -a, b = -b;
    if (b == 0 && a < 0)
      a = -a, b = -b;
    if (a <= 0) {
      ll a_ = a;
      a = b;
      b = -a_;
      mp[P(a, b)].first++;
    } else
      mp[P(a, b)].second++;
  }
  for (auto p : mp) {
    a = p.second.first;
    b = p.second.second;
    ll ans_ = 1;
    ans_ += modpow(2, a) - 1;
    ans_ += modpow(2, b) - 1;
    ans_ %= mod;
    ans *= ans_;
    ans %= mod;
  }
  ans -= 1;
  ans += zero_w;
  ans %= mod;
  while (ans < 0)
    ans += mod;
  print(ans);
  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define cvector vector<char>
#define svector vector<string>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll, lvector, greater<ll>>
#define P pair<ll, ll>
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define print(a) cout << (a) << endl

ll mod = 1e9 + 7;

ll modpow(ll a, ll p) {
  ll ret = 1;
  while (p > 0) {
    if (p & 1)
      ret = (ret * a) % mod;
    a = (a * a) % mod;
    p >>= 1;
  }
  return ret;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll a, b, d, n, ans = 1, zero_w = 0;
  cin >> n;
  map<P, P> mp;
  rep(i, n) {
    cin >> a >> b;
    if (a == 0 && b == 0)
      zero_w++;
    d = __gcd(a, b);
    a /= d, b /= d;
    if (b < 0 || (b == 0 && a < 0))
      a = -a, b = -b;
    if (a <= 0) {
      ll a_ = a;
      a = b, b = -a_;
      mp[P(a, b)].first++;
    } else
      mp[P(a, b)].second++;
  }
  for (auto p : mp) {
    a = p.second.first, b = p.second.second;
    ll ans_ = 1;
    ans_ = (ans_ + modpow(2, a) - 1) % mod;
    ans_ = (ans_ + modpow(2, b) - 1) % mod;
    ans = (ans * ans_) % mod;
  }
  ans += zero_w - 1;
  print(ans % mod);
  return 0;
}
Problem p02679 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
const int N = 200000 + 10;
const int p = 1000000000 + 7;

long long gcd(long long a, long long b) { return !b ? a : gcd(b, a % b); }

void Change(long long &x, long long &y) {
  if (x < 0) {
    x = -x;
    y = -y;
  }
  if (x == 0 && y < 0) {
    y = -y;
  }
}

long long qpow(long long a, long long k = p - 2) {
  long long res = 1;
  while (k) {
    if (k & 1)
      res = res * a % p;
    a = a * a % p;
    k >>= 1;
  }
  return res;
}

int n;
map<pair<long long, long long>, int> mp;

int main() {
  scanf("%d", &n);
  long long ans = 0, tans = 1;
  for (int i = 1; i <= n; i++) {
    long long x, y;
    scanf("%lld %lld", &x, &y);
    if (!x && !y) {
      ans++;
      continue;
    }
    long long d = gcd(x, y);
    x /= d;
    y /= d;
    Change(x, y);
    pair<long long, long long> a = {x, y};
    swap(x, y);
    y = -y;
    Change(x, y);
    pair<long long, long long> b = {x, y};

    tans = tans * qpow(qpow(2, mp[a]) + qpow(2, mp[b]) - 1) % p;
    tans = tans * qpow(2, mp[a]) % p;
    ans = (ans + tans) % p;
    tans = tans * qpow(qpow(2, mp[a])) % p;
    mp[a]++;
    tans = tans * (qpow(2, mp[a]) + qpow(2, mp[b]) - 1) % p;
  }
  printf("%lld\\n", ans);
#ifndef ONLINE_JUDGE
  system("pause");
#endif
  return 0;
}

Error: 0
sh: 1: pause: not found


Fixed submission:

#include <bits/stdc++.h>
using namespace std;
const int N = 200000 + 10;
const int p = 1000000000 + 7;

long long gcd(long long a, long long b) { return !b ? a : gcd(b, a % b); }

void Change(long long &x, long long &y) {
  if (x < 0) {
    x = -x;
    y = -y;
  }
  if (x == 0 && y < 0) {
    y = -y;
  }
}

long long qpow(long long a, long long k = p - 2) {
  long long res = 1;
  while (k) {
    if (k & 1)
      res = res * a % p;
    a = a * a % p;
    k >>= 1;
  }
  return res;
}

int n;
map<pair<long long, long long>, int> mp;

int main() {
  scanf("%d", &n);
  long long ans = 0, tans = 1;
  for (int i = 1; i <= n; i++) {
    long long x, y;
    scanf("%lld %lld", &x, &y);
    // if (!x && !y)   continue;
    long long d = gcd(abs(x), abs(y));
    x /= d;
    y /= d;
    Change(x, y);
    pair<long long, long long> a = {x, y};
    swap(x, y);
    y = -y;

    Change(x, y);
    pair<long long, long long> b = {x, y};

    tans = tans * qpow(qpow(2, mp[a]) + qpow(2, mp[b]) - 1) % p;
    tans = tans * qpow(2, mp[a]) % p;
    ans = (ans + tans) % p;
    tans = tans * qpow(qpow(2, mp[a])) % p;
    mp[a]++;
    tans = tans * (qpow(2, mp[a]) + qpow(2, mp[b]) - 1) % p;
  }
  printf("%lld\\n", ans);
#ifndef ONLINE_JUDGE
  system("pause");
#endif
  return 0;
}
Problem p02679 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

ll gcd(ll a, ll b) {
  while (b) {
    ll c = a % b;
    a = b;
    b = c;
  }
  return a;
}

int main() {
  ios::sync_with_stdio(false);
  int n, y = 0;
  ll a[200005] = {}, b[200005] = {}, z = 1, p[200005] = {1};
  map<pair<ll, ll>, int> m;
  set<pair<ll, ll>> s;
  cin >> n;
  for (int i = 1; i <= n; i++)
    p[i] = p[i - 1] * 2 % mod;
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
    ll g = gcd(abs(a[i]), abs(b[i]));
    if (g == 0) {
      y++;
      continue;
    }
    a[i] /= g;
    b[i] /= g;
    m[{a[i], b[i]}]++;
  }
  for (auto i : m)
    if (s.find(i.first) == s.end()) {
      ll c, d, x = i.first.first, y = i.first.second;
      s.insert({x, y});
      s.insert({-y, x});
      s.insert({-x, -y});
      s.insert({y, -x});
      c = m[{x, y}] + m[{-x, -y}];
      d = m[{-y, x}] + m[{y, -x}];
      z = z * (p[c] + p[d] - 1) % mod;
    }
  cout << (z + mod - 1 + y) % mod;
}


Error: WA

Fixed submission:

#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

ll gcd(ll a, ll b) {
  while (b) {
    ll c = a % b;
    a = b;
    b = c;
  }
  return a;
}

int main() {
  ios::sync_with_stdio(false);
  int n, y = 0;
  ll a[200005] = {}, b[200005] = {}, z = 1, p[200005] = {1};
  map<pair<ll, ll>, int> m;
  set<pair<ll, ll>> s;
  cin >> n;
  for (int i = 1; i <= n; i++)
    p[i] = p[i - 1] * 2 % mod;
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
    ll g = gcd(abs(a[i]), abs(b[i]));
    if (g == 0) {
      return 1;
      y = 1;
      continue;
    }
    a[i] /= g;
    b[i] /= g;
    m[{a[i], b[i]}]++;
  }
  for (auto i : m)
    if (s.find(i.first) == s.end()) {
      ll c, d, x = i.first.first, y = i.first.second;
      s.insert({x, y});
      s.insert({-y, x});
      s.insert({-x, -y});
      s.insert({y, -x});
      c = m[{x, y}] + m[{-x, -y}];
      d = m[{-y, x}] + m[{y, -x}];
      z = z * (p[c] + p[d] - 1) % mod;
    }
  cout << (z + mod - 1 + y) % mod;
}
Problem p02679 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int MD = 1e9 + 7;
map<pair<ll, ll>, int> ma;
set<pair<ll, ll>> vis;
int quick_pow(int x, int y) {
  int ans = 1;
  while (y) {
    if (y & 1)
      ans = 1LL * ans * x % MD;
    y >>= 1;
    x = 1LL * x * x % MD;
  }
  return ans;
}
int main() {
  int n, s = 0;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    ll a, b;
    scanf("%lld%lld", &a, &b);
    ll d = __gcd(a, b);
    if (d == 0) {
      s++;
      continue;
    }
    a /= d, b /= d;
    if (a < 0)
      a = -a, b = -b;
    ma[{a, b}]++;
  }
  ll ans = 1;
  for (auto it : ma) {
    if (vis.find(it.first) != vis.end())
      continue;
    ll a = it.first.first, b = it.first.second;
    ll d = quick_pow(2, ma[{a, b}]);
    b = -b;
    if (b < 0)
      a = -a, b = -b;
    if (ma.count({b, a})) {
      d = (d + quick_pow(2, ma[{b, a}]) - 1) % MD;
      vis.insert({b, a});
    }
    ans = ans * d % MD;
  }
  ans = (ans - 1 + s + MD) % MD;
  printf("%lld\\n", ans);
  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int MD = 1e9 + 7;
map<pair<ll, ll>, int> ma;
int quick_pow(int x, int y) {
  int ans = 1;
  while (y) {
    if (y & 1)
      ans = 1LL * ans * x % MD;
    y >>= 1;
    x = 1LL * x * x % MD;
  }
  return ans;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    ll a, b;
    scanf("%lld%lld", &a, &b);
    if (a < 0)
      a = -a, b = -b;
    ll t = __gcd(a, abs(b));
    a /= t, b /= t;
    ma[{a, b}]++;
  }
  ll ans = 1;
  for (auto it : ma) {
    ll a = it.first.first, b = it.first.second;
    if (b < 0)
      b = -b, a = -a;
    int c = it.second;
    if (c == 0)
      continue;
    if (!ma.count({b, -a})) {
      ans = ans * quick_pow(2, c) % MD;
    } else {
      ans = ans * (quick_pow(2, c) + quick_pow(2, ma[{b, -a}]) - 1);
      ma[{b, -a}] = 0;
    }
  }
  printf("%lld\\n", (ans - 1 + MD) % MD);
  return 0;
}
Problem p02679 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#define mod 1000000007
using namespace std;
inline long long gcd(long long x, long long y) {
  if (x > y)
    swap(x, y);
  while (x)
    y %= x, swap(x, y);
  return y;
}
map<pair<long long, long long>, long long> mp;
pair<long long, long long> a[200005];
long long ksm[200005];
signed main(int argc, char **argv) {
  long long n;
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    long long x, y;
    scanf("%lld%lld", &x, &y);
    if (x < 0)
      x = -x, y = -y;
    if (x == 0 && y < 0)
      y = -y;
    long long G = gcd(max(x, -x), max(y, -y));
    if (G)
      x /= G, y /= G;
    else {
      if (x != 0)
        a[i] = {1, 0};
      else if (y != 0)
        a[i] = {0, 1};
      else
        a[i] = {0, 0};
    }
    a[i] = {x, y};
    ++mp[a[i]];
  }
  ksm[0] = 1;
  for (long long i = 1; i <= n; i++)
    ksm[i] = (ksm[i - 1] * 2 % mod);
  long long ans = 1, s = 0;
  for (long long i = 1; i <= n; i++) {
    if (a[i].first == 0 && a[i].second == 0) {
      ++s;
      continue;
    }
    long long x = mp[a[i]], y = max(mp[{a[i].second, -a[i].first}],
                                    mp[{-a[i].second, a[i].first}]);
    mp[a[i]] = mp[{a[i].second, -a[i].first}] = mp[{-a[i].second, a[i].first}] =
        0;
    ans *= ksm[x] + ksm[y] - 1, ans %= mod;
  }
  cout << (ans + mod - 1 + s) % mod;
  return 0;
}

Error: WA

Fixed submission:

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#define mod 1000000007
using namespace std;
inline long long gcd(long long x, long long y) {
  if (x > y)
    swap(x, y);
  while (x)
    y %= x, swap(x, y);
  return y;
}
map<pair<long long, long long>, long long> mp;
pair<long long, long long> a[200005];
long long ksm[200005];
signed main(int argc, char **argv) {
  long long n;
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    long long x, y;
    scanf("%lld%lld", &x, &y);
    if (x < 0)
      x = -x, y = -y;
    if (x == 0 && y < 0)
      y = -y;
    long long G = gcd(max(x, -x), max(y, -y));
    x /= G, y /= G;
    a[i] = {x, y};
    ++mp[a[i]];
  }
  ksm[0] = 1;
  for (long long i = 1; i <= n; i++)
    ksm[i] = (ksm[i - 1] * 2 % mod);
  long long ans = 1;
  for (long long i = 1; i <= n; i++) {
    long long x = mp[a[i]], y = max(mp[{a[i].second, -a[i].first}],
                                    mp[{-a[i].second, a[i].first}]);
    mp[a[i]] = mp[{a[i].second, -a[i].first}] = mp[{-a[i].second, a[i].first}] =
        0;
    ans *= ksm[x] + ksm[y] - 1, ans %= mod;
  }
  cout << (ans - mod + 1) % mod;
  return 0;
}
Problem p02679 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;
ll gcd(ll a, ll b) {
  if (a < b)
    gcd(b, a);
  ll r = 1;
  while (r != 0) {
    r = a % b;
    a = b;
    b = r;
  }
  return a;
}
ll modpow(ll a, ll n, ll mod = MOD) {
  ll res = 1;
  while (n > 0) {
    if (n & 1)
      res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}
ll sign(ll n) {
  if (n >= 0) {
    return 1;
  } else {
    return -1;
  }
}
int main() {
  int n;
  cin >> n;
  map<pair<ll, ll>, ll> cnt;
  for (int i = 0; i < n; i++) {
    ll a, b;
    cin >> a >> b;
    if (a == 0 && b == 0) {
      cnt[make_pair(0, 0)]++;
    } else if (a == 0 && b != 0) {
      cnt[make_pair(0, 1)]++;
    } else if (a != 0 && b == 0) {
      cnt[make_pair(1, 0)]++;
    } else {
      ll g = gcd(abs(a), abs(b));
      ll sig = sign(a) * sign(b);
      cnt[make_pair(sig * abs(a) / g, abs(b) / g)]++;
    }
  }
  ll ans = 1;
  for (auto e : cnt) {
    if (e.second == 0) {
      continue;
    }
    if (e.first == make_pair(0LL, 0LL)) {
      continue;
    }
    pair<ll, ll> ort;
    if (e.first == make_pair(0LL, 1LL)) {
      ort = make_pair(1, 0);
    } else if (e.first == make_pair(1LL, 0LL)) {
      ort = make_pair(0, 1);
    } else {
      ort = make_pair(-sign(e.first.first) * abs(e.first.second),
                      abs(e.first.first));
      ;
    }
    ans *= modpow(2, e.second) + modpow(2, cnt[ort]) - 1;
    ans %= MOD;
    cnt[ort] = 0;
    cnt[e.first] = 0;
  }
  cout << (cnt[make_pair(0, 0)] + ans - 1 + MOD) % MOD << endl;
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;
ll gcd(ll a, ll b) {
  if (a < b)
    gcd(b, a);
  ll r = 1;
  while (r != 0) {
    r = a % b;
    a = b;
    b = r;
  }
  return a;
}
ll modpow(ll a, ll n, ll mod = MOD) {
  ll res = 1;
  while (n > 0) {
    if (n & 1)
      res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}
int main() {
  int n;
  cin >> n;
  vector<ll> a(n), b(n);
  map<pair<ll, ll>, ll> r1, r2;
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
    ll g = gcd(abs(a[i]), abs(b[i]));
    ll sig = a[i] * b[i];
    if (a[i] * b[i] > 0) {
      sig = 1;
    }
    if (a[i] * b[i] < 0) {
      sig = -1;
    }
    r1[make_pair(sig * abs(a[i]) / g, abs(b[i]) / g)]++;
    r2[make_pair(abs(b[i]) / g, -sig * abs(a[i]) / g)]++;
  }
  ll ans = 1;
  for (auto &e : r1) {
    auto tmp = e.first;
    swap(tmp.first, tmp.second);
    ans *= modpow(2, e.second) + modpow(2, r2[tmp]) - 1;
    ans %= MOD;
    r2[tmp] = 0;
    e.second = 0;
  }
  cout << ans - 1 << endl;
}