I was doing the question [problem:https://codeforces.net/problemset/problem/1372/B]. Here are my two submissions 271307925 and 271307851. One of the approaches works correctly while other gives TLE. The only difference between them is how I initialize the iterator 'it' using the upper_bound function.