For immersed curves in Euclidean space of any codimension we establish Li-Yau type inequalities that give lower bounds of the (normalized) bending energy in terms of multiplicity. The obtained inequalities are 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é's algebraic-independence theorem for certain hypergeometric functions. Applications to elastic flows are also given.