Postgresql Substring Between Two Strings Codeforces