The following are very familiar and basic items, individually.


(1) The number $a(n)$ of rectangles (parallel to axes) in an $n\times n$ square grid.


(2) The number $b(n)$ of cubes (parallel to axes) in an $n\times n\times n$ cube.


However, I could not find a reference to a direct **bijective** proof for $a(n)=b(n)$. Can you provide such an argument of reference?



in need of a direct combinatorial/bijective proof
Following @wojowu's suggestion, we have:


Let $h$ be the side of the inner cube, and let $(i,j,k)$ be its corner nearest the origin. Then we have $0\le i,j,k < n-h+1 \le n$.


Let us describe our rectangle by the corners $(x\_1, y\_1)$ and $(x\_2, y\_2)$ with $x\_1<x\_2$ and $y\_1<y\_2$. Then our mapping from $(i,j,k,h)\to (x\_1,y\_1), (x\_2,y\_2)$ looks like


$$ (i,j,k,h) \to
\begin{cases}
(i,k),(j,n-h+1) & \text{if $i<j$} \\
(j,k),(n-h+1,n-h+1) & \text{if $i=j$}\\
(k,j),(n-h+1,i) & \text{if $i>j$}.
\end{cases}
$$


Going the other way we have
$$
(x\_1,y\_1),(x\_2,y\_2)\to
\begin{cases}
(x\_1,x\_2,y\_1,n-y\_2+1) & \text{if $x\_2 < y\_2$}\\
(x\_1,x\_1,y\_1,n-y\_2+1) & \text{if $x\_2 = y\_2$}\\
(x\_2,y\_1,x\_1,n-y\_2+1) & \text{if $x\_2 > y\_2$}
\end{cases}
$$


It is easy to see that these are inverse.


