Language: C++

#include <bits/stdc++.h>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 30;

const int nmax=200010;
int n,d;
int x[nmax],y[nmax],b[nmax];

int index[nmax];

int offset;
int xdata[1<<19][2],ydata[1<<19][2];

void init(int m){
	offset=1;
	while(offset<m) offset*=2;
	rep(i,2*offset-1){
		xdata[i][0]=ydata[i][0]=inf;
		xdata[i][1]=ydata[i][1]=-inf;
	}
}

void update(int data[1<<19][2],int k,int x){
	k+=offset-1;
	data[k][0]=min(data[k][0],x);
	data[k][1]=max(data[k][1],x);
	while(k>0){
		k=(k-1)/2;
		data[k][0]=min(data[2*k+1][0],data[2*k+2][0]);
		data[k][1]=max(data[2*k+1][1],data[2*k+2][1]);
	}
	return;
}

pii query(int data[1<<19][2],int a,int b,int k,int l,int r){
	// cerr << a << " " << b <<" " << k << " " << l << " " << r << endl;
	if(b<=l||r<=a)
		return make_pair(inf,-inf);
	if(a<=l&&r<=b)
		return make_pair(data[k][0],data[k][1]);
	else{
		pii vl=query(data,a,b,2*k+1,l,(l+r)/2);
		pii vr=query(data,a,b,2*k+2,(l+r)/2,r);
		return	make_pair(min(vl.first,vr.first),max(vl.second,vr.second));
	}
}

int main(void){
	cin >> n >> d;
	rep(i,n) cin >> x[i] >> y[i] >> b[i];
	rep(i,n) index[i]=b[i];
	sort(index,index+n);
	int m=unique(index,index+n)-index;
	init(m);

	rep(i,n){
		int pos=lower_bound(index,index+m,b[i])-index;
		update(xdata,pos,x[i]);
		update(ydata,pos,y[i]);
	}


	ll ans=0LL;
	rep(i,m){
		int j=upper_bound(index,index+m,index[i]+d)-index;
		pii xx=query(xdata,i,j,0,0,offset);
		pii yy=query(ydata,i,j,0,0,offset);
		ans=max(ans,1LL*(xx.second-xx.first)*(yy.second-yy.first));
	}
	cout << ans << endl;
	return 0;
}

Compiler output:
a.cc:36:15: error: 'int index [200010]' redeclared as different kind of entity
   36 | int index[nmax];
      |               ^
In file included from /usr/include/string.h:462,
                 from /usr/include/c++/14/cstring:43,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:121,
                 from a.cc:1:
/usr/include/strings.h:50:20: note: previous declaration 'const char* index(const char*, int)'
   50 | extern const char *index (const char *__s, int __c)
      |                    ^~~~~
a.cc: In function 'int main()':
a.cc:78:23: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   78 |         rep(i,n) index[i]=b[i];
      |                       ^
a.cc:79:25: error: invalid operands of types '<unresolved overloaded function type>' and 'int' to binary 'operator+'
   79 |         sort(index,index+n);
      |                    ~~~~~^~
a.cc:80:33: error: invalid operands of types '<unresolved overloaded function type>' and 'int' to binary 'operator+'
   80 |         int m=unique(index,index+n)-index;
      |                            ~~~~~^~
a.cc:84:48: error: invalid operands of types '<unresolved overloaded function type>' and 'int' to binary 'operator+'
   84 |                 int pos=lower_bound(index,index+m,b[i])-index;
      |                                           ~~~~~^~
a.cc:92:46: error: invalid operands of types '<unresolved overloaded function type>' and 'int' to binary 'operator+'
   92 |                 int j=upper_bound(index,index+m,index[i]+d)-index;
      |                                         ~~~~~^~
a.cc:92:54: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   92 |                 int j=upper_bound(index,index+m,index[i]+d)-index;
      |                                                      ^