Postgresql Substring Between Two Strings Codeforces Rating