Buggy python submission (verdict: Runtime Error):
n=int(input())
from math import gcd
from collections import defaultdict
abd=defaultdict(int)
mod=10**9+7
ab=[]
wzero=0
azero=0
bzero=0
for i in range(n):
    a,b=map(int,input().split())
    if a==0 and b==0:
        wzero+=1
        continue
    elif a==0 and b!=0:
        azero+=1
        continue
    elif a!=0 and b==0:
        bzero+=1
        continue
    x=gcd(a,b)
    a//=x
    b//=x
    ab.append((a,b))
    abd[(a,b)]+=1

kumid=defaultdict(int)
for i in range(len(ab)):
    a,b=ab[i]
    cnt=abd[(-b,a)]+abd[(b,-a)]
    kumid[cnt]+=1
maxkey=max(kumid.keys())
ans=1

for i in range(maxkey,1,-1):
    if kumid[i]!=0:
        j=kumid[i]
        kumid[j]-=i
        tmp=2**i+2**j-1
        ans*=(tmp%mod)
        ans%=mod
#print(kumid)
ans*=(kumid[1]+1)
ans%=mod
ans*=2**kumid[0]%mod
ans%=mod
ans*=(2**azero+2**bzero-1)%mod
ans%=mod
ans+=wzero
ans=(ans+mod-1)%mod
print(ans)

Fixed submission:
from math import gcd
from collections import defaultdict

n=int(input())
abd=defaultdict(int)
mod=10**9+7
wzero=0
azero=0
bzero=0
for i in range(n):
    a,b=map(int,input().split())
    if a==0 and b==0:
        wzero+=1
    elif a==0 and b!=0:
        azero+=1
    elif a!=0 and b==0:
        bzero+=1
    else:
        g=gcd(a,b)
        a=a//g
        b=b//g
        abd[(a,b)]+=1

liskey=list(abd.keys())
ans=1
for k in liskey:
    if abd[k] != 0:
        a,b=k
        x=abd[(a,b)]+abd[(-a,-b)]
        y=abd[(-b,a)]+abd[(b,-a)]
        abd[(a,b)]=0
        abd[(-a,-b)]=0
        abd[(-b,a)]=0
        abd[(b,-a)]=0
        ans*=(2**x+2**y-1+mod)%mod
        ans%=mod

ans*=(2**azero+2**bzero-1)
ans%=mod
ans=(ans+wzero)%mod
ans=(ans+mod-1)%mod
print(ans)

Buggy python submission (verdict: Runtime Error):
n=int(input())
from math import gcd
from collections import defaultdict
abd=defaultdict(int)
mod=10**9+7
ab=[]
wzero=0
azero=0
bzero=0
for i in range(n):
    a,b=map(int,input().split())
    if a==0 and b==0:
        wzero+=1
        continue
    elif a==0 and b!=0:
        azero+=1
        continue
    elif a!=0 and b==0:
        bzero+=1
        continue
    x=gcd(a,b)
    a//=x
    b//=x
    ab.append((a,b))
    abd[(a,b)]+=1

n-=(wzero+azero+bzero)
kumid=defaultdict(int)
for i in range(n):
    a,b=ab[i]
    cnt=abd[(-b,a)]+abd[(b,-a)]
    kumid[cnt]+=1
maxkey=max(kumid.keys())
ans=1

for i in range(maxkey,1,-1):
    if kumid[i]!=0:
        j=kumid[i]
        kumid[j]-=i
        tmp=2**i+2**j-1
        ans*=(tmp%mod)
        ans%=mod
#print(kumid)
ans*=(kumid[1]+1)
ans%=mod
ans*=2**kumid[0]%mod
ans%=mod
ans*=(2**azero+2**bzero-1)%mod
ans%=mod
ans+=wzero
ans=(ans+mod-1)%mod
print(ans)

Fixed submission:
from math import gcd
from collections import defaultdict

n=int(input())
abd=defaultdict(int)
mod=10**9+7
wzero=0
azero=0
bzero=0
for i in range(n):
    a,b=map(int,input().split())
    if a==0 and b==0:
        wzero+=1
    elif a==0 and b!=0:
        azero+=1
    elif a!=0 and b==0:
        bzero+=1
    else:
        g=gcd(a,b)
        a=a//g
        b=b//g
        abd[(a,b)]+=1

liskey=list(abd.keys())
ans=1
for k in liskey:
    if abd[k] != 0:
        a,b=k
        x=abd[(a,b)]+abd[(-a,-b)]
        y=abd[(-b,a)]+abd[(b,-a)]
        abd[(a,b)]=0
        abd[(-a,-b)]=0
        abd[(-b,a)]=0
        abd[(b,-a)]=0
        ans*=(2**x+2**y-1+mod)%mod
        ans%=mod

ans*=(2**azero+2**bzero-1)
ans%=mod
ans=(ans+wzero)%mod
ans=(ans+mod-1)%mod
print(ans)

Buggy python submission (verdict: Runtime Error):
n=int(input())
from math import gcd
from collections import defaultdict
abd=defaultdict(int)
ab=[]
wzero=0
azero=0
bzero=0
for i in range(n):
    a,b=map(int,input().split())
    if a==0 and b==0:
        wzero+=1
        continue
    elif a==0 and b!=0:
        azero+=1
        continue
    elif a!=0 and b==0:
        bzero+=1
        continue
    x=gcd(a,b)
    a//=x
    b//=x
    ab.append((a,b))
    abd[(a,b)]+=1

n-=(wzero+azero+bzero)
kumid=defaultdict(int)
for i in range(n):
    a,b=ab[i]
    cnt=abd[(-b,a)]+abd[(b,-a)]
    kumid[cnt]+=1
maxkey=max(kumid.keys())
ans=1

for i in range(maxkey,1,-1):
    if kumid[i]!=0:
        j=kumid[i]
        kumid[j]-=i
        tmp=2**i+2**j-1
        ans*=tmp
#print(kumid)
ans*=(kumid[1]+1)

ans*=2**kumid[0]
ans*=(2**azero+2**bzero-1)
ans+=wzero
ans-=1
print(ans)

Fixed submission:
from math import gcd
from collections import defaultdict

n=int(input())
abd=defaultdict(int)
mod=10**9+7
wzero=0
azero=0
bzero=0
for i in range(n):
    a,b=map(int,input().split())
    if a==0 and b==0:
        wzero+=1
    elif a==0 and b!=0:
        azero+=1
    elif a!=0 and b==0:
        bzero+=1
    else:
        g=gcd(a,b)
        a=a//g
        b=b//g
        abd[(a,b)]+=1

liskey=list(abd.keys())
ans=1
for k in liskey:
    if abd[k] != 0:
        a,b=k
        x=abd[(a,b)]+abd[(-a,-b)]
        y=abd[(-b,a)]+abd[(b,-a)]
        abd[(a,b)]=0
        abd[(-a,-b)]=0
        abd[(-b,a)]=0
        abd[(b,-a)]=0
        ans*=(2**x+2**y-1+mod)%mod
        ans%=mod

ans*=(2**azero+2**bzero-1)
ans%=mod
ans=(ans+wzero)%mod
ans=(ans+mod-1)%mod
print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())
zen=[]
ab=[]
ba=[]
for i in range(n):
    a,b=map(int, input().split())
    zen.append([a,b])
    ab.append(a/b)
    ba.append(b/a)

ba=sorted(ba)
from bisect import bisect_left, bisect_right
from collections import defaultdict
kosudic=defaultdict(int)
for i in range(n):
    a,b=zen[i][0],zen[i][1]
    x=-a/b
    #print(x)
    l=bisect_left(ba, x)
    r=bisect_right(ba, x)
    #print(l,r)
    search=ba[l:r]
    kosu=sum([1 for j in search if abs(j-x)<10**(-10)])
    kosudic[kosu]+=1

ans=1
maxs=max(kosudic.keys())
#print(kosudic)

for i in range(maxs,-1,-1):
    if kosudic[i]!=0 and i!=1:
        ans*=(i**2+1)**kosudic[i]
        kosudic[1]-=i
    if i==1:
        ans*=3**(kosudic[1]//2)
    if i==0:
        ans*=2**kosudic[0]

print(ans-1)

Fixed submission:
from math import gcd
from collections import defaultdict

n=int(input())
abd=defaultdict(int)
mod=10**9+7
wzero=0
azero=0
bzero=0
for i in range(n):
    a,b=map(int,input().split())
    if a==0 and b==0:
        wzero+=1
    elif a==0 and b!=0:
        azero+=1
    elif a!=0 and b==0:
        bzero+=1
    else:
        g=gcd(a,b)
        a=a//g
        b=b//g
        abd[(a,b)]+=1

liskey=list(abd.keys())
ans=1
for k in liskey:
    if abd[k] != 0:
        a,b=k
        x=abd[(a,b)]+abd[(-a,-b)]
        y=abd[(-b,a)]+abd[(b,-a)]
        abd[(a,b)]=0
        abd[(-a,-b)]=0
        abd[(-b,a)]=0
        abd[(b,-a)]=0
        ans*=(2**x+2**y-1+mod)%mod
        ans%=mod

ans*=(2**azero+2**bzero-1)
ans%=mod
ans=(ans+wzero)%mod
ans=(ans+mod-1)%mod
print(ans)