Help regarding fast I/O

Why is my same code getting WA when submitted with
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
gives WA but when removed gets AC?!!
With the lines
Without the lines

Also what does sync with base , cin.tie and cout.tie means?

Try it again, this time replacing all usages of puts with the corresponding cout statement.

4 Likes