Language: C++

#include <bits/stdc++.h>

#define long long long int

using namespace std;

// @author: pashka

int main() {
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    vector<pair<long, long>> a(2 * n);
    for (int i = 0; i < n; i++) {
        cin >> a[i].first >> a[i].second;
        a[i + n].first = -a[i].first;
        a[i + n].second = -a[i].second;
    }

    long y0 = 0;
    long x0 = 0;
    for (int i = 0; i < n; i++) {
        long x = a[i].first;
        long y = a[i].second;
        if (y > 0 || (y == 0 && x < 0)) {
            x0 += x;
            y0 += y;
        }
    }

    sort(a.begin(), a.end(), [](auto &q, auto &w) -> bool {
        if (q == w)
            return false;
        if (q == make_pair(0.0, 0.0))
            return true;
        if (w == make_pair(0.0, 0.0))
            return false;
        bool side1 = (q.second > 0 || q.second == 0 && q.first < 0);
        bool side2 = (w.second > 0 || w.second == 0 && w.first < 0);

        if (side1 != side2) {
            return side1 < side2;
        }

        long vp = q.first * w.second - q.second * w.first;
        return vp > 0;
    });

    double res = 0;

    for (int i = 0; i < 2 * n; i++) {
        long x = a[i].first;
        long y = a[i].second;
        x0 += x;
        y0 += y;
        res = max(res, hypot(x0, y0));
    }
    cout << setprecision(20) << res;

    return 0;
}

Compiler output:
a.cc: In instantiation of 'main()::<lambda(auto:28&, auto:29&)> [with auto:28 = std::pair<long long int, long long int>; auto:29 = std::pair<long long int, long long int>]':
/usr/include/c++/14/bits/predefined_ops.h:158:30:   required from 'constexpr bool __gnu_cxx::__ops::_Iter_comp_iter<_Compare>::operator()(_Iterator1, _Iterator2) [with _Iterator1 = __gnu_cxx::__normal_iterator<std::pair<long long int, long long int>*, std::vector<std::pair<long long int, long long int> > >; _Iterator2 = __gnu_cxx::__normal_iterator<std::pair<long long int, long long int>*, std::vector<std::pair<long long int, long long int> > >; _Compare = main()::<lambda(auto:28&, auto:29&)>]'
  158 |         { return bool(_M_comp(*__it1, *__it2)); }
      |                       ~~~~~~~^~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:1777:14:   required from 'void std::__insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<pair<long long int, long long int>*, vector<pair<long long int, long long int> > >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<main()::<lambda(auto:28&, auto:29&)> >]'
 1777 |           if (__comp(__i, __first))
      |               ~~~~~~^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:1817:25:   required from 'void std::__final_insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<pair<long long int, long long int>*, vector<pair<long long int, long long int> > >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<main()::<lambda(auto:28&, auto:29&)> >]'
 1817 |           std::__insertion_sort(__first, __first + int(_S_threshold), __comp);
      |           ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:1908:31:   required from 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<pair<long long int, long long int>*, vector<pair<long long int, long long int> > >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<main()::<lambda(auto:28&, auto:29&)> >]'
 1908 |           std::__final_insertion_sort(__first, __last, __comp);
      |           ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:4805:18:   required from 'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = __gnu_cxx::__normal_iterator<pair<long long int, long long int>*, vector<pair<long long int, long long int> > >; _Compare = main()::<lambda(auto:28&, auto:29&)>]'
 4805 |       std::__sort(__first, __last, __gnu_cxx::__ops::__iter_comp_iter(__comp));
      |       ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:32:9:   required from here
   32 |     sort(a.begin(), a.end(), [](auto &q, auto &w) -> bool {
      |     ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   33 |         if (q == w)
      |         ~~~~~~~~~~~
   34 |             return false;
      |             ~~~~~~~~~~~~~
   35 |         if (q == make_pair(0.0, 0.0))
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   36 |             return true;
      |             ~~~~~~~~~~~~
   37 |         if (w == make_pair(0.0, 0.0))
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   38 |             return false;
      |             ~~~~~~~~~~~~~
   39 |         bool side1 = (q.second > 0 || q.second == 0 && q.first < 0);
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   40 |         bool side2 = (w.second > 0 || w.second == 0 && w.first < 0);
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   41 | 
      |          
   42 |         if (side1 != side2) {
      |         ~~~~~~~~~~~~~~~~~~~~~
   43 |             return side1 < side2;
      |             ~~~~~~~~~~~~~~~~~~~~~
   44 |         }
      |         ~
   45 | 
      |          
   46 |         long vp = q.first * w.second - q.second * w.first;
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   47 |         return vp > 0;
      |         ~~~~~~~~~~~~~~
   48 |     });
      |     ~~   
a.cc:35:15: error: no match for 'operator==' (operand types are 'std::pair<long long int, long long int>' and 'std::pair<double, double>')
   35 |         if (q == make_pair(0.0, 0.0))
      |             ~~^~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/regex:68,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:181,
                 from a.cc:1:
/usr/include/c++/14/bits/regex.h:1103:5: note: candidate: 'template<class _BiIter> bool std::__cxx11::operator==(const sub_match<_BiIter>&, const sub_match<_BiIter>&)'
 1103 |     operator==(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs)
      |     ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1103:5: note:   template argument deduction/substitution failed:
a.cc:35:15: note:   'std::pair<long long int, long long int>' is not derived from 'const std::__cxx11::sub_match<_BiIter>'
   35 |         if (q == make_pair(0.0, 0.0))
      |             ~~^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/regex.h:1199:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator==(__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&, const sub_match<_BiIter>&)'
 1199 |     operator==(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1199:5: note:   template argument deduction/substitution failed:
a.cc:35:15: note:   'std::pair<long long int, long long int>' is not derived from 'std::__cxx11::__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>'
   35 |         if (q == make_pair(0.0, 0.0))
      |             ~~^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/regex.h:1274:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator==(const sub_match<_BiIter>&, __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&)'
 1274 |     operator==(const sub_match<_Bi_iter>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1274:5: note:   template argument deduction/substitution failed:
a.cc:35:15: note:   'std::pair<long long int, long long int>' is not derived from 'const std::__cxx11::sub_match<_BiIter>'
   35 |         if (q == make_pair(0.0, 0.0))
      |             ~~^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/regex.h:1366:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator==(const typename std::iterator_traits<_Iter>::value_type*, const sub_match<_BiIter>&)'
 1366 |     operator==(typename iterator_traits<_Bi_iter>::value_type const* __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1366:5: note:   template argument deduction/substitution failed:
a.cc:35:15: note:   'std::pair<double, double>' is not derived from 'const std::__cxx11::sub_match<_BiIter>'
   35 |         if (q == make_pair(0.0, 0.0))
      |             ~~^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/regex.h:1441:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator==(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type*)'
 1441 |     operator==(const sub_match<_Bi_iter>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1441:5: note:   template argument deduction/substitution failed:
a.cc:35:15: note:   'std::pair<long long int, long long int>' is not derived from 'const std::__cxx11::sub_match<_BiIter>'
   35 |         if (q == make_pair(0.0, 0.0))
      |             ~~^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/regex.h:1534:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator==(const typename std::iterator_traits<_Iter>::value_type&, const sub_match<_BiIter>&)'
 1534 |     operator==(typename iterator_traits<_Bi_iter>::value_type const& __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1534:5: note:   template argument deduction/substitution failed:
a.cc:35:15: note:   'std::pair<double, double>' is not derived from 'const std::__cxx11::sub_match<_BiIter>'
   35 |         if (q == make_pair(0.0, 0.0))
      |             ~~^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/regex.h:1613:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator==(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type&)'
 1613 |     operator==(const sub_match<_Bi_iter>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1613:5: note:   template argument deduction/substitution failed:
a.cc:35:15: note:   'std::pair<long long int, long long int>' is not derived from 'const std::__cxx11::sub_match<_BiIter>'
   35 |         if (q == make_pair(0.0, 0.0))
      |             ~~^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/regex.h:2186:5: note: candidate: 'template<class _Bi_iter, class _Alloc> bool std::__cxx11::operator==(const match_results<_BiIter, _Alloc>&, const match_results<_BiIter, _Alloc>&)'
 2186 |     operator==(const match_results<_Bi_iter, _Alloc>& __m1,
      |     ^~~~~~~~
/usr/include/c++/14/bits/regex.h:2186:5: note:   template argument deduction/substitution failed:
a.cc:35:15: note:   'std::pair<long long int, long long int>' is not derived from 'const std::__cxx11::match_results<_BiIter, _Alloc>'
   35 |         if (q == make_pair(0.0, 0.0))
      |             ~~^~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
                 from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51:
/usr/include/c++/14/bits/stl_pair.h:1033:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator==(const pair<_T1, _T2>&, const pair<_T1, _T2>&)'
 1033 |     operator==(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:1033:5: note:   template argument deduction/substitution failed:
a.cc:35:15: note:   deduced conflicting types for parameter '_T1' ('long long int' and 'double')
   35 |         if (q == make_pair(0.0, 0.0))
      |             ~~^~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c+