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

#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
#include <atcoder/all>
using namespace std;
using namespace atcoder;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> LP;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

class rmq_seg{
    const int MAX_SEG;
    int seg_len;
    vector<int> segtree;
    public:
        rmq_seg(int N, int def) : MAX_SEG(10000000), segtree(MAX_SEG), seg_len(1){
            while(seg_len < N)seg_len *= 2;
            rep(i,MAX_SEG)segtree[i] = def;
        }

        void update(int l, int r, int k){
        	l += seg_len-1;
        	r += seg_len-1;
        	while(l<r){
        		if(l % 2 == 1){segtree[l] = max(segtree[l], k); ++l;}
        		l /= 2;
        		if(r % 2 == 1){segtree[r-1] = max(segtree[r-1], k); --r;}
        		r /= 2;
        	}
        }

        int get(int k){
            k += seg_len-1;
            int res = -1;
            while(k > 0){
                res = max(res, segtree[k]);
                k /= 2;
            }
            return res;
        }
};

int main(){
    int N, K;
    cin >> N >> K;
    vector<int> a(N);
    rep(i,N)cin >> a[i];
    rmq_seg seg(8000000, 0);
    vector<int> ans(N);
    rep(i,N){
        ans[i] = seg.get(a[i]+1) + 1;
        seg.update(max(1, a[i] - K + 1), a[i] + K + 2, ans[i]);
    }
	int res = 0;
	rep(i,N)res = max(res, ans[i]);
    cout << res << endl;
    return 0;
}


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>
using namespace std;
#pragma region atcoder
#include <atcoder/segtree>
using namespace atcoder;
//These are for segment tree
int op(int a, int b){return max(a, b);}
int e(){return 0;}
//bool f(int v){ return v < target;}

#pragma endregion
#pragma region macros
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vl = vector<ll>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = n - 1; i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#pragma endregion
#pragma region debug for var, v, vv
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){cout << endl;int cnt = 0;for(const auto& v : vv){cout << cnt << "th : "; view(v); cnt++;} cout << endl;}
#pragma endregion

const ll mod = 1000000007;
const int inf = 1001001001;
const ll INF = 1001001001001001001;
const int MAX = 2000005;

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; }
ll modpow(ll a, ll p){ll ret = 1; while(p){if(p & 1){ret = ret * a % mod;} a = a * a % mod; p >>= 1;} return ret;}

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

/*-----------------------------------------------------------------------------------------------------*/
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, k; cin >> n >> k;
	vi a(n);
	rep(i,n) cin >> a[i];
	segtree<int, op, e> dp(300002);
	rep(i,n){
		int len = dp.prod(max(0, a[i] - k), min(300002, a[i] + k + 1));
		dp.set(a[i], max(dp.get(a[i]), len + 1));
	}
	cout << dp.all_prod() << endl;
}

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

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

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PLL;
typedef pair<P,P> PP;
typedef vector<ll> llVEC;
typedef vector<P> PVEC;
typedef priority_queue<P,PVEC,greater<P> > PQ;
typedef priority_queue<ll, llVEC, greater<ll> > llPQ;

#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n-1; i >= a;i--)
#define LINF (ll)1e18
#define INF (int)1e9
#define fs first
#define sc second

template<typename T>
ll sz(vector<T> &vec){ return (ll)vec.size(); }
template<typename T>
ll sz(priority_queue<T, vector<T>> &pq) {return (ll)pq.size(); }
template<typename T>
ll sz(priority_queue<T, vector<T>, greater<T>> &pq) {return (ll)pq.size(); }
ll sz(string &s) {return (ll)s.size(); } 
ll gcd(ll a,ll b){ return ((!b) ?a :gcd(b, a%b)); }
ll lcm(ll a,ll b){ return a / gcd(a,b) * b; }
bool checkindex(ll i,ll n){ return (i < n && i >= 0); }
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

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

int main(){
    ll n,k;
    cin >> n >> k;
    segtree<ll,op,e> seg(600010);

    ll a;
    rep(i,0,n){
        cin >> a;
        a--;
        ll l = max(0LL,a-k);
        ll r = min(300000LL,a+k+1);
        seg.set(a-1,find(l,r)+1);
    }

    cout << seg.all_prod() << endl;


    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 <iostream>
//#include <atcoder/all>
#include "ac-library/atcoder/string.hpp"

using namespace std;
using namespace atcoder;

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n, 0);
    cin >> a[0];
    for(int i = 1;i < n;i++) {
        cin >> a[i];
    }
    int count = 1;
    int first = 0, last = 1;
    while(last < n) {
        int d = a[last] - a[first];
        if(abs(d) <= k) {
            count++;
            first = last;
            last++;
        } else {
            last++;
        }
    }
    cout << count << endl;
    return 0;
}


Compiler output:
a.cc:3:10: fatal error: ac-library/atcoder/string.hpp: No such file or directory
    3 | #include "ac-library/atcoder/string.hpp"
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

template <typename T>
class segmenttree
{
private:
    using F = function<T(T, T)>;
    int n;

    T dif;
    F f;

