SPOJ TRT Treat for the Cows


Using fast I/O by Egor isn’t working too.
Getting TLE. Can anyone help??
And does anyone have a better approach??