human
Count squares possible from M and N straight lines parallel to X and Y axis respectively | Function to count all the possible squares with given lines parallel to both the X and Y axis.
Stores the count of all possible distances in X [ ] & Y [ ] respectively.
Find distance between all pairs in the array X [ ].
Add the count to m1.
Find distance between all pairs in the array Y [ ].
Add the count to m2.
Find sum of m1 [ i ] * m2 [ i ] for same distance.
Find current count in m2.
Add to the total count.
Return the final count.
Driver Code.
Given lines.
Function call"
Solution in Python:

=====
Write me a code to count squares possible from M and N straight lines parallel to X and Y axis respectively and the other steps required?
assistant
#Here is code to count squares possible from M and N straight lines parallel to X and Y axis respectively and the other steps required.
 def numberOfSquares ( X , Y , N , M ) :
	m1 = { }
	m2 = { }
	ans = 0
	for i in range ( 0 , N ) :
		for j in range ( i + 1 , N ) :
			dist = abs ( X [ i ] - X [ j ] )
			if dist in m1 :
				m1 [ dist ] = m1 [ dist ] + 1
			else :
				m1 [ dist ] = 1
	for i in range ( 0 , M ) :
		for j in range ( i + 1 , M ) :
			dist = abs ( Y [ i ] - Y [ j ] )
			if dist in m2 :
				m2 [ dist ] = m2 [ dist ] + 1
			else :
				m2 [ dist ] = 1
	for key in m1 :
		if key in m2 :
			ans = ans + ( m1 [ key ] * m2 [ key ] )
	return ans
if __name__ == " _ _ main _ _ " :
	X = [ 1 , 3 , 7 ]
	Y = [ 2 , 4 , 6 , 1 ]
	N = len ( X )
	M = len ( Y )
	print ( numberOfSquares ( X , Y , N , M ) )