Language: C++

#include <assert.h>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
 
using ll = long long;
using P = std::pair<char, ll>;
 
#define rep(i, a, b) for (ll(i) = (a); (i) < (b); (i)++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << "debug " << #i <<" "<<i<<std::endl;
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}

//非再帰累乗(mod付き)
ll pow_mod(ll a, ll b, ll mod=-1) {
  if ((a == 0)||(mod!=-1&&a%mod==0)) {
    return 0;
  }

  ll x = 1;

  while (b > 0) {
    if (b & 1) {
      x = (mod!=-1)?(x * a) % mod:x*a;
    }
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}
 
// const ll MOD = 998244353;
const ll MOD = 1e9 + 7;
 
int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);

  ll n;
  std::cin>>n;

  std::vector<ll> lsec(n),rsec(n);

  rep(i,0,n){
    std::cin>>lsec[i]>>rsec[i];
  }

  std::sort(all(rsec));
  std::sort(all(lsec),std::greater<ll>());

  ll ans=0;

  rep(r,0,(n+3)/2){
    rep(l,std::max(r-1,0),r+2){
      if(r>=0&&l>=0&&r+l<=n){
        ll val=0;
        rep(i,0,r)val-=2*rsec[i];
        rep(i,0,l)val+=2*lsec[i];
        chmax(ans,val);
      }
    }
  }

  std::cout<<ans;

  return 0;
}





Compiler output:
a.cc: In function 'int main()':
a.cc:85:19: error: no matching function for call to 'max(ll, int)'
   85 |     rep(l,std::max(r-1,0),r+2){
      |           ~~~~~~~~^~~~~~~
a.cc:24:36: note: in definition of macro 'rep'
   24 | #define rep(i, a, b) for (ll(i) = (a); (i) < (b); (i)++)
      |                                    ^
In file included from /usr/include/c++/14/algorithm:60,
                 from a.cc:3:
/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:85:19: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   85 |     rep(l,std::max(r-1,0),r+2){
      |           ~~~~~~~~^~~~~~~
a.cc:24:36: note: in definition of macro 'rep'
   24 | #define rep(i, a, b) for (ll(i) = (a); (i) < (b); (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
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:85:19: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   85 |     rep(l,std::max(r-1,0),r+2){
      |           ~~~~~~~~^~~~~~~
a.cc:24:36: note: in definition of macro 'rep'
   24 | #define rep(i, a, b) for (ll(i) = (a); (i) < (b); (i)++)
      |                                    ^