import algorithm, complex, macros, math, sequtils, sets, strutils, tables macro unpack*(rhs: seq, cnt: static[int]): auto = let v = genSym(); result = quote do:(let `v` = `rhs`;()) if NimMajor == 0 and NimMinor <= 17: for i in 0..>=`*(n: var int, m: int) = n = n shr m proc `?=`*(n: var SomeNumber, m: SomeNumber) = n = max(n, m) proc newSeq2*[T](n1, n2: Natural): seq[seq[T]] = newSeqWith(n1, newSeq[T](n2)) proc newSeq3*[T](n1, n2, n3: Natural): seq[seq[seq[T]]] = newSeqWith(n1, newSeqWith(n2, newSeq[T](n3))) # -------------------------------------------------- # const INF = 10 ^ 9 let (N, M) = input(int, 2) let S, T = "#" & input(string) var dp: array[-1 .. 1000, array[-1 .. 1000, int]] for i in -1 .. N: for j in -1 .. M: if i == 0 and j == 0: dp[i][j] = 0 else: dp[i][j] = INF for i in 0 .. N: for j in 0 .. M: let c = (if S[i] == T[j]: 0 else: 1) dp[i][j]