code forces help

http://codeforces.com/problemset/problem/852/C