Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

const ll INF=1e9+7;
const ll N=1E5+7;
ll l[N],r[N];
ll arr[N];
struct stu{
	ll a,b;
	bool friend operator <(const stu &x,const stu &y){
		return x.a>y.a;
	}
}s[N];
int main()
{
	ll n;
	cin>>n;
	ll lmax=0,rmin=INF,width=0;
	for(ll i=1;i<=n;i++){
		cin>>l[i]>>r[i];
		if(l[i]>=lmax)	lmax=l[i];
		if(r[i]<=rmin)	rmin=r[i];
		width=max(width,r[i]-l[i]+1);
	}
	ll sum=max(rmin-lmax+1,0)+width;
	for(ll i=1;i<=n;i++){
		s[i].a=max(0,rmin-l[i]+1);
		s[i].b=max(0,r[i]-lmax+1);
	}
	sort(s+1,s+1+n);
	arr[n]=s[n].b;
	for(ll i=n-1;i>=1;i--){
		arr[i]=min(arr[i+1],s[i].b);
	}
	ll ans=0;
	for(ll i=1;i<=n-1;i++){
		ans=max(ans,s[i].a+arr[i+1]);	
	}
	cout<<max(ans,sum)<<endl;
	return 0;
 } 

Compiler output:
a.cc: In function 'int main()':
a.cc:26:19: error: no matching function for call to 'max(ll, int)'
   26 |         ll sum=max(rmin-lmax+1,0)+width;
      |                ~~~^~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 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:26:19: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   26 |         ll sum=max(rmin-lmax+1,0)+width;
      |                ~~~^~~~~~~~~~~~~~~
/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:26:19: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   26 |         ll sum=max(rmin-lmax+1,0)+width;
      |                ~~~^~~~~~~~~~~~~~~
a.cc:28:27: error: no matching function for call to 'max(int, ll)'
   28 |                 s[i].a=max(0,rmin-l[i]+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:28:27: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   28 |                 s[i].a=max(0,rmin-l[i]+1);
      |                        ~~~^~~~~~~~~~~~~~~
/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:28:27: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   28 |                 s[i].a=max(0,rmin-l[i]+1);
      |                        ~~~^~~~~~~~~~~~~~~
a.cc:29:27: error: no matching function for call to 'max(int, ll)'
   29 |                 s[i].b=max(0,r[i]-lmax+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:29:27: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   29 |                 s[i].b=max(0,r[i]-lmax+1);
      |                        ~~~^~~~~~~~~~~~~~~
/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:29:27: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   29 |                 s[i].b=max(0,r[i]-lmax+1);
      |                        ~~~^~~~~~~~~~~~~~~