Advertisement
Aqib12

Untitled

Nov 29th, 2020
493
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JSON 5.43 KB | None | 0 0
  1. {
  2.     "boilerplate cpp template": {
  3.         "prefix": "startER",
  4.         "body": [
  5.             "#include <bits/stdc++.h>",
  6.             "",
  7.             "using namespace std;",
  8.             "",
  9.             "int main() {",
  10.             "  ios_base::sync_with_stdio(false);",
  11.             "  cin.tie(nullptr);",
  12.             "  $0",
  13.             "  return 0;",
  14.             "}"
  15.         ],
  16.         "description": "boilerplate cpp template"
  17.     },
  18.     "boilerplate code for test case": {
  19.         "prefix": "startWithTestCase",
  20.         "body": [
  21.             "#include <bits/stdc++.h>",
  22.             "",
  23.             "using namespace std;",
  24.             "",
  25.             "void solve() {",
  26.             "  $0",
  27.             "}",
  28.             "",
  29.             "int main() {",
  30.             "  ios_base::sync_with_stdio(false);",
  31.             "  cin.tie(nullptr);",
  32.             "  int t;",
  33.             "  cin >> t;",
  34.             "  while (t--) {",
  35.             "    solve();",
  36.             "  }",
  37.             "  return 0;",
  38.             "}",
  39.             ""
  40.         ],
  41.         "description": "boilerplate code for test case"
  42.     },
  43.     "debugging in runtime": {
  44.         "prefix": "code_debug",
  45.         "body": [
  46.             "template <typename A, typename B>",
  47.             "string to_string(pair<A, B> p);",
  48.             "",
  49.             "template <typename A, typename B, typename C>",
  50.             "string to_string(tuple<A, B, C> p);",
  51.             "",
  52.             "template <typename A, typename B, typename C, typename D>",
  53.             "string to_string(tuple<A, B, C, D> p);",
  54.             "",
  55.             "string to_string(const string& s) { return '\"' + s + '\"'; }",
  56.             "",
  57.             "string to_string(char c) { return string(1, c); }",
  58.             "",
  59.             "string to_string(const char* s) { return to_string((string)s); }",
  60.             "",
  61.             "string to_string(bool b) { return (b ? \"true\" : \"false\"); }",
  62.             "",
  63.             "string to_string(const vector<bool>& v) {",
  64.             "  bool first = true;",
  65.             "  string res = \"{\";",
  66.             "  for (auto&& i : v) {",
  67.             "    if (!first) {",
  68.             "      res += \", \";",
  69.             "    }",
  70.             "    first = false;",
  71.             "    res += to_string(i);",
  72.             "  }",
  73.             "  res += \"}\";",
  74.             "  return res;",
  75.             "}",
  76.             "",
  77.             "template <size_t N>",
  78.             "string to_string(bitset<N> v) {",
  79.             "  string res;",
  80.             "  for (size_t i = 0; i < N; i++) {",
  81.             "    res += static_cast<char>('0' + v[i]);",
  82.             "  }",
  83.             "  return res;",
  84.             "}",
  85.             "",
  86.             "template <typename A>",
  87.             "string to_string(A v) {",
  88.             "  bool first = true;",
  89.             "  string res = \"{\";",
  90.             "  for (const auto& x : v) {",
  91.             "    if (!first) {",
  92.             "      res += \", \";",
  93.             "    }",
  94.             "    first = false;",
  95.             "    res += to_string(x);",
  96.             "  }",
  97.             "  res += \"}\";",
  98.             "  return res;",
  99.             "}",
  100.             "",
  101.             "template <typename A, typename B>",
  102.             "string to_string(pair<A, B> p) {",
  103.             "  return \"(\" + to_string(p.first) + \", \" + to_string(p.second) + \")\";",
  104.             "}",
  105.             "",
  106.             "template <typename A, typename B, typename C>",
  107.             "string to_string(tuple<A, B, C> p) {",
  108.             "  return \"(\" + to_string(get<0>(p)) + \", \" + to_string(get<1>(p)) + \", \" +",
  109.             "         to_string(get<2>(p)) + \")\";",
  110.             "}",
  111.             "",
  112.             "template <typename A, typename B, typename C, typename D>",
  113.             "string to_string(tuple<A, B, C, D> p) {",
  114.             "  return \"(\" + to_string(get<0>(p)) + \", \" + to_string(get<1>(p)) + \", \" +",
  115.             "         to_string(get<2>(p)) + \", \" + to_string(get<3>(p)) + \")\";",
  116.             "}",
  117.             "",
  118.             "void debug_out() { cerr << endl; }",
  119.             "",
  120.             "template <typename Head, typename... Tail>",
  121.             "void debug_out(Head H, Tail... T) {",
  122.             "  cerr << \" \" << to_string(H);",
  123.             "  debug_out(T...);",
  124.             "}",
  125.             "",
  126.             "#ifndef LOCAL",
  127.             "#define debug(...) cerr << \"[\" << #__VA_ARGS__ << \"]:\", debug_out(__VA_ARGS__)",
  128.             "#else",
  129.             "#define debug(...) 42",
  130.             "#endif$1"
  131.         ],
  132.         "description": "debugging in runtime"
  133.     },
  134.     "endline": {
  135.         "prefix": "en",
  136.         "body": [
  137.             "'\\n'"
  138.         ],
  139.         "description": "endline"
  140.     },
  141.     "long long": {
  142.         "prefix": "ll",
  143.         "body": [
  144.             "long long"
  145.         ],
  146.         "description": "long long"
  147.     },
  148.     "debugging template": {
  149.         "prefix": "dbg",
  150.         "body": [
  151.             "void __print(int x) {cerr << x;}",
  152.             "void __print(long x) {cerr << x;}",
  153.             "void __print(long long x) {cerr << x;}",
  154.             "void __print(unsigned x) {cerr << x;}",
  155.             "void __print(unsigned long x) {cerr << x;}",
  156.             "void __print(unsigned long long x) {cerr << x;}",
  157.             "void __print(float x) {cerr << x;}",
  158.             "void __print(double x) {cerr << x;}",
  159.             "void __print(long double x) {cerr << x;}",
  160.             "void __print(char x) {cerr << '\\'' << x << '\\'';}",
  161.             "void __print(const char *x) {cerr << '\\\"' << x << '\\\"';}",
  162.             "void __print(const string &x) {cerr << '\\\"' << x << '\\\"';}",
  163.             "void __print(bool x) {cerr << (x ? \"true\" : \"false\");}",
  164.             "",
  165.             "template<typename T, typename V>",
  166.             "void __print(const pair<T, V> &x) {cerr << '('; __print(x.first); cerr << ','; __print(x.second); cerr << ')';}",
  167.             "template<typename T>",
  168.             "void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? \",\" : \"\"), __print(i); cerr << \"}\";}",
  169.             "void _print() {cerr << \"]\\n\";}",
  170.             "template <typename T, typename... V>",
  171.             "void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << \", \"; _print(v...);}",
  172.             "#ifndef ONLINE_JUDGE",
  173.             "#define debug(x...) cerr << \"[\" << #x << \"] = [\"; _print(x)",
  174.             "#else",
  175.             "#define debug(x...)",
  176.             "#endif"
  177.         ],
  178.         "description": "debugging template"
  179.     },
  180.     "binary exponetiation": {
  181.         "prefix": "bin_power",
  182.         "body": [
  183.             "long long binpow(long long a, long long b) {",
  184.             "  long long res = 1;",
  185.             "  while (b > 0) {",
  186.             "    if (b & 1) res = res * a;",
  187.             "    a = a * a;",
  188.             "    b >>= 1;",
  189.             "  }",
  190.             "  return res;",
  191.             "}"
  192.         ],
  193.         "description": "binary exponetiation"
  194.     }
  195. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement