02 Jul PMCA Friday 19:00 Python Homework 20.06.26.
Alice took a clean sheet of paper and drew horizontal and vertical lines onto the paper.
The horizontal lines have -coordinates , and the vertical lines have -coordinates .
Given these coordinates, count the number of squares that appeared on the paper.
(The whole boundary of the square has to be drawn. The inside of the square does not have to be empty.)
The first line of input contains the integers and .
The second line of input contains a strictly increasing sequence consisting of space-separated integers: .
The third line of input contains a strictly increasing sequence consisting of space-separated integers: .
All horizontal and vertical coordinates are between and , inclusive.
Output a single line with a single integer: the total number of squares.
3 4 0 1 3 1 2 4 8
In the example there is one square, one square, and one square.
You can consider all the distances between horizontal lines or vertical lines are potential square sides.
for example, if the distance between 2 horizontal lines is 5, as long as you can find the distance between 2 vertical lines is also 5, then you can form a squre.
You can put all the distances between horizontal lines into a list.