Problem p02679 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i, m, n) for (ll(i) = (m), (i_len) = (n); (i) < (i_len); ++(i))
#define FORR(i, v) for (auto(i) : v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define ASC(x) sort(ALL((x)))
#define DESC(x) sort(ALL((x)), greater<ll>())
#define REV(x) reverse(ALL((x)))
#define pb push_back

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

ll modpow(ll a, ll n, ll m) {
  if (n == 0)
    return 1;
  ll t = modpow(a, n >> 1, m);
  t = t * t % m;
  if (n & 1)
    t = t * a % m;
  return t;
}

int main() {
  ll N;
  cin >> N;
  map<pair<ll, ll>, ll> R, S;
  ll c = 0;
  REP(i, 0, N) {
    ll a, b;
    cin >> a >> b;
    if (b == 0) {
      if (a == 0) {
        ++c;
        continue;
      } else if (a < 0)
        a = -a;
    } else if (b < 0) {
      a = -a;
      b = -b;
    };
    ll g = gcd(abs(a), abs(b));
    ++R[{a / g, b / g}];
  }

  ll sum = 1;
  FORR(r, R) {
    pair<ll, ll> p = r.first, s;
    ll ci = r.second, cj;
    R[p] = 0;
    if (p.first > 0)
      s = {-p.second, p.first};
    else
      s = {p.second, -p.first};
    if (R.count(s) > 0) {
      cj = R[s];
      R[s] = 0;
    } else
      cj = 0;
    ll t = (modpow(2, ci, MOD) + modpow(2, cj, MOD) - 1 + MOD) % MOD;
    sum = (sum * t) % MOD;
  }
  PR((sum + c - 1 + MOD) % MOD);

  return 0;
}

/*



*/

Error: 0

Fixed submission:

#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i, m, n) for (ll(i) = (m), (i_len) = (n); (i) < (i_len); ++(i))
#define FORR(i, v) for (auto(i) : v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define ASC(x) sort(ALL((x)))
#define DESC(x) sort(ALL((x)), greater<ll>())
#define REV(x) reverse(ALL((x)))
#define pb push_back

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

ll modpow(ll a, ll n, ll m) {
  if (n == 0)
    return 1;
  ll t = modpow(a, n >> 1, m);
  t = t * t % m;
  if (n & 1)
    t = t * a % m;
  return t;
}

int main() {
  ll N;
  cin >> N;
  map<pair<ll, ll>, ll> R, S;
  ll c = 0;
  REP(i, 0, N) {
    ll a, b;
    cin >> a >> b;
    if (b == 0) {
      if (a == 0)
        ++c;
      else if (a < 0)
        a = -a;
    } else if (b < 0) {
      a = -a;
      b = -b;
    };
    ll g = gcd(abs(a), abs(b));
    ++R[{a / g, b / g}];
  }

  S = R;
  ll sum = 1;
  FORR(r, R) {
    pair<ll, ll> p = r.first, s;
    ll ci = S[p], cj;
    S[p] = 0;
    if (p.first > 0)
      s = {-p.second, p.first};
    else
      s = {p.second, -p.first};
    if (S.count(s) > 0) {
      cj = S[s];
      S[s] = 0;
    } else
      cj = 0;
    ll t = (modpow(2, ci, MOD) + modpow(2, cj, MOD) - 1 + MOD) % MOD;
    sum = (sum * t) % MOD;
  }
  PR(sum + c - 1);

  return 0;
}

/*



*/