In C++, I apparently made my code run faster by using sqrt() instead of floor() and not defining any functions, maybe that could work for you. Also remember no new line after the last test case. By the way I didn’t use Eratosthenes sieve or segmented sieve or something, it’s possible to do this with only just for loops and if statements.