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<ll, ll> pll;
map<pll, ll> cnt;

const int N = int(2e5) + 100;
ll a[N], b[N];
const ll mod = ll(1e9) + 7LL;

ll fast_pow(ll x, ll e) {
  ll b = x;
  ll r = 1LL;

  while (e) {
    if (e & 1LL) {
      r = (r * b) % mod;
    }

    e >>= 1LL;
    b = (b * b) % mod;
  }

  return r;
}

int main() {
  int n;

  scanf("%d", &n);

  ll joker = 0LL;

  for (int i = 0; i < n; i++) {
    scanf("%lld %lld", &a[i], &b[i]);

    if (a[i] == 0 && b[i] == 0) {
      joker++;
      continue;
    }

    ll g = __gcd(a[i], b[i]);
    a[i] /= g;
    b[i] /= g;

    if (a[i] < 0) {
      a[i] *= -1LL;
      b[i] *= -1LL;
    }

    cnt[{a[i], b[i]}]++;
  }

  ll tot = 1LL;
  ll qtdg = 0;
  ll add = joker;

  for (auto u : cnt) {
    if (u.first.second < 0) {
      continue;
    }

    auto v = u.first;
    swap(v.first, v.second);

    v.second *= -1;

    // cout << u.first.first << " " << u.first.second << " | " << v.first << " "
    // << v.second << endl;

    if (cnt.count(v) == 0) {
      qtdg++;
    } else {
      add += cnt[u.first] + cnt[v];

      // cout << cnt[u.first] << " " << cnt[v] << " " << v.first << " " <<
      // v.second << endl;

      tot =
          (tot *
           ((fast_pow(2LL, cnt[u.first]) + fast_pow(2LL, cnt[v]) - 1LL) % mod) %
           mod) %
          mod;
    }
  }

  tot = (tot * fast_pow(2LL, ll(n) - add)) % mod;
  tot = ((tot - 1LL) % mod + mod) % mod;
  tot += joker;

  if (tot >= mod)
    tot -= mod;

  printf("%lld\\n", tot);

  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

typedef pair<ll, ll> pll;
map<pll, ll> cnt;

const int N = int(2e5) + 100;
ll a[N], b[N];
const ll mod = ll(1e9) + 7LL;

ll fast_pow(ll x, ll e) {
  ll b = x;
  ll r = 1LL;

  while (e) {
    if (e & 1LL) {
      r = (r * b) % mod;
    }

    e >>= 1LL;
    b = (b * b) % mod;
  }

  return r;
}

int main() {
  int n;

  scanf("%d", &n);

  for (int i = 0; i < n; i++) {
    scanf("%lld %lld", &a[i], &b[i]);

    if (a[i] == 0 && b[i] == 0) {
      assert(false);
    }

    ll g = __gcd(a[i], b[i]);
    a[i] /= g;
    b[i] /= g;

    if (a[i] < 0) {
      a[i] *= -1LL;
      b[i] *= -1LL;
    }

    cnt[{a[i], b[i]}]++;
  }

  ll tot = 1LL;
  ll qtdg = 0;
  ll add = 0LL;

  for (auto u : cnt) {
    if (u.first.second < 0) {
      continue;
    }

    auto v = u.first;
    swap(v.first, v.second);

    v.second *= -1;

    // cout << u.first.first << " " << u.first.second << " | " << v.first << " "
    // << v.second << endl;

    if (cnt.count(v) == 0) {
      qtdg++;
    } else {
      add += cnt[u.first] + cnt[v];

      // cout << cnt[u.first] << " " << cnt[v] << " " << v.first << " " <<
      // v.second << endl;

      tot =
          (tot *
           ((fast_pow(2LL, cnt[u.first]) + fast_pow(2LL, cnt[v]) - 1LL) % mod) %
           mod) %
          mod;
    }
  }

  tot = (tot * fast_pow(2LL, ll(n) - add)) % mod;

  printf("%lld\\n", ((tot - 1LL) % mod + mod) % mod);

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

#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
const int mod = 1000000007;
typedef long long ll;
typedef pair<ll, ll> ii;
ll gcd(ll a, ll b) { return a == 0 ? b : gcd(b % a, a); }
ll p2[N];
ll ans = 1;
void f(ll &a, ll &b) {
  ll g = gcd(abs(a), abs(b));
  if (g == 0)
    return;
  a /= g;
  b /= g;
  if (b < 0) {
    a = -a;
    b = -b;
  }
  if (a < 0) {
    a = -a;
    b = -b;
  }
}
ii D(ii a) { return ii(a.second, -a.first); }
map<ii, int> ct;
map<ii, int> vis;
int main() {
  int n;
  scanf("%d", &n);
  p2[0] = 1ll;
  for (int i = 1; i <= n; i++) {
    p2[i] = (p2[i - 1] * 2) % mod;
  }
  for (int i = 0; i < n; i++) {
    ll a, b;
    scanf("%lld%lld", &a, &b);
    f(a, b);
    ct[ii(a, b)]++;
  }
  for (auto it : ct) {
    ii k = it.first;
    if (vis[it.first])
      continue;
    if (k.first == 0 && k.second == 0) {
      continue;
    }
    // printf("have vector %lld %lld\\n",k.first,k.second);
    k = D(k);
    // printf("dot %lld %lld\\n",k.first,k.second);
    f(k.first, k.second);
    // printf("correct %lld %lld\\n",k.first,k.second);
    int s1 = it.second, s2 = ct[k];
    // printf("ct = %d, %d\\n",s1,s2);
    ans *= (p2[s1] + p2[s2] - 1);
    ans %= mod;
    vis[it.first] = vis[k] = 1;
  }
  ans += ct[ii(0, 0)];
  ans = (ans + mod - 1) % mod;
  printf("%lld", ans);
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
const int mod = 1000000007;
typedef long long ll;
typedef pair<ll, ll> ii;
ll gcd(ll a, ll b) { return a == 0 ? b : gcd(b % a, a); }
ll p2[N];
ll ans = 1;
void f(ll &a, ll &b) {
  ll g = gcd(abs(a), abs(b));
  a /= g;
  b /= g;
  if (b < 0) {
    a = -a;
    b = -b;
  }
  if (a < 0) {
    a = -a;
    b = -b;
  }
}
ii D(ii a) { return ii(a.second, -a.first); }
map<ii, int> ct;
int main() {
  int n;
  scanf("%d", &n);
  p2[0] = 1ll;
  for (int i = 1; i <= n; i++) {
    p2[i] = (p2[i - 1] * 2) % mod;
  }
  for (int i = 0; i < n; i++) {
    ll a, b;
    scanf("%lld%lld", &a, &b);
    f(a, b);
    ct[ii(a, b)]++;
  }
  for (auto it : ct) {
    ii k = it.first;
    if (it.second == 0)
      continue;
    // printf("have vector %lld %lld\\n",k.first,k.second);
    k = D(k);
    // printf("dot %lld %lld\\n",k.first,k.second);
    f(k.first, k.second);
    // printf("correct %lld %lld\\n",k.first,k.second);
    int s1 = it.second, s2 = ct[k];
    // printf("ct = %d, %d\\n",s1,s2);
    ans *= (p2[s1] + p2[s2] - 1);
    ans %= mod;
    ct[it.first] = 0;
    ct[k] = 0;
  }
  ans = (ans + mod - 1) % mod;
  printf("%lld", ans);
}
Problem p02679 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

#define pb push_back
#define fi first
#define se second
#define eb emplace_back

using namespace std;

typedef pair<int, int> ii;
typedef long long ll;
const int N = 1000007, M = 1e9 + 7, inf = 0x3f3f3f3f;

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

ll pot[N];

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);

  pot[0] = 1;
  for (int i = 1; i < N; i++) {
    pot[i] = pot[i - 1] * 2ll % M;
  }
  int n;
  cin >> n;

  map<pair<ll, ll>, int> cnt;

  int uno, dos, ambos;
  uno = 0, dos = 0, ambos = 0;
  for (int i = 0; i < n; i++) {
    ll a, b;
    cin >> a >> b;

    if (!a or !b) {
      if (a == 0 and b == 0)
        ambos++;
      else if (a == 0)
        uno++;
      else
        dos++;
      continue;
    }

    int nega = 0;
    if (a < 0) {
      nega ^= 1;
      a = -a;
    }

    if (b < 0) {
      nega ^= 1;
      b = -b;
    }

    ll g = gcd(a, b);
    a /= g;
    b /= g;

    if (nega)
      a = -a;
    cnt[{a, b}]++;
  }

  ll ans = 1;
  for (auto aux : cnt) {
    ll a, b;
    tie(a, b) = aux.first;

    if (a < 0 and cnt.count({b, -a}))
      continue;

    if (cnt.count({-b, a})) {
      ans = ans * ((pot[aux.se] + pot[cnt[{-b, a}]] - 1) % M) % M;
    } else {
      ans = ans * pot[aux.second] % M;
    }
  }

  ans = ans * ((pot[uno] + pot[dos] - 1) % M) % M;

  cout << (ans + ambos - 1 + M) % M << '\\n';
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>

#define pb push_back
#define fi first
#define se second
#define eb emplace_back

using namespace std;

typedef pair<int, int> ii;
typedef long long ll;
const int N = 1000007, M = 1e9 + 7, inf = 0x3f3f3f3f;

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

ll pot[N];

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);

  pot[0] = 1;
  for (int i = 1; i < N; i++) {
    pot[i] = pot[i - 1] * 2ll % M;
  }
  int n;
  cin >> n;

  map<pair<ll, ll>, int> cnt;
  for (int i = 0; i < n; i++) {
    ll a, b;
    cin >> a >> b;

    int nega = 0;
    if (a < 0) {
      nega ^= 1;
      a = -a;
    }

    if (b < 0) {
      nega ^= 1;
      b = -b;
    }

    ll g = gcd(a, b);
    a /= g;
    b /= g;

    if (nega)
      a = -a;
    cnt[{a, b}]++;
  }

  ll ans = 1;
  for (auto aux : cnt) {
    ll a, b;
    tie(a, b) = aux.first;

    if (a < 0 and cnt.count({b, -a}))
      continue;

    if (cnt.count({-b, a})) {
      ans = ans * ((pot[aux.se] + pot[cnt[{-b, a}]] - 1) % M) % M;
    } else {
      ans = ans * pot[aux.second];
    }
  }
  cout << (ans - 1 + M) % M << '\\n';
}
Problem p02679 (C++) — buggy submission, verdict: Runtime Error

