What are the huge lines of code added before the main code

I am new to coding, so apologies if this sounds silly and stupid. Recently I was looking at some codes submitted by top coders at Google CodeJam and I noticed, nearly everyone includes LONG strings of code before the main code (lots #include and template) even if they don’t use it in the code. I understand they do this to make things easier, but I’d like to know what this practice is called and how can I create my own. Any places where I can learn about it?

I don’t think that there’s something special about it. Many of your own codechef submissions started with the following two lines:

#include <iostream>
using namespace std;

Do you open an empty text editor and spend time typing these lines manually whenever solving a competitive programming problem? Or do you just copy/paste some code template, which already contains these lines?

It makes sense to prepare a code template with the necessary includes, some frequently used defines, the main function with fast i/o activation and maybe a few other things. Experienced people keep adding more things to their code templates whenever they notice that something can be reused in the future, so their templates grow big. The unnecessary parts of the code template don’t do any harm. And spending time on code cleanup to remove these unnecessary parts from your template is unreasonable during a contest.

1 Like

So as i learn more and more about coding, I’ll slowly start building my own template overtime