introduce fmemo
use fmemo in lcs