#include <cmath>
#include <iostream>
#include <map>
#include <vector>
using namespace std;

long long gcd(long long a, long long b) {
  if (b == 0)
    return a;
  return gcd(b, a % b);
}

long long mod = 1000000007;
long long N, A[1 << 18], B[1 << 18], power[1 << 18];
map<pair<long long, long long>, int> Map, V;

void init() {
  power[0] = 1;
  for (int i = 1; i <= 250000; i++)
    power[i] = (2LL * power[i - 1]) % mod;
}

int main() {
  cin >> N;
  init();

  int addi = 0;
  for (int i = 1; i <= N; i++) {
    cin >> A[i] >> B[i];
    if (A[i] == 0 && B[i] == 0) {
      addi++;
      continue;
    }
    if (A[i] == 0) {
      A[i] = 0;
      B[i] = 1;
    } else if (B[i] == 0) {
      A[i] = 1;
      B[i] = 0;
    } else {
      long long v = gcd(abs(A[i]), abs(B[i]));
      A[i] /= v;
      B[i] /= v;
      if (A[i] < 0) {
        A[i] *= -1LL;
        B[i] *= -1LL;
      }
    }
    Map[make_pair(A[i], B[i])] += 1;
  }

  long long sum = 1;
  for (int i = 1; i <= N; i++) {
    if (V[make_pair(A[i], B[i])] == 1)
      continue;
    if (A[i] == 0 && B[i] == 0)
      continue;

    long long r1 = B[i], r2 = -A[i];
    if (r1 < 0) {
      r1 *= -1LL;
      r2 *= -1LL;
    }
    if (r1 == 0 && r2 < 0) {
      r1 *= -1LL;
      r2 *= -1LL;
    }

    long long c1 = Map[make_pair(A[i], B[i])];
    long long c2 = Map[make_pair(r1, r2)];
    sum *= (power[c1] + power[c2] - 1LL + mod) % mod;
    sum %= mod;
    V[make_pair(A[i], B[i])] = 1;
    V[make_pair(r1, r2)] = 1;
  }
  sum += addi;

  cout << (sum + mod - 1LL) % mod << endl;
  return 0;
}

