solution for codeforces 439C