Problem - D - CodeforcesCodeforces. Programming competitions and contests, programming communityhttps://codeforces.com/contest/1610/problem/D