#C6365. Minimum Cost String Transformation

    ID: 50117 Type: Default 1000ms 256MiB

Minimum Cost String Transformation

Minimum Cost String Transformation

Given two strings a and b, compute the minimum cost required to transform a into b using the following operations:

  • Insert a character (cost = 1)
  • Delete a character (cost = 1)
  • Replace a character (cost = 2)

You are allowed to perform any of these operations any number of times. Use a dynamic programming approach to solve the problem. The output is a single integer representing the minimum cost.

Note: If one of the strings is empty, the cost will be equal to the number of characters in the other string multiplied by the insertion or deletion cost.

inputFormat

The input consists of two lines. The first line contains the string a and the second line contains the string b.

outputFormat

Output a single integer, which is the minimum cost required to transform a into b.

## sample
abcdef
azced
5

</p>