CodeJam done by Arnav Limaye.