GRAVEL : codechef problem

What is the difference between following two codes??
One gives WA bt other gives AC… took so many wa’s? just the diff. of cout and printf();
http://www.codechef.com/viewsolution/3077197
http://www.codechef.com/viewsolution/3077185