✅ One Line Solution
(Disclaimer: this is not an example to follow in a real project - it is written for fun and training mostly)\n\n# Code #1.1 - One Line\nTime complexity: O(mn). 
(Disclaimer: this is not an example to follow in a real project - it is written for fun and training mostly)\n\n# Code #1.1 - One Line\nTime complexity: $$O(m*n)$$. Space complexity: $$O(m*n)$$.\n```python3\nclass Solution:\n    def countSquares(self, g: List[List[int]]) -> int:\n        return sum(starmap(f:=cache(lambda i,j:i*j*g[i][j] and 1+min(f(i,j-1),f(i-1,j-1),f(i-1,j)) or g[i][j]),product(range(len(g)),range(len(g[0])))))\n```\n\n# Code #1.2 - Unwrapped\n```python3\nclass Solution:\n    def countSquares(self, g: List[List[int]]) -> int:\n        @cache\n        def f(i, j):\n            if i and j and g[i][j]:\n                return 1 + min(f(i,j-1), f(i-1,j-1), f(i-1,j))\n\n            return g[i][j]\n\n        return sum(starmap(f, product(range(len(g)), range(len(g[0])))))\n```\n\n(Disclaimer 2: code above is just a product of fantasy packed into one line, it is not claimed to be \'true\' oneliners - please, remind about drawbacks only if you know how to make it better)
['Array', 'Dynamic Programming', 'Recursion', 'Memoization', 'Matrix', 'Python', 'Python3']