TITLE: Number of squares and rectangles in a grid with a corner removed
QUESTION [5 upvotes]: I wish to find the number of squares and rectangles in an $8\times9$ checkered grid with two squares removed from the top right. I was able to find the total number of squares and the rectangles in the grid without the removal of the two squares.
Since $n=9,m=8$, therefore $n-m=1$.
number of squares = $\sum_{r=1}^8 (r+r^2) = \frac{8(8+1)}{2}+\frac{8(8+1)[2(8)+1]}{6}$=240
number of rectangles = $\frac {(9)(9+1)(8)(8+1)}{4}$ = 1620
The grid in question: 


Edit: The above calculations were derived as such:
number of squares in an m*n grid, where $m\le n$, 
$=\sum _{r=1}^m r(n-m+r)\\=\sum _{r=1}^m (n-m)r+r^2\\=(n-m)\sum _{r=1}^m r+\sum _{r=1}^mr^2\\=\frac {1}{2}m(m+1)+\frac {1}{6}m(m+1)(2m+1)$
number of rectangles in an $m\times n$ grid, where $m\le n$,
$={m+1 \choose 2}{n+1 \choose 2}\\=\frac{1}{2}(m)(m+1)\times\frac{1}{2}(n)(n+1)\\=\frac {1}{4}(m)(m+1)(n)(n+1)$
Please excuse me for the poor formatting. I'd be very grateful if someone could guide me on the formatting.

REPLY [4 votes]: Hint: 
For squares, it is obvious that the number of $1\times 1$ squares reduced by the truncation is $2$. This is also the case for $2\times 2 ,3\times 3, ...$ squares,  i.e. total squares reduced is $16$. 

FYI - for an $m\times n$ grid where $n=m+1$, number of squares is given by
$$\begin{align}
\sum_{r=1}^m (m-r+1)(n-r+1)
&=\sum_{s=1}^m s(s+1)
&&(s=m-r+1)\\
&=2\sum_{s=1}^m \binom {s+1}2\\
&=2\binom {m+2}3\\
&=\frac 13m(m+1)(m+2)\end{align}$$

Addendum: More Extensive Solution
Consider an $m\times n$ grid where $n=m+1$. Here $m=8$ i.e. $n=9$.
SQUARES
Subtractive Method

Number of squares in Full Grid is $\displaystyle \frac 13 m(m+1)(m+2)=240$.  
The leftmost small square is part of $m$ squares (each of dimension $q\times 
q, q=1,2,3,\cdots, m$). Hence the truncation of this small squares reduces the number of squares by $m$. Similarly for the second leftmost small square*.
Hence the truncation of the two squares reduces total number of squares by $2m=16$. 
Hence total number of squares after truncation is is $240-16=\color{red}{224}$

Additive Method
(This is similar to the Mythomorphic's now deleted solution).

Number of squares in a $p\times q$ grid ($p<q$) is $S_{p,q}=\displaystyle \sum_{r=1}^p (q+1-r)(p+1-r)=\sum_{s=1}^p s(s+q-p)=\frac16 p(p+1)(3q-p+1)$
Number of squares in truncated grid is $\displaystyle \underbrace{S_{7,9}}_{7\times 9\text{grid}}+\underbrace{S_{7,8}}_{8\times 7\text{grid}}-\underbrace{S_{7,7}}_{\text{overlapping $7\times 7$ grid}}=196+168-140=\color{red}{224}$

RECTANGLES
Subtractive Method

Number of rectangles in Full Grid is $\displaystyle \binom {m+1}2\binom{m+2}2=1620$.  
The leftmost small square is part of $\displaystyle\sum_{r=1}^n\sum_{s=1}^m rs=mn=m(m+1)$ rectangles (each of dimension $r\times 
s$). Hence the truncation of the leftmost small square reduces the number of rectangles by $m(m+1)$. 
The second leftmost small square is part of $\displaystyle\sum_{r=1}^{n-1}\sum_{s=1}^m rs=m(n-1)=m^2$ rectangles (each of dimension $r\times 
s$). Hence the truncation of the second leftmost small square reduces total number of squares by $m^2$. 
The truncation of both first and second leftmost small squares reduces total number of rectangles by $m(2m+1)=136$.
Hence total number of rectangles after truncation is is $1620-136=\color{red}{1484}$

Additive Method
(This is similar to the Mythomorphic's now deleted solution).

Number of rectangles in a $p\times q$ grid ($p<q$) is $R_{p,q}=\displaystyle \binom {p+1}2\binom {q+2}2$
Number of rectangles in truncated grid is $\displaystyle \underbrace{R_{7,9}}_{7\times 9\text{grid}}+\underbrace{R_{7,8}}_{8\times 7\text{grid}}-\underbrace{R_{7,7}}_{\text{overlapping $7\times 7$ grid}}\\=\binom 82\binom {10}2+\binom 82\binom 92-\binom 82\binom 82=1260+1008-784=\color{red}{1484}$