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;
  double 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(-1*a,b));
    D.push_back(make_pair(a,-1*b));
    E.push_back(make_pair(-1*a,-1*b));
    F.push_back(make_pair(-1*b,a));
    G.push_back(make_pair(b,-1*a));
    H.push_back(make_pair(-1*b,-1*a));
  }
  
  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){
      for(int j=i; j<A.size(); ++j){
        if(X*X+Y*Y) 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);
  }
  
  
  
  SORT(C);
  X=0;
  Y=0;
  for(int i=0; i<C.size(); ++i){
    if(C[i].first>=0){
      if(C[i].second>0) break;
    }
    X+=C[i].first;
    Y+=C[i].second;
    ans=max(ans,X*X+Y*Y);
  }
  
  REVERSE(C);
  X=0;
  Y=0;
  for(int i=0; i<C.size(); ++i){
    if(C[i].first<=0){
      for(int j=i; j<C.size(); ++j){
        if(X*X+Y*Y) break;
      }
    }
    X+=C[i].first;
    Y+=C[i].second;
    ans=max(ans,X*X+Y*Y);
  }
  
  
  
  SORT(D);
  X=0;
  Y=0;
  for(int i=0; i<D.size(); ++i){
    if(D[i].first>=0){
      if(D[i].second>0) break;
    }
    X+=D[i].first;
    Y+=D[i].second;
    ans=max(ans,X*X+Y*Y);
  }
  
  REVERSE(D);
  X=0;
  Y=0;
  for(int i=0; i<D.size(); ++i){
    if(D[i].first<=0){
      for(int j=i; j<D.size(); ++j){
        if(X*X+Y*Y) break;
      }
    }
    X+=D[i].first;
    Y+=D[i].second;
    ans=max(ans,X*X+Y*Y);
  }
  
  
  
  SORT(E);
  X=0;
  Y=0;
  for(int i=0; i<E.size(); ++i){
    if(E[i].first>=0){
      if(E[i].second>0) break;
    }
    X+=E[i].first;
    Y+=E[i].second;
    ans=max(ans,X*X+Y*Y);
  }
  
  REVERSE(E);
  X=0;
  Y=0;
  for(int i=0; i<E.size(); ++i){
    if(E[i].first<=0){
      for(int j=i; j<E.size(); ++j){
        if(X*X+Y*Y) break;
      }
    }
    X+=E[i].first;
    Y+=E[i].second;
    ans=max(ans,X*X+Y*Y);
  }
  
  
  
  
  SORT(F);
  X=0;
  Y=0;
  for(int i=0; i<F.size(); ++i){
    if(F[i].first>=0){
      if(F[i].second>0) break;
    }
    X+=F[i].first;
    Y+=F[i].second;
    ans=max(ans,X*X+Y*Y);
  }
  
  REVERSE(F);
  X=0;
  Y=0;
  for(int i=0; i<F.size(); ++i){
    if(F[i].first<=0){
      for(int j=i; j<F.size(); ++j){
        if(X*X+Y*Y) break;
      }
    }
    X+=F[i].first;
    Y+=F[i].second;
    ans=max(ans,X*X+Y*Y);
  }
  
  
  
  SORT(G);
  X=0;
  Y=0;
  for(int i=0; i<G.size(); ++i){
    if(G[i].first>=0){
      if(G[i].second>0) break;
    }
    X+=G[i].first;
    Y+=G[i].second;
    ans=max(ans,X*X+Y*Y);
  }
  
  REVERSE(G);
  X=0;
  Y=0;
  for(int i=0; i<G.size(); ++i){
    if(G[i].first<=0){
      for(int j=i; j<G.size(); ++j){
        if(X*X+Y*Y) break;
      }
    }
    X+=G[i].first;
    Y+=G[i].second;
    ans=max(ans,X*X+Y*Y);
  }
  
  
  
  SORT(H);
  X=0;
  Y=0;
  for(int i=0; i<H.size(); ++i){
    if(H[i].first>=0){
      if(H[i].second>0) break;
    }
    X+=H[i].first;
    Y+=H[i].second;
    ans=max(ans,X*X+Y*Y);
  }
  
  REVERSE(H);
  X=0;
  Y=0;
  for(int i=0; i<H.size(); ++i){
    if(H[i].first<=0){
      for(int j=i; j<H.size(); ++j){
        if(X*X+Y*Y) break;
      }
    }
    X+=H[i].first;
    Y+=H[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:31:5: error: 'D' was not declared in this scope
   31 |     D.push_back(make_pair(a,-1*b));
      |     ^
a.cc:32:5: error: 'E' was not declared in this scope
   32 |     E.push_back(make_pair(-1*a,-1*b));
      |     ^
a.cc:33:5: error: 'F' was not declared in this scope
   33 |     F.push_back(make_pair(-1*b,a));
      |     ^
a.cc:34:5: error: 'G' was not declared in this scope
   34 |     G.push_back(make_pair(b,-1*a));
      |     ^
a.cc:35:5: error: 'H' was not declared in this scope
   35 |     H.push_back(make_pair(-1*b,-1*a));
      |     ^
a.cc:120:8: error: 'D' was not declared in this scope
  120 |   SORT(D);
      |        ^
a.cc:13:23: note: in definition of macro 'SORT'
   13 | #define SORT(V) sort((V).begin(),(V).end())
      |                       ^
a.cc:148:8: error: 'E' was not declared in this scope
  148 |   SORT(E);
      |        ^
a.cc:13:23: note: in definition of macro 'SORT'
   13 | #define SORT(V) sort((V).begin(),(V).end())
      |                       ^
a.cc:177:8: error: 'F' was not declared in this scope
  177 |   SORT(F);
      |        ^
a.cc:13:23: note: in definition of macro 'SORT'
   13 | #define SORT(V) sort((V).begin(),(V).end())
      |                       ^
a.cc:205:8: error: 'G' was not declared in this scope
  205 |   SORT(G);
      |        ^
a.cc:13:23: note: in definition of macro 'SORT'
   13 | #define SORT(V) sort((V).begin(),(V).end())
      |                       ^
a.cc:233:8: error: 'H' was not declared in this scope
  233 |   SORT(H);
      |        ^
a.cc:13:23: note: in definition of macro 'SORT'
   13 | #define SORT(V) sort((V).begin(),(V).end())
      |                       ^