Question: how to avoid tle in codechef?
Answer: Read the bounds in the input carefully before writing your program, and try to figure out which inputs will cause your program to run the slowest. The second most common cause of TLE is that your method of reading input and writing output is too slow. In Java, do not use a Scanner; use a BufferedReader instead.