Error: 0

Fixed submission:

#include <cmath>
#include <iostream>
#include <map>
#include <vector>
using namespace std;

long long gcd(long long a, long long b) {
  if (b == 0)
    return a;
  return gcd(b, a % b);
}

long long mod = 1000000007;
long long N, A[1 << 18], B[1 << 18], power[1 << 18];
map<pair<long long, long long>, int> Map, V;

void init() {
  power[0] = 1;
  for (int i = 1; i <= 250000; i++)
    power[i] = (2LL * power[i - 1]) % mod;
}

int main() {
  cin >> N;
  init();
  for (int i = 1; i <= N; i++) {
    cin >> A[i] >> B[i];
    long long v = gcd(abs(A[i]), abs(B[i]));
    A[i] /= v;
    B[i] /= v;
    if (A[i] < 0) {
      A[i] *= -1LL;
      B[i] *= -1LL;
    }
    Map[make_pair(A[i], B[i])] += 1;
  }

  long long sum = 1;
  for (int i = 1; i <= N; i++) {
    if (V[make_pair(A[i], B[i])] == 1)
      continue;
    long long r1 = B[i], r2 = -A[i];
    if (r1 < 0) {
      r1 *= -1LL;
      r2 *= -1LL;
    }

    long long c1 = Map[make_pair(A[i], B[i])];
    long long c2 = Map[make_pair(r1, r2)];
    sum *= (power[c1] + power[c2] - 1LL + mod) % mod;
    sum %= mod;
    V[make_pair(A[i], B[i])] = 1;
    V[make_pair(r1, r2)] = 1;
  }

  cout << (sum + mod - 1LL) % mod << endl;
  return 0;
}
Problem p02679 (C++) — buggy submission, verdict: Runtime Error

