How to find the number of squares formed by given lattice points? Let us say that we are N integer coordinates (x, y) - what would our approach be if we were supposed to find the number of squares we could make from those given n points?
Additionally, if we were to figure out how many, minimally, more points should we add that we manage to form at least ONE square from the points, how would we go about that?

I dont have the reputation to comment so I am writing it in answer. This problem seems to be taken from http://www.codechef.com/OCT14/problems/CHEFSQUA live contest! please do remove it. Please respect the code of honor.
And more over you are complaining of no help.
