An integer between $1000$ and $9999,$ inclusive, is called lopsided if the sum of its two leftmost digits is exactly $2$ more than the sum of its two rightmost digits. How many lopsided integers are there?
Let $L(t)$ count pairs $(a,b)$ with $1\le a\le9$, $0\le b\le9$, $a+b=t$, and $R(s)$ count digit pairs with sum $s$.
The answer is $\sum_sL(s+2)R(s)$, so $s=0,\dots,7$ give $\sum(s+2)(s+1)=240$; $s=8,9$ give $9\cdot9+8\cdot10=161$; $s=10,\dots,16$ give $\sum(17-s)(19-s)=196$.