Problem:
Edit Distance (Levenshtein Distance)

Find the edit distance between given two words s1 and s2.

The disntace is the minimum number of single-character edits required to change one word into the other. The edits including the following operations:

insertion: Insert a character at a particular position.

deletion: Delete a character at a particular position.

substitution: Change the character at a particular position to a different character

Input

s1
s2

Two words s1 and s2 are given in the first line and the second line respectively. The words will consist of lower case characters.

Output

Print the edit distance in a line.

Constraints

1 ≤ length of s1 ≤ 1000

1 ≤ length of s2 ≤ 1000

Sample Input 1

acac
acm

Sample Output 1

2

Sample Input 2

icpc
icpc

Sample Output 2

0

Solution in C# (judge verdict: Accepted)

using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
using static System.Convert;
using static System.Math;
//using Debug;
//using static System.Globalization.CultureInfo;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
        var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        Solve();
        Console.Out.Flush();
        //WriteLine(Solve());
    }
    static void Solve()
    {
        var str1 = ReadLine();
        var str2 = ReadLine();
        var dp = new int[str1.Length + 1, str2.Length + 1];
        for (var i = 0; i <= str1.Length; i++)
            dp[i, 0] = i;
        for (var i = 0; i <= str2.Length; i++)
            dp[0, i] = i;
        for (var i = 1; i <= str1.Length; i++)
            for (var j = 1; j <= str2.Length; j++)
                dp[i, j] = Min(dp[i - 1, j] + 1, Min(dp[i, j - 1] + 1, dp[i - 1, j - 1] + ToInt32(str1[i - 1] != str2[j - 1])));
        WriteLine(dp[str1.Length, str2.Length]);
    }
}