templates/cp-starter-template.cpp
compilable
$cat templates/cp-starter-template
CP Starter Template
Modern competitive programming starter template with fast I/O, common aliases, and contest-ready boilerplate.
#template#boilerplate#fast-io#starter
Log in to track progress, save custom versions, and organize into collections.Log In
$cat source_code/
cpp
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define sz(x) (int)(x).size()
const ll MOD = 998244353;
const ll MOD2 = 1e9 + 7;
const int MAXN = 2e5 + 5;
void solve() {
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int t = 1;
// cin >> t;
while (t--) solve();
}28 linesutf-8
$cat explanation_notes.md
notes_viewer --renderedmarkdown (math enabled)
CP Starter Template
Paste at the top of every solution to skip boilerplate.
What's Included
ios_base::sync_with_stdio(false) + cin.tie(nullptr) for ~2x faster inputll for long long, pii for pair, vi/vll for vectorsall(x) / rall(x) for range iterators, pb for push_back, sz(x) for safe size castMAXN for array sizingNotes
cout.tie(nullptr) is optional — only helps if mixing cout and cin heavilyMAXN is set to by default — adjust per problemint main() to call solve() in a loop for multi-test — add that as needed