Given a grid with blocked points, count the maximum number of axis-aligned square items of any side length that can be placed without covering blocked points, respecting placement order and same-size non-overlap rules.
Hard8ArrayDynamic programmingPrefix sumCombinatoricsNo attempts yetTime limit2sMemory limit512 MB"Lefkaritika" are traditional handmade lace designs and the characteristic embroidery art of Cyprus. Lace making in the village of Lefkara goes back to the fourteenth century. Local craft, the embroidery of the Venetian courtiers who ruled the island in 1489, and ancient Greek and Byzantine geometric patterns all shaped it, and every design is made by hand from four basic elements: the hemstitch, cut work, satin stitch fillings and needlepoint edgings.
The craft is still the main occupation of the women in the village. They make tablecloths, napkins and show pieces while sitting together and talking in the narrow streets or on covered patios. A young girl picks it up over years of informal exposure, then learns from her mother or grandmother how to apply cotton thread to linen. Once a lace maker knows the art thoroughly, she designs work that carries both the tradition and her own personality. Lace making is at the center of daily life for the women of Lefkara and a proud symbol of their identity.

"Lefkaritika" were inscribed on the Representative List of the Intangible Cultural Heritage of Humanity in 2009. They are recorded in the Heritage Archives of the Municipality of Lefkara, in the Archives of Oral Tradition of the Scientific Research Centre of Cyprus, and in the National Heritage Index.
Pantelis owns a small souvenir shop in Lefkara. He inherited a large collection of square "Lefkaritika" from his grandmother and wants to store them in the shop's storeroom. The storeroom is not large enough, so he will have to place some items on top of others. He wants to know how many items he can put down at once.
The floor of the storeroom is a grid of W×L points with integer coordinates. Write (x,y) for the point in column x and row y, where 1≤x≤W and 1≤y≤L. A light bulb hangs directly above some of these points.
The rules for placing items are:
The picture below is a storeroom with W=4 and L=3, drawn as a grid of points. A point with a bulb above it is drawn as O and a free point as a dot. The bulbs are at (2,2) and (3,3).

Only one item fits here, the item of side 1 whose top left corner is (3,1). Every other placement covers a point that lies under a bulb.
Print one line with the largest number of items that can be placed in the storeroom at once. The answer can be larger than a 32-bit integer holds.
In the first example the storeroom has W=4 and L=5, and the bulbs are at (1,4), (1,5) and (4,1). Three items of side 2 fit, as in image 3. An item of side 1 may lie on an item of side 2 but not on another item of side 1, so nine more items fit as in image 4. That is twelve items in total.
