Solution for HELPLIRA in Codechef Oct 2013 Long Contest.