// -----------------------------------
// Author     : MatsuTaku
// Country    : Japan
// Created    : 05/17/20 20:37:02
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

constexpr ll MOD = 1000000007;

ll modpow(ll x, ll p) {
  ll u = x;
  ll t = 1;
  while (p) {
    if (p & 1)
      (t *= u) %= MOD;
    (u *= u) %= MOD;
    p >>= 1;
  }
  return t;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  int n;
  cin >> n;
  map<pair<ll, ll>, int> AB;
  int zz = 0, ze = 0, ez = 0;
  for (int i = 0; i < n; i++) {
    ll a, b;
    cin >> a >> b;
    if (a != 0 and b != 0) {
      if (b < 0) {
        a *= -1;
        b *= -1;
      }
      auto g = gcd(abs(a), abs(b));
      a /= g;
      b /= g;
      AB[{a, b}]++;
    } else if (a == 0 and b == 0) {
      zz++;
    } else if (a == 0) {
      ze++;
    } else {
      ez++;
    }
  }
  ll ans = 1;
  for (auto it = AB.begin(); it != AB.end(); ++it) {
    auto [k, c] = *it;
    if (c == 0)
      continue;
    auto [a, b] = k;
    ll p;
    auto invkey = make_pair(-b, a);
    if (a < 0) {
      invkey.first *= -1;
      invkey.second *= -1;
    }
    auto inv = AB.find(invkey);
    if (inv != AB.end()) {
      p = ((modpow(2, c) + modpow(2, inv->second)) % MOD + MOD - 1) % MOD;
      inv->second = 0;
    } else {
      p = modpow(2, c);
    }
    (ans *= p) %= MOD;
  }
  (ans *= ((modpow(2, ze) + modpow(2, ez)) % MOD + MOD - 1) % MOD) %= MOD;
  cout << (ans + zz - 1 + MOD) % MOD << endl;

  return 0;
}


Error: 0

Fixed submission:

// -----------------------------------
// Author     : MatsuTaku
// Country    : Japan
// Created    : 05/17/20 20:37:02
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

constexpr ll MOD = 1e9 + 7;

