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

//  RAKSHIT KADAM
// ALWAYS USE &IT FOR ITERATING USING AUTO ...
// USE COUNT(STARTING ADDRESS, ENDING ADRESS ,VALUE) FOR FINDING THE COUNT IN
// THE RESPECTIVE DATA STRUCTURE NOTE THAT MEMSET CANT FILL THE DOUBLE VALUES;
// ACCUMULATE DOES NOT WORK PROPERLY IF VALUES START SUMMING BEYOND 1E9...
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree< int ,  null_type ,  less<int> ,  rb_tree_tag ,
// tree_order_statistics_node_update>
#warning !!!check the size of arrayss!!!

// NUMERIC DEFINITIONS :
#define INF 100000000000000005
#define inf 1000000000
#define MOD 1000000007
#define newMOD 998244353
#define MAX 300006
#define pi 3.1415926535897932384626433832795
#define ld long double
#define ll long long
#define int long long

#define P(gg)                                                                  \\
  for (auto rax : gg) {                                                        \\
    cout << rax << " ";                                                        \\
  }                                                                            \\
  cout << endl;
#define Need_for_speed(activated)                                              \\
  ios_base ::sync_with_stdio(0);                                               \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL)
#define satisfy                                                                \\
  ll t;                                                                        \\
  cin >> t;                                                                    \\
  while (t--)
#define inp(n)                                                                 \\
  int n;                                                                       \\
  cin >> n
#define mp make_pair
#define pb push_back
#define endl "\\n"
#define x first
#define y second
#define fore(i, a, b) for (ll i = a; i < b; i++)
#define forci(i, n) for (ll i = 0; i < n; i++)
#define vi vector<ll>
#define Endl endl
#define lb lower_bound
#define ub upper_bound
#define pii pair<ll, ll>

#define input                                                                  \\
  freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
#define time                                                                   \\
  cerr << "\\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\\n";
using namespace std;

ll gcd(ll a, ll b) {
  if (b == 0)
    return a;
  return gcd(b, a % b);
}
int power(int x, unsigned int y, unsigned int m) {
  if (y == 0)
    return 1;
  int p = power(x, y / 2, m) % m;
  p = (p * p) % m;
  return (y % 2 == 0) ? p : (x * p) % m;
}
ll modInverse(int a, int m) {
  { return power(a, m - 2, m); }
}
const int maxn = 500003;

void solve() {
  ll n;
  cin >> n;
  map<pii, ll> m;
  ll a, b;
  ll cntt = 0;
  ll pow2[200005] = {0};
  pow2[0] = 1;
  for (ll i = 1; i < 200005; i++) {
    (pow2[i] = pow2[i - 1] * (2)) %= MOD;
  }
  for (ll i = 0; i < n; i++) {
    cin >> a >> b;
    if (!a && !b) {
      cntt++;
      continue;
    }
    if (a < 0)
      a *= -1, b *= -1;
    if (a == 0 || b == 0) {
      if (a < 0)
        a *= -1;
      if (b < 0)
        b *= -1;
    }
    ll g = abs(gcd(a, b));
    m[mp(a / g, b / g)]++;
  }
  ll ans = 1;
  for (auto it : m) {
    if (it.y == 0)
      continue;
    ll l = it.x.x;
    ll r = it.x.y;
    ll cnt = it.y;
    ll p1 = -r;
    ll p2 = l;

    m[mp(it.x.x, it.x.y)] = 0;

    if (p1 < 0)
      p1 *= -1, p2 *= -1;
    if (p1 == 0 || p2 == 0) {
      if (p1 < 0)
        p1 *= -1;
      if (p2 < 0)
        p2 *= -1;
    }
    ll cnt2 = m[mp(p1, p2)];
    m[mp(p1, p2)] = 0;
    (ans *= (pow2[cnt] - 1 + pow2[cnt2] - 1 + 1 + MOD)) %= MOD;
  }
  cout << (ans - 1 + cntt + MOD) % MOD << endl;
}

