need help with stream member functions

ios_base::sync_with_stdio(0);
cin.tie(0);

after trying to solve kingkon for about a week i looked at solution , my code got TLE and memory used was 28 M aftr adding the two lines at the top, the same code got accepted and mem used was 2.3 M,
please throw some light on the function of these stream member functions…
heres my code http://www.codechef.com/viewsolution/4376661
and the one i looked at http://ideone.com/xiZpct
thanx for ur time.

//