Language: C++

#include <iostream>
#include <vector>
#include <bits/stdc++.h>
using namespace std;
int main()
{
  long long N, x = 0, temp;
 cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  cin >> N;
  vector<pair<long long, int>> v;
  for (long long i = 0; i <N; ++i)
  {
    cin >>temp;
    v.emplace_back(make_pair(temp,i));
  }
  sort(v.rbegin(), v.rend());
  long long f = 0, s = 1, c = 0;
  vector<long long> bad;
  for (; c <N/2; ++c)
    if (abs(v[f].second - v[s].second) != 1)
    {
      int f = 0;
      for (long long i = 0. size = bad.size;
          i <size(); ++i)
        if (v[f].first == bad[i] ||
           v[s].first == bad[i])
        {
          f = 1;
          break;
        }
      if (f) continue;
      x += v[f].first + v[s].first;
      bad.emplace_back(v[f]);
      bad.emplace_back(v[s]);
 
  	else
    {
      if (v[s+1] > v[f+1])
        ++s;
      else
        ++f;
    }
    }
  cout <<x;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:24:28: error: expected ';' before 'size'
   24 |       for (long long i = 0. size = bad.size;
      |                            ^~~~~
      |                            ;
a.cc:24:40: error: overloaded function with no contextual type information
   24 |       for (long long i = 0. size = bad.size;
      |                                        ^~~~
a.cc:25:18: error: no matching function for call to 'size()'
   25 |           i <size(); ++i)
      |              ~~~~^~
In file included from /usr/include/c++/14/string:53,
                 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/range_access.h:262:5: note: candidate: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:   candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/range_access.h:272:5: note: candidate: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note:   candidate expects 1 argument, 0 provided
a.cc:25:20: error: expected ')' before ';' token
   25 |           i <size(); ++i)
      |                    ^
      |                    )
a.cc:24:11: note: to match this '('
   24 |       for (long long i = 0. size = bad.size;
      |           ^
a.cc:25:24: error: 'i' was not declared in this scope
   25 |           i <size(); ++i)
      |                        ^
a.cc:37:9: error: expected '}' before 'else'
   37 |         else
      |         ^~~~
a.cc:22:5: note: to match this '{'
   22 |     {
      |     ^
a.cc: At global scope:
a.cc:45:3: error: 'cout' does not name a type
   45 |   cout <<x;
      |   ^~~~
a.cc:46:1: error: expected declaration before '}' token
   46 | }
      | ^
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/c++allocator.h:33,
                 from /usr/include/c++/14/bits/allocator.h:46,
                 from /usr/include/c++/14/string:43:
/usr/include/c++/14/bits/new_allocator.h: In instantiation of 'void std::__new_allocator<_Tp>::construct(_Up*, _Args&& ...) [with _Up = long long int; _Args = {std::pair<long long int, int>&}; _Tp = long long int]':
/usr/include/c++/14/bits/alloc_traits.h:575:17:   required from 'static void std::allocator_traits<std::allocator<_CharT> >::construct(allocator_type&, _Up*, _Args&& ...) [with _Up = long long int; _Args = {std::pair<long long int, int>&}; _Tp = long long int; allocator_type = std::allocator<long long int>]'
  575 |           __a.construct(__p, std::forward<_Args>(__args)...);
      |           ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/vector.tcc:117:30:   required from 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::emplace_back(_Args&& ...) [with _Args = {std::pair<long long int, int>&}; _Tp = long long int; _Alloc = std::allocator<long long int>; reference = long long int&]'
  117 |             _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish,
      |             ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  118 |                                      std::forward<_Args>(__args)...);
      |                                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:34:23:   required from here
   34 |       bad.emplace_back(v[f]);
      |       ~~~~~~~~~~~~~~~~^~~~~~
/usr/include/c++/14/bits/new_allocator.h:191:11: error: cannot convert 'std::pair<long long int, int>' to 'long long int' in initialization
  191 |         { ::new((void *)__p) _Up(std::forward<_Args>(__args)...); }
      |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~