Unsupervised and Supervised learning by Dense Associative Memory under replica symmetry breaking