Language: C++

#include<bits/stdc++.h>
using namespace std;

/* FastIO by rsk0315 (last update: 2018/02/21 00:36) */

namespace FastIn {
  static constexpr size_t BUF_SIZE=1<<17, INT_LEN=24, FLT_LEN=400;
  static char buf[BUF_SIZE|1]={}, *pos=buf, *endbuf=nullptr;
  FILE *fin;

  inline bool rebuffer() {
    // returns true <=> there is at least one unread character
    size_t rest=endbuf-pos;
    if (buf+rest > pos) {
      // buf[:pos] and buf[-pos:] are overlapping, which std::memcpy()
      // causes undefined behavior.
      return true;
    }

    std::memcpy(buf, pos, rest); 
    pos = buf;
    size_t len=std::fread(pos+rest, 1, BUF_SIZE-rest, fin);
    *(endbuf = buf + (rest+len)) = 0;

    return *pos;
  }

  inline bool scan(char &in) {
    if ((in = *pos)) {
      ++pos;
      return true;
    }

    return rebuffer() && (in = *pos++);
  }

  inline bool scan(char *in) {
    if ((*in = *pos) == 0) {
      if (rebuffer() && (*in = *pos) == 0) {
        return false;
      }
    }
    ++in;
    while (true) {
      if ((*in = *pos++) == 0) {
        if (rebuffer() && (*in = *pos++) == 0) {
          return true;
        }
      }
      ++in;
    }
  }

  inline bool scan(double &in) {
    if (pos + FLT_LEN >= endbuf && !rebuffer()) {
      in = 0.0;
      return false;
    }

    char *tmp;
    in = std::strtod(pos, &tmp);
    pos = tmp;
    return true;
  }

  template <class Int>
  inline bool scan(Int &in) {
    in = 0;

    // assume that no redundant whitespace appears
    if (pos + INT_LEN >= endbuf && !rebuffer()) {
      return false;
    }

    if (std::is_signed<Int>::value) {
      if (*pos == '-') {
        in = ~*++pos+'1';
        while (*++pos >= '0') {
          in = in*10 + ~*pos+'1';
        }
        ++pos;
        return true;
      }
    }

    // assume that numbers are separated by the character whose value is
    // less than '0' (e.g. whitespaces, newlines)
    do {
      in = in*10 + *pos-'0';
    } while (*++pos >= '0');
    ++pos;
    return true;
  }

  inline bool eat() {
    if (*pos > ' ') {
      return true;
    }

    do {
      if (*pos == 0 && !rebuffer()) {
        return false;
      }
    } while (*++pos <= ' ');

    return true;
  }

  inline bool eat(char ch) {
    if (*pos == ch) {
      return true;
    }

    do {
      if (*pos == 0 && !rebuffer()) {
        return false;
      }
    } while (*++pos != ch);

    return true;
  }

  class Scanner {
    bool rebuffer() {
      return FastIn::rebuffer();
    }

  public:
    Scanner(FILE *fin=stdin) {
      FastIn::fin = fin;
      endbuf = pos + std::fread(buf, 1, BUF_SIZE, fin);
    }

    template <class T>
    inline bool scan(T &in) {
      return FastIn::scan(in);
    }

    template <class First, class... Rest>
    inline bool scan(First &in, Rest &...ins) {
      return scan(in) && scan(ins...);
    }
  };
}

int main(){
    FastIn::Scanner in;
    long N;
    in.scan(N);
    vector<long> A(N);
    for(auto& i : A)in.scan(i);
    nth_element(A.begin(), A.end() - 1, A.end());
    long m = A[N - 1];
    nth_element(A.begin(), A.begin(), A.end() - 1, [&m](auto a){return a * (a - m) > b * (b - m);});
    cout << A[N - 1] << " " << A[0] << endl;
}

Compiler output:
a.cc: In lambda function:
a.cc:154:86: error: 'b' was not declared in this scope
  154 |     nth_element(A.begin(), A.begin(), A.end() - 1, [&m](auto a){return a * (a - m) > b * (b - m);});
      |                                                                                      ^
In file included from /usr/include/c++/14/bits/stl_algobase.h:71,
                 from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'constexpr bool __gnu_cxx::__ops::_Iter_comp_iter<_Compare>::operator()(_Iterator1, _Iterator2) [with _Iterator1 = __gnu_cxx::__normal_iterator<long int*, std::vector<long int> >; _Iterator2 = __gnu_cxx::__normal_iterator<long int*, std::vector<long int> >; _Compare = main()::<lambda(auto:28)>]':
/usr/include/c++/14/bits/stl_algo.h:1595:12:   required from 'void std::__heap_select(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<long int*, vector<long int> >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<main()::<lambda(auto:28)> >]'
 1595 |         if (__comp(__i, __first))
      |             ~~~~~~^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:1923:26:   required from 'void std::__introselect(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Size, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<long int*, vector<long int> >; _Size = long int; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<main()::<lambda(auto:28)> >]'
 1923 |               std::__heap_select(__first, __nth + 1, __last, __comp);
      |               ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:4740:25:   required from 'void std::nth_element(_RAIter, _RAIter, _RAIter, _Compare) [with _RAIter = __gnu_cxx::__normal_iterator<long int*, vector<long int> >; _Compare = main()::<lambda(auto:28)>]'
 4740 |       std::__introselect(__first, __nth, __last,
      |       ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
 4741 |                          std::__lg(__last - __first) * 2,
      |                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 4742 |                          __gnu_cxx::__ops::__iter_comp_iter(__comp));
      |                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:154:16:   required from here
  154 |     nth_element(A.begin(), A.begin(), A.end() - 1, [&m](auto a){return a * (a - m) > b * (b - m);});
      |     ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/predefined_ops.h:158:30: error: no match for call to '(main()::<lambda(auto:28)>) (long int&, long int&)'
  158 |         { return bool(_M_comp(*__it1, *__it2)); }
      |                       ~~~~~~~^~~~~~~~~~~~~~~~
