Language: C++

#include<bits/stdc++.h>
using namespace std;
int main () {
	long long n;
	cin >> n;
	vector<pair<long long, long long>>fi,se;
	long long l[n+1], r[n+1];
	for (int i = 1; i <= n; i++) {
		cin >> l[i] >> r[i];
		fi.push_back({l[i], r[i]});
		se.push_back({r[i], l[i]});
	}
	sort(fi.rbegin(), fi.rend());
	sort(se.rbegin(), se.rend());
	long long var11 = fi[0].first, var12 = fi[0].second, var21 = se[0].first, var22 = se[0].second;
	long long var31 = fi[1].first, var32 = fi[1].second, var21 = se[1].first, var22 = se[1].second;
	long long mx = -1;
//	cout << var11 << ' ' << var12 << '\n';
//	cout << var21 << ' ' << var22 << '\n';
	for (int i = 1; i <= n; i++) {
		mx = max({mx, abs(var11 - l[i]) + abs(var12 - r[i]), abs(var21 - r[i]) + abs(var22 - l[i]), abs(var31 - l[i]) + abs(var32 - r[i]), abs(var41 - r[i]) + abs(var42 - l[i])});
	} cout << mx;
}
/*
4
15 12
16 14
21 31
41 20

15 12
41 20
26 + 8
*/

Compiler output:
a.cc: In function 'int main()':
a.cc:16:62: error: redeclaration of 'long long int var21'
   16 |         long long var31 = fi[1].first, var32 = fi[1].second, var21 = se[1].first, var22 = se[1].second;
      |                                                              ^~~~~
a.cc:15:62: note: 'long long int var21' previously declared here
   15 |         long long var11 = fi[0].first, var12 = fi[0].second, var21 = se[0].first, var22 = se[0].second;
      |                                                              ^~~~~
a.cc:16:83: error: redeclaration of 'long long int var22'
   16 |         long long var31 = fi[1].first, var32 = fi[1].second, var21 = se[1].first, var22 = se[1].second;
      |                                                                                   ^~~~~
a.cc:15:83: note: 'long long int var22' previously declared here
   15 |         long long var11 = fi[0].first, var12 = fi[0].second, var21 = se[0].first, var22 = se[0].second;
      |                                                                                   ^~~~~
a.cc:21:152: error: 'var41' was not declared in this scope; did you mean 'var31'?
   21 |                 mx = max({mx, abs(var11 - l[i]) + abs(var12 - r[i]), abs(var21 - r[i]) + abs(var22 - l[i]), abs(var31 - l[i]) + abs(var32 - r[i]), abs(var41 - r[i]) + abs(var42 - l[i])});
      |                                                                                                                                                        ^~~~~
      |                                                                                                                                                        var31
a.cc:21:172: error: 'var42' was not declared in this scope; did you mean 'var32'?
   21 |                 mx = max({mx, abs(var11 - l[i]) + abs(var12 - r[i]), abs(var21 - r[i]) + abs(var22 - l[i]), abs(var31 - l[i]) + abs(var32 - r[i]), abs(var41 - r[i]) + abs(var42 - l[i])});
      |                                                                                                                                                                            ^~~~~
      |                                                                                                                                                                            var32
a.cc:21:25: error: no matching function for call to 'max(<brace-enclosed initializer list>)'
   21 |                 mx = max({mx, abs(var11 - l[i]) + abs(var12 - r[i]), abs(var21 - r[i]) + abs(var22 - l[i]), abs(var31 - l[i]) + abs(var32 - r[i]), abs(var41 - r[i]) + abs(var42 - l[i])});
      |                      ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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:   candidate expects 2 arguments, 1 provided
/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, 1 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:   template argument deduction/substitution failed:
/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:   candidate expects 2 arguments, 1 provided