n^2 algorithms for the win