signed main() {
  Need_for_speed(activated);
  //
  // satisfy
  //    {
  //  solve();
  //   }

  solve();

  return 0;
}


Error: 0

Fixed submission:

//  RAKSHIT KADAM
// ALWAYS USE &IT FOR ITERATING USING AUTO ...
// USE COUNT(STARTING ADDRESS, ENDING ADRESS ,VALUE) FOR FINDING THE COUNT IN
// THE RESPECTIVE DATA STRUCTURE NOTE THAT MEMSET CANT FILL THE DOUBLE VALUES;
// ACCUMULATE DOES NOT WORK PROPERLY IF VALUES START SUMMING BEYOND 1E9...
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree< int ,  null_type ,  less<int> ,  rb_tree_tag ,
// tree_order_statistics_node_update>
#warning !!!check the size of arrayss!!!

// NUMERIC DEFINITIONS :
#define INF 100000000000000005
#define inf 1000000000
#define MOD 1000000007
#define newMOD 998244353
#define MAX 300006
#define pi 3.1415926535897932384626433832795
#define ld long double
#define ll long long
#define int long long

#define P(gg)                                                                  \\
  for (auto rax : gg) {                                                        \\
    cout << rax << " ";                                                        \\
  }                                                                            \\
  cout << endl;
#define Need_for_speed(activated)                                              \\
  ios_base ::sync_with_stdio(0);                                               \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL)
#define satisfy                                                                \\
  ll t;                                                                        \\
  cin >> t;                                                                    \\
  while (t--)
#define inp(n)                                                                 \\
  int n;                                                                       \\
  cin >> n
#define mp make_pair
#define pb push_back
#define endl "\\n"
#define x first
#define y second
#define fore(i, a, b) for (ll i = a; i < b; i++)
#define forci(i, n) for (ll i = 0; i < n; i++)
#define vi vector<ll>
#define Endl endl
#define lb lower_bound
#define ub upper_bound
#define pii pair<ll, ll>

#define input                                                                  \\
  freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
#define time                                                                   \\
  cerr << "\\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\\n";
using namespace std;

ll gcd(ll a, ll b) {
  if (b == 0)
    return a;
  return gcd(b, a % b);
}
int power(int x, unsigned int y, unsigned int m) {
  if (y == 0)
    return 1;
  int p = power(x, y / 2, m) % m;
  p = (p * p) % m;
  return (y % 2 == 0) ? p : (x * p) % m;
}
ll modInverse(int a, int m) {
  { return power(a, m - 2, m); }
}
const int maxn = 500003;

void solve() {
  ll n;
  cin >> n;
  map<pii, ll> m;
  ll a, b;
  ll cntt = 0;
  ll pow2[100005] = {0};
  pow2[0] = 1;
  for (ll i = 1; i < 100005; i++) {
    (pow2[i] = pow2[i - 1] * (2)) %= MOD;
  }
  for (ll i = 0; i < n; i++) {
    cin >> a >> b;
    if (!a && !b) {
      cntt++;
      continue;
    }
    if (a < 0)
      a *= -1, b *= -1;
    ll g = abs(gcd(a, b));
    m[mp(a / g, b / g)]++;
  }
  ll ans = 1;
  for (auto it : m) {
    if (it.y == 0)
      continue;
    ll l = it.x.x;
    ll r = it.x.y;
    ll cnt = it.y;
    ll p1 = -r;
    ll p2 = l;

    m[mp(it.x.x, it.x.y)] = 0;
    if (p1 < 0)
      p1 *= -1, p2 *= -1;
    ll cnt2 = m[mp(p1, p2)];
    m[mp(p1, p2)] = 0;
    (ans *= (pow2[cnt] - 1 + pow2[cnt2] - 1 + 1)) %= MOD;
  }
  cout << (ans - 1 + cntt + MOD) % MOD << endl;
}

signed main() {
  Need_for_speed(activated);
  //
  // satisfy
  //    {
  //  solve();
  //   }

  solve();

  return 0;
}