There's an off-by-one error in the dynamic programming step of DTW that should be fixed by expanding the memoization matrix.