Remember
- Row-major: (r, c) is flat index r x cols + c. Walk rows in the inner loop and memory is touched in order.
- 2D prefix sum: own value plus above plus left minus the diagonal, and any rectangle is four lookups.
- An adjacency matrix costs V squared cells no matter how few edges there are.