a.cc:154:52: note: candidate: 'template<class auto:28> main()::<lambda(auto:28)>'
  154 |     nth_element(A.begin(), A.begin(), A.end() - 1, [&m](auto a){return a * (a - m) > b * (b - m);});
      |                                                    ^
a.cc:154:52: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Val_comp_iter<_Compare>::operator()(_Value&, _Iterator) [with _Value = long int; _Iterator = __gnu_cxx::__normal_iterator<long int*, std::vector<long int> >; _Compare = main()::<lambda(auto:28)>]':
/usr/include/c++/14/bits/stl_algo.h:1757:20:   required from 'void std::__unguarded_linear_insert(_RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<long int*, vector<long int> >; _Compare = __gnu_cxx::__ops::_Val_comp_iter<main()::<lambda(auto:28)> >]'
 1757 |       while (__comp(__val, __next))
      |              ~~~~~~^~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:1785:36:   required from 'void std::__insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<long int*, vector<long int> >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<main()::<lambda(auto:28)> >]'
 1785 |             std::__unguarded_linear_insert(__i,
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
 1786 |                                 __gnu_cxx::__ops::__val_comp_iter(__comp));
      |                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:1936:28:   required from 'void std::__introselect(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Size, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<long int*, vector<long int> >; _Size = long int; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<main()::<lambda(auto:28)> >]'
 1936 |       std::__insertion_sort(__first, __last, __comp);
      |       ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:4740:25:   required from 'void std::nth_element(_RAIter, _RAIter, _RAIter, _Compare) [with _RAIter = __gnu_cxx::__normal_iterator<long int*, vector<long int> >; _Compare = main()::<lambda(auto:28)>]'
 4740 |       std::__introselect(__first, __nth, __last,
      |       ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
 4741 |                          std::__lg(__last - __first) * 2,
      |                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 4742 |                          __gnu_cxx::__ops::__iter_comp_iter(__comp));
      |                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:154:16:   required from here
  154 |     nth_element(A.begin(), A.begin(), A.end() - 1, [&m](auto a){return a * (a - m) > b * (b - m);});
      |     ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/predefined_ops.h:240:30: error: no match for call to '(main()::<lambda(auto:28)>) (long int&, long int&)'
  240 |         { return bool(_M_comp(__val, *__it)); }
      |                       ~~~~~~~^~~~~~~~~~~~~~
a.cc:154:52: note: candidate: 'template<class auto:28> main()::<lambda(auto:28)>'
  154 |     nth_element(A.begin(), A.begin(), A.end() - 1, [&m](auto a){return a * (a - m) > b * (b - m);});
      |                                                    ^
a.cc:154:52: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Iter_comp_val<_Compare>::operator()(_Iterator, _Value&) [with _Iterator = __gnu_cxx::__normal_iterator<long int*, std::vector<long int> >; _Value = long int; _Compare = main()::<lambda(auto:28)>]':
/usr/include/c++/14/bits/stl_heap.h:140:48:   required from 'void std::__push_heap(_RandomAccessIterator, _Distance, _Distance, _Tp, _Compare&) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<long int*, vector<long int> >; _Distance = long int; _Tp = long int; _Compare = __gnu_cxx::__ops::_Iter_comp_val<main()::<lambda(auto:28)> >]'
  140 |       while (__holeIndex > __topIndex && __comp(__first + __parent, __value))
      |                                          ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_heap.h:247:23:   required from 'void std::__adjust_heap(_RandomAccessIterator, _Distance, _Distance, _Tp, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<long int*, vector<long int> >; _Distance = long int; _Tp = long int; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<main()::<lambda(auto:28)> >]'
  247 |       std::__push_heap(__first, __holeIndex, __topIndex,
      |       ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  248 |                        _GLIBCXX_MOVE(__value), __cmp);
      |                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_heap.h:356:22:   required from 'void std::__make_heap(_RandomAccessIterator, _RandomAccessIterator, _Compare&) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<long int*, vector<long int> >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<main()::<lambda(auto:28)> >]'
  356 |           std::__adjust_heap(__first, __parent, __len, _GLIBCXX_MOVE(__value),
      |           ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  357 |                              __comp);
      |                              ~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:1593:23:   required from 'void std::__heap_select(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<long int*, vector<long int> >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<main()::<lambda(auto:28)> >]'
 1593 |       std::__make_heap(__first, __middle, __comp);
      |       ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:1923:26:   required from 'void std::__introselect(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Size, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<long int*, vector<long int> >; _Size = long int; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<main()::<lambda(auto:28)> >]'
 1923 |               std::__heap_select(__first, __nth + 1, __last, __comp);
      |               ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:4740:25:   required from 'void std::nth_element(_RAIter, _RAIter, _RAIter, _Compare) [with _RAIter = __gnu_cxx::__normal_iterator<long int*, vector<long int> >; _Compare = main()::<lambda(auto:28)>]'
 4740 |       std::__introselect(__first, __nth, __last,
      |       ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
 4741 |                          std::__lg(__last - __first) * 2,
      |                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 4742 |                          __gnu_cxx::__ops::__iter_comp_iter(__comp));
      |                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:154:16:   required from here
  154 |     nth_element(A.begin(), A.begin(), A.end() - 1, [&m](auto a){return a * (a - m) > b * (b - m);});
      |     ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/