criyle/codenet-compile-errors huggingface dataset:
Language: C++

//Compiler optimization
#pragma GCC optimize("Ofast")

//include
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;

//typedef
typedef long long ll;
typedef double db;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef string S;
typedef queue<int> qi;
typedef pair<ll,ll> P;
typedef vector<P> vp;
typedef vector<vl> mat;

//macro
#define reverse(a) reverse(a.begin(),a.end())
#define unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define fr(i,n)for(ll i=0;i<(n);i++)
#define ifr(i,n)for(ll i=(n)-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define each(x, v) for (auto &x : v)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
ll pow(ll a,ll n, ll m){
    ll ret=1;
    for(;n>0;n>>=1,a=a*a%m){
        if(n%2==1){
        ret=ret*a%m;
        }
    }
    return ret;
}

//abbreviation
#define pb push_back
#define elif else if
#define mp make_pair
#define endl '\n'

//debug
#define debug(x) cerr << #x << ": " << x << endl
#define v_debug(v) cerr << #v << endl;fr(i,v.size()) cerr << i << ": " << v[i] << endl

//const
const  ll INF = 1e18;
const int MAX_A = 300005;
using S = int;
S op(S x, S y){return max(x, y)};
S e() {return 0;}

atcoder::segtree<S, op, e> dp(MAX_A);

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << setprecision(20);
    int n,k; cin << n << k;
    vi a(n);
    fr(i,n)cin >> a[i];

    fr(i,n){
        int x = a[i];
        int l = max(0, x-k), r =min(x + k - 1, MAX_A);
        int now = dp.prod(l, r) + 1;
        dp.set(x, now);
    }
    int ans = dp.prod(0, MAX_A);
    cout << ans << endl;
    return 0;
}

Compiler output:
a.cc:6:10: fatal error: atcoder/all: No such file or directory
    6 | #include <atcoder/all>
      |          ^~~~~~~~~~~~~
compilation terminated.
Language: C++

#include<bits/stdc++.h>
using namespace std;

int n,k,result,a;
int t[1300000];

void update(int idx,int l,int r, int aim, int val){
    if (l == aim and aim == r){
        t[idx] = val;//这里是否可以直接赋值???
        return;
    }
    int mid = (l+r)>>1;
    if (aim <= mid){
        update(idx<<1,l,mid,aim,val);
    }
    else{
        update(idx<<1|1,mid+1,r,aim,val);
    }
    t[idx] = max(t[idx<<1],t[idx<<1|1]);
    return;
}

int query(int idx,int l,int r,int aiml,int aimr){
    if (aiml<=l and r<=aimr){
        return t[idx];
    }
    int mid = (l+r)>>1, ansl = 0, ansr = 0;
    if (aiml<=mid){
        ansl = query(idx<<1,l,mid,aiml,aimr);
    }
    if (mid<aimr){
        ansr = query(idx<<1|1,mid+1,r,aiml,aimr);
    }
    return max(ansl,ansr);
}

int main(){
    cin>>n>>k;
    for(int i=0;i<n;i++){
        scanf("%d",&a);
        result = query(1,1,3e5,max(0,a-k),min(3e5,a+k))+1;
        update(1,1,3e5,a,result);
    }
    cout<<result<<endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:41:46: error: no matching function for call to 'min(double, int)'
   41 |         result = query(1,1,3e5,max(0,a-k),min(3e5,a+k))+1;
      |                                           ~~~^~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:41:46: note:   deduced conflicting types for parameter 'const _Tp' ('double' and 'int')
   41 |         result = query(1,1,3e5,max(0,a-k),min(3e5,a+k))+1;
      |                                           ~~~^~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:41:46: note:   mismatched types 'std::initializer_list<_Tp>' and 'double'
   41 |         result = query(1,1,3e5,max(0,a-k),min(3e5,a+k))+1;
      |                                           ~~~^~~~~~~~~
Language: C++

#include<bits/stdc++.h>
#include<atcoder/segtree>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;
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 max_a = 300005;
int op(int a,int b){
	return max(a,b);
}
int e(){
	return 0;
}
int main(){
	int n,k;cin>>n>>k;
	vector<int> a(n);
	for(int i = 0; i < n; i++) {
		cin>>a[i];	
	}

	atcoder::segtree<int,op,e> dp(max_a);
	for(int i = 0; i < n; i++) {
		int x = a[i];
		int l = max(0,x - k),r = min(x + k + 1,max_a);
		int now = dp.prod(l,r) + 1;
		dp.set(x,now);
	}
	int ans = dp.prod(0,max_a);
	cout << ans << endl;
	return 0;
}

Compiler output:
a.cc:2:9: fatal error: atcoder/segtree: No such file or directory
    2 | #include<atcoder/segtree>
      |         ^~~~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;
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 max_a = 300005;
int op(int a,int b){
	return max(a,b);
}
int e(){
	return 0;
}
int main(){
	int n,k;cin>>n>>k;
	vector<int> a(n);
	for(int i = 0; i < n; i++) {
		cin>>a[i];	
	}

	atcoder::segtree<int,op,e> dp(max_a);
	for(int i = 0; i < n; i++) {
		int x = a[i];
		int l = max(0,x - k),r = min(x + k + 1,max_a);
		int now = dp.prod(l,r) + 1;
		dp.set(x,now);
	}
	int ans = dp.prod(0,max_a);
	cout << ans << endl;
	return 0;
}

Compiler output:
a.cc:2:9: fatal error: atcoder/all: No such file or directory
    2 | #include<atcoder/all>
      |         ^~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;

int n, m;

int main() {
	cin >> n >> m;
	dsu d(n);
	int ans = n - 1;
	for (int i = 0, a, b; i < m; ++i) {
		cin >> a >> b;
		--a;
		--b;
		if (!d.same(a, b)) {
			--ans;
			d.merge(a, b);
		}
	}
	cout<<ans<<endl;

}


Compiler output:
a.cc:2:10: fatal error: atcoder/all: No such file or directory
    2 | #include <atcoder/all>
      |          ^~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <atcoder/all>
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
using namespace atcoder;
const int INF = 1001001001;
const long long LINF = 1001002003004005006ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int,int> P;

int op(int a,int b) {return max(a,b);}

int e() {return -1;};

int main(){
  int n,k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i,n)cin >> a[i];

  vector<int> v(300100,0);
  segtree<int,op,e> seg(v);

  rep(i,n){
    int l = max(0,a[i]-k);
    int r = min(300000,a[i]+k);
    int mx = seg.prod(l,r);
    seg.set(a[i],mx+1);
  }
  cout << seg.all_prod()+1 << endl;
}

Compiler output:
a.cc:1:10: fatal error: atcoder/all: No such file or directory
    1 | #include <atcoder/all>
      |          ^~~~~~~~~~~~~
compilation terminated.
Language: C++

#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;

int mx(int a,int b){return max(a,b);}

int e(){return 0;}

int main(){
  int N,K;cin>>N>>K;
  segtree<int,mx,e> S(300001);
  for(int i=0;i<N;i++){
    int a;cin>>a;
    S.set(a,S.prod(max(a-K,0),min(a+K+1,300001))+1)//ふーん
  }
  
  cout<<S.prod(0,300001)<<endl;
}
  

Compiler output:
a.cc:2:9: fatal error: atcoder/all: No such file or directory
    2 | #include<atcoder/all>
      |         ^~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <bits/stdc++.h>
#include <atcoder/segtree>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using namespace atcoder;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

ll op(ll a, ll b){
  return max(a,b);
}

ll e(){
  return (ll)(0);
}

int main() {
  ll n,k;
  cin >> n >> k;
  segtree<ll,op,e> t(603030);
  vl a(n);
  rep(i,n)cin >> a[i];
  ll ans = 0;
  rep(i,n){
    ll l = max(0LL,a[i]-k), r = min(n,a[i]+k);
    ll x = t.prod(l,r+1);
    t.set(a[i],x+1);
    maxs(ans,x+1);
  }
  print(ans);
  return 0;
}

Compiler output:
a.cc:2:10: fatal error: atcoder/segtree: No such file or directory
    2 | #include <atcoder/segtree>
      |          ^~~~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ll mod2 = 998244353;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int op(int a, int b) {
  return max(a, b);
}
int e() {
  return 0;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, k; cin >> n >> k;
  vector<int> A(n); rep(i, n) cin >> A[i];
  segtree<int, op, e> seg(300005);
  rep(i, n) {
    seg.set(A[i], seg.prod(max(0, A[i]-k), min(300005, A[i]+k+1))+1);
  }
  cout << seg.prod(0, 300005) << endk;
  return 0;
}


Compiler output:
a.cc:3:10: fatal error: atcoder/all: No such file or directory
    3 | #include <atcoder/all>
      |          ^~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <bits/stdc++.h>
#include <atcoder/all>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using namespace atcoder;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

ll op(ll a, ll b){
  return max(a,b);
}

ll e(){
  return (ll)(0);
}

int main() {
  ll n,k;
  cin >> n >> k;
  segtree<ll,op,e> t(303030);
  vl a(n);
  rep(i,n)cin >> a[i];
  //rep(i,n)t.set(i,0);
  ll ans = 0;
  rep(i,n){
    ll l = max(0LL,a[i]-k), r = min(n,a[i]+k);
    ll x = t.prod(l,r+1);
    //show(x);
    t.set(a[i],x+1);
    // t.set(l,x+1);
    // t.set(r,x+1);
    maxs(ans,x+1);
  }
  print(ans);
  return 0;
}

Compiler output:
a.cc:2:10: fatal error: atcoder/all: No such file or directory
    2 | #include <atcoder/all>
      |          ^~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <bits/stdc++.h>
#include <atcoder/all>

using namespace std;
using namespace atcoder;
 
#ifdef DEBUG
    #include "debug.h"
    #define dump(...)                                                              \
        DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
                << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
                << endl                                                            \
                << "    ",                                                         \
            dump_func(__VA_ARGS__)
#else
    #define dump(...)
#endif

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

#define int long long
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
#define ALL(v) (v).begin(), (v).end()
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

/*
#define mod 1000000007 /*/
#define mod 998244353 //*/

typedef pair<int, int> P;
//#define INF (1LL<<60)

using S = long long;
using F = long long;

const S INF = 8e18;
const F ID = 8e18;

S op(S a, S b){ return std::max(a, b); }
S e(){ return -INF; }
S mapping(F f, S x){ return (f == ID ? x : f); }
F composition(F f, F g){ return (f == ID ? g : f); }
F id(){ return ID; }

void solve(){
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    rep(i,N) cin >> A[i];
    
    std::vector<S> v(300001);
    atcoder::lazy_segtree<S, op, e, F, mapping, composition, id> seg(v);
    
    rep(i,N){
        int m = seg.prod(max(0LL,A[i]-K), min(300001,A[i]+K+1));
        seg.apply(A[i],A[i]+1, m+1);
    }
    cout << seg.all_prod() << endl;
}


signed main(){
    cout << fixed << setprecision(18);
    cerr << fixed;
    solve();
}


Compiler output:
a.cc:2:10: fatal error: atcoder/all: No such file or directory
    2 | #include <atcoder/all>
      |          ^~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <bits/stdc++.h>
#include <atcoder/segtree>
using namespace std;
using namespace atcoder;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
constexpr ll mod = 1000000007;

#define NMAX 300010
ll op(ll a, ll b) { return max(a, b); }
ll e() { return 0; }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i, 0, n) cin >> a[i];

    segtree<ll, op, e> t(NMAX);
    ll ans = 0;
    rep(i, 0, n) {
        ll l = max(a[i] - k, 0LL);
        ll r = min(a[i] + k, (ll)NMAX);
        ll tmp = t.prod(l, r+1) + 1;
        ans = max(ans, tmp);
        t.set(a[i], tmp);
    }
    
    cout << ans << endl;
    return 0;
}

Compiler output:
a.cc:2:10: fatal error: atcoder/segtree: No such file or directory
    2 | #include <atcoder/segtree>
      |          ^~~~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <bits/stdc++.h>
#include <atcoder/all>

using namespace std;
using namespace atcoder;

int op(int a, int b)
{
    return max(a, b);
}
int e()
{
    return 0;
}
int main()
{
    int N, K;

    cin >> N >> K;

    segtree<int, op, e> seg(N + 1);

    for (int i = 0; i < N; i++)
    {
        int A;

        cin >> A;

        int l = A - K;
        int r = A + K + 1;

        if (l < 1)
        {
            l = 1;
        }
        if (r > N + 1)
        {
            r = N + 1;
        }
        int v = seg.prod(l, r);

        seg.set(A, v + 1);
    }
    cout << seg.prod(1, N + 1) << endl;
}

Compiler output:
a.cc:2:10: fatal error: atcoder/all: No such file or directory
    2 | #include <atcoder/all>
      |          ^~~~~~~~~~~~~
compilation terminated.
Language: C++

//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <bitset>
#include <assert.h>
using namespace std;

typedef long long ll;
#define free  freopen ("input.txt", "r", stdin);freopen ("output.txt", "w", stdout);
#define Fast  ios::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define F first
#define S second
const int mod = 998244353;
const int N = 3e5+ 5;
ll mx = 0;

pair <ll, ll> p;
//stack <int> st1;
string s, s1;
char o;
bool mark, h;
//vector <ll> vt[N], vm, vs;
ll a[N], b, c, d, dp, dis, tree[6*N];
bool vowel(char che){if (che == 'A' || che == 'E' || che == 'I' || che == 'O' || che == 'U' || che == 'Y'){return true;} else{return false;}}
ll pw(ll a, ll b){ll ans = 1;while (b){if (b%2 == 1){ans *= a;ans %= mod;}b /= 2;a*= a;}return ans;}

void build(ll node, ll st, ll ed)
{
    if (st == ed){
        if (mark[st])
            tree[node] = 1;
    }
    else {
        ll mid = (st+ed) / 2;
        build (2*node, st, mid);
        build (2*node+1, mid+1, ed);
        tree[node] = max(tree[2*node], tree[(2*node)+1]);
    }
}

void update (ll node, ll st, ll ed, ll id, ll val)
{
    if (st == ed)
        tree[node] = val;
    else {
        ll mid = (st+ed)/2;
        if (id <= mid)
            update (2*node, st, mid, id, val);
        else
            update ((2*node)+1, mid+1, ed, id, val);

        tree[node] = max(tree[2*node], tree[(2*node)+1]);
    }
}

ll query (ll node, ll st, ll ed, ll l, ll r)
{
    if (r < st || l > ed)
        return 0;
    if (l <= st && ed <= r)
        return tree[node];
    ll mid = (st+ed)/2;
    ll q1 = query(2*node, st, mid, l, r);
    ll q2 = query((2*node)+1,mid+1, ed, l, r);
    return max(q1, q2);
}
int main()
{
    Fast
    ll t = 0, n, m = 0, k = 0, f = 0, sum = 0, ans = 0;
    cin >> n >> k;
    for (int i = 0; i < n; i++){
        cin >> a[i];
    }
    build(1, 0, N)
    for (int i = 0; i < n; i++){
        ll l = max(ll(0), a[i]-k);
        ll r = min(ll(N), a[i]+k);
        ans = query(1, 0, N, l, r)+1;
        update (1, 0, N-1, a[i], ans);
    }
    cout << tree[1] << endl;
}


Compiler output:
a.cc: In function 'void build(ll, ll, ll)':
a.cc:38:17: error: invalid types 'bool[ll {aka long long int}]' for array subscript
   38 |         if (mark[st])
      |                 ^
a.cc: In function 'int main()':
a.cc:83:19: error: expected ';' before 'for'
   83 |     build(1, 0, N)
      |                   ^
      |                   ;
   84 |     for (int i = 0; i < n; i++){
      |     ~~~            
a.cc:84:21: error: 'i' was not declared in this scope
   84 |     for (int i = 0; i < n; i++){
      |                     ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a); i<(int)(b); i++)

using ll = long long;

int op(int a, int b){return max(a,b);}
int e(){return 0;}
const int MAX_A = 300005;
#include <atcoder/all>
using namespace atcoder;

int main(){
  int N,K;
  cin >> N >> K;
  vector<int> A(N);
  rep(i,N){cin >> A[i];}

  // Aをi番目まで見た時の最後の数字がjである時のBの長さをdp[i][j]に格納(解説放送より)
    /* dp遷移は
      dp[i][j] = dp[i-1][j] <選ばない場合>
      dp[i][Ai] = max(dp[i-1][Ai-K~Ai+K]) + 1 <選ぶ>

      ただこのままだとdp配列が確保できないのでiを消去
      <選ばない場合>はdp[j]の基本変化なし
      dp[Ai] = max(dp[Ai], max(dp[Ai-K ~ Ai+K]) <選ぶ>

      maxdpの部分では区間の最大値を取るのでO(NK)になり間に合わない
       → segtreeを使用(解説略された…)(蟻本)
    */
  
  // 以下、解説放送の写経 // 上記のop,e,MAX_A及びatcoderライブラリも含む

  segtree<int, op, e> dp(MAX_A);
  // op … 加算などの演算を表す　
  // e … 上記演算における単位元
  rep(i,N){
    int x = a[i];
    int l = x-K, r = x+K+1;// prodの範囲は半開区間なのでrには+1が必要
    l = max(l,0); r = min(r,MAX_A);
    int now = dp.prod(l,r) + 1;
    dp.set(x, now);
  }
  int ans = dp.prod(0,MAX_A);
  cout << ans << endl;
}


