Problem:


Score: 500 points

Problem Statement

We have caught N sardines. The deliciousness and fragrantness of the i-th sardine is A_i and B_i, respectively.

We will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time.

The i-th and j-th sardines (i \neq j) are on bad terms if and only if A_i \cdot A_j + B_i \cdot B_j = 0.

In how many ways can we choose the set of sardines to put into the cooler? Since the count can be enormous, print it modulo 1000000007.

Constraints

All values in input are integers.

1 \leq N \leq 2 \times 10^5

-10^{18} \leq A_i, B_i \leq 10^{18}

Input

Input is given from Standard Input in the following format:

N
A_1 B_1
:
A_N B_N

Output

Print the count modulo 1000000007.

Sample Input 1

3
1 2
-1 1
2 -1

Sample Output 1

5

There are five ways to choose the set of sardines, as follows:

The 1-st

The 1-st and 2-nd

The 2-nd

The 2-nd and 3-rd

The 3-rd

Sample Input 2

10
3 2
3 2
-1 1
2 -1
-3 -9
-8 12
7 7
8 1
8 2
8 4

Sample Output 2

479



Sample input:
3
1 2
-1 1
2 -1


Sample output:
5

Submission status: Wrong Answer

Solution code:
from math import gcd
_, *e = [[*map(int, t.split())] for t in open(0)]
ans = 1
mod = 10 ** 9 + 7
slope_dict = {}
zeros = 0
for x, y in e:
    if x == y == 0:
        zeros += 1
    else:
        d = gcd(x, y)
        x /= d
        y /= d
        if x < 0 or x == 0 < y:
            x, y = -x, -y
        s = 0
        if y < 0:
            x, y, s = -y, x, 1
        if (x, y) not in slope_dict:
            slope_dict[(x, y)] = [0, 0]
        slope_dict[(x, y)][s] += 1

for k in slope_dict:
    ans = ans * (pow(2, slope_dict[k][0], mod) +
                 pow(2, slope_dict[k][1], mod) - 1) % mod
print((ans + zeros - 1) % mod)

Submission status: Wrong Answer

Solution code:
from math import gcd
_, *e = [[*map(int, t.split())] for t in open(0)]
ans = 1
mod = 10 ** 9 + 7
slope_dict = {}
zeros = 0
for x, y in e:
    if x == y == 0:
        zeros += 1
    else:
        d = gcd(x, y)
        x /= d
        y /= d
        if x < 0 or x == 0 < y:
            x, y = -x, -y
        s = 0
        if y < 0:
            x, y, s = -y, x, 1
        if (x, y) not in slope_dict:
            slope_dict[(x, y)] = [0, 0]
        slope_dict[(x, y)][s] += 1

for k in slope_dict:
    ans = ans * (pow(2, slope_dict[k][0], mod) +
                 pow(2, slope_dict[k][1], mod) - 1) % mod
print(ans + zeros - 1 % mod)

Submission status: Wrong Answer

Solution code:
from math import gcd
_, *e = [[*map(int, t.split())] for t in open(0)]
ans = 1
mod = 10 ** 9 + 7
slope_dict = {}
zeros = 0
for x, y in e:
    if x == y == 0:
        zeros += 1
    else:
        d = gcd(x, y)
        x /= d
        y /= d
        if x < 0 or x == 0 > y:
            x, y = -x, -y
        if y <= 0:
            u = (-y, x)
            s = 1
        else:
            u = (x, y)
            s = 0
        if u not in slope_dict:
            slope_dict[u] = [0, 0]
        slope_dict[u][s] += 1

for k in slope_dict:
    ans = ans * (pow(2, slope_dict[k][0], mod) +
                 pow(2, slope_dict[k][1], mod) - 1) % mod
print(ans + zeros - 1 % mod)

Submission status: Wrong Answer

Solution code:
# E - Bullet

from collections import Counter
from math import gcd

n = int(input())
counter = Counter()  # 各ベクトルの個数
for i in range(n):
    a, b = map(int, input().split())
    if b < 0:
        a, b = -a, -b  # 180度回転して第1〜2象限に
    elif b == 0:
        a = abs(a)
    if not a == b == 0:
        # 既約化
        g = gcd(a, b)
        a //= g
        b //= g
    counter[(a, b)] += 1

modulus = 1000000007

vs = set(counter)
# 第2象限のベクトルと直交するベクトルを追加
vs.update((b, -a) for a, b in counter if a <= 0)
# 第1象限のベクトルのみ抽出
vs = [(a, b) for a, b in vs if a > 0]

ncomb = 1  # イワシの選び方の個数
for a, b in vs:
    # 互いに仲が悪いイワシ群
    n1 = counter[(a, b)]
    n2 = counter[(-b, a)]
    # それぞれの群から好きな数だけイワシを選ぶ (0匹選ぶことも含む)
    m = pow(2, n1, modulus) + pow(2, n2, modulus) - 1
    ncomb = ncomb * m % modulus

