Tag - dynamic programming code generation algorithm