Dimension formula for graded Lie algebras and its applications