Language: C++

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

int N,K;
//book[i]には、ジャンルiの本の価格が昇順で入っている。
priority_queue<int,vector<int>,greater<int>> book[11];	
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:19:17: error: reference to 'size' is ambiguous
   19 |                 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:8:5: note:                 'int size [11]'
    8 | int size[11] = {0};
      |     ^~~~
a.cc:23:20: error: reference to 'size' is ambiguous
   23 |                 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:8:5: note:                 'int size [11]'
    8 | int size[11] = {0};
      |     ^~~~
a.cc:24:33: error: reference to 'size' is ambiguous
   24 |                         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:8:5: note:                 'int size [11]'
    8 | int size[11] = {0};
      |     ^~~~
a.cc:24:44: error: reference to 'size' is ambiguous
   24 |                         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:8:5: note:                 'int size [11]'
    8 | int size[11] = {0};
      |     ^~~~
a.cc:31:28: error: reference to 'size' is ambiguous
   31 |                         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:8:5: note:                 'int size [11]'
    8 | int size[11] = {0};
      |     ^~~~
a.cc:36:60: error: reference to 'size' is ambiguous
   36 |                                 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:8:5: note:                 'int size [11]'
    8 | int size[11] = {0};
      |     ^~~~
a.cc:41:28: error: reference to 'size' is ambiguous
   41 |                         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:8:5: note:                 'int size [11]'
    8 | int size[11] = {0};
      |     ^~~~
a.cc:43:44: error: reference to 'size' is ambiguous
   43 |                         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:8:5: note:                 'int size [11]'
    8 | int size[11] = {0};
      |     ^~~~
a.cc:45:60: error: reference to 'size' is ambiguous
   45 |                                 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:8:5: note:                 'int size [11]'
    8 | int size[11] = {0};
      |     ^~~~
a.cc:50:17: error: reference to 'size' is ambiguous
   50 |                 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:8:5: note:                 'int size [11]'
    8 | int size[11] = {0};
      |     ^~~~