Harryxun/stf_run huggingface dataset:
import numpy as np
N = int(input())
B = str(input())

B_array = np.array(list(map(int, list(B))))
B_1 = B_array.sum()
mod_list_m1 = []
mod_list = []
mod_list_p1 = []
if B_1 == 1:
  for i in range(N):
    print(0)
else:
    for i in range(N):
        mod_list.append((2**i) % (B_1))
        mod_list_m1.append((2**i) % (B_1-1))
        mod_list_p1.append((2**i) % (B_1+1))
    mod_list = np.array(mod_list)[::-1]
    mod_list_m1 = np.array(mod_list_m1)[::-1]
    mod_list_p1 = np.array(mod_list_p1)[::-1]

    mod_m1 = B_array.dot(mod_list_m1) % (B_1-1)
    mod_p1 = B_array.dot(mod_list_p1) % (B_1+1)
    print(mod_m1)

    def calc_small(n, iter):
        iter += 1
        mod = n % bin(n).count("1")
        if mod == 0:
            return iter
        else:
            return calc_small(mod, iter)

    for i in range(N):
        mod = (mod_m1 - mod_list_m1[i]) % (B_1-1) if B_array[i] == 1 else (mod_p1 + mod_list_p1[i]) % (B_1+1)
        iter = 1
        if mod == 0:
            print(iter)
        else:
            print(calc_small(mod, iter))


### FIXED CODE ###

N = int(input())
B = input()

B_1 = B.count("1")
mod_p1 = int(B,2) % (B_1+1)
if B_1 != 1:
    mod_m1 = int(B,2) % (B_1-1)

def calc_small(n, iter):
    iter += 1
    mod = n % bin(n).count("1")

    if mod == 0:
        return iter
    else:
        return calc_small(mod, iter)

for i in range(N):
    if B_1 == 1 and int(B[i]) == 1:
        print(0)
        continue
    mod = (mod_m1 - pow(2,N-i-1,B_1-1)) % (B_1-1) if int(B[i]) == 1 else (mod_p1 + pow(2,N-i-1,B_1+1)) % (B_1+1)
    iter = 1
    if mod == 0:
        print(iter)
    else:
        print(calc_small(mod, iter))
AB = int(input().split())

A = AB[0]
B = AB[1]

if A%2 == 0 and B%2 == 0:
  print((A+B)/2)
  
elif A%2 == 1 and B%2 ==1:
  print((A+B)/1)
  
else:
  print("IMPOSSIBLE")

### FIXED CODE ###

AB = list(map(int, input().split()))
 
A = int(AB[0])
B = int(AB[1])
 
if A%2 == 0 and B%2 == 0:
    print(int((A+B)/2))
elif A%2 == 1 and B%2 == 1:
    print(int((A+B)/2))
else:
    print("IMPOSSIBLE")
import sys

count = 0

for line in sys.stdin:
	array = line.readLine().split(" ")
	a = array[0]
	b = array[1]
	c = array[3]

	if (a < 1 or a > 10000) or (b < 1 or b > 10000) or (c < 1 or c > 10000):
		sys.exit()

	for x in xrange(a,b):
		if c % x == 0:
			count =  count + 1


	print count

### FIXED CODE ###

import sys

count = 0

array = raw_input().split(' ')

a = int(array[0])
b = int(array[1])
c = int(array[2])

if (a < 1 or a > 10000) or (b < 1 or b > 10000) or (c < 1 or c > 10000):
	sys.exit()

for x in xrange(a,b+1):
	if c % x == 0:
		count =  count + 1

print count
A, B, C, K = map(int, input().split())

cards = [1]*A + [0]*B + [-1]*C
print(sum(cards[:K]))

### FIXED CODE ###

A, B, C, K = map(int, input().split())
if K < A:
    print(K)
elif K <= A+B:
    print(A)
else:
    print(A + (K-A-B)*-1)
import sys
def input():
    return sys.stdin.readline()[:-1]
N,u,v = map(int,input().split(' '))
l = [None]*N
for i in range(N-1):
    l[i] = list(map(int, input().split()))

