Successful solution for DevuLand, Dinosaurs and Laddus problem - http://www.codechef.com/OCT14/problems/PRLADDU.
Algorithm was correct from the beginning, however a usage of long was needed.