Language: C++

#include<iostream>
#include<queue>
using namespace std;

int N,K;
priority_queue<int,vector<int>,greater<int>> book[11];	//book[i]には、ジャンルiの本の価格が昇順で入っている。
int size[11] = {0};

int main(){
	int i,j;
	int data,topic;
	int sum = 0;
	cin >> N >> K;
	for(i = 0;i < N;i++){
		cin >> data >> topic;
		sum += data;
		book[topic].push(data);
		size[topic]++;
	}
	//付加価値を足す。(本の値段は素のまま)
	for(i = 0;i < 11;i++){
		if(size[i] > 1)
			sum += (size[i]-1)*size[i];
	}
	//cout << sum << endl;
	//のこす本を選ぶ
	for(i = 0;i < N-K;i++){
		for(j = 0;j < 11;j++){
			//在庫があったら
			if(size[j] != 0){
				//とる本の候補のジャンルと値段をそれに初期化し、探索開始
				topic = j;								//選ぶ本					
				data = book[topic].top()+2*size[j]-2;	//本を取った時の損失
				break;
			}
		}
		for(;j < 11;j++){
			if(size[j] == 0)
				continue;
			if(book[j].top()+2*size[j]-2 < data){
				topic = j;								//選ぶ本					
				data = book[topic].top()+2*size[j]-2;	//本を取った時の損失
			}
		}
		sum -= data;
		book[topic].pop();
		size[topic]--;
	}
	cout << sum << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:17: error: reference to 'size' is ambiguous
   18 |                 size[topic]++;
      |                 ^~~~
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:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:7:5: note:                 'int size [11]'
    7 | int size[11] = {0};
      |     ^~~~
a.cc:22:20: error: reference to 'size' is ambiguous
   22 |                 if(size[i] > 1)
      |                    ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:7:5: note:                 'int size [11]'
    7 | int size[11] = {0};
      |     ^~~~
a.cc:23:33: error: reference to 'size' is ambiguous
   23 |                         sum += (size[i]-1)*size[i];
      |                                 ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:7:5: note:                 'int size [11]'
    7 | int size[11] = {0};
      |     ^~~~
a.cc:23:44: error: reference to 'size' is ambiguous
   23 |                         sum += (size[i]-1)*size[i];
      |                                            ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:7:5: note:                 'int size [11]'
    7 | int size[11] = {0};
      |     ^~~~
a.cc:30:28: error: reference to 'size' is ambiguous
   30 |                         if(size[j] != 0){
      |                            ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:7:5: note:                 'int size [11]'
    7 | int size[11] = {0};
      |     ^~~~
a.cc:33:60: error: reference to 'size' is ambiguous
   33 |                                 data = book[topic].top()+2*size[j]-2;   //本を取った時の損失
      |                                                            ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:7:5: note:                 'int size [11]'
    7 | int size[11] = {0};
      |     ^~~~
a.cc:38:28: error: reference to 'size' is ambiguous
   38 |                         if(size[j] == 0)
      |                            ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:7:5: note:                 'int size [11]'
    7 | int size[11] = {0};
      |     ^~~~
a.cc:40:44: error: reference to 'size' is ambiguous
   40 |                         if(book[j].top()+2*size[j]-2 < data){
      |                                            ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:7:5: note:                 'int size [11]'
    7 | int size[11] = {0};
      |     ^~~~
a.cc:42:60: error: reference to 'size' is ambiguous
   42 |                                 data = book[topic].top()+2*size[j]-2;   //本を取った時の損失
      |                                                            ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:7:5: note:                 'int size [11]'
    7 | int size[11] = {0};
      |     ^~~~
a.cc:47:17: error: reference to 'size' is ambiguous
   47 |                 size[topic]--;
      |                 ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:7:5: note:                 'int size [11]'
    7 | int size[11] = {0};
      |     ^~~~