Last active
October 7, 2024 10:35
-
-
Save JayantGoel001/e8c455723851a108f9ccaffae7626590 to your computer and use it in GitHub Desktop.
Basic Syntax & Snippet of C++ for Competitive Programming for VS Code.
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
Show hidden characters
{ | |
"Basic Syntax for C++": { | |
"scope": "cpp", | |
"prefix": "cpp", | |
"body": [ | |
"#include<bits/stdc++.h>", | |
"using namespace std;", | |
"", | |
"#define int long long int", | |
"#define double long double", | |
"#define INF 1e18", | |
"", | |
"#define f first", | |
"#define s second", | |
"#define pb push_back", | |
"#define endl \"\\n\"", | |
"", | |
"#define pii pair <int,int>", | |
"", | |
"#define vi vector <int>", | |
"#define vpi vector <pii>", | |
"", | |
"#define si set <int>", | |
"#define spi set <pii>", | |
"", | |
"#define umpi unordered_map <int,int>", | |
"#define mpi map <int,int>", | |
"#define mpp map <pii, int>", | |
"", | |
"#define pq_max priority_queue <int>", | |
"#define pq_min priority_queue <int, vi, greater <int>>", | |
"", | |
"#define print(v) for(auto x : v) cout << x << \" \"; cout << endl", | |
"#define print_pair(v) for(auto x : v) cout << x.f << \" \" << x.s << endl", | |
"#define print_range(v,x,y) for(int i = x; i < y; i++) cout<< v[i]<< \" \"; cout << endl" | |
"", | |
"#define yn(x) cout << (x ? \"YES\" :\"NO\") << endl", | |
"", | |
"#define bug(...) __f (#__VA_ARGS__, __VA_ARGS__)", | |
"", | |
"#define all(v) v.begin(), v.end()", | |
"", | |
"template <typename Arg1>", | |
"void __f (const char* name, Arg1&& arg1) { " | |
" cout << name << \" : \" << arg1 << endl;" | |
"}", | |
"template <typename Arg1, typename... Args>", | |
"void __f (const char* names, Arg1&& arg1, Args&&... args) {", | |
" const char* comma = strchr (names + 1, ',');", | |
" cout.write (names, comma - names) << \" : \" << arg1 << \" | \"; __f (comma + 1, args...);", | |
"}", | |
"" | |
"const int N = 200005;", | |
"const int MOD = 1000000000 + 7;", | |
"", | |
"int GCD(int a, int b) {" | |
" return b == 0 ? a : GCD(b, a % b);", | |
"}", | |
"", | |
"int power(int x, int y) {", | |
" return y ? ((y % 2 ? x : 1ll) * power((x * x) % MOD, y / 2) % MOD) % MOD : 1ll;" | |
"}", | |
"", | |
"void initialize() {", | |
" ", | |
"}", | |
"", | |
"void solve() {" | |
" $0", | |
"}" | |
"", | |
"int32_t main(){", | |
"", | |
" ios_base::sync_with_stdio(false);", | |
" cin.tie(nullptr);", | |
" cout.tie(nullptr);", | |
"", | |
" #ifndef ONLINE_JUDGE", | |
" freopen(\"input.txt\", \"r\", stdin);", | |
" freopen(\"output.txt\", \"w\", stdout);", | |
" #endif", | |
"", | |
" clock_t startTime = clock();", | |
"", | |
" int t = 1;", | |
" cin >> t;", | |
"", | |
" initialize();" | |
"", | |
" while(t--){", | |
" solve();", | |
" }" | |
"", | |
" cerr << \"Run Time: \" << (double)(clock() - startTime) / CLOCKS_PER_SEC;", | |
"}" | |
], | |
"description": "Basic Syntax of C++ for Competitive Programming." | |
} | |
} |
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
#include<bits/stdc++.h> | |
using namespace std; | |
#define int long long int | |
#define double long double | |
#define INF 1e18 | |
#define f first | |
#define s second | |
#define pb push_back | |
#define endl "\n" | |
#define pii pair <int,int> | |
#define vi vector <int> | |
#define vpi vector <pii> | |
#define si set <int> | |
#define spi set <pii> | |
#define umpi unordered_map <int,int> | |
#define mpi map <int,int> | |
#define mpp map <pii, int> | |
#define pq_max priority_queue <int> | |
#define pq_min priority_queue <int, vi, greater <int>> | |
#define print(v) for(auto x : v) cout << x << " "; cout << endl | |
#define print_pair(v) for(auto x : v) cout << x.f << " " << x.s << endl | |
#define print_range(v,x,y) for(int i = x; i < y; i++) cout<< v[i]<< " "; cout << endl | |
#define yn(x) cout << (x ? "YES" :"NO") << endl | |
#define bug(...) __f (#__VA_ARGS__, __VA_ARGS__) | |
#define all(v) v.begin(), v.end() | |
template <typename Arg1> | |
void __f (const char* name, Arg1&& arg1) { | |
cout << name << " : " << arg1 << endl; | |
} | |
template <typename Arg1, typename... Args> | |
void __f (const char* names, Arg1&& arg1, Args&&... args) { | |
const char* comma = strchr (names + 1, ','); | |
cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...); | |
} | |
const int N = 200005; | |
const int MOD = 1000000000 + 7; | |
int GCD(int a, int b) { | |
return b == 0 ? a : GCD(b, a % b); | |
} | |
int power(int x, int y) { | |
return y ? ((y % 2 ? x : 1ll) * power((x * x) % MOD, y / 2) % MOD) % MOD : 1ll; | |
} | |
void initialize() { | |
} | |
void solve() { | |
} | |
int32_t main(){ | |
ios_base::sync_with_stdio(false); | |
cin.tie(nullptr); | |
cout.tie(nullptr); | |
#ifndef ONLINE_JUDGE | |
freopen("input.txt", "r", stdin); | |
freopen("output.txt", "w", stdout); | |
#endif | |
clock_t startTime = clock(); | |
int t = 1; | |
cin >> t; | |
initialize(); | |
while(t--){ | |
solve(); | |
} | |
cerr << "Run Time: " << (double)(clock() - startTime) / CLOCKS_PER_SEC; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment