text stringlengths 49 983k |
|---|
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5e5 + 10, MAXM = 2e6 + 10;
const int INF = INT_MAX, SINF = 0x3f3f3f3f;
const long long llINF = LLONG_MAX;
const int MOD = 1e9 + 7, mod = 998244353;
long long tr[MAXN], tot, n, t[MAXN];
void add(int x, long long val) {
while (x <= n) {
tr[x] += val;
... |
#include <bits/stdc++.h>
using namespace std;
int b[200005], m;
long long c[200005][2];
struct node {
int x, v;
bool operator<(const node t) const { return x < t.x; }
} a[200005];
int lsh(long long x) { return lower_bound(b + 1, b + 1 + m, x) - b; }
long long query(int x, int k) {
long long ret = 0;
for (int i ... |
#include <bits/stdc++.h>
using namespace std;
const long long mx = 105;
const long long mod = 1000000007;
const long long maxn = 1e17;
vector<long long> v1;
vector<long long> v2;
long long get(long long x, long long vt) {
long long i, j, k;
long long res = 0;
for (i = x; i > 0; i -= (i & -i)) {
if (vt == 1) {... |
#include <bits/stdc++.h>
using namespace std;
void dout() { cerr << '\n'; }
template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
cerr << " " << H;
dout(T...);
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N = 2e5 + 7;
int n, m, cnt[N];
long long sum[N];
pair<i... |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5;
int m;
long long val[maxn + 11];
int cnt[maxn + 11];
pair<int, int> p[maxn + 11];
vector<int> v;
int lowbit(int x) { return x & (-x); }
void add(int x, int o) {
for (; x <= m; x += lowbit(x)) {
cnt[x] += 1;
val[x] += o;
}
}
pair<int, long l... |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 5;
pair<int, int> p[maxn];
int n;
long long d[maxn];
long long e[maxn];
void add(long long *c, int i, int k) {
while (i <= n) {
c[i] += k;
i += i & (-i);
}
}
long long sum(long long *c, int i) {
long long res = 0;
while (i > 0) {
r... |
#include <bits/stdc++.h>
using namespace std;
long long BIT[200009][4], N = 200009, n, ans, I;
struct st {
long long x, v;
} a[200009];
bool cmp(st a, st b) {
if (a.v == b.v) return a.x > b.x;
return a.v > b.v;
}
bool cmp2(st a, st b) {
if (a.v == b.v) return a.x > b.x;
return a.v > b.v;
}
set<long long> s;
m... |
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 7;
pair<int, int> p[N];
struct fenwick {
long long fen[N];
void add(int first, int d) {
for (int i = first + 1; i < N; i += i & -i) {
fen[i] += d;
}
}
long long sum(int first) {
long long ans = 0;
for (int i = first + 1; i; ... |
#include <bits/stdc++.h>
using namespace std;
vector<pair<long long, long long>> t;
pair<long long, long long> get(long long v, long long l, long long r,
long long a, long long b) {
if (l > b || a > r) {
return {0, 0};
}
if (a <= l && r <= b) {
return t[v];
}
long long m... |
#include <bits/stdc++.h>
using namespace std;
int b[200005], m;
long long c[200005][2];
struct node {
int x, v;
bool operator<(const node t) const { return x < t.x; }
} a[200005];
int lsh(long long x) { return lower_bound(b + 1, b + 1 + m, x) - b; }
long long query(int x, int k) {
long long ret = 0;
for (int i ... |
#include <bits/stdc++.h>
using namespace std;
struct segtree {
long long int M = 1, INIT;
vector<long long int> dat;
segtree(long long int N, long long int num) {
INIT = num;
while (M < N) M *= 2;
for (int i = 0; i < M * 2 - 1; i++) dat.push_back(num);
}
void update(long long int x, long long int ... |
#include <bits/stdc++.h>
using namespace std;
vector<vector<pair<long long, long long>>> mt(4 * 200005);
vector<pair<long long, long long>> a;
void buildTree(long long idx, long long second, long long se) {
if (second == se) {
mt[idx].push_back({a[second].second, a[second].first});
return;
}
long long mid... |
#include <bits/stdc++.h>
using namespace std;
int num[800005], m;
long long b[200005], sum[200005], cnt[200005], tr[800005];
struct node {
int x, v;
bool operator<(const node t) const { return x < t.x; }
} a[200005];
int lsh(long long x) { return lower_bound(b + 1, b + 1 + m, x) - b; }
void build(int l, int r, int ... |
#include <bits/stdc++.h>
using namespace std;
template <class T>
class BIT {
private:
vector<T> dat;
int n;
public:
BIT(int _n) : dat(_n + 1), n(_n) {}
T sum(int i) {
T s = 0;
while (i > 0) s += dat[i], i -= i & -i;
return s;
}
T sum(int l, int r) { return l > r ? 0 : sum(r) - sum(l - 1); }
... |
#include <bits/stdc++.h>
using namespace std;
int n;
long long bit[200005][2];
void update(int x, long long val) {
for (int i = x; i <= n; i += (i & -i)) bit[i][0] += val;
for (int i = x; i <= n; i += (i & -i)) bit[i][1] += 1;
}
pair<long long, long long> query(int x) {
long long ret1 = 0;
long long ret2 = 0;
... |
#include <bits/stdc++.h>
using namespace std;
map<int, int> mp;
set<int> st;
set<int>::iterator it;
pair<int, int> arr[200005];
pair<long long, long long> tree[4 * 200005];
void update(int node, int b, int e, int i, long long v) {
if (b > i || e < i) return;
if (b == e && b == i) {
tree[node].first += v;
tr... |
#include <bits/stdc++.h>
using namespace std;
struct node {
int loc, v;
} a[200010];
int n, m, b[200010];
long long c[200010], e[200010];
int cmp(node a, node b) { return a.loc < b.loc; }
int lowbit(int x) { return x & -x; }
void update(int pos, int delta, long long *d) {
for (int i = pos; i <= n; i += lowbit(i)) d... |
#include <bits/stdc++.h>
using namespace std;
void dout() { cerr << '\n'; }
template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
cerr << " " << H;
dout(T...);
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N = 2e5 + 7;
int n, m, cnt[N];
long long sum[N];
pair<i... |
#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fll;
const int MAX = 2e5 + 10;
vector<pair<int, int>> v(MAX);
vector<int> spdv(MAX), compress(MAX);
long long n, bit[2][MAX];
void poe(int a, long long x, long long p) {
for (; p <= n; p += p & -p) bit[a]... |
#include <bits/stdc++.h>
using namespace std;
long long ts[(int)8e5 + 10], tc[(int)8e5 + 10], n;
pair<long long, long long> o[(int)2e5 + 10];
void update(long long i, long long v, long long t = 1, long long nl = 1,
long long nr = n) {
if (i < nl || nr < i) return;
if (nl == nr) {
ts[t] += v;
tc[... |
#include <bits/stdc++.h>
using namespace std;
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};
long long gcd(long long a, long long b) {
for (; b; a %= b, swap(a, b))
;
return a;
}
const int N = 200002;
pair<long long, long long> segTree[N * 4];
vector<long long> vIdx;
void update(int ptr, int s, int e, in... |
#include <bits/stdc++.h>
using namespace std;
template <class T>
using minheap = priority_queue<T, vector<T>, greater<T>>;
template <typename T>
void setmax(T& a, T b) {
a = max(a, b);
};
template <typename T>
void setmin(T& a, T b) {
a = min(a, b);
};
template <typename T>
bool in(T v, T lo, T hi) {
return lo <=... |
#include <bits/stdc++.h>
using namespace std;
long long int n, bit1[200050], bit2[200050];
vector<pair<long long int, long long int> > arr(200050);
map<long long int, long long int> mp;
long long int get1(int idx) {
long long int ans = 0;
while (idx > 0) {
ans += bit1[idx];
idx -= (idx & -idx);
}
return... |
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
pair<int, int> p[N];
long long sum[N];
long long ans = 0;
int n;
pair<long long, long long> tree[N];
inline int lowbit(int x) { return x & (-x); }
void update(int x, int v) {
while (x <= n) {
tree[x].first++;
tree[x].second += v;
x += lo... |
#include <bits/stdc++.h>
using namespace std;
mt19937_64 mt_rnd_64(chrono::steady_clock::now().time_since_epoch().count());
long long rnd(long long l, long long r) {
return (mt_rnd_64() % (r - l + 1)) + l;
}
using ll = long long;
using ld = long double;
using ull = unsigned long long;
const double PI = acos(-1.0);
co... |
#include <bits/stdc++.h>
using namespace std;
long long n;
pair<long long, long long> a[200001];
long long cnt[200001], sum[200001];
void update(long long x, long long val) {
for (; x <= 200000; x += x & (-x)) {
cnt[x]++;
sum[x] += val;
}
}
long long query(long long x, long long val) {
long long ans = 0;
... |
#include <bits/stdc++.h>
using namespace std;
vector<pair<long long, long long>> t[2 * 200004];
vector<long long> tpre[2 * 200004];
long long ans = 0;
int cntlo = 0, cnthi = 0;
void build(int n) {
for (int i = n - 1; i > 0; i--)
merge(t[i << 1].begin(), t[i << 1].end(), t[i << 1 | 1].begin(),
t[i << 1 |... |
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 7;
int n;
long long ans = 0;
vector<long long> T1(N, 0), T2(N, 0);
pair<int, int> a[N];
vector<int> b;
void update(vector<long long>& T, int x, long long v) {
for (; x <= (int)b.size(); x += (x & (-x))) T[x] += v;
}
long long get(const vector<long long... |
#include <bits/stdc++.h>
using namespace std;
const long long N = 200005;
long long n;
pair<long long, long long> x[N];
long long ans;
struct seg {
long long vals[2 * N];
long long q(long long l, long long r) {
long long ret = 0;
for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
if (l & 1) ret += vals[l... |
#include <bits/stdc++.h>
using namespace std;
struct seg {
vector<long long> tree;
int n;
seg(int n) {
tree = vector<long long>(n);
for (int i = 0; i < n; i++) tree[i] = 0;
}
void update(int node, int l, int r, int x, int y) {
if (l > r) return;
if (x > r || x < l) return;
if (l == x && r ... |
#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
int n;
long long ans;
pair<long long, long long> a[N];
bool cmp(pair<long long, long long> x, pair<long long, long long> y) {
if (x.second != y.second) {
return x.second < y.second;
} else {
return x.first < y.first;
}
}
vector<long long>... |
#include <bits/stdc++.h>
using namespace std;
vector<pair<long long, long long> > v;
vector<long long> v1;
long long a[200005], b[200005], c[200005], d[200005], n, m;
map<long long, long long> mp;
long long get(long long f[], long long pos) {
long long res = 0;
for (; pos >= 0; pos = (pos & (pos + 1)) - 1) res += f... |
#include <bits/stdc++.h>
using namespace std;
template <class c>
struct rge {
c b, e;
};
template <class c>
rge<c> range(c i, c j) {
return rge<c>{i, j};
}
template <class c>
auto dud(c* x) -> decltype(cerr << *x, 0);
template <class c>
char dud(...);
struct debug {
template <class c>
debug& operator<<(const c&... |
#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 bit[1000005], bit1[1000005];
long long sum(long long x) {
long long s = 0;
while (x > 0) {
s += bit[x];
x -= (x & (-x));
}
return s;
}
void update(long long x, long l... |
#include <bits/stdc++.h>
using namespace std;
bool test_cases_exist = false;
class FenwickTree {
public:
vector<long long int> tree;
long long int n;
FenwickTree(long long int n) {
this->n = n;
tree.resize(n + 5);
}
void update(long long int ind, long long int delta) {
while (ind <= n) {
tr... |
#include <bits/stdc++.h>
using namespace std;
int b[200005], m;
long long c[200005][2];
struct node {
int x, v;
bool operator<(const node t) const { return x < t.x; }
} a[200005];
int lsh(int x) { return lower_bound(b + 1, b + 1 + m, x) - b; }
long long query(int x, int k) {
long long ret = 0;
for (int i = x; i... |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 4e5 + 1000;
pair<long long, long long> p[maxn];
vector<long long> v;
int getpos(long long V) {
return lower_bound(v.begin(), v.end(), V) - v.begin() + 1;
}
long long C1[2][maxn];
long long C2[2][maxn];
void add(int x, long long K, long long C[][maxn], int... |
#include <bits/stdc++.h>
using namespace std;
struct Scanner {
bool hasNext = 1;
bool hasRead = 1;
int nextInt() {
hasRead = 0;
int res = 0;
char flag = 1, ch = getchar();
while (ch != EOF && !isdigit(ch)) {
hasRead = 1;
flag = (ch == '-') ? -flag : flag;
ch = getchar();
}
... |
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pr = pair<T, T>;
const int mod = 1e9 + 7;
struct SegTree {
vector<pr<long long>> segtree;
long long N;
SegTree(long long n) {
N = 1;
while (N < n) N <<= 1;
segtree = vector<pr<long long>>(2 * N);
}
void modify(long long k, l... |
#include <bits/stdc++.h>
using namespace std;
template <typename T>
struct BIT {
int n;
vector<T> bit;
BIT(int n_ = 0) : n(n_), bit(n_ + 1) {}
T sum(int i) {
T ans = 0;
for (; i > 0; i -= i & -i) ans += bit[i];
return ans;
}
void add(int i, T a) {
if (i == 0) return;
for (; i <= n; i += ... |
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
struct FTDown {
long long ft[N + 5];
FTDown() {
for (int i = 1; i <= N; i++) ft[i] = 0;
}
void update(int p, long long v) {
for (; p <= N; p += (p & -p)) ft[p] += v;
}
long long get(int p) {
long long sum = 0;
for (; p; p -... |
#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 1000;
const long long M = 1e5 + 10;
const long long inf = 1e9 + 7;
const long long Mod = 1e9 + 7;
const double eps = 1e-6;
int T;
pair<int, int> a[N];
int b[N];
int n;
pair<long long, long long> sg[4 * N];
void build(int k, int l, int r) {
if (l ... |
#include <bits/stdc++.h>
using namespace std;
pair<long long, long long> o[(int)2e5 + 10];
long long n, ts[(int)2e5 + 10], tc[(int)2e5 + 10];
int main(void) {
scanf("%lld", &n);
for (int i = 0; i < n; i++) {
scanf("%lld", &o[i].second);
}
for (int i = 0; i < n; i++) {
scanf("%lld", &o[i].first);
}
s... |
#include <bits/stdc++.h>
using namespace std;
int n, T;
long long cnt[200010], sum[200010];
pair<int, int> a[200010];
long long getval(long long f[], int pos) {
pos++;
long long ans = 0;
for (int i = pos; i > 0; i -= (i & -i)) ans += f[i];
return ans;
}
void upd(long long f[], int pos, int val) {
pos++;
for... |
#include <bits/stdc++.h>
using namespace std;
int n;
const int maxn = 2e5 + 10;
inline int lowbit(int x) { return x & (-x); }
struct point {
int x, v;
} p[maxn];
int v[maxn];
long long c1[maxn], c2[maxn];
bool comp(point a, point b) { return a.x < b.x; }
long long getnum(long long c[], int i) {
long long res = 0LL;... |
#include <bits/stdc++.h>
using namespace std;
using namespace std;
long long st[800001], st2[800001];
vector<long long> vx[200001], idxs[200001];
long long getMid(long long s, long long e) { return s + (e - s) / 2; }
long long SumUtil(long long* st, long long ss, long long se, long long l,
long long r... |
#include <bits/stdc++.h>
using namespace std;
template <class Ch, class Tr, class Container>
basic_ostream<Ch, Tr>& operator<<(basic_ostream<Ch, Tr>& os,
Container const& x) {
os << "{ ";
for (auto& y : x) os << y << " ";
return os << "}";
}
template <class X, class Y>
ostream& o... |
#include <bits/stdc++.h>
using namespace std;
vector<vector<long long> > mtree, msum, mpos;
void merge_sort(vector<pair<long long, long long> >& arr, long long l,
long long h, long long id) {
long long m = (l + h) / 2;
if (l == h) {
mtree[id].push_back(arr[l].second);
msum[id].push_back(arr[... |
#include <bits/stdc++.h>
using namespace std;
int b[200005], cnt[200005], num[800005], m;
long long sum[200005], tr[800005];
struct node {
int x, v;
bool operator<(const node t) const { return x < t.x; }
} a[200005];
int lsh(long long x) { return lower_bound(b + 1, b + 1 + m, x) - b; }
void build(int l, int r, int ... |
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
void update(vector<long long>& v, long long ind, long long val) {
ind++;
long long n = v.size();
while (ind <= n) {
v[ind] += val;
ind += ((ind) & (-ind));
}
}
long long query(vector<long long>& v, long long ind) {
ind++;
long long r... |
#include <bits/stdc++.h>
using namespace std;
pair<int, long long> a[200005];
int t[200005];
map<int, int> M;
pair<int, long long> f[200005];
int n;
void update(int gt) {
int x = M[gt];
while (x <= n) {
f[x] = {f[x].first + 1, f[x].second + gt};
x += (x & -x);
}
}
pair<int, long long> get(int x) {
int c... |
#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
cerr << name << " : " << arg1 << '\n';
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
const char* comma = strchr(names + 1, ',');
cerr.write(nam... |
#include <bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
const long long INF = 1e18;
const int maxn = 1e6 + 6;
const int mod = 1e9 + 7;
const double eps = 1e-9;
inline bool read(long long &num) {
char in;
bool IsN = false;
in = getchar();
if (in == EOF) return false;
while (in != '-' && (in < '0'... |
#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 5;
long long Bit[N][2], n;
long long get(long long i, long long k) {
long long ans = 0;
for (i; i > 0; i -= i & (-i)) {
ans += Bit[i][k];
}
return ans;
}
void update(long long i, long long val, long long k) {
for (i; i <= n; i += i & ... |
#include <bits/stdc++.h>
using namespace std;
const int64_t INF = (int64_t)(2e18);
const int64_t inf = (int64_t)(1e9 + 7);
struct stree {
vector<int64_t> t;
int64_t n = 1;
stree() {}
stree(int64_t nn) {
while (n < nn) n *= 2;
t.assign(2 * n, 0);
}
void set(int64_t i, int64_t x) {
t[i += n] += x;... |
#include <bits/stdc++.h>
using namespace std;
template <class T>
bool uin(T& a, T b) {
return a > b ? (a = b, true) : false;
}
template <class T>
bool uax(T& a, T b) {
return a < b ? (a = b, true) : false;
}
template <typename T>
class fenwick {
public:
vector<T> fenw;
int n;
fenwick(int _n) : n(_n) { fenw.r... |
#include <bits/stdc++.h>
using namespace std;
template <typename Monoid>
struct SegmentTree {
typedef function<Monoid(Monoid, Monoid)> F;
int n;
F f;
Monoid id;
vector<Monoid> dat;
SegmentTree(int n_, F f, Monoid id) : f(f), id(id) { init(n_); }
void init(int n_) {
n = 1;
while (n < n_) n <<= 1;
... |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 3;
const int maxm = 1e6 + 3;
const int mod = 1e9 + 7;
const int oo = 1e9 + 5;
const long double pi = 3.141592653589793238462643383279502884;
void input() {
if (fopen("abc"
".inp",
"r")) {
freopen(
"abc"
".... |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll ftget(vector<ll> &ft, ll idx) {
ll ans = 0;
while (idx > 0) {
ans += ft[idx];
idx -= (idx & (-idx));
}
return ans;
}
void ftput(vector<ll> &ft, ll idx, ll value) {
while (idx < ft.size()) {
ft[idx] += value;
idx += (idx & (... |
#include <bits/stdc++.h>
using namespace std;
const long long int inf = 1e18, M = 1e9 + 7;
const long long int N = 2e5 + 10;
vector<pair<long long int, long long int> > tree(4 * N, make_pair(0, 0));
map<long long int, long long int> mp;
pair<long long int, long long int> combine(
pair<long long int, long long int> ... |
#include <bits/stdc++.h>
using namespace std;
const int M = 200005;
int n, m, w[M];
long long ans, c[M][2];
struct node {
int x, v;
} p[M];
bool cmp(node a, node b) { return a.x < b.x; }
long long query(int x, int t) {
long long r = 0;
for (int i = x; i; i -= i & -i) r += c[i][t];
return r;
}
void upd(int x, in... |
#include <bits/stdc++.h>
using namespace std;
int n, op;
pair<long long, int> tree[201000];
pair<long long, int> q[201000];
long long a[201000];
int lowbits(int x) { return x & (-x); }
void add(long long x, int pos) {
while (pos <= n) {
tree[pos].first += x;
tree[pos].second++;
pos += lowbits(pos);
}
}
... |
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("no-stack-protector")
using namespace std;
const int inf = 1e9 + 7;
const int max_n = 2e5 + 1;
struct fenwick {
vector<int> sum;
fenwick(int n) {
sum.clear();
sum.resize(n, 0);
}
int f(int v) { return (v & (v + 1)); }
int h(int v... |
#include <bits/stdc++.h>
using rmain = int;
using namespace std;
long long n;
vector<pair<long long, long long>> points;
vector<long long> v, cnt, xs;
long long LSOne(long long k) { return (k & (-k)); }
void update(vector<long long>& f, long long pos, long long val) {
for (; pos <= n; pos += LSOne(pos)) f[pos] += val... |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
const long long mod = 998244353;
int T, n;
struct node {
long long d, v;
friend bool operator<(node a, node b) { return a.d < b.d; }
} a[maxn];
long long c[maxn], d[maxn];
int b[maxn];
void update(int x, int y) {
for (int i = x; i <= n; i += ... |
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 7;
pair<int, int> p[N];
long long cnt[N << 2], val[N << 2];
void update(int a, int b, int l, int r, int rt, int v) {
if (a <= l && b >= r) {
val[rt] += v, cnt[rt]++;
return;
}
int mid = l + r >> 1;
if (a <= mid) update(a, b, l, mid, rt <<... |
#include <bits/stdc++.h>
using namespace std;
struct fenwick {
long long N;
vector<long long> Bit;
fenwick(long long n = 1e5) {
N = n;
n += 5;
Bit.resize(n, 0);
}
void update(long long id, long long val) {
while (id <= N) {
Bit[id] += val;
id += id & -id;
}
}
long long quer... |
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 7;
const int MOD = 1e9 + 7;
template <class T>
bool umin(T& a, T b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
template <class T>
bool umax(T& a, T b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T>
bool um... |
#include <bits/stdc++.h>
using namespace std;
void FastInputOutput() {
ios_base ::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
inline int D() {
int t;
scanf("%d", &t);
return t;
}
inline long long LLD() {
long long t;
scanf("%lld", &t);
return t;
}
long long gcd(long long a, long long b) { return b ... |
#include <bits/stdc++.h>
using namespace std;
const int kMaxN = 200001;
struct E {
int x, v, w;
bool operator<(const E &e) const { return x < e.x; }
} e[kMaxN];
struct T {
long long c, v;
} t[kMaxN];
int a[kMaxN];
int n;
long long ans;
int LowBit(int x) { return x & (-x); }
void Calc(int x) {
t[0] = {0, 0};
w... |
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200200;
int n;
long long ans, bit[2][MAXN];
pair<int, int> a[MAXN];
void compress() {
map<int, int> m;
for (int i = 1; i <= n; ++i) m[a[i].second];
int cnt = 1;
for (auto& [key, val] : m) val = cnt++;
for (int i = 1; i <= n; ++i) a[i].second = m[a... |
#include <bits/stdc++.h>
using namespace std;
struct Pt {
int x, v;
bool operator<(const Pt &a) const { return x < a.x; }
};
struct BIT {
vector<long long> bit, cnt;
int n;
BIT(int sz) {
bit.resize(sz + 1);
cnt.resize(sz + 1);
n = sz;
}
void add(int x, long long v) {
while (x <= n) {
... |
#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
const double EPS = 1e-6;
const int INF = 0x3f3f3f3f;
const int MAXN = 200005;
int n, m;
int maps[MAXN];
long long sum[MAXN][2];
pair<long long, long long> node[MAXN];
inline long long lowbit(long long x) { return x & (-x); }
void add(long long ... |
#include <bits/stdc++.h>
using namespace std;
const int INF32 = 1E9;
const long long INF64 = 4E18;
const long long M = 1E9 + 7;
const double EPS = 1E-9;
const double PI = 2 * acos(0);
vector<long long> suffix_sum(1E6);
bool cmp_v(pair<long long, long long> a, pair<long long, long long> b) {
return (a.second < b.secon... |
#include <bits/stdc++.h>
using namespace std;
long long gcd(long long x, long long y) {
if (!y) return x;
return gcd(y, x % y);
}
const long long MOD = 1e9 + 7;
int inf = 1e9 + 7;
long long INF = 2e18 + 9;
long long power(long long x, long long y) {
long long res = 1ll;
x %= MOD;
if (x == 0) return 0;
while... |
#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1);
const int N = 2e5 + 5, mod = 998244353, M = 1e7 + 7;
const long long MAX = 5e18;
int n;
pair<int, int> a[N];
long long ans;
struct BIT {
long long s[N][2], sum[2];
void init() {
memset(s, 0, sizeof s);
sum[0] = sum[1] = 0;
}
void ... |
#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int MX = 4e5 + 7;
int n;
long long c[MX][2];
int v[MX];
struct p {
int x, v;
inline bool operator<(const p& w) const { return x < w.x; }
} a[MX];
inline int lowbit(int x) { return x & -x; }
void add(int pos, long long k) {
while (pos ... |
#include <bits/stdc++.h>
using namespace std;
const long long N = 2e6 + 7;
const long long INF = 1e18;
long long n, k, q, st[N][2];
pair<long long, long long> p[N];
map<long long, bool> m;
bool comp(pair<long long, long long>& a, pair<long long, long long>& b) {
if (a.second == b.second) return a.first < b.first;
r... |
#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
struct {
int l, r;
long long sum;
long long cnt;
} A[N * 4];
pair<pair<long long, long long>, int> pt[N];
int n;
bool cmp(pair<pair<long long, long long>, int> x1,
pair<pair<long long, long long>, int> x2) {
return x1.first.first < x2.... |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
constexpr int MAXN = 5 + 200000;
struct Bit {
ll b[MAXN];
Bit() { fill(b, b + MAXN, 0); }
void upd(int x, ll val) {
for (; x < MAXN; x += (x & -x)) b[x] += val;
}
ll query(int x) {
ll ans = 0LL;
for (; x... |
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 100011;
const long long INF = (1 << 29) + 123;
const long long MOD = 1000000007;
const long double PI = 4 * atan((long double)1);
int fenw[2 * MAX_N];
int n;
void mod(int i, int v) {
while (i <= n) {
fenw[i] += v;
i += i & -i;
}
}
int query(int... |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
struct nod {
long long x, v;
} a[maxn];
bool cmp(nod p, nod q) { return p.x < q.x; }
int L = 0, R = 2e8, rt = 0, tot = 0;
class dsegtree {
public:
struct dsegnode {
int l, r;
long long sum1, sum2;
} node[maxn * 50];
void pushup(int... |
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5;
int N;
pair<long long, long long> A[MAXN + 10];
long long ans;
vector<long long> comp;
long long tree1[MAXN + 10];
void update1(int i, long long v) {
for (; i <= N; i += (i & -i)) tree1[i] += v;
}
long long query1(int i) {
long long ret = 0;
for ... |
#include <bits/stdc++.h>
using namespace std;
long long int ans = 0;
void merger(vector<pair<long long int, long long int> > &v, long long int l,
long long int mid, long long int r) {
long long int n1 = mid - l + 1, n2 = r - mid;
pair<long long int, long long int> larr[n1], rarr[n2];
long long int lsu... |
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int n, m, pos, v[N];
long long tot, s[N][2];
struct node {
long long x, v;
} a[N];
bool cmp(node x, node y) { return x.x < y.x; }
int lowbit(int x) { return x & (-x); }
void update(int x, int val) {
while (x <= n) {
s[x][0]++;
s[x][1] += v... |
#include <bits/stdc++.h>
using namespace std;
long long get(vector<long long> &f, int pos) {
long long res = 0;
for (; pos >= 0; pos = (pos & (pos + 1)) - 1) res += f[pos];
return res;
}
void upd(vector<long long> &f, int pos, int val) {
for (; pos < int(f.size()); pos |= pos + 1) {
f[pos] += val;
}
}
int... |
#include <bits/stdc++.h>
using namespace std;
struct OrderSet {
struct Trie {
int cnt;
int next[2];
Trie() {
memset(next, -1, sizeof(next));
cnt = 0;
}
};
vector<Trie*> trie;
OrderSet() {
auto u = new Trie();
trie.push_back(u);
}
bool find(int first) {
int cur = 0;
... |
#include <bits/stdc++.h>
using namespace std;
long long get(vector<long long> &f, int pos) {
long long res = 0;
for (; pos >= 0; pos = (pos & (pos + 1)) - 1) res += f[pos];
return res;
}
void upd(vector<long long> &f, int pos, int val) {
for (; pos < int(f.size()); pos |= pos + 1) {
f[pos] += val;
}
}
int... |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 4e5 + 1000;
pair<long long, long long> p[maxn];
vector<long long> v;
int getpos(long long V) {
return lower_bound(v.begin(), v.end(), V) - v.begin() + 1;
}
long long C[2][maxn];
void add(int x, long long K) {
while (0 < x && x < maxn) {
C[0][x] += 1... |
#include <bits/stdc++.h>
using namespace std;
const long long maxn = 2e5 + 10;
const long long maxX = 2e8 + 10;
long long n;
long long sz = 1;
pair<long long, long long> p[maxn];
long long segsum[25 * maxn];
long long segtedad[25 * maxn];
long long L[25 * maxn];
long long R[25 * maxn];
long long ans;
void in();
void so... |
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e9 + 7;
const int N = 3e5 + 10;
void init(vector<pair<int, int>>& vp) {
vector<int> v;
for (auto& p : vp) v.push_back(p.second);
sort(v.begin(), v.end());
for (auto& p : vp) {
p.second = lower_bound(v.begin(), v.end(), p.second) - v.begin(... |
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
const int M = 2e3 + 5;
const int mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);
template <class T>
inline void read(T &x) {
char c;
x = 1;
while ((c = getchar()) < '0' || c > '9')
if (c == '-') x = -1;
T res = c - '0';... |
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int bit[N];
void add(int p, int v) {
for (p += 2; p < N; p += p & -p) bit[p] += v;
}
long long query(int p) {
int r = 0;
for (p += 2; p; p -= p & -p) r += bit[p];
return r;
}
int n;
pair<int, int> p[N];
long long l[N], r[N];
int ql[N], qr[N];
... |
#include <bits/stdc++.h>
using namespace std;
long long int g[800010][2];
void up(int l, int r, int n, int x, int i, long long int val) {
if (l == r) {
g[n][i] = val;
} else {
int mid = (l + r) / 2;
if (x <= mid && x >= l)
up(l, mid, 2 * n, x, i, val);
else
up(mid + 1, r, 2 * n + 1, x, i... |
#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,-O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
const int oo = 2e9;
const long long OO = 4e18;
const int md = 0x3b800001;
co... |
#include <bits/stdc++.h>
using namespace std;
template <typename C>
class fenwick {
vector<C> t;
int n;
public:
fenwick(int _n) : n(_n) { t.resize(n); }
fenwick(const vector<C>& a) : n(a.size()) {
t.resize(n);
for (int i = 0; i < n; ++i) {
upd(i, a[i]);
}
}
C get(int k) {
C res = 0;
... |
#include <bits/stdc++.h>
using namespace std;
vector<long long> x, v;
int idX(int val) { return (lower_bound(x.begin(), x.end(), val) - x.begin()); }
int idV(int val) { return (lower_bound(v.begin(), v.end(), val) - v.begin()); }
struct FenwickTree {
vector<long long> bit;
int n;
FenwickTree(int n) {
this->n ... |
#include <bits/stdc++.h>
using namespace std;
struct FT {
vector<long long> f;
FT(long long n) { f.resize(n + 1, 0); }
long long sum(long long r) {
long long res = 0;
for (; r >= 0; r = (r & (r + 1)) - 1) {
res += f[r];
}
return res;
}
long long sum(long long l, long long r) { return sum... |
#include <bits/stdc++.h>
#pragma GCC optimize("fast-math")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC diagnostic ignored "-Woverflow"
using namespace std;
const short INF16 = ~(1 << 15);
const int INF32 = 2e9 + 11;
const int SZ = (1 << 19);
const int SZ2 = int(1e6 + 11);
const int mo... |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = double;
const ll MODBASE = 1000000007LL;
const int MAXN = 200010;
const int MAXM = 1000;
const int MAXK = 16;
const int MAXQ = 200010;
struct Car {
int x, v;
Car(int x = 0, int v = 0) : x(x), v(v) {}
};
bool operator<(Car a, Car b) { ret... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.