First off, credits to Topcoder, as this problem was used in one of their SRMs (but they have no editorial for it..)
In this problem, I am given n points (where n is
Let there be a triangle with 3 points p1=(x_1,y_1),p2=(x_2,y_2) and p3=(x_3,y_3). Let p1,p2,p3 be the position vectors.If origin lies within, then cross product of any one position vector with other two will be different in sign ( one negative , one positive ). But if origin lies outside then there will be one point which has negative cross product with both the other points. So for each point i find points whose cross product is less than 0.Now if you select any two of these points and make a triangle along with point i , origin will be outside this triangle.Thats why you subtract from res ( selection of 2 from such points + point i ). This was by far the best solution many implemented as it did not have the problem of precision with double etc.