#include - Compile Time

Is it good to use bits/stdc++.h header file in Codechef or any other competitive platforms? Because according to this link, the first answer says it increases compilation time. In general, I want to know some advantages of using this header, though I know it includes all precompiled headers.

Yes! You can use it anywhere. There is no restriction of this header file at any platform of online judge. Since it only increase the compilation time as it first copy or link all the header files in a single phase and then executes your program.

But I am assure that it doesn’t interfere the time complexity of the whole program. So you can use it without any worry.

it includes all precompiled headers.

Yes, that’s the most important reason why its used. It saves writing lots of unnecessary “includes”. Meaning, writing code is less time consuming.

In other words, this saves time. Especially now when codechef is giving laddus to the person who solves the problem “First” now. Imagine, will you spend ~30sec-1min writing only includes for header files when you want to save time and submit code asap? (Many other online contest sites such as hackerrank.com break tie by submit time. “Whoever submits first will be given a better rank”. So submitting first and quickly assumes a important role in competitive coding. )

Just look at this. A lot of unnecessary files, yes. But still, after including bits/stdc++ header file, one can relax and use any algo/function etc. without worrying about “Did I include that header file” etc.

Also, I think this quora question will answer any other query you have.

(Not to mention those nerve-eating “Program terminated” errors you get when you misspell a header file.)

The sole advantage of this is it includes all precompiled headers that you have already mentioned.

It does increase the compile time but execution time is more or less the same. So it’s convinient to use it.

It increases the compilation time, but the increased time is independent of input or output data in other words it’s constant and negligible. No matter how big your input is, the increased time will be the same as it’s on small input data.

1 Like

You would never encounter a TLE just because you are using the #include<bits/stdc++.h>. If you get a TLE, it HAS to be because other parts of your code are not efficient enough OR the time constraints set in the online judge is too tight, in which case, it’s not really your fault. So, leaving performance aside,(because it doesn’t have a noticeable performance hit), it is advantageous to use it because it saves you from having to type out all the libraries you want to include in your code (assuming you don’t already have a template that you use all the time, in which case you are just making your code look concise and neat). So , TLDR: just use it, you won’t have any disadvantages.

2 Likes

It increase the compilation time of your program by adding unnecessary header files.It is a good to minimise this include. Actually includes this also include a lot of files, which your program may not need, thus it increase both compile time and program size unnecessarily.
Butfor competition point of view it is good to use this header file because it save a lot of time while coding and mostly effect compilation time not execution time. I think the answer might be clear.

1 Like
//