Language: C++

#include <iostream>
#include <queue>
#include <cstdio>
#define MAX_N 1000000
#define MAX_Q 100000
using namespace std;
typedef pair<int, int> P; //番号, 匹数
int ary[MAX_N + 1];
int n, q;

struct Greater {
    bool operator() (const P a, const P b) {
        if(a.first == b.first) { //匹数が同じなら
            return(a.second > b.second); //番号を昇順に
        }
        return(a.first < b.first); //同じでなければ匹数の降順に
    }
};
priority_queue<P, vector<P>, Greater> data;

//キューのデータをクリアする
void clear() {
    while(!data.empty()) data.pop();
}
void update(int no, int point) {
    ary[no] += point; //更新
    if(data.size() > 0) clear(); //キューのデータ全消し
    //データを再度入れる
    for(int r = 1; r <= n; r++) {
        data.push(P(ary[r], r));
        printf("data updated: %d, %d\n", r, ary[r]);
    }
}


int main(void) {
    cin >> n >> q;
    //initialize
    memset(ary, 0, sizeof(ary));
    
    for(int r = 0; r < q; r++) {
        int no, point; cin >> no >> point;
        update(no, point);
        P top = data.top(); printf("%d %d\n", top.second, top.first);
    }
    return(0);
}

Compiler output:
a.cc: In function 'void clear()':
a.cc:23:12: error: reference to 'data' is ambiguous
   23 |     while(!data.empty()) data.pop();
      |            ^~~~
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: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:19:39: note:                 'std::priority_queue<std::pair<int, int>, std::vector<std::pair<int, int> >, Greater> data'
   19 | priority_queue<P, vector<P>, Greater> data;
      |                                       ^~~~
a.cc:23:26: error: reference to 'data' is ambiguous
   23 |     while(!data.empty()) data.pop();
      |                          ^~~~
/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:19:39: note:                 'std::priority_queue<std::pair<int, int>, std::vector<std::pair<int, int> >, Greater> data'
   19 | priority_queue<P, vector<P>, Greater> data;
      |                                       ^~~~
a.cc: In function 'void update(int, int)':
a.cc:27:8: error: reference to 'data' is ambiguous
   27 |     if(data.size() > 0) clear(); //キューのデータ全消し
      |        ^~~~
/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:19:39: note:                 'std::priority_queue<std::pair<int, int>, std::vector<std::pair<int, int> >, Greater> data'
   19 | priority_queue<P, vector<P>, Greater> data;
      |                                       ^~~~
a.cc:30:9: error: reference to 'data' is ambiguous
   30 |         data.push(P(ary[r], r));
      |         ^~~~
/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:19:39: note:                 'std::priority_queue<std::pair<int, int>, std::vector<std::pair<int, int> >, Greater> data'
   19 | priority_queue<P, vector<P>, Greater> data;
      |                                       ^~~~
a.cc: In function 'int main()':
a.cc:39:5: error: 'memset' was not declared in this scope
   39 |     memset(ary, 0, sizeof(ary));
      |     ^~~~~~
a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    3 | #include <cstdio>
  +++ |+#include <cstring>
    4 | #define MAX_N 1000000
a.cc:44:17: error: reference to 'data' is ambiguous
   44 |         P top = data.top(); printf("%d %d\n", top.second, top.first);
      |                 ^~~~
/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:19:39: note:                 'std::priority_queue<std::pair<int, int>, std::vector<std::pair<int, int> >, Greater> data'
   19 | priority_queue<P, vector<P>, Greater> data;
      |                                       ^~~~