Templates of C++ users.

Could anyone please tell me some of their c++ program templates that you use and found useful in short contests.
I used to code in java, But recently I have decided to code in C++.I love C++ now, But I need to find some good templates for C++ …I would be highly thankful…!!

1 Like

include <bits/stdc++.h>

define lli long long int

define pb push_back

define mp make_pair

define cases lli testcases;cin>>testcases; while(testcases–)

using namespace std;

int main()

return 0;


my template

Hope this helps

Hi @smartcool take a look at this repository https://github.com/mohitkyadav/Amazing-STL-Algoritms
They are not templates but that’s my cheat sheet of the algorithm header since you are new to C++ this might help you learn about the standard library algorithms.


Instead of asking here go and see submissions of some top-coders and copy macros of them.