Counting Rectangles

UVA - 10502