codejam dynamic programming knapsack parenthesization edit distance divide and conquer cloest pair of points