  For immersed curves in Euclidean space of any codimension we establish a
Li--Yau type inequality that gives a lower bound of the (normalized) bending
energy in terms of multiplicity. The obtained inequality is optimal for any
codimension and any multiplicity except for the case of planar closed curves
with odd multiplicity; in this remaining case we discover a hidden algebraic
obstruction and indeed prove an exhaustive non-optimality result. The proof is
mainly variational and involves Langer--Singer's classification of elasticae
and Andr\'{e}'s algebraic-independence theorem for certain hypergeometric
functions. We also discuss applications to elastic flows, networks, and knots.
