Last active
July 23, 2025 23:47
-
-
Save ShardulJunagade/e29fef9140932637a08a02a28f415150 to your computer and use it in GitHub Desktop.
C++ Snippets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| // Place your snippets for cpp here. Each snippet is defined under a snippet name and has a prefix, body and | |
| // description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are: | |
| // $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the | |
| // same ids are connected. | |
| // Example: | |
| // "Print to console": { | |
| // "prefix": "log", | |
| // "body": [ | |
| // "console.log('$1');", | |
| // "$2" | |
| // ], | |
| // "description": "Log output to console" | |
| // } | |
| "C++ Base Code": { | |
| "prefix": "cpp", | |
| "body": [ | |
| "#include<bits/stdc++.h>", | |
| "using namespace std;", | |
| "", | |
| "int main() {", | |
| " ", | |
| " return 0;", | |
| "}" | |
| ], | |
| "description": "cpp base code" | |
| }, | |
| "C Base Code": { | |
| "prefix": "cbase", | |
| "body": [ | |
| "#include <stdio.h>", | |
| "#include <stdlib.h>", | |
| "#include<bits/stdc++.h>", | |
| "using namespace std;", | |
| "", | |
| "int main() {", | |
| " ", | |
| " return 0;", | |
| "}" | |
| ], | |
| "description": "c base code" | |
| }, | |
| "DSA Template": { | |
| "prefix": "dsatemplate", | |
| "body": [ | |
| "// Author: Shardul Junagade", | |
| "// Created: ${CURRENT_DATE}-${CURRENT_MONTH}-${CURRENT_YEAR}", | |
| "", | |
| "#include <bits/stdc++.h>", | |
| "using namespace std;", | |
| "", | |
| "int main() {", | |
| " int t;", | |
| " cin >> t;", | |
| " while (t--) {", | |
| " int n;", | |
| " cin >> n;", | |
| " ", | |
| " ", | |
| " }", | |
| " ", | |
| " return 0;", | |
| "}" | |
| ], | |
| "description": "C++ template for DSA with common macros and functions" | |
| }, | |
| "Master CP Template": { | |
| "prefix": "mastercptemplate", | |
| "body": [ | |
| "// Author: Shardul Junagade", | |
| "// Created: ${CURRENT_DATE}-${CURRENT_MONTH}-${CURRENT_YEAR}", | |
| "", | |
| "#include <bits/stdc++.h>", | |
| "using namespace std;", | |
| "", | |
| "#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);", | |
| "#define endl '\\n'", | |
| "#define ll long long", | |
| "#define ull unsigned long long", | |
| "#define vi vector<int>", | |
| "#define vll vector<long long>", | |
| "#define pii pair<int, int>", | |
| "#define pb push_back", | |
| "#define mp make_pair", | |
| "#define all(v) v.begin(), v.end()", | |
| "#define F first", | |
| "#define S second", | |
| "#define loop(i, a, b) for (int i=a; i<b; i++)", | |
| "#define loopr(i, a, b) for (int i=a; i>=b; i--)", | |
| "#define gcd(a, b) __gcd(a, b)", | |
| "#define lcm(a, b) ((a) * ((b) / gcd(a, b)))", | |
| "const int INF = 1e9;", | |
| "const ll LINF = 1e18;", | |
| "const int MOD = 1e9 + 7;", | |
| "void printVector(const vector<int>& arr) {", | |
| " for (int i=0; i<arr.size(); i++) cout << arr[i] << \" \";", | |
| " cout << endl;", | |
| "}", | |
| "// Modular arithmetic", | |
| "ll modAdd(ll a, ll b, ll m = MOD) { return ((a % m + b % m) % m + m) % m; }", | |
| "ll modSub(ll a, ll b, ll m = MOD) { return ((a % m - b % m) % m + m) % m; }", | |
| "ll modMul(ll a, ll b, ll m = MOD) { return ((a % m) * (b % m)) % m; }", | |
| "ll modPow(ll a, ll b, ll m = MOD) {", | |
| " ll res = 1;", | |
| " a %= m;", | |
| " while (b > 0) {", | |
| " if (b & 1) res = modMul(res, a, m);", | |
| " a = modMul(a, a, m);", | |
| " b >>= 1;", | |
| " }", | |
| " return res;", | |
| "}", | |
| "", | |
| "", | |
| "", | |
| "int main() {", | |
| " fastIO;", | |
| " // Uncomment the following line to enable debugging", | |
| " // #define DEBUG", | |
| " #ifdef DEBUG", | |
| " freopen(\"input.txt\", \"r\", stdin);", | |
| " freopen(\"output.txt\", \"w\", stdout);", | |
| " #endif", | |
| "", | |
| " int t;", | |
| " cin >> t;", | |
| " while (t--) {", | |
| " ", | |
| " ", | |
| " }", | |
| " ", | |
| " return 0;", | |
| "}" | |
| ], | |
| "description": "Master C++ competitive programming template with advanced macros and modular arithmetic functions" | |
| }, | |
| "CP Template":{ | |
| "prefix": "cptemplate", | |
| "body": [ | |
| "// Author: Shardul Junagade", | |
| "// Created: ${CURRENT_DATE}-${CURRENT_MONTH}-${CURRENT_YEAR}", | |
| "", | |
| "#include <bits/stdc++.h>", | |
| "using namespace std;", | |
| "", | |
| "#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);", | |
| "#define endl '\\n'", | |
| "#define ll long long", | |
| "#define vi vector<int>", | |
| "#define vll vector<long long>", | |
| "#define pii pair<int, int>", | |
| "#define all(v) v.begin(), v.end()", | |
| "#define loop(i, a, b) for (int i=a; i<b; i++)", | |
| "#define loopr(i, a, b) for (int i=a; i>=b; i--)", | |
| "#define gcd(a, b) __gcd(a, b)", | |
| "#define lcm(a, b) ((a) * ((b) / gcd(a, b)))", | |
| "const int INF = 1e9;", | |
| "const ll LINF = 1e18;", | |
| "const int MOD = 1e9 + 7;", | |
| "void printVector(const vector<int>& arr) {", | |
| " for (int i=0; i<arr.size(); i++) cout << arr[i] << \" \";", | |
| " cout << endl;", | |
| "}", | |
| "", | |
| "", | |
| "", | |
| "int main() {", | |
| " fastIO;", | |
| " // Uncomment the following line to enable debugging", | |
| " // #define DEBUG", | |
| " #ifdef DEBUG", | |
| " freopen(\"input.txt\", \"r\", stdin);", | |
| " freopen(\"output.txt\", \"w\", stdout);", | |
| " #endif", | |
| "", | |
| " int t;", | |
| " cin >> t;", | |
| " while (t--) {", | |
| " ", | |
| " ", | |
| " }", | |
| " ", | |
| " return 0;", | |
| "}" | |
| ], | |
| "description": "Advanced C++ template with common competitive programming macros and functions" | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment