  We employ signed measures that are positive definite up to certain degrees to
establish Levenshtein-type upper bounds on the cardinality of codes with given
minimum and maximum distances, and universal lower bounds on the potential
energy (for absolutely monotone interactions) for codes with given maximum
distance and cardinality. The distance distributions of codes that attain the
bounds are found in terms of the parameters of Levenshtein-type quadrature
formulas. Necessary and sufficient conditions for the optimality of our bounds
are derived. Further, we obtain upper bounds on the energy of codes of fixed
minimum and maximum distances and cardinality.