    T query_(int a, int b, int k, int l, int r)
    {
        if (r <= a || b <= l)
        {
            return dif;
        }

        if (a <= l && r <= b)
        {
            return st[k];
        }
        else
        {
            T x = query_(a, b, 2 * k + 1, l, (l + r) / 2);
            T y = query_(a, b, 2 * k + 2, (l + r) / 2, r);

            return f(x, y);
        }
    }

public:
    using F = function<T(T, T)>;

    vector<T> st;

    segmenttree(int size, T init, F f) : f(f)
    {
        n = 1;

        while (n < size)
        {
            n *= 2;
        }

        st.assign(2 * n - 1, init);
    }

    void set(int i, T x)
    {
        st[i + n - 1] = x;
    }

    void build()
    {
        for (int i = n - 2; i >= 0; i--)
        {
            st[i] = f(st[i * 2 + 1], st[i * 2 + 2]);
        }
    }

    void update(int i, T x)
    {
        i += n - 1;
        st[i] = x;

        while (i > 0)
        {
            i = (i - 1) / 2;
            st[i] = f(st[2 * i + 1], st[2 * i + 2]);
        }
    }

    T query(int a, int b)
    {
        return query_(a, b, 0, 0, n);
    }
};

//初期化例 segmenttree<bitset<26>> seg(n, 0, [](bitset<26> a, bitset<26> b) { return a | b; });

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

    vector<ll> a(n);
    ll ma = 0;

    for (int i = 0; i < n; i++)
    {
        cin >> a[i];

        ma = max(ma, a[i]);
    }

    segmenttree<ll> s(ma + 1, 0, [](ll a, ll b) { return max(a, b); });

    ll ans = 0;

    s.build();

    for (int i = 0; i < n; i++)
    {
        ll l, r;

        l = max(a[i] - k, 0ll);
        r = min(a[i] + k + 1, ma + 1);

        ll x = s.query(l, r) + 1;

        s.update(a[i], x);
        ans = max(ans, x);
    }

    cout << ans << endl;
}

Compiler output:
a.cc:56:32: error: redeclaration of 'using segmenttree<T>::F = class std::function<T(T, T)>'
   56 |     using F = function<T(T, T)>;
      |                                ^
a.cc:29:11: note: previous declaration 'using segmenttree<T>::F = class std::function<T(T, T)>'
   29 |     using F = function<T(T, T)>;
      |           ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define bit(k) (1LL<<(k))
#define SUM(v) accumulate(all(v), 0LL)

typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
struct fast_ios{ fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; }fast_ios_;

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) { a = b; return true; } return false; }

#define TOSTRING(x) string(#x)
template <typename T> istream &operator>>(istream &is, vector<T> &vec) { for (T &x : vec) is >> x; return is; }
template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) { os  << "["; for(auto _: v) os << _ << ", "; os << "]"; return os; };
template <typename T> ostream &operator<<(ostream &os, set<T> &st) { os << "("; for(auto _: st) { os << _ << ", "; } os << ")";return os;}
template <typename T, typename U> ostream &operator<<(ostream &os, const pair< T, U >& p){os << "{" <<p.first << ", " << p.second << "}";return os; }
template <typename T, typename U> ostream &operator<<(ostream &os, const map<T, U> &mp){ os << "["; for(auto _: mp){ os << _ << ", "; } os << "]" << endl; return os; }

#define DUMPOUT cerr
void dump_func(){ DUMPOUT << endl; }
template <class Head, class... Tail> void dump_func(Head &&head, Tail &&... tail) { DUMPOUT << head; if (sizeof...(Tail) > 0) { DUMPOUT << ", "; } dump_func(std::move(tail)...); }

#ifdef DEBUG
#define dbg(...) dump_func(__VA_ARGS__)
#define dump(...) DUMPOUT << string(#__VA_ARGS__) << ": "; dump_func(__VA_ARGS__)
#else
#define dbg(...)
#define dump(...)
#endif

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = 1000000007;
// const ll MOD = 998244353;
const long double PI = acos(-1.0);

/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/

#include<atcoder/segtree>

ll op(ll a, ll b){
    return max(a, b);
}
ll e(){
    return 0;
}
int main() {
    int N, K;
    cin >> N >> K;
    atcoder::segtree<ll, op, e> S(300010);
    vector<int> A(N);
    rep(i,N){
        cin >> A[i];
    }
    ll ans = 0;
    for(int i = 0; i < N; i++){
        int l = max(0, A[i] - K);
        int r = min(300001, A[i]+K+1);
        ll prod = S.prod(l, r);
        S.set(A[i], prod+1);
        chmax(ans, prod+1);
    }
    cout << ans << endl;
}


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

#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main()
{
  int k,n;
  cin>>n>>k;
  int a[n];
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
  }
  vector<int> b;
  for(int i=0;i<a.size();i++)
  {
    if(abs(a[i]-a[i+1])<=k) b.push_back(a[i]);
    else {b.push_back(a[i]);i++;}
  }
  //int an[b.size()];
  cout<<b.size()<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:19: error: request for member 'size' in 'a', which is of non-class type 'int [n]'
   15 |   for(int i=0;i<a.size();i++)
      |                   ^~~~
Language: C++

#include<iostream>
#include<string>
using namespace std;
int main()
{
  int k,n;
  cin>>n>>k;
  int a[n];
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
  }
  vector<int> b;
  for(int i=0;i<a.size();i++)
  {
    if(abs(a[i]-a[i+1])<=k) b.push_back(a[i]);
    else {b.push_back(a[i]);i++;}
  }
  //int an[b.size()];
  cout<<b.size()<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:3: error: 'vector' was not declared in this scope
   13 |   vector<int> b;
      |   ^~~~~~
a.cc:2:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    1 | #include<iostream>
  +++ |+#include <vector>
    2 | #include<string>
a.cc:13:10: error: expected primary-expression before 'int'
   13 |   vector<int> b;
      |          ^~~
a.cc:14:19: error: request for member 'size' in 'a', which is of non-class type 'int [n]'
   14 |   for(int i=0;i<a.size();i++)
      |                   ^~~~
a.cc:16:29: error: 'b' was not declared in this scope
   16 |     if(abs(a[i]-a[i+1])<=k) b.push_back(a[i]);
      |                             ^
a.cc:17:11: error: 'b' was not declared in this scope
   17 |     else {b.push_back(a[i]);i++;}
      |           ^
a.cc:20:9: error: 'b' was not declared in this scope
   20 |   cout<<b.size()<<endl;
      |         ^
Language: C++

#include<string>
using namespace std;
int main()
{
  int k,n;
  cin>>n>>k;
  int a[n];
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
  }
  vector<int> b;
  for(int i=0;i<a.size();i++)
  {
    if(abs(a[i]-a[i+1])<=k) b.push_back(a[i]);
    else {b.push_back(a[i]);i++;}
  }
  //int an[b.size()];
  cout<<b.size()<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:3: error: 'cin' was not declared in this scope
    6 |   cin>>n>>k;
      |   ^~~
a.cc:2:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    1 | #include<string>
  +++ |+#include <iostream>
    2 | using namespace std;
a.cc:12:3: error: 'vector' was not declared in this scope
   12 |   vector<int> b;
      |   ^~~~~~
a.cc:2:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    1 | #include<string>
  +++ |+#include <vector>
    2 | using namespace std;
a.cc:12:10: error: expected primary-expression before 'int'
   12 |   vector<int> b;
      |          ^~~
a.cc:13:19: error: request for member 'size' in 'a', which is of non-class type 'int [n]'
   13 |   for(int i=0;i<a.size();i++)
      |                   ^~~~
a.cc:15:29: error: 'b' was not declared in this scope
   15 |     if(abs(a[i]-a[i+1])<=k) b.push_back(a[i]);
      |                             ^
a.cc:16:11: error: 'b' was not declared in this scope
   16 |     else {b.push_back(a[i]);i++;}
      |           ^
a.cc:19:3: error: 'cout' was not declared in this scope
   19 |   cout<<b.size()<<endl;
      |   ^~~~
a.cc:19:3: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:19:9: error: 'b' was not declared in this scope
   19 |   cout<<b.size()<<endl;
      |         ^
a.cc:19:19: error: 'endl' was not declared in this scope
   19 |   cout<<b.size()<<endl;
      |                   ^~~~
a.cc:2:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
    1 | #include<string>
  +++ |+#include <ostream>
    2 | using namespace std;
Language: C++

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

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

    vector<int> dp(n, 1e9);
    int ans = 0;
    // rep(i, n) {
    //     dp[i] = 1;
    //     rep(j, i) {
    //         if (abs(a[i] - a[j]) <= k) {
    //             dp[i] = max(dp[i], dp[j] + 1);
    //         }
    //         ans = max(ans, dp[i]);
    //     }
    // }

    rep(i, n) {
        if (lower_bound(dp.begin(), dp.end(), a[i] - 2) != lower_bound(dp.begin(), dp.end(), a[i] + 2)) {
            *lower_bound(dp.begin(), dp.end(), a[i] - 2) = a[i];
            *lower_bound(dp.begin(), dp.end(), a[i] + 2) = a[i];
        } else {
            *lower_bound(dp.begin(), dp.end(), a[i] - 2) = a[i];
        }
    }

    int ans = 0;
    rep(i, n) {
        if (dp[i] != 1e9)
            ans = max(ans, dp[i]);
    }

    cout << ans << endl;

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:33:9: error: redeclaration of 'int ans'
   33 |     int ans = 0;
      |         ^~~
a.cc:13:9: note: 'int ans' previously declared here
   13 |     int ans = 0;
      |         ^~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
const int MOD = (int)1e9 + 7;
const int INF = (int)1e9 * 2;

int max(int l, int r){
	int n, k;
	cin >> n >> k;
	int a[n];
	rep(i, n) cin >> a[i];
    int dp[n];
    fill(dp, dp + n, 1);
    for(int i = 1; i < n; i++){
        int Max = 1;
        for(int j = 0; j < i; j++){
            if(abs(a[i] - a[j]) <= k){
                Max = max(max, dp[j] + 1);
            }
        }
        dp[i] = Max;
    }
    cout << dp[n - 1] << endl;
}

int main() {

}


