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;
    }
}

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:13: error: invalid operands of types 'long long int' and '<unresolved overloaded function type>' to binary 'operator<'
   25 |           i <size; ++i)
      |           ~~^~~~~
a.cc:25:18: 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:22: error: 'i' was not declared in this scope
   25 |           i <size; ++i)
      |                      ^
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,
                 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/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)...); }
      |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~