Language: C++

#include<cstdio>
#include<algorithm>
#define INF 1e9
using namespace std;
typedef long long ll;
int n,d;
struct data{
	ll x,y,c;
};

bool comp(const data& d1,const data& d2){
	return d1.c<d2.c;
};

data s[200001];

struct segtree{
	int val,b,s,v2;
};
segtree seg[2][1<<22];

void init(){
	for(int i=0;i<(1<<22);i++)seg[0][i].s=seg[1][i].s=INF;
	for(int i=1<<21;i<1<<22;i++)seg[0][i].v2=seg[1][i].v2=i-(1<<22);
}

void update(int upd,int x,int a){
	x+=(1<<21);
	seg[upd][x].val+=a;
	if(seg[upd][x].val>=1)seg[upd][x].s=seg[upd][x].b=seg[upd][x].v2;
	else{
		seg[upd][x].s=INF;
		seg[upd][x].b=0;
	}
	while(x>0){
		x=(x-1)/2;
		seg[upd][x].s=min(seg[upd][x*2+1].s,seg[upd][x*2+2].s);
		seg[upd][x].b=max(seg[upd][x*2+1].b,seg[upd][x*2+2].b);
	}
}


int main(void){
	scanf("%d%d",&n,&d);
	init();
	for(int i=0;i<n;i++)scanf("%lld%lld%lld",&s[i].x,&s[i].y,&s[i].c);
	sort(s,s+n,comp);
	ll res=0;
	int mc=0;
	for(int i=0;i<n;i++){
		update(0,s[i].x,1);
		update(1,s[i].y,1);
		while(s[i].c-s[mc].c>d){
			update(0,s[mc].x,-1);
			update(1,s[mc].y,-1);
			mc++;
		}
		res=max(res,(seg[0][0].b-seg[0][0].s)*(seg[1][0].b-seg[1][0].s));
	}
	printf("%lld\n",res);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:58:24: error: no matching function for call to 'max(ll&, int)'
   58 |                 res=max(res,(seg[0][0].b-seg[0][0].s)*(seg[1][0].b-seg[1][0].s));
      |                     ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from a.cc:2:
/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:58:24: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   58 |                 res=max(res,(seg[0][0].b-seg[0][0].s)*(seg[1][0].b-seg[1][0].s));
      |                     ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:58:24: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   58 |                 res=max(res,(seg[0][0].b-seg[0][0].s)*(seg[1][0].b-seg[1][0].s));
      |                     ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~