TLE problem with O(1) time complexity solution

This is my solution -

[1] for the problem [TR][2] of contest Encoding Feb'19
the solution is giving  TLE verdict for O(1) complexity and O(T) total complexity.
can anyone tell me the reason?
Thank you!


The range of test cases is from 1 to 10^9! It’s almost impossible to scan that much and give output in 1 second.

But in this case you just have use fast i/o to take the input. This worked in my case.

what is faster than scanf and prinf in c, c++?

You could use this simple fast i/o template using cin and cout. See my code for an example

freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);