So many people want to make a template that including everything needed to code faster during rounds. But if your templates are too long, it will take some time to scroll down. So here's a solution (asides from `#pragma region`): `#include __FILE__`.↵
↵
Combine it with `#ifdef` and other defines, it can move codes to the top section. Here's an example:↵
↵
```cpp↵
#ifndef TYPE_A↵
#define TYPE_A 1↵
#include __FILE__↵
int main()↵
{↵
lint a=0;↵
}↵
#elif TYPE_A == 1↵
using lint=long long;↵
#endif↵
```↵
↵
You can see it just move the `lint` declaration to the top. But your clangd might give you an error. To bypass this, you need to add a `using` before the `#include`. It can be `using namespace ...`, or `using lint = int64_t`. But I suggest you to write like this:↵
↵
```cpp↵
#ifndef TYPE_A↵
#define TYPE_A 1↵
#include <bits/stdc++.h>↵
using namespace std;↵
#include __FILE__↵
int main()↵
{↵
lint a=0;↵
}↵
#elif TYPE_A == 1↵
using lint=long long;↵
#endif↵
```↵
↵
Now there will be no warnings or errors anymore. Also if you decided to move `bits/stdc++.h` down below, your clangd will be super slow.↵
↵
Also you can `#include __FILE__` multiple times, just `#undef TYPE_A` the redefine it. But that will make your template a terrible chaos. Use at your own risk.↵
↵
I've been using this technique on several OJs, they can all accept such codes.↵
↵
Note that even if clangd gives you an error, g++ can still compile this.
↵
Combine it with `#ifdef` and other defines, it can move codes to the top section. Here's an example:↵
↵
```cpp↵
#ifndef TYPE_A↵
#define TYPE_A 1↵
#include __FILE__↵
int main()↵
{↵
lint a=0;↵
}↵
#elif TYPE_A == 1↵
using lint=long long;↵
#endif↵
```↵
↵
You can see it just move the `lint` declaration to the top. But your clangd might give you an error. To bypass this, you need to add a `using` before the `#include`. It can be `using namespace ...`, or `using lint = int64_t`. But I suggest you to write like this:↵
↵
```cpp↵
#ifndef TYPE_A↵
#define TYPE_A 1↵
#include <bits/stdc++.h>↵
using namespace std;↵
#include __FILE__↵
int main()↵
{↵
lint a=0;↵
}↵
#elif TYPE_A == 1↵
using lint=long long;↵
#endif↵
```↵
↵
Now there will be no warnings or errors anymore. Also if you decided to move `bits/stdc++.h` down below, your clangd will be super slow.↵
↵
Also you can `#include __FILE__` multiple times, just `#undef TYPE_A` the redefine it. But that will make your template a terrible chaos. Use at your own risk.↵
↵
I've been using this technique on several OJs, they can all accept such codes.↵
↵
Note that even if clangd gives you an error, g++ can still compile this.




