you need to come up with a better algorithm to solve the problem, fast IO has nothing to do, sometimes it does but mostly the faster and optimized algorithms are more of the importance.
adding these line may only give you an advantage of may be a few mill second but not more than that. the most important thing if you are having input file where inputs generally exceed 10^5 then you should try to avoid N^2 complexity and try to come with an algorithm which has complexity say N, N*logN or something which is lower than that
some algorithms you can implement to reduce the time complexity are
Divide and Conquer
Greedy approach and many more.
Huh i don’t know any more because you know i recently started to program this very month.
Feel free to share any more queries