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;
  bool CAN=true;
  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;
  CAN=true;
  for(int i=0; i<A.size(); ++i){
    if(A[i].first>=0){
      for(int j=i; j<A.size(); ++j){
        if(A[j].second<=0){
          if(X*X+Y*Y<(X+A[j].first)*(X+A[j].first)+(Y+A[j].second)*(Y+A[j].second){
            CAN=false;
            i=j;
          }
        }
      }
      if(CAN) break;
    }
    X+=A[i].first;
    Y+=A[i].second;
    ans=max(ans,X*X+Y*Y);
  }
  
  REVERSE(A);
  X=0;
  Y=0;
  CAN=true;
  for(int i=0; i<A.size(); ++i){
    if(A[i].first<=0){
      for(int j=i; j<A.size(); ++j){
        if(A[j].second>=0){
          if(X*X+Y*Y<(X+A[j].first)*(X+A[j].first)+(Y+A[j].second)*(Y+A[j].second){
            CAN=false;
            i=j;
          }
        }
      }
      if(CAN) break;
    }
    X+=A[i].first;
    Y+=A[i].second;
    ans=max(ans,X*X+Y*Y);
  }
  
  SORT(B);
  X=0;
  Y=0;
  CAN=true;
  for(int i=0; i<B.size(); ++i){
    if(B[i].first>=0){
      for(int j=i; j<B.size(); ++j){
        if(B[j].second<=0){
          if(X*X+Y*Y<(X+B[j].first)*(X+B[j].first)+(Y+B[j].second)*(Y+B[j].second){
            CAN=false;
            i=j;
          }
        }
      }
      if(CAN) break;
    }
    X+=B[i].first;
    Y+=B[i].second;
    ans=max(ans,X*X+Y*Y);
  }
  
  REVERSE(B);
  X=0;
  Y=0;
  CAN=true;
  for(int i=0; i<B.size(); ++i){
    if(B[i].first<=0){
      for(int j=i; j<B.size(); ++j){
        if(B[j].second>=0){
          if(X*X+Y*Y<(X+B[j].first)*(X+B[j].first)+(Y+B[j].second)*(Y+B[j].second){
            CAN=false;
            i=j;
          }
        }
      }
      if(CAN) 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:42:83: error: expected ')' before '{' token
   42 |           if(X*X+Y*Y<(X+A[j].first)*(X+A[j].first)+(Y+A[j].second)*(Y+A[j].second){
      |             ~                                                                     ^
      |                                                                                   )
a.cc:46:9: error: expected primary-expression before '}' token
   46 |         }
      |         ^
a.cc:63:83: error: expected ')' before '{' token
   63 |           if(X*X+Y*Y<(X+A[j].first)*(X+A[j].first)+(Y+A[j].second)*(Y+A[j].second){
      |             ~                                                                     ^
      |                                                                                   )
a.cc:67:9: error: expected primary-expression before '}' token
   67 |         }
      |         ^
a.cc:84:83: error: expected ')' before '{' token
   84 |           if(X*X+Y*Y<(X+B[j].first)*(X+B[j].first)+(Y+B[j].second)*(Y+B[j].second){
      |             ~                                                                     ^
      |                                                                                   )
a.cc:88:9: error: expected primary-expression before '}' token
   88 |         }
      |         ^
a.cc:105:83: error: expected ')' before '{' token
  105 |           if(X*X+Y*Y<(X+B[j].first)*(X+B[j].first)+(Y+B[j].second)*(Y+B[j].second){
      |             ~                                                                     ^
      |                                                                                   )
a.cc:109:9: error: expected primary-expression before '}' token
  109 |         }
      |         ^