-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate.cpp
236 lines (207 loc) · 5.65 KB
/
template.cpp
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
#include <algorithm>
#include <algorithm>
#include <iostream>
#include <memory.h>
#include <numeric>
#include <sstream>
#include <iterator>
#include <cassert>
#include <fstream>
#include <cstdlib>
#include <vector>
#include <cstdio>
#include <string>
#include <queue>
#include <deque>
#include <cmath>
#include <ctime>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <complex>
// HLIB ARSENIUK
// TEMPLATE VERSION 3.0.2
// DESCRIPTION:
// Main template that I'm using in CP :>
// 2024 y.
// '*UUUUUwUUUUU*'
// 'q1-H-+-X---M-'
// 'q2-H-X-+--M|-'
// '----------||-'
// 'me--------==-'
/*
▄███████▀▀▀▀▀▀███████▄
░▐████▀▒ЗАПУСКАЕМ▒▀██████▄
░███▀▒▒▒▒▒ДЯДЮ▒▒▒▒▒▒▀█████
░▐██▒▒▒▒▒▒БОГДАНА▒▒▒▒▒████▌
░▐█▌▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒████▌
░░█▒▄▀▀▀▀▀▄▒▒▄▀▀▀▀▀▄▒▐███▌
░░░▐░░░▄▄░░▌▐░░░▄▄░░▌▐███▌
░▄▀▌░░░▀▀░░▌▐░░░▀▀░░▌▒▀▒█▌
░▌▒▀▄░░░░▄▀▒▒▀▄░░░▄▀▒▒▄▀▒▌
░▀▄▐▒▀▀▀▀▒▒▒▒▒▒▀▀▀▒▒▒▒▒▒█
░░░▀▌▒▄██▄▄▄▄████▄▒▒▒▒█▀
░░░░▄██████████████▒▒▐▌
░░░▀███▀▀████▀█████▀▒▌
░░░░░▌▒▒▒▄▒▒▒▄▒▒▒▒▒▒▐
░░░░░▌▒▒▒▒▀▀▀▒▒▒▒▒▒▒▐
TAYA, found in @xoxo@ submissions
*/
// START OF THE TEMPLATE HELL
// Standard types
using ll = long long; // 2^32 - 1
using ld = long double; // 2^32 - 1
using l128 = __int128_t; // 2^128 - 1
using u32 = unsigned; // 2^32 - 1
using u64 = unsigned long long; // 2^64 - 1
using lli = long long int; // 2^63 - 1
// Complex nums
using Com = std::complex<ll>;
#define ComX real()
#define ComY real()
// Some constants
#define INF 1e12 + 7
#define MOD7e9 1e9 + 7;
#define MOD9e12 1e12 + 9;
#define MIN 0
#define EU exp(1.0)
const ld PI = acos((ld)-1);
const int maxNum = 111111111;
// Vectors
template<typename T>
using V = std::vector<T>;
typedef V<int> vi;
typedef V<V<int>> vii;
typedef V<std::string> vs;
typedef V<bool> vb;
typedef V<ll> vl;
typedef V<ld> vd;
typedef V<lli> vli;
typedef V<V<int>> vvi;
typedef V<V<ll>> vvl;
#define sz(x) int(size(x))
#define bg(x) begin(x)
#define all(x) bg(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define sor(x) sort(all(x))
#define rsz resize
#define ins insert
#define pb push_back
#define eb emplace_back
#define ft front()
#define bk back()
// Functions
template<typename T>
ll cdiv(T a, T b) {
return a / b + ((a ^ b) > 0 && a % b);
} // Divide a by b rounded up
template<typename T>
ll fdiv(T a, T b) {
return a / b - ((a ^ b) < 0 && a % b);
} // Divide a by b rounded down
template<typename T>
bool ckmin(T &a, const T &b) {
return b < a ? a = b, 1 : 0;
} // Set a = min(a, b)
template<typename T>
bool ckmax(T &a, const T &b) {
return a < b ? a = b, 1 : 0;
} // Set a = max(a, b)
template<typename T>
void remDup(V<T> &v) {
sort(v.begin(), v.end()); // Sort the elements of the vector
v.erase(unique(v.begin(), v.end()), v.end()); // Remove duplicates
}
template<typename T>
T gdc_euclid(T a, T b) {
while(b > 0) {
ll temp = a/b;
a -= temp*b;
std::swap(a, b);
}
return a;
} // finds greate common div
template<typename T>
T lcd(T a, T b) {
return a / gdc_euclid(a, b) * b;
} // finds least common denominator by gdc euclid
template<typename T>
T factorial(T a) {
if(a == 0) {
return 1;
}
return factorial(a-1) * a;
} // finds factorial
template<typename T>
std::vector<T> divisors(T n) {
std::vector<T> res;
for (T d = 1; d * d <= n; ++d) {
if (n % d == 0) {
res.pb(d);
if (d * d != n) {
res.pb(n / d);
}
}
}
sort(all(res));
return res;
} // finds all divisiors
std::vector<bool> seive_count(int n) {
std::vector<bool> is_prime(n+1, true);
is_prime[0] = is_prime[1] = false;
for (int i = 2; i <= n; i++) {
if (is_prime[i] && (long long)i * i <= n) {
for (int j = i * i; j <= n; j += i)
is_prime[j] = false;
}
}
return is_prime;
} // prime numbers
bool is_prime_number(int n) {
if(n<2) {
return false;
}
for(int x = 2; x*x <= n; x++) {
if(n%x == 0) {
return false;
}
}
return true;
} // is_prime
struct pair_hash {
template <class T1, class T2>
std::size_t operator () (const std::pair<T1, T2> &pair) const {
auto h1 = std::hash<T1>{}(pair.first);
auto h2 = std::hash<T2>{}(pair.second);
return h1 ^ h2;
}
}; // pair hash
// Pairs
#define f first
#define s second
#define mkp make_pair
typedef std::pair<int, int> pii;
// Fors
#define FOR(i,a,b) for (int _n(b), i(a); i <= _n; i++)
#define FORD(i,b,a) for (int _n(b), i(a); i <= _n; i--)
#define REP(i,n) for (int i = 0; i < n; i++)
#define trav(a,x) for (auto &a : x)
// file output/input
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
using namespace std;
// ###$=-----------------+=:|| MAIN ||:=+-----------------=$### //
void solve() {
return;
}
int main() {
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
ios_base::sync_with_stdio(0);
solve();
return 0;
}