Language: Java


import javafx.util.Pair;

import java.io.*;
import java.util.*;

public class Main {
    private static final long INF = Long.MAX_VALUE;
    private static final int MOD = 1000000007;

    private long pow(long a, long n) {
        long ret = 1;
        long base = a;
        while (n > 0) {
            if ((n & 1) > 0) {
                ret = (ret * base) % MOD;
            }
            base = (base * base) % MOD;
            n >>= 1;
        }
        return ret;
    }

    private void add(Map<Pair<Long, Long>, int[]> cnt, Pair<Long, Long> key, int i) {
        int[] v = cnt.computeIfAbsent(key, k -> new int[]{0, 0});
        ++v[i];
    }

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

    private void solve() {
        int n = sc.nextInt();
        Map<Pair<Long, Long>, int[]> cnt = new HashMap<>();
        for (int i = 0; i < n; i++) {
            long a = sc.nextLong();
            long b = sc.nextLong();
            if (a == 0 && b == 0) {
                continue;
            }

            if (a == 0L) {
                add(cnt, new Pair<>(0L, 0L), 0);
            } else if (b == 0L) {
                add(cnt, new Pair<>(0L, 0L), 1);
            } else {
                if ((a > 0 && b > 0) || (a < 0 && b < 0)) {
                    a = Math.abs(a);
                    b = Math.abs(b);
                    long g = gcd(a, b);
                    add(cnt,new Pair<>(a / g, b / g), 0);
                } else {
                    a = Math.abs(a);
                    b = Math.abs(b);
                    long g = gcd(a, b);
                    add(cnt, new Pair<>(b / g, a / g), 1);
                }
            }
        }

        long ans = 1;
        for (int[] v : cnt.values()) {
            ans = (ans * ((pow(2, v[0]) + pow(2, v[1]) - 1 + MOD) % MOD)) % MOD;
        }

        ans = (ans - 1 + MOD) % MOD;
        out.println(ans);
    }

    private static PrintWriter out;
    private static MyScanner sc;

    private static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        private MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }

    public static void main(String[] args) {
        out = new PrintWriter(new BufferedOutputStream(System.out));
        sc = new MyScanner();
        new Main().solve();
        out.close();
    }
}


Compiler output:
Main.java:2: error: package javafx.util does not exist
import javafx.util.Pair;
                  ^
Main.java:24: error: cannot find symbol
    private void add(Map<Pair<Long, Long>, int[]> cnt, Pair<Long, Long> key, int i) {
                         ^
  symbol:   class Pair
  location: class Main
Main.java:24: error: cannot find symbol
    private void add(Map<Pair<Long, Long>, int[]> cnt, Pair<Long, Long> key, int i) {
                                                       ^
  symbol:   class Pair
  location: class Main
Main.java:38: error: cannot find symbol
        Map<Pair<Long, Long>, int[]> cnt = new HashMap<>();
            ^
  symbol:   class Pair
  location: class Main
Main.java:47: error: cannot find symbol
                add(cnt, new Pair<>(0L, 0L), 0);
                             ^
  symbol:   class Pair
  location: class Main
Main.java:49: error: cannot find symbol
                add(cnt, new Pair<>(0L, 0L), 1);
                             ^
  symbol:   class Pair
  location: class Main
Main.java:55: error: cannot find symbol
                    add(cnt,new Pair<>(a / g, b / g), 0);
                                ^
  symbol:   class Pair
  location: class Main
Main.java:60: error: cannot find symbol
                    add(cnt, new Pair<>(b / g, a / g), 1);
                                 ^
  symbol:   class Pair
  location: class Main
8 errors