Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- // Place your global snippets here. Each snippet is defined under a snippet name and has a scope, prefix, body and
- // description. Add comma separated ids of the languages where the snippet is applicable in the scope field. If scope
- // is left empty or omitted, the snippet gets applied to all languages. 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": {
- // "scope": "javascript,typescript",
- // "prefix": "log",
- // "body": [
- // "console.log('$1');",
- // "$2"
- // ],
- // "description": "Log output to console"
- // }
- "MahTemp": {
- "prefix": "mahTemp",
- "scope": "cpp",
- "body": [
- // "#pragma GCC optimize(\"Ofast\")",
- // "#pragma GCC target(\"avx,avx2,fma\")",
- "#include <bits/stdc++.h>",
- "using namespace std;",
- "/*",
- "#include <ext/pb_ds/assoc_container.hpp>",
- "#include <ext/pb_ds/tree_policy.hpp>",
- "using namespace __gnu_pbds;",
- "typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;",
- "*/",
- "",
- "typedef long long ll;",
- "typedef long double ld;",
- "typedef pair<int, int> pii;",
- "typedef pair<ll, ll> pll;",
- "template <class T> using PQMax = priority_queue<T>;"
- "template <class T> using PQMin = priority_queue<T, vector<T>, greater<T>>;"
- "template <class T1, class T2>",
- "void maximize(T1 &a, T2 b){",
- "\tif (b > a) a = b;",
- "}",
- "template <class T1, class T2>",
- "void minimize(T1 &a, T2 b){",
- "\tif (b < a) a = b;",
- "}",
- "template <class T>",
- "void read(T &number)",
- "{",
- "\tbool negative = false;",
- "\tregister int c;",
- "\tnumber = 0;",
- "\tc = getchar();",
- "\twhile (c != '-' && !isalnum(c)) c = getchar();",
- "\tif (c=='-'){",
- "\t\tnegative = true;",
- "\t\tc = getchar();",
- "\t}",
- "\tfor (; (c>47 && c<58); c=getchar())",
- "\t\tnumber = number *10 + c - 48;",
- "\tif (negative)",
- "\t\tnumber *= -1;",
- "}",
- "template <class T, class ...Ts>",
- "void read(T &a, Ts& ... args){",
- "\tread(a);",
- "\tread(args...);",
- "}",
- "",
- "/*",
- "struct Node",
- "{",
- "\tint node, len;",
- "\tNode() {node = len = 0;}",
- "\tNode(int node, int len) {this -> node = node, this -> len = len;}",
- "};",
- "typedef vector<Node> vg;",
- "*/",
- "",
- "#define MAX ${1:1000001}",
- "#define MOD ${2:1000000007}",
- "",
- "#define fi first",
- "#define se second",
- "",
- "#define FOR(type, i, a, b) for(type i = (a); i <= (b); i++)",
- "#define FORD(type, i, b, a) for(type i = (b); i >= (a); i--)",
- "",
- "#define testBit(n, bit) (((n) >> (bit)) & 1)",
- "#define flipBit(n, bit) ((n) ^ (1ll << (bit)))",
- "#define cntBit(n) __builtin_popcount(n)",
- "#define cntBitll(n) __builtin_popcountll(n)",
- "#define randomize mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());",
- "",
- "main()",
- "{\n\tios_base::sync_with_stdio(0); cin.tie(0);\n\t$0\n}"
- ],
- "description": "the Damn template"
- },
- "MahFreopen": {
- "prefix": "mahFreopen",
- "scope": "cpp",
- "body": [
- "#ifndef HIEU",
- "freopen(\"${1:name}.inp\", \"r\", stdin);",
- "freopen(\"${1:name}.out\", \"w\", stdout);",
- "#endif"
- ],
- "description": "the Damn template"
- },
- "For": {
- "prefix": "forEach",
- "scope": "cpp",
- "body": [
- "for (${1:size_t} ${2:i}: ${3:array}){",
- "\t$0",
- "}"
- ],
- "description": "the Damn template"
- },
- "Data": {
- "prefix": "stData",
- "scope": "cpp",
- "body": [
- "struct ${1:name}",
- "{",
- "\tint ${2:first}, ${3:second};",
- "\t${1:name}() {${2:first} = ${3:second} = 0;}",
- "\t${1:name}(int ${2:first}, int ${3:second}) {this -> ${2:first} = ${2:first}, this -> ${3:second} = ${3:second};}",
- "};"
- ],
- "description": "temp for Data struct"
- },
- "CreateGraph":{
- "prefix": "createGraph",
- "scope": "cpp",
- "body": [
- "for (int i = 0; i < m; i++)",
- "{",
- "\tint u, v; cin >> u >> v;",
- "\tgraph[u].push_back(v);",
- "\tgraph[v].push_back(u);",
- "}",
- ]
- },
- "CreateGraphWeighted":{
- "prefix": "createGraphWeighted",
- "scope": "cpp",
- "body": [
- "for (int i = 0; i < m; i++)",
- "{",
- "\tint u, v, w; cin >> u >> v >> w;",
- "\tgraph[u].push_back(Node(v, w));",
- "\tgraph[v].push_back(Node(u, w));",
- "}",
- ]
- },
- "Exponentiation":{
- "prefix": "expo",
- "scope": "cpp",
- "body": [
- "ll power(ll a, ll n){",
- "\tif (n == 0) return 1;",
- "\tll ans = power(a, n >> 1);",
- "\tans *= ans, ans %= MOD;",
- "\tif (n & 1) return (ans * a) % MOD;",
- "\treturn ans;",
- "}",
- ]
- },
- "ExponentiationMod":{
- "prefix": "expoMod",
- "scope": "cpp",
- "body": [
- "ll power(ll a, ll n, ll mod){",
- "\tif (n == 0) return 1;",
- "\tll ans = power(a, n >> 1, mod);",
- "\tans *= ans, ans %= mod;",
- "\tif (n & 1) return (ans * a) % mod;",
- "\treturn ans;",
- "}",
- ]
- },
- "Math":{
- "prefix": "math",
- "scope": "cpp",
- "body": [
- "class Math{",
- "\tprivate:",
- "\t\tll fact[MAX + 1] = {};",
- "\t\tll ifac[MAX + 1] = {};",
- "\tpublic:",
- "\t\tMath(){",
- "\t\t\tfact[0] = 1;",
- "\t\t\tFOR(ll, i, 1, MAX)",
- "\t\t\t\tfact[i] = (fact[i - 1] * i) % MOD;",
- "\t\t\tifac[MAX] = power(fact[MAX], MOD - 2);",
- "\t\t\tFORD(ll, i, MAX - 1, 0)",
- "\t\t\t\tifac[i] = (ifac[i + 1] * (i + 1)) % MOD;",
- "\t\t}",
- "",
- "\t\tll power(ll a, ll n){",
- "\t\t\tif (n == 0) return 1;",
- "\t\t\tll ans = power(a, n >> 1);",
- "\t\t\tans *= ans, ans %= MOD;",
- "\t\t\tif (n & 1) return (ans * a) % MOD;",
- "\t\t\treturn ans;",
- "\t\t}",
- "",
- "\t\tll C(ll n, ll k){",
- "\t\t\treturn (((fact[n] * ifac[k]) % MOD) * ifac[n - k]) % MOD;",
- "\t\t}",
- "\t\t",
- "\t\tll P(ll n, ll k){",
- "\t\t\treturn (fact[n] * ifac[n - k]) % MOD;",
- "\t\t}",
- "\t\t",
- "\t\tll factorial(ll n){",
- "\t\t\treturn fact[n];",
- "\t\t}",
- "};",
- ]
- },
- "NewSection":{
- "prefix": "newSect",
- "scope": "cpp",
- "body": [
- "//${1:section}",
- "$0",
- "//========================="
- ]
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement