-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcpp.json
348 lines (348 loc) · 12.7 KB
/
cpp.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
{
"Code Snippet": {
"prefix": "include",
"body": [
"/***************************************************/",
"/* Author : Md. Arik Rayhan */",
"/* Github : github.com/mdarikrayhan */",
"/***************************************************/",
"",
"#pragma GCC target (\"avx2\")",
"#pragma GCC optimization (\"O3\")",
"#pragma GCC optimization (\"unroll-loops\")",
"",
"#include <bits/stdc++.h>",
"using namespace std;",
"const char nl = '\\n';",
"",
"typedef long long ll;",
"typedef unsigned long long ull;",
"typedef __uint128_t u128;",
"typedef long double ld;",
"typedef complex<ld> cd;",
"",
"typedef pair<int, int> pi;",
"typedef pair<ll, ll> pl;",
"typedef pair<ld, ld> pd;",
"",
"typedef vector<int> vi;",
"typedef vector<ld> vd;",
"typedef vector<ll> vl;",
"typedef vector<pi> vpi;",
"typedef vector<pl> vpl;",
"typedef vector<cd> vcd;",
"",
"#define YES cout << \"YES\" << nl;",
"#define NO cout << \"NO\" << nl;",
"",
"#define ins insert",
"#define mp make_pair",
"#define pb push_back",
"#define ff first",
"#define ss second",
"#define lb lower_bound",
"#define ub upper_bound",
"#define all(x) x.begin(), x.end()",
"#define sz(x) (int)(x).size()",
"",
"#define rep(i, a, b) for (int i = a; i < (b); i++)",
"#define per(i, a, b) for (int i = (b)-1; i >= a; i--)",
"#define gcd(a, b) __gcd(a, b)",
"#define lcm(a, b) (a * (b / gcd(a, b)))",
"",
"#define start_time using std::chrono::duration;using std::chrono::duration_cast; using std::chrono::high_resolution_clock; using std::chrono::milliseconds; auto t1111 = high_resolution_clock::now();",
"#define end_time auto t2222 = high_resolution_clock::now(); duration<double, std::milli> ms_double = t2222 - t1111;std::cout << ms_double.count() << 'm' << 's' << nl;",
"#define spring for (int num = 0; num < 9185319; num++){string a = \"Arik\";a.pop_back();a.pop_back();a.pop_back();a.pop_back();}",
"#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);",
"#define fastIO spring sievefactor(); fastio",
"#define multicase int NoOfTestCase = 1;cin >> NoOfTestCase;for (int testcaseno = 1; testcaseno <= NoOfTestCase; testcaseno++)",
"",
"#define deb(x) cout << #x << \"=\" << x << endl",
"#define deb2(x, y) cout << #x << \"=\" << x << \",\" << #y << \"=\" << y << endl",
"#define deb3(x, y, z) cout << #x << \"=\" << x << \",\" << #y << \"=\" << y << \",\" << #z << \"=\" << z << endl",
"#define deb4(a, b, c, d) cout << #a << \"=\" << a << \",\" << #b << \"=\" << b << \",\" << #c << \"=\" << c << \",\" << #d << \"=\" << d << endl",
"",
"/****************** Debug.h Files **********************/",
"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",
"",
"//Bitwise Sieve",
"const int pmxsz = 100000000;",
"int status[(pmxsz / 32) + 2];",
"int prime[5761455 + 5], noofprime = 0;",
"inline bool Bit_Check(int N, int pos) { return (bool)(N & (1 << pos)); }",
"inline int Bit_Set(int N, int pos) { return N = N | (1 << pos); }",
"inline bool PrimeCheck(int i) { return 1 ^ (bool)(Bit_Check(status[i >> 5], i & 31)); }",
"inline void PrimeSet(int i) { status[i >> 5] = Bit_Set(status[i >> 5], i & 31); }",
"inline void Mark(int i, int N) { for (int j = i * i; j <= N; j += (i << 1)) PrimeSet(j); }",
"void sieve(int N) { int i, j, sqrtN; sqrtN = int(sqrt(N)); for (i = 5; i <= sqrtN; i += 6) { if (PrimeCheck(i)) { Mark(i, N); } if (PrimeCheck(i + 2)) { Mark(i + 2, N); } } prime[noofprime++] = 2; prime[noofprime++] = 3; for (i = 5; i <= N; i += 6) { if (PrimeCheck(i)) { prime[noofprime++] = i; } if (PrimeCheck(i + 2)) { prime[noofprime++] = i + 2; } } }",
"",
"//Single Prime Check using Miller Rabin",
"ull binpower(ull base, ull e, ull mod) { ull result = 1; base %= mod; while (e) { if (e & 1) result = (u128)result * base % mod; base = (u128)base * base % mod; e >>= 1; } return result; }",
"bool check_composite(ull n, ull a, ull d, int s) { ull x = binpower(a, d, n); if (x == 1 || x == n - 1) return false; for (int r = 1; r < s; r++) { x = (u128)x * x % n; if (x == n - 1) return false; } return true; };",
"bool MillerRabin(ull n) { if (n < 2) return false; int r = 0; ull d = n - 1; while ((d & 1) == 0) { d >>= 1; r++; } for (int a : {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37}) { if (n == a) return true; if (check_composite(n, a, d, r)) return false; } return true; }",
"",
"//Prime Factorization using SPFs and Sieve",
"const int MAXN = 10e6+5; int spf[MAXN]; vector<int> factor[MAXN]; inline vector<int> getFactorization(int x) { vector<int> ret; while (x != 1) { ret.push_back(spf[x]); x = x / spf[x]; } return ret; }",
"void sievefactor() { spf[1] = 1; for (int i = 2; i <= MAXN; i++) { spf[i] = i; } for (int i = 4; i <= MAXN; i += 2) { spf[i] = 2; } for (int i = 3; i * i < MAXN; i++) { if (spf[i] == i) { for (int j = i * i; j < MAXN; j += i) if (spf[j] == j) { spf[j] = i; } } } for (int i = 1; i <= MAXN; i++) { factor[i] = getFactorization(i); } }",
"",
"ull rangesum(ll L, ll R) { return ((L + R) * (abs(R - L) + 1)) / 2; }",
"bool isPalindrome(string S) { string P = S; reverse(P.begin(), P.end()); return S == P ? true : false; }",
"bool isPowerof(ll num, ll base) { return (num > 0 && num % base == 0) ? isPowerof(num / base, base) : num == 1; }",
"bool isPowerofTwo(ll num) { return (num > 0 && (num & (num - 1)) == 0) ? true : false; }",
"",
"template <class T>",
"bool ckmin(T &a, const T &b) { return b < a ? a = b, 1 : 0; }",
"template <class T>",
"bool ckmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }",
"",
"void solve()",
"{",
" ",
"}",
"",
"int32_t main()",
"{",
" fastio",
" multicase",
" {",
" solve();",
" }",
" return 0;",
"}"
],
"description": "Code Snippet"
},
"My_details": {
"prefix": "author",
"body": [
"/***************************************************/",
"/* Author : Md. Arik Rayhan */",
"/* Github : github.com/mdarikrayhan */",
"/***************************************************/",
"$0"
],
"description": "author"
},
"Simple Snippter": {
"prefix": "sinclude",
"body": [
"#include <bits/stdc++.h>",
"using namespace std;",
"const char nl = '\\n';",
"#define ll long long",
"int main()",
"{",
" ios_base::sync_with_stdio(false);",
" cin.tie(NULL);",
" cout.tie(NULL);",
" int T = 1;",
" cin >> T;",
" while (T--)",
" {",
" $0",
" }",
" return 0;",
"}"
],
"description": "Simple Snippter"
},
"Bitwise Sieve 10^8 in 400ms & 35MB": {
"prefix": "bitwise_sieve",
"body": [
"const int pmxsz = 100000000;",
"int status[(pmxsz / 32) + 2];",
"int prime[5761455 + 5],noofprime = 0;",
"inline bool Bit_Check(int N, int pos) { return (bool)(N & (1 << pos)); }",
"inline int Bit_Set(int N, int pos) { return N = N | (1 << pos); }",
"inline bool PrimeCheck(int i) { return 1^(bool)(Bit_Check(status[i >> 5], i & 31)); }",
"inline void PrimeSet(int i) { status[i >> 5] = Bit_Set(status[i >> 5], i & 31); }",
"inline void Mark(int i,int N){ for (int j = i * i; j <= N; j += (i << 1)){PrimeSet(j);} }",
"",
"void sieve(int N)",
"{",
" int i, j, sqrtN;",
" sqrtN = int(sqrt(N));",
" for (i = 5; i <= sqrtN; i += 6)",
" {",
" if (PrimeCheck(i))",
" {",
" Mark(i,N);",
" }",
" if (PrimeCheck(i+2))",
" {",
" Mark(i+2,N);",
" }",
" }",
" prime[noofprime++] = 2;",
" prime[noofprime++] = 3;",
" ",
" for (i = 5; i <= N; i += 6)",
" {",
" if (PrimeCheck(i))",
" {",
" prime[noofprime++] = i;",
" }",
" if (PrimeCheck(i + 2))",
" {",
" prime[noofprime++] = i + 2;",
" }",
" }",
"}"
],
"description": "Bitwise Sieve for finding prime numbers"
},
"SPF using Sieve 10^6 in 280ms & 42MB": {
"prefix": "spfsieve",
"body": [
"const int MAXN = 1000005;",
"//Used: 265 ms, 41764 KB 10^6",
"//Used: 2822 ms, 424072 KB 10^7",
"int spf[MAXN];",
"vector<int> factor[MAXN];",
"inline vector<int> getFactorization(int x)",
"{",
" vector<int> ret;",
" while (x != 1)",
" {",
" ret.push_back(spf[x]);",
" x = x / spf[x];",
" }",
" return ret;",
"}",
"void sievefactor()",
"{",
" spf[1] = 1;",
" for (int i = 2; i <= MAXN; i++)",
" {",
" spf[i] = i;",
" }",
" for (int i = 4; i <= MAXN; i += 2)",
" {",
" spf[i] = 2;",
" }",
" for (int i = 3; i * i < MAXN; i++)",
" {",
" if (spf[i] == i)",
" {",
" for (int j = i * i; j < MAXN; j += i)",
" if (spf[j] == j)",
" {",
" spf[j] = i;",
" }",
" }",
" }",
" for (int i = 1; i <= MAXN; i++)",
" {",
" factor[i] = getFactorization(i);",
" }",
"}"
],
"description": "SPF using Sieve 10^6 in 280ms & 42MB"
},
"C++ header files": {
"prefix": "headerfiles",
"body": [
"#include <cassert>",
"#include <cctype>",
"#include <cerrno>",
"#include <cfloat>",
"#include <ciso646>",
"#include <climits>",
"#include <clocale>",
"#include <cmath>",
"#include <csetjmp>",
"#include <csignal>",
"#include <cstdarg>",
"#include <cstddef>",
"#include <cstdio>",
"#include <cstdlib>",
"#include <cstring>",
"#include <ctime>",
"#include <ccomplex>",
"#include <cfenv>",
"#include <cinttypes>",
"#include <cstdbool>",
"#include <cstdint>",
"#include <ctgmath>",
"#include <cwchar>",
"#include <cwctype>",
"#include <algorithm>",
"#include <bitset>",
"#include <complex>",
"#include <deque>",
"#include <exception>",
"#include <fstream>",
"#include <functional>",
"#include <iomanip>",
"#include <ios>",
"#include <iosfwd>",
"#include <iostream>",
"#include <istream>",
"#include <iterator>",
"#include <limits>",
"#include <list>",
"#include <locale>",
"#include <map>",
"#include <memory>",
"#include <new>",
"#include <numeric>",
"#include <ostream>",
"#include <queue>",
"#include <set>",
"#include <sstream>",
"#include <stack>",
"#include <stdexcept>",
"#include <streambuf>",
"#include <string>",
"#include <typeinfo>",
"#include <utility>",
"#include <valarray>",
"#include <vector>",
"#include <array>",
"#include <atomic>",
"#include <chrono>",
"#include <condition_variable>",
"#include <forward_list>",
"#include <future>",
"#include <initializer_list>",
"#include <mutex>",
"#include <random>",
"#include <ratio>",
"#include <regex>",
"#include <scoped_allocator>",
"#include <system_error>",
"#include <thread>",
"#include <tuple>",
"#include <typeindex>",
"#include <type_traits>",
"#include <unordered_map>",
"#include <unordered_set>"
],
"description": "C++ header files"
}
}