-
Notifications
You must be signed in to change notification settings - Fork 10
/
snippets.conf
164 lines (146 loc) · 23.8 KB
/
snippets.conf
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
# Geany's snippets configuration file
#
# use \n or %newline% for a new line (it will be replaced by the used EOL char(s) - LF, CR/LF, CR).
# use \t or %ws% for an indentation step, it will be replaced according to the current document's indent mode.
# use \s to force whitespace at beginning or end of a value ('key= value' won't work, use 'key=\svalue').
# use %key% for all keys defined in the [Special] section.
# use %cursor% to define where the cursor should be placed after completion. You can define multiple
# %cursor% wildcards and use the "Move cursor in snippet" to jump to the next defined cursor
# position in the completed snippet.
# You can define a section for each supported filetype to overwrite default settings, the section
# name must match exactly the internal filetype name, run 'geany --ft-names' for a full list.
#
# Additionally, you can use most of the template wildcards like {developer}, {command:...},
# or {date} in the snippets.
# See the documentation for details.
# For a list of available filetype names, execute:
# geany --ft-names
# Default is used for all filetypes and keys can be overwritten by [filetype] sections
[Default]
# special keys to be used in other snippets, cannot be used "standalone"
# can be used by %key%, e.g. %brace_open%
# nesting of special keys is not supported (e.g. brace_open=\n{\n%brace_close% won't work)
# key "wordchars" is very special, it defines the word delimiting characters when looking for
# a word to auto complete, leave commented to use the default wordchars
[Special]
brace_open=\n{\n\t
brace_close=}\n
block=\n{\n\t%cursor%\n}
block_cursor=\n{\n\t%cursor%\n}
#wordchars=_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789
# Optional keybindings to insert snippets
# Note: these can be overridden by Geany's configurable keybindings
[Keybindings]
#for=<Ctrl>7
[C]
if=if (%cursor%)%block_cursor%
else=else%block_cursor%
for=for (i = 0; i < %cursor%; i++)%block_cursor%
while=while (%cursor%)%block_cursor%
do=do\n{\n\t%cursor%\n} while (%cursor%)\n
switch=switch (%cursor%)%brace_open%case %cursor%:\n\t\t%cursor%\n\t\tbreak;\n\tdefault:\n\t\t%cursor%\n%brace_close%
[C++]
if=if (%cursor%)%block_cursor%
else=else%block_cursor%
for=for (int i = 0; i < %cursor%; i++)%brace_open%\n%brace_close%
while=while (%cursor%)%block_cursor%
do=do\n{\n\t%cursor%\n} while (%cursor%)\n
switch=switch (%cursor%)%brace_open%case %cursor%:\n\t\t%cursor%\n\t\tbreak;\n\tdefault:\n\t\t%cursor%\n%brace_close%
try=try%block%\ncatch (%cursor%)%block_cursor%
template=#include <bits/stdc++.h>\n\nusing namespace std;\ntypedef long long Int;\n\nint main(){\n\tios::sync_with_stdio(false);\n\tint T;\n\tcin >> T;\n\twhile(T--){\n\n\t}\n\treturn 0;\n}
debug=string to_string(string s) {\n\treturn '"' + s + '"';\n}\nstring to_string(const char* s) {\n\treturn to_string((string) s);\n}\nstring to_string(bool b) {\n\treturn (b ? "true" : "false");\n}\ntemplate <typename A, typename B>\nstring to_string(pair<A, B> p) {\nreturn "(" + to_string(p.first) + ", " + to_string(p.second) + ")";\n}\ntemplate <typename A>\nstring to_string(A v) {\n\tbool first = true;\n\tstring res = "{";\n\tfor (const auto &x : v) {\n\t\tif (!first) {\n\t\t\tres += ", ";\n\t\t}\n\t\tfirst = false;\n\t\tres += to_string(x);\n\t}\n\tres += "}";\n\treturn res;\n}\nvoid print() { cerr << endl; }\ntemplate <typename Head, typename... Tail>\nvoid print(Head H, Tail... T) {\n\tcerr << " " << to_string(H);\n\tprint(T...);\n}\n#ifdef ABHI\n#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", print(__VA_ARGS__)\n#else\n#define debug(...) 42\n#endif\n
trace=#ifdef ABHI\n #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)\ntemplate <typename Arg1>\nvoid __f(const char* name, Arg1&& arg1){\n cerr << name << " : " << arg1 << std::endl;\n}\ntemplate <typename Arg1, typename... Args>\nvoid __f(const char* names, Arg1&& arg1, Args&&... args){\n const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);\n}\n#else\n #define trace(...)\n#endif\n\n
hashes=// code credit : https://www.codechef.com/viewsolution/18660185\ntypedef long long lint;\nconst int maxn = 400001;\nconst int mod = 1004669333, base = 33, inv_base = 121778101;\nvector<int> base_pow(maxn + 1), inv_base_pow(maxn + 1);\nvoid prep() {\n base_pow[0] = 1;\n for (int i = 1; i <= maxn; ++i)\n base_pow[i] = (lint)base_pow[i - 1] * base % mod;\n inv_base_pow[0] = 1;\n for (int i = 1; i <= maxn; ++i)\n inv_base_pow[i] = (lint)inv_base_pow[i - 1] * inv_base % mod;\n}\nstruct hashes_t {\n string s;\n int n;\n vector<int> acc_hash, acc_inv_hash;\n hashes_t(const string &_s): s(_s), n(s.size()), acc_hash(n + 1, 0)\n , acc_inv_hash(n + 1, 0) {\n for (int i = 0; i < n; ++i) {\n acc_hash[i + 1] =\n (acc_hash[i] + (lint)base_pow[i] * (s[i] - 'a' + 1)) % mod;\n acc_inv_hash[i + 1] =\n (acc_inv_hash[i] + (lint)inv_base_pow[i] * (s[i] - 'a' + 1)) % mod;\n }\n }\n int get_hash(int a, int b) {\n int hash = acc_hash[b + 1] - acc_hash[a];\n if (hash < 0) hash += mod;\n hash = (lint)hash * inv_base_pow[a] % mod;\n return hash;\n }\n int get_inv_hash(int a, int b) {\n int hash = acc_inv_hash[b + 1] - acc_inv_hash[a];\n if (hash < 0) hash += mod;\n hash = (lint)hash * base_pow[b] % mod;\n return hash;\n }\n};\n
fenwick=\ntemplate <typename T>\nclass fenwick {\n public:\n vector<T> fenw;\n int n;\n \n fenwick(int _n) : n(_n) {\n fenw.resize(n);\n }\n \n void modify(int x, T v) {\n while (x < n) {\n fenw[x] += v;\n x |= (x + 1);\n }\n }\n \n T get(int x) {\n T v{};\n while (x >= 0) {\n v += fenw[x];\n x = (x & (x + 1)) - 1;\n }\n return v;\n }\n};\n\n
segtree=\nclass SegTree {\npublic:\n struct Node {\n // don't forget to set default value (used for leaves)\n // not necessarily neutral element!\n int x = 0;\n int add = 0;\n void apply(int val){\n x = val;\n }\n void update(int val){\n x += val;\n }\n };\nprivate:\n vector<Node> tree;\n int N , n;\n\n // for lazy propogation\n inline void push(int x , int l , int r){\n if(tree[x].add != 0){\n tree[x].update(tree[x].add);\n if(l != r){\n int cover = (r - l + 1);\n tree[x << 1].add += (tree[x].add);\n tree[(x << 1)|1].add += (tree[x].add);\n }\n tree[x].add = 0;\n }\n }\n\n Node combine(const Node &A , const Node &B){\n Node ans;\n ans.x = max(A.x , B.x);\n return ans;\n }\n \n void build(int s , int e , int idx) {\n if(s == e){\n tree[idx].apply(0);\n return;\n }\n int mid = (s+e) >> 1;\n build(s , mid , (idx << 1));\n build(mid + 1 , e , ((idx << 1)|1));\n return;\n }\n\n template <typename T>\n void build(const vector < T > &ar , int s , int e , int idx) {\n if(s == e){\n tree[idx].apply(ar[s]);\n return;\n }\n int mid = (s+e) >> 1;\n build(ar , s , mid , (idx << 1));\n build(ar , mid + 1 , e , ((idx << 1)|1));\n tree[idx] = combine(tree[idx << 1] , tree[(idx << 1)|1]);\n return;\n }\n\n Node query(int s , int e , int lf , int rf , int idx) {\n push(idx , s , e);\n if(rf < s or e < lf) return Node();\n if(lf <= s and e <= rf){\n return tree[idx];\n }\n int mid = (s + e) >> 1;\n int l = idx << 1;\n int r = (idx << 1) | 1;\n if(lf <= mid){\n if(rf <= mid){\n return query(s , mid , lf , rf , l);\n }else{\n return combine(query(s , mid , lf , rf , l) , query(mid + 1 , e , lf , rf , r));\n }\n }else{\n return query(mid + 1 , e , lf , rf , r);\n }\n }\n\n template <typename M>\n void update(int s , int e , int i , M val , int idx) {\n if(s > i or e < i) return;\n if(s == e){\n tree[idx].apply(val);\n return;\n }\n int mid = (s + e) >> 1;\n update(s , mid , i , val , (idx << 1));\n update(mid + 1 , e , i , val , (idx << 1)|1);\n tree[idx] = combine(tree[idx << 1] , tree[(idx << 1) | 1]);\n return;\n }\n\n template <typename M>\n void update(int s , int e , int l , int r , M val , int idx) {\n push(idx , s , e);\n if(s > r or e < l or s > e) return;\n if(l <= s && e <= r){\n tree[idx].add += val;\n push(idx , s , e);\n return;\n }\n int mid = (s + e) >> 1;\n update(s , mid , l , r , val , (idx << 1));\n update(mid + 1 , e , l , r , val , (idx << 1)|1);\n tree[idx] = combine(tree[idx << 1] , tree[(idx << 1) | 1]);\n return;\n }\n\npublic:\n template<typename T>\n SegTree(const vector<T> &ar) {\n n = (int) ar.size();\n N = 4*(n) + 1;\n tree.resize(N, {});\n build(ar , 0 , n - 1 , 1);\n }\n\n SegTree(int _n) : n (_n){\n N = 4 * (n) + 1;\n tree.resize(N , {});\n build(0 , n - 1 , 1);\n }\n\n SegTree(){\n n = 100000;\n N = 4 * n + 1;\n tree.resize(N , {});\n }\n\n void build(){\n build(0 , n - 1 , 1); \n }\n\n template<typename T>\n void build(const vector<T> &ar) {\n build(ar , 0 , n - 1 , 1);\n }\n\n Node query(int l ,int r){\n return query(0 , n - 1 , l , r , 1);\n }\n\n template<typename T>\n void update(int l , int r , T val){\n update(0 , n - 1 , l , r , val , 1);\n }\n\n template<typename M>\n void update(int i , M val) {\n update(0 , n - 1 , i , val , 1);\n }\n};\n
psegtree=struct Node {\n int x;\n Node* l, *r;\n Node(Node* _l = NULL , Node* _r = NULL , int _x = 0) {\n l = _l;\n r = _r;\n x = _x;\n }\n};\n\nint ar[N];\nNode* versions[N];\n\nvoid build(Node* tree , int l , int r) {\n if(r < l) return;\n if(l == r) {\n tree->x = ar[l];\n return;\n }\n int mid = (l + r) >> 1;\n tree->l = new Node();\n tree->r = new Node();\n build(tree->l , l , mid);\n build(tree->r , mid + 1 , r);\n tree->x = tree->l->x + tree->r->x;\n}\n\nvoid update(Node* old, Node* curr, int l , int r , int idx , int val) {\n if(idx < l || idx > r || r < l) return;\n if(l == r) {\n curr->x = old->x + val;\n return;\n }\n int mid = (l + r) >> 1;\n if(idx <= mid) {\n curr->r = old->r;\n curr->l = new Node();\n update(old->l , curr->l , l , mid , idx , val);\n } else {\n curr->l = old->l;\n curr->r = new Node();\n update(old->r , curr->r , mid + 1 , r , idx , val);\n }\n curr->x = curr->l->x + curr->r->x;\n}\n\nint query(Node* root , int l , int r , int lo , int hi) {\n if(lo > r || hi < l || r < l) return 0;\n if(root == NULL) assert(false);\n if(lo <= l && r <= hi) {\n return root->x;\n }\n int mid = (l + r) >> 1;\n int a = query(root->l , l , mid , lo , hi);\n int b = query(root->r , mid + 1 , r , lo , hi);\n return a + b;\n}\n\n
math=const Int MOD = 998244353;\n\ninline Int add(Int a, Int b) {\n a += b;\n if (a >= MOD) a -= MOD;\n return a;\n}\n\ninline Int sub(Int a, Int b) {\n a -= b;\n if (a < 0) a += MOD;\n return a;\n}\n\ninline Int mul(Int a) {\n return a;\n}\n\ntemplate<typename... T>\ninline Int mul(Int a, T... b) {\n return (Int) ((Int) a * mul(b...) % MOD);\n}\n\ninline Int power(Int a, Int b) {\n Int res = 1;\n while (b) {\n if (b & 1) {\n res = mul(res, a);\n }\n a = mul(a, a);\n b >>= 1;\n }\n return res;\n}\n\ninline Int inv(Int a) {\n a %= MOD;\n if (a < 0) a += MOD;\n Int b = MOD, u = 0, v = 1;\n while (a) {\n Int t = b / a;\n b -= t * a; swap(a, b);\n u -= t * v; swap(u, v);\n }\n assert(b == 1);\n if (u < 0) u += MOD;\n return u;\n}\n\n
comb=const Int MOD = 998244353;\n\ninline Int add(Int a, Int b) {\n a += b;\n if (a >= MOD) a -= MOD;\n return a;\n}\n\ninline Int sub(Int a, Int b) {\n a -= b;\n if (a < 0) a += MOD;\n return a;\n}\n\ninline Int mul(Int a) {\n return a;\n}\n\ntemplate<typename... T>\ninline Int mul(Int a, T... b) {\n return (Int) ((Int) a * mul(b...) % MOD);\n}\n\ninline Int power(Int a, Int b) {\n Int res = 1;\n while (b) {\n if (b & 1) {\n res = mul(res, a);\n }\n a = mul(a, a);\n b >>= 1;\n }\n return res;\n}\n\ninline Int inv(Int a) {\n a %= MOD;\n if (a < 0) a += MOD;\n Int b = MOD, u = 0, v = 1;\n while (a) {\n Int t = b / a;\n b -= t * a; swap(a, b);\n u -= t * v; swap(u, v);\n }\n assert(b == 1);\n if (u < 0) u += MOD;\n return u;\n}\n\nconst int MAXN = 1e6 + 10;\nvector<Int> fact(MAXN) , ifact(MAXN);\nvoid pre() {\n fact[0] = ifact[0] = 1LL;\n fact[1] = ifact[1] = 1LL;\n for(int i = 2 ; i < MAXN ; ++i) {\n fact[i] = mul(fact[i - 1] , 1LL * i);\n ifact[i] = inv(fact[i]);\n }\n}\n\nInt P(int N , int K) {\n if(K > N) {\n return 0LL;\n }\n return mul(fact[N] , ifact[N - K]);\n}\n\nInt C(int N , int K) {\n if(K > N) {\n return 0LL;\n }\n return mul(fact[N] , ifact[N - K] , ifact[K]);\n} \n\n
sieve=vector <int> primes;\nvoid sieve(){ \n const int n = 1000010;\n bool prime[n + 1]; \n memset(prime, true, sizeof(prime)); \n for (int p = 2 ; p * p <= n; ++p) { \n if (prime[p] == true) { \n for (int i = p * 2 ; i <= n ; i += p) \n prime[i] = false; \n } \n } \n for (int p = 2 ; p <= n ; p++) \n if (prime[p]) \n primes.push_back(p); \n} \n
getf=const int MAXN = 1e5 + 10;\nvector<int> spf(MAXN);\n\nvoid sieve(){ \n iota(spf.begin(), spf.end() , 0);\n for (int i = 4 ; i < MAXN ; i += 2) \n spf[i] = 2; \n for (int i = 3 ; i * i < MAXN ; i++) { \n if (spf[i] == i) { \n for (int j = i * i; j < MAXN ; j += i) \n if (spf[j] == j) \n spf[j] = i; \n } \n } \n} \n\nvector<int> getF(int x){ \n vector<int> factors; \n while (x != 1) { \n factors.push_back(spf[x]); \n x = x / spf[x]; \n } \n return factors; \n} \n
pbds=#include <ext/pb_ds/assoc_container.hpp>\n#include <ext/pb_ds/tree_policy.hpp>\n\nusing namespace __gnu_pbds;\ntemplate<typename T, class cmp = std::less<T>>\nusing ordered_set = tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;\n\n
prng=mt19937 prng(chrono::steady_clock::now().time_since_epoch().count());\nint rand(int l, int r) {\n return uniform_int_distribution<int>(l, r)(prng);\n}\n
dsu=template <typename T>\nclass dsu {\npublic:\n vector<T> p;\n vector<T> rank;\n int n;\n\n dsu(int _n) : n(_n) {\n p.resize(n);\n rank.resize(n);\n iota(p.begin(), p.end(), 0);\n fill(rank.begin(), rank.end() , 1);\n }\n\n inline T get(T x) {\n return (x == p[x] ? x : (p[x] = get(p[x])));\n }\n\n inline bool unite(T x, T y) {\n T px = get(x);\n T py = get(y);\n if (px != py) {\n if(rank[px] == rank[py]){\n p[py] = px;\n rank[px]++; \n } else if(rank[px] < rank[py]){\n p[px] = py;\n } else {\n p[py] = px;\n }\n return true;\n }\n return false;\n }\n};\n\n
trie=const int SZ = 26;\nstruct TrieNode {\n vector<TrieNode*> node;\n int pass = 0;\n TrieNode() {\n pass = 0;\n node.resize(SZ);\n for(int i = 0; i < SZ; ++i) {\n node[i] = nullptr;\n }\n } \n};\n\nclass Trie {\n TrieNode *root, *temp;\npublic:\n Trie() {\n root = new TrieNode;\n }\n\n void add(const string &s) {\n temp = root;\n for(auto &c: s) {\n int x = c - 'a';\n if(temp->node[x] == nullptr) {\n temp->node[x] = new TrieNode;\n }\n temp = temp->node[x];\n temp->pass++;\n }\n }\n\n int query(const string &s) {\n temp = root;\n for(auto &c: s) {\n int x = c - 'a';\n if(temp->node[x] == nullptr) {\n return 0;\n }\n temp = temp->node[x];\n }\n return (temp ? temp->pass : 0);\n }\n};\n\n
hull=namespace geo{\n struct point{\n int x , y;\n };\n bool operator < (point a, point b) {\n return a.x < b.x || (a.x == b.x && a.y < b.y);\n }\n bool cw(point a, point b, point c) { //clockwise\n return a.x * (b.y - c.y) + b.x * (c.y - a.y) + c.x * (a.y-b.y) < 0;\n }\n\n bool ccw(point a, point b, point c) { //counter-clockwise\n return a.x * (b.y - c.y) + b.x * (c.y - a.y) + c.x * (a.y - b.y) > 0;\n }\n}\n\nusing namespace geo;\n\nvector <point> convex_hull(vector<point> a) {\n if (a.size() == 1)\n return a;\n sort(a.begin(), a.end());\n point p1 = a[0], p2 = a.back();\n vector<point> up, down;\n up.push_back(p1);\n down.push_back(p1);\n for (int i = 1; i < (int)a.size(); i++) {\n if (i == (int) a.size() - 1 || cw(p1, a[i], p2)) {\n while (up.size() >= 2 && !cw(up[up.size()-2], up[up.size()-1], a[i]))\n up.pop_back();\n up.push_back(a[i]);\n }\n if (i == (int) a.size() - 1 || ccw(p1, a[i], p2)) {\n while(down.size() >= 2 && !ccw(down[down.size()-2], down[down.size()-1], a[i]))\n down.pop_back();\n down.push_back(a[i]);\n }\n }\n vector <point> ans;\n for (int i = 0; i < (int)up.size(); i++)\n ans.push_back(up[i]);\n for (int i = (int) down.size() - 2; i > 0; i--)\n ans.push_back(down[i]);\n return ans;\n}\n\n
dijkstra=template <typename T> \nusing minpq = priority_queue<T, vector<T>, greater<T>>;\nconst Int inf = (Int) (1e18);\n\nvoid dijkstra(int S) {\n Int u , vv , c , w;\n minpq<pair<Int, Int>> Q;\n fill(dist.begin(), dist.end(), inf);\n Q.push({0,S});\n dist[S] = 0;\n while(!Q.empty()){\n u = Q.top().second;\n c = Q.top().first;\n Q.pop();\n if(dist[u] < c){\n continue;\n }\n for(int i = 0 ; i < (int) G[u].size() ; i++){\n w = G[u][i].first;\n vv = G[u][i].second;\n if(dist[vv] > dist[u] + w){\n dist[vv] = dist[u] + w;\n Q.push({dist[vv],vv});\n }\n }\n }\n}\n \n
phi=\ntemplate<typename T>\nT phi(T n){\n double res = n;\n for(int p = 2 ; p*p <= n ; ++p){\n if(n % p == 0){\n while(n % p == 0) {\n n /= p;\n }\n res -= res/p; \n }\n }\n if(n > 1){\n res -= res / n;\n }\n return (T) res;\n}\n\n
gcd=template<typename T>\nT gcd(T a, T b) { \n if (b == 0) \n return a; \n return gcd(b, a % b); \n} \n\n
kmp=template <typename T>\nvector<int> kmp_table(int n, const T &s) {\n vector<int> p(n, 0);\n int k = 0;\n for (int i = 1; i < n; i++) {\n while (k > 0 && !(s[i] == s[k])) {\n k = p[k - 1];\n }\n if (s[i] == s[k]) {\n k++;\n }\n p[i] = k;\n }\n return p;\n}\n \ntemplate <typename T>\nvector<int> kmp_table(const T &s) {\n return kmp_table((int) s.size(), s);\n}\n \ntemplate <typename T>\nvector<int> kmp_search(int n, const T &s, int m, const T &w, const vector<int> &p) {\n assert(n >= 1 && (int) p.size() == n);\n vector<int> res;\n int k = 0;\n for (int i = 0; i < m; i++) {\n while (k > 0 && (k == n || !(w[i] == s[k]))) {\n k = p[k - 1];\n }\n if (w[i] == s[k]) {\n k++;\n }\n if (k == n) {\n res.push_back(i - n + 1);\n }\n }\n return res;\n // returns 0-indexed positions of occurrences of s in w\n}\n \ntemplate <typename T>\nvector<int> kmp_search(const T &s, const T &w, const vector<int> &p) {\n return kmp_search((int) s.size(), s, (int) w.size(), w, p);\n}\n
lca=\nconst int MAXN = 1e5 + 10;\nconst int LG = 17;\nvector<vector<int>> g(MAXN);\nint tim = 0;\nint parent[LG][MAXN];\nint tin[MAXN], tout[MAXN], level[MAXN];\nvoid dfs(int u, int par = -1 , int lvl = 0) {\n tin[u] = ++tim;\n parent[0][u] = par;\n level[u] = lvl;\n for(auto x : g[u]) {\n if(x == par)\n continue;\n dfs(x, u, lvl + 1);\n }\n tout[k] = tim;\n}\n\nvoid precompute() {\n for(int i = 1 ; i < LG ; i++)\n for(int j = 0 ; j < N; j++)\n if(parent[i-1][j] != -1)\n parent[i][j] = parent[i-1][parent[i-1][j]];\n}\n\nint LCA(int u, int v) {\n if(level[u] < level[v])\n swap(u,v);\n int diff = level[u] - level[v];\n for(int i = LG - 1 ; i >= 0 ; i--) {\n if((1<<i) & diff) {\n u = parent[i][u];\n }\n }\n if(u == v)\n return u;\n for(int i = LG - 1 ; i >=0 ; i--) {\n if(parent[i][u] != -1 && parent[i][u] != parent[i][v]) {\n u = parent[i][u];\n v = parent[i][v];\n }\n }\n return parent[0][u];\n}\n
matrix=const int sz = 3;\nstruct vec{\n int arr[SZ];\n void reset(){\n memset(arr , 0 , sizeof(arr));\n }\n};\nstruct matrix{\n int arr[SZ][SZ];\n void reset(){\n memset(arr , 0 , sizeof(arr));\n }\n void makeiden(){\n reset();\n for(int i = 0 ; i < SZ ; ++i){\n arr[i][i] = 1;\n }\n }\n matrix operator + (const matrix &o) const {\n matrix res;\n for(int i = 0 ; i < SZ ; ++i){\n for(int j = 0 ; j < SZ ; ++j){\n res.arr[i][j] = arr[i][j] + o.arr[i][j];\n res.arr[i][j] -= (res.arr[i][j] >= mod) * mod;\n }\n }\n return res;\n }\n matrix operator * (const matrix &o) const {\n matrix res;\n for(int i = 0 ; i < SZ ; ++i){\n for(int j = 0 ; j < SZ ; ++j){\n res.arr[i][j] = 0;\n for(int k = 0 ; k < SZ ; ++k){\n res.arr[i][j] = (res.arr[i][j] + 1LL * arr[i][k] * o.arr[k][j]) % mod;\n }\n }\n }\n return res;\n }\n vec operator * (const vec &o) const {\n vec res;\n for(int i = 0 ; i < SZ ; ++i){\n res.arr[i] = 0;\n for(int k = 0 ; k < SZ ; ++k){\n res.arr[i] = (res.arr[i] + 1LL * arr[i][k] * o.arr[k]) % mod;\n }\n }\n return res;\n }\n};\n
mulmod=int mmul(int a,int b) { \n int res = 0; \n a %= MOD; \n while (b) { \n if (b & 1) \n res = (res + a) % MOD; \n a = (2 * a) % MOD; \n b >>= 1; // b = b / 2 \n } \n return res; \n} \n
[Java]
if=if (%cursor%)%block_cursor%
else=else%block_cursor%
for=for (int i = 0; i < %cursor%; i++)%brace_open%\n%brace_close%
while=while (%cursor%)%block_cursor%
do=do\n{\n\t%cursor%\n} while (%cursor%)\n
switch=switch (%cursor%)%brace_open%case %cursor%:\n\t\t%cursor%\n\t\tbreak;\n\tdefault:\n\t\t%cursor%\n%brace_close%
try=try%block%\ncatch (%cursor%)%block_cursor%
[PHP]
if=if (%cursor%)%block_cursor%
else=else%block_cursor%
for=for ($i = 0; $i < %cursor%; $i++)%brace_open%\n%brace_close%
while=while (%cursor%)%block_cursor%
do=do\n{\n\t%cursor%\n} while (%cursor%)\n
switch=switch (%cursor%)%brace_open%case %cursor%:\n\t\t%cursor%\n\t\tbreak;\n\tdefault:\n\t\t%cursor%\n%brace_close%
try=try%block%\ncatch (%cursor%)%block_cursor%
[Javascript]
if=if (%cursor%)%block_cursor%
else=else%block_cursor%
for=for (i = 0; i < %cursor%; i++)%block_cursor%
while=while (%cursor%)%block_cursor%
do=do\n{\n\t%cursor%\n} while (%cursor%)\n
switch=switch (%cursor%)%brace_open%case %cursor%:\n\t\t%cursor%\n\t\tbreak;\n\tdefault:\n\t\t%cursor%\n%brace_close%
try=try%block%\ncatch (%cursor%)%block_cursor%
[C#]
if=if (%cursor%)%block_cursor%
else=else%block_cursor%
for=for (i = 0; i < %cursor%; i++)%block_cursor%
while=while (%cursor%)%block_cursor%
do=do\n{\n\t%cursor%\n} while (%cursor%)\n
switch=switch (%cursor%)%brace_open%case %cursor%:\n\t\t%cursor%\n\t\tbreak;\n\tdefault:\n\t\t%cursor%\n%brace_close%
try=try%block%\ncatch (%cursor%)%block_cursor%
[Vala]
if=if (%cursor%)%block_cursor%
else=else%block_cursor%
for=for (i = 0; i < %cursor%; i++)%block_cursor%
while=while (%cursor%)%block_cursor%
do=do\n{\n\t%cursor%\n} while (%cursor%)\n
switch=switch (%cursor%)%brace_open%case %cursor%:\n\t\t%cursor%\n\t\tbreak;\n\tdefault:\n\t\t%cursor%\n%brace_close%
try=try%block%\ncatch (%cursor%)%block_cursor%
[ActionScript]
if=if (%cursor%)%block_cursor%
else=else%block_cursor%
for=for (i = 0; i < %cursor%; i++)%block_cursor%
while=while (%cursor%)%block_cursor%
do=do\n{\n\t%cursor%\n} while (%cursor%)\n
switch=switch (%cursor%)%brace_open%case %cursor%:\n\t\t%cursor%\n\t\tbreak;\n\tdefault:\n\t\t%cursor%\n%brace_close%
try=try%block%\ncatch (%cursor%)%block_cursor%
[Python]
for=for i in xrange(%cursor%):\n\t
if=if %cursor%:\n\t
elif=elif %cursor%:\n\t
else=else:\n\t
while=while %cursor%:\n\t
try=try:\n\t%cursor%\nexcept Exception, ex:\n\t
with=with %cursor%:\n\t
def=def %cursor% (%cursor%):\n\t""" Function doc """\n\t
class=class %cursor%:\n\t""" Class doc """\n\t\n\tdef __init__ (self):\n\t\t""" Class initialiser """\n\t\tpass
[Ferite]
iferr=iferr%block_cursor%fix%block%
monitor=monitor%block_cursor%handle%block%
[Haskell]
[HTML]
table=<table>\n\t<tr>\n\t\t<td>%cursor%</td>\n\t</tr>\n</table>
[Erlang]
case=case %cursor% of\n\t%cursor% -> %cursor%\nend
if=if\n\t%cursor% -> %cursor%\nend
begin=begin\n\t%cursor%\nend
fun=fun(%cursor%) ->\n\t%cursor%\nend
try=try %cursor% of\n\t%cursor% ->\n\t%cursor%\ncatch\n\t%cursor% ->\n\t%cursor%\nend
module=-module(%cursor%).
export=-export(%cursor%).
compile=-compile(%cursor%).
include=-include(%cursor%).