Problem p02679 (python)

Fixed submission:
def main():
    import sys
    input = sys.stdin.buffer.readline
    from collections import Counter as cc
    from fractions import gcd
    n = int(input())
    mod = 10**9 + 7
    C_p,C_n = cc(),cc()
    count= 0
    count_zero_a = count_zero_b = 0
    ans = 1
    for i in range(n):
        a,b = map(int, input().split())
        if a == 0 and b== 0:
            count += 1
        else:
            gcd_ab = gcd(a,b)
            a //= gcd_ab
            b //= gcd_ab
            if b == 0:
                count_zero_b += 1
            elif a == 0: 
                count_zero_a += 1
            else:
                if a/b>0:
                    C_p[a,b] += 1
                else:
                    C_n[a,b] += 1
    count_zero = count
    ans *= (2**count_zero_a + 2**count_zero_b -1)%mod
    count += count_zero_a + count_zero_b    
    for a,b in C_p:
        if (-b,a) in C_n:
            count += C_n[-b,a] + C_p[a,b]
            ans *= (2**C_n[-b,a] + 2**C_p[a,b] -1)%mod
    ans *= pow(2,n-count,mod)%mod
    ans = (ans +count_zero -1) % mod
    print(ans)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    import sys
    input = sys.stdin.buffer.readline
    from collections import Counter as cc
    from fractions import gcd
    n = int(input())
    mod = 10**9 + 7
    C_p,C_n = cc(),cc()
    count= 0
    ans = 1
    for i in range(n):
        a,b = map(int, input().split())
        if a == 0 and b== 0:
            count += 1
        else:
            gcd_ab = gcd(a,b)
            a //= gcd_ab
            b //= gcd_ab
            if b == 0:
                count_zero_b += 1
            elif a == 0: 
                count_zero_a += 1
            else:
                if a/b>0:
                    C_p[a,b] += 1
                else:
                    C_n[a,b] += 1
    count_zero = count
    ans *= (2**count_zero_a + 2**count_zero_b -1)%mod
    count += count_zero_a + count_zero_b    
    for a,b in C_p:
        if (-b,a) in C_n:
            count += C_n[-b,a] + C_p[a,b]
            ans *= (2**C_n[-b,a] + 2**C_p[a,b] -1)%mod
    ans *= pow(2,n-count,mod)%mod
    ans += count -1
    print(ans)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    import sys
    input = sys.stdin.buffer.readline
    n = int(input())
    mod = 10**9 + 7
    C_p,C_n = [],[]
    for i in range(n):
        a,b = map(int, input().split())
        if b == 0:
            C_n.append(0)
        elif a/b < 0:
            C_n.append(a/b)
        else:
            C_p.append(a/b)
    import numpy as np
    from collections import Counter as cc
    C_p,C_n = cc(C_p),cc(C_n)
    count= 0
    re = 1
    for c in C_p:
        if c == 0:
            re *= (2**C_n[-1/c] + 2**C_p[c] -1)%mod
            count += C_p[c]+C_n[c]
            continue

        if -1/c in C_n:
            count += C_n[-1/c] + C_p[c]
            re *= (2**C_n[-1/c] + 2**C_p[c] -1)%mod
    ans = pow(2,n-count,mod)*re%mod -1
    print(ans)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    import sys
    input = sys.stdin.buffer.readline
    n = int(input())
    mod = 10**9 + 7
    C = []
    for i in range(n):
        a,b = map(int, input().split())
        if b == 0:
            C.append(0)
        C.append(a/b)
    import numpy as np
    C = np.array(C)
    C_p = C[C>=0]
    C_n = C[C<0]
    from collections import Counter as cc
    C_p,C_n = cc(C_p),cc(C_n)
    count= 0
    re = 1
    for c in C_p:
        if c == 0:
            re *= C_p[c]
            count += C_p[c]
            continue
        
        if -1/c in C_n:
            count += C_n[-1/c] + C_p[c]
            re *= (2**C_n[-1/c] + 2**C_p[c] -1)%mod
    ans = pow(2,n-count,mod)*re%mod -1
    print(ans)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    import sys
    input = sys.stdin.buffer.readline
    n = int(input())
    mod = 10**9 + 7
    # A = []
    # B = []
    C = []
    for i in range(n):
        a,b = map(int, input().split())
        C.append(a/b)
    import numpy as np
    # A = np.array(A)
    # B = np.array(B)
    C = np.array(C)
    C_p = C[C>=0]
    C_n = C[C<0]
    from collections import Counter as cc
    C_p,C_n = cc(C_p),cc(C_n)
    num = 0
    count= 0
    re = 1
    for c in C_p:
        if -1/c in C_n:
            num = C_n[-1/c] + C_p[c]
            count += num
            re *= (2**C_n[-1/c] + 2**C_p[c] -1)%mod
    ans = pow(2,n-count,mod)*re%mod -1
    print(ans)



if __name__ == '__main__':
    main()