ncomb -= 1  # 1匹も選ばない場合を除く

# (0, 0)のイワシを好きな数だけ選ぶ (0匹選ぶことはない)
ncomb += pow(2, counter[(0, 0)], modulus) - 1

print(ncomb % modulus)

Submission status: Wrong Answer

Solution code:
# E - Bullet

from collections import Counter
from math import gcd

n = int(input())
counter = Counter()  # 各ベクトルの個数
for i in range(n):
    a, b = map(int, input().split())
    if b < 0:
        a, b = -a, -b  # 180度回転して第1〜2象限に
    if not a == b == 0:
        # 既約化
        g = gcd(a, b)
        a //= g
        b //= g
    counter[(a, b)] += 1

modulus = 1000000007

vs = set(counter)
# 第2象限のベクトルと直交するベクトルを追加
vs.update((b, -a) for a, b in counter if a <= 0)
# 第1象限のベクトルのみ抽出
vs = [(a, b) for a, b in vs if a > 0]

ncomb = 1  # イワシの選び方の個数
for a, b in vs:
    # 互いに仲が悪いイワシ群
    n1 = counter[(a, b)]
    n2 = counter[(-b, a)]
    # それぞれの群から好きな数だけイワシを選ぶ (0匹選ぶことも含む)
    m = pow(2, n1, modulus) + pow(2, n2, modulus) - 1
    ncomb = ncomb * m % modulus

ncomb -= 1  # 1匹も選ばない場合を除く

# (0, 0)のイワシを好きな数だけ選ぶ (0匹選ぶことはない)
ncomb += pow(2, counter[(0, 0)], modulus) - 1

print(ncomb % modulus)

Submission status: Wrong Answer

Solution code:
_, *e = [[*map(int, t.split())] for t in open(0)]
ans = 1
mod = 10 ** 9 + 7
slope_dict = {}
zeros = 0
vect_x = 0
for x, y in e:
    if x == y == 0:
        zeros += 1
    elif y == 0:
        vect_x += 1
    else:
        slope_dict[x/y] = slope_dict.get(x/y, 0) + 1
ans = ans * (pow(2, vect_x, mod) + pow(2, slope_dict.get(0, 0), mod) - 1) % mod
slope_dict.pop(0, True)
for k in slope_dict:
    if -1/k in slope_dict:
        if k > 0:
            ans = ans * (pow(2, slope_dict[k], mod) +
                         pow(2, slope_dict[-1/k], mod) - 1) % mod
    else:
        ans = ans * (pow(2, slope_dict[k], mod)) % mod
print(ans + zeros - 1 % mod)

Submission status: Wrong Answer

Solution code:
_, *e = [[*map(int, t.split())] for t in open(0)]
ans = 1
mod = 10 ** 9 + 7
slope_dict = {}
zeros = 0
vect_x = 0
for x, y in e:
    if x == y == 0:
        zeros += 1
    elif y == 0:
        vect_x += 1
    else:
        slope_dict[x/y] = slope_dict.get(x/y, 0) + 1
ans = ans * (pow(2, vect_x, mod) + pow(2, slope_dict.get(0, 0), mod) - 1) % mod
slope_dict.pop(0, True)
for k in slope_dict:
    if -1/k in slope_dict:
        if k >= 1:
            ans = ans * (pow(2, slope_dict[k], mod) +
                         pow(2, slope_dict[-1/k], mod) - 1) % mod
    else:
        ans = ans * (pow(2, slope_dict[k], mod)) % mod
print(ans + zeros - 1 % mod)

Submission status: Wrong Answer

Solution code:
from math import gcd
from sys import setrecursionlimit
setrecursionlimit(4100000)
mod = 10 ** 9 + 7
n = int(input())

zeros = 0
d = {}
for i in range(n):
    x, y = map(int, input().split())
    if x == 0 and y == 0:
        zeros += 1
    else:
        g = gcd(x, y)
        x, y = x / g, y / g
        if (y < 0) or (y == 0 and x < 0): 
            x, y = -x, -y
        else: 
            pass
        if x <= 0:
            sq = True   #second quadrant
            x, y = y, -x
        else:
            sq = False
        if sq == True:
            if (x, y) in d:
                d[(x, y)][1] += 1
            else:
                d[(x, y)] = [0, 1]
        else:
            if (x, y) in d:
                d[(x, y)][0] += 1
            else:
                d[(x, y)] =[1, 0] 

