This problem is in Contest(s) below:
Contest 1073:7月8日C++String
Contest 1075:Python初级算法字符串