Untitled
"CPP Boilerplate": { "prefix": "cpp-boilerplate", "body": [ "#include <bits/stdc++.h>", "#include <ext/pb_ds/assoc_container.hpp>", "#include <ext/pb_ds/tree_policy.hpp>\n", "#ifndef ONLINE_JUDGE", "#include \"/home/vbaswan/CompetitiveProgramming/TestingLibrary/TestingLibrary.h\"", "#endif\n", "//#include <sys/resource.h>\n", "using namespace std;", "using namespace __gnu_pbds;\n", "#pragma GCC optimize(\"Ofast\")", "#pragma GCC target(\"avx,avx2,sse,sse2,sse3,sse4,popcnt,fma\")", "#pragma GCC optimize(\"unroll-loops\")\n", "typedef long long int ll;", "typedef long long unsigned int ull;", "typedef pair<ll, ll> llpair;", "//Refer https://codeforces.com/blog/entry/11080", "typedef tree<", "ll,", "null_type,", "less<ll>,", "rb_tree_tag,", "tree_order_statistics_node_update>", "ordered_set;", "typedef std::numeric_limits<double> dbl;\n", "#if defined(_USE_MATH_DEFINES) && !defined(_MATH_DEFINES_DEFINED)", "#define _MATH_DEFINES_DEFINED", "#define M_E 2.71828182845904523536", "#define M_LOG2E 1.44269504088896340736", "#define M_LOG10E 0.434294481903251827651", "#define M_LN2 0.693147180559945309417", "#define M_LN10 2.30258509299404568402", "#define M_PI 3.14159265358979323846", "#define M_PI_2 1.57079632679489661923", "#define M_PI_4 0.785398163397448309616", "#define M_1_PI 0.318309886183790671538", "#define M_2_PI 0.636619772367581343076", "#define M_2_SQRTPI 1.12837916709551257390", "#define M_SQRT2 1.41421356237309504880", "#define M_SQRT1_2 0.707106781186547524401", "#endif\n", "void prepareIO()", "{", "\tios_base::sync_with_stdio(false);", "\tcin.tie(NULL);", "\tcout.precision(dbl::max_digits10);", "}\n", "//void increaseStackDepth()", "//{", "//\trlimit R;", "//\tgetrlimit(RLIMIT_STACK, &R);", "//\tR.rlim_cur = R.rlim_max;", "//\tsetrlimit(RLIMIT_STACK, &R);", "//}", "/*", "unordered_map<int,int>mp;", "mp.reserve(1024);", "mp.max_load_factor(0.25);", "*/\n", "struct HASH\n{\n\tsize_t operator()(const llpair &x) const\n\t{\n\t\treturn hash<long long>()(x.first ^ (x.second) << 32);\n\t}\n};\n", "const ll MOD = 1e9 + 7;\n", "const ll N = 1e5+5;\n", "int main()", "{", "#ifndef ONLINE_JUDGE", "\tfreopen(\"../../input.txt\", \"r\", stdin);", "\tfreopen(\"../../output.txt\", \"w\", stdout);", "#endif", "\tprepareIO();", "\treturn 0;", "}" ], "description": "Boilerplate code for CPP" }, "My Hash": { "prefix": [ "hash", "my-hash" ], "body": [ "struct custom_hash", "{", "\tstatic uint64_t splitmix64(uint64_t x)", "\t{", "\t\t// http://xorshift.di.unimi.it/splitmix64.c", "\t\tx += 0x9e3779b97f4a7c15;", "\t\tx = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;", "\t\tx = (x ^ (x >> 27)) * 0x94d049bb133111eb;", "\t\treturn x ^ (x >> 31);", "\t}\n", "\tsize_t operator()(uint64_t x) const", "\t{", "\t\tstatic const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();", "\t\treturn splitmix64(x + FIXED_RANDOM);", "\t}", "};", "$0" ], "description": "Custom hash function for unordered maps" }, "Testcase Code": { "prefix": [ "test", "testcase" ], "body": [ "ll t = 1;", "cin >> t;\n", "for (ll Case = 1; Case <= t; Case++)", "{", "\t$0", "}" ], "description": "Snippet to add code to read test cases" }
Leave a Comment