text stringlengths 49 983k |
|---|
#include <bits/stdc++.h>
const int inf = INT_MAX;
const int MAX = 3e6 + 9;
const long long MOD = 1e9 + 7;
const int TOT_PRIMES = 1e6 + 9;
const int MAX_A = 71;
const int LN = 20;
using namespace std;
long long bt[MAX];
long long arr[MAX];
void update(int x, long long val) {
for (int i = x; i < MAX; i += i & -i) bt[i]... |
#include <bits/stdc++.h>
using namespace std;
const int N = 200010;
long long fen[N];
void modify(int x, long long v) {
while (x < N) {
fen[x] += v;
x |= x + 1;
}
}
long long get(int x) {
long long r = 0;
while (x >= 0) {
r += fen[x];
x = (x & (x + 1)) - 1;
}
return r;
}
int main() {
ios::... |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 9;
long long s[maxn];
int p[maxn];
int vis[maxn];
int temp;
struct node {
int l, r;
long long minn, lazy;
} tree[maxn << 2];
void BT(int p, int l, int r) {
tree[p].l = l, tree[p].r = r;
if (l == r) {
tree[p].minn = s[l];
tree[p].lazy =... |
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10, eps = 1e-10;
int n;
long long a[N];
long long tree[N];
int ans[N];
long long sum(int x) {
long long res = 0;
while (x) {
res += tree[x];
x -= (x & (-x));
}
return res;
}
void add(int x, long long sum) {
while (x <= n) {
tree[x] ... |
#include <bits/stdc++.h>
using namespace std;
int n;
long long cl[202020];
long long T[202020];
int chk[202020];
int ans[202020];
void m_Tree(int x, int t) {
for (int i = x; i <= n; i += i & (-i)) {
T[i] += t;
}
}
long long g_Tree(int x) {
long long ret = 0;
for (int i = x; i > 0; i -= i & (-i)) ret += T[i]... |
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
const long double PI =
3.141592653589793238462643383279502884197169399375105820974944;
const long long mod = 998244353;
const long long inf = 1e18;
const long long maxn = 1e5 + 5;
struct BIT {
vector<long long> bit;
long long maxn;
void ini... |
#include <bits/stdc++.h>
using namespace std;
vector<unsigned long long> t, lazy;
void build(unsigned long long a[], int v, int tl, int tr) {
if (tl == tr) {
t[v] = a[tl];
} else {
int tm = (tl + tr) / 2;
build(a, v * 2 + 1, tl, tm);
build(a, v * 2 + 2, tm + 1, tr);
t[v] = min(t[v * 2 + 1], t[v ... |
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int MAXN = 2e5 + 5;
const int inf = 0x3f3f3f3f;
long long s[MAXN];
struct node {
int l, r;
long long sum;
} node[MAXN << 2];
void build(int l, int r, int num) {
node[num].l = l;
node[num].r = r;
if (l == r) {
node[num].sum = l;
... |
#include <bits/stdc++.h>
using namespace std;
int n;
long long a[300000], b[300000], C[300000];
int lowbit(int x) { return x & (-x); }
long long getSum(int x) {
long long sum = 0;
for (int i = x; i > 0; i -= lowbit(i)) sum += C[i];
return sum;
}
void add(int x, int val) {
for (int i = x; i < n; i += lowbit(i)) ... |
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
struct node {
long long w, change;
int in;
};
vector<long long> a;
vector<node> t;
const long long INF = 1e18;
node combine(node a, node b, long long change) {
a.w += a.change;
b.w += b.change;
node res;
if (a.w != b.w)
res = (... |
#include <bits/stdc++.h>
using namespace std;
int dx[8] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy[8] = {1, -1, -1, 0, 1, -1, 0, 1};
long long tree[4 * 200005], lazy[4 * 200005], ans[4 * 200005], a[200005];
void build(long long int start, long long int last, long long int node) {
if (start == last) {
tree[node] = a[st... |
#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 5;
long long n, m, s[N], a[N], C[N], vis[N];
long long lowbit(long long x) { return (x & (-x)); }
long long sum(long long x) {
long long res = 0;
while (x > 0) {
res += C[x];
x -= lowbit(x);
}
return res;
}
void add(long long x, lon... |
#include <bits/stdc++.h>
using namespace std;
template <class T>
bool mini(T &a, T b) {
return a > b ? (a = b, true) : false;
}
template <class T>
bool maxi(T &a, T b) {
return a < b ? (a = b, true) : false;
}
const int N = 2e5 + 5;
int n, ans[N];
long long bit[N], p[N];
void up(int i) {
assert(i > 0);
for (lon... |
#include <bits/stdc++.h>
using namespace std;
int n, lo[(long long)(2e5 + 5) * 4], hi[(long long)(2e5 + 5) * 4],
ans[(long long)(2e5 + 5)];
long long base[(long long)(2e5 + 5)], delta[(long long)(2e5 + 5) * 4];
pair<long long, int> mn[(long long)(2e5 + 5) * 4];
void update(int i);
void ini(int i, int a, int b) {
... |
#include <bits/stdc++.h>
using namespace std;
long int n;
long long int tree[200001 * 10];
long int a[200002];
void build(long int node, long int start, long int end) {
if (start == end) {
tree[node] = a[start];
} else {
long int mid = (start + end) / 2;
build(2 * node + 1, start, mid);
build(2 * no... |
#include <bits/stdc++.h>
using namespace std;
const long long Nmax = 2e6 + 5;
long long v[Nmax];
long long ans[Nmax];
long long lazy[4 * Nmax];
pair<long long, long long> all[4 * Nmax];
long long p, q, val;
void add(long long &first, long long val) {
if (first != LLONG_MAX) first += val;
}
void propagate(long long no... |
#include <bits/stdc++.h>
using namespace std;
int n;
int z[200020];
long long a[200020];
long long c[200020];
void R(int x, int y) {
for (; x <= n; x += x & -x) {
c[x] += y;
}
}
int A(long long x) {
int re = 0;
for (int i = 1 << 20; i > 0; i >>= 1) {
if (re + i <= n && c[re + i] <= x) {
x -= c[re ... |
#include <bits/stdc++.h>
using namespace std;
long long t[200025 * 4], lz[200025 * 4], n, a[200025];
void build(int l, int r, int i) {
t[i] = 1ll * l * (l - 1) / 2;
if (l == r) return;
build(l, (l + r) / 2, i * 2 + 1);
build((l + r) / 2 + 1, r, i * 2 + 2);
t[i] = max(t[i * 2 + 1], t[i * 2 + 2]);
}
void down(i... |
#include <bits/stdc++.h>
const int MAXN = 2e5 + 10;
const long long inf = 1e17 + 10;
using namespace std;
struct Seg {
long long v[MAXN * 4], lazy[MAXN * 4];
int m(int l, int r) { return (l + r) / 2; }
void updPoint(int pos, int l, int r, int x, long long val) {
if (l == r) {
v[pos] = val;
return;... |
#include <bits/stdc++.h>
using namespace std;
template <typename Tp>
void read(Tp &x) {
x = 0;
long long f = 1;
char c = getchar();
while (c > '9' || c < '0') {
if (c == '-') {
f = -1;
}
c = getchar();
}
while (c >= '0' && c <= '9') {
x = (x << 1) + (x << 3) + (c ^ 48);
c = getchar... |
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
const long long INF = 1e16 + 239;
const int MAXN = 1e6 + 239;
long long a[MAXN];
namespace SegmentTree {
int n;
long long t[4 * MAXN];
long long mod[4 * MAXN];
void pull(int v) { t[v] = min(t[2 * v + 1], t[2 * v + 2]); }
void apply(int v, long ... |
#include <bits/stdc++.h>
using namespace std;
long long n, ar[200005], br[200005], up[800555], dr[100];
pair<long long, long long> tr[800555];
void build(long long, long long, long long),
update(long long, long long, long long, long long),
upd(long long, long long, long long, long long, long long, long long);
i... |
#include <bits/stdc++.h>
using namespace std;
long long bit[200005];
void add(long long idx, long long val) {
for (int i = idx; i < 200005; i += (i & (-i))) {
bit[i] += val;
}
}
long long query(long long i) {
long long ans = 0;
for (; i > 0; i -= (i & (-i))) ans += bit[i];
return ans;
}
long long b[200005... |
#include <bits/stdc++.h>
using namespace std;
const long long MM = 10000000000000001;
int n;
long long a[200005];
int rs[200005];
long long lazy[4 * 200005];
pair<long long, int> it[4 * 200005];
pair<long long, int> minp(pair<long long, int> A, pair<long long, int> B) {
if (A.first < B.first) return A;
if (A.first ... |
#include <bits/stdc++.h>
using namespace std;
int n;
long long s[200066];
long long c[200066];
long long ans[200066];
long long lowbit(long long x) { return x & (-x); }
long long q(long long x) {
long long ans = 0;
while (x > 0) {
ans += c[x];
x -= lowbit(x);
}
return ans;
}
void update(long long x, lon... |
#include <bits/stdc++.h>
using namespace std;
const int MAXN = (int)2E5;
long long arr[MAXN + 1];
long long sum[MAXN + 1];
long long bit[MAXN + 1];
int ans[MAXN + 1];
long long query(int x) {
long long ans = 0;
while (x > 0) {
ans += bit[x];
x -= x & -x;
}
return ans;
}
void increment(int x, int amt, in... |
#include <bits/stdc++.h>
using namespace std;
const int MX = 200005;
vector<int> v;
long long n, a[MX], w[MX], tree[MX * 4 + 5];
long long con(int num, int nodeL, int nodeR) {
if (nodeL == nodeR) return tree[num] = w[nodeL];
long long mid = (nodeL + nodeR) / 2;
return tree[num] =
con(num * 2, nodeL, ... |
#include <bits/stdc++.h>
using namespace std;
const int M = 200010;
struct BIT {
long long tree[M];
BIT() { memset(tree, 0, sizeof tree); }
void update(int idx, int val) {
while (idx < M) {
tree[idx] += val;
idx += idx & (-idx);
}
}
long long query(int idx) {
long long sum = 0;
whi... |
#include <bits/stdc++.h>
using namespace std;
const int max_n = 200222;
const long long inf = 1000111222000111222LL;
struct tree {
long long mx[4 * max_n], add[4 * max_n];
tree() {
memset(mx, 0, sizeof(mx));
memset(add, 0, sizeof(add));
}
void push(int v) {
if (add[v]) {
mx[2 * v] += add[v];
... |
#include <bits/stdc++.h>
const int inf = INT_MAX;
const int MAX = 3e6 + 9;
const long long MOD = 1e9 + 7;
const int TOT_PRIMES = 1e6 + 9;
const int MAX_A = 71;
const int LN = 20;
using namespace std;
long long bt[MAX];
long long arr[MAX];
void update(int x, long long val) {
for (int i = x; i < MAX; i += i & -i) bt[i]... |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
inline ll read();
const int M = 500016, MOD = 1000000007;
struct BinaryIndexTree {
ll bit[M], n;
inline void modify(ll p, ll x) {
for (; p <= n; p += p & -p) bit[p] += x;
}
inline ll sum(ll p) {
ll res = 0;
for (; p; p -= p & -p) re... |
#include <bits/stdc++.h>
using namespace std;
const double PI = 3.141592653589793;
const long long I_MAX = 1LL << 60;
long long mod = 1000000007;
const long long maxN = 2E5;
vector<long long> inv(maxN + 5, 1);
vector<long long> fac(maxN + 5, 1);
void ADD(long long &x, long long y) {
x += y;
if (x >= mod) x -= mod;
... |
#include <bits/stdc++.h>
using namespace std;
int n;
long long ar[200005];
long long tree[800005];
long long valr[800005];
long long lazy[800005];
long long ans[200005];
int gl = 0;
long long h;
void build(int node, int start, int end) {
if (start == end) {
tree[node] = ar[start];
valr[node] = start;
} else... |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
const int maxN = 1e6 + 10;
ll tree[4 * maxN];
int n, p[maxN];
ll s[maxN];
void update(int x, int l, int r, int k, int w) {
if (l == r)
tree[x] = w;
else {
int mid = (l + r) / 2;
if (k <= mid)
update(2 * x, ... |
#include <bits/stdc++.h>
using namespace std;
pair<long long, long long> t[4 * 200009];
long long a[200009], lazy[4 * 200009], ans[200009];
void build(long long v, long long tl, long long tr) {
if (tl == tr) {
t[v] = {a[tl], tl};
} else {
long long tm = (tl + tr) / 2;
build(v * 2, tl, tm);
build(v *... |
#include <bits/stdc++.h>
using namespace std;
long long good_rand() { return rand() * RAND_MAX + rand(); }
template <class A>
class myvector : public std::vector<A> {
public:
A &operator[](int pos) {
if (pos < 0) pos = 0;
while (this->size() <= pos) {
this->push_back({});
}
return std::vector<A... |
#include <bits/stdc++.h>
using namespace std;
long long n;
long long s[200005], p[200005];
long long t[200005];
long long lowbit(long long x) {
return x & (-x);
if (14209 > 9243) {
if (31558 > 31075) {
bool ZENBDJUSHQ;
ZENBDJUSHQ = 28821;
if (21853 > 13000) {
if (11380 > 20609) {
... |
#include <bits/stdc++.h>
using namespace std;
inline int read() {
int x = 0, f = 1, c = getchar();
for (; !isdigit(c); c = getchar())
if (c == '-') f ^= 1;
for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
return f ? x : -x;
}
struct BIT {
long long sum[200005];
void upd(int x, int v) {
for (;... |
#include <bits/stdc++.h>
using namespace std;
const int LIM = 1e5 + 5, MOD = 1e9 + 7;
const int maxn = 1000006;
long long solve(long long a, long long b) {
if ((a == b) || (a == 0)) {
return 0;
} else {
long long res;
res = 1 + solve(a % (b / 2), b / 2);
return res;
}
}
long long ft[200005];
long ... |
#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f, N = 2e5 + 5;
inline int read() {
int sum = 0, f = 1;
char c = getchar();
while (c > '9' || c < '0') {
if (c == '-') f = -f;
c = getchar();
}
while (c >= '0' && c <= '9') sum = sum * 10 + c - 48, c = getchar();
return sum * f;
... |
#include <bits/stdc++.h>
#pragma GCC optimize "O3"
using namespace std;
const int inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3f;
const int N = 2e5 + 5;
const int M = 1 << 18;
pair<long long, int> tree[M * 2 + 5];
long long lazy[M * 2 + 5];
int n, ans[N];
void push(int v) {
tree[v * 2].first += lazy[v];
... |
#include <bits/stdc++.h>
using namespace std;
using pii = pair<long long, int>;
const int maxn = 2e5 + 5;
int n;
long long a[maxn], s[maxn], t[maxn << 2];
void build(int l, int r, int rt) {
if (l == r) {
t[rt] = l;
return;
}
int m = l + r >> 1;
build(l, m, rt << 1);
build(m + 1, r, rt << 1 | 1);
t[r... |
#include <bits/stdc++.h>
using namespace std;
int ans[200005], n;
long long a[200005], aib[200005];
inline void Update(int p, int val) {
while (p <= n) {
aib[p] += val;
p += p & (-p);
}
}
inline long long Sum(int p) {
long long s = 0;
while (p >= 1) {
s += aib[p];
p -= p & (-p);
}
return s;
... |
#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:640000000")
using namespace std;
const double eps = 1e-9;
const double pi = acos(-1.0);
const int maxn = (int)2e5 + 10;
long long a[maxn];
int res[maxn];
long long t[4 * maxn];
void build(int idx, int l, int r) {
if (l == r) {
t[idx] = l;
} else {
int... |
#include <bits/stdc++.h>
using namespace std;
vector<long long> tree;
vector<long long> s;
vector<long long> p;
long long build(long long L, long long R, long long v) {
if (R - L == 1) {
return tree[v] = L + 1;
} else {
return tree[v] = build(L, (L + R) / 2, v * 2 + 1) +
build((L + R) /... |
#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:1000000000")
using namespace std;
const int maxn = (int)2e5 + 10;
int n;
long long v[maxn];
long long t[4 * maxn];
void change(int it, int l, int r, int pos, int x) {
if (l == r) {
t[it] = x;
} else {
int m = (l + r) >> 1;
if (pos <= m) {
ch... |
#include <bits/stdc++.h>
using namespace std;
int T;
long long n;
long long a[333333];
long long twosum[333333];
long long tree[(1LL << 18) * 3];
long long ans[333333];
set<long long> s;
void update(long long x, long long y) {
x += (1LL << 18);
while (x > 0LL) {
tree[x] += y;
x /= 2LL;
}
}
long long sum(i... |
#include <bits/stdc++.h>
using namespace std;
int n, ans[200100];
long long s[200100];
pair<long long, int> seg[800100];
long long lazy[800100];
void build(int l, int r, int ind) {
if (l == r) {
seg[ind] = {s[l], l};
return;
}
int mid = (l + r) / 2;
build(l, mid, ind * 2);
build(mid + 1, r, ind * 2 + ... |
#include <bits/stdc++.h>
using namespace std;
const long long inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3f;
const long long mod = 1e9 + 7;
long long tree[200050 << 2], lazy[200050 << 2], a[200050];
void pushup(long long rt) { tree[rt] = min(tree[rt << 1], tree[rt << 1 | 1]); }
void pushdown(long long rt) ... |
#include <bits/stdc++.h>
using namespace std;
struct BIT {
int size;
vector<long long> bit;
BIT() { size = 0; }
BIT(int s) {
size = s;
bit.resize(size + 1);
init();
}
void init() {
for (int i = 1; i <= size; i++) bit[i] = 0;
}
long long query(long long i) {
long long ret = 0;
whi... |
#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
const long long maxn = 2e5 + 10;
long long n, a[maxn], ans[maxn];
long long read() {
long long x = 0, f = 1;
char ch = getchar();
while (ch < '0' || ch > '9') {
if (ch == '-') f = -1;
ch = getchar();
}
while (ch >= '0' && ch <= ... |
#include <bits/stdc++.h>
using namespace std;
vector<long long> bit(200001);
void update(long long x, long long y, long long n) {
for (long long i = x; i <= n; i = i + (i & (-i))) bit[i] += y;
}
int search(long long x, int n) {
long long ans = 0, sum = 0;
for (int i = 21; i >= 0; i--) {
if (ans + (1LL << i) <... |
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 5;
int n, ans[MAXN], mark[MAXN];
long long s[MAXN], tree[MAXN];
void add(int x, int val) {
for (; x <= n; x += x & -x) tree[x] += val;
}
long long ask(int x) {
long long res = 0;
for (; x; x &= x - 1) res += tree[x];
return res;
}
int main() {... |
#include <bits/stdc++.h>
std::vector<long long> a;
const long long INF = 1000000000000000000LL;
int lm = -1;
std::vector<long long> ts;
long long fill(int l, int r, int i) {
if (l == r) {
ts[i] = a[l];
return a[l];
}
int m = (l + r) / 2;
ts[i] = fill(l, m, i * 2) + fill(m + 1, r, i * 2 + 1);
return ts... |
#include <bits/stdc++.h>
using namespace std;
long long A[300001];
long long tree[300001 * 4 + 2], prop[4 * 300001 + 2], ans[300001];
void create(long long node, long long b, long long e) {
if (b == e) {
tree[node] = A[b];
return;
}
long long l = 2 * node;
long long r = l + 1;
long long m = (b + e) / ... |
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using PII = pair<int, int>;
template <class T>
struct Fenwick {
vector<T> v;
Fenwick(size_t n) : v(n + 1) {}
void add(size_t i, T x) {
for (++i; i < v.size(); i += i & -i) v[i] += x;
}
T sum(size_t i) {
for (v[0] = T(); i; i -= i & -i... |
#include <bits/stdc++.h>
using namespace std;
struct BIT {
int n, N_MAX;
vector<long long> v;
BIT(int n) {
this->n = n + 100;
N_MAX = n - 1;
v.assign(n + 110, 0);
}
void upd(int p, int x) {
while (p <= n) v[p] += x, p += p & -p;
}
long long que(int p) {
long long ans = 0;
while (p)... |
#include <bits/stdc++.h>
using namespace std;
void rset();
void init_test();
void solve();
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout << fixed;
cout.precision(20);
init_test();
return 0;
}
template <typename T>
void chmin(T& a, T b) {
if (a > b) a = b;
}
template <typename T>
void chmax... |
#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
int n, b[N];
long long BIT[N], a[N];
int lowbit(int x) { return x & (-x); }
void Add(int x, int y) {
while (x <= n) {
BIT[x] += y;
x += lowbit(x);
}
}
long long Sum(int x) {
long long ans = 0;
while (x) {
ans += BIT[x];
x -= low... |
#include <bits/stdc++.h>
using namespace std;
long long int bit[200005];
int n;
void update(int j, int x) {
for (; j < 200005; j += j & (-j)) bit[j] += x;
}
long long int query(int j) {
if (j == 0) return 0;
long long int x = 0;
for (; j > 0; j -= (j) & (-j)) x += bit[j];
return x;
}
int next_ele(long long in... |
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int n;
long long sum[N], ans[N], cur;
long long seg[1 << 20];
set<int> nw;
void update(int i, int v, int ni = 0, int ns = 0, int ne = n) {
if (ns > i || ne < i || ns > ne) return;
if (ns == ne && ns == i) {
seg[ni] += v;
return;
}
if (... |
#include <bits/stdc++.h>
using namespace std;
int n, a[200005];
long long s[200005];
pair<long long, int> sg[800005];
long long lz[800005];
void Build(int nod, int l, int r) {
sg[nod] = {0, r};
if (l == r) return;
int mid = (l + r) / 2;
Build(2 * nod, l, mid);
Build(2 * nod + 1, mid + 1, r);
}
void Sift(int n... |
#include <bits/stdc++.h>
using namespace std;
namespace fast {
inline char nc() {
static char buf[100000], *L = buf, *R = buf;
return L == R && (R = (L = buf) + fread(buf, 1, 100000, stdin), L == R)
? EOF
: *L++;
}
template <class orz>
inline void qread(orz &x) {
x = 0;
char ch = nc();... |
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int n, ans[N];
long long a[N], bit[N];
void update(int pos) {
for (int i = pos; i < N; i += (i & -i)) {
bit[i] += pos;
}
}
long long query(int pos) {
long long res = 0;
for (int i = pos; i; i -= (i & -i)) {
res += bit[i];
}
return ... |
#include <bits/stdc++.h>
using namespace std;
const long long maxn = 1000005;
const long long inf = 0x3f3f3f3f3f3f3f3f;
const long long MOD = 100000007;
const double eps = 1e-10;
long long qpow(long long a, long long b) {
long long tmp = a % MOD, ans = 1;
while (b) {
if (b & 1) {
ans *= tmp, ans %= MOD;
... |
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("O3")
#pragma GCC optimize("fast-math")
#pragma GCC optimize("Ofast")
using namespace std;
const int INF = 1e9 + 10;
const long long INFll = 2e18;
const int BASE1 = 179;
const int BASE2 = 653;
const long long MOD = 998244353;
const int M... |
#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int grand(int x) { return uniform_int_distribution<int>(0, x - 1)(rng); }
long long getInt() {
bool minus = false;
long long result = 0;
char ch;
ch = getchar();
while (true) {
if (ch == '-')... |
#include <bits/stdc++.h>
using namespace std;
int t, n;
long long s[200005];
long long T[200005 << 2];
void build(int u, int l, int r) {
T[u] = 0;
if (l == r) {
T[u] = l;
return;
}
build((u << 1), l, ((l + r) >> 1));
build((u << 1 | 1), ((l + r) >> 1) + 1, r);
T[u] = T[(u << 1)] + T[(u << 1 | 1)];
}... |
#include <bits/stdc++.h>
using namespace std;
int n;
long long s[200001];
int used[200001];
long long stree[800001];
int result[200001];
long long update(int node, int l, int r, int index, long long diff) {
if (r < index || index < l) return stree[node];
if (r == l) {
stree[node] += diff;
return stree[node]... |
#include <bits/stdc++.h>
using namespace std;
template <class T>
bool mini(T &a, T b) {
return a > b ? (a = b, true) : false;
}
template <class T>
bool maxi(T &a, T b) {
return a < b ? (a = b, true) : false;
}
const int N = 2e5 + 5;
int n, ans[N];
long long bit[N], p[N];
void up(int i, int val) {
assert(i > 0);
... |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
const long long INF = 1e18;
int n;
long long a[maxn], ans[maxn];
long long tree[maxn << 2], laz[maxn << 2];
void pushup(int rt) { tree[rt] = min(tree[rt << 1], tree[(rt << 1) | 1]); }
void build(int l, int r, int rt) {
if (l == r) {
tree[rt] ... |
#include <bits/stdc++.h>
inline long long minn(long long a, long long b) {
if (a < b) return a;
return b;
}
const int MAXN = 2e5 + 5;
const long long INF = 1ll << 60;
int n;
long long mi[MAXN << 2], tag[MAXN << 2];
inline void pushdwn(int k) {
mi[k << 1] -= tag[k];
tag[k << 1] += tag[k];
mi[k << 1 | 1] -= tag... |
#include <bits/stdc++.h>
using namespace std;
struct S {
int a, b;
S() {}
S(int _a, int _b) {
a = _a;
b = _b;
}
const bool operator<(const S &o) const { return a < o.a; }
};
string exm;
inline void exf(void) {
cout << exm << "\n";
exit(0);
}
template <typename T>
inline void showAll(vector<T> &v, ... |
#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
long long a[N];
pair<long long, long long> seg[4 * N];
void build(long long ind, long long l, long long r) {
if (l > r) return;
if (l == r) {
seg[ind] = {a[l], l};
return;
}
long long mid = (l + r) / 2;
build(2 * ind + 1, l, mid);
b... |
#include <bits/stdc++.h>
using namespace std;
long long n;
long long s[200001], up[200001];
long long d[200001], c[200001];
long long ans[200001];
inline long long lowbit(long long x) { return x & -x; }
inline long long getup(long long x) {
long long ans = 0;
for (; x; x -= lowbit(x)) ans += c[x];
return ans;
}
i... |
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
template <class T, class U>
inline void add_self(T &a, U b) {
a += b;
if (a >= mod) a -= mod;
if (a < 0) a += mod;
}
template <class T, class U>
inline void min_self(T &x, U y) {
if (y < x) x = y;
}
template <class T, class U>
inline void ma... |
#include <bits/stdc++.h>
using namespace std;
const int M = 2e5 + 10;
const long long inf = 1e15 + 10;
const long long mod = 1e9 + 7;
set<int> s;
long long a[M], ans[M];
long long sum[4 * M], lazy[4 * M];
int v[M * 4];
void pushup(int x) { sum[x] = min(sum[x << 1], sum[x << 1 | 1]); }
void built(int l, int r, int i) {
... |
#include <bits/stdc++.h>
using namespace std;
const int MN = 200010;
int n;
long long ft[MN];
void update(int pos, long long by) {
while (pos < n) ft[pos] += by, pos |= pos + 1;
}
long long query(int pos) {
long long ans = 0;
while (pos >= 0) ans += ft[pos], pos = (pos & (pos + 1)) - 1;
return ans;
}
int main()... |
#include <bits/stdc++.h>
using namespace std;
int n, p[200005], mnpos[1 << 19];
long long s[200005], mn[1 << 19], add[1 << 19];
void pushup(int u) {
mn[u] = mn[u << 1 | 1], mnpos[u] = mnpos[u << 1 | 1];
if (mn[u << 1] < mn[u]) mn[u] = mn[u << 1], mnpos[u] = mnpos[u << 1];
}
void build(int u, int l, int r) {
if (l... |
#include <bits/stdc++.h>
using namespace std;
const int N = 200001;
long long pre[N] = {};
void add(long long p, long long x) {
for (long long i = p; i <= N; i += (i & -i)) pre[i] += x;
}
long long query(long long p) {
long long ans = 0;
for (long long i = p; i > 0; i -= i & (-i)) ans += pre[i];
return ans;
}
i... |
#include <bits/stdc++.h>
using namespace std;
void solve();
int32_t main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
;
int t = 1;
for (int i = 1; i <= t; ++i) solve();
cerr << "Time taken: " << ((clock() * 1000) / CLOCKS_PER_SEC) << "ms\n";
}
const long long int N = 2e5 + 2;
long long int t... |
#include <bits/stdc++.h>
using namespace std;
struct BIT {
int n, N_MAX;
vector<long long> v;
BIT(int n) {
this->n = n + 100;
N_MAX = n;
v.assign(n + 110, 0);
}
void upd(int p, int x) {
while (p <= n) v[p] += x, p += p & -p;
}
long long que(int p) {
long long ans = 0;
while (p) ans... |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
const long long inf = 1e14;
int n;
long long a[maxn], ans[maxn];
struct SegmentTree {
long long tr[maxn << 2], tag[maxn << 2];
void pushup(int rt) { tr[rt] = min(tr[rt << 1], tr[rt << 1 | 1]); }
void build(int rt, int l, int r) {
tag[rt]... |
#include <bits/stdc++.h>
using namespace std;
inline long long read() {
long long x = 0, f = 1;
char ch = getchar();
while (ch < '0' || ch > '9') {
if (ch == '-') f = -1;
ch = getchar();
}
while (ch >= '0' && ch <= '9') {
x = (x << 3) + (x << 1) + (ch ^ '0');
ch = getchar();
}
return x * f... |
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
long long BIT[N], s[N];
int n;
int ans[N];
void update(int x, int delta) {
for (; x <= n; x += x & -x) BIT[x] += delta;
}
long long query(int x) {
long long sum = 0;
for (; x > 0; x -= x & -x) sum += BIT[x];
return sum;
}
int searchNumber(long... |
#include <bits/stdc++.h>
using namespace std;
template <class X, class Y>
bool minimize(X &x, const Y &y) {
X eps = 1e-9;
if (x > y + eps) {
x = y;
return true;
} else
return false;
}
template <class X, class Y>
bool maximize(X &x, const Y &y) {
X eps = 1e-9;
if (x + eps < y) {
x = y;
retu... |
#include <bits/stdc++.h>
using namespace std;
long long n;
long long s[200010];
long long a[200010];
long long cnt[200010];
long long p[200010];
long long lb(long long x) { return x & (-x); }
void ins(int x, int y) {
for (long long i = x; i <= n; i += lb(i)) {
p[i] += y;
}
return;
}
long long gs(int x) {
lo... |
#include <bits/stdc++.h>
using namespace std;
long long dx[] = {1, 0, -1, 0};
long long dy[] = {0, 1, 0, -1};
long long gcd(long long x, long long y) {
if (y == 0)
return x;
else
return gcd(y, x % y);
}
long long expo(long long n, long long m, long long p) {
long long r = 1;
n = n % p;
while (m > 0) {... |
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
long long arr[N];
int n;
int lowbit(int x) { return x & -x; }
void addv(int p, long long val) {
while (p <= n) {
arr[p] += val;
p += lowbit(p);
}
}
void add(int l, int r, long long val) {
addv(l, val);
addv(r + 1, -val);
}
long long g... |
#include <bits/stdc++.h>
using namespace std;
struct Node {
long long l, r, rt, lz, minn, maxx;
} node[1008611];
long long a[200861], sum[400861];
long long ans[200861];
void build(long long l, long long r, long long rt) {
long long mid = (l + r) / 2;
node[rt].l = l, node[rt].r = r;
node[rt].lz = 0;
if (l == ... |
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
const int MAXN = 2e5 + 20;
const int SIZE = (1 << 19) + 20;
long long s[MAXN];
int ans[MAXN];
struct Segment_tree {
struct Node {
int sl, sr;
long long val;
} tree[SIZE];
inline void update(int root) {
tree[root].val = tree[(r... |
#include <bits/stdc++.h>
using namespace std;
template <class T>
bool tomin(T &x, T y) {
return y < x ? x = y, 1 : 0;
}
template <class T>
bool tomax(T &x, T y) {
return x < y ? x = y, 1 : 0;
}
template <class T>
void read(T &x) {
char c;
x = 0;
int f = 1;
while (c = getchar(), c < '0' || c > '9')
if (c... |
#include <bits/stdc++.h>
using namespace std;
long long int bit[200005];
int n;
void update(int j, int x) {
for (; j < 200005; j += j & (-j)) bit[j] += x;
}
long long int query(int j) {
if (j == 0) return 0;
long long int x = 0;
for (; j > 0; j -= (j) & (-j)) x += bit[j];
return x;
}
int next_ele(long long in... |
#include <bits/stdc++.h>
using namespace std;
const long long mxN = 2e5 + 10;
long long a[mxN], v[mxN];
long long N;
long long ans[mxN];
void upd(long long x, long long v) {
for (long long i = x; i <= N; i += i & -i) a[i] += v;
}
long long sum(long long x) {
long long S = 0;
for (long long i = x; i; i -= i & -i) ... |
#include <bits/stdc++.h>
using namespace std;
long long n;
class fenwicktree {
public:
long long n;
long long b[200005];
fenwicktree(long long N) {
n = N;
for (long long i = 0; i <= n; i++) b[i] = 0;
}
long long sum(long long idx) {
long long ret = 0;
for (idx; idx > 0; idx -= (idx & -idx)) r... |
#include <bits/stdc++.h>
const int N = 1e6 + 10;
const long long int INF = 1e18;
const int MOD = 998244353;
const int lgN = 20;
using namespace std;
long long int tree[4 * N], lz[4 * N], v[N], w[N];
void build(int node, int st, int en) {
lz[node] = 0;
if (st == en) {
tree[node] = v[st];
return;
}
int m ... |
#include <bits/stdc++.h>
using namespace std;
const int N = 200004;
long long s[N], p[N];
int n, a[N];
void add(int x, int v) {
for (int i = x; i <= n; i += (i & -i)) s[i] += v;
}
long long que(int x) {
long long ans = 0;
for (int i = x; i; i -= (i & -i)) ans += s[i];
return ans;
}
int main() {
scanf("%d", &n... |
#include <bits/stdc++.h>
using namespace std;
const long long N = 2 * 1e5 + 3;
const long long INF = INT_MAX;
const long long NEINF = INT_MIN;
const long long MOD = 1e9 + 7;
long long Add(long long x, long long y) { return (x + y) % MOD; }
long long Mul(long long x, long long y) { return (x * y) % MOD; }
long long BinP... |
#include <bits/stdc++.h>
using namespace std;
struct BigNum {
vector<long long> value;
void set(long long x) {
value = *(new vector<long long>);
value.push_back(x);
}
void duplicate(BigNum other) { value = other.value; }
void add(BigNum other) {
vector<long long> o = other.value;
if (o.size() ... |
#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e17;
struct node {
long long ans, sub;
node() : ans(0), sub(0){};
};
struct SegmentTree {
long long N;
vector<node> st;
vector<long long> a;
long long left(long long p) { return p << 1; }
long long right(long long p) { return (p << 1) + ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.