Buggy python submission (verdict: Runtime Error):
N = int(input())
mod = 10 **9 + 7

def equal(item0, item1, delta = 10 ** (-24)):
    if abs(item0 - item1) < delta:
        return True
    else:
        return False
def bigger(item0, item1, delta = 10** (-24)):
    if item0 -item1 > delta:
        return True
    else:
        return False

ab = []
ba = []
zero = 0
from bisect import insort
from math import gcd
for _ in range(N):
    A, B = map(int, input().split())
    if A*B == 0:
        if A == 0 and B == 0:
            zero += 1
        elif A == 0 and B != 0:
            ab = [0] + ab
        else:
            ba = [0] + ba
    elif A*B > 0:
        d = gcd(A,B)
        insort(ab, (A//d)/(B//d))
    else:
        insort(ba, -(B//d)/(A//d))
print(ab,ba)
def make_count(list):
    k = 0
    lis = []
    while k < len(list):
        cnt = 1
        while k+1 < len(list):
            if list[k] == list[k+1]:
                cnt += 1
                k += 1
                continue
            else:
                break
        lis.append([list[k], cnt])
        k += 1
    return lis

ab = make_count(ab)
ba = make_count(ba)
from collections import deque
ab = deque(ab)
ba = deque(ba)
ans = 1 #all pattern
flag = True
pair = []
if len(ab) == 0:
    print(pow(2, N-zero, mod)+zero-1)
    exit()
if len(ba) == 0:
    print(pow(2, N-zero, mod)+ zero -1)
    exit()


while True:
    if flag:
        a = ab.popleft()
        b = ba.popleft()
    flag = False
    if a[0] == b[0]:
        pair.append([a[1], b[1]])
        if ab:
            a = ab.popleft()
        else:
            a = [-1, 0]
        if ba:
            b = ba.popleft()
        else:
            b = [-1, 0]
        if a[0] == b[0] == -1:
            break
    elif a[0] >b[0]:
        if ba:
            pair.append([0,b[1]])
            b = ba.popleft()
            continue
        elif ab:
            pair.append([a[1],0])
            a = ab.popleft()
            b = [-1, 0]
            continue
        else:
            if a[0] != -1:
                pair.append([a[1], 0])
            if b[0]!= -1:
                pair.append([0, b[1]])
            break
    else:
        if ab:
            pair.append([a[1], 0])
            a = ab.popleft()
            continue
        elif ba:
            pair.append([0, b[1]])
            b = ba.popleft()
            a = [-1, 0]
        else:
            if a[0] != -1:
                pair.append([a[1], 0])
            if b[0]!= -1:
                pair.append([0, b[1]])
            break
ans = 1
for item in pair:
    ans *= pow(2, item[0], mod) + pow(2, item[1], mod) -1
    ans %= mod
ans += zero-1
ans %= mod
print(ans)




Fixed submission:
from collections import defaultdict
from math import gcd
N = int(input())
MOD = 10**9 + 7
L = defaultdict(lambda: [0,0])
zero = 0
for _ in range(N):
    A, B = map(int, input().split())
    if A==0: d=B
    elif B==0: d=A
    else: d=gcd(A,B)
    if d != 0:
        A, B = A//d, B//d
        if A<0: A, B = -A, -B
        if B>0: L[(A,B)][0] += 1
        else: L[(-B,A)][1] += 1
    else: zero += 1

res = 1

for x,y in L.values():
    res *= pow(2,x,MOD) + pow(2,y,MOD) -1
    res %= MOD
print((res+zero-1)%MOD)

Buggy python submission (verdict: Runtime Error):
N = int(input())
mod = 10 **9 + 7

def equal(item0, item1, delta = 10 ** (-20)):
    if abs(item0 - item1) < delta:
        return True
    else:
        return False
def bigger(item0, item1, delta = 10** (-20)):
    if item0 -item1 > delta:
        return True
    else:
        return False
bit = [1]
for k in range(N):
    bit.append(bit[-1]*2%mod)


AB = []
BA = []
zero = 0
from bisect import insort
for _ in range(N):
    A, B = map(int, input().split())
    if A*B == 0:
        if A == 0 and B == 0:
            zero += 1
        elif A == 0 and B != 0:
            AB = [0] + AB
        else:
            BA = [0] + BA
    elif A*B > 0:
        insort(AB, A/B)
    else:
        insort(BA, -B/A)
def make_count(list):
    k = 0
    lis = []
    while k < len(list):
        cnt = 1
        while k+1 < len(list):
            if list[k]==list[k+1]:
                cnt += 1
                k += 1
                continue
            else:
                break
        lis.append([list[k], cnt])
        k += 1
    return lis

AB = make_count(AB)
BA = make_count(BA)
from collections import deque
AB = deque(AB)
BA = deque(BA)
ans = 1 #all pattern
flag = True
pair = []
if len(AB) == 0:
    print(bit[N-zero]+zero-1)
    exit()
if len(BA) == 0:
    print(bit[N-zero]+ zero -1)
    exit()


while True:
    if flag:
        a = AB.popleft()
        b = BA.popleft()
    flag = False
    if a[0]== b[0]:
        pair.append([a[1], b[1]])
        if AB:
            a = AB.popleft()
        if BA:
            b = BA.popleft()
    elif a[0]>b[0]:
        if BA:
          	pair.append([0,b[1]])
            b = BA.popleft()
            continue
        elif AB:
          	pair.append([a[1],0])
            a = AB.popleft()
            continue
        else:
            break
    else:
        if AB:
          	pair.append([a[1], 0])
            a = AB.popleft()
            continue
        elif BA:
          	pair.append([0, b[1]])
            b = BA.popleft()
        else:
            break
ans = 1
for item in pair:
    ans *= pow(2, item[0], mod) + pow(2, item[1], mod) -1
    ans %= mod
ans += zero-1
ans %= mod
print(ans)




Fixed submission:
from collections import defaultdict
from math import gcd
N = int(input())
MOD = 10**9 + 7
L = defaultdict(lambda: [0,0])
zero = 0
for _ in range(N):
    A, B = map(int, input().split())
    if A==0: d=B
    elif B==0: d=A
    else: d=gcd(A,B)
    if d != 0:
        A, B = A//d, B//d
        if A<0: A, B = -A, -B
        if B>0: L[(A,B)][0] += 1
        else: L[(-B,A)][1] += 1
    else: zero += 1

res = 1

for x,y in L.values():
    res *= pow(2,x,MOD) + pow(2,y,MOD) -1
    res %= MOD
print((res+zero-1)%MOD)

Buggy python submission (verdict: Runtime Error):
N = int(input())
mod = 10 **9 + 7

def equal(item0, item1, delta = 10 ** (-20)):
    if abs(item0 - item1) < delta:
        return True
    else:
        return False
def bigger(item0, item1, delta = 10** (-20)):
    if item0 -item1 > delta:
        return True
    else:
        return False
bit = [1]
for k in range(N):
    bit.append(bit[-1]*2%mod)


AB = []
BA = []
zero = 0
from bisect import insort
for _ in range(N):
    A, B = map(int, input().split())
    if A*B == 0:
        if A == 0 and B == 0:
            zero += 1
        elif A == 0 and B != 0:
            AB = [0] + AB
        else:
            BA = [0] + BA
    elif A*B > 0:
        insort(AB, A/B)
    else:
        insort(BA, -B/A)
def make_count(list):
    k = 0
    lis = []
    while k < len(list):
        cnt = 1
        while k+1 < len(list):
            if list[k]==list[k+1]:
                cnt += 1
                k += 1
                continue
            else:
                break
        lis.append([list[k], cnt])
        k += 1
    return lis

AB = make_count(AB)
BA = make_count(BA)
from collections import deque
AB = deque(AB)
BA = deque(BA)
ans = 1 #all pattern
flag = True
pair = []
if len(AB) == 0:
    print(bit[N-zero]+zero-1)
    exit()
if len(BA) == 0:
    print(bit[N-zero]+ zero -1)
    exit()


while True:
    if flag:
        a = AB.popleft()
        b = BA.popleft()
    flag = False
    if a[0]== b[0]:
        pair.append([a[1], b[1]])
        if AB:
            a = AB.popleft()
        if BA:
            b = BA.popleft()
    elif a[0]>b[0]:
        if BA:
          	pair.append([0,b[1]])
            b = BA.popleft()
            continue
        elif AB:
          	pair.append([a[1],0])
            a = AB.popleft()
            continue
        else:
            break
    else:
        if AB:
          	pair.append([a[1], 0])
            a = AB.popleft()
            continue
        elif BA:
          	pair.append([0, b[1])
            b = BA.popleft()
        else:
            break
ans = 1
for item in pair:
    ans *= pow(2, item[0], mod) + pow(2, item[1], mod) -1
    ans %= mod
ans += zero-1
ans %= mod
print(ans)




Fixed submission:
from collections import defaultdict
from math import gcd
N = int(input())
MOD = 10**9 + 7
L = defaultdict(lambda: [0,0])
zero = 0
for _ in range(N):
    A, B = map(int, input().split())
    if A==0: d=B
    elif B==0: d=A
    else: d=gcd(A,B)
    if d != 0:
        A, B = A//d, B//d
        if A<0: A, B = -A, -B
        if B>0: L[(A,B)][0] += 1
        else: L[(-B,A)][1] += 1
    else: zero += 1

res = 1

for x,y in L.values():
    res *= pow(2,x,MOD) + pow(2,y,MOD) -1
    res %= MOD
print((res+zero-1)%MOD)

Buggy python submission (verdict: Runtime Error):
N = int(input())
mod = 10 **9 + 7

def equal(item0, item1, delta = 10 ** (-18)):
    if abs(item0 - item1) < delta:
        return True
    else:
        return False
def bigger(item0, item1, delta = 10** (-18)):
    if item0 -item1 > delta:
        return True
    else:
        return False
bitlist = [1]
for k in range(N):
    bitlist.append(bitlist[-1]*2%mod)


liABplus = []
liBAplus = []
zero = 0
from bisect import insort
for _ in range(N):
    A, B = map(int, input().split())
    if A*B == 0:
        if A == 0 and B == 0:
            zero += 1
        elif A == 0 and B != 0:
            liABplus.leftappend(0)
        else:
            liBAplus.leftappend(0)
    elif A*B > 0:
        insort(liABplus, A/B)
    else:
        insort(liBAplus, -B/A)
def make_count(list):
    k = 0
    lis = []
    while k < len(list):
        cnt = 1
        while k+1 < len(list):
            if equal(list[k], list[k+1]):
                cnt += 1
                k += 1
                continue
            else:
                break
        lis.append([list[k], cnt])
        k += 1
    return lis

liABplus = make_count(liABplus)
liBAplus = make_count(liBAplus)
N -= zero
from collections import deque
liABplus = deque(liABplus)
liBAplus = deque(liBAplus)
ans = bitlist[N]-1 #all pattern
flag = True
eqpair = []
while liABplus and liBAplus:
    if flag:
        AB = liABplus.popleft()
        BA = liBAplus.popleft()
    if equal(AB[0], BA[0]):
        eqpair.append([AB[1], BA[1]])
        if liABplus and liBAplus:
            flag = True
            continue
        else:
            break
    elif bigger(AB[0], BA[0]):
        if liBAplus:
            BA = liBAplus.popleft()
            flag = False
            continue
        else:
            break
    else:
        if liABplus:
            AB = liABplus.popleft()
            flag = False
            continue
        else:
            break

minus = 0
from itertools import combinations
for k in range(1, len(eqpair)+1):
    for item in combinations(eqpair, k):
        sgn = (-1)**k
        ideal = 1
        cnt = 0
        for i in item:
            cnt += i[0] + i[1]
            ideal *= bitlist[i[0]]-1
            ideal %= mod
            ideal *= bitlist[i[1]]-1
            ideal %= mod
        ideal *= bitlist[N-cnt]
        ideal %= mod
        ans += sgn*ideal
        ans %= mod
print(ans)



Fixed submission:
from collections import defaultdict
from math import gcd
N = int(input())
MOD = 10**9 + 7
L = defaultdict(lambda: [0,0])
zero = 0
for _ in range(N):
    A, B = map(int, input().split())
    if A==0: d=B
    elif B==0: d=A
    else: d=gcd(A,B)
    if d != 0:
        A, B = A//d, B//d
        if A<0: A, B = -A, -B
        if B>0: L[(A,B)][0] += 1
        else: L[(-B,A)][1] += 1
    else: zero += 1

res = 1

for x,y in L.values():
    res *= pow(2,x,MOD) + pow(2,y,MOD) -1
    res %= MOD
print((res+zero-1)%MOD)

Buggy python submission (verdict: Runtime Error):
N = int(input())
mod = 10 **9 + 7

def equal(item0, item1, delta = 10 ** (-18)):
    if abs(item0 - item1) < delta:
        return True
    else:
        return False
def bigger(item0, item1, delta = 10** (-18)):
    if item0 -item1 > delta:
        return True
    else:
        return False
bitlist = [1]
for k in range(N):
    bitlist.append(bitlist[-1]*2%mod)


liABplus = []
liBAplus = []
from bisect import insort
for _ in range(N):
    A, B = map(int, input().split())
    if A*B > 0:
        insort(liABplus, A/B)
    else:
        insort(liBAplus, -B/A)
def make_count(list):
    k = 0
    lis = []
    while k < len(list):
        cnt = 1
        while k+1 < len(list):
            if equal(list[k], list[k+1]):
                cnt += 1
                k += 1
                continue
            else:
                break
        lis.append([list[k], cnt])
        k += 1
    return lis

liABplus = make_count(liABplus)
liBAplus = make_count(liBAplus)

from collections import deque
liABplus = deque(liABplus)
liBAplus = deque(liBAplus)
ans = bitlist[N]-1 #all pattern
flag = True
eqpair = []
while liABplus and liBAplus:
    if flag:
        AB = liABplus.popleft()
        BA = liBAplus.popleft()
    if equal(AB[0], BA[0]):
        eqpair.append([AB[1], BA[1]])
        if liABplus and liBAplus:
            flag = True
            continue
        else:
            break
    elif bigger(AB[0], BA[0]):
        if liBAplus:
            BA = liBAplus.popleft()
            flag = False
            continue
        else:
            break
    else:
        if liABplus:
            AB = liABplus.popleft()
            flag = False
            continue
        else:
            break

minus = 0
from itertools import combinations
for k in range(1, len(eqpair)+1):
    for item in combinations(eqpair, k):
        sgn = (-1)**k
        ideal = 1
        cnt = 0
        for i in item:
            cnt += i[0] + i[1]
            ideal *= bitlist[i[0]]-1
            ideal %= mod
            ideal *= bitlist[i[1]]-1
            ideal %= mod
        ideal *= bitlist[N-cnt]
        ideal %= mod
        ans += sgn*ideal
        ans %= mod
print(ans)



Fixed submission:
from collections import defaultdict
from math import gcd
N = int(input())
MOD = 10**9 + 7
L = defaultdict(lambda: [0,0])
zero = 0
for _ in range(N):
    A, B = map(int, input().split())
    if A==0: d=B
    elif B==0: d=A
    else: d=gcd(A,B)
    if d != 0:
        A, B = A//d, B//d
        if A<0: A, B = -A, -B
        if B>0: L[(A,B)][0] += 1
        else: L[(-B,A)][1] += 1
    else: zero += 1

res = 1

for x,y in L.values():
    res *= pow(2,x,MOD) + pow(2,y,MOD) -1
    res %= MOD
print((res+zero-1)%MOD)