Language: C++

#include<vector>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#define pb push_back
#define gt getchar()
#define ll long long
#define File(s) freopen(s".in","r",stdin),freopen(s".out","w",stdout)
typedef std::pair<int,int> P;
#define mk std::make_pair
#define fr first
#define sc second
inline int in()
{
	int k=0;char ch=gt;bool p=1;
	while(ch<'-')ch=gt;if(ch=='-')ch=gt,p=0;
	while(ch>'-')k=k*10+ch-'0',ch=gt;
	return p?k:-k;
}
const int N=4e5+5;
ll ans=1e18;
ll x[N],y[N],n,Mx,Mi,mx,mi,fz[N<<1],tot;
std::vector<int>G[N<<1];
inline void upd(int x,int i){if(x>Mx)Mx=x,mx=i;if(x<Mi)Mi=x,mi=i;}
inline void work1()
{
	int mmx=-2e9,mmi=2e9;
	mmx=std::max(mmx,y[mx]);
	mmi=std::min(mmi,x[mi]);
	for(int i=1;i<=n;++i)
		if(i!=mx&&i!=mi)
			mmx=std::max(mmx,y[i]),mmi=std::min(mmi,x[i]);
	ans=std::min(ans,1ll*(mmx-Mi)*(Mx-mmi));
}
inline void work2()
{
	for(int i=1;i<=n;++i)fz[++tot]=x[i],fz[++tot]=y[i];
	std::sort(fz+1,fz+tot+1);tot=std::unique(fz+1,fz+tot+1)-fz-1;
	int mmi=std::min(y[mx],x[mi]),mmx=y[mx]+x[mi]-mmi;
	for(int i=1;i<=n;++i)if(i!=mx&&i!=mi)mmi=std::min(mmi,x[i]),mmx=std::max(mmx,y[i]);
	int l=std::lower_bound(fz+1,fz+tot+1,mmi)-fz;
	for(int i=1;i<=n;++i)if(i!=mx&&i!=mi)G[std::lower_bound(fz+1,fz+tot+1,y[i])-fz].pb(i);
	for(int i=2;i<=l;++i)
	{
		ans=std::min(ans,1ll*(Mx-Mi)*(mmx-fz[i]));
		for(int j:G[i])mmx=std::max(mmx,x[j]);
	}
}
int main()
{
	n=in();Mx=-2e9,Mi=2e9;
	for(int i=1;i<=n;++i)
	{
		upd(x[i]=in(),i),upd(y[i]=in(),i);
		if(x[i]<y[i])std::swap(x[i],y[i]);
	}
	work1(),work2();printf("%lld\n",ans);
	return 0;
}


Compiler output:
a.cc: In function 'void work1()':
a.cc:30:21: error: no matching function for call to 'max(int&, long long int&)'
   30 |         mmx=std::max(mmx,y[mx]);
      |             ~~~~~~~~^~~~~~~~~~~
In file included from /usr/include/c++/14/vector:62,
                 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:30:21: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   30 |         mmx=std::max(mmx,y[mx]);
      |             ~~~~~~~~^~~~~~~~~~~
/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:30:21: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   30 |         mmx=std::max(mmx,y[mx]);
      |             ~~~~~~~~^~~~~~~~~~~
a.cc:31:21: error: no matching function for call to 'min(int&, long long int&)'
   31 |         mmi=std::min(mmi,x[mi]);
      |             ~~~~~~~~^~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:31:21: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   31 |         mmi=std::min(mmi,x[mi]);
      |             ~~~~~~~~^~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:31:21: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   31 |         mmi=std::min(mmi,x[mi]);
      |             ~~~~~~~~^~~~~~~~~~~
a.cc:34:37: error: no matching function for call to 'max(int&, long long int&)'
   34 |                         mmx=std::max(mmx,y[i]),mmi=std::min(mmi,x[i]);
      |                             ~~~~~~~~^~~~~~~~~~
/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:34:37: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   34 |                         mmx=std::max(mmx,y[i]),mmi=std::min(mmi,x[i]);
      |                             ~~~~~~~~^~~~~~~~~~
/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
/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:34:37: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   34 |                         mmx=std::max(mmx,y[i]),mmi=std::min(mmi,x[i]);
      |                             ~~~~~~~~^~~~~~~~~~
a.cc:34:60: error: no matching function for call to 'min(int&, long long int&)'
   34 |                         mmx=std::max(mmx,y[i]),mmi=std::min(mmi,x[i]);
      |                                                    ~~~~~~~~^~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:34:60: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   34 |                         mmx=std::max(mmx,y[i]),mmi=std::min(mmi,x[i]);
      |                                                    ~~~~~~~~^~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:34:60: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   34 |                         mmx=std::max(mmx,y[i]),mmi=std::min(mmi,x[i]);
      |                                                    ~~~~~~~~^~~~~~~~~~
a.cc: In function 'void work2()':
a.cc:42:58: error: no matching function for call to 'min(int&, long long int&)'
   42 |         for(int i=1;i<=n;++i)if(i!=mx&&i!=mi)mmi=std::min(mmi,x[i]),mmx=std::max(mmx,y[i]);
      |                                                  ~~~~~~~~^~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:42:58: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   42 |         for(int i=1;i<=n;++i)if(i!=mx&&i!=mi)mmi=std::min(mmi,x[i]),mmx=std::max(mmx,y[i]);
      |                                                  ~~~~~~~~^~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:42:58: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   42 |         for(int i=1;i<=n;++i)if(i!=mx&&i!=mi)mmi=std::min(mmi,x[i]),mmx=std::max(mmx,y[i]);
      |                                                  ~~~~~~~~^~~~~~~~~~
a.cc:42:81: error: no matching function for call to 'max(int&, long long int&)'
   42 |         for(int i=1;i<=n;++i)if(i!=mx&&i!=mi)mmi=std::min(mmi,x[i]),mmx=std::max(mmx,y[i]);
      |                                                                         ~~~~~~~~^~~~~~~~~~
/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_