Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- "boilerplate cpp template": {
- "prefix": "startER",
- "body": [
- "#include <bits/stdc++.h>",
- "",
- "using namespace std;",
- "",
- "int main() {",
- " ios_base::sync_with_stdio(false);",
- " cin.tie(nullptr);",
- " $0",
- " return 0;",
- "}"
- ],
- "description": "boilerplate cpp template"
- },
- "boilerplate code for test case": {
- "prefix": "startWithTestCase",
- "body": [
- "#include <bits/stdc++.h>",
- "",
- "using namespace std;",
- "",
- "void solve() {",
- " $0",
- "}",
- "",
- "int main() {",
- " ios_base::sync_with_stdio(false);",
- " cin.tie(nullptr);",
- " int t;",
- " cin >> t;",
- " while (t--) {",
- " solve();",
- " }",
- " return 0;",
- "}",
- ""
- ],
- "description": "boilerplate code for test case"
- },
- "debugging in runtime": {
- "prefix": "code_debug",
- "body": [
- "template <typename A, typename B>",
- "string to_string(pair<A, B> p);",
- "",
- "template <typename A, typename B, typename C>",
- "string to_string(tuple<A, B, C> p);",
- "",
- "template <typename A, typename B, typename C, typename D>",
- "string to_string(tuple<A, B, C, D> p);",
- "",
- "string to_string(const string& s) { return '\"' + s + '\"'; }",
- "",
- "string to_string(char c) { return string(1, c); }",
- "",
- "string to_string(const char* s) { return to_string((string)s); }",
- "",
- "string to_string(bool b) { return (b ? \"true\" : \"false\"); }",
- "",
- "string to_string(const vector<bool>& v) {",
- " bool first = true;",
- " string res = \"{\";",
- " for (auto&& i : v) {",
- " if (!first) {",
- " res += \", \";",
- " }",
- " first = false;",
- " res += to_string(i);",
- " }",
- " res += \"}\";",
- " return res;",
- "}",
- "",
- "template <size_t N>",
- "string to_string(bitset<N> v) {",
- " string res;",
- " for (size_t i = 0; i < N; i++) {",
- " res += static_cast<char>('0' + v[i]);",
- " }",
- " return res;",
- "}",
- "",
- "template <typename A>",
- "string to_string(A v) {",
- " bool first = true;",
- " string res = \"{\";",
- " for (const auto& x : v) {",
- " if (!first) {",
- " res += \", \";",
- " }",
- " first = false;",
- " res += to_string(x);",
- " }",
- " res += \"}\";",
- " return res;",
- "}",
- "",
- "template <typename A, typename B>",
- "string to_string(pair<A, B> p) {",
- " return \"(\" + to_string(p.first) + \", \" + to_string(p.second) + \")\";",
- "}",
- "",
- "template <typename A, typename B, typename C>",
- "string to_string(tuple<A, B, C> p) {",
- " return \"(\" + to_string(get<0>(p)) + \", \" + to_string(get<1>(p)) + \", \" +",
- " to_string(get<2>(p)) + \")\";",
- "}",
- "",
- "template <typename A, typename B, typename C, typename D>",
- "string to_string(tuple<A, B, C, D> p) {",
- " return \"(\" + to_string(get<0>(p)) + \", \" + to_string(get<1>(p)) + \", \" +",
- " to_string(get<2>(p)) + \", \" + to_string(get<3>(p)) + \")\";",
- "}",
- "",
- "void debug_out() { cerr << endl; }",
- "",
- "template <typename Head, typename... Tail>",
- "void debug_out(Head H, Tail... T) {",
- " cerr << \" \" << to_string(H);",
- " debug_out(T...);",
- "}",
- "",
- "#ifndef LOCAL",
- "#define debug(...) cerr << \"[\" << #__VA_ARGS__ << \"]:\", debug_out(__VA_ARGS__)",
- "#else",
- "#define debug(...) 42",
- "#endif$1"
- ],
- "description": "debugging in runtime"
- },
- "endline": {
- "prefix": "en",
- "body": [
- "'\\n'"
- ],
- "description": "endline"
- },
- "long long": {
- "prefix": "ll",
- "body": [
- "long long"
- ],
- "description": "long long"
- },
- "debugging template": {
- "prefix": "dbg",
- "body": [
- "void __print(int x) {cerr << x;}",
- "void __print(long x) {cerr << x;}",
- "void __print(long long x) {cerr << x;}",
- "void __print(unsigned x) {cerr << x;}",
- "void __print(unsigned long x) {cerr << x;}",
- "void __print(unsigned long long x) {cerr << x;}",
- "void __print(float x) {cerr << x;}",
- "void __print(double x) {cerr << x;}",
- "void __print(long double x) {cerr << x;}",
- "void __print(char x) {cerr << '\\'' << x << '\\'';}",
- "void __print(const char *x) {cerr << '\\\"' << x << '\\\"';}",
- "void __print(const string &x) {cerr << '\\\"' << x << '\\\"';}",
- "void __print(bool x) {cerr << (x ? \"true\" : \"false\");}",
- "",
- "template<typename T, typename V>",
- "void __print(const pair<T, V> &x) {cerr << '('; __print(x.first); cerr << ','; __print(x.second); cerr << ')';}",
- "template<typename T>",
- "void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? \",\" : \"\"), __print(i); cerr << \"}\";}",
- "void _print() {cerr << \"]\\n\";}",
- "template <typename T, typename... V>",
- "void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << \", \"; _print(v...);}",
- "#ifndef ONLINE_JUDGE",
- "#define debug(x...) cerr << \"[\" << #x << \"] = [\"; _print(x)",
- "#else",
- "#define debug(x...)",
- "#endif"
- ],
- "description": "debugging template"
- },
- "binary exponetiation": {
- "prefix": "bin_power",
- "body": [
- "long long binpow(long long a, long long b) {",
- " long long res = 1;",
- " while (b > 0) {",
- " if (b & 1) res = res * a;",
- " a = a * a;",
- " b >>= 1;",
- " }",
- " return res;",
- "}"
- ],
- "description": "binary exponetiation"
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement