Language: C++

#include<bits/stdc++.h>

#define int long long int
#define rep(a,b,c) for(int a=b;a<c;a++)
#define repm(a,b,c) for(int a=(b-1);a>=c;a--)
#define pb push_back
#define str string
#define sf(a) scanfs("%d",&a)
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()
#define clean(used) memset(used,false,sizeof(used))
using namespace std;

static const int INF = 1e18 + 9;
static const int Mod = 1e9 + 7;
inline int replac(str s){double ans=0;rep(i,0,s.length()){ans+=(s[i]-'0')*pow(10,s.length()-i-1);}return (int)ans;}
inline string numstr(int m){str s="";while(m>0){char c;int a=m/10;if(a>0)a=m%(a*10);else a=m;c=(char)('0'+a);s+=c;m/=10;}str st="";for(int i=s.size()-1;i>=0;i--){st+=s[i];}return st;}
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vii;

static const int MAX_N = 200002;

struct Seg{
    int n;
    int dat[MAX_N * 2];
    void init(int n_){
        init(n_ , INF);
    }

    void init(int n_, int d){
        n = 1;
        while(n < n_)n *= 2;
        fill(dat, dat + MAX_N * 2, d);
    }
};

struct SegMin : Seg {
    int Min(int s,int t){
        return Min(s,t,0,0,n);
    }
    int Min(int s, int t, int k, int l, int r){
        if(r <= s || t <= l) return INF;
        if(s <= l && r <= t) return dat[k];

        int t1 = Min(s, t, k * 2 + 1, l, (l + r)/2);
        int t2 = Min(s, t, k * 2 + 2, (l + r)/2, r);
        return min(t1, t2);
    }
    void update(int k, int x){
        k += n - 1;
        dat[k] = min(dat[k], x);
        while(0 < k){
            k = (k - 1)/2;
            dat[k] = min(dat[k * 2 + 1], dat[k * 2 + 2]);
        }
    }
};

SegMin x1,x2,y1,y2;

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int d,m;
    cin >> m >> d;
    x1.init(m);
    x2.init(m);
    y1.init(m);
    y2.init(m);
    int b_max = 0;
    int x,y,b;
    rep(i,0,m){
        cin >> x >> y >> b;
        x1.update(b,x);
        x2.update(b,-x);
        y1.update(b,y);
        y2.update(b,-y);
    }
    int ans = 0,x_mi,x_ma,y_mi,y_ma;
    rep(i,0,MAX_N){
        x_mi = x1.Min(i,i+d+1);
        x_ma = x2.Min(i,i+d+1);
        y_mi = y1.Min(i,i+d+1);
        y_ma = y2.Min(i,i+d+1);
        ans = max(ans, abs(x_ma+x_mi)*abs(y_ma+y_mi));
    }
    cout << ans << endl;
    return 0;
}

Compiler output:
a.cc:63:14: error: 'SegMin y1' redeclared as different kind of entity
   63 | SegMin x1,x2,y1,y2;
      |              ^~
In file included from /usr/include/features.h:523,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/c++config.h:683,
                 from /usr/include/c++/14/cassert:43,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:33,
                 from a.cc:1:
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:257:1: note: previous declaration 'double y1(double)'
  257 | __MATHCALL (y1,, (_Mdouble_));
      | ^~~~~~~~~~
a.cc: In function 'int main()':
a.cc:72:8: error: request for member 'init' in 'y1', which is of non-class type 'double(double) noexcept'
   72 |     y1.init(m);
      |        ^~~~
a.cc:80:12: error: request for member 'update' in 'y1', which is of non-class type 'double(double) noexcept'
   80 |         y1.update(b,y);
      |            ^~~~~~
a.cc:87:19: error: request for member 'Min' in 'y1', which is of non-class type 'double(double) noexcept'
   87 |         y_mi = y1.Min(i,i+d+1);
      |                   ^~~