/*
サンプルでは貪欲でイケるけど貪欲で取るとだめな例がある
(ex)K=3のとき(1,4,0,0,0,0,0,0)など

取る場合と取らない場合を両方考慮する必要があるのでdpっぽい
ぽいけど…最長共通部分列問題と違って保持する最後の数字が変化する・複数の可能性があるから実装がわからん…

ので解説放送をみた！dpは合ってたけど二次元dpっぽい

ACLという競プロライブラリ実装記念のコンテストなので
想定解はライブラリ使って殴ることらしい。(が、わからん)
*/

Compiler output:
a.cc:11:10: fatal error: atcoder/all: No such file or directory
   11 | #include <atcoder/all>
      |          ^~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a); i<(int)(b); i++)

using ll = long long;

int op(int a, int b){return max(a,b);}
int e(){return 0;}
const int MAX_A = 300005;
#include <atcoder/all>
using namespace atcoder;

int main(){
  int N,K;
  cin >> N >> K;
  vector<int> A(N);
  rep(i,N){cin >> A[i];}

  // Aをi番目まで見た時の最後の数字がjである時のBの長さをdp[i][j]に格納(解説放送より)
    /* dp遷移は
      dp[i][j] = dp[i-1][j] <選ばない場合>
      dp[i][Ai] = max(dp[i-1][Ai-K~Ai+K]) + 1 <選ぶ>

      ただこのままだとdp配列が確保できないのでiを消去
      <選ばない場合>はdp[j]の基本変化なし
      dp[Ai] = max(dp[Ai], max(dp[Ai-K ~ Ai+K]) <選ぶ>

      maxdpの部分では区間の最大値を取るのでO(NK)になり間に合わない
       → segtreeを使用(解説略された…)(蟻本)
    */
  
  // 以下、解説放送の写経 // 上記のop,e,MAX_Aも含む

  segtree<int, op, e> dp(MAX_A);
  // op … 加算などの演算を表す　
  // e … 上記演算における単位元
  rep(i,n){
    int x = a[i];
    int l = x-K, r = x+K+1;// prodの範囲は半開区間なのでrには+1が必要
    l = max(l,0); r = min(r,MAX_A);
    int now = dp.prod(l,r) + 1;
    dp.set(x, now);
  }
  int ans = dp.prod(0,MAX_A);
  cout << ans << endl;
}


/*
サンプルでは貪欲でイケるけど貪欲で取るとだめな例がある
(ex)K=3のとき(1,4,0,0,0,0,0,0)など

取る場合と取らない場合を両方考慮する必要があるのでdpっぽい
ぽいけど…最長共通部分列問題と違って保持する最後の数字が変化する・複数の可能性があるから実装がわからん…

ので解説放送をみた！dpは合ってたけど二次元dpっぽい

ACLという競プロライブラリ実装記念のコンテストなので
想定解はライブラリ使って殴ることらしい。(が、わからん)
*/

Compiler output:
a.cc:11:10: fatal error: atcoder/all: No such file or directory
   11 | #include <atcoder/all>
      |          ^~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a); i<(int)(b); i++)

using ll = long long;

int op(int a, int b){return max(a,b);}
int e(){return 0;}
const int MAX_A = 300005;

int main(){
  int N,K;
  cin >> N >> K;
  vector<int> A(N);
  rep(i,N){cin >> A[i];}

  // Aをi番目まで見た時の最後の数字がjである時のBの長さをdp[i][j]に格納(解説放送より)
    /* dp遷移は
      dp[i][j] = dp[i-1][j] <選ばない場合>
      dp[i][Ai] = max(dp[i-1][Ai-K~Ai+K]) + 1 <選ぶ>

      ただこのままだとdp配列が確保できないのでiを消去
      <選ばない場合>はdp[j]の基本変化なし
      dp[Ai] = max(dp[Ai], max(dp[Ai-K ~ Ai+K]) <選ぶ>

      maxdpの部分では区間の最大値を取るのでO(NK)になり間に合わない
       → segtreeを使用(解説略された…)(蟻本)
    */
  
  // 以下、解説放送の写経 // 上記のop,e,MAX_Aも含む

  #include <atcoder/all>
  using namespace atcoder;
  segtree<int, op, e> dp(MAX_A);
  // op … 加算などの演算を表す　
  // e … 上記演算における単位元
  rep(i,n){
    int x = a[i];
    int l = x-K, r = x+K+1;// prodの範囲は半開区間なのでrには+1が必要
    l = max(l,0); r = min(r,MAX_A);
    int now = dp.prod(l,r) + 1;
    dp.set(x, now);
  }
  int ans = dp.prod(0,MAX_A);
  cout << ans << endl;
}


/*
サンプルでは貪欲でイケるけど貪欲で取るとだめな例がある
(ex)K=3のとき(1,4,0,0,0,0,0,0)など

取る場合と取らない場合を両方考慮する必要があるのでdpっぽい
ぽいけど…最長共通部分列問題と違って保持する最後の数字が変化する・複数の可能性があるから実装がわからん…

ので解説放送をみた！dpは合ってたけど二次元dpっぽい

ACLという競プロライブラリ実装記念のコンテストなので
想定解はライブラリ使って殴ることらしい。(が、わからん)
*/

Compiler output:
a.cc:33:12: fatal error: atcoder/all: No such file or directory
   33 |   #include <atcoder/all>
      |            ^~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a); i<(int)(b); i++)

using ll = long long;

int op(int a, int b){return max(a,b);}
int e(){return 0;}
const int MAX_A = 300005;

int main(){
  int N,K;
  cin >> N >> K;
  vector<int> A(N);
  rep(i,N){cin >> A[i];}

  // Aをi番目まで見た時の最後の数字がjである時のBの長さをdp[i][j]に格納(解説放送より)
    /* dp遷移は
      dp[i][j] = dp[i-1][j] <選ばない場合>
      dp[i][Ai] = max(dp[i-1][Ai-K~Ai+K]) + 1 <選ぶ>

      ただこのままだとdp配列が確保できないのでiを消去
      <選ばない場合>はdp[j]の基本変化なし
      dp[Ai] = max(dp[Ai], max(dp[Ai-K ~ Ai+K]) <選ぶ>

      maxdpの部分では区間の最大値を取るのでO(NK)になり間に合わない
       → segtreeを使用(解説略された…)(蟻本)
    */
  
  // 以下、解説放送の写経 // 上記のop,e,MAX_Aも含む

  #include <atcoder/all>
  using namespace atcoder;
  
  segtree<int, op, e> dp(MAX_A);
  // op … 加算などの演算を表す　
  // e … 上記演算における単位元
  rep(i,n){
    int x = a[i];
    int l = x-K, r = x+K+1;// prodの範囲は半開区間なのでrには+1が必要
    l = max(l,0); r = min(r,MAX_A);
    int now = dp.prod(l,r) + 1;
    dp.set(x, now);
  }
  int ans = dp.prod(0,MAX_A);
  cout << ans << endl;
}


/*
サンプルでは貪欲でイケるけど貪欲で取るとだめな例がある
(ex)K=3のとき(1,4,0,0,0,0,0,0)など

取る場合と取らない場合を両方考慮する必要があるのでdpっぽい
ぽいけど…最長共通部分列問題と違って保持する最後の数字が変化する・複数の可能性があるから実装がわからん…

ので解説放送をみた！dpは合ってたけど二次元dpっぽい

ACLという競プロライブラリ実装記念のコンテストなので
想定解はライブラリ使って殴ることらしい。(が、わからん)
*/

Compiler output:
a.cc:33:12: fatal error: atcoder/all: No such file or directory
   33 |   #include <atcoder/all>
      |            ^~~~~~~~~~~~~
compilation terminated.
Language: C++

#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include "bits/stdc++.h"
using namespace std;
#define ll long long
#define pb push_back
#define all(_obj) _obj.begin(),_obj.end()
#define F first
#define S second
#define INF 1e18
#define pll pair<ll, ll> 
#define vll vector<ll>
ll n,m,a,b,c,k,temp,x,y;
const int MAXN=1e5+11,mod=1e9+7;
ll max(ll a,ll b) {return ((a>b)?a:b);}
ll min(ll a,ll b) {return ((a>b)?b:a);}
vll read(int n) {vll v(n);for (int i = 0; i < v.size(); i++)cin>>v[i];return v;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int tree[6*MAXN];
int qfst(int l,int r)
{
    int res=0;
    for(l+=300001,r+=300001;l<r;l>>=1,r>>=1)
    {
        if(l&1) res=max(tree[l++],res);
        if(r&1) res=max(tree[--r],res);
    }
    return res;
}
void modify(int p, int value) 
{ 
for (tree[p += 300001] = value; p > 1; p >>= 1)
tree[p >> 1] = max(tree[p], tree[p ^ 1]);
}
void sol(void)
{
cin>>n>>k;
vll v=read(n);
for(int i=0;i<n;i++)
{
    int mx=qfst(v[i],v[i]+1);
    int ending=qfst(max(0,v[i]-k),min(v[i]+k+1,300001))+1;
    modify(v[i],max(mx,ending));
}
cout<<qfst(0,300001);
return ;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int test=1;
    //cin>>test;
    for(int i=1;i<=test;i++)
    sol();
}


Compiler output:
In file included from /usr/include/c++/14/string:43,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:3:
/usr/include/c++/14/bits/allocator.h: In destructor 'std::_Vector_base<long long int, std::allocator<long long int> >::_Vector_impl::~_Vector_impl()':
/usr/include/c++/14/bits/allocator.h:182:7: error: inlining failed in call to 'always_inline' 'std::allocator< <template-parameter-1-1> >::~allocator() noexcept [with _Tp = long long int]': target specific option mismatch
  182 |       ~allocator() _GLIBCXX_NOTHROW { }
      |       ^
In file included from /usr/include/c++/14/vector:66,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53:
/usr/include/c++/14/bits/stl_vector.h:132:14: note: called from here
  132 |       struct _Vector_impl
      |              ^~~~~~~~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
#define rep(i, n) for (int i = 0; i < (n); ++i)
using ll = long long;
using P = pair<int, int>;

const int MAX_A = 300005;

int cp(int a, int b) { return max(a, b); }
int e() { return 0; }

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	
	segtree<int, op, e> dp(MAX_A);
	
	rep(i, n) {
		int x = a[i];
		int l = x - k, r = x + k + 1;
		l = max(l, 0);
		r = min(r, MAX_A);
		int now = dp.prod(l, r) + 1;
		dp.set(x, now);
	}
	
	int ans = dp.prod(0, MAX_A);
	cout << ans << '\n';
	
	return 0;
}

Compiler output:
a.cc:3:10: fatal error: atcoder/all: No such file or directory
    3 | #include <atcoder/all>
      |          ^~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <bits/stdc++.h>
