Language: C++

#include <bits/stdc++.h>

using namespace std;

const int maxn = 1e5 + 9;
int m,n;
struct data
{
    int64_t gt, sl;
};
data a[maxn];

void Enter()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cin >> n >> m;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i].gt;
        a[i].sl = 1;
    }
    for (int i = 1, sl, gt; i <= m; i++)
    {
        cin >> sl >> gt;
        a[i + n].gt = gt;
        a[i + n].sl = sl;
    }
}

bool cmp(data x, data y)
{
    if (x.gt < y.gt) return true;
    return false;
}

void Solve()
{
    sort(a + 1, a + m + n + 1, cmp);
    int i = m + n;
    int64_t s = 0;
    while (n > 0)
    {
        if (a[i].sl > n)
            s += a[i].gt * n;
        else
            s += a[i].gt * a[i].sl;
         n -= a[i].sl, i--;
    }
    cout << s;

}

int main()
{
    Enter();
    Solve();
    return 0;
}


Compiler output:
a.cc:11:1: error: reference to 'data' is ambiguous
   11 | data a[maxn];
      | ^~~~
In file included from /usr/include/c++/14/string:53,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:1:
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:7:8: note:                 'struct data'
    7 | struct data
      |        ^~~~
a.cc: In function 'void Enter()':
a.cc:20:16: error: 'a' was not declared in this scope
   20 |         cin >> a[i].gt;
      |                ^
a.cc:26:9: error: 'a' was not declared in this scope
   26 |         a[i + n].gt = gt;
      |         ^
a.cc: At global scope:
a.cc:31:10: error: reference to 'data' is ambiguous
   31 | bool cmp(data x, data y)
      |          ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:7:8: note:                 'struct data'
    7 | struct data
      |        ^~~~
a.cc:31:18: error: reference to 'data' is ambiguous
   31 | bool cmp(data x, data y)
      |                  ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:7:8: note:                 'struct data'
    7 | struct data
      |        ^~~~
a.cc:31:24: error: expression list treated as compound expression in initializer [-fpermissive]
   31 | bool cmp(data x, data y)
      |                        ^
a.cc: In function 'void Solve()':
a.cc:39:10: error: 'a' was not declared in this scope
   39 |     sort(a + 1, a + m + n + 1, cmp);
      |          ^