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(), 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:11:31: error: template argument 1 is invalid
   11 |   vector<pair<long long, int> v;
      |                               ^
a.cc:11:31: error: template argument 2 is invalid
a.cc:15:5: error: 'v' was not declared in this scope
   15 |     v.emplace_back(make_pair(temp,i));
      |     ^
a.cc:17:8: error: 'v' was not declared in this scope
   17 |   sort(v.rbegin(), rend());
      |        ^
a.cc:17:24: error: no matching function for call to 'rend()'
   17 |   sort(v.rbegin(), rend());
      |                    ~~~~^~
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:172:5: note: candidate: 'template<class _Container> constexpr decltype (__cont.rend()) std::rend(_Container&)'
  172 |     rend(_Container& __cont) -> decltype(__cont.rend())
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:172:5: note:   candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/range_access.h:183:5: note: candidate: 'template<class _Container> constexpr decltype (__cont.rend()) std::rend(const _Container&)'
  183 |     rend(const _Container& __cont) -> decltype(__cont.rend())
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:183:5: note:   candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/range_access.h:205:5: note: candidate: 'template<class _Tp, long unsigned int _Nm> constexpr std::reverse_iterator<_Tp*> std::rend(_Tp (&)[_Nm])'
  205 |     rend(_Tp (&__arr)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:205:5: note:   candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/range_access.h:227:5: note: candidate: 'template<class _Tp> constexpr std::reverse_iterator<const _Tp*> std::rend(initializer_list<_Tp>)'
  227 |     rend(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:227:5: note:   candidate expects 1 argument, 0 provided
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)
      |                      ^