#include <atcoder/all> 
using namespace std;
using namespace atcoder;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i--)
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 25;
const int MAX_A = 300010;

int a;

int op(int x, int y) {return max(x,y);}
int e() {return 0;}

int main() {
	int n, k;
	cin >> n >> k;

	segtree<int, op, e> dp(MAX_A);
	int ans = 0;
	rep(i,n) {
		cin >> a;
		int l = max(0, a-k);
		int r = min(a+k+1, MAX_A);
		int now = dp.prod(l,r) + 1;
		ans = max(ans, now);
		dp.set(a,now);
	}
	cout << dp.prod(0,MAX_A) << endl;
	//cout << n+k << endl;
	return 0;
}

Compiler output:
a.cc:2:10: fatal error: atcoder/all: No such file or directory
    2 | #include <atcoder/all>
      |          ^~~~~~~~~~~~~
compilation terminated.
Language: C++

// #include <bits/stdc++.h>
// using namespace std;

#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
 
#define rp(i, k, n) for (int i = k; i < n; i++)
using ll = long long;
using ld = double;

template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7ll;
// const ll MOD = 998244353;
const double PI=3.14159265358979323846;

int n, k;

int op(int a, int b) {
    return max(a, b);
}
int e() {
    return 0;
}
segtree<int, op, e> seg(300010);

int main() {
    cin >> n >> k;
    vector<int> A(n);
    rp(i, 0, n) {
        cin >> A[i];
    }
    int res = 0;
    for(int i = n-1; i >= 0; i--) {
        seg.set(A[i], seg.prod( max(0, A[i] - k), min(A[i] + k, 300000) + 1 ) + 1 );
    }
    cout << seg.all_prod() << endl;
    return 0;

    return 0;
}


Compiler output:
a.cc:22:10: fatal error: atcoder/all: No such file or directory
   22 | #include <atcoder/all>
      |          ^~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
 
#define rp(i, k, n) for (int i = k; i < n; i++)
using ll = long long;
using ld = double;

template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7ll;
// const ll MOD = 998244353;
const double PI=3.14159265358979323846;

int n, k;

int op(int a, int b) {
    return max(a, b);
}
int e() {
    return 0;
}
segtree<int, op, e> seg(300010);

int main() {
    cin >> n >> k;
    vector<int> A(n);
    rp(i, 0, n) {
        cin >> A[i];
    }
    int res = 0;
    for(int i = n-1; i >= 0; i--) {
        seg.set(A[i], seg.prod( max(0, A[i] - k), min(A[i] + k, 300000) + 1 ) + 1 );
    }
    cout << seg.all_prod() << endl;
    return 0;

    return 0;
}


Compiler output:
a.cc:2:10: fatal error: atcoder/all: No such file or directory
    2 | #include <atcoder/all>
      |          ^~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define All(a) (a).begin(),(a).end()
int *A,*S,m=0;

void search(int i,int cnt,int n){
  int p=A[i];
  cnt++;
  S[i]=cnt;
  m=max(m,cnt);
  for (int k = i+1; k < n; k++)
  {
    if(abs(p-A[k])<=3){
      if(S[k]>cnt)continue;
      search(k,cnt,n);
    }
  }
}