#繰り返し2乗法
def  mod_pow(a:int, b:int, mod:int)->int:
    if b == 0:
        return 1 % mod
    elif b % 2 == 0:
        return (mod_pow(a, b//2, mod) ** 2) % mod
    elif b == 1:
        return a % mod
    else:
        return ((mod_pow(a, b//2, mod) ** 2) * a) % mod
#print(d)

ans = 1
for (i, j) in tuple(d.values()):
    now = 1
    now = (now + mod_pow(2, i, mod) - 1) % mod
    now = (now + mod_pow(2, j, mod) - 1) % mod
    ans = (ans * now) % mod
    
ans -= 1
zeros = zeros % mod
ans = (ans + zeros) % mod
print(ans)

Submission status: Wrong Answer

Solution code:
from math import gcd
from sys import setrecursionlimit
setrecursionlimit(4100000)
mod = 10 ** 9 + 7
n = int(input())

zeros = 0
d = {}
for i in range(n):
    x, y = map(int, input().split())
    if x == 0 and y == 0:
        zeros += 1
    else:
        g = gcd(x, y)
        x, y = x / g, y / g
        if (y < 0) or (y == 0 and x < 0): 
            x, y = -x, -y
        else: 
            pass
        if x <= 0:
            sq = True   #second quadrant
            x, y = y, -x
        else:
            sq = False
        if sq == True:
            if (x, y) in d:
                d[(x, y)][1] += 1
            else:
                d[(x, y)] = [0, 1]
        else:
            if (x, y) in d:
                d[(x, y)][0] += 1
            else:
                d[(x, y)] =[1, 0] 

#繰り返し2乗法
def  mod_pow(a:int, b:int, mod:int)->int:
    if b == 0:
        return 1 % mod
    elif b % 2 == 0:
        return (mod_pow(a, b//2, mod) ** 2) % mod
    elif b == 1:
        return a % mod
    else:
        return ((mod_pow(a, b//2, mod) ** 2) * a) % mod
#print(d)

ans = 1
for (i, j) in tuple(d.values()):
    now = 1
    now = (now + mod_pow(2, i, mod) - 1) % mod
    now = (now + mod_pow(2, j, mod) - 1) % mod
    ans = (ans * now) % mod
    
ans -= 1
ans += zeros % mod
ans = ans % mod
print(ans)

Submission status: Wrong Answer

Solution code:
from math import gcd
from sys import setrecursionlimit
setrecursionlimit(4100000)
mod = 10 ** 9 + 7
n = int(input())

zeros = 0
d = {}
for i in range(n):
    x, y = map(int, input().split())
    if x == 0 and y == 0:
        zeros += 1
    else:
        g = gcd(x, y)
        x, y = x / g, y / g
        if (y < 0) or (y == 0 and x < 0): 
            x, y = -x, -y
        else: 
            pass
        if x <= 0:
            sq = True   #second quadrant
            x, y = y, -x
        else:
            sq = False
        if sq == True:
            if (x, y) in d:
                d[(x, y)][1] += 1
            else:
                d[(x, y)] = [0, 1]
        else:
            if (x, y) in d:
                d[(x, y)][0] += 1
            else:
                d[(x, y)] =[1, 0] 

#繰り返し2乗法
def  mod_pow(a:int, b:int, mod:int)->int:
    if b == 0:
        return 1 % mod
    elif b % 2 == 0:
        return (mod_pow(a, b//2, mod) ** 2) % mod
    elif b == 1:
        return a % mod
    else:
        return ((mod_pow(a, b//2, mod) ** 2) * a) % mod
#print(d)

ans = 1
for (i, j) in tuple(d.values()):
    now = 1
    now += (mod_pow(2, i, mod) - 1) % mod
    now += (mod_pow(2, j, mod) - 1) % mod
    now = now % mod
    ans = (ans * now) % mod
    
ans -= 1
ans += zeros % mod
ans = ans % mod
print(ans)

Submission status: Wrong Answer

Solution code:
from math import gcd
from sys import setrecursionlimit
setrecursionlimit(4100000)
mod = 10 ** 9 + 7
n = int(input())

zeros = 0
d = {}
for i in range(n):
    x, y = map(int, input().split())
    if x == 0 and y == 0:
        zeros += 1
    else:
        g = gcd(x, y)
        x, y = x / g, y / g
        if (y < 0) or (y == 0 and x < 0): 
            x, y = -x, -y
        else: 
            pass
        if x <= 0:
            sq = True   #second quadrant
            x, y = y, -x
        else:
            sq = False
        if sq == True:
            if (x, y) in d:
                d[(x, y)][1] += 1
            else:
                d[(x, y)] = [0, 1]
        else:
            if (x, y) in d:
                d[(x, y)][0] += 1
            else:
                d[(x, y)] =[1, 0] 

#繰り返し2乗法
def  mod_pow(a:int, b:int, mod:int)->int:
    if b == 0:
        return 1 % mod
    elif b % 2 == 0:
        return (mod_pow(a, b//2, mod) ** 2) % mod
    elif b == 1:
        return a % mod
    else:
        return ((mod_pow(a, b//2, mod) ** 2) * a) % mod
#print(d)

ans = 1
for (i, j) in tuple(d.values()):
    now = 1
    now += (mod_pow(2, i, mod) - 1) % mod
    now += (mod_pow(2, j, mod) - 1) % mod
    ans *= (now % mod)
    
ans -= 1
ans += zeros % mod
print(ans)

Submission status: Wrong Answer

Solution code:
from math import gcd
from sys import setrecursionlimit
setrecursionlimit(4100000)
mod = 10 ** 9 + 7
n = int(input())

zeros = 0
d = {}
for i in range(n):
    x, y = map(int, input().split())
    if x == 0 and y == 0:
        zeros += 1
    else:
        g = gcd(x, y)
        x, y = x / g, y / g
        if (y < 0) or (y == 0 and x < 0): 
            x, y = -x, -y
        else: 
            pass
        if x <= 0:
            sq = True   #second quadrant
            x, y = y, -x
        else:
            sq = False
        if sq == True:
            if (x, y) in d:
                d[(x, y)][1] += 1
            else:
                d[(x, y)] = [0, 1]
        else:
            if (x, y) in d:
                d[(x, y)][0] += 1
            else:
                d[(x, y)] =[1, 0] 

#繰り返し2乗法
def  mod_pow(a:int, b:int, mod:int)->int:
    if b == 0:
        return 1 % mod
    elif b % 2 == 0:
        return (mod_pow(a, b//2, mod) ** 2) % mod
    elif b == 1:
        return a % mod
    else:
        return ((mod_pow(a, b//2, mod) ** 2) * a) % mod
#print(d)

ans = 1
for (i, j) in tuple(d.values()):
    now = 1
    now += (mod_pow(2, i, mod) - 1) % mod
    now += (mod_pow(2, j, mod) - 1) % mod
    ans *= now
    
ans -= 1
ans += zeros % mod
print(ans)

Submission status: Wrong Answer

Solution code:
from math import gcd
from sys import setrecursionlimit
setrecursionlimit(4100000)
mod = 10 ** 9 + 7
n = int(input())

zeros = 0
d = {}
for i in range(n):
    x, y = map(int, input().split())
    if x == 0 and y == 0:
        zeros += 1
    else:
        g = gcd(x, y)
        x, y = x / g, y / g
        if (y < 0) or (y == 0 and x < 0): 
            x, y = -x, -y
        else: 
            pass
        if x <= 0:
            sq = True   #second quadrant
            x, y = y, -x
        else:
            sq = False
        if sq == True:
            if (x, y) in d:
                d[(x, y)][1] += 1
            else:
                d[(x, y)] = [0, 1]
        else:
            if (x, y) in d:
                d[(x, y)][0] += 1
            else:
                d[(x, y)] =[1, 0] 

#繰り返し2乗法
def  mod_pow(a:int, b:int, mod:int)->int:
    if b == 0:
        return 1 % mod
    elif b % 2 == 0:
        return (mod_pow(a, b//2, mod) ** 2) % mod
    elif b == 1:
        return a % mod
    else:
        return ((mod_pow(a, b//2, mod) ** 2) * a) % mod
#print(d)

ans = 1
for (i, j) in tuple(d.values()):
    ans = (ans * ((mod_pow(2, i, mod) + mod_pow(2, j, mod) - 1) % mod)) % mod
ans -= 1
ans += zeros % mod
print(ans)

Submission status: Wrong Answer

Solution code:
#10**9+7のあまりを忘れていた
import math 
n=int(input())
d=dict()
for i in range(n):
    a,b=map(int,input().split())
    if a==0 and b==0:
        pass
    elif a==0:
        a,b=0,1
    elif b==0:
        a,b=1,0
    else:
        x=math.gcd(abs(a),abs(b))
        a,b=a//x,b//x
        if a<0:
            a,b=-a,-b
    if (a,b) in d:
        d[(a,b)]+=1
    else:
        d[(a,b)]=1
#print(d)
#exit()
#こっからは数え上げ
#print(d)
ans1,ans2=1,0
for i in d:
    if d[i]==0:
        continue
    if i==(0,0):
        ans2=d[i]
        d[i]=0
        continue
    #独立…
    a,b=i
    if (-b,a) in d:
        print(a,b,1111)
        ans1*=(2**(d[i])+2**(d[(-b,a)])-1)
        d[(-b,a)]=0
        d[i]=0
    elif (b,-a) in d:
        print(a,b,2222)
        ans1*=(2**(d[i])+2**(d[(b,-a)])-1)
        d[(b,-a)]=0
        d[i]=0
    else:
        print(a,b,3333)
        ans1*=(2**(d[i]))
        d[i]=0
print((ans1+ans2-1)%(10**9+7))

Submission status: Wrong Answer

Solution code:
a=int(input())
lst=[]

for _ in range(a):
    b=input().split()
    b=[int(p) for p in b]

    lst.append(b)

count=0
count=count+len(lst)
count2=0
for i in range(len(lst)):
    for j in range(len(lst)):
        if i!=j:
            if (lst[i][0]*lst[j][0]+lst[i][1]*lst[j][1])!=0:
                count2=count2+1
count2=count2/2
count=count+count2

print (int(count%1000000007))

Submission status: Wrong Answer

Solution code:
from math import gcd
from sys import setrecursionlimit
setrecursionlimit(4100000)
mod = 10 ** 9 + 7
n = int(input())

zeros = 0
d = {}
for i in range(n):
    x, y = map(int, input().split())
    if x == 0 and y == 0:
        zeros += 1
    else:
        g = gcd(x, y)
        x, y = x / g, y / g
        if (y < 0) or (y == 0 and x < 0): 
            x, y = -x, -y
        else: 
            pass
        if x < 0:
            sq = True   #second quadrant
            x, y = y, -x
        else:
            sq = False
        if sq == True:
            if (x, y) in d:
                d[(x, y)][1] += 1
            else:
                d[(x, y)] = [0, 1]
        else:
            if (x, y) in d:
                d[(x, y)][0] += 1
            else:
                d[(x, y)] =[1, 0] 

#繰り返し2乗法
def  mod_pow(a:int, b:int, mod:int)->int:
    if b == 0:
        return 1 % mod
    elif b % 2 == 0:
        return (mod_pow(a, b//2, mod) ** 2) % mod
    elif b == 1:
        return a % mod
    else:
        return ((mod_pow(a, b//2, mod) ** 2) * a) % mod
#print(d)

ans = 1
for (i, j) in tuple(d.values()):
    ans = (ans * ((mod_pow(2, i, mod) + mod_pow(2, j, mod) - 1) % mod)) % mod
ans -= 1
ans += zeros % mod
print(ans)

Submission status: Wrong Answer

Solution code:
from math import gcd
from sys import setrecursionlimit
setrecursionlimit(4100000)
mod = 10 ** 9 + 7
n = int(input())

zeros = 0
d = {}
for i in range(n):
    x, y = map(int, input().split())
    if x == 0 and y == 0:
        zeros += 1
    else:
        g = gcd(x, y)
        x, y = x / g, y / g
        if (y < 0) or (y == 0 and x < 0): 
            x, y = -x, -y
        else: 
            pass
        if x < 0:
            sq = True   #second quadrant
            x, y = y, -x
        else:
            sq = False
        if sq == True:
            if (x, y) in d:
                d[(x, y)][1] += 1
            else:
                d[(x, y)] = [0, 1]
        else:
            if (x, y) in d:
                d[(x, y)][0] += 1
            else:
                d[(x, y)] =[1, 0] 
#繰り返し2乗法
def  mod_pow(a:int, b:int, mod:int)->int:
    if b == 0:
        return 1 % mod
    elif b % 2 == 0:
        return (mod_pow(a, b//2, mod) ** 2) % mod
    elif b == 1:
        return a % mod
    else:
        return ((mod_pow(a, b//2, mod) ** 2) * a) % mod
#print(d)

ans = 0
for (i, j) in tuple(d.values()):
    if ans == 0:
        ans = (mod_pow(2, i, mod) + mod_pow(2, j, mod) - 1) % mod
    else:
        ans = (ans * ((mod_pow(2, i, mod) + mod_pow(2, j, mod) - 1) % mod)) % mod
ans -= 1
ans += zeros
print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
M = 1000000007


def gcd(a, b):
  while b != 0:
    a, b = b, a % b

  return a


def comb(n):
  c = 1

  for _ in range(n):
    c = (c * 2) % M

  return c - 1


def main():
  zeros = 0
  groups = {}

  for _ in range(int(input())):
    a, b = map(int, input().split())

    if a == 0 and b == 0:
      zeros += 1
      continue

    if a == 0:
      v = (1, 0)
      i = 0
    elif b == 0:
      v = (1, 0)
      i = 1
    else:
      if b < 0:
        a = -a
        b = -b

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

      if a > 0:
        v = (a, b)
        i = 0
      else:
        v = (b, -a)
        i = 1

    if v not in groups:
      groups[v] = [0, 0]

    groups[v][i] += 1

  count = 1

  for k, (v1, v2) in groups.items():
    c = (comb(v1) + comb(v2) + 1) % M
    count = (count * c) % M

  print(count - 1 + zeros)


if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
M = 1000000007


def gcd(a, b):
  while b != 0:
    a, b = b, a % b

  return a


def comb(n):
  c = 1

  for _ in range(n):
    c = (c * 2) % M

  return c - 1


def main():
  zeros = 0
  groups = {}

  for _ in range(int(input())):
    a, b = map(int, input().split())

    if a == 0 and b == 0:
      zeros += 1
      continue

    if a == 0:
      v = (1, 0)
      i = 0
    elif b == 0:
      v = (1, 0)
      i = 1
    else:
      g = gcd(a, b)
      a //= g
      b //= g

      if b < 0:
        a = -a
        b = -b

      if a > 0:
        v = (a, b)
        i = 0
      else:
        v = (b, -a)
        i = 1

    if v not in groups:
      groups[v] = [0, 0]

    groups[v][i] += 1

  count = 1

  for k, (v1, v2) in groups.items():
    c = (comb(v1) + comb(v2) + 1) % M
    count = (count * c) % M

  print(count - 1 + zeros)


if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
M = 1000000007


def gcd(a, b):
  while b != 0:
    a, b = b, a % b

  return a


def comb(n):
  c = 1

  for _ in range(n):
    c = (c * 2) % M

  return c - 1


def main():
  zeros = 0
  groups = {}

  for _ in range(int(input())):
    a, b = map(int, input().split())

    if a == 0 and b == 0:
      zeros += 1
      continue

    if a == 0:
      v = (1, 0)
      i = 0
    elif b == 0:
      v = (1, 0)
      i = 1
    else:
      g = gcd(a, b)
      a //= g
      b //= g

      if b < 0:
        a = -a
        b = -b

      if a > 0:
        v = (a, b)
        i = 0
      else:
        v = (b, -a)
        i = 1

    if v not in groups:
      groups[v] = [0, 0]

    groups[v][i] += 1

  count = 1

  for k, (v1, v2) in groups.items():
    count = (count * (comb(v1) + comb(v2) + 1)) % M

  print(count - 1)


if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
M = 1000000007


def gcd(a, b):
  while b != 0:
    a, b = b, a % b

  return a


def comb(n):
  c = 1

  for _ in range(n):
    c = (c * 2) % M

  return c - 1


def main():
  zeros = 0
  groups = {}

  for _ in range(int(input())):
    a, b = map(int, input().split())

    if a == 0 and b == 0:
      zeros += 1
      continue

    if a == 0:
      v = (1, 0)
      i = 0
    elif b == 0:
      v = (1, 0)
      i = 1
    else:
      g = gcd(a, b)
      a //= g
      b //= g

      if b < 0:
        a = -a
        b = -b

      if a > 0:
        v = (a, b)
        i = 0
      else:
        v = (b, -a)
        i = 1

    if v not in groups:
      groups[v] = [0, 0]

    groups[v][i] += 1

  count = 1

  for k, (v1, v2) in groups.items():
    count = (count * (comb(v1) + comb(v2) + 1)) % M

  print(count - 1 + zeros)


if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
import math

N = int(input())
m = defaultdict(lambda : 0)
BIG_NUMBER = 1000000007
bad_iwashi_count = 0

for _ in range(N):
    A,B = map(int,input().split())
    #0の場合
    if A == 0 and B == 0:
        bad_iwashi_count += 1
        continue
    if A == 0:
        m[(1,0,1)]+=1
        continue
    if B == 0:
        m[(-1,1,0)]+=1
        continue
    gcd_ = math.gcd(A,B)
    A = A//gcd_
    B = B//gcd_
    #0以外
    if A < 0 and B > 0: m[(-1,-A,B)]+=1
    elif B < 0 and A > 0: m[(-1,A,-B)]+=1
    else: m[(1,A,B)]+=1

total = 1
for key in list(dict(m).keys()):
    total *= pow(2,m[key],BIG_NUMBER) + pow(2,m[-key[0],key[2],key[1]],BIG_NUMBER) -1
    total %= BIG_NUMBER
    m.pop(key)
    m.pop((-key[0],key[2],key[1]))
print((total+bad_iwashi_count-1)%BIG_NUMBER)

'''
3
1 2
-1 1
2 -1
'''

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
import math

N = int(input())
m = defaultdict(lambda : 0)
BIG_NUMBER = 1000000007
bad_iwashi_count = 0

for _ in range(N):
    A,B = map(int,input().split())
    gcd_ = math.gcd(A,B)
    #0の場合
    if A == 0 and B == 0:
        bad_iwashi_count += 1
        continue
    if A == 0:
        m[(1,0,1)]+=1
        continue
    if B == 0:
        m[(-1,1,0)]+=1
        continue
    A = A//gcd_
    B = B//gcd_
    #0以外
    if A < 0 and B > 0: m[(-1,-A,B)]+=1
    elif B < 0 and A > 0: m[(-1,A,-B)]+=1
    else: m[(1,A,B)]+=1

total = 1
for key in list(dict(m).keys()):
    total *= pow(2,m[key],BIG_NUMBER) + pow(2,m[-key[0],key[2],key[1]],BIG_NUMBER) -1
    m.pop(key)
    m.pop((-key[0],key[2],key[1]))
print(total-bad_iwashi_count-1)

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
List = []
ls_append = List.append
for i in range(N):
  a,b = map(int, input().split())
  ls_append([a,b])
 
count = 0

for i in range(N):
  for j in range(N):
    if i >= j:
      dots = np.dot(List[i],List[j])
      if dots != 0:
        count +=1
      else:
        pass
    else:
      pass
    
print(count % 1000000007)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = []
B = []
for i in range(N):
  a,b = map(int, input().split())
  A.append(a)
  B.append(b)
 
count = 0

for i in range(N):
  for j in range(N):
    if j>=i:
      pair = A[i]*A[j] + B[i]*B[j]
      if pair != 0:
        count += 1
      else:
        pass
    else:
      pass
    
    
print(count % 1000000007)

Submission status: Wrong Answer

Solution code:
from math import gcd
 
n=int(input())
mod = 10**9+7
 
d = dict()
zeros=0
for _ in range(n):
  a,b=map(int,input().split())
  if not any((a,b)):
    zeros+=1
    continue
  if all((a,b)):
    g = gcd(a,b)//1
  elif a:
    g = a
  else:
    g = b
  
  p = a//g,b//g
  d[p] = d.get(p,0)+1
 
ans = 1
done = set()
for (a,b),v in d.items():
  if (-b,a) in done or (b,-a) in done:
    continue
  done.add((a,b))
  w=d.get((-b,a),0)+d.get((b,-a),0)
  ans *= (pow(2,v,mod)+pow(2,w,mod)-1)
  ans %= mod
print((ans+zeros-1+mod)%mod)

Submission status: Wrong Answer

Solution code:
from math import gcd
 
n = int(input())
mod = 10**9+7
 
d = dict()
zeros=0
for _ in range(n):
  a, b = map(int,input().split())
  if not any((a,b)):
    zeros+=1
    continue
  if all((a,b)):
    g = gcd(a,b)
  elif a:
    g = a
  else:
    g = b
  
  p = a//g, b//g
  d[p] = d.get(p,0)+1

ans = 1
done = set()
for (a,b),v in d.items():
  if (-b,a) in done or (b,-a) in done:
    continue
  done.add((a,b))
  w = d.get((-b,a),0) + d.get((b,-a),0)
  ans *= (pow(2,v,mod)+pow(2,w,mod)-1)
  ans %= mod
print((ans+zeros-1)%mod)

Submission status: Wrong Answer

Solution code:
from math import gcd
 
n = int(input())
mod = 10**9+7
 
d = dict()
zeros=0
for _ in range(n):
  a, b = map(int,input().split())
  if not any((a,b)):
    zeros+=1
    continue
  if all((a,b)):
    g = gcd(a,b)
  elif a:
    g = a
  else:
    g = b
  
  p = a//g, b//g
  d[p] = d.get(p,0)+1

ans = 1
done = set()
for (a,b),v in d.items():
  if (-b,a) in done or (b,-a) in done:
    continue
  done.add((a,b))
  w = d.get((-b,a),0) + d.get((b,-a),0)
  ans *= (pow(2,v)+pow(2,w)-1)
  ans %= mod
print((ans+zeros-1)%mod)

Submission status: Wrong Answer

Solution code:
n=int(input())
ab=[list(map(int,input().split())) for _ in range(n)]
from collections import defaultdict
from math import gcd
d=defaultdict(int)
for a,b in ab:
  if a==0 and b==0:
    d[(0,0)]+=1
  elif a==0:
    d[(1,0)]+=1
  elif b==0:
    d[(0,1)]+=1
  else:
    if a<0:
      a*=-1
      b*=-1
    g=gcd(a,b)
    d[(a//g,b//g)]+=1
mod=pow(10,9)+7
ans=1
keys=d.keys()
for k in keys:
  if k==(0,0):
    continue
  else:
    a,b=k
    x=b if b>0 else -b
    y=-a if b>0 else a
    k0=tuple([x,y])
    if k0 in d:
      ans*=pow(2,d[k],mod)-1+pow(2,d[k0],mod)-1+1
      ans%=mod
      d[k]=0
      d[k0]=0
    else:
      ans*=pow(2,d[(a,b)],mod)
      ans%=mod
ans+=d[(0.0)]
ans-=1
print(ans%mod)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list()
for i in range(N):
  a,b  =map(int,input().split())
  A.append([a,b])
n = 0
 
for i in range(N - 1):
  for j in range(i + 1,N):
    if A[i][0] * A[j][0] + A[i][1] * A[j][1] == 0:
      n += 1

fac = [1,1]
inv = [1,1]
finv = [1,1]
 
MOD = 100000007
for i in range(2,N + 1):
    tmp = fac[-1] * i % MOD
    fac.append(tmp)
    tmp = MOD - inv[MOD % i] * (MOD // i) % MOD
    inv.append(tmp)
    tmp = finv[-1] * inv[i] % MOD
    finv.append(tmp)
    
ret = N - n # k = 1
 
for i in range(2,N+1):
  tmp = ((fac[N] * finv[N-i]) % MOD * finv[i]) % MOD
  tmp2 = ((fac[n] * finv[n-i]) % MOD * finv[i]) % MOD
  ret += (tmp - tmp2) % MOD
ret = ret % MOD
print(ret)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list()
for i in range(N):
  a,b  =map(int,input().split())
  A.append([a,b])
n = 0
 
for i in range(n - 1):
  for j in range(i + 1,j):
    if A[i][0] * A[j][0] + A[i][1] + A[j][1] == 0:
      n += 1
 
 
 
fac = [1,1]
inv = [1,1]
finv = [1,1]
 
MOD = 100000007
for i in range(2,N + 1):
    tmp = fac[-1] * i % MOD
    fac.append(tmp)
    tmp = MOD - inv[MOD % i] * (MOD // i) % MOD
    inv.append(tmp)
    tmp = finv[-1] * inv[i] % MOD
    finv.append(tmp)
    
ret = N - n # k = 1
 
for i in range(2,N+1):
  tmp = ((fac[N] * finv[N-i]) % MOD * finv[i]) % MOD
  tmp2 = ((fac[n] * finv[n-i]) % MOD * finv[i]) % MOD
  ret += (tmp - tmp2) % MOD
ret = ret % MOD
print(ret)

Submission status: Wrong Answer

Solution code:
from math import gcd
n = int(input())
p = 10**9 + 7
iwashi = {}
bad = 0
ans = 1
for i in range(n):
    x, y = map(int, input().split())
    if(x == 0 and y == 0):
      bad += 1
      continue
    elif(x == 0):
        try:
        	iwashi[(0, 1)] += 1
        except KeyError:
            iwashi[(0, 1)] = 1
            continue
    elif(y == 0):
        try:
        	iwashi[(1, 0)] += 1
        except KeyError:
            iwashi[(1, 0)] = 1
        continue
    else:
        g = gcd(x, y)
        x, y = x // g, y // g
        if x < 0:
            x, y = -x, -y
        try:
        	iwashi[(x, y)] += 1
        except KeyError:
            iwashi[(x, y)] = 1
            
for x, y in iwashi:
    a = iwashi[(x, y)]
    if y > 0:
    	rx,ry = y, -x
    else:
      	rx,ry = y, -x
    try:
        b = iwashi[(rx,ry)]
        iwashi[(rx,ry)] = 0
    except KeyError:
      	b = 0
    ans *= pow(2, a, p) + pow(2, b, p) - 1
    ans %= p
    iwashi[(x, y)] = 0
print((ans + bad - 1) % p)

Submission status: Wrong Answer

Solution code:
from math import gcd
n = int(input())
p = 10**9 + 7
iwashi = {}
bad = 0
ans = 1
for i in range(n):
    x, y = map(int, input().split())
    if(x == 0 and y == 0):
      bad += 1
      continue
    elif(x == 0):
        try:
        	iwashi[(0, -1)] += 1
        except KeyError:
            iwashi[(0, -1)] = 1
            continue
    elif(y == 0):
        try:
        	iwashi[(-1, 0)] += 1
        except KeyError:
            iwashi[(-1, 0)] = 1
        continue
    else:
        g = gcd(x, y)
        x, y = x // g, y // g
        if x < 0:
            x, y = -x, -y
        try:
        	iwashi[(x, y)] += 1
        except KeyError:
            iwashi[(x, y)] = 1
            
for x, y in iwashi:
    a = iwashi[(x, y)]
    if y > 0:
    	rx,ry = y, -x
    else:
      	rx,ry = y, -x
    try:
        b = iwashi[(rx,ry)]
        iwashi[(rx,ry)] = 0
    except KeyError:
      	b = 0
    ans *= pow(2, a, p) + pow(2, b, p) - 1
    ans %= p
    iwashi[(x, y)] = 0
print((ans + bad - 1) % p)

Submission status: Wrong Answer

Solution code:
import math

def divide(a,b):
    minus=0
    if a*b<0:
        minus=1
    t=math.gcd(a,b)
    ret=str(abs(a)//t)+'/'+str(abs(b)//t)
    if minus==1:
        ret="-"+ret
    return ret

n = int(input())
d={}
s=set([])
x=0
y=0
z=0
c=0
ans=1
N=1000000007
for i in range(n):
    a,b =map(int,input().split())
    if (a==0) and (b!=0):
        x+=1
    elif (a!=0) and (b==0):
        y+=1
    elif (a==0) and (b==0):
        z+=1
    else:
        p=divide(b,a)
        if d.get(p)==None:
            d[p]=1
        else:
            d[p]+=1
        s|={p}
if x==0:
    ans*=2**y
elif y==0:
    ans*=2**x
else:
    ans*=2**x+2**y-1

for i in s:
    if i.startswith("-"):
        index=i.index('/')
        q=i[index+1:]+'/'+i[1:index]
    else:
        index=i.index('/')
        q='-'+i[index+1:]+'/'+i[:index]
    if d.get(q)!=None:
        j=d[q]
        ans*=2**d[i]+2**j-1
        d[i]=0
        d[q]=0
    else:
        ans*=2**d[i]
        d[i]=0
    if ans>N:
        ans%=N
print(ans+z-1)