Problem Link: https://mirror.codeforces.com/contest/1417/problem/C
My solution: https://mirror.codeforces.com/contest/1417/submission/131124634
My solution is very similar (or almost same) to the editorial's solution: https://mirror.codeforces.com/blog/entry/83036 The only difference I noticed is that I'm using cin/cout instead of scanf/printf and I'm using vectors instead of arrays. Also, I'm using #define int long long.