int main(){ 
  ll n,k;
  cin >> n >>k;
  A=new int[n];
  S=new int[n];
  for (int i = 0; i < n; i++) {
    cin>>A[i];
    S[i]=0;
  }

  for(int i=0; i < n; i++){
    if(S[i]==0)search(i,0,n);
  }

  // for (int i = 0; i < n; i++)
  // {
  //   cout<<A[i]<<" ";
  // }
  // cout<<endl;
  // for (int i = 0; i <n; i++)
  // {
  //     cout<<S[i]<<" ";
  // }
  cout<<m<<endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:33:22: warning: ignoring return value of '_ForwardIterator std::search(_ForwardIterator, _ForwardIterator, const _Searcher&) [with _ForwardIterator = int; _Searcher = long long int]', declared with attribute 'nodiscard' [-Wunused-result]
   33 |     if(S[i]==0)search(i,0,n);
      |                ~~~~~~^~~~~~~
In file included from /usr/include/c++/14/algorithm:61,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algo.h:4184:5: note: declared here
 4184 |     search(_ForwardIterator __first, _ForwardIterator __last,
      |     ^~~~~~
/usr/include/c++/14/bits/stl_algo.h: In instantiation of '_ForwardIterator std::search(_ForwardIterator, _ForwardIterator, const _Searcher&) [with _ForwardIterator = int; _Searcher = long long int]':
a.cc:33:22:   required from here
   33 |     if(S[i]==0)search(i,0,n);
      |                ~~~~~~^~~~~~~
/usr/include/c++/14/bits/stl_algo.h:4186:24: error: expression cannot be used as a function
 4186 |     { return __searcher(__first, __last).first; }
      |              ~~~~~~~~~~^~~~~~~~~~~~~~~~~
Language: C++

#include <atcoder/segtree>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
#define rep(i,n) for (int i = 0; i < (n); ++i)
int nmax = 300005;

int op(int a, int b) {
    return max(a, b);
}

int e() {
    return 0;
}

int main() {
  int n,k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  
  segtree<int,op,e> dp(nmax);
  
  for(int i=0;i<n;i++){
    int x = a[i];
    int l = max(x-k,0);
    int r = min(x+k+1,nmax);
    int now = dp.prod(l,r)+1;
    dp.set(x,now);
  }

  int ans = dp.prod(0,nmax);
  cout << ans << endl;
  
  return(0);
}

Compiler output:
a.cc:1:10: fatal error: atcoder/segtree: No such file or directory
    1 | #include <atcoder/segtree>
      |          ^~~~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;

using S = int64_t;
using F = int64_t;

const S INF = 8e18;
const F ID = 8e18;

S op(S a, S b) { return std::max(a, b); }
S e() { return -INF; }
S mapping(F f, S x) { return (f == ID ? x : f); }
F composition(F f, F g) { return (f == ID ? g : f); }
F id() { return ID; }

const int64_t SZ = 300000 + 2;
int main() {
    int n, k;
    cin >> n >> k;
    std::vector<S> v(SZ);
    // 1点更新、区間最大値なので遅延ではないセグ木で十分だが、
    // 勉強のため遅延セグ木を用いる。
    atcoder::lazy_segtree<S, op, e, F, mapping, composition, id> seg(v);

    while (n--) {
        int64_t x;
        cin >> x;
        // 過去に存在した x±k の座標に対する点の数の最大値を求める
        int64_t me = seg.prod(max(0LL, x - k), min(SZ, x + k + 1));
        // 現在のx座標に対して上記+1をセット（区間更新）
        seg.apply(x, x + 1, me + 1);
    }
    cout << seg.all_prod() << endl;
}


Compiler output:
a.cc:1:10: fatal error: atcoder/all: No such file or directory
    1 | #include <atcoder/all>
      |          ^~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
#include <deque>
#include <atcoder/all>

using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;
typedef pair<ll, ll> PLL;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int op(int a, int b) {
  return max(a, b);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  int n, k, ans = 0;
  cin >> n >> k;

  segtree<int, op, e> seg(300010);

  REP(i, n) {
    int x;
    cin >> x;
    int l = max(x - k, 0);
    int r = min(x + k, 0);
    int t = seg.prod(l, r + 1) + 1
    ans = max(ans, t);

    seg.set(x, t);
  }

  cout << ans << endl;
}


Compiler output:
a.cc:14:10: fatal error: atcoder/all: No such file or directory
   14 | #include <atcoder/all>
      |          ^~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;

using ll = long long;
const ll INF = 1LL << 60;
const ll MAX_A = 300005;

ll op(ll a, ll b) { return max(a, b); }
ll e() { return 0; }

int main() {
    int N, K;  cin >> N >> K;
    vector<ll> A(N);
    for (int i = 0; i < N; ++i) cin >> A[i];
    segtree<ll, op, e> dp(MAX_A);
    for (int i = 0; i < N; ++i) {
        DUMPS(max(A[i] - K, 0LL), min(A[i] + K + 1, MAX_A));
        ll mx = dp.prod(max(A[i] - K, 0LL), min(A[i] + K + 1, MAX_A));
        dp.set(A[i], mx + 1);
    }
    ll ans = dp.all_prod();
    cout << ans << endl;
}


Compiler output:
a.cc:2:10: fatal error: atcoder/all: No such file or directory
    2 | #include <atcoder/all>
      |          ^~~~~~~~~~~~~
compilation terminated.
Language: C++

#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
typedef long long ll;
int op(int a, int b) {
    return max(a, b);
}
 
int e() {
    return (int)(0);
}
int main(){
  int n,k;
  cin>>n>>k;
  atcoder::segtree<int,op,e>seg(n+1);
  int ans=0;
  for(int i=0;i<n;i++){
    int a; cin >> a;
        int p = seg.prod(max(0,a-k),min(N+1,a+k+1))+1;
        seg.set(a,p);
        ans = max(ans,p);
  }
  cout<<ans<<"\n";
}


Compiler output:
a.cc:2:9: fatal error: atcoder/all: No such file or directory
    2 | #include<atcoder/all>
      |         ^~~~~~~~~~~~~
compilation terminated.
Language: C++

#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
typedef long long ll;
int op(int a, int b) {
    return max(a, b);
}
 
int e() {
    return (int)(0);
}
int main(){
  ll n,k;
  cin>>n>>k;
  atcoder::segtree<int,op,e>seg(n+1);
  ll ans=0;
  for(int i=0;i<n;i++){
    ll a; cin >> a;
        ll p = seg.prod(max(0,a-k),min(N+1,a+k+1))+1;
        seg.set(a,p);
        ans = max(ans,p);
  }
  cout<<ans<<"\n";
}


Compiler output:
a.cc:2:9: fatal error: atcoder/all: No such file or directory
    2 | #include<atcoder/all>
      |         ^~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;

using ll = long long;
//print(fixed << setprecision(10));
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define repk(i,n,k) for(ll i = k; i < (n); i++)
#define all(n) n.begin(), n.end()
#define print(n) cout << n << endl
double PI = acos(-1.0);
int INF = 1e9;
ll LINF = 1e18;
ll MOD = 1e9+7;

ll op(ll a, ll b) {
    return max(a, b);
}

ll e() {
    return (ll)(0);
}

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    ll n,k;
    cin >> n >> k;
    segtree<ll,op,e> seg(n+1);
    rep(i,n){
        ll a;
        cin >> a;
        ll p = seg.prod(max(a-k,(ll)1),min(a+k+1,n+1));
        seg.set(a,p+1);
    }
    print(seg.all_prod());
    return 0;
}

Compiler output:
a.cc:2:10: fatal error: atcoder/all: No such file or directory
    2 | #include <atcoder/all>
      |          ^~~~~~~~~~~~~
compilation terminated.
Language: C++

#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
typedef long long ll;
int op(int a, int b) {
    return max(a, b);
}
 
int e() {
    return (int)(0);
}
int main(){
  ll n,k;
  cin>>n>>k;
  segtree<int,op,e>seg(n+1);
  ll ans=0;
  for(int i=0;i<n;i++){
    ll a; cin >> a;
        ll p = seg.prod(max(0,a-k),min(N+1,a+k+1))+1;
        seg.set(a,p);
        ans = max(ans,p);
  }
  cout<<ans<<"\n";
}


Compiler output:
a.cc:2:9: fatal error: atcoder/all: No such file or directory
    2 | #include<atcoder/all>
      |         ^~~~~~~~~~~~~
compilation terminated.
Language: C++

#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
typedef long long ll;
int op(int a, int b) {
    return max(a, b);
}
 
int e() {
    return (int)(0);
}
int main(){
  ll n,k;
  cin>>n>>k;
  segtree<int,op,e>seg(n+1);
  ll ans=0;
  for(int i=0;i<n;i++){
    ll a; cin >> a;
        ll p = seg.prod(max(0,a-k),min(N+1,a+k+1))+1;
        seg.set(a,p);
        ans = max(ans,p);
  }
  cout<<ans<<"\n";
}

Compiler output:
a.cc:2:9: fatal error: atcoder/all: No such file or directory
    2 | #include<atcoder/all>
      |         ^~~~~~~~~~~~~
compilation terminated.
Language: C

#include <iostream>
#include <vector>
using namespace std;
struct segK{
    int n;
    vector<long long> dat;
    long long MAX;
    segK(int n_){
        n = 1;
        MAX = 0;
        while(n < n_) n *= 2;
        dat.resize(2 * n - 1);
        for(int i = 0; i < 2 * n - 1; i++) dat[i] = MAX;
    }
    void update(int k, int a){
        k += n - 1;
        dat[k] = a;
        while(k > 0){
            k = (k - 1) / 2;
            dat[k] = max(dat[k * 2 + 1], dat[k * 2 + 2]);
        }
    }
    long long query(int a, int b, int k = 0, int l = 0, int r = -1){
        if(r < 0) r = n;
        if(r <= a || b <= l) return MAX;
        if(a <= l && r <= b) return dat[k];
        else{
            long long vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
            long long vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
            return max(vl, vr);
        }
    }
};
int main(){
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    for(int i = 0; i < N; i++) cin >> A[i];
    segK seg(300100);
    for(int i = 0; i < N; i++){
        if(i == 0) seg.update(A[i], 1);
        else{
            int l = max(0, A[i] - K);
            int r = min(300050, A[i] + K);
            int res = seg.query(l, r + 1);
            seg.update(A[i], res + 1);
        }
    }
    cout << seg.query(0, 300100) << endl;
}

Compiler output:
main.c:1:10: fatal error: iostream: No such file or directory
    1 | #include <iostream>
      |          ^~~~~~~~~~
compilation terminated.
Language: C

#include <iostream>
using namespace std;
#include<bits/stdc++.h>
const int N=int(1e5);
#define ll long long
#define F first
#define S second
priority_queue<pair<ll,pair<ll,ll>>>pq;
int st[2*N+1]={0};
int n;
void build()
{
    for(int i=n-1;i>0;i--)
    st[i]=max(st[i<<1],st[i<<1|1]);
}
void update(int pos,int val)
{
    st[pos+n]=val;   
    for(int i=pos+n;i>1;i>>=1)
    {
        st[i>>1]=max(st[i],st[i^1]);
    }
}
void modify(int pos,int val)
{
    st[pos+n]=val;   
    for(int i=pos+n;i>1;i>>=1)
    {
        st[i>>1]=st[i]+st[i^1];
    }
    
    
}
int maxquery(int l,int r)
{
    int res=0;
    l+=n;
    r+=n;
    while (l<r)
    {
        if(l&1)
        {
            res=max(st[l],res);
            l++;
	}
        if(r&1)
        {
            r--;
            res=max(st[r],res);
        }
        
        l>>=1;
        r>>=1;
        //cout<<l<<" "<<r<<endl;
    }
    return res;
}
int  queury(int l,int r)
{
    int res=0;
    l+=n;
    r+=n;
    while (l<r)
    {
        if(l&1)
        {
            res+=st[l];
            l++;
	}
        if(r&1)
        {
            r--;
            res+=st[r];
        }
        
        l>>=1;
        r>>=1;
        //cout<<l<<" "<<r<<endl;
    }
    return res;
}

int main() {
    int k;
    cin>>n>>k;
    vector<int>v(n);
    for(int i=0;i<n;i++)
    cin>>v[i];
    build();
    int maxm,l,r;
    vector<int>dp(n,1);
    for(int i=0;i<n;i++)
    {
        l=max(0,v[i]-k);
        r=min(n,v[i]+k);
        maxm=maxquery(l,r+1);
        dp[i]+=maxm;
        if (st[v[i]+n]<dp[i])
        update(v[i],dp[i]);
    }
    cout<<dp[n-1]<<endl;

    return 0;
}

Compiler output:
main.c:1:10: fatal error: iostream: No such file or directory
    1 | #include <iostream>
      |          ^~~~~~~~~~
compilation terminated.
Language: C++

#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;

#define INF 1000000010
#define EPS 1e-9

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

int op(int a, int b) { return max(a, b); }
int e() { return -1; }

typedef pair<int,int> PII;
typedef pair<int,string> PIS;
typedef pair<string,int> PSI;


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n,k;
  cin>>n>>k;
  
  segtree<int, op, e> seg(300010);

  int ans=0;
  
  rep(i,n){
    int x;
    cin>>x;
    int l=max(0,x-k);
    int r=min(300010,x+k+1);
    int g=seg.prod(l,r);
    int d=g+1;
    seg.set(x,d);
    if(ans>d) ans=d;
  }
  cout<<ans<<endl;


  return 0;
}


Compiler output:
a.cc:2:9: fatal error: atcoder/all: No such file or directory
    2 | #include<atcoder/all>
      |         ^~~~~~~~~~~~~
compilation terminated.