Codeforces 474F problem solved
Codeforces 474F code structure and memory optimized