I have been taking part in coding competitions for a few months now. I still have a lot to learn, but I thought I would share with you a beginner coding template that saves me a lot of time when starting a new problem.
The template is for C++ and based on modern C++ practices.
I have carefully looked at the code that top programmers use and they all follow roughly the same pattern. Also, I am not including all kinds of predefined functions, #define or typedef statements, etc. This is a bare-bones template to get started.
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
void solve() {
int n;
cin >> n;
// Your code here
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int t;
cin >> t;
while (t--) solve();
}