Silly solution in c++ for enormous input. Apparently, cin costs too much time, so we have to try somthing else
Enormous input problem with cin solved. Very interesting, indeed, follow the links
Plain old C is always efficient. Vanilla solution stands the time constraint for enormous input