Wrong answer while using stdin,stdout for input and output in python

I was using input() and print() function to take input and output, but as you know TLE is always a problem in python so I came to know about stdin and stdout. I used stdin.readline() for input and stdout.write() for output.They work fine in my ide but they give WA on CodeChef, however if I run the same code with print() and input() it solves all tasks except last and gives TLE.please help…