Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <set>

using namespace std;
struct dish
{
    long long A;
    long long B;
};

int main()
{
    // 整数の入力
    long long N, K, i, a_i, b_i, sumA, sumB;
    sumA = 0;
    sumB = 0;
    bool c = [](dish p1, dish p2) {
        return (p1.A + p1.B) > (p2.A + p2.B);
    };

    priority_queue<dish, vector<dish>, decltype(c)> q1(c);

    cin >> N;

    for (int i = 0; i < N; i++)
    {
        cin >> a_i >> b_i;
        q1.push({a_i, b_i});
    }

    for (int i = 0; i < N; i++)
    {
        if (i % 2 == 0)
        {
            dish d = q1.top();
            sumA += d.A;
            q1.pop();
        }
        else
        {
            dish d = q1.top();
            sumA -= d.B;
            q1.pop();
        }
    }
    cout << sumA << endl;

    return 0;
}

Compiler output:
In file included from /usr/include/c++/14/bits/stl_algobase.h:71,
                 from /usr/include/c++/14/string:51,
                 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/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Iter_comp_val<_Compare>::operator()(_Iterator, _Value&) [with _Iterator = __gnu_cxx::__normal_iterator<dish*, std::vector<dish> >; _Value = dish; _Compare = bool]':
/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<dish*, vector<dish> >; _Distance = long int; _Tp = dish; _Compare = __gnu_cxx::__ops::_Iter_comp_val<bool>]'
  140 |       while (__holeIndex > __topIndex && __comp(__first + __parent, __value))
      |                                          ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_heap.h:216:23:   required from 'void std::push_heap(_RAIter, _RAIter, _Compare) [with _RAIter = __gnu_cxx::__normal_iterator<dish*, vector<dish> >; _Compare = bool]'
  216 |       std::__push_heap(__first, _DistanceType((__last - __first) - 1),
      |       ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  217 |                        _DistanceType(0), _GLIBCXX_MOVE(__value), __cmp);
      |                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:747:16:   required from 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(value_type&&) [with _Tp = dish; _Sequence = std::vector<dish>; _Compare = bool; value_type = dish]'
  747 |         std::push_heap(c.begin(), c.end(), comp);
      |         ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:32:16:   required from here
   32 |         q1.push({a_i, b_i});
      |         ~~~~~~~^~~~~~~~~~~~
/usr/include/c++/14/bits/predefined_ops.h:196:30: error: expression cannot be used as a function
  196 |         { return bool(_M_comp(*__it, __val)); }
      |                       ~~~~~~~^~~~~~~~~~~~~~
/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<dish*, std::vector<dish> >; _Iterator2 = __gnu_cxx::__normal_iterator<dish*, std::vector<dish> >; _Compare = bool]':
/usr/include/c++/14/bits/stl_heap.h:232:14:   required from 'void std::__adjust_heap(_RandomAccessIterator, _Distance, _Distance, _Tp, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<dish*, vector<dish> >; _Distance = long int; _Tp = dish; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool>]'
  232 |           if (__comp(__first + __secondChild,
      |               ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
  233 |                      __first + (__secondChild - 1)))
      |                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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<dish*, vector<dish> >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool>]'
  356 |           std::__adjust_heap(__first, __parent, __len, _GLIBCXX_MOVE(__value),
      |           ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  357 |                              __comp);
      |                              ~~~~~~~
/usr/include/c++/14/bits/stl_heap.h:413:23:   required from 'void std::make_heap(_RAIter, _RAIter, _Compare) [with _RAIter = __gnu_cxx::__normal_iterator<dish*, vector<dish> >; _Compare = bool]'
  413 |       std::__make_heap(__first, __last, __cmp);
      |       ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:565:23:   required from 'std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(const _Compare&, _Sequence&&) [with _Tp = dish; _Sequence = std::vector<dish>; _Compare = bool]'
  565 |       { std::make_heap(c.begin(), c.end(), comp); }
      |         ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:25:57:   required from here
   25 |     priority_queue<dish, vector<dish>, decltype(c)> q1(c);
      |                                                         ^
/usr/include/c++/14/bits/predefined_ops.h:158:30: error: expression cannot be used as a function
  158 |         { return bool(_M_comp(*__it1, *__it2)); }
      |                       ~~~~~~~^~~~~~~~~~~~~~~~