MAP = {}
for i in range(N):
    if l[i]==None:
        continue
    a,b = l[i]
    if a in MAP:
        MAP[a].append(b)
    else:
        MAP[a] = [b]
    if b in MAP:
        MAP[b].append(a)
    else:
        MAP[b] = [a]

#Tがたどり着くのにかかる手数
t_MAP = [0]*(N+1)
cost = 0

def t_dfs(n,c):
    t_MAP[n] = c
    c += 1
    if n in MAP:
        for j in MAP[n]:
            if t_MAP[j]==0 and j!=u:
                t_dfs(j,c)
t_dfs(u,cost)

a_visited = [False]*(N+1)
break_even = False
pre_tcost = 10**5
ANS = [0]
def a_dfs(n,c,pre_c):
    a_visited[n] = True
    t_cost = t_MAP[n]
    if t_cost>c:
        if t_cost>pre_c:
            return
    ANS[0] = max(c,ANS[0])
    c += 1
    if n in MAP:
        for j in MAP[n]:
            if not a_visited[j]:
                a_dfs(j,c,t_cost)
a_visited[v] = True
a_dfs(v,cost,pre_tcost)
print(ANS[0]-1)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**5)
def input():
    return sys.stdin.readline()[:-1]
N,u,v = map(int,input().split(' '))
l = [None]*N
for i in range(N-1):
    l[i] = list(map(int, input().split()))

MAP = {}
for i in range(N):
    if l[i]==None:
        continue
    a,b = l[i]
    if a in MAP:
        MAP[a].append(b)
    else:
        MAP[a] = [b]
    if b in MAP:
        MAP[b].append(a)
    else:
        MAP[b] = [a]

#Tがたどり着くのにかかる手数
t_MAP = [0]*(N+1)
cost = 0

def t_dfs(n,c):
    t_MAP[n] = c
    c += 1
    if n in MAP:
        for j in MAP[n]:
            if t_MAP[j]==0 and j!=u:
                t_dfs(j,c)
t_dfs(u,cost)

a_visited = [False]*(N+1)
break_even = False
pre_tcost = 10**5
ANS = [0]
def a_dfs(n,c,pre_c):
    a_visited[n] = True
    t_cost = t_MAP[n]
    if t_cost>c:
        if t_cost>pre_c:
            return
    ANS[0] = max(c,ANS[0])
    c += 1
    if n in MAP:
        for j in MAP[n]:
            if not a_visited[j]:
                a_dfs(j,c,t_cost)
a_visited[v] = True
a_dfs(v,cost,pre_tcost)
print(ANS[0]-1)
N = int(input().split())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
L = 0
for i in range(N):
  l = min(A[i], B[i])
  r = min(A[i + 1], B[i])
  A[i + 1] -= r
  L += l + r
print(L)

### FIXED CODE ###

N = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
L = 0
for i in range(N):
  l = min(A[i], B[i])
  B[i] -= l
  r = min(A[i + 1], B[i])
  A[i + 1] -= r
  L += l + r
print(L)
nums = list(map(int,input().split(" ")))
res = [0 for _ in range(len(nums))]
for i in range(len(nums)):
    index = i+1
    cnt = nums[i]
    res[cnt-1] = index
print(res)


### FIXED CODE ###

n = int(input())
nums = list(map(int,input().split(" ")))
res = [0 for _ in range(len(nums))]
for i in range(len(nums)):
    index = i+1
    cnt = nums[i]
    res[cnt-1] = index
print(*res,sep=" ")
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M = MAP()
a = [INT()]
for i in range(1, M):
	a.append(INT())
	if a[i] == a[i-1]+1:
		print(0)
		exit()
m = [a[0]-1]
for i in range(1, M):
	m.append(a[i]-a[i-1]-2)
m.append(N-a[M-1]-1)


def Fibo(n):
	S = [1, 1]
	if n == 1:
		return 1
	for i in range(1, n):
		S.append(S[i] + S[i-1])

	return S[n]

ans = 1
for n in m:
	ans *= Fibo(n)

print(ans%mod)

### FIXED CODE ###

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M = MAP()

def Fibo(n):
	S = [1, 1]
	if n == 1:
		return 1
	for i in range(1, n):
		S.append(S[i] + S[i-1])

	return S[n]

if M == 0:
	print(Fibo(N)%mod)
	exit()

a = [INT()]
for i in range(1, M):
	a.append(INT())
	if a[i] == a[i-1]+1:
		print(0)
		exit()
m = [a[0]-1]
for i in range(1, M):
	m.append(a[i]-a[i-1]-2)
m.append(N-a[M-1]-1)



ans = 1
for n in m:
	ans *= Fibo(n)

print(ans%mod)
import bisect.bisect_right from bisect
A, B, Q = map(int, input().split())
INF = 10 ** 18
s = [-INF] + [int(input()) for i in range(A)] + [INF]
t = [-INF] + [int(input()) for i in range(B)] + [INF]
for q in range(Q):
    x = int(input())
    b, d = bisect.bisect_right(s, x), bisect.bisect_right(t, x)
    #print(b,d)
    res = INF
    for S in [s[b - 1], s[b]]:
        for T in [t[d - 1], t[d]]:
            d1, d2 = abs(S - x) + abs(T - S), abs(T - x) + abs(S - T)
            res = min(res, d1, d2)
    print(res)

### FIXED CODE ###

import bisect
A, B, Q = map(int, input().split())
INF = 10 ** 18
s = [-INF] + [int(input()) for i in range(A)] + [INF]
t = [-INF] + [int(input()) for i in range(B)] + [INF]
for q in range(Q):
    x = int(input())
    b, d = bisect.bisect_right(s, x), bisect.bisect_right(t, x)
    #print(b,d)
    res = INF
    for S in [s[b - 1], s[b]]:
        for T in [t[d - 1], t[d]]:
            d1, d2 = abs(S - x) + abs(T - S), abs(T - x) + abs(S - T)
            res = min(res, d1, d2)
    print(res)
[H, A] = [int(i) for i in input().split()]
t = 0
if H/A != int(H/A):
    t = 1
print(int(H/A) + t)

### FIXED CODE ###

[S, T] = [str(i) for i in input().split()]
[A, B] = [int(i) for i in input().split()]
U = str(input())

if S == U:
    print(A-1, B)
else:
    print(A, B-1)
n,a,b=map(int,input().split())
l=[]
for i in range(1,n+1):
  s=sum(list(map(int,str(i))))
  if s>=a s<=b:
    l.append(i)
print(sum(l))


### FIXED CODE ###

n,a,b=map(int,input().split())
x=[]
y=[]
for i in range(1,n+1):
  x.append(i)
for j in range(n):
  s=sum(list(map(int,str(x[j]))))
  if s>=a and s<=b:
    y.append(x[j])
print(sum(y))
#2019/10/12
N = int(open(0).read())
L0 = 2
L1 = 1
for i in range(N-1):
    L2 = L1 + L0
    L1, L0 = L2, L1
    #print(i, L2)
print(L2)

### FIXED CODE ###

#2019/10/12
N = int(open(0).read())
L0 = 2
L1 = 1
L2 = 3
for i in range(N):
    L2 = L1 + L0
    L1, L0 = L2, L1
    #print(i, L2)
print(L0)
def main(){
 

    n = input()
    for i in n-1:
        R[i] = input()
 
    max = R[1] - R[0]
    min = R[0]
 
    for i+1 in n-1:
        if R[i]-min>max:
            max = R[i] - min
        if R[i]<min:
            min = R[i]
 
    print max
 
    return 0

}
 

### FIXED CODE ###

n = input()

R = [input() for i in range(n)]
  
max = R[1] - R[0]
min = R[0]
  
for i in range(1,n):
    if R[i] - min > max:
        max = R[i] - min
    if R[i] < min:
        min = R[i]
  
print max
#editorial参照

#偶奇
import numpy as np
import sys
input = sys.stdin.readline
n=int(input())
a_ = list(map(int, list(input())))
a = np.array(a_)
div2=[1]
cnt=0
ex1 = False

if 1 in a:
    ex1 = True
else:
    a//=2
for i in range(1,n):
    cnt += bin(n-i)[::-1].find('1')
    cnt -= bin(i)[::-1].find('1')
    div2.append(cnt)

div2=np.array(div2)

tmp= (a*div2%2).sum()%2
if tmp:
    if ex1:
        print(1)
    else:
        print(2)

else:
    print(0)


### FIXED CODE ###

#editorial参照

#偶奇
import numpy as np
n=int(input())
a_ = list(map(int, list(input())))
a = np.array(a_)-1###
div2=[0]
cnt=0
ex1 = False

if 1 in a:
    ex1 = True
else:
    a//=2
tst=1
tsts=[1]
for i in range(n-1):
    cnt += bin(n-i-1)[::-1].find('1')
    cnt -= bin(i+1)[::-1].find('1')
    #tst*=n-i-1
    #tst//=i+1
    div2.append(cnt)
    tsts.append(tst)

div2=np.array(div2)###これは2で割れる数のカウント
dv2=1-(div2>0)##これが2で割れるか否か
#print(a)
#print(tsts)
#print(dv2)
tmp= (a*dv2).sum()%2
if tmp:
    if ex1:
        print(1)
    else:
        print(2)

else:
    print(0)
n=int(input())
txylist=[[0,0,0,]]
for i in range(n):
    txy=list(map(int,input().split(" ")))
    txylist+=[txy]
if n==1:
    t1,x1,y1=txylist[1]
    if t==abs(x1)+abs(y1):
        p=True
    else:
        print("No")
else:
    for i in range(n):
        p=False
        t0,x0,y0=txylist[i]
        t1,x1,y1=txylist[i+1]
        t=t1-t0
        x=x1-x0
        y=y1-y0
        longs=abs(x)+abs(y)
        if longs==t:
            p=True
        else:
            print("No")
            break
if p==True:
    print("Yes")

### FIXED CODE ###

n=int(input())
txylist=[[0,0,0]]
for i in range(n):
    txy=list(map(int,input().split(" ")))
    txylist+=[txy]
for i in range(n):
    p=False
    t0,x0,y0=txylist[i]
    t1,x1,y1=txylist[i+1]
    t=t1-t0
    x=x1-x0
    y=y1-y0
    tt=abs(x)+abs(y)
    legs=t-tt
    if legs>=0 and legs%2==0:
        p=True
    else:
        print("No")
        break
if p==True:
    print("Yes")
import sys
a,b,c,k=map(int,input().split())
if a+b>c:
    print(a+b)
else:
    print(a-(k-a-b))

### FIXED CODE ###

s=str(input())
t=str(input())
if s[:-1]==t or t[:-1]==s:
    print("Yes")
else:
    print("No")
