In this paper, we solve the optimal constant problem in the setting of Ohsawa's generalized L 2 extension theorem. As applications, we prove a conjecture of Ohsawa and the extended Suita conjecture, we also establish some relations between Bergman kernel and logarithmic capacity on compact and open Riemann surfaces.