solution stringlengths 11 983k | difficulty int64 0 21 | language stringclasses 2
values |
|---|---|---|
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long INF = 4e18 + 10;
long long power(long long a, long long b, long long in_mod) {
long long ans = 1;
long long prod = a;
while (b) {
if (b % 2) ans = (ans * prod) % in_mod;
prod = (prod * prod) % in_mod;
b /= 2;
... | 12 | CPP |
#include <bits/stdc++.h>
using namespace std;
const int Z = (int)1e3 + 228;
const int N = (int)2e5 + 228;
const int INF = (int)1e9 + 228;
const int MOD = (int)998244353;
const long long LLINF = (long long)1e18 + 228;
const long double eps = (long double)1e-6;
pair<long long, long long> t[4 * N];
void update(int v, int ... | 12 | CPP |
#include <bits/stdc++.h>
using namespace std;
const int mxn = 2e5 + 100;
pair<int, long long> a[mxn];
long long r[mxn], b1[mxn], b2[mxn], ans;
void add(long long *b, int idx, int val, int n) {
for (; idx <= n; idx += idx & -idx) b[idx] += val;
}
long long ask(long long *b, int idx) {
long long ret = 0;
for (; idx... | 12 | CPP |
#include <bits/stdc++.h>
using namespace std;
long long ans, n, a1[202020], a2[202020], od[202020];
pair<long long, long long> p[202020];
map<long long, long long> mp;
void gx1(long long x, long long v) {
for (long long i = x; i < 200200; i += i & -i) {
a1[i] += v;
}
}
void gx2(long long x, long long v) {
for... | 12 | CPP |
import sys
input = sys.stdin.readline
from heapq import heappush, heappop, heapify
def query(f, i):
ret = [0, 0]
while i:
ret[0] += f[i][0]
ret[1] += f[i][1]
i -= (i & -i)
return ret
def update(f, i, d):
n = len(f)
while i < n:
f[i][0] += d[0]
f[i][1] += d[... | 12 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
int dddx[] = {1, -1, 0, 0, 1, 1, -1, -1};
int dddy[] = {0, 0, 1, -1, 1, -1, 1, -1};
vector<pair<long long int, long long int> > vec;
int n;
long long int tree[(int)(2 * 1e5 + 1)], tree2[(int)(2 * 1e5 + 1)];
void atualiza(i... | 12 | CPP |
#include <bits/stdc++.h>
using namespace std;
struct hash_pair {
template <class T1, class T2>
size_t operator()(const pair<T1, T2>& p) const {
auto hash1 = hash<T1>{}(p.first);
auto hash2 = hash<T2>{}(p.second);
return hash1 ^ hash2;
}
};
bool prime[10000001];
long long P = 1000000007 - 2;
long long ... | 12 | CPP |
import bisect
import sys
class ft:
def __init__(self,n):
self.a = [0]*(200000)
self.n = n
def qry(self,r):
ret = 0
while r>=0:
ret+=self.a[r]
r=(r&(r+1))-1
return ret
def upd(self,i,v):
while i<self.n:
self.a[i]+=v
... | 12 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
long long int savev[maxn];
struct node {
long long int x, v;
node(){};
node(long long int x, long long int v) : x(x), v(v){};
bool operator<(const node& n) const { return x < n.x; }
} save[maxn];
map<long long int, long long int> getv;
lon... | 12 | CPP |
#include <bits/stdc++.h>
using namespace std;
long long max(long long a, long long b) { return a > b ? a : b; }
void swap(long long& a, long long& b) {
long long tmp = a;
a = b;
b = tmp;
}
long long t, n;
long long x[200006], v[200006];
pair<long long, long long> xv[200006];
long long prfxSum[200006];
pair<long l... | 12 | CPP |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
struct Node {
int x, v;
bool operator<(const Node &rhs) const { return x < rhs.x; }
} p[maxn];
int b[maxn], n, to;
long long t[maxn], tt[maxn];
inline int lowbit(int x) { return x & -x; }
void update(long long *t, int x, int v) {
for (; x <=... | 12 | CPP |
#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... | 12 | CPP |
# ---------------------------iye ha aam zindegi---------------------------------------------
import math
import heapq, bisect
import sys
from collections import deque, defaultdict
from fractions import Fraction
import sys
#import threading
from collections import defaultdict
#threading.stack_size(10**8)
mod = 10 ** 9 +... | 12 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
int n;
pair<int, int> a[maxn];
int m;
vector<int> v;
struct fenwick {
long long val[maxn];
void init() { fill(begin(val), end(val), 0); }
void upd(int x, int k) {
for (; x < maxn; x += x & -x) val[x] += k;
}
long long get(int x) {
... | 12 | CPP |
#include <bits/stdc++.h>
using namespace std;
int N;
pair<signed long long, signed long long> P[202020];
pair<signed long long, signed long long> Q[202020];
template <class V, int ME>
class BIT {
public:
V bit[1 << ME];
V operator()(int e) {
if (e < 0) return 0;
V s = 0;
e++;
while (e) s += bit[e -... | 12 | CPP |
#include <bits/stdc++.h>
using namespace std;
bool comp(pair<long long, long long> p1, pair<long long, long long> p2) {
if (p1.second == p2.second) return p1.first < p2.first;
return p1.second < p2.second;
}
signed main() {
long long n;
cin >> n;
vector<pair<long long, long long> > v(n);
for (long long i = ... | 12 | CPP |
#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... | 12 | CPP |
#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 (long long i = 0; i < n; i++) {
scanf("%lld", &o[i].second);
}
for (long long i = 0; i < n; i++) {
scanf("%lld", &o[i].fir... | 12 | CPP |
#include <bits/stdc++.h>
using namespace std;
const long long maxn = 200000 + 50;
const long long LIM = 17;
const long long INF = (long long)1e9 + 7;
long long N;
long long h[maxn];
long long sum[maxn << 1], cnt[maxn << 1];
struct node {
long long x, v;
} a[maxn];
bool cmp(const node& a, const node& b) { return a.x <... | 12 | CPP |
#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... | 12 | CPP |
#include <bits/stdc++.h>
using namespace std;
struct tree {
tree* l;
tree* r;
long long sum;
long long cnt;
tree() {
l = r = nullptr;
sum = cnt = 0;
}
}* rt = new tree;
tree* get_l(tree* v) {
if (!v->l) {
v->l = new tree;
}
return v->l;
}
tree* get_r(tree* v) {
if (!v->r) {
v->r = ne... | 12 | CPP |
#include <bits/stdc++.h>
using namespace std;
const int MAX_SIZE = 200010;
pair<int, int> arr[MAX_SIZE], backup[MAX_SIZE];
long long prefix[MAX_SIZE];
int N;
void sortX(int l, int r) {
if (l >= r) return;
int mi = (l + r) / 2;
sortX(l, mi);
sortX(mi + 1, r);
int i = l, j = mi + 1, k = l;
while (i <= mi && j... | 12 | CPP |
#include <bits/stdc++.h>
int xx[200000], vv[200000];
int compare_v(const void *a, const void *b) {
int i = *(int *)a;
int j = *(int *)b;
return vv[i] - vv[j];
}
int compare_x(const void *a, const void *b) {
int i = *(int *)a;
int j = *(int *)b;
return xx[i] - xx[j];
}
void sort(int *ii, int n, int (*compare... | 12 | CPP |
import sys
input = sys.stdin.readline
from collections import defaultdict
def compress(l):
l = list(set(l))
l.sort()
idx = defaultdict(int)
c = 0
for li in l:
idx[li] = c
c += 1
return idx
class BIT:
#n:要素数
def __init__(self, n):
self.n = n
... | 12 | PYTHON3 |
#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> bt[N];
pair<long long, long long> query(int first) {
... | 12 | CPP |
#include <bits/stdc++.h>
using namespace std;
struct treap {
treap* l = nullptr;
treap* r = nullptr;
long long int pos;
long long int vel;
long long int y;
long long int sum;
int ch;
static long long int s(treap* A) {
if (A == nullptr) return 0;
return A->sum;
}
static int c(treap* A) {
... | 12 | CPP |
#include <bits/stdc++.h>
using namespace std;
struct Node {
int X, V;
inline friend bool operator<(Node x, Node y) {
if (x.V == y.V) {
return x.X < y.X;
}
return x.V < y.V;
}
} p[200000];
map<int, int> A;
set<int> B;
int ct;
long long c1[200001];
int c2[200001];
inline void Add(int x, int d) {
... | 12 | CPP |
#include <bits/stdc++.h>
using namespace std;
long long n, m, ans[200005 << 2], tag[200005 << 2], cnt[200005 << 2],
tagg[200005 << 2];
struct p {
long long x, v, vv;
} a[200005];
int cmp(p a, p b) { return a.v < b.v; }
int cmpp(p a, p b) { return a.x < b.x; }
inline long long ls(long long x) { return x << 1; }
in... | 12 | CPP |
#include <bits/stdc++.h>
using namespace std;
struct data {
long long x, v, pos;
} p[200005];
struct seg {
long long val, cnt;
} f[1000005];
long n;
bool cmp(data a, data b) {
if (a.v == b.v)
return a.x < b.x;
else
return a.v < b.v;
}
bool cmp2(data a, data b) { return a.x < b.x; }
void update(long id, ... | 12 | CPP |
#include <bits/stdc++.h>
using namespace std;
long long int MOD = 100000007;
long long int MX = 1000000000;
long long int n;
pair<long long int, long long int> a[200200];
map<long long int, long long int> sor;
map<long long int, long long int> val;
long long int tree[600005];
long long int lazy[600005];
long long int t... | 12 | CPP |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10, mod = 1e9 + 7, INF = 0x3f3f3f3f;
long long fwk[maxn], cnt[maxn];
void upd(int p, int c) {
for (; p < maxn; p += p & -p) fwk[p] += c, cnt[p]++;
}
void qry(int p, long long& sum, long long& c) {
sum = c = 0;
for (; p; p -= p & -p) sum += fwk[p... | 12 | CPP |
#include <bits/stdc++.h>
using namespace std;
constexpr long long maxN = 2e5 + 43;
long long n;
vector<pair<long long, long long>> point;
vector<long long> val, cnt, cval;
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 += LSOn... | 12 | CPP |
#include <bits/stdc++.h>
using namespace std;
int MOD = 1000000000 + 7;
long long int inverse(long long int i) {
if (i == 1) return 1;
return (MOD - ((MOD / i) * inverse(MOD % i)) % MOD + MOD) % MOD;
}
long long int calc(vector<pair<long long int, long long int>>& v1, int st,
int fn) {
if (fn -... | 12 | CPP |
#include <bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pli = pair<ll, int>;
using pii = pair<int, int>;
constexpr ll mod = 1e9 + 7;
constexpr int N = 200010;
struct node {
ll x;
int v, id;
bool operator<(const node &o) const { return x < o... | 12 | CPP |
#include <bits/stdc++.h>
using namespace std;
const int M = 2e5 + 5;
int n, t[M], k;
long long ans;
struct node {
long long p;
int v;
} a[M];
struct BIT {
long long s[M];
void add(int i, long long x) {
for (; i <= k; i += i & -i) s[i] += x;
}
long long ask(int i) {
long long res = 0;
for (; i > ... | 12 | CPP |
#include <bits/stdc++.h>
using namespace std;
int dx[] = {0, 0, 1, -1, -1, -1, 1, 1};
int dy[] = {1, -1, 0, 0, -1, 1, 1, -1};
template <class T>
inline T biton(T n, T pos) {
return n | ((T)1 << pos);
}
template <class T>
inline T bitoff(T n, T pos) {
return n & ~((T)1 << pos);
}
template <class T>
inline T ison(T n... | 12 | CPP |
#include <bits/stdc++.h>
using namespace std;
long long bit1[200005], bit2[200005];
inline void upd(long long idx, long long val, long long bit[]) {
while (idx < 200005) {
bit[idx] += val;
idx += (idx & -idx);
}
}
inline long long que(long long idx, long long bit[]) {
long long ans = 0;
while (idx > 0) ... | 12 | CPP |
#include <bits/stdc++.h>
using namespace std;
long long n;
pair<long long, long long> p[200005];
long long v[200005];
map<long long, long long> m;
long long f0[200005];
long long f1[200005];
void up0(long long x, long long val) {
for (long long i = x; i <= 200000; i += i & -i) f0[i] += val;
}
void up1(long long x, lo... | 12 | CPP |
#include <bits/stdc++.h>
int dr[] = {2, 2, -2, -2, 1, -1, 1, -1};
int dc[] = {1, -1, 1, -1, 2, 2, -2, -2};
int dr1[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dc1[] = {1, -1, 1, 0, -1, 0, 1, -1};
int dr2[] = {0, 0, 1, -1};
int dc2[] = {1, -1, 0, 0};
using namespace std;
long long a[200005];
long long dp[200005];
long long tr[... | 12 | CPP |
#include <bits/stdc++.h>
using namespace std;
int tab_x[200000 + 5];
int tab_v[200000 + 5];
long long D_dist[550000 + 5];
int D_ile[550000 + 5];
int zakresy[550000 + 5][2];
int max_pot = 1;
int QUERRY_ile(int L, int R, int w) {
if (zakresy[w][0] > R || L > zakresy[w][1]) return 0;
if (L <= zakresy[w][0] && zakresy[... | 12 | CPP |
def bitadd(a,w,bit):
x = a
while x <= (len(bit)-1):
bit[x] += w
x += x & (-1 * x)
def bitsum(a,bit):
ret = 0
x = a
while x > 0:
ret += bit[x]
x -= x & (-1 * x)
return ret
n = int(input())
x = list(map(int,input().split()))
v = list(map(int,input().split(... | 12 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
const long long md = 1e9 + 7;
const int xn = 2e5 + 10;
const int xm = 5e5;
const int SQ = 750;
const int sq = 1e3 + 10;
const long long inf = 1e18 + 10;
long long power(long long a, long long b) {
return (!b ? 1
: (b & 1 ? a * power(a * a % md, b / 2) % md
... | 12 | CPP |
#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long ppow(long long a, long long b, long long mod) {
a %= mod;
long long ans = 1;
while (b) {
if (b & 1) ans = ans * a % mod;
a = a * a % mod;
b >>= 1;
}
return ans;
}
... | 12 | CPP |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 15;
int tot = 1, N;
const int L = -2e8;
const int R = 2e8;
struct Node {
int l, r, num;
long long sum;
Node() { l = 0, r = 0, num = 0, sum = 0; }
} E[maxn * 40];
struct Point {
long long x, v;
bool operator<(const Point &T) const { return x ... | 12 | CPP |
class Points:
def __init__(self, x = 0, v = 0):
self.x, self.v = x, v
class Fenwick_tree:
def __init__(self, n = 0):
self.n = n
self.bit = [0] * (n + 1)
def update(self, x, value):
while x <= self.n:
self.bit[x] += value
x += x & -x
def get(self... | 12 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 10;
const int MOD = 998244353;
const int INF = 0x3f3f3f3f;
struct Node {
int x;
int v;
} a[MAXN];
bool cmp(Node a, Node b) {
if (a.v == b.v) {
return a.x < b.x;
}
return a.v < b.v;
}
int N, M;
vector<int> dic;
int main() {
int now;
l... | 12 | CPP |
class SegmentTree():
def __init__(self,arr,func,initialRes=0):
self.f=func
self.N=len(arr)
self.tree=[0 for _ in range(4*self.N)]
self.initialRes=initialRes
for i in range(self.N):
self.tree[self.N+i]=arr[i]
for i in range(self.N-1,0,-1):
self... | 12 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
void coordinatecompress(vector<int> &data) {
int n = data.size();
vector<pair<int, int> > tempdata(n);
for (int i = 0; i < n; i++) tempdata[i] = {data[i], i};
sort(tempdata.begin(), tempdata.end());
data[tempdata[0].second] = 0;
for (int i = 1; i < n; i++)
d... | 12 | CPP |
# -*- coding: utf-8 -*-
import sys
from collections import Counter
from bisect import bisect_left
def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[... | 12 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
vector<pair<long long, long long>> v;
long long arr[200005];
map<long long, long long> mp;
map<long long, long long> rmp;
pair<long long, long long> bit[200005];
set<long long> s;
void insert(long long ind) {
for (long long i = ind; i < 200005; i += i & -i)
bit[i].fir... | 12 | CPP |
#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using ... | 12 | CPP |
import sys
input=sys.stdin.readline
def getsum(BITTree,i):
s = 0
while i > 0:
s += BITTree[i]
i -= i & (-i)
return(s)
def updatebit(BITTree , n , i ,v):
while i <= n:
BITTree[i] += v
i += i & (-i)
n=int(input())
x=[int(i) for i in input().split() if i!='\n']
v=[int(i) f... | 12 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
const long long mx = 2 * 1e5 + 5;
const long long mod = 1e9 + 7;
long long sum[mx];
long long num[mx];
void update(int pos, int value) {
while (pos <= mx) {
sum[pos] += value;
num[pos]++;
pos += (pos & -pos);
}
}
pair<int, long long> query(int pos) {
long ... | 12 | CPP |
#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 10;
struct node {
long long a;
long long t;
} w[N];
bool cmp(node a, node b) { return a.a < b.a; }
long long c[N][2], cnt[N], n;
long long lowbit(long long x) { return x & (-x); }
void add(long long x, long long val) {
while (x <= n) c[x][0]+... | 12 | CPP |
#include <bits/stdc++.h>
using namespace std;
class STlazy {
private:
int n;
vector<long long> node, lazy;
public:
STlazy(vector<long long> v) {
int siz = v.size();
n = 1;
while (n < siz) n *= 2;
node.resize(2 * n - 1, 0);
lazy.resize(2 * n - 1, 0);
for (int i = 0; i < siz; i++) node[n ... | 12 | CPP |
#include <bits/stdc++.h>
using namespace std;
const long long maxn = 200005;
map<long long, long long> g;
map<long long, long long> invG;
long long tree[8][maxn];
long long sum(long long k, long long t) {
long long res = 0;
for (long long i = k; i >= 1; i -= i & -i) res += tree[t][i];
return res;
}
void add(long ... | 12 | CPP |
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 22, inf = 1e9 + 7;
int n;
long long s[4 * N], cursum;
vector<pair<int, int> > t[4 * N];
vector<long long> p[4 * N];
pair<int, int> a[N];
void build(int v, int tl, int tr) {
if (tl == tr) {
s[v] = a[tl].first;
t[v].push_back({a[tl].second, a[tl]... | 12 | CPP |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
long long c1[maxn], c2[maxn];
void add(long long *c, int x, int y) {
for (; x < maxn; x += x & -x) c[x] += y;
}
long long ask(long long *c, int x) {
long long ret = 0;
for (; x > 0; x -= x & -x) ret += c[x];
return ret;
}
struct node {
i... | 12 | CPP |
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int n, i;
pair<int, int> dot[N];
long long mergeMoving(pair<int, int> arr[], pair<int, int> temp[], int left,
int right);
long long merge(pair<int, int> arr[], pair<int, int> temp[], int left, int mid,
int right)... | 12 | CPP |
#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 5, MOD = 1e9 + 7;
pair<long long, long long> a[N];
vector<pair<long long, long long> > tree[4 * N];
void build(long long node, long long st, long long en) {
if (st == en) {
tree[node].push_back({a[st].first, a[st].first});
return;
}
l... | 12 | CPP |
#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;
... | 12 | CPP |
#include <bits/stdc++.h>
using namespace std;
int main() {
long long n, i;
cin >> n;
pair<long long, long long> p[n];
long long a[n];
for (i = 0; i < n; i++) {
cin >> a[i];
p[i].second = a[i];
}
for (i = 0; i < n; i++) cin >> p[i].first;
sort(a, a + n);
sort(p, p + n);
map<long long, long lo... | 12 | CPP |
#include <bits/stdc++.h>
#pragma GCC optimize(2)
#pragma GCC optimize(3)
using namespace std;
inline int read() {
int x = 0, neg = 1;
char op = getchar();
while (!isdigit(op)) {
if (op == '-') neg = -1;
op = getchar();
}
while (isdigit(op)) {
x = 10 * x + op - '0';
op = getchar();
}
return... | 12 | CPP |
#include <bits/stdc++.h>
using namespace std;
const long long maxn = 6e6;
const long long inf = 1e9;
const long long maxv = 2e8 + 100;
void init() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
}
struct point {
long long x, v;
point() {}
};
vector<point> foo;
unordered_map<long long, pair<long long, ... | 12 | CPP |
# BIT
def add(bit, x, v):
while x < len(bit):
bit[x] += v
x += x & (-x)
def query(bit, x):
ans = 0
while x > 0:
ans += bit[x]
x -= x & (-x)
return ans
def relabel(arr):
srt = sorted(set(arr))
mp = {v:k for k, v in enumerate(srt, 1)}
arr = [mp[a] for a in arr]... | 12 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
const int N = 1000007, inf = 0x3f3f3f3f;
int x[N], v[N];
pair<long long, int> seg[N + N];
pair<long long, int> soma(pair<long long, int> x, pair<long long, int> y) {
return pair<long long, int>(x.first + y.first, x.second + y.second);
}
pair<long long, int> query(int l, i... | 12 | CPP |
#include <bits/stdc++.h>
using namespace std;
long long int tree[800005], sree[800005];
struct sc {
long long int a, b;
};
bool comp(sc x, sc y) {
if (x.a < y.a) return 1;
return 0;
}
void update(long long int node, long long int s, long long int e,
long long int ind, long long int val) {
if (s == e... | 12 | CPP |
class SegmentTree():
def __init__(self,N,func,initialRes=0):
self.f=func
self.N=N
self.tree=[0 for _ in range(4*self.N)]
self.initialRes=initialRes
# for i in range(self.N):
# self.tree[self.N+i]=arr[i]
# for i in range(self.N-1,0,-1):
# self.... | 12 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
int n, tot;
long long ans, ans1, ans2;
struct dot {
long long x, v, nv;
} a[maxn];
struct node {
long long cnt, d;
} T[maxn * 4];
bool cmp1(dot x, dot y) { return x.v < y.v; }
bool cmp2(dot x, dot y) { return x.x < y.x; }
void pushup(int x) {
... | 12 | CPP |
#include <bits/stdc++.h>
template <class C>
inline void log_c(const C& c) {}
template <class C>
inline int sz(const C& c) {
return static_cast<int>(c.size());
}
using namespace std;
using pii = pair<int, int>;
using num = int64_t;
using pll = pair<num, num>;
const std::string eol = "\n";
const int max_x = 100000000;
... | 12 | CPP |
#include <bits/stdc++.h>
using namespace std;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
int dddx[] = {1, -1, 0, 0, 1, 1, -1, -1};
int dddy[] = {0, 0, 1, -1, 1, -1, 1, -1};
struct FenwickTree {
vector<long long int> bit;
int n;
FenwickTree(int n) {
this->n = n;
bit.assign(n, 0);
}
long long i... | 12 | CPP |
#Pye
from os import path
from sys import stdin, stdout
from bisect import bisect_left
if path.exists('inp.txt'): stdin = open("inp.txt", "r")
maxn = 200005
a = []; b = []; fen = [(0, 0) for i in range(maxn)]
res = 0
n = int(stdin.readline())
def update(x, val):
global fen
while x > 0:
fen[x] = (fen[x][0... | 12 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U>
using Pa = pair<T, U>;
template <class T>
using vec = vector<T>;
template <class T>
using vvec = vector<vec<T>>;
template <typename Monoid, typename F>
class SegmentTree {
private:
int sz;
vector<Monoid> seg;
const F ... | 12 | CPP |
#include <bits/stdc++.h>
using namespace std;
const long long int N = 2e5 + 2;
struct Fenwick {
long long int BIT[N] = {};
void update(long long int idx, long long int val) {
for (long long int i = idx; i < N; i += (i & -i)) {
BIT[i] += val;
}
}
long long int query(long long int k) {
long long... | 12 | CPP |
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int n, i;
pair<int, int> dot[N];
long long mergeMoving(pair<int, int> arr[], pair<int, int> temp[], int left,
int right);
long long merge(pair<int, int> arr[], pair<int, int> temp[], int left, int mid,
int right)... | 12 | CPP |
#include <bits/stdc++.h>
using namespace std;
const long long maxn = 500007;
long long n, C1[maxn], C2[maxn];
long long ans, p1[maxn], p2[maxn];
pair<long long, long long> fk[maxn];
bool cmp2(long long u, long long v) {
if (fk[u].second < fk[v].second) {
return 1;
} else {
if (fk[u].second == fk[v].second &... | 12 | CPP |
#include <bits/stdc++.h>
using namespace std;
const int N = 200000;
long long BIT1[200001];
long long cnt1[200001];
map<long long, long long> r, l;
pair<long long, long long> arr[200001];
int n;
void upd1(long long idx, long long val) {
for (; idx <= N; idx = (idx | (idx + 1))) {
BIT1[idx] += val;
cnt1[idx]++... | 12 | CPP |
import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__
class RangeMinimumQuery:
def __init__(self, n, inf=float("inf")):
self.n0 = 2**(n-1).bit_length()
self.inf = inf
self.data = [self.inf]*(2*self.n0)
self.cnt = [0]*(2*self.n0)
def query(self, l,r):
... | 12 | PYTHON3 |
class Points:
def __init__(self, x = 0, v = 0):
self.x, self.v = x, v
class Fenwick_tree:
def __init__(self, n = 0):
self.n = n
self.bit = [0] * (n + 1)
def update(self, x, value):
while x <= self.n:
self.bit[x] += value
x += x & -x
def get(self... | 12 | PYTHON3 |
# -*- coding:utf-8 -*-
"""
created by shuangquan.huang at 2020/3/13
"""
import collections
import time
import os
import sys
import bisect
import heapq
from typing import List
def solve(N, X, S):
si = {}
ss = list(sorted(set(S)))
for i, s in enumerate(ss):
si[s] = i
xs = [(x, si[s]... | 12 | PYTHON3 |
#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 ... | 12 | CPP |
#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const long long mod = 1e9 + 7;
const long long maxn = 500010;
long long T, n, m, p[maxn], v[maxn], mxval = 0, tree[maxn], cnt[maxn], ans = 0;
struct node {
int pos, val, v;
} a[maxn];
void add(int pos, long long val) {
pos += n;
cnt[pos] +=... | 12 | CPP |
#include <bits/stdc++.h>
using namespace std;
long long query(int a, vector<long long>& ft) {
long long res = 0;
for (; ~a; a = (a & (a + 1)) - 1) {
res += ft[a];
}
return res;
}
void update(int a, int val, vector<long long>& ft) {
for (; a < ft.size(); a = a | (a + 1)) {
ft[a] += val;
}
}
int main(... | 12 | CPP |
#include <bits/stdc++.h>
using namespace std;
pair<long long, long long> st[800005];
void update(long long node, long long beg, long long end, long long pos,
long long dist) {
if (beg == end) {
st[node].first += 1;
st[node].second += dist;
return;
}
long long mid = beg + (end - beg) / 2;
... | 12 | CPP |
#include <bits/stdc++.h>
using namespace std;
pair<long long, long long> ara[200005];
map<long long, long long> mark;
long long seg[4 * 300005], seg2[4 * 300005];
long long query(long long qlo, long long qhi, long long lo, long long hi,
long long pos) {
if (qlo > hi || qhi < lo || qlo > qhi) return 0;... | 12 | CPP |
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const int INF = 1000000007;
const int MAXN = (int)2e5 + 1;
void setIO(string name) {
ios_base::sync_with_stdio(0);
cin.tie(0);
freopen((name + ".in").c_str(), "r", stdin);
freopen((name + ".out").c_str(), "w", stdout);
}
pair<pair<long lo... | 12 | CPP |
import bisect
class Bit :
def __init__(self, n) :
self.bit = [0 for i in range(0, n)]
def add(self, pos, x) :
while pos < len(self.bit) :
self.bit[pos] += x
pos = pos | (pos + 1)
def query(self, pos) :
res = 0
while pos > 0 :
res += self... | 12 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
int cnt[400000], cnt1[400000], a[400000], b[400000], number[800000];
map<int, int> mp;
vector<pair<int, int> > v;
int q(int ind) {
int sum = 0;
while (ind > 0) {
sum += number[ind];
ind -= ind & (-ind);
}
return sum;
}
void u(int ind, int n) {
int sum = 0;... | 12 | CPP |
#include <bits/stdc++.h>
using namespace std;
long long query(vector<long long>& ft, int pos) {
long long ans = 0;
while (pos > 0) {
ans += ft[pos - 1];
pos -= (pos & (-pos));
}
return ans;
}
void update(vector<long long>& ft, int pos, long long val, int& ceil) {
while (pos <= ceil) {
ft[pos - 1] ... | 12 | CPP |
import heapq
import sys
input = sys.stdin.readline
def make_tree(n):
tree = [0] * (n + 1)
return tree
def get_sum(i, tree):
s = 0
while i > 0:
s += tree[i]
i -= i & -i
return s
def add(i, x, tree):
while i <= n:
tree[i] += x
i += i & -i
n = int(input())
x = li... | 12 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
long long n;
int tc = 0;
int solve();
int main() {
ios_base::sync_with_stdio(0);
if (tc < 0) {
cout << "TC!\n";
cin.ignore(1e8);
} else if (!tc)
cin >> tc;
while (tc--) solve();
return 0;
}
int solve() {
long long l, r;
cin >> n >> l >> r;
l--;
... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
void solve() {
int64_t n, l, r;
cin >> n >> l >> r;
l--, r--;
int64_t cnt = 0;
int64_t start = 1;
int64_t num = n - 1;
while (start < n) {
if (l < cnt + 2 * num && r >= cnt) {
for (int64_t i = 0; i < 2 * num; i++) {
if (l <= cnt + i && cnt + ... | 10 | CPP |
#include <bits/stdc++.h>
using namespace std;
int T;
int N;
long long L, R;
int main() {
scanf("%d", &T);
while (T--) {
scanf("%d%lld%lld", &N, &L, &R);
if (L == R && L == 1LL * N * (N - 1) + 1) {
printf("1\n");
continue;
}
long long i = N - 1;
for (; i; i--) {
if (L > 2 * i)
... | 10 | CPP |
# -*- coding:utf-8 -*-
"""
created by shuangquan.huang at 2020/7/1
"""
import collections
import time
import os
import sys
import bisect
import heapq
from typing import List
def solve(n, l, r):
# 1, 2, 1, 3, ..., 1, n
# 2, 3, 2, 4, ..., 2, n
# ...
# n-1, n
# 1
lo, hi = 1, n
while... | 10 | PYTHON3 |
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
long long n, pstart, pend;
int t;
cin >> t;
for (int testcases = 1; testcases <= t; testcases++) {
cin >> n >> pstart >> pend;
bool completestart = true;
b... | 10 | CPP |
#include <bits/stdc++.h>
const int N = 3 * 1e5 + 5;
const long long MOD = 1000000007;
const long long inf = 1e18;
using namespace std;
long long power(long long x, long long y, long long p) {
long long res = 1;
x = x % p;
if (x == 0) return 0;
while (y > 0) {
if (y & 1) res = (res * x) % p;
y = y >> 1;
... | 10 | CPP |
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = "x" in file.mode or "r" not in file.mode
self.write = self.buffer.write if self... | 10 | PYTHON3 |
t=int(input())
for _ in range(t):
n,l,r=map(int, input().split())
cycle_size = 2 * (n - 1)
cycle_start = 1
cycle_number = 1
# while True:
# if cycle_start + cycle_size >= l:
# break
# cycle_start += cycle_size
# cycle_number += 1
# cycle_size -= 2
# pr... | 10 | PYTHON3 |
for _ in range(int(input())):
numbers, LEFTs, RIGHTs = map(int, input().split())
KEYSs = 0
GREATS = 0
for i in range(1, numbers+1):
if KEYSs + 2 * (numbers-i) >= LEFTs:
GREATS = LEFTs-KEYSs-1
break
KEYSs += 2 * (numbers-i)
LISTs = []
while len(LISTs) < (RIGHTs-LEFTs+1) + GREATS:
for j in range(i+1, n... | 10 | PYTHON3 |
#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
using namespace std;
long long binpow(long long base, long long exp, int mod) {
long long res = 1;
while (exp > 0) {
if (ex... | 10 | CPP |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.