k, x = map(int, input().split(' ')

minimum = max(x - k + 1, -1000000)
maximum = min(x + k - 1, 1000000)

ran = [str(i) for i in range(minimum, maximum+1)]
print(' '.join(ran)

### FIXED CODE ###

a, b = input().split(" ")
a = int(a)
b = int(b)

add = a + b
diff = a - b
mul = a * b

print(max(add, diff, mul))
a=int(input())
a=a.split(" ")
c=0
for i in a:
    c+=1
    if i==0:
        break
print(c)

### FIXED CODE ###

a=input()
a=a.split(" ")
c=0
for i in a:
    c+=1
    if i==str(0):
        break
print(c)
t=list(map(int,input().split()))
a=list(map(int,input().split()))
b=list(map(int,input().split()))
p,q=[0],[0]
x,y=[(a[0]-b[0])*t[0],(a[1]-b[1])*t[1]]
#print(x,y,abs(x)<abs(y))
#exit()
if x+y==0:
    print("infinity")
#elif (x<0 and y<0) or (x>0 and y>0):
#    print(0)
#elif (x<0 and x+(x+y)>0) or (x>0 and x+(x+y)<0):
#    print(1)

#elif x<0 and x+y>0:
#    print((abs(x)//(x+y))*2+[0,1][abs(x)%(x+y)>0])
#elif x<0 and x+y<0:
#    print((y//abs(x+y))*2)
#elif x>0 and x+y<0:
#    print((x//abs(x+y))*2+[0,1][x%abs(x+y)>0])
elif x>0 and x+y>0:
    print((abs(y)//(x+y))*2+[0,2][abs(y)%(x+y)>0])
else:
    print(hhh)

### FIXED CODE ###

T1, T2 = map(int, input().split())
A1, A2 = map(int, input().split())
B1, B2 = map(int, input().split())
 
P = (A1 - B1) * T1
Q = (A2 - B2) * T2
if P > 0:
	P *= -1
	Q *= -1
 
if P + Q < 0:
	print(0)
elif P + Q == 0:
	print("infinity")
else:
	S = (-P) // (P + Q)
	T = (-P) % (P + Q)
	if T != 0:
		print(S * 2 + 1)
	else:
		print(S * 2)
a=int(input())
b=list(map(int,input().split()))
i=0
j=0
c="YES"  ##ここ文字列だからくおーてーしょんいるの注意
for i in range(a-1):
  for j in range (a-1):
    if b[i]==b[j]
    c="NO" 
print(c)

### FIXED CODE ###

a,b=input().split()
A,B=map(int,input().split())
c=input()
if a==c:
  A=A-1
else:
  B=B-1
print(A,B)
import sys

def input(): return sys.stdin.readline().rstrip("\r\n")
def List(): return list(map(int, input().split()))
def Num(): return int(input())


x, k, d = List()
x = abs(x)
if k * d > x:
    point1 = x - (x // d) * d
    point2 = point1 - d
    travel_to_point1 = (x - point1) // d
    travel_to_point2 = (x - point2) // d
    pair = [[abs(point1), abs(travel_to_point1)], [abs(point2), abs(travel_to_point2)]]
    pair.sort(key = lambda i: i[0])
    # print(pair)
    if pair[0][1] != 0 or pair[1][1] != 0:
        if k % pair[0][1] == 0:
            if pair[0][1] != 1:
                print(pair[0][0])
            else:
                if k & 1:
                    print(pair[0][0])
                else:
                    print(pair[1][0])
        else:
            if pair[1][1] != 1:
                print(pair[1][0])
            else:
                if k & 1:
                    print(pair[1][0])
                else:
                    print(pair[0][0])
    else:
        if pair[0][1] == 0:
            if k % 2 == 0:
                print(pair[0][0])
            else:
                print(pair[1][0])
        else:
            if k % 2 == 0:
                print(pair[1][0])
            else:
                print(pair[0][0])

else:
    print(x - k * d)


### FIXED CODE ###

import sys

def input(): return sys.stdin.readline().rstrip("\r\n")
def List(): return list(map(int, input().split()))
def Num(): return int(input())


x, k, d = List()
x = abs(x)
if d * k > x:
    distance = x % d
    do = k - (x // d)
    if do & 1:
        print(d - distance)
    else:
        print(distance)
else:
    print(x - k * d)
from itertools import product

h, w, k = map(int, input().split())
c = [list(input().split()) for _ in range(h)]

ans = 0

for row_bit in product(range(2), repeat=h):
    for col_bit in product(range(2), repeat=w):
        cnt = 0
        for row in range(h):
            for col in range(w):
                if (c[row][col] == '#') and ((row_bit[row] == 0) and (col_bit[col] == 0)):
                    cnt += 1   
        if cnt == k:
            ans += 1
print(ans)

### FIXED CODE ###

from itertools import product

h, w, k = map(int, input().split())
c = [input() for _ in range(h)]

ans = 0

for row_bit in product(range(2), repeat=h):
    for col_bit in product(range(2), repeat=w):
        cnt = 0
        for row in range(h):
            for col in range(w):
                if (c[row][col] == '#') and ((row_bit[row] == 0) and (col_bit[col] == 0)):
                    cnt += 1   
        if cnt == k:
            ans += 1
print(ans)
n = input()
s = input()

ans = 0
for i in s:
  if i == "I":
    cnt += 1
  else:
    cnt -= 1
  if ans < cnt:
    ans = cnt
print(ans)

### FIXED CODE ###

n = input()
s = input()

ans = 0
cnt = 0
for i in s:
  if i == "I":
    cnt += 1
  else:
    cnt -= 1
  if ans < cnt:
    ans = cnt
print(ans)
a,b=map(int,input().split())
print(a*b if 1<=a,b<=9 else -1)

### FIXED CODE ###

a,b=map(int,input().split())
if 1<=a<=9 and 1<=b<=9:
  print(a*b)
else:
  print(-1)
class Node:
  def __init__(self, n):
    self.number = n
    self.children = []
    self.value = 0
def add_values(nodes, i, x):
  n = nodes[i]
  n.value += x
  for c in n.children:
    add_values(nodes, c, x)
n, q = map(int, input().split())
nodes = [Node(i) for i in range(0, n + 1)]
nodes[0] = None
for i in range(n - 1):
  a, b = map(int, input().split())
  nodes[a].children.append(b)
for _ in range(q):
  p, x = map(int, input().split())
  add_values(nodes, p, x)
print(' '.join(str(nodes[i].value) for i in range(1, n + 1)))


### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000)
def main():
  _map = map
  _input = input
  _int = int
  def calc_results(results, pvalue, i):
    results[i] = pvalue + values[i]
    for j in childrens[i]:
      calc_results(results, results[i], j)
  n, q = _map(_int, _input().split())
  values = [0] * (n + 1)
  results = [0] * (n + 1)
  childrens = [[] for _ in range(n + 1)]
  for i in range(n - 1):
    a, b = _map(_int, _input().split())
    childrens[a].append(b)
  for _ in range(q):
    p, x = _map(_int, _input().split())
    values[p] += x
  calc_results(results, 0, 1)
  print(*[results[i] for i in range(1, n + 1)])
main()
def main():
    import math
    import collections
    N = int(input())

    # def cmb(n, r, mod):
    #     if (r < 0 or r > n):
    #         return 0
    #     r = min(r, n-r)
    #     return g1[n] * g2[r] * g2[n-r] % mod

    mod = 10**9+7
    # g1 = [1, 1]  # 元テーブル
    # g2 = [1, 1]  # 逆元テーブル
    # inverse = [0, 1]  # 逆元テーブル計算用テーブル

    # for i in range(2, N + 1):
    #     g1.append((g1[-1] * i) % mod)
    #     inverse.append((-inverse[mod % i] * (mod//i)) % mod)
    #     g2.append((g2[-1] * inverse[-1]) % mod)

    AB = [tuple(map(int, input().split())) for i in range(N)]

    # d = collections.defaultdict(int)
    d = collections.defaultdict(set)
    # d2 = collections.defaultdict(int)
    i = 0
    ab = []
    for a, b in AB:
        g = math.gcd(a, b)
        a = a // g
        b = b // g
        # d[(a, b)] += 1
        if a > 0 and b < 0:
            a = -a
            b = -b
        d[(a, b)].add(i)
        ab.append((a, b))
        i += 1

    ans = 0
    r = set()

    dd = [1]
    for i in range(1, N):
        dd.append(dd[i-1]*2 % mod)

    r = set()
    ans = 1
    for (a, b) in d:
        if (a, b) in r:
            continue
        l1 = len(d[(a, b)])
        tmp = dd[l1]
        s = set()
        if (-b, a) in d:
            s |= d[(-b, a)]
        if (b, -a) in d:
            s |= d[(b, -a)]
        l2 = len(s)
        if l2:
            ans *= tmp + dd[l2] - 1
            N -= l1 + l2
            ans %= mod

            r.add((-b, a))
            r.add((b, -a))
        else:
            continue

    ans *= dd[N]
    ans -= 1

    print(ans % mod)


main()


### FIXED CODE ###

def main():
    import math
    import collections
    N = int(input())

    mod = 10**9+7
    AB = [tuple(map(int, input().split())) for i in range(N)]

    d = collections.defaultdict(set)
    i = 0
    ans2 = 0
    for a, b in AB:
        if a == 0 and b == 0:
            N -= 1
            ans2 += 1
            continue
        g = math.gcd(a, b)
        if g != 0:
            a = a // g
            b = b // g

        d[(a, b)].add(i)
        i += 1

    ans = 0
    r = set()

    dd = [1]
    for i in range(1, N+1):
        dd.append(dd[i-1]*2 % mod)

    r = set()
    ans = 1
    for a, b in d:
        if (a, b) in r:
            continue
        s1 = d[(a, b)]
        if (-a, -b) in d:
            s1 |= d[(-a, -b)]
        l1 = len(s1)
        r.add((-a, -b))
        if l1:
            s2 = set()
            if (-b, a) in d:
                s2 |= d[(-b, a)]
            if (b, -a) in d:
                s2 |= d[(b, -a)]
            s2 -= s1
            l2 = len(s2)
            if l2:
                ans *= dd[l1] + dd[l2] - 1
                N -= l1 + l2
                ans %= mod
                r.add((-b, a))
                r.add((b, -a))
            else:
                continue
    if N:
        ans *= dd[N]
    ans += ans2
    ans -= 1
    print(ans % mod)


main()
#! /usr/bin/python
# -*- encoding: utf-8 -*-

import sys

if __name__ == '__main__':
    inputN = int(input())
    inputList = list(map(int, input().split()))
    #
    flag = False
    before = 0
    for k in range(inputN):
        if before >= inputList[k]:
            flag = True
        before = inputList[k]
    
    #
    if not flag:
        sys.stdout.write("YES")
        sys.exit()
    
    #  
    for i in range(inputN):
        for j in range(inputN):
            if i != j:
                changeList = inputList[:]
                swap = changeList[i]
                changeList[i] = changeList[j]
                changeList[j] = swap
          
                #
                flag = False
                before = 0
                for k in range(inputN):
                    if before >= changeList[k]:
                        flag = True
                    before = changeList[k]
          
                #
                if not flag:
                    sys.stdout.write("YES")
                    sys.exit()


sys.stdout.write("NO")
          
    
    
    

### FIXED CODE ###

#! /usr/bin/python
# -*- encoding: utf-8 -*-

import sys

if __name__ == '__main__':
    inputN = int(input())
    inputList = list(map(int, input().split()))
    #
    flag = False
    before = 0
    for k in range(inputN):
        if before >= inputList[k]:
            flag = True
        before = inputList[k]
    
    #
    if not flag:
        sys.stdout.write("YES")
        sys.exit()
    
    #  
    for i in range(inputN):
        for j in range(inputN):
            if i != j:
                changeList = inputList[:]
                swap = changeList[i]
                changeList[i] = changeList[j]
                changeList[j] = swap
          
                #
                flag = False
                before = 0
                for k in range(inputN):
                    if before >= changeList[k]:
                        flag = True
                    before = changeList[k]
          
                #
                if not flag:
                    sys.stdout.write("YES")
                    sys.exit()


    sys.stdout.write("NO")
a,b=map(int,input().split())
print(b*2-a)

### FIXED CODE ###

a=int(input())
b=int(input())
print(b*2-a)
S = int(input())

hour = S // 3600
min = (S - 3600 * hour) // 60
sec = S - 3600 * hour - 60 * min

print(':'.join([str(hour),str(min),str(sec)])

### FIXED CODE ###

x = int(input())
a = x // 3600
b = x // 60 %60
c = x % 60

a = str(a)
b = str(b)
c = str(c)
print(":".join([a,b,c]))
n=int(input())
if n == 1:
	print('Hello World')
else:
	a,b=map(int,input().split())
	print(a*b)

### FIXED CODE ###

n=int(input())
if n == 1:
    print('Hello World')
if n == 2:
    a=int(input())
    b=int(input())
    print(a+b)