Compiler output:
a.cc: In function 'int max(int, int)':
a.cc:20:26: error: no matching function for call to 'max(<unresolved overloaded function type>, int)'
   20 |                 Max = max(max, dp[j] + 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:257:5: note: candidate: 'constexpr const _Tp& std::max(const _Tp&, const _Tp&) [with _Tp = int]'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:20: note:   no known conversion for argument 1 from '<unresolved overloaded function type>' to 'const int&'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |         ~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303: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:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:20:26: note:   mismatched types 'std::initializer_list<_Tp>' and 'int (*)(int, int)'
   20 |                 Max = max(max, dp[j] + 1);
      |                       ~~~^~~~~~~~~~~~~~~~
a.cc:20:26: note:   couldn't deduce template parameter '_Tp'
a.cc:9:5: note: candidate: 'int max(int, int)'
    9 | int max(int l, int r){
      |     ^~~
a.cc:9:13: note:   no known conversion for argument 1 from '<unresolved overloaded function type>' to 'int'
    9 | int max(int l, int r){
      |         ~~~~^
a.cc:26:1: warning: no return statement in function returning non-void [-Wreturn-type]
   26 | }
      | ^
Language: C++

#include<iostream>
#include <cstdio>
#include <cmath>
#include <cstring> 
#include <algorithm>
#include <string>
using namespace std;
#define ll long long
#define M(x) memset(x,0,sizeof(x))
int main()
{
	int k,n;
	cin>>n>>k;
	int num[n];
	for(int i=0;i<n;i++)
	{
		cin>>num[i];
	}
	int T[n]={};
	ll ans=0;
	int end=0;
	while(end!=n)
	{
		int h=0;
		int temp;
		for(int i=0;i<n;i++)
		{
			if(T[i]!=0)continue;
			else
			{
				if(h==0)
				{
					temp=num[i];h++;T[i]=1;
				}
				else 
				{
					if(abs(temp-num[i])<=k)
					{
						temp=num[i];h++;T[i]=1;
					}
				}
			}
		}
		ans=max(ans,h);
	}
	cout<<ans;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:44:24: error: no matching function for call to 'max(long long int&, int&)'
   44 |                 ans=max(ans,h);
      |                     ~~~^~~~~~~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:44:24: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   44 |                 ans=max(ans,h);
      |                     ~~~^~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:5:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:44:24: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   44 |                 ans=max(ans,h);
      |                     ~~~^~~~~~~
Language: C++


// 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)

#include <bits/stdc++.h>
using namespace std;
#define ff         first
#define ss         second
#define endl       '\n'
#define pb         push_back
#define int        long long
#define vi         vector<int>
#define mii        map<int, int>
#define pii        pair<int, int>
#define all(x)     (x).begin(), (x).end()
#define fill(a,b)  memset(a, b, sizeof(a))
#define setbits(x) __builtin_popcountll(x)
#define rep(i,x,y) for(int i=(int)x; i<y; i++)
#define px(a)      for(auto x: a) cout<<x<<" "; cout<<'\n';
#define pxy(a,n)   rep(i,0,n) {px(a[i])};
/*_________________________________________________________*/

const long long MOD=1e9+7,N=3e5+5;
int dp[N][N];
int n;
int find(int i,int x,int k,vi &a){
	if(i>=n) return dp[i][x]=0;
	if(x==-1){
		return max(find(i+1,a[i],k,a)+1,find(i+1,x,k,a));
	}
	if(dp[i][x]!=-1) return dp[i][x];
	if(abs(a[i]-x)>k) return dp[i][x]=find(i+1,x,k,a);
	
	return dp[i][x]=max(find(i+1,a[i],k,a)+1,find(i+1,x,k,a));
}
int solve()
{
	fill(dp,-1);
	int k,ans=0;
	cin>>n>>k;
	vi a(n);
	rep(i,0,n) cin>>a[i];
	return find(0,-1,k,a);
}
int32_t main()
{	
	std::ios::sync_with_stdio(false); 
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<solve()<<endl;
}

Compiler output:
/tmp/ccm40Fh1.o: in function `find(long long, long long, long long, std::vector<long long, std::allocator<long long> >&)':
a.cc:(.text+0x1b): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccm40Fh1.o
/tmp/ccm40Fh1.o: in function `solve()':
a.cc:(.text+0x2ca): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccm40Fh1.o
a.cc:(.text+0x2ff): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccm40Fh1.o
a.cc:(.text+0x35d): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccm40Fh1.o
collect2: error: ld returned 1 exit status
Language: C++

// *
// *
// *  Created By :hozaifa wahid
// * "mai maut ko takia aur kafan ko chadar banakar sota hu" 
// *------------------------------------
// *  OS : Ubuntu 16.04
// *  Language : CPP14
// *  Editor : Sublime Text 3
// *  C++ compiler : g++
// *https://www.geeksforgeeks.org/space-and-time-efficient-binomial-coefficient/
// *https://www.geeksforgeeks.org/binomial-coefficient-dp-9/
//https://www.geeksforgeeks.org/compute-ncr-p-set-2-lucas-theorem/
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define inf 1000000007
#define fr first
#define sc second
#define eps 1e-9
#define clr(a) memset(a, 0, sizeof(a))
#define sz(x) x.size()
#define sni(x) scanf("%d",&x)
#define snl(x) scanf("%lld", &x)
#define snc(x) scanf("%c", &c);
#define rep(n) for(int i = 0 ; i < n ;i ++)
#define repc(i, n) for(int i = 0 ; i < n ; i ++)
#define FOR(i, x, y) for(int i = x ; i < y ; i ++)
#define DEC(i, x, y) for(int i = x ; i >= y ; i --)
#define all(v) v.begin(), v.end()
#define min3(a, b, c) min(a, min(b,c))
#define max3(a, b, c) max(a, max(b, c))
#define alla(a, n) a, a+n
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
ll a[300005];
ll vis[300005];
ll n,k;
ll t[6000055];
void modify(ll p, ll value) {  // set value at position p
  for (t[p += n] = value; p > 1; p/=2) t[p/2] = max(t[p] , t[p^1]);
}
ll query(ll l, ll r) {  // sum on interval [l, r)
  ll res = INT_MIN;
  for (l += n, r += n; l < r; l/=2, r/=2) {
    if (l&1) res =max(res, t[l++]);
    if (r&1) res = max(res,t[--r]);
  }
  return res;
}
ll go()
{
    vector<ll> dp(600005, -1); 
  
    
   
  ll mini=*min_element(a,a+n);;
        ll maxi=*max_element(a,a+n);
        
    for (ll i = 0; i < n; i++)  
    { 
  
       
        ll curr = a[i]; 
        
        ll lower = max(mini, curr - k); 
          
        
        int upper = min(maxi, curr + k); 
        
         
        
        dp[i]=max(dp[i],query(lower,upper+1)+1);
         //cout<<dp[i]<<endl;
        modify(curr,max(dp[i],query(curr,curr+1))); 
    } 
  
    ll ans = 0; 
  
    for(ll i:dp) ans = max(i, ans); 
  
    
    return ans; 
}


void solve()
{
//comb(2001,2001);
std::ios::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
ll t;
//cin>>t;
//buildPrefix();
 t=1;
while(t--)
{
  cin>>n>>k;
  FOR(i,0,n)
  cin>>a[i],t[i]=-1;
  ll res=go();
  cout<<res;
  
}
}
 
 
 
int main(){
    std::ios::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    
    solve();
    
}
 
 
 
 
 
 
 
 
 
 

Compiler output:
a.cc: In function 'void solve()':
a.cc:105:14: error: invalid types 'll {aka long long int}[int]' for array subscript
  105 |   cin>>a[i],t[i]=-1;
      |              ^
Language: C++


// 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)

#include <bits/stdc++.h>
using namespace std;
#define ff         first
#define ss         second
#define endl       '\n'
#define pb         push_back
#define int        long long
#define vi         vector<int>
#define mii        map<int, int>
#define pii        pair<int, int>
#define all(x)     (x).begin(), (x).end()
#define fill(a,b)  memset(a, b, sizeof(a))
#define setbits(x) __builtin_popcountll(x)
#define rep(i,x,y) for(int i=(int)x; i<y; i++)
#define px(a)      for(auto x: a) cout<<x<<" "; cout<<'\n';
#define pxy(a,n)   rep(i,0,n) {px(a[i])};
/*_________________________________________________________*/

const long long MOD=1e9+7,N=3e5+5;
int dp[N][N];
int n;
int find(int i,int x,int k,vi &a){
	if(i>=n) return dp[i][x]=0;
	if(x==-1){
		return dp[i][x]=max(find(i+1,a[i],k,a)+1,find(i+1,x,k,a));
	}
	if(dp[i][x]!=-1) return dp[i][x];
	if(abs(a[i]-x)>k) return dp[i][x]=find(i+1,x,k,a);
	
	return dp[i][x]=max(find(i+1,a[i],k,a)+1,find(i+1,x,k,a));
}
int solve()
{
	fill(dp,-1);
	int k,ans=0;
	cin>>n>>k;
	vi a(n);
	rep(i,0,n) cin>>a[i];
	return find(0,-1,k,a);
}
int32_t main()
{	
	std::ios::sync_with_stdio(false); 
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<solve()<<endl;
}

Compiler output:
/tmp/ccj3WOwO.o: in function `find(long long, long long, long long, std::vector<long long, std::allocator<long long> >&)':
a.cc:(.text+0x1b): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccj3WOwO.o
/tmp/ccj3WOwO.o: in function `solve()':
a.cc:(.text+0x318): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccj3WOwO.o
a.cc:(.text+0x34d): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccj3WOwO.o
a.cc:(.text+0x3ab): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccj3WOwO.o
collect2: error: ld returned 1 exit status
Language: C++

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

int main(){
  int n,k;
  cin >> n >>k;
  vector<int> a(n);
  int ans =1;
  cin >> a.at(0);
  int temp = a.at(0);
  for(int i=1;i<n;i++){
    cin >> a.at(i);
    if(abs(temp - a.at(i))<=k){
      temp = a.at(i);
      ans++;
    }
  } 
  
  ans2 = 1;
  for(int i=2;i<n;i++){
    if(n-i+1>=ans){
      temp = a.at(i);
      for(int j=i+1;j<n;j++){
        if(abs(temp - a.at(j))<=k){
          temp = a.at(j);
          ans2++;
        }
      }
      if(ans2>ans){
        ans = ans2;
      }
    }
  }
  cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:3: error: 'ans2' was not declared in this scope; did you mean 'ans'?
   19 |   ans2 = 1;
      |   ^~~~
      |   ans
Language: C

#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
	int n, k, a, temp, res = 1;
	cin >> n >> k;
	scanf("%d", &temp);
	while (n--)
	{
		scanf("%d", &a);
		if (abs(a - temp) <= k)
		{
			res++;
			temp = a;
		}
	}
	cout << res;
	return 0;
}

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

#include <bits/stdc++.h>
#include <atcoder/twosat>
#include <iostream>
#include <vector>

using namespace std;
using namespace atcoder;

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++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;//llの最大9*10^18
const int INF = pow(2, 30) - 1;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

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

    ll N,K;
    string S;
    cin >> N>>K;

    vector<ll> A(N),B(N);
    REP(i, N){
        cin >> A.at(i);
    }

    REP(i,N-1){
        B.at(i+1) = A.at(i);
    }
    B.at(0) = A.at(N - 1);

    two_sat ts(N);

    for (int i = 0; i < N; i++)
    {
        for (int j = i + 1; j < N; j++)
        {
            if (abs(A[i] - A[j]) < K)
            {
                // cannot use both of x[i] and x[j]
                ts.add_clause(i, true, j, true);
            }
            if(abs(A[i] - B[j])<K)
            {
                ts.add_clause(i, true, j, false);
            }
            if (abs(A[j] - B[i]) < K)
            {
                ts.add_clause(i, false, j, true);
            }
            if(abs(A[j] - B[j]){
                ts.add_clause(i, false, j, false);
            }
        }
    }

    ll count = 0;

    if(!ts.satisfiable()){
        cout << 0 << endl;
    }
    else{
        auto ans = ts.answer();
        REP(i,N){
            if (ans[i] == true)
            {
                count++;
            }
        }

        cout << count << endl;
    }
}


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

#include <bits/stdc++.h>
#define rep(i, e, n) for (int i = e; i < (n); ++i)
using namespace std;
typedef long long ll;
using P = pair<int,ll>;
const ll inf=1000000000007;
const int mod=1000000007;


int main() {
  int n,k;
  cin >> n >> k;
  vector<int> a(n);

  vector<int> rans(n,1);
  for(int i=n-2; i>=0;i--){
    int val=a[i];
    for(int j=i+1; j<n; j++){
      if(abs(val-a[j])<=k) {
          rans[i]+= rans[j];
          break;          
      }
    }
  }
  int mx=0;
  rep(i,0,n) mx=max(ans[i],mx);
  rep(i,0,n) mx=max(rans[i],mx);
  cout << mx << endl;
//  rep(i,0,n) cout << ans[i] << ' ';
//  cout << endl;
//  rep(i,0,n) cout << rans[i] << ' ';
//  cout << endl;

  return 0;



}


Compiler output:
a.cc: In function 'int main()':
a.cc:26:21: error: 'ans' was not declared in this scope; did you mean 'rans'?
   26 |   rep(i,0,n) mx=max(ans[i],mx);
      |                     ^~~
      |                     rans
Language: C++

#include <iostream>
#include <vector>
#include <cmath>
using namespace std;

int main()
{
  	int n, k;
  	cin >> n >> k;
	int a[n];
  	for (int i=0; i<n; i++)
  	{
    	cin >> a[i];
  	}
  	int len, maxlen=1;
  	for (int i=0; i<n; i++)
    {
        len = 0;
        for (int j=i+1; j<n; j++)
        {
            if (abs(a[j]-prev) <= k)
            {
                len++;
                prev = a[j];
            }
        }
        if (len > maxlen) maxlen = len;
    }

}


Compiler output:
a.cc: In function 'int main()':
a.cc:21:25: error: invalid operands of types 'int' and '<unresolved overloaded function type>' to binary 'operator-'
   21 |             if (abs(a[j]-prev) <= k)
      |                     ~~~~^~~~~
a.cc:24:27: error: overloaded function with no contextual type information
   24 |                 prev = a[j];
      |                           ^
Language: C++

#include <iostream>
#include <vector>
#include <cmath>
using namespace std;

int main()
{
  	int n, k;
  	cin >> n >> k;
	int a[n];
  	for (int i=0; i<n; i++)
  	{
    	cin >> a[i];
  	}
  	int len, maxlen=1;
  	for (int i=0; i<n; i++)
    {
        len = 0;
        for (j=i+1; j<n; j++)
        {
            if (abs(a[j]-prev) <= k)
            {
                len++;
                prev = a[j];
            }
        }
        if (len > maxlen) maxlen = len;
    }

}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:14: error: 'j' was not declared in this scope
   19 |         for (j=i+1; j<n; j++)
      |              ^
Language: C++

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using ll = long long;
using namespace atcoder;
using lint = long long;
const lint INF = 1ll << 60;
const int mod = 1e9+7;



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

int e() {
    return (int)(mod);
}

int main(void) {
  int n, k; cin >> n >> k;
  segtree<int,op,e> s(n);
	vector<int> d(n);
	for (int i = 0; i < n; i++) {
      cin >> d[i];
    }
  for (int i=0;i<n;i++) 
    s.set(i,0);
  vector<int> dp(n,0);
  for (int i=0;i<n;i++){
    dp[d[i]-1]=s.prod(max(0,d[i]-k),min(n,d[i]+k + 1));
    s.set(i,dp[i]);
  }
  int ans=0;
  for (int i=0;i<n;i++) ans=max(dp[i],ans);
  cout<<ans<<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 <iostream>
#include <map>
#include <algorithm>
#include <cmath>
using namespace std;

int arr[300000];
int maxlen[300000];
const int N = 300000;  // limit for array size
int t[4 * N + 1];

void buildTree(int* tree, int index, int s, int e)
{
	//base case
	if (s > e)
		return;
	//reached leaf node
	if (s == e)
	{
		tree[index] = 0;
		return;
	}
	//now build the segment tree in bottom up manner
	int m = (s + e) / 2;
	buildTree(tree, 2 * index, s, m);
	buildTree(tree, 2 * index + 1, m + 1, e);
	tree[index] = max(tree[2 * index], tree[2 * index + 1]);
	return;
}

//function to query the segment tree for RMQ
int query(int* tree, int index, int s, int e, int qs, int qe)
{
	//base case: if query range is outside the node range
	if (qs > e || s > qe)
		return INT_MIN;
	//complete overlap
	if (s >= qs && e <= qe)
		return tree[index];
	//now partial overlap case is executed
	int m = (s + e) / 2;
	int left_ans = query(tree, 2 * index, s, m, qs, qe);
	int right_ans = query(tree, 2 * index + 1, m + 1, e, qs, qe);
	return max(left_ans, right_ans);
}

//function to update a value at position to "pos"
void updateNode(int* tree, int index, int s, int e, int pos, int val)
{
	if (pos<s || pos>e)
		return;
	if (s == e)
	{
		tree[index] = val;
		return;
	}
	int m = (s + e) / 2;
	updateNode(tree, 2 * index, s, m, pos, val);
	updateNode(tree, 2 * index + 1, m + 1, e, pos, val);
	tree[index] = max(tree[2 * index], tree[2 * index + 1]);
	return;
}

int main() {
	int result = 0;
	int n, k;
	cin >> n >> k;

	for (int i = 0; i < n; i++)
	{
		cin >> arr[i];
	}

	int s = 0, e = n - 1;
	buildTree(t, 1, 0, n-1);

	for (int i = 0; i < n; i++)
	{
		int a = arr[i];

		// a가 마지막
		// - activelast 에서 제일 긴거 탐색, 뒤에 이어 붙인다?
		/*for (int j = 0; j < i; j++)
		{
			if (abs(arr[j] - arr[i]) <= k)
			{
				maxlen[i] = max(maxlen[i], maxlen[j] + 1);
			}
		}
		
		// a가 처음임
		maxlen[i] = max(maxlen[i], 1);
		result  = max(result, maxlen[i]);*/

		int maxim = query(t, 1, s, e, a-k, a+k+1);
		updateNode(t, 1, s, e, a, maxim + 1);

		maxlen[i] = maxim + 1;
		result = max(result, maxlen[i]);
	}

	//debug
	/*for (int i = 0; i < n; i++)
	{
		cout << maxlen[i] << ' ';
	}
	cout << endl;*/

	cout << result << endl;
}

Compiler output:
a.cc: In function 'int query(int*, int, int, int, int, int)':
a.cc:36:24: error: 'INT_MIN' was not declared in this scope
   36 |                 return INT_MIN;
      |                        ^~~~~~~
a.cc:5:1: note: 'INT_MIN' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    4 | #include <cmath>
  +++ |+#include <climits>
    5 | using namespace std;
Language: C++

#include <bits/stdc++.h>

#include <atcoder/all>
using namespace std;
using namespace atcoder;

typedef long long ll;

int op(int a, int b) { return a + b; }
int e() { return 0; }

int main() {
  int n, k, ans = 0;
  cin >> n >> k;

  segtree<int, op, e> seg(n - 1);
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 1; i < n; i++) seg.set(i - 1, a[i] - a[i - 1]);

  for (int i = 0; i < n; i++) {
    int l = i, r = i + 1, tmp = 0;
    while (r < n) {
      if (seg.prod(l, r) <= k) {
        tmp++;
        l = r;
      }
      r++;
    }
    if (ans < tmp) ans = tmp;
  }

  cout << ans << endl;
}

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/segtree>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll/*, vl, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef pair<pl, ll> ppl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rep2(i, k, n) for(ll i = ll(k); i <= ll(n); i++)
#define rep3(i, n, k) for(ll i = ll(n); i >= ll(k); i--)
#define all(v) (v).begin(), (v).end()
ll mod(ll a, ll b) {if(b == 0) return 0; return (a % b + b) % b;}
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 3e5;
const char newl = '\n';

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

ll e() {
    return 0;
}

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

  ll n, k;
  cin >> n >> k;

  vl a(n);
  rep(i, n) cin >> a[i];

  atcoder::segtree<ll, op, e> dp(MAX);
  ll ans=0;
  rep(i, n) {
    dp.set(a[i], dp.prod(max(a[i]-k, 0LL), min(a[i]+k+1, MAX)) + 1);
    chmax(ans, dp.get(a[i]));
  }
  cout << ans << newl;
  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;
#define mod 1e18
#define ll long long int
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define inf 9223372036854775807
#define mini 9223372036854775807
ll A[500005];
ll tree[2000005];
void update(ll node, ll start, ll end, ll idx, ll val)
{
    if(start == end)
    {
        A[idx] += val;
        tree[node] += val;
    }
    else
    {
        ll mid = (start + end) / 2;
        if(start <= idx and idx <= mid)
        {
            update(2*node, start, mid, idx, val);
        }
        else
        {
            update(2*node+1, mid+1, end, idx, val);
        }
        tree[node] = tree[2*node] + tree[2*node+1];
    }
}
ll query(ll node, ll start, ll end, ll l, ll r)
{
    if(r < start or end < l)
    {
        return 0;
    }
    if(l <= start and end <= r)
    {
        return tree[node];
    }
    ll mid = (start + end) / 2;
    ll p1 = query(2*node, start, mid, l, r);
    ll p2 = query(2*node+1, mid+1, end, l, r);
    return (p1 + p2);
}
int main()
{
	boost
	ll n,k;
	cin>>n>>k;
	ll a[n];
	pair<ll,ll>p[n];
	ll c[n];
	for(ll i=0; i<n; i++)
	{
		cin>>a[i];
		p[i]=mp(a[i],i);
	}
	sort(p,p+n);
	ll b[n];
	for(ll i=0; i<n; i++)
	{
		b[p[i].se]=i;
		c[i]=p[i].fi;
	}	
	for(ll i=n-1; i>=0; i--)
	{
		ll ub=upper_bound(c,c+n,a[i]+k)-c;
		ub--;
		ll lb=lower_bound(c,c+n,a[i]-k)-c;
		ll xxx=query(1,0,n,lb,ub);
		xxx%=mod;
		xxx++;
		xxx%=mod;
		update(1,0,n,b[i],xxx);
	}
	ll ans=query(1,0,n,0,n);
	ans%=mod;
	cout<<ans<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:76:20: error: invalid operands of types 'long long int' and 'double' to binary 'operator%'
   76 |                 xxx%=mod;
      |                    ^
a.cc:76:20: note:   in evaluation of 'operator%=(long long int, double)'
a.cc:78:20: error: invalid operands of types 'long long int' and 'double' to binary 'operator%'
   78 |                 xxx%=mod;
      |                    ^
a.cc:78:20: note:   in evaluation of 'operator%=(long long int, double)'
a.cc:82:12: error: invalid operands of types 'long long int' and 'double' to binary 'operator%'
   82 |         ans%=mod;
      |            ^
a.cc:82:12: note:   in evaluation of 'operator%=(long long int, double)'
Language: C++

#include <bits/stdc++.h>
#include <atcoder/segtree>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll/*, vl, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef pair<pl, ll> ppl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rep2(i, k, n) for(ll i = ll(k); i <= ll(n); i++)
#define rep3(i, n, k) for(ll i = ll(n); i >= ll(k); i--)
#define all(v) (v).begin(), (v).end()
ll mod(ll a, ll b) {if(b == 0) return 0; return (a % b + b) % b;}
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 3e5;
const char newl = '\n';

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

int e() {
    return 0;
}

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

  ll n, k;
  cin >> n >> k;

  vl a(n);
  rep(i, n) cin >> a[i];

  segtree<ll, op, e> dp(MAX);
  ll ans=0;
  rep(i, n) {
    dp[a[i]] = dp.prod(max(a[i]-k, 0LL), min(a[i]+k+1, MAX)) + 1;
    chmax(ans, dp[a[i]]);
  }
  cout << ans << newl;
  return 0;
}

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

/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Ideone
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int a[] = new int[n];
		for(int i = 0; i < n; i++) a[i] = sc.nextInt();
		System.out.println(lengthOfLISAtLeastK(a,k));
	}
	public static int lengthOfLISAtLeastK(int[] nums, int K) {
    if ( nums == null ) return 0;
    if ( nums.length <= 1 ) return nums.length;
    List<Integer> list = new ArrayList<Integer>(nums.length);
    list.add( 0, nums[0] );
    for ( int i = 1; i < nums.length; i++ ) {
        if ( Math.abs(nums[i] - list.get( list.size() - 1 )) <= K ) {
            list.add( nums[i] );
        } else  {
            int index = Collections.binarySearch( list, nums[i] );
            if ( index >= 0 && index < nums.length ) {
                list.set( index, nums[i] );
            } else {
                if ( -index - 1 > list.size() - 1 ) {
                    if ( Math.abs(nums[i] - list.get(list.size()-1)) <= K ) {
                        list.add(nums[i]);
                    }
                } else {
                     if ( -index - 1 == 0 ) {
                        list.set(-index-1, nums[i]);
                    } else if ( Math.abs(nums[i] - list.get(-index-2)) <= K ) {
                        list.set(-index-1, nums[i]);
                    }
                }
            }
        }
    }
    return list.size();
}
}

Compiler output:
Main.java:8: error: class Ideone is public, should be declared in a file named Ideone.java
public class Ideone
       ^
1 error