buggy_code
stringlengths
11
625k
fixed_code
stringlengths
17
625k
bug_type
stringlengths
2
4.45k
language
int64
0
8
token_count
int64
5
200k
class DisjointSets: def __init__(self, n): self.nodes = [-1] * n #根にサイズを負の値で格納する。 def find(self, i): if self.nodes[i] < 0: #値が負の場合は根 return i else: self.nodes[i] = self.find(self.nodes[i]) #縮約 return self.nodes[i] def unite(self, i, j): i =...
class DisjointSets: def __init__(self, n): self.nodes = [-1] * n #根にサイズを負の値で格納する。 def find(self, i): if self.nodes[i] < 0: #値が負の場合は根 return i else: self.nodes[i] = self.find(self.nodes[i]) #縮約 return self.nodes[i] def unite(self, i, j): i =...
[["-", 0, 652, 3, 668, 0, 659, 12, 319, 500, 22], ["-", 0, 652, 3, 668, 0, 659, 12, 319, 0, 131], ["-", 0, 652, 3, 668, 0, 659, 12, 319, 319, 22], ["+", 0, 652, 3, 668, 0, 659, 12, 652, 63, 22], ["+", 3, 668, 0, 659, 12, 652, 3, 4, 0, 24], ["+", 3, 668, 0, 659, 12, 652, 3, 4, 0, 22], ["+", 3, 668, 0, 659, 12, 652, 3, 4...
5
259
class UnionFind: __slots__ = ["N", "root"] def __init__(self, N): """ N:要素数 root:各要素の親要素の番号を格納するリスト. ただし, root[x] < 0 ならその頂点が根で-root[x]が木の要素数. """ self.N = N self.root = [-1] * N def __repr__(self): return '\n'.join('{}: {}'.format(r, se...
class UnionFind: __slots__ = ["N", "root"] def __init__(self, N): """ N:要素数 root:各要素の親要素の番号を格納するリスト. ただし, root[x] < 0 ならその頂点が根で-root[x]が木の要素数. """ self.N = N self.root = [-1] * N def __repr__(self): return '\n'.join('{}: {}'.format(r, se...
[["-", 0, 1, 0, 652, 3, 4, 0, 657, 31, 22], ["-", 0, 1, 0, 652, 3, 4, 0, 657, 17, 33], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 17, 33], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 12, 612]]
5
468
#include <bits/stdc++.h> #include <iostream> #define ll long long using namespace std; const ll num = 1e9 + 7; ll mod(ll n) { return (n % num + num) % num; } ll add(ll x, ll y) { return mod(mod(x) + mod(y)); } ll mult(ll x, ll y) { return mod(mod(x) * mod(y)); } ll sub(ll x, ll y) { return mod(mod(x) - mod(y)); } ll pt...
#include <bits/stdc++.h> #include <iostream> #define ll long long using namespace std; const ll num = 1e9 + 7; ll mod(ll n) { return (n % num + num) % num; } ll add(ll x, ll y) { return mod(mod(x) + mod(y)); } ll mult(ll x, ll y) { return mod(mod(x) * mod(y)); } ll sub(ll x, ll y) { return mod(mod(x) - mod(y)); } ll pt...
[["+", 0, 1, 0, 16, 31, 16, 12, 16, 17, 33], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 12, 13]]
1
406
#include <bits/stdc++.h> using namespace std; #define ALL(v) v.begin(), v.end() #define V vector #define P pair using ll = long long; struct UnionFind { vector<int> d; // n要素で初期化 UnionFind(int n) : d(n, -1) {} // 木の根を決める int root(int x) { if (d[x] < 0) return x; return d[x] = root(d[x]); } ...
#include <bits/stdc++.h> using namespace std; #define ALL(v) v.begin(), v.end() #define V vector #define P pair using ll = long long; struct UnionFind { vector<int> d; // n要素で初期化 UnionFind(int n) : d(n, -1) {} // 木の根を決める int root(int x) { if (d[x] < 0) return x; return d[x] = root(d[x]); } ...
[["+", 8, 9, 0, 7, 15, 16, 12, 16, 17, 33], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13]]
1
326
#include <bits/stdc++.h> using namespace std; #define ll long long #define ar array const int mxN = 1e5; int n, m; vector<int> adj[mxN]; bool vis[mxN]; void dfs(int u) { vis[u] = 1; for (int v : adj[u]) { if (vis[v]) continue; dfs(v); } } int main() { ios::sync_with_stdio(0); cin.tie(0); ...
#include <bits/stdc++.h> using namespace std; #define ll long long #define ar array const int mxN = 1e5; int n, m; vector<int> adj[mxN]; bool vis[mxN]; void dfs(int u) { vis[u] = 1; for (int v : adj[u]) { if (vis[v]) continue; dfs(v); } } int main() { ios::sync_with_stdio(0); cin.tie(0); ...
[["-", 8, 9, 0, 1, 0, 16, 12, 16, 31, 22], ["-", 8, 9, 0, 1, 0, 16, 12, 16, 17, 33], ["+", 8, 9, 0, 1, 0, 16, 12, 16, 17, 33], ["+", 8, 9, 0, 1, 0, 16, 12, 16, 12, 13]]
1
201
class UnionFind: def __init__(self, n): self.r = [-1 for i in range(n)] def root(self, x): if self.r[x] < 0: return x self.r[x] = self.root(self.r[x]) return self.r[x] def unite(self, x, y): x = self.root(x) y = self.root(y) if x ...
class UnionFind: def __init__(self, n): self.r = [-1 for i in range(n)] def root(self, x): if self.r[x] < 0: return x self.r[x] = self.root(self.r[x]) return self.r[x] def unite(self, x, y): x = self.root(x) y = self.root(y) if x ...
[["-", 0, 1, 0, 652, 3, 4, 0, 319, 500, 22], ["-", 0, 1, 0, 652, 3, 4, 0, 319, 0, 131], ["-", 0, 1, 0, 652, 3, 4, 0, 319, 319, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 25], ["-", 36, 36, 0, 656, 0, 1, 0, 652, 63, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 24]]
5
264
import sys sys.setrecursionlimit(10000) class UnionFindTree: def __init__(self,size): """ size個の集合を作成 負の値は、ルートで集合の個数 正の値は、次の要素 """ self.table=[-1 for _ in range(size)] def find(self,x): """ グループ番号を取得 """ # 本質的には、木を上に辿るだけ # ただし、通常、UnionFindでは経路圧縮を行うのが普通らしい if self.table[x] < 0: # 一個上がルートな...
import sys sys.setrecursionlimit(10000) class UnionFindTree: def __init__(self,size): """ size個の集合を作成 負の値は、ルートで集合の個数 正の値は、次の要素 """ self.table=[-1 for _ in range(size)] def find(self,x): """ グループ番号を取得 """ # 本質的には、木を上に辿るだけ # ただし、通常、UnionFindでは経路圧縮を行うのが普通らしい if self.table[x] < 0: # 一個上がルートな...
[["-", 36, 36, 36, 36, 0, 656, 0, 7, 31, 22], ["+", 36, 36, 36, 36, 0, 656, 0, 7, 31, 22], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 17, 33], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 12, 612]]
5
295
#include <bits/stdc++.h> using namespace std; #define __ << " " << #define ___ << " " #define bash push_back #define ALL(x) x.begin(), x.end() // #define int long long struct IoSetup { IoSetup() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(10); cerr << fixed << setprecision...
#include <bits/stdc++.h> using namespace std; #define __ << " " << #define ___ << " " #define bash push_back #define ALL(x) x.begin(), x.end() // #define int long long struct IoSetup { IoSetup() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(10); cerr << fixed << setprecision...
[["-", 0, 1, 0, 16, 31, 16, 12, 16, 31, 22], ["-", 0, 1, 0, 16, 31, 16, 12, 16, 17, 33], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 17, 33], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 12, 13]]
1
574
#include <bits/stdc++.h> using namespace std; using lint = long long; constexpr lint mod = 998244353; #define all(x) (x).begin(), (x).end() #define bitcount(n) __builtin_popcountl((lint)(n)) #define fcout cout << fixed << setprecision(15) #define highest(x) (63 - __builtin_clzl(x)) #define rep(i, n) for (int i = 0; i <...
#include <bits/stdc++.h> using namespace std; using lint = long long; constexpr lint mod = 998244353; #define all(x) (x).begin(), (x).end() #define bitcount(n) __builtin_popcountl((lint)(n)) #define fcout cout << fixed << setprecision(15) #define highest(x) (63 - __builtin_clzl(x)) #define rep(i, n) for (int i = 0; i <...
[["-", 0, 1, 0, 16, 31, 16, 12, 16, 31, 22], ["-", 0, 1, 0, 16, 31, 16, 12, 16, 17, 33], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 17, 33], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 12, 13]]
1
1,431
import sys input = sys.stdin.readline class UnionFind: def __init__(self, n): self.parent = list(range(n)) def find(self, a): acopy = a while a != self.parent[a]: a = self.parent[a] while acopy != a: self.parent[acopy], acopy = a, self.parent[acopy] ...
import sys input = sys.stdin.readline class UnionFind: def __init__(self, n): self.parent = list(range(n)) def find(self, a): acopy = a while a != self.parent[a]: a = self.parent[a] while acopy != a: self.parent[acopy], acopy = a, self.parent[acopy] ...
[["-", 0, 652, 3, 4, 0, 652, 63, 319, 319, 22], ["+", 0, 652, 3, 4, 0, 652, 63, 319, 319, 22]]
5
203
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define P pair<ll, ll> class UnionFind { vector<int> data; ll num; public: UnionFind(int size) : data(size, -1), num(size) {} bool unite(int x, int y) { // xとyの集合を統合する x = root(x); ...
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define P pair<ll, ll> class UnionFind { vector<int> data; ll num; public: UnionFind(int size) : data(size, -1), num(size) {} bool unite(int x, int y) { // xとyの集合を統合する x = root(x); ...
[["+", 0, 1, 0, 16, 31, 16, 12, 16, 17, 33], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 12, 13]]
1
292
#include <algorithm> #include <iostream> #include <set> #include <vector> using namespace std; struct UF { vector<int> par, rank, size; UF() {} UF(int n) { init(n); } void init(int n) { par.assign(n, 0); rank.assign(n, 0); size.assign(n, 1); for (int i = 0; i < n; i++) par[i] = i; } i...
#include <algorithm> #include <iostream> #include <set> #include <vector> using namespace std; struct UF { vector<int> par, rank, size; UF() {} UF(int n) { init(n); } void init(int n) { par.assign(n, 0); rank.assign(n, 0); size.assign(n, 1); for (int i = 0; i < n; i++) par[i] = i; } i...
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19]]
1
355
N, M = map(int, input().split()) class DisjointSetUnion(): def __init__(self, n): self.n = n self.par_size = [-1] * n def merge(self, a, b): #assert 0 <= a < self.n #assert 0 <= b < self.n x = self.leader(a) y = self.leader(b) if x == y: return x ...
N, M = map(int, input().split()) class DisjointSetUnion(): def __init__(self, n): self.n = n self.par_size = [-1] * n def merge(self, a, b): #assert 0 <= a < self.n #assert 0 <= b < self.n x = self.leader(a) y = self.leader(b) if x == y: return x ...
[["+", 0, 1, 0, 652, 3, 4, 0, 657, 17, 33], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 12, 612]]
5
401
#include <bits/stdc++.h> #include <iomanip> using namespace std; #define ll long long #define ld long double #define vpll vector<pair<ll, ll>> #define vpii vector<pair<int, int>> #define pii pair<int, int> #define pll pair<ll, ll> #define mem(a, b) memset(a, b, sizeof a); #define M 1000000007 #define bs(a, b, x) binary...
#include <bits/stdc++.h> #include <iomanip> using namespace std; #define ll long long #define ld long double #define vpll vector<pair<ll, ll>> #define vpii vector<pair<int, int>> #define pii pair<int, int> #define pll pair<ll, ll> #define mem(a, b) memset(a, b, sizeof a); #define M 1000000007 #define bs(a, b, x) binary...
[["-", 64, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 64, 9, 0, 1, 0, 2, 3, 4, 0, 22]]
1
379
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef pair<ll, ll> p_ll; typedef vector<pair<ll, ll>> vec_p; // vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i) #define ture ture #define flase false #define falg flag #define REP(i, x) for (ll i = 0; i < (ll)(x); i++) #defi...
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef pair<ll, ll> p_ll; typedef vector<pair<ll, ll>> vec_p; // vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i) #define ture ture #define flase false #define falg flag #define REP(i, x) for (ll i = 0; i < (ll)(x); i++) #defi...
[["-", 0, 1, 0, 16, 31, 16, 12, 16, 31, 22], ["-", 0, 1, 0, 16, 31, 16, 12, 16, 17, 33], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 17, 33], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 12, 13]]
1
724
N, M = map(int, input().split()) ab = [0] * M for i in range(M): ab[i] = list(map(int, input().split())) import sys sys.setrecursionlimit(100500) class UnionFind(): def __init__(self, n): self.n = n self.parents = [-1] * n def find(self, x): if self.parents[x] < 0: ret...
N, M = map(int, input().split()) ab = [0] * M for i in range(M): ab[i] = list(map(int, input().split())) import sys sys.setrecursionlimit(100500) class UnionFind(): def __init__(self, n): self.n = n self.parents = [-1] * n def find(self, x): if self.parents[x] < 0: ret...
[["+", 0, 1, 0, 652, 3, 4, 0, 657, 17, 33], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 12, 612]]
5
438
n,m=map(int,input().split()) global fri fri=[] global tab tab=[0]*n def run(nn): #print(tab) global cnt if tab[nn]: return tab[nn]=1 cnt+=1 for i in fri[nn]: que.append(i) for i in range(n): fri.append([]) for i in range(m): a,b=map(int,input().split()) fri[a-1].append(b-1) fri[b-1].append(...
n,m=map(int,input().split()) global fri fri=[] global tab tab=[0]*n def run(nn): #print(tab) global cnt if tab[nn]: return tab[nn]=1 cnt+=1 for i in fri[nn]: que.append(i) for i in range(n): fri.append([]) for i in range(m): a,b=map(int,input().split()) fri[a-1].append(b-1) fri[b-1].append(...
[["+", 0, 1, 0, 652, 3, 4, 0, 657, 17, 33], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 12, 612]]
5
201
#include <bits/stdc++.h> using namespace std; void dfs(int src, vector<int> v[], vector<bool> &vis) { vis[src] = true; for (int it : v[src]) { if (!vis[it]) dfs(it, v, vis); } } int main() { int n, m; cin >> n >> m; vector<int> v[n + 1]; for (int i = 0; i < m; i++) { int a, b; cin >> a >...
#include <bits/stdc++.h> using namespace std; void dfs(int src, vector<int> v[], vector<bool> &vis) { vis[src] = true; for (int it : v[src]) { if (!vis[it]) dfs(it, v, vis); } } int main() { int n, m; cin >> n >> m; vector<int> v[n + 1]; for (int i = 0; i < m; i++) { int a, b; cin >> a >...
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19]]
1
202
/* lib.cpp */ #include <algorithm> #include <bitset> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <deque> #include <iomanip> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <vector> #define overload4(_1, _2, _3, _4, name...
/* lib.cpp */ #include <algorithm> #include <bitset> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <deque> #include <iomanip> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <vector> #define overload4(_1, _2, _3, _4, name...
[["+", 51, 69, 341, 342, 0, 2, 63, 118, 28, 22], ["+", 51, 69, 341, 342, 0, 2, 63, 118, 17, 131], ["+", 51, 69, 341, 342, 0, 2, 63, 118, 119, 120], ["+", 51, 69, 341, 342, 0, 2, 3, 4, 0, 24], ["+", 51, 69, 341, 342, 0, 2, 3, 4, 0, 25]]
1
3,468
#include <bits/stdc++.h> using namespace std; #define ll long long #define ull unsigned long long #define ld long double #define pii pair<int, int> #define pll pair<ll, ll> #define vi vector<int> #define vll vector<ll> #define vc vector<char> #define vs vector<string> #define vpll vector<pll> #define vpii vector<pii> #...
#include <bits/stdc++.h> using namespace std; #define ll long long #define ull unsigned long long #define ld long double #define pii pair<int, int> #define pll pair<ll, ll> #define vi vector<int> #define vll vector<ll> #define vc vector<char> #define vs vector<string> #define vpll vector<pll> #define vpii vector<pii> #...
[["+", 0, 1, 0, 16, 31, 16, 12, 16, 17, 33], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 12, 13]]
1
532
import sys sys.setrecursionlimit(2*10**5)#必要に応じて class UnionFind:#再帰上限に引っかかることがあるので def __init__(self,n): self.l=list(range(n)) self.n=n self.rank=[0 for i in range(n)] def find(self,x): if self.l[x]==x: return x self.l[x]=self.find(self.l[x]) return ...
import sys sys.setrecursionlimit(2*10**5)#必要に応じて class UnionFind:#再帰上限に引っかかることがあるので def __init__(self,n): self.l=list(range(n)) self.n=n self.rank=[0 for i in range(n)] def find(self,x): if self.l[x]==x: return x self.l[x]=self.find(self.l[x]) return ...
[["-", 0, 1, 0, 652, 3, 4, 0, 657, 31, 22], ["-", 0, 1, 0, 652, 3, 4, 0, 657, 17, 33], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 17, 33], ["+", 0, 1, 0, 652, 3, 4, 0, 657, 12, 612]]
5
305
import java.io.DataInputStream; import java.io.FileInputStream; import java.io.IOException; import java.io.PrintWriter; public class Main { static class Reader { final private int BUFFER_SIZE = 1 << 16; private DataInputStream din; private byte[] buffer; private int bufferPointer, bytesRead; pub...
import java.io.DataInputStream; import java.io.FileInputStream; import java.io.IOException; import java.io.PrintWriter; public class Main { static class Reader { final private int BUFFER_SIZE = 1 << 16; private DataInputStream din; private byte[] buffer; private int bufferPointer, bytesRead; pub...
[["-", 0, 503, 49, 200, 51, 492, 3, 4, 0, 499], ["+", 0, 503, 49, 200, 51, 492, 3, 4, 0, 499], ["-", 8, 196, 0, 1, 0, 492, 3, 4, 0, 499], ["+", 8, 196, 0, 1, 0, 492, 3, 4, 0, 499]]
3
1,021
N, K = map(int, input().split()) lm = 300001 # N: 処理する区間の長さ N0 = 2**(lm-1).bit_length() INF = 0 data = [INF]*(2*N0) # a_k の値を x に更新 def update(k, x): k += N0-1 data[k] = x while k >= 0: k = (k - 1) // 2 data[k] = max(data[2*k+1], data[2*k+2]) # 区間[l, r)の最小値 def query(l, r): L = l + N0;...
N, K = map(int, input().split()) lm = 300001 # N: 処理する区間の長さ N0 = 2**(lm-1).bit_length() INF = 0 data = [INF]*(2*N0) # a_k の値を x に更新 def update(k, x): k += N0-1 data[k] = x while k >= 0: k = (k - 1) // 2 data[k] = max(data[2*k+1], data[2*k+2]) # 区間[l, r)の最小値 def query(l, r): L = l + N...
[["-", 0, 652, 3, 4, 0, 652, 3, 4, 0, 22], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 22]]
5
242
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define inf 0x3f3f3f3f #define read(x) scanf("%d", &x) #define lowbit(x) (x & -x) const int N = 3e5 + 7; int T; int n, m; int a[N], p[N], tot; struct node { int mx, l, r; } t[N << 2]; inline void build(int p, int l, int r) { t[p].l = l, t[p].r = r;...
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define inf 0x3f3f3f3f #define read(x) scanf("%d", &x) #define lowbit(x) (x & -x) const int N = 3e5 + 7; int T; int n, m; int a[N], p[N], tot; struct node { int mx, l, r; } t[N << 2]; inline void build(int p, int l, int r) { t[p].l = l, t[p].r = r;...
[["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 31, 22], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13], ["-", 12, 2, 3, 4, 0, 2, 3, 4, 0, 22], ["+", 3, 4, 0, 2, 3, 4, 0, 16, 31, 22], ["+", 3, 4, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 3, 4, 0, 2, 3, 4, 0, 16, 12, 13]]
1
563
import sys def input(): return sys.stdin.readline().rstrip() from math import gcd class seg(): def __init__(self,init_val): self.n=len(init_val) self.ide_ele= 0 #単位元 self.num=2**(self.n-1).bit_length() #n以上の最小の2のべき乗 self.seg=[self.ide_ele]*2*self.num for i in range(self.n): ...
import sys def input(): return sys.stdin.readline().rstrip() from math import gcd class seg(): def __init__(self,init_val): self.n=len(init_val) self.ide_ele= 0 #単位元 self.num=2**(self.n-1).bit_length() #n以上の最小の2のべき乗 self.seg=[self.ide_ele]*2*self.num for i in range(self.n): ...
[["-", 31, 652, 3, 4, 0, 652, 3, 4, 0, 612], ["+", 31, 652, 3, 4, 0, 652, 3, 4, 0, 612], ["-", 0, 652, 3, 4, 0, 652, 3, 4, 0, 612], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 612]]
5
554
import sys input = sys.stdin.buffer.readline MOD = 10 ** 9 + 7 INF = 2 * 10**18 in_n = lambda: int(input()) in_nn = lambda: map(int, input().split()) in_s = lambda: input().rstrip().decode('utf-8') in_map = lambda: [s == ord('.') for s in input() if s != ord('\n')] # 1点更新・区間クエリ(0-index) class SegTree: def __in...
import sys input = sys.stdin.buffer.readline MOD = 10 ** 9 + 7 INF = 2 * 10**18 in_n = lambda: int(input()) in_nn = lambda: map(int, input().split()) in_s = lambda: input().rstrip().decode('utf-8') in_map = lambda: [s == ord('.') for s in input() if s != ord('\n')] # 1点更新・区間クエリ(0-index) class SegTree: def __in...
[["-", 0, 1, 0, 662, 12, 652, 3, 4, 0, 612], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 612]]
5
544
class ST def initialize n @l = (1<<(n-1).bit_length)-1 @h = [0]*(@l+@l+1) end def max return @h[0] end def [] l,r return if r < l l,r = @l+l+1,@l+r+1 lx,rx = @h[l-1],@h[r-1] while l <= r lx = @h[l-1] if lx < @h[l-1] rx = @h[r-1] if rx < @h[r-1] l = (l+1)/2 r = (r-1)/2 end return l...
class ST def initialize n @l = (1<<(n-1).bit_length)-1 @h = [0]*(@l+@l+1) end def max return @h[0] end def [] l,r return if r < l l,r = @l+l+1,@l+r+1 lx,rx = @h[l-1],@h[r-1] while l <= r lx = @h[l-1] if lx < @h[l-1] rx = @h[r-1] if rx < @h[r-1] l = (l+1)/2 r = (r-1)/2 end return l...
[["+", 0, 493, 0, 662, 12, 652, 3, 4, 0, 612], ["-", 36, 36, 36, 36, 0, 493, 0, 652, 486, 743], ["-", 12, 742, 0, 652, 486, 516, 0, 738, 31, 743], ["-", 12, 742, 0, 652, 486, 516, 0, 738, 17, 33], ["-", 12, 742, 0, 652, 486, 516, 0, 738, 12, 612], ["+", 12, 738, 12, 742, 0, 652, 486, 516, 0, 612]]
4
263
#include <bits/stdc++.h> using namespace std; #define all(v) v.begin(), v.end() #define prec(n) fixed << setprecision(n) // declaration shortcuts typedef long long int ll; #define int ll // Constants constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1}; constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1}; constexpr ll INF = 1...
#include <bits/stdc++.h> using namespace std; #define all(v) v.begin(), v.end() #define prec(n) fixed << setprecision(n) // declaration shortcuts typedef long long int ll; #define int ll // Constants constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1}; constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1}; constexpr ll INF = 1...
[["-", 0, 43, 49, 50, 51, 2, 3, 4, 0, 13], ["+", 0, 43, 49, 50, 51, 2, 3, 4, 0, 13], ["-", 51, 2, 3, 4, 0, 2, 3, 4, 0, 13], ["+", 51, 2, 3, 4, 0, 2, 3, 4, 0, 13], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13]]
1
740
#include <bits/stdc++.h> #define pb push_back #define mp make_pair using namespace std; typedef long long ll; typedef long double ld; typedef unsigned long long ull; const ll mod = 998244353; const int N = 300006; const ll INF = 1e18; struct seg_tree { int sz; vector<int> val; void init(int x) { sz = 1; ...
#include <bits/stdc++.h> #define pb push_back #define mp make_pair using namespace std; typedef long long ll; typedef long double ld; typedef unsigned long long ull; const ll mod = 998244353; const int N = 500006; const ll INF = 1e18; struct seg_tree { int sz; vector<int> val; void init(int x) { sz = 1; ...
[["-", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13], ["-", 0, 2, 3, 4, 0, 2, 3, 4, 0, 13], ["+", 0, 2, 3, 4, 0, 2, 3, 4, 0, 13]]
1
700
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using namespace std; #define mp make_pair #define pb(x) push_back(x) #define vll vector<long long> #define pll pair<long long, long long> #define mll map<long long, long long> #define sz(v)...
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using namespace std; #define mp make_pair #define pb(x) push_back(x) #define vll vector<long long> #define pll pair<long long, long long> #define mll map<long long, long long> #define sz(v)...
[["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13]]
1
874
#include <bits/stdc++.h> //#include <atcoder/scc> using namespace std; // using namespace atcoder; using ll = long long; using ull = unsigned long long; using pii = pair<int, int>; using pll = pair<ll, ll>; using pull = pair<ull, ll>; using pis = pair<int, string>; #define all(x) (x).begin(), (x).end() #define INF 1000...
#include <bits/stdc++.h> //#include <atcoder/scc> using namespace std; // using namespace atcoder; using ll = long long; using ull = unsigned long long; using pii = pair<int, int>; using pll = pair<ll, ll>; using pull = pair<ull, ll>; using pis = pair<int, string>; #define all(x) (x).begin(), (x).end() #define INF 1000...
[["-", 0, 16, 31, 2, 3, 4, 0, 16, 12, 13], ["+", 0, 16, 31, 2, 3, 4, 0, 16, 12, 22], ["+", 31, 2, 3, 4, 0, 16, 31, 16, 12, 22], ["+", 0, 16, 31, 2, 3, 4, 0, 16, 17, 72], ["+", 0, 16, 31, 2, 3, 4, 0, 16, 12, 13], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13]]
1
583
// Problem : D - Flat Subsequence // Contest : AtCoder - ACL Beginner Contest // URL : https://atcoder.jp/contests/abl/tasks/abl_d // Memory Limit : 1024 MB // Time Limit : 2000 ms // Powered by CP Editor (https://github.com/cpeditor/cpeditor) //#pragma GCC optimize("Ofast") //#pragma GCC optimize ("unroll-loops") //...
// Problem : D - Flat Subsequence // Contest : AtCoder - ACL Beginner Contest // URL : https://atcoder.jp/contests/abl/tasks/abl_d // Memory Limit : 1024 MB // Time Limit : 2000 ms // Powered by CP Editor (https://github.com/cpeditor/cpeditor) //#pragma GCC optimize("Ofast") //#pragma GCC optimize ("unroll-loops") //...
[["-", 0, 43, 49, 50, 51, 2, 3, 4, 0, 13], ["+", 0, 43, 49, 50, 51, 2, 3, 4, 0, 13], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13]]
1
866
class SegmentTree(): def __init__(self, n, oper, e): self.n = n self.oper = oper self.e = e self.log = (n - 1).bit_length() self.size = 1 << self.log self.data = [e] * (2 * self.size) def update(self, k): self.data[k] = self.oper(self.data[2 * k], self.data[2 * k + 1]) def build(self...
class SegmentTree(): def __init__(self, n, oper, e): self.n = n self.oper = oper self.e = e self.log = (n - 1).bit_length() self.size = 1 << self.log self.data = [e] * (2 * self.size) def update(self, k): self.data[k] = self.oper(self.data[2 * k], self.data[2 * k + 1]) def build(self...
[["-", 31, 652, 3, 4, 0, 652, 3, 4, 0, 612], ["+", 31, 652, 3, 4, 0, 652, 3, 4, 0, 612]]
5
464
#include <bits/stdc++.h> using namespace std; // type alias typedef long long LL; typedef pair<int, int> II; typedef tuple<int, int, int> III; typedef vector<int> VI; typedef vector<string> VS; typedef unordered_map<int, int> MAPII; typedef unordered_set<int> SETI; template <class T> using VV = vector<vector<T>>; // mi...
#include <bits/stdc++.h> using namespace std; // type alias typedef long long LL; typedef pair<int, int> II; typedef tuple<int, int, int> III; typedef vector<int> VI; typedef vector<string> VS; typedef unordered_map<int, int> MAPII; typedef unordered_set<int> SETI; template <class T> using VV = vector<vector<T>>; // mi...
[["-", 8, 9, 0, 43, 49, 50, 51, 4, 0, 22], ["+", 8, 9, 0, 43, 49, 50, 51, 4, 0, 22]]
1
1,119
# ------------------- fast io -------------------- 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...
# ------------------- fast io -------------------- 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...
[["-", 0, 662, 12, 652, 3, 4, 0, 657, 12, 612], ["+", 0, 662, 12, 652, 3, 4, 0, 657, 12, 612], ["-", 0, 1, 0, 652, 3, 4, 0, 206, 206, 22], ["+", 0, 1, 0, 652, 3, 4, 0, 206, 206, 612], ["-", 3, 4, 0, 652, 3, 4, 0, 657, 31, 22], ["-", 3, 4, 0, 652, 3, 4, 0, 657, 17, 33], ["-", 3, 4, 0, 652, 3, 4, 0, 657, 12, 612], ["+", ...
5
1,310
#include <algorithm> #include <bitset> #include <cassert> #include <chrono> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <functional> #include <iostream> #include <map> #include <queue> #include <random> #include <set> #include <stack> #include <s...
#include <algorithm> #include <bitset> #include <cassert> #include <chrono> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <functional> #include <iostream> #include <map> #include <queue> #include <random> #include <set> #include <stack> #include <s...
[["-", 3, 4, 0, 16, 31, 69, 341, 342, 0, 22], ["+", 3, 4, 0, 16, 31, 69, 341, 342, 0, 22], ["-", 51, 2, 3, 4, 0, 69, 341, 342, 0, 22], ["+", 51, 2, 3, 4, 0, 69, 341, 342, 0, 22]]
1
1,236
// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools #include <bits/stdc++.h> // #include "atcoder/all" using namespace std; using i64 = long long; const i64 MOD = 1e9 + 7; const i64 INF = i64(1e18) + 7; template <typename T> bool chmin(T &x, T y) { if (x > y) { x = y; return true; } ...
// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools #include <bits/stdc++.h> // #include "atcoder/all" using namespace std; using i64 = long long; const i64 MOD = 1e9 + 7; const i64 INF = i64(1e18) + 7; template <typename T> bool chmin(T &x, T y) { if (x > y) { x = y; return true; } ...
[["-", 31, 2, 3, 4, 0, 2, 3, 4, 0, 22], ["+", 31, 2, 3, 4, 0, 2, 3, 4, 0, 13]]
1
787
#define _USE_MATH_DEFINES #include <algorithm> #include <array> #include <cfloat> #include <climits> #include <cmath> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <queue> #include <random> #include <set> #include <sstream> #include <stack> #incl...
#define _USE_MATH_DEFINES #include <algorithm> #include <array> #include <cfloat> #include <climits> #include <cmath> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <queue> #include <random> #include <set> #include <sstream> #include <stack> #incl...
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13]]
1
544
#include <bits/stdc++.h> using namespace std; const int maxn = 300005; struct tree { int l, r, sum; } t[maxn * 4]; int a[maxn], f[maxn], n, m, ans; void build(int id, int l, int r) { t[id].l = l, t[id].r = r; if (l == r) { return; } int mid = (l + r) / 2; build(id * 2, l, mid); build(id * 2 + 1, mid +...
#include <bits/stdc++.h> using namespace std; const int maxn = 300005; struct tree { int l, r, sum; } t[maxn * 4]; int a[maxn], f[maxn], n, m, ans; void build(int id, int l, int r) { t[id].l = l, t[id].r = r; if (l == r) { return; } int mid = (l + r) / 2; build(id * 2, l, mid); build(id * 2 + 1, mid +...
[["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13]]
1
514
import sys sys.setrecursionlimit(10**6) int1 = lambda x: int(x)-1 p2D = lambda x: print(*x, sep="\n") def II(): return int(sys.stdin.readline()) def MI(): return map(int, sys.stdin.readline().split()) def LI(): return list(map(int, sys.stdin.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_n...
import sys sys.setrecursionlimit(10**6) int1 = lambda x: int(x)-1 p2D = lambda x: print(*x, sep="\n") def II(): return int(sys.stdin.readline()) def MI(): return map(int, sys.stdin.readline().split()) def LI(): return list(map(int, sys.stdin.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_n...
[["-", 12, 652, 3, 4, 0, 652, 3, 4, 0, 22], ["+", 12, 652, 3, 4, 0, 652, 3, 4, 0, 22]]
5
813
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> PP; //#define MOD 1000000007 #define MOD 998244353 #define INF 2305843009213693951 //#define INF 810114514 #define PI 3.141592653589 #define setdouble setprecision #define REP(i, n) for (ll i = 0; i < (n); ++i) #define OREP(i, n) f...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> PP; //#define MOD 1000000007 #define MOD 998244353 #define INF 2305843009213693951 //#define INF 810114514 #define PI 3.141592653589 #define setdouble setprecision #define REP(i, n) for (ll i = 0; i < (n); ++i) #define OREP(i, n) f...
[["-", 0, 43, 49, 50, 51, 2, 3, 4, 0, 22], ["+", 0, 43, 49, 50, 51, 2, 3, 4, 0, 13]]
1
505
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--) #define all(x) (x).begin(), (x).end() #define sz(x) int(x.size()) using namespace std; typedef long long ll; const int INF = 1e9; const ll MOD = 1e9 + 7; const ll LINF = 1e18; templat...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--) #define all(x) (x).begin(), (x).end() #define sz(x) int(x.size()) using namespace std; typedef long long ll; const int INF = 1e9; const ll MOD = 1e9 + 7; const ll LINF = 1e18; templat...
[["-", 0, 16, 31, 2, 3, 4, 0, 16, 31, 22], ["-", 0, 16, 31, 2, 3, 4, 0, 16, 17, 33], ["-", 0, 16, 31, 2, 3, 4, 0, 16, 12, 13], ["+", 51, 2, 3, 4, 0, 2, 3, 4, 0, 13], ["-", 3, 4, 0, 16, 31, 2, 3, 4, 0, 25], ["+", 51, 2, 3, 4, 0, 2, 3, 4, 0, 25]]
1
1,379
/** * “Experience is the name everyone gives to their mistakes.” – Oscar Wilde * * author : Prodip Datta * handle : prodipdatta7 * created : Saturday 26-September, 2020 06:14:03 PM **/ //#include <bits/stdc++.h> #include <algorithm> #include <assert.h> #include <bitset> #include <cmath> #include <cs...
/** * “Experience is the name everyone gives to their mistakes.” – Oscar Wilde * * author : Prodip Datta * handle : prodipdatta7 * created : Saturday 26-September, 2020 06:14:03 PM **/ //#include <bits/stdc++.h> #include <algorithm> #include <assert.h> #include <bitset> #include <cmath> #include <cs...
[["+", 0, 7, 8, 9, 0, 1, 0, 27, 17, 29], ["+", 0, 7, 8, 9, 0, 1, 0, 27, 28, 22], ["+", 8, 9, 0, 7, 8, 9, 0, 1, 0, 35]]
1
1,364
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int(i) = 0; (i) < (n); (i)++) #define FOR(i, m, n) for (int(i) = (m); (i) < (n); (i)++) #define All(v) (v).begin(), (v).end() #define pb push_back #define MP(a, b) make_pair((a), (b)) template <class T> vector<T> make_vec(size_t a, T val) { return v...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int(i) = 0; (i) < (n); (i)++) #define FOR(i, m, n) for (int(i) = (m); (i) < (n); (i)++) #define All(v) (v).begin(), (v).end() #define pb push_back #define MP(a, b) make_pair((a), (b)) template <class T> vector<T> make_vec(size_t a, T val) { return v...
[["-", 0, 14, 49, 53, 54, 55, 0, 56, 39, 78], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 0, 1, 0, 2, 3, 4, 0, 25, 0, 35]]
1
976
/*{{{*/ #include <algorithm> #include <assert.h> #include <bitset> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <limits.h> #include <map> #include <queue> #include <set> #include <sstream> #include <string> #include <vector> #define SZ(X) ((int)(X).size()) #defin...
/*{{{*/ #include <algorithm> #include <assert.h> #include <bitset> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <limits.h> #include <map> #include <queue> #include <set> #include <sstream> #include <string> #include <vector> #define SZ(X) ((int)(X).size()) #defin...
[["-", 49, 50, 51, 16, 31, 2, 3, 4, 0, 13], ["+", 49, 50, 51, 16, 31, 2, 3, 4, 0, 13], ["-", 31, 2, 3, 4, 0, 2, 3, 4, 0, 13], ["+", 31, 2, 3, 4, 0, 2, 3, 4, 0, 13], ["-", 0, 43, 49, 50, 51, 2, 3, 4, 0, 13], ["+", 0, 43, 49, 50, 51, 2, 3, 4, 0, 13], ["-", 64, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 64, 9, 0, 1, 0, 2, 3, 4, 0...
1
1,271
#include <bits/stdc++.h> // #include <ext/pb_ds/assoc_container.hpp> // #include <ext/pb_ds/tree_policy.hpp> // using namespace __gnu_pbds; using namespace std; #define fbo find_by_order #define ook order_of_key #define fi first #define se second #define long long long typedef pair<int, int> ii; typedef pair<int, ii>...
#include <bits/stdc++.h> // #include <ext/pb_ds/assoc_container.hpp> // #include <ext/pb_ds/tree_policy.hpp> // using namespace __gnu_pbds; using namespace std; #define fbo find_by_order #define ook order_of_key #define fi first #define se second #define long long long typedef pair<int, int> ii; typedef pair<int, ii>...
[["-", 0, 43, 49, 50, 51, 2, 3, 4, 0, 13], ["+", 0, 43, 49, 50, 51, 2, 3, 4, 0, 13], ["-", 51, 2, 3, 4, 0, 2, 3, 4, 0, 13], ["+", 51, 2, 3, 4, 0, 2, 3, 4, 0, 13], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13]]
1
401
#ifndef SEGMENT_TREE_HPP #define SEGMENT_TREE_HPP #include <functional> #include <iterator> #include <vector> //=== template <class Monoid> struct SegmentTree { using T = typename Monoid::value_type; std::vector<T> tree; SegmentTree() = default; explicit SegmentTree(int n) : tree(n << 1, Monoid::identity())...
#ifndef SEGMENT_TREE_HPP #define SEGMENT_TREE_HPP #include <functional> #include <iterator> #include <vector> //=== template <class Monoid> struct SegmentTree { using T = typename Monoid::value_type; std::vector<T> tree; SegmentTree() = default; explicit SegmentTree(int n) : tree(n << 1, Monoid::identity())...
[["+", 3, 4, 0, 69, 341, 342, 0, 69, 28, 22], ["+", 0, 69, 341, 342, 0, 69, 341, 342, 0, 70], ["+", 0, 69, 341, 342, 0, 69, 341, 342, 0, 73]]
1
961
#include <bits/stdc++.h> typedef long long int ll; using namespace std; #define sz 300009 #define mx 10000000000008 #define mod 1000000007 ll n, tt, arr[sz], t[4 * sz]; ll query(ll node, ll l, ll r, ll le, ll ri) { if (le > ri || l > ri || r < le) return 0; if (le <= l && r <= ri) return t[node]; ll mid =...
#include <bits/stdc++.h> typedef long long int ll; using namespace std; #define sz 300009 #define mx 10000000000008 #define mod 1000000007 ll n, tt, arr[sz], t[4 * sz]; ll query(ll node, ll l, ll r, ll le, ll ri) { if (le > ri || l > ri || r < le) return 0; if (le <= l && r <= ri) return t[node]; ll mid =...
[["-", 0, 57, 64, 9, 0, 1, 0, 11, 17, 107], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 17, 32]]
1
396
#include <bits/stdc++.h> using ll = long long; using uint = unsigned int; using ull = unsigned long long; using ld = long double; template <typename T> using max_heap = std::priority_queue<T>; template <typename T> using min_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>; constexpr int popcount(const u...
#include <bits/stdc++.h> using ll = long long; using uint = unsigned int; using ull = unsigned long long; using ld = long double; template <typename T> using max_heap = std::priority_queue<T>; template <typename T> using min_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>; constexpr int popcount(const u...
[["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13]]
1
2,254
import sys def input(): return sys.stdin.readline().strip() def list2d(a, b, c): return [[c for j in range(b)] for i in range(a)] def list3d(a, b, c, d): return [[[d for k in range(c)] for j in range(b)] for i in range(a)] def list4d(a, b, c, d, e): return [[[[e for l in range(d)] for k in range(c)] for j in range(b)]...
import sys def input(): return sys.stdin.readline().strip() def list2d(a, b, c): return [[c for j in range(b)] for i in range(a)] def list3d(a, b, c, d): return [[[d for k in range(c)] for j in range(b)] for i in range(a)] def list4d(a, b, c, d, e): return [[[[e for l in range(d)] for k in range(c)] for j in range(b)]...
[["-", 0, 662, 12, 652, 3, 4, 0, 657, 31, 22], ["+", 0, 662, 12, 652, 3, 4, 0, 657, 31, 22], ["-", 3, 4, 0, 657, 12, 23, 0, 657, 31, 22], ["+", 3, 4, 0, 657, 12, 23, 0, 657, 31, 22], ["-", 3, 4, 0, 657, 31, 652, 3, 4, 0, 22], ["+", 3, 4, 0, 657, 31, 652, 3, 4, 0, 22]]
5
952
/* Created by Rahul Goel. */ #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> /*******************************************************************************/ using namespace std; using namespace __gnu_pbds; template <typename T> using ordered_set = tree<T,...
/* Created by Rahul Goel. */ #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> /*******************************************************************************/ using namespace std; using namespace __gnu_pbds; template <typename T> using ordered_set = tree<T,...
[["-", 49, 50, 51, 2, 3, 4, 0, 16, 31, 22], ["+", 49, 50, 51, 2, 3, 4, 0, 16, 31, 13], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 31, 22], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 31, 13]]
1
735
// includes #include <bits/stdc++.h> using namespace std; // macros #define pb emplace_back #define mk make_pair #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define rep(i, n) FOR(i, 0, n) #define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--) #define irep(itr, st) for (auto itr = (st).begin(); itr != (st)...
// includes #include <bits/stdc++.h> using namespace std; // macros #define pb emplace_back #define mk make_pair #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define rep(i, n) FOR(i, 0, n) #define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--) #define irep(itr, st) for (auto itr = (st).begin(); itr != (st)...
[["-", 0, 43, 49, 53, 54, 55, 0, 56, 39, 78], ["+", 0, 43, 49, 53, 54, 55, 0, 56, 39, 78]]
1
1,616
#pragma GCC optimize("Ofast") #define _USE_MATH_DEFINES #include "bits/stdc++.h" using namespace std; using u8 = uint8_t; using u16 = uint16_t; using u32 = uint32_t; using u64 = uint64_t; using i8 = int8_t; using i16 = int16_t; using i32 = int32_t; using i64 = int64_t; using vi = vector<int>; constexpr char newl = ...
#pragma GCC optimize("Ofast") #define _USE_MATH_DEFINES #include "bits/stdc++.h" using namespace std; using u8 = uint8_t; using u16 = uint16_t; using u32 = uint32_t; using u64 = uint64_t; using i8 = int8_t; using i16 = int16_t; using i32 = int32_t; using i64 = int64_t; using vi = vector<int>; constexpr char newl = ...
[["-", 0, 16, 12, 118, 28, 2, 3, 4, 0, 22], ["+", 0, 16, 12, 118, 28, 2, 3, 4, 0, 13]]
1
1,873
#include <bits/stdc++.h> using namespace std; #define maxn 3000005 int tree[4 * maxn], f[maxn], a[maxn], lazy[4 * maxn]; void pushup(int i) { tree[i] = max(tree[i << 1], tree[i << 1 | 1]); } void xia(int i, int l, int r) { tree[i << 1] = max(tree[i << 1], lazy[i]); tree[i << 1 | 1] = max(tree[i << 1 | 1], lazy[i]);...
#include <bits/stdc++.h> using namespace std; #define maxn 300005 int tree[4 * maxn], f[maxn], a[maxn], lazy[4 * maxn]; void pushup(int i) { tree[i] = max(tree[i << 1], tree[i << 1 | 1]); } void xia(int i, int l, int r) { tree[i << 1] = max(tree[i << 1], lazy[i]); tree[i << 1 | 1] = max(tree[i << 1 | 1], lazy[i]); ...
[["-", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["+", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["-", 12, 2, 3, 4, 0, 2, 3, 4, 0, 13], ["+", 12, 2, 3, 4, 0, 2, 3, 4, 0, 13], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13]]
1
1,146
#include <stdio.h> int S[4 * 300010]; int T, NN = 0; //評価関数(今はMIN) int hyoka(int a, int b) { return a > b ? a : b; } //セグ木を長さnの数列dで初期化、構成 void sset(int n) { int i; for (T = 1; T < n; T *= 2) ; for (i = 0; i < T * 2; i++) S[i] = NN; } //セグ木のupdate関数 // i番目の数値をnに変更、再構成 void sud(int i, int n) { for (S[i +=...
#include <stdio.h> int S[4 * 300010]; int T, NN = 0; //評価関数(今はMIN) int hyoka(int a, int b) { return a > b ? a : b; } //セグ木を長さnの数列dで初期化、構成 void sset(int n) { int i; for (T = 1; T < n; T *= 2) ; for (i = 0; i < T * 2; i++) S[i] = NN; } //セグ木のupdate関数 // i番目の数値をnに変更、再構成 void sud(int i, int n) { for (S[i +=...
[["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13]]
0
439
#from collections import deque, Counter #from heapq import heapify, heappop, heappush #from bisect import insort #from math import gcd #from decimal import Decimal #mod = 1000000007 #mod = 998244353 #N = int(input()) #####segfunc##### def segfunc(x, y): return max(x, y) ################# #####ide_ele##### ide_ele...
#from collections import deque, Counter #from heapq import heapify, heappop, heappush #from bisect import insort #from math import gcd #from decimal import Decimal #mod = 1000000007 #mod = 998244353 #N = int(input()) #####segfunc##### def segfunc(x, y): return max(x, y) ################# #####ide_ele##### ide_ele...
[["-", 0, 7, 8, 196, 0, 1, 0, 677, 31, 22], ["-", 0, 7, 8, 196, 0, 1, 0, 677, 17, 110], ["-", 0, 7, 8, 196, 0, 1, 0, 677, 12, 612]]
5
430
N,k=map(int,input().split()) n=3*10**5 #####segfunc###### def segfunc(x,y): return max(x,y) def init(init_val): #set_val for i in range(n): seg[i+num-1]=init_val[i] #built for i in range(num-2,-1,-1) : seg[i]=segfunc(seg[2*i+1],seg[2*i+2]) def update(k,x): k += num-1 ...
N,k=map(int,input().split()) n=3*10**5+10 #####segfunc###### def segfunc(x,y): return max(x,y) def init(init_val): #set_val for i in range(n): seg[i+num-1]=init_val[i] #built for i in range(num-2,-1,-1) : seg[i]=segfunc(seg[2*i+1],seg[2*i+2]) def update(k,x): k += num-...
[["+", 0, 656, 0, 1, 0, 662, 12, 657, 17, 72], ["+", 0, 656, 0, 1, 0, 662, 12, 657, 12, 612], ["-", 8, 196, 0, 1, 0, 662, 12, 657, 17, 33], ["-", 8, 196, 0, 1, 0, 662, 12, 657, 12, 612]]
5
373
#include <bits/stdc++.h> using namespace std; int Read() { int x = 0, f = 1; char ch = getchar(); while (!isdigit(ch)) { if (ch == '-') f = -1; ch = getchar(); } while (isdigit(ch)) { x = (x << 3) + (x << 1) + ch - '0'; ch = getchar(); } return x * f; } int n, k, f[300055], maxn[1200...
#include <bits/stdc++.h> using namespace std; int Read() { int x = 0, f = 1; char ch = getchar(); while (!isdigit(ch)) { if (ch == '-') f = -1; ch = getchar(); } while (isdigit(ch)) { x = (x << 3) + (x << 1) + ch - '0'; ch = getchar(); } return x * f; } int n, k, f[600055], maxn[2400...
[["-", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["-", 0, 11, 12, 16, 31, 2, 3, 4, 0, 22], ["+", 0, 11, 12, 16, 31, 2, 3, 4, 0, 13], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13]]
1
495
/* * じょえチャンネル * 高評価・チャンネル登録よろしくおねがいします! * https://www.youtube.com/channel/UCRXsI3FL_kvaVL9zoolBfbQ */ #include <algorithm> #include <bitset> #include <cassert> #include <cfloat> #include <climits> #include <cmath> #include <complex> #include <ctime> #include <deque> #include <fstream> #include <functional> #includ...
/* * じょえチャンネル * 高評価・チャンネル登録よろしくおねがいします! * https://www.youtube.com/channel/UCRXsI3FL_kvaVL9zoolBfbQ */ #include <algorithm> #include <bitset> #include <cassert> #include <cfloat> #include <climits> #include <cmath> #include <complex> #include <ctime> #include <deque> #include <fstream> #include <functional> #includ...
[["-", 8, 9, 0, 43, 49, 50, 51, 4, 0, 13], ["+", 8, 9, 0, 43, 49, 50, 51, 4, 0, 13], ["-", 3, 4, 0, 2, 3, 4, 0, 16, 12, 13], ["+", 3, 4, 0, 2, 3, 4, 0, 16, 12, 13]]
1
3,129
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; #define ll long long #define X first #define Y second #define all(x) x.begin(), x.end() #define ordered_set ...
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; #define ll long long #define X first #define Y second #define all(x) x.begin(), x.end() #define ordered_set ...
[["-", 0, 57, 64, 9, 0, 1, 0, 11, 17, 107], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 17, 32]]
1
1,282
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i, n) for (ll i = 0; i < n; ++i) #define all(c) begin(c), end(c) #define PI acos(-1) #define oo LLONG_MAX template <typename T1, typename T2> bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return true; } else return false; } ...
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i, n) for (ll i = 0; i < n; ++i) #define all(c) begin(c), end(c) #define PI acos(-1) #define oo LLONG_MAX template <typename T1, typename T2> bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return true; } else return false; } ...
[["-", 8, 9, 0, 43, 49, 50, 51, 4, 0, 13], ["+", 8, 9, 0, 43, 49, 50, 51, 4, 0, 13], ["-", 0, 43, 49, 50, 51, 2, 3, 4, 0, 22], ["+", 0, 43, 49, 50, 51, 2, 3, 4, 0, 13], ["-", 0, 43, 49, 50, 51, 2, 3, 4, 0, 13]]
1
862
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <map> #include <queue> #define N1 200005 #define ll long long #define inf 0x3f3f3f3f #define mod 998244353 using namespace std; int n, Q; ll val[10][N1], m10[N1]; struct SEG { ll sum[N1 << 2]; int tag[N1]; void pushup(int len, i...
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <map> #include <queue> #define N1 200005 #define ll long long #define inf 0x3f3f3f3f #define mod 998244353 using namespace std; int n, Q; ll val[10][N1], m10[N1]; struct SEG { ll sum[N1 << 2]; int tag[N1 << 2]; void pushup(int l...
[["+", 8, 123, 0, 124, 49, 80, 81, 16, 17, 151], ["+", 8, 123, 0, 124, 49, 80, 81, 16, 12, 13]]
1
581
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> // Common file #include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update #define MIN(a, b) (((a) < (b)) ? (a) : (b)) #define MAX(a, b) (((a) < (b)) ? (b) : (a)) using namespace std; using namespace __gnu_pbds; auto random_addres...
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> // Common file #include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update #define MIN(a, b) (((a) < (b)) ? (a) : (b)) #define MAX(a, b) (((a) < (b)) ? (b) : (a)) using namespace std; using namespace __gnu_pbds; auto random_addres...
[["+", 0, 1, 0, 11, 12, 16, 31, 23, 0, 24], ["+", 31, 23, 0, 16, 12, 16, 31, 23, 0, 25], ["+", 12, 16, 31, 23, 0, 16, 12, 16, 17, 109], ["+", 12, 16, 31, 23, 0, 16, 12, 16, 12, 22]]
1
597
#include <algorithm> #include <bitset> #include <cmath> #include <cstdio> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <string> #include <vector> #define rep(i, n) for (int i = 0; i < (n); i++) #define repi(i, a, b) for (int i = int(a); i < int(b); ++i) #define r...
#include <algorithm> #include <bitset> #include <cmath> #include <cstdio> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <string> #include <vector> #define rep(i, n) for (int i = 0; i < (n); i++) #define repi(i, a, b) for (int i = int(a); i < int(b); ++i) #define r...
[["-", 0, 43, 49, 50, 51, 2, 3, 4, 0, 22], ["+", 0, 43, 49, 50, 51, 2, 3, 4, 0, 13]]
1
673
# 0-index segment tree class SegmentTree: """ init(init_val, ide_ele): 配列init_valで初期化 O(N) update(k, x): k番目の値をxに更新 O(logN) query(l, r): 区間[l, r)をsegfuncしたものを返す O(logN) """ def __init__(self, init_val, segfunc, ide_ele): """ init_val: 配列の初期値 segfunc: ...
# 0-index segment tree class SegmentTree: """ init(init_val, ide_ele): 配列init_valで初期化 O(N) update(k, x): k番目の値をxに更新 O(logN) query(l, r): 区間[l, r)をsegfuncしたものを返す O(logN) """ def __init__(self, init_val, segfunc, ide_ele): """ init_val: 配列の初期値 segfunc: ...
[["-", 36, 36, 0, 656, 0, 1, 0, 662, 12, 612], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 12, 612]]
5
477
#include <algorithm> #include <chrono> #include <cmath> #include <deque> #include <fstream> #include <functional> #include <iostream> #include <iterator> #include <limits> #include <list> #include <map> #include <queue> #include <random> #include <set> #include <sstream> #include <stack> #include <string> #include <uno...
#include <algorithm> #include <chrono> #include <cmath> #include <deque> #include <fstream> #include <functional> #include <iostream> #include <iterator> #include <limits> #include <list> #include <map> #include <queue> #include <random> #include <set> #include <sstream> #include <stack> #include <string> #include <uno...
[["-", 3, 4, 0, 2, 3, 4, 0, 16, 31, 22], ["-", 3, 4, 0, 2, 3, 4, 0, 16, 17, 72], ["-", 3, 4, 0, 2, 3, 4, 0, 16, 12, 13], ["+", 51, 2, 3, 4, 0, 2, 3, 4, 0, 13]]
1
975
def segfunc(x, y): return max(x, y) class SegmentTree: def __init__(self, arr): size = len(arr) n = 2 ** (size - 1).bit_length() self.n = n self.node = [0] * (2*n) for i in range(size): self.node[i+n-1] = arr[i] for i in reversed(range(n-2)): ...
def segfunc(x, y): return max(x, y) class SegmentTree: def __init__(self, arr): size = len(arr) n = 2 ** (size - 1).bit_length() self.n = n self.node = [0] * (2*n) for i in range(size): self.node[i+n-1] = arr[i] for i in reversed(range(n-2)): ...
[["-", 0, 662, 12, 652, 3, 4, 0, 657, 12, 22], ["+", 0, 662, 12, 652, 3, 4, 0, 657, 12, 612], ["-", 0, 652, 3, 4, 0, 652, 3, 4, 0, 22], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 612]]
5
477
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rrep(ri, n) for (int ri = (int)(n - 1); ri >= 0; ri--) #define rep2(i, x, n) for (int i = (int)(x); i < (int)(n); i++) #define rrep2(ri, x, n) for (int ri = (int)(n - 1); ri >= (int)(x); ri--) #define repit(itr, x) for (auto itr = x.b...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rrep(ri, n) for (int ri = (int)(n - 1); ri >= 0; ri--) #define rep2(i, x, n) for (int i = (int)(x); i < (int)(n); i++) #define rrep2(ri, x, n) for (int ri = (int)(n - 1); ri >= (int)(x); ri--) #define repit(itr, x) for (auto itr = x.b...
[["-", 0, 43, 49, 53, 54, 55, 0, 56, 39, 78], ["+", 8, 9, 0, 43, 49, 50, 51, 4, 0, 13], ["-", 0, 14, 8, 9, 0, 1, 0, 27, 28, 22], ["-", 0, 14, 8, 9, 0, 1, 0, 27, 17, 68], ["-", 8, 9, 0, 14, 8, 9, 0, 1, 0, 35], ["-", 51, 2, 3, 4, 0, 2, 3, 4, 0, 22], ["+", 51, 2, 3, 4, 0, 2, 3, 4, 0, 13]]
1
14,939
# 0-indexed class SegTree: def __init__(self, vals, seg_f, ide_ele): n = len(vals) self.seg_f = seg_f self.ide_ele = ide_ele self.leaf_n = 1 << (n-1).bit_length() self.tree = [ide_ele]*(2*self.leaf_n-1) for i in range(n): # init leaf self.tree[i+self.leaf...
# 0-indexed class SegTree: def __init__(self, vals, seg_f, ide_ele): n = len(vals) self.seg_f = seg_f self.ide_ele = ide_ele self.leaf_n = 1 << (n-1).bit_length() self.tree = [ide_ele]*(2*self.leaf_n-1) for i in range(n): # init leaf self.tree[i+self.leaf...
[["-", 0, 1, 0, 662, 12, 652, 3, 4, 0, 612], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 612]]
5
447
#include <bits/stdc++.h> using namespace std; const int N = 6e5 + 7; int n, a[N], k, tree[4 * N]; #define m (l + r) / 2 #define lson 2 * node #define rson 2 * node + 1 void update(int pos, int v, int l, int r, int node) { if (l == r) { tree[node] = v; } if (pos <= m) update(pos, v, l, m, lson); else ...
#include <bits/stdc++.h> using namespace std; const int N = 6e5 + 7; int n, a[N], k, tree[4 * N]; #define m (l + r) / 2 #define lson 2 * node #define rson 2 * node + 1 void update(int pos, int v, int l, int r, int node) { if (l == r) { tree[node] = v; return; } if (pos <= m) update(pos, v, l, m, ls...
[["+", 8, 9, 0, 57, 64, 9, 0, 37, 0, 38], ["+", 8, 9, 0, 57, 64, 9, 0, 37, 0, 35]]
1
361
#include <bits/stdc++.h> #define rep(i, a, b) for (ll i = ll(a); i < ll(b); i++) #define irep(i, a, b) for (ll i = ll(a); i >= ll(b); i--) template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { ...
#include <bits/stdc++.h> #define rep(i, a, b) for (ll i = ll(a); i < ll(b); i++) #define irep(i, a, b) for (ll i = ll(a); i >= ll(b); i--) template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { ...
[["-", 0, 43, 49, 50, 51, 2, 3, 4, 0, 22], ["+", 0, 43, 49, 50, 51, 2, 3, 4, 0, 13]]
1
1,201
#pragma GCC optimize("O3") #pragma GCC target("sse4") #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef double db; typedef string str; typedef pair<int, int> pi; typedef pair<ll, ll> pl; typedef pair<db, db> pd; typedef vector<int> vi; typedef vector<ll> vl; typedef...
#pragma GCC optimize("O3") #pragma GCC target("sse4") #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef double db; typedef string str; typedef pair<int, int> pi; typedef pair<ll, ll> pl; typedef pair<db, db> pd; typedef vector<int> vi; typedef vector<ll> vl; typedef...
[["-", 49, 50, 51, 2, 3, 4, 0, 16, 31, 22], ["+", 49, 50, 51, 2, 3, 4, 0, 16, 31, 22]]
1
1,095
class SegmentTree: ''' Segment tree。区間を表す関数の引数は全て閉区間で統一する(search系の戻り値を考慮) -------- n:要素数, func:演算(モノイド), e:単位元(モノイド), init_list:初期値 ''' def __init__(self, n, func=lambda x, y : max(x, y), e = -float('inf'), init_list = None): assert n > 0 and (not init_list or len(init_list) <= n) ...
class SegmentTree: ''' Segment tree。区間を表す関数の引数は全て閉区間で統一する(search系の戻り値を考慮) -------- n:要素数, func:演算(モノイド), e:単位元(モノイド), init_list:初期値 ''' def __init__(self, n, func=lambda x, y : max(x, y), e = -float('inf'), init_list = None): assert n > 0 and (not init_list or len(init_list) <= n) ...
[["-", 36, 36, 0, 656, 0, 1, 0, 662, 12, 612], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 12, 612]]
5
1,309
def segfunc(x,y):#自分で設定 return max(x,y) def init(init_val): #set_val for i in range(n): seg[i+num-1]=init_val[i] #built for i in range(num-2,-1,-1) : seg[i]=segfunc(seg[2*i+1],seg[2*i+2]) def update(k,x): k += num-1 seg[k] = x while k: k = (k-1)//2 ...
def segfunc(x,y):#自分で設定 return max(x,y) def init(init_val): #set_val for i in range(n): seg[i+num-1]=init_val[i] #built for i in range(num-2,-1,-1) : seg[i]=segfunc(seg[2*i+1],seg[2*i+2]) def update(k,x): k += num-1 seg[k] = x while k: k = (k-1)//2 ...
[["-", 0, 656, 0, 1, 0, 662, 12, 658, 8, 612], ["+", 0, 656, 0, 1, 0, 662, 12, 658, 8, 612], ["-", 31, 652, 3, 4, 0, 652, 3, 4, 0, 612], ["+", 31, 652, 3, 4, 0, 652, 3, 4, 0, 612], ["+", 3, 4, 0, 652, 3, 4, 0, 657, 17, 72], ["+", 3, 4, 0, 652, 3, 4, 0, 657, 12, 612]]
5
403
#include <bits/stdc++.h> #define _GLIBCXX_DEBUG #define all(v) (v).begin(), (v).end() using namespace std; using ll = long long; using ld = long double; using pii = pair<int, int>; using vi = vector<int>; using vii = vector<vector<int>>; const ll LINF = 1LL << 60; const int INF = 1 << 29; const int MOD = 1e9 + 7; ...
#include <bits/stdc++.h> #define _GLIBCXX_DEBUG #define all(v) (v).begin(), (v).end() using namespace std; using ll = long long; using ld = long double; using pii = pair<int, int>; using vi = vector<int>; using vii = vector<vector<int>>; const ll LINF = 1LL << 60; const int INF = 1 << 29; const int MOD = 1e9 + 7; ...
[["+", 0, 16, 31, 69, 341, 342, 0, 16, 17, 33], ["+", 0, 16, 31, 69, 341, 342, 0, 16, 12, 13], ["+", 0, 16, 31, 2, 3, 4, 0, 16, 17, 72], ["+", 0, 16, 31, 2, 3, 4, 0, 16, 12, 13]]
1
572
#####segfunc##### def segfunc(x, y): return max(x,y) ################# #####ide_ele##### ide_ele = 0 ################# class SegTree: """ init(init_val, ide_ele): 配列init_valで初期化 O(N) update(k, x): k番目の値をxに更新 O(logN) query(l, r): 区間[l, r)をsegfuncしたものを返す O(logN) """ def __init__(self, init_v...
#####segfunc##### def segfunc(x, y): return max(x,y) ################# #####ide_ele##### ide_ele = 0 ################# class SegTree: """ init(init_val, ide_ele): 配列init_valで初期化 O(N) update(k, x): k番目の値をxに更新 O(logN) query(l, r): 区間[l, r)をsegfuncしたものを返す O(logN) """ def __init__(self, init_v...
[["-", 3, 4, 0, 652, 3, 4, 0, 657, 17, 72], ["-", 3, 4, 0, 652, 3, 4, 0, 657, 12, 612]]
5
438
// include //------------------------------------------ #include <algorithm> #include <bitset> #include <deque> #include <functional> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> #include <complex> #include <numeric> #include <utility> #include <i...
// include //------------------------------------------ #include <algorithm> #include <bitset> #include <deque> #include <functional> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> #include <complex> #include <numeric> #include <utility> #include <i...
[["+", 31, 16, 31, 16, 31, 23, 0, 16, 17, 72], ["+", 31, 16, 31, 16, 31, 23, 0, 16, 12, 22], ["+", 31, 16, 12, 16, 31, 16, 31, 16, 17, 109], ["+", 31, 16, 12, 16, 31, 16, 31, 16, 12, 22]]
1
3,540
#include <bits/stdc++.h> #include <complex> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using namespace std; #define ll long long #define ull unsigned long long #define f first #define s second typedef pair<int, int> pii; typedef pair<ll, ll> pll; #define o...
#include <bits/stdc++.h> #include <complex> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using namespace std; #define ll long long #define ull unsigned long long #define f first #define s second typedef pair<int, int> pii; typedef pair<ll, ll> pll; #define o...
[["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]]
1
1,322
#include <algorithm> #include <cstdio> #include <cstring> #include <iostream> #include <queue> #define LL long long #define maxn 200005 using namespace std; const LL mod = 998244353; int n, v[maxn << 2], q, a[maxn]; LL mp[11][maxn], M[maxn]; void Init() { for (int i = 1; i <= 9; i++) { mp[i][0] = 0; for (i...
#include <algorithm> #include <cstdio> #include <cstring> #include <iostream> #include <queue> #define LL long long #define maxn 200005 using namespace std; const LL mod = 998244353; int n, v[maxn << 2], q, a[maxn]; LL mp[11][maxn], M[maxn << 2]; void Init() { for (int i = 1; i <= 9; i++) { mp[i][0] = 0; f...
[["+", 0, 30, 0, 43, 49, 80, 81, 16, 17, 151], ["+", 0, 30, 0, 43, 49, 80, 81, 16, 12, 13]]
1
688
#include <bits/stdc++.h> using namespace std; const int mod = 998244353; const int MAXN = 400010; using ll = long long; ll popsum[MAXN]; using PII = pair<int, int>; using PIII = pair<PII, int>; set<PIII> st; int main() { int n, m; scanf("%d%d", &n, &m); popsum[0] = 0; int po10 = 0; for (int i = 1; i <= n; ...
#include <bits/stdc++.h> using namespace std; const int mod = 998244353; const int MAXN = 400010; using ll = long long; ll popsum[MAXN]; using PII = pair<int, int>; using PIII = pair<PII, int>; set<PIII> st; int main() { int n, m; scanf("%d%d", &n, &m); popsum[0] = 0; ll po10 = 0; for (int i = 1; i <= n; i...
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78]]
1
533
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define re register #define ls (o << 1) #define m (l + r) / 2 #define rs (o << 1 | 1) #define pb push_back const double PI = acos(-1.0); const int M = 1e5 + 7; /* int head[M],cnt=1; void init(int n){cnt=1;for(int i=0;i<=n;i++)head[i]=0;} struct EDGE{in...
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define re register #define ls (o << 1) #define m (l + r) / 2 #define rs (o << 1 | 1) #define pb push_back const double PI = acos(-1.0); const int M = 1e6 + 7; /* int head[M],cnt=1; void init(int n){cnt=1;for(int i=0;i<=n;i++)head[i]=0;} struct EDGE{in...
[["-", 0, 30, 0, 43, 49, 50, 51, 16, 31, 13], ["+", 0, 30, 0, 43, 49, 50, 51, 16, 31, 13]]
1
723
#include <iostream> #include <numeric> #include <set> #include <vector> using namespace std; class UnionFind { vector<int> par, rank, size; public: explicit UnionFind(int n) : par(n), rank(n, 0), size(n, 1) { iota(par.begin(), par.end(), 0); } int find(int i) { return (par[i] == i) ? i : (par[i] = find(p...
#include <iostream> #include <numeric> #include <set> #include <vector> using namespace std; class UnionFind { vector<int> par, rank, size; public: explicit UnionFind(int n) : par(n), rank(n, 0), size(n, 1) { iota(par.begin(), par.end(), 0); } int find(int i) { return (par[i] == i) ? i : (par[i] = find(p...
[["-", 0, 57, 15, 339, 51, 16, 31, 118, 119, 120], ["+", 0, 57, 15, 339, 51, 16, 31, 118, 119, 120]]
1
454
import sys import heapq, functools, collections import math, random from collections import Counter, defaultdict from atcoder.fenwicktree import FenwickTree # available on Google, not available on Codeforces # import numpy as np # import scipy def solve(grid, n): # fix inputs here console("----- solving ------...
import sys import heapq, functools, collections import math, random from collections import Counter, defaultdict # from atcoder.fenwicktree import FenwickTree # available on Google, not available on Codeforces # import numpy as np # import scipy def solve(grid, n): # fix inputs here console("----- solving ----...
[["-", 36, 36, 36, 36, 0, 656, 0, 686, 0, 314], ["-", 36, 36, 0, 656, 0, 686, 687, 673, 0, 22], ["-", 36, 36, 0, 656, 0, 686, 687, 673, 0, 131], ["-", 36, 36, 36, 36, 0, 656, 0, 686, 0, 487], ["-", 36, 36, 0, 656, 0, 686, 141, 673, 0, 22]]
5
513
#include <bits/stdc++.h> using namespace std; const long long MOD = 998244353; vector<int> parent; int getRoot(int idx) { if (parent[idx] != idx) { parent[idx] = getRoot(parent[idx]); } return parent[idx]; } void fusion(vector<tuple<int, int, int>> &coordinates, int left, int right) { if (right - left ...
#include <bits/stdc++.h> using namespace std; const long long MOD = 998244353; vector<int> parent; int getRoot(int idx) { if (parent[idx] != idx) { parent[idx] = getRoot(parent[idx]); } return parent[idx]; } void fusion(vector<tuple<int, int, int>> &coordinates, int left, int right) { if (right - left ...
[["+", 8, 9, 0, 43, 49, 50, 51, 2, 63, 22], ["+", 0, 43, 49, 50, 51, 2, 3, 4, 0, 24], ["+", 51, 2, 3, 4, 0, 2, 3, 4, 0, 25]]
1
603
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; #define ll long long #define FI first #define SE second #define pb push_back #define eb emplace_back #define mod 1000000007 #define all(c) (c).begin(), (c).end() #defi...
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; #define ll long long #define FI first #define SE second #define pb push_back #define eb emplace_back #define mod 1000000007 #define all(c) (c).begin(), (c).end() #defi...
[["-", 0, 16, 12, 118, 28, 118, 28, 69, 28, 22], ["+", 0, 16, 12, 118, 28, 118, 28, 69, 28, 22], ["-", 0, 2, 3, 4, 0, 118, 28, 69, 28, 22], ["+", 0, 2, 3, 4, 0, 118, 28, 69, 28, 22], ["-", 0, 1, 0, 2, 3, 4, 0, 69, 28, 22], ["+", 0, 1, 0, 2, 3, 4, 0, 69, 28, 22]]
1
858
from functools import reduce from math import gcd import math import bisect import itertools import sys sys.setrecursionlimit(10000000) input = sys.stdin.readline INF = float("inf") # update: node[x] を更新する # getmin: 区間 [a, b) の最小値を返す class SegmentTree: def __init__(self, arr): size = len(arr) n = ...
from functools import reduce from math import gcd import math import bisect import itertools import sys sys.setrecursionlimit(10000000) input = sys.stdin.readline INF = float("inf") # update: node[x] を更新する # getmin: 区間 [a, b) の最小値を返す class SegmentTree: def __init__(self, arr): size = len(arr) n = ...
[["-", 12, 657, 31, 652, 3, 4, 0, 657, 17, 72], ["-", 12, 657, 31, 652, 3, 4, 0, 657, 12, 612]]
5
411
#include <algorithm> #include <bitset> #include <cmath> #include <cstdio> #include <cstring> #include <deque> #include <forward_list> #include <functional> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <tuple> #include <utility> #include <vector> #define...
#include <algorithm> #include <bitset> #include <cmath> #include <cstdio> #include <cstring> #include <deque> #include <forward_list> #include <functional> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <tuple> #include <utility> #include <vector> #define...
[["+", 8, 9, 0, 1, 0, 11, 12, 2, 63, 22], ["+", 0, 1, 0, 11, 12, 2, 3, 4, 0, 24], ["+", 0, 1, 0, 11, 12, 2, 3, 4, 0, 22], ["+", 0, 1, 0, 11, 12, 2, 3, 4, 0, 21], ["+", 12, 2, 3, 4, 0, 2, 3, 4, 0, 25]]
1
655
// URL : https://atcoder.jp/contests/abl/tasks/abl_d #pragma region optimize // #pragma GCC optimize("Ofast") // #pragma GCC optimize("unroll-loops") // #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx") #pragma endregion #include <bits/stdc++.h> // #include <atcoder/all> using namespace std; #pragma reg...
// URL : https://atcoder.jp/contests/abl/tasks/abl_d #pragma region optimize // #pragma GCC optimize("Ofast") // #pragma GCC optimize("unroll-loops") // #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx") #pragma endregion #include <bits/stdc++.h> // #include <atcoder/all> using namespace std; #pragma reg...
[["-", 49, 50, 51, 2, 3, 4, 0, 16, 31, 22], ["-", 49, 50, 51, 2, 3, 4, 0, 16, 17, 33], ["-", 49, 50, 51, 2, 3, 4, 0, 16, 12, 13], ["+", 0, 43, 49, 50, 51, 2, 3, 4, 0, 13]]
1
2,774
import sys, math import io, os #data = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline from bisect import bisect_left as bl, bisect_right as br, insort from heapq import heapify, heappush, heappop from collections import defaultdict as dd, deque, Counter # from itertools import permutations,combinations def data():...
import sys, math import io, os #data = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline from bisect import bisect_left as bl, bisect_right as br, insort from heapq import heapify, heappush, heappop from collections import defaultdict as dd, deque, Counter # from itertools import permutations,combinations def data():...
[["-", 31, 652, 3, 4, 0, 652, 3, 4, 0, 612], ["+", 31, 652, 3, 4, 0, 652, 3, 4, 0, 612]]
5
466
#include <bits/stdc++.h> using namespace std; #include <iomanip> #include <math.h> template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } const int INF = 30000...
#include <bits/stdc++.h> using namespace std; #include <iomanip> #include <math.h> template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } const int INF = 60000...
[["-", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 21], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["-", 49, 50, 51, 4, 0, 2, 3, 4, 0, 22], ["+", 49, 50, 51, 4, 0, 2, 3, 4, 0, 22]]
1
545
#include <algorithm> #include <bitset> #include <cmath> #include <cstdio> #include <deque> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <utility> #include <vector> #define rep(i, n, m) for (int i = (n); i < (int)(m); i++) #define re...
#include <algorithm> #include <bitset> #include <cmath> #include <cstdio> #include <deque> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <utility> #include <vector> #define rep(i, n, m) for (int i = (n); i < (int)(m); i++) #define re...
[["-", 0, 43, 49, 50, 51, 2, 3, 4, 0, 22], ["+", 0, 43, 49, 50, 51, 2, 3, 4, 0, 13]]
1
874
#include <algorithm> #include <bitset> #include <cassert> #include <climits> #include <cmath> #include <cstdlib> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <string> #include <vector> #define DEBUG 1 using namespace std; constexpr int kMod = 1000000007; typedef long lo...
#include <algorithm> #include <bitset> #include <cassert> #include <climits> #include <cmath> #include <cstdlib> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <string> #include <vector> #define DEBUG 1 using namespace std; constexpr int kMod = 1000000007; typedef long lo...
[["+", 8, 9, 0, 7, 8, 9, 0, 57, 0, 121], ["+", 0, 7, 8, 9, 0, 57, 15, 339, 0, 24], ["+", 0, 7, 8, 9, 0, 57, 15, 339, 51, 22], ["+", 0, 7, 8, 9, 0, 57, 15, 339, 0, 25]]
1
278
#include <iostream> #include <queue> #include <unordered_map> #include <vector> using namespace std; #define ll long long int n, k; int seg[600005]; int sz = 300000; void upd(int i, int v) { seg[i += sz] = v; while (i > 1) { i /= 2; seg[i] = max(seg[2 * i], seg[2 * i + 1]); } } int query(int l, int r) { ...
#include <iostream> #include <queue> #include <unordered_map> #include <vector> using namespace std; #define ll long long int n, k; int seg[600055]; int sz = 300005; void upd(int i, int v) { seg[i += sz] = v; while (i > 1) { i /= 2; seg[i] = max(seg[2 * i], seg[2 * i + 1]); } } int query(int l, int r) { ...
[["-", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["-", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13], ["-", 8, 9, 0, 7, 8, 1, 0, 27, 17, 68]]
1
312
n,k,*a=map(int,open(0).read().split()) d=[1]*n for i in range(n):d[i]=max(d[j]for j in range(max(0,i-99),i)if abs(a[i]-a[j])<=k)+1 print(max(d))
n,k,*a=map(int,open(0).read().split()) d=[0]*n for i in range(n):d[i]=max(d[j]for j in range(max(0,i-99),i+1)if abs(a[i]-a[j])<=k)+1 print(max(d))
[["-", 0, 1, 0, 662, 12, 657, 31, 634, 0, 612], ["+", 0, 1, 0, 662, 12, 657, 31, 634, 0, 612], ["+", 0, 659, 12, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 659, 12, 652, 3, 4, 0, 657, 12, 612]]
5
91
// #pragma GCC optimize ("O3") // #pragma GCC target ("sse4") #include <bits/stdc++.h> using namespace std; const int INF = 1 << 29; const int NINF = -1 * INF; const long long LLINF = 1ll << 60; const long long LLNINF = -1 * LLINF; template <class Ch, class Tr, class Container> basic_ostream<Ch, Tr> &operator<<(basic...
// #pragma GCC optimize ("O3") // #pragma GCC target ("sse4") #include <bits/stdc++.h> using namespace std; const int INF = 1 << 29; const int NINF = -1 * INF; const long long LLINF = 1ll << 60; const long long LLNINF = -1 * LLINF; template <class Ch, class Tr, class Container> basic_ostream<Ch, Tr> &operator<<(basic...
[["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 31, 13], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 22]]
1
802
#include <algorithm> #include <bitset> #include <cmath> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <regex> #include <set> #include <stack> #include <string> #include <tuple> #include <vector> using namespace std; template...
#include <algorithm> #include <bitset> #include <cmath> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <regex> #include <set> #include <stack> #include <string> #include <tuple> #include <vector> using namespace std; template...
[["-", 0, 43, 49, 50, 51, 2, 3, 4, 0, 22], ["+", 0, 43, 49, 50, 51, 2, 3, 4, 0, 13]]
1
804
import math import sys import os sys.setrecursionlimit(10**7) def _S(): return sys.stdin.readline().rstrip() def I(): return int(_S()) def LS(): return list(_S().split()) def LI(): return list(map(int,LS())) if os.getenv("LOCAL"): inputFile = basename_without_ext = os.path.splitext(os.path.basename(__file__))[0]...
import math import sys import os sys.setrecursionlimit(10**7) def _S(): return sys.stdin.readline().rstrip() def I(): return int(_S()) def LS(): return list(_S().split()) def LI(): return list(map(int,LS())) if os.getenv("LOCAL"): inputFile = basename_without_ext = os.path.splitext(os.path.basename(__file__))[0]...
[["-", 36, 36, 0, 656, 0, 1, 0, 652, 63, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 25]]
5
845
#define rep(i, n) for (int i = 0; i < (int)(n); i++) #define ALL(v) v.begin(), v.end() typedef long long ll; #include <bits/stdc++.h> using namespace std; const int INF = 2147483647; /* RMQ:[0,n-1] について、区間ごとの最小値を管理する構造体 set(int i, T x), build(): i番目の要素をxにセット。まとめてセグ木を構築する。O(n) update(i,x): i 番目の要素を x に更新。O(...
#define rep(i, n) for (int i = 0; i < (int)(n); i++) #define ALL(v) v.begin(), v.end() typedef long long ll; #include <bits/stdc++.h> using namespace std; const int INF = 2147483647; /* RMQ:[0,n-1] について、区間ごとの最小値を管理する構造体 set(int i, T x), build(): i番目の要素をxにセット。まとめてセグ木を構築する。O(n) update(i,x): i 番目の要素を x に更新。O(...
[["-", 8, 9, 0, 37, 0, 69, 341, 342, 0, 13], ["+", 8, 9, 0, 37, 0, 69, 341, 342, 0, 13], ["-", 0, 43, 49, 53, 54, 55, 0, 56, 39, 78], ["+", 8, 9, 0, 43, 49, 50, 51, 4, 0, 13], ["-", 49, 50, 51, 2, 3, 4, 0, 16, 31, 22], ["-", 49, 50, 51, 2, 3, 4, 0, 16, 17, 33], ["-", 49, 50, 51, 2, 3, 4, 0, 16, 12, 13], ["+", 0, 43, 49...
1
958
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (i = 0; i < n; ++i) #define all(v) v.begin(), v.end() using ll = long long; template <typename T> struct RUQ // calculateはminimum { int n; const T ex = 0; // dat 初期値(minなので) const T em = 0; // lazy 初期値(minなので) vector<T> dat, lazy; /...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (i = 0; i < n; ++i) #define all(v) v.begin(), v.end() using ll = long long; template <typename T> struct RUQ // calculateはminimum { int n; const T ex = 0; // dat 初期値(minなので) const T em = 0; // lazy 初期値(minなので) vector<T> dat, lazy; /...
[["-", 8, 9, 0, 43, 49, 50, 51, 4, 0, 22], ["+", 8, 9, 0, 43, 49, 50, 51, 4, 0, 22]]
1
902
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> p_ll; template <class T> void debug(T itr1, T itr2) { auto now = itr1; while (now < itr2) { cout << *now << " "; now++; } cout << endl; } #define repr(i, from, to) for (ll i = (ll)from; i < (ll)to; i++) #define al...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> p_ll; template <class T> void debug(T itr1, T itr2) { auto now = itr1; while (now < itr2) { cout << *now << " "; now++; } cout << endl; } #define repr(i, from, to) for (ll i = (ll)from; i < (ll)to; i++) #define al...
[["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13]]
1
831