Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>

using namespace std;

#define INF (int)1E6

struct seg
{
    pubcic : int log, size;
    vector<int> v;
    seg(n)
    {
        log = 0;
        while ((1 << log) < n)
        {
            log++;
        }
        size = (1 << log);
        v = vector<int>(2 * size, 0);
    }

    void set(int p, int x)
    {
        p += size;
        v[p] = x;
        for (int i = 1; i <= log; i++)
        {
            int parent = p >> i;
            v[parent] = max(v[parent << 1], v[parent << 1 + 1]);
        }
    }

    int query(int l, int r)
    {
        int sml = 0, smr = 0;
        l += size;
        r += size;
        while (l < r)
        {
            if (l & 1)
                sml = max(sml, d[l++]);
            if (r & !)
                smr = max(smr, d[--r]);
            l >>= 1;
            r >>= 1;
        }
        return max(l, r);
    }
};

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }

    seg s(300010);
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        int l = min(0, a[i] - k);
        int r = max(300000, a[i] + k);
        int tmp = s.query(l, r + 1);
        s.set(a[i], tmp + 1);
        ans = max(ans, tmp + 1);
    }

    cout << ans << endl;
}

Compiler output:
a.cc:13:5: error: 'pubcic' does not name a type
   13 |     pubcic : int log, size;
      |     ^~~~~~
a.cc:15:9: error: field 'n' has incomplete type 'seg'
   15 |     seg(n)
      |         ^
a.cc:11:8: note: definition of 'struct seg' is not complete until the closing brace
   11 | struct seg
      |        ^~~
a.cc:24:5: error: expected ';' at end of member declaration
   24 |     }
      |     ^
      |      ;
a.cc: In member function 'void seg::set(int, int)':
a.cc:28:14: error: overloaded function with no contextual type information
   28 |         p += size;
      |              ^~~~
a.cc:30:30: error: 'log' was not declared in this scope; did you mean 'long'?
   30 |         for (int i = 1; i <= log; i++)
      |                              ^~~
      |                              long
a.cc: In member function 'int seg::query(int, int)':
a.cc:40:14: error: overloaded function with no contextual type information
   40 |         l += size;
      |              ^~~~
a.cc:41:14: error: overloaded function with no contextual type information
   41 |         r += size;
      |              ^~~~
a.cc:45:32: error: 'd' was not declared in this scope
   45 |                 sml = max(sml, d[l++]);
      |                                ^
a.cc:46:22: error: expected primary-expression before ')' token
   46 |             if (r & !)
      |                      ^
a.cc:47:32: error: 'd' was not declared in this scope
   47 |                 smr = max(smr, d[--r]);
      |                                ^
a.cc: In function 'int main()':
a.cc:65:17: error: no matching function for call to 'seg::seg(int)'
   65 |     seg s(300010);
      |                 ^
a.cc:11:8: note: candidate: 'seg::seg()'
   11 | struct seg
      |        ^~~
a.cc:11:8: note:   candidate expects 0 arguments, 1 provided
a.cc:11:8: note: candidate: 'seg::seg(const seg&)'
a.cc:11:8: note:   no known conversion for argument 1 from 'int' to 'const seg&'
a.cc:11:8: note: candidate: 'seg::seg(seg&&)'
a.cc:11:8: note:   no known conversion for argument 1 from 'int' to 'seg&&'