ll modpow(ll x, ll p) {
  ll u = x;
  ll t = 1;
  while (p) {
    if (p & 1)
      (t *= u) %= MOD;
    (u *= u) %= MOD;
    p >>= 1;
  }
  return t;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  int n;
  cin >> n;
  map<pair<ll, ll>, int> AB;
  for (int i = 0; i < n; i++) {
    ll a, b;
    cin >> a >> b;
    auto g = gcd(a, b);
    a /= g;
    b /= g;
    if (b < 0) {
      a *= -1;
      b *= -1;
    }
    AB[{a, b}]++;
  }
  ll ans = 1;
  for (auto it = AB.begin(); it != AB.end(); ++it) {
    auto [k, c] = *it;
    if (c == 0)
      continue;
    auto [a, b] = k;
    ll p;
    auto invkey = make_pair(-b, a);
    if (a < 0) {
      invkey.first *= -1;
      invkey.second *= -1;
    }
    auto inv = AB.find(invkey);
    if (inv != AB.end()) {
      (p = modpow(2, c) + modpow(2, inv->second) - 1) %= MOD;
      inv->second = 0;
    } else {
      p = modpow(2, c);
    }
    (ans *= p) %= MOD;
  }
  cout << (ans + MOD - 1) % MOD << endl;

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

/*
 *       ~ AtCoder  Botay ~
 *        code by kazalika
 */

#include <bits/stdc++.h>

using namespace std;

const long long mod = 1e9 + 7;

long long pw(long long a, long long b) {
  if (!b)
    return 1;
  if (b % 2)
    return (pw(a, b - 1) * a) % mod;
  long long v = pw(a, b / 2);
  return (v * v) % mod;
}

long long gcd(long long a, long long b) {
  if (a < b)
    swap(a, b);
  if (!b)
    return a;
  if (a % b == 0)
    return b;
  return gcd(b, a % b);
}

pair<long long, long long> get(long long a, long long b) {
  if (b == 0)
    return {1, 0};
  if (a == 0)
    return {0, 1};
  if (b > 0)
    return {a / gcd(abs(a), abs(b)), b / gcd(abs(a), abs(b))};
  return {-a / gcd(abs(a), abs(b)), -b / gcd(abs(a), abs(b))};
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int n;
  cin >> n;

  map<pair<long long, long long>, long long> mp, rmp;
  long long ans = 1, cn = 0;
  for (int i = 0; i < n; ++i) {
    long long a, b;
    cin >> a >> b;
    if (a == 0 && b == 0) {
      cn++;
      continue;
    }
    pair<long long, long long> vp = get(a, b),
                               rvp = (a != 0 ? get(b, -a) : get(-b, a));
    if (mp.find(rvp) != mp.end())
      rmp[rvp]++;
    else
      mp[vp]++;
  }
  for (auto &i : mp) {
    long long vl = pw(2, i.second);
    if (rmp.find(i.first) != rmp.end())
      vl += pw(2, rmp[i.first]) - 1;
    vl %= mod;
    ans = (ans * vl) % mod;
  }
  cout << (ans + cn - 1 + mod) % mod;
}

Error: WA

Fixed submission:

/*
 *       ~ AtCoder  Botay ~
 *        code by kazalika
 */

#include <bits/stdc++.h>

using namespace std;

const long long mod = 1e9 + 7;

long long pw(long long a, long long b) {
  if (!b)
    return 1;
  if (b & 1)
    return (pw(a, b - 1) * a) % mod;
  long long v = pw(a, b / 2);
  return (v * v) % mod;
}

long long gcd(long long a, long long b) {
  if (a < b)
    swap(a, b);
  if (a % b == 0)
    return b;
  if (!b)
    return a;
  return gcd(b, a % b);
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int n;
  cin >> n;
  vector<pair<long long, long long>> v(n);

  map<pair<long long, long long>, long long> mp, rmp;
  long long ans = 1, cn = 0;
  for (int i = 0; i < n; ++i) {
    long long a, b;
    cin >> a >> b;
    bool ok = true;
    if (b == 0) {
      if (a > 0)
        v[i] = {1, 0};
      else if (a < 0)
        v[i] = {-1, 0};
      else {
        cn++;
        ok = false;
      }
    } else if (b > 0)
      v[i] = {a / gcd(abs(a), abs(b)), b / gcd(abs(a), abs(b))};
    else
      v[i] = {-a / gcd(abs(a), abs(b)), -b / gcd(abs(a), abs(b))};
    if (!ok)
      continue;
    a = v[i].first;
    b = v[i].second;
    pair<long long, long long> chk;
    if (a < 0)
      chk = {b, -a};
    else
      chk = {-b, a};
    if (mp.find(chk) != mp.end())
      rmp[chk]++;
    else
      mp[v[i]]++;
  }
  for (auto i : mp) {
    long long vl = pw(2, i.second);
    if (rmp.find(i.first) != rmp.end())
      vl += pw(2, rmp[i.first]) - 1;
    ans = (ans * vl) % mod;
  }
  cout << ans + cn - 1;
}
Problem p02679 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back
#define fi first
#define se second
const ll inf = 1e18;
const ld pi = acos(-1.0);
const int N = 3e5 + 6;
const int M = 1e9 + 7;
map<pair<ll, ll>, int> mp;
ll po(ll a, ll b) {
  if (b == 0)
    return 1;
  ll x = po(a, b / 2);
  x = (x * x) % M;
  if (b & 1)
    x = (x * a) % M;
  return x;
}
void solve() {
  int n;
  cin >> n;
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    ll x, y;
    cin >> x >> y;
    if (x == 0 and y == 0) {
      cnt++;
      continue;
    }
    //    px[i] = x;
    //   py[i] = y;
    ll g = __gcd(x, y);
    x = x / g;
    y = y / g;
    mp[{x, y}]++;
  }
  ll ans = 1;
  for (auto p : mp) {
    ll c = p.second;
    ll x = p.first.first;
    ll y = p.first.second;
    if (c == 0)
      continue;
    ll xx = y;
    ll yy = -x;
    ll g = __gcd(xx, yy);
    xx /= g;
    yy /= g;
    ll pp = mp[{xx, yy}];
    mp[{xx, yy}] = 0;

    ll A = po(2, c) - 1;
    ll B = po(2, pp) - 1;
    ans *= (A + B + 1);
    ans %= M;
  }
  ans += cnt;
  ans %= M;
  cout << (ans - 1 + M) % M << endl;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  //   cin>>t;
  while (t--)
    solve();
  return 0;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back
#define fi first
#define se second
const ll inf = 1e18;
const ld pi = acos(-1.0);
const int N = 3e5 + 6;
const int M = 1e9 + 7;
map<pair<ll, ll>, int> mp;
ll po(ll a, ll b) {
  if (b == 0)
    return 1;
  ll x = po(a, b / 2);
  x = (x * x) % M;
  if (b & 1)
    x = (x * a) % M;
  return x;
}
void solve() {
  int n;
  cin >> n;
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    ll x, y;
    cin >> x >> y;
    //    px[i] = x;
    //   py[i] = y;
    ll g = __gcd(x, y);
    x = x / g;
    y = y / g;
    mp[{x, y}]++;
  }
  ll ans = 1;
  for (auto p : mp) {
    ll c = p.second;
    ll x = p.first.first;
    ll y = p.first.second;
    if (c == 0)
      continue;
    ll xx = y;
    ll yy = -x;
    ll g = __gcd(xx, yy);
    xx /= g;
    yy /= g;
    ll pp = mp[{xx, yy}];
    mp[{xx, yy}] = 0;

    ll A = po(2, c) - 1;
    ll B = po(2, pp) - 1;
    ans *= (A + B + 1);
    ans %= M;
  }
  cout << ans - 1 << endl;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  //   cin>>t;
  while (t--)
    solve();
  return 0;
}
Problem p02679 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;

const int N = 200200;
long long p2[N];
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  p2[0] = 1;
  for (int i = 1; i < N; i++) {
    p2[i] = (p2[i - 1] * 2) % mod;
  }
  int n;
  cin >> n;

  map<pair<long long, long long>, pair<int, int>> m;
  long long zeros = mod - 1;

  for (int i = 0; i < n; i++) {
    long long a, b;
    cin >> a >> b;
    if (a == 0 && b == 0) {
      zeros++;
      continue;
    }

    if (make_pair(a, b) < make_pair(0LL, 0LL)) {
      a = -a;
      b = -b;
    }
    long long g = gcd(abs(a), abs(b));
    a /= g;
    b /= g;
    if (b > 0)
      m[{a, b}].first++;
    else
      m[{-b, a}].second++;
  }

  long long ans = 1;
  for (auto e : m) {
    pair<int, int> cnt = e.second;
    ans = ans * (p2[cnt.first] + p2[cnt.second] - 1) % mod;
  }
  ans = (ans + zeros) % mod;
  cout << ans << endl;
  return 0;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

  int n;
  cin >> n;

  map<pair<long long, long long>, pair<int, int>> m;
  int zeros = 0;

  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    if (a == 0 && b == 0)
      zeros++;
    else {
      int g = __gcd(abs(a), abs(b));
      a /= g;
      b /= g;
      if (a > 0 and b >= 0) {
        m[{a, b}].first++;
      } else if (a <= 0 and b < 0) {
        m[{-a, -b}].first++;
      } else if (a >= 0 and b < 0) {
        m[{-b, a}].second++;
      } else if (a <= 0 and b > 0) {
        m[{b, -a}].second++;
      }
    }
  }

  long long int ans = 1;
  for (auto e : m) {
    pair<int, int> cnt = e.second;
    ans *= 1LL * pow(2, cnt.first) + 1LL * pow(2, cnt.second) - 1LL;
    ans = ans % mod;
  }
  if (zeros)
    ans *= 1LL * zeros;
  ans = ans % mod;
  ans--;
  cout << ans << endl;
  return 0;
}