Advertisement
zipdang04

snippet

Oct 13th, 2020 (edited)
384
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JSON 6.33 KB | None | 0 0
  1. {
  2.     // Place your global snippets here. Each snippet is defined under a snippet name and has a scope, prefix, body and
  3.     // description. Add comma separated ids of the languages where the snippet is applicable in the scope field. If scope
  4.     // is left empty or omitted, the snippet gets applied to all languages. The prefix is what is
  5.     // used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
  6.     // $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders.
  7.     // Placeholders with the same ids are connected.
  8.     // Example:
  9.     // "Print to console": {
  10.     //  "scope": "javascript,typescript",
  11.     //  "prefix": "log",
  12.     //  "body": [
  13.     //      "console.log('$1');",
  14.     //      "$2"
  15.     //  ],
  16.     //  "description": "Log output to console"
  17.     // }
  18.     "MahTemp": {
  19.         "prefix": "mahTemp",
  20.         "scope": "cpp",
  21.         "body": [
  22.             // "#pragma GCC optimize(\"Ofast\")",
  23.             // "#pragma GCC target(\"avx,avx2,fma\")",
  24.             "#include <bits/stdc++.h>",
  25.             "using namespace std;",
  26.             "/*",
  27.             "#include <ext/pb_ds/assoc_container.hpp>",
  28.             "#include <ext/pb_ds/tree_policy.hpp>",
  29.             "using namespace __gnu_pbds;",
  30.             "typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;",
  31.             "*/",
  32.             "",
  33.             "typedef long long ll;",
  34.             "typedef long double ld;",
  35.             "typedef pair<int, int> pii;",
  36.             "typedef pair<ll, ll> pll;",
  37.  
  38.             "template <class T> using PQMax = priority_queue<T>;"
  39.             "template <class T> using PQMin = priority_queue<T, vector<T>, greater<T>>;"
  40.             "template <class T1, class T2>",
  41.             "void maximize(T1 &a, T2 b){",
  42.             "\tif (b > a) a = b;",
  43.             "}",
  44.             "template <class T1, class T2>",
  45.             "void minimize(T1 &a, T2 b){",
  46.             "\tif (b < a) a = b;",
  47.             "}",
  48.             "template <class T>",
  49.             "void read(T &number)",
  50.             "{",
  51.             "\tbool negative = false;",
  52.             "\tregister int c;",
  53.             "\tnumber = 0;",
  54.             "\tc = getchar();",
  55.             "\twhile (c != '-' && !isalnum(c)) c = getchar();",
  56.             "\tif (c=='-'){",
  57.             "\t\tnegative = true;",
  58.             "\t\tc = getchar();",
  59.             "\t}",
  60.             "\tfor (; (c>47 && c<58); c=getchar())",
  61.             "\t\tnumber = number *10 + c - 48;",
  62.             "\tif (negative)",
  63.             "\t\tnumber *= -1;",
  64.             "}",
  65.             "template <class T, class ...Ts>",
  66.             "void read(T &a, Ts& ... args){",
  67.             "\tread(a);",
  68.             "\tread(args...);",
  69.             "}",
  70.             "",
  71.             "/*",
  72.             "struct Node",
  73.             "{",
  74.             "\tint node, len;",
  75.             "\tNode() {node = len = 0;}",
  76.             "\tNode(int node, int len) {this -> node = node, this -> len = len;}",
  77.             "};",
  78.             "typedef vector<Node> vg;",
  79.             "*/",
  80.             "",
  81.             "#define MAX ${1:1000001}",
  82.             "#define MOD ${2:1000000007}",
  83.             "",
  84.             "#define fi first",
  85.             "#define se second",
  86.             "",
  87.             "#define FOR(type, i, a, b) for(type i = (a); i <= (b); i++)",
  88.             "#define FORD(type, i, b, a) for(type i = (b); i >= (a); i--)",
  89.             "",
  90.             "#define testBit(n, bit) (((n) >> (bit)) & 1)",
  91.             "#define flipBit(n, bit) ((n) ^ (1ll << (bit)))",
  92.             "#define cntBit(n) __builtin_popcount(n)",
  93.             "#define cntBitll(n) __builtin_popcountll(n)",
  94.             "#define randomize mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());",
  95.             "",
  96.             "main()",
  97.             "{\n\tios_base::sync_with_stdio(0); cin.tie(0);\n\t$0\n}"
  98.         ],
  99.         "description": "the Damn template"
  100.     },
  101.     "MahFreopen": {
  102.         "prefix": "mahFreopen",
  103.         "scope": "cpp",
  104.         "body": [
  105.             "#ifndef HIEU",
  106.             "freopen(\"${1:name}.inp\", \"r\", stdin);",
  107.             "freopen(\"${1:name}.out\", \"w\", stdout);",
  108.             "#endif"
  109.         ],
  110.         "description": "the Damn template"
  111.     },
  112.     "For": {
  113.         "prefix": "forEach",
  114.         "scope": "cpp",
  115.         "body": [
  116.             "for (${1:size_t} ${2:i}: ${3:array}){",
  117.             "\t$0",
  118.             "}"
  119.         ],
  120.         "description": "the Damn template"
  121.     },
  122.     "Data": {
  123.         "prefix": "stData",
  124.         "scope": "cpp",
  125.         "body": [
  126.             "struct ${1:name}",
  127.             "{",
  128.             "\tint ${2:first}, ${3:second};",
  129.             "\t${1:name}() {${2:first} = ${3:second} = 0;}",
  130.             "\t${1:name}(int ${2:first}, int ${3:second}) {this -> ${2:first} = ${2:first}, this -> ${3:second} = ${3:second};}",
  131.             "};"
  132.         ],
  133.         "description": "temp for Data struct"
  134.     },
  135.     "CreateGraph":{
  136.         "prefix": "createGraph",
  137.         "scope": "cpp",
  138.         "body": [
  139.             "for (int i = 0; i < m; i++)",
  140.             "{",
  141.             "\tint u, v; cin >> u >> v;",
  142.             "\tgraph[u].push_back(v);",
  143.             "\tgraph[v].push_back(u);",
  144.             "}",
  145.         ]
  146.     },
  147.     "CreateGraphWeighted":{
  148.         "prefix": "createGraphWeighted",
  149.         "scope": "cpp",
  150.         "body": [
  151.             "for (int i = 0; i < m; i++)",
  152.             "{",
  153.             "\tint u, v, w; cin >> u >> v >> w;",
  154.             "\tgraph[u].push_back(Node(v, w));",
  155.             "\tgraph[v].push_back(Node(u, w));",
  156.             "}",
  157.         ]
  158.     },
  159.     "Exponentiation":{
  160.         "prefix": "expo",
  161.         "scope": "cpp",
  162.         "body": [
  163.             "ll power(ll a, ll n){",
  164.             "\tif (n == 0) return 1;",
  165.             "\tll ans = power(a, n >> 1);",
  166.             "\tans *= ans, ans %= MOD;",
  167.             "\tif (n & 1) return (ans * a) % MOD;",
  168.             "\treturn ans;",
  169.             "}",
  170.         ]
  171.     },
  172.     "ExponentiationMod":{
  173.         "prefix": "expoMod",
  174.         "scope": "cpp",
  175.         "body": [
  176.             "ll power(ll a, ll n, ll mod){",
  177.             "\tif (n == 0) return 1;",
  178.             "\tll ans = power(a, n >> 1, mod);",
  179.             "\tans *= ans, ans %= mod;",
  180.             "\tif (n & 1) return (ans * a) % mod;",
  181.             "\treturn ans;",
  182.             "}",
  183.         ]
  184.     },
  185.     "Math":{
  186.         "prefix": "math",
  187.         "scope": "cpp",
  188.         "body": [
  189.             "class Math{",
  190.             "\tprivate:",
  191.             "\t\tll fact[MAX + 1] = {};",
  192.             "\t\tll ifac[MAX + 1] = {};",
  193.             "\tpublic:",
  194.             "\t\tMath(){",
  195.             "\t\t\tfact[0] = 1;",
  196.             "\t\t\tFOR(ll, i, 1, MAX)",
  197.             "\t\t\t\tfact[i] = (fact[i - 1] * i) % MOD;",
  198.             "\t\t\tifac[MAX] = power(fact[MAX], MOD - 2);",
  199.             "\t\t\tFORD(ll, i, MAX - 1, 0)",
  200.             "\t\t\t\tifac[i] = (ifac[i + 1] * (i + 1)) % MOD;",
  201.             "\t\t}",
  202.             "",
  203.             "\t\tll power(ll a, ll n){",
  204.             "\t\t\tif (n == 0) return 1;",
  205.             "\t\t\tll ans = power(a, n >> 1);",
  206.             "\t\t\tans *= ans, ans %= MOD;",
  207.             "\t\t\tif (n & 1) return (ans * a) % MOD;",
  208.             "\t\t\treturn ans;",
  209.             "\t\t}",
  210.             "",
  211.             "\t\tll C(ll n, ll k){",
  212.             "\t\t\treturn (((fact[n] * ifac[k]) % MOD) * ifac[n - k]) % MOD;",
  213.             "\t\t}",
  214.             "\t\t",
  215.             "\t\tll P(ll n, ll k){",
  216.             "\t\t\treturn (fact[n] * ifac[n - k]) % MOD;",
  217.             "\t\t}",
  218.             "\t\t",
  219.             "\t\tll factorial(ll n){",
  220.             "\t\t\treturn fact[n];",
  221.             "\t\t}",
  222.             "};",
  223.         ]
  224.     },
  225.     "NewSection":{
  226.         "prefix": "newSect",
  227.         "scope": "cpp",
  228.         "body": [
  229.             "//${1:section}",
  230.             "$0",
  231.             "//========================="
  232.         ]
  233.     }
  234. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement