Language: C++

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#define ll long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,0,n)
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
using namespace std;

int main(){
  int N,X=0,Y=0;
  double ans=0;
  cin>>N;
  vector<pair<int,int> A,B,C;
  REP(i,N){
    int a,b;
    cin>>a>>b;
    A.push_back(make_pair(a,b));
    B.push_back(make_pair(b,a));
    C.push_back(make_pair(a,b));
  }
  
  SORT(A);
  X=0;
  Y=0;
  for(int i=0; i<A.size(); ++i){
    if(A[i].first>=0){
      if(A[i].second>0) break;
    }
    X+=A[i].first;
    Y+=A[i].second;
    ans=max(ans,X*X+Y*Y);
  }
  
  REVERSE(A);
  X=0;
  Y=0;
  for(int i=0; i<A.size(); ++i){
    if(A[i].first<=0){
      if(A[i].second<0) break;
    }
    X+=A[i].first;
    Y+=A[i].second;
    ans=max(ans,X*X+Y*Y);
  }
  
  SORT(B);
  X=0;
  Y=0;
  for(int i=0; i<B.size(); ++i){
    if(B[i].first>=0){
      if(B[i].second>0) break;
    }
    X+=B[i].first;
    Y+=B[i].second;
    ans=max(ans,X*X+Y*Y);
  }
  
  REVERSE(B);
  X=0;
  Y=0;
  for(int i=0; i<B.size(); ++i){
    if(B[i].first<=0){
      if(B[i].second<0) break;
    }
    X+=B[i].first;
    Y+=B[i].second;
    ans=max(ans,X*X+Y*Y);
  }
  
  cout<<setprecision(10)<<sqrt(ans)<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:23:28: error: template argument 1 is invalid
   23 |   vector<pair<int,int> A,B,C;
      |                            ^
a.cc:23:28: error: template argument 2 is invalid
a.cc:27:5: error: 'A' was not declared in this scope
   27 |     A.push_back(make_pair(a,b));
      |     ^
a.cc:28:5: error: 'B' was not declared in this scope
   28 |     B.push_back(make_pair(b,a));
      |     ^
a.cc:29:5: error: 'C' was not declared in this scope
   29 |     C.push_back(make_pair(a,b));
      |     ^
a.cc:32:8: error: 'A' was not declared in this scope
   32 |   SORT(A);
      |        ^
a.cc:13:23: note: in definition of macro 'SORT'
   13 | #define SORT(V) sort((V).begin(),(V).end())
      |                       ^
a.cc:41:12: error: no matching function for call to 'max(double&, int)'
   41 |     ans=max(ans,X*X+Y*Y);
      |         ~~~^~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 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:41:12: note:   deduced conflicting types for parameter 'const _Tp' ('double' and 'int')
   41 |     ans=max(ans,X*X+Y*Y);
      |         ~~~^~~~~~~~~~~~~
/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:4:
/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:41:12: note:   mismatched types 'std::initializer_list<_Tp>' and 'double'
   41 |     ans=max(ans,X*X+Y*Y);
      |         ~~~^~~~~~~~~~~~~
a.cc:53:12: error: no matching function for call to 'max(double&, int)'
   53 |     ans=max(ans,X*X+Y*Y);
      |         ~~~^~~~~~~~~~~~~
/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:53:12: note:   deduced conflicting types for parameter 'const _Tp' ('double' and 'int')
   53 |     ans=max(ans,X*X+Y*Y);
      |         ~~~^~~~~~~~~~~~~
/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:53:12: note:   mismatched types 'std::initializer_list<_Tp>' and 'double'
   53 |     ans=max(ans,X*X+Y*Y);
      |         ~~~^~~~~~~~~~~~~
a.cc:56:8: error: 'B' was not declared in this scope
   56 |   SORT(B);
      |        ^
a.cc:13:23: note: in definition of macro 'SORT'
   13 | #define SORT(V) sort((V).begin(),(V).end())
      |                       ^
a.cc:65:12: error: no matching function for call to 'max(double&, int)'
   65 |     ans=max(ans,X*X+Y*Y);
      |         ~~~^~~~~~~~~~~~~
/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:65:12: note:   deduced conflicting types for parameter 'const _Tp' ('double' and 'int')
   65 |     ans=max(ans,X*X+Y*Y);
      |         ~~~^~~~~~~~~~~~~
/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:65:12: note:   mismatched types 'std::initializer_list<_Tp>' and 'double'
   65 |     ans=max(ans,X*X+Y*Y);
      |         ~~~^~~~~~~~~~~~~
a.cc:77:12: error: no matching function for call to 'max(double&, int)'
   77 |     ans=max(ans,X*X+Y*Y);
      |         ~~~^~~~~~~~~~~~~
/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:77:12: note:   deduced conflicting types for parameter 'const _Tp' ('double' and 'int')
   77 |     ans=max(ans,X*X+Y*Y);
      |         ~~~^~~~~~~~~~~~~
/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:77:12: note:   mismatched types 'std::initializer_list<_Tp>' and 'double'
   77 |     ans=max(ans,X*X+Y*Y);
      |         ~~~^~~~~~~~~~~~~