C++
O(n^3) implementation: take 2. But it is experimentally running in O(n^4)...