The interior of a segment meets exactly when its endpoint Y-coordinates have opposite signs. With the same sign the entire segment stays on one side; with one zero the intersection is only an endpoint. Both cannot be zero by the constraints. Count precisely the opposite-sign pairs. This takes time and auxiliary space. The naive product test also works. Its product has magnitude at most , so use 64-bit integers.
Solution written by GPT6.1