Learned a very important lesson that never use cin and cout with a program which is very heavily relieved on high data rate.
instead use printf and scanf because it drastically changes the rate of processing of your program.
for example on codechef using cin and cout this program took (1.78) sec to execute.
while using printf and scanf the program took                (0.23) sec ONLY..!!!! i.e. 800% gain....
will surely use them foreever from now on.
This again shows the consistency of scanf and printf for large inputs.
although this program took (5.52) seconds which is not all the way too good.
but it is acceptable to the codechef and there are several programs which get it done in as short a time as (0.21) seconds.
but there is a inconsistency with thier program that they all use getchar_unlocked which is way too fast than scanf but it not at all recommednded when it comes the scanf works fine as there are many online posts stating that there is a buffer leak on using it..
so ofcourse this result is acceptable to the domain of codechef..