Language: C++

#include <iostream>
#include <list>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

int n, w;
int maxv = 0;
size_t asize;
vector<cl> arr;
vector<int> vl;

class cl
{
public:
	cl(int a, int b) : v(a), w(b) { vs = double(v) / w; }
	int v, w;
	double vs;
};

bool operator<(const cl& left, const cl& right) {
	return left.vs < right.vs;
}

void f(size_t num, int vadd, int wadd, int passed)
{
	if (maxv > vadd + vl.back() - vl[passed])
	{
		return;
	}

	if (passed + 1 == asize)
	{
		maxv = max(maxv, vadd);
		return;
	}

	if (wadd + arr[num].w <= w)
	{
		f(num + 1, vadd + arr[num].v, wadd + arr[num].w, passed + 1);
	}
	f(num + 1, vadd, wadd, passed + 1);
}

int main()
{
	cin >> n; cin >> w;

	arr.reserve(n);
	vl.reserve(n);

	for (int i = 0; i < n; ++i)
	{
		int a, b;
		cin >> a; cin >> b;
		arr.emplace_back(b, a);
	}

	sort(arr.begin(), arr.end());
	vl.emplace_back();
	vl.emplace_back(arr[0].v);
	asize = arr.size();
	for (size_t i = 1; i < asize; ++i)
	{
		vl.emplace_back(vl.back() + arr[i].v);
	}

	cout << maxv;
}


Compiler output:
a.cc:13:8: error: 'cl' was not declared in this scope
   13 | vector<cl> arr;
      |        ^~
a.cc:13:10: error: template argument 1 is invalid
   13 | vector<cl> arr;
      |          ^
a.cc:13:10: error: template argument 2 is invalid
a.cc: In function 'void f(size_t, int, int, int)':
a.cc:41:23: error: invalid types 'int[size_t {aka long unsigned int}]' for array subscript
   41 |         if (wadd + arr[num].w <= w)
      |                       ^
a.cc:43:38: error: invalid types 'int[size_t {aka long unsigned int}]' for array subscript
   43 |                 f(num + 1, vadd + arr[num].v, wadd + arr[num].w, passed + 1);
      |                                      ^
a.cc:43:57: error: invalid types 'int[size_t {aka long unsigned int}]' for array subscript
   43 |                 f(num + 1, vadd + arr[num].v, wadd + arr[num].w, passed + 1);
      |                                                         ^
a.cc: In function 'int main()':
a.cc:52:13: error: request for member 'reserve' in 'arr', which is of non-class type 'int'
   52 |         arr.reserve(n);
      |             ^~~~~~~
a.cc:59:21: error: request for member 'emplace_back' in 'arr', which is of non-class type 'int'
   59 |                 arr.emplace_back(b, a);
      |                     ^~~~~~~~~~~~
a.cc:62:18: error: request for member 'begin' in 'arr', which is of non-class type 'int'
   62 |         sort(arr.begin(), arr.end());
      |                  ^~~~~
a.cc:62:31: error: request for member 'end' in 'arr', which is of non-class type 'int'
   62 |         sort(arr.begin(), arr.end());
      |                               ^~~
a.cc:64:28: error: invalid types 'int[int]' for array subscript
   64 |         vl.emplace_back(arr[0].v);
      |                            ^
a.cc:65:21: error: request for member 'size' in 'arr', which is of non-class type 'int'
   65 |         asize = arr.size();
      |                     ^~~~
a.cc:68:48: error: invalid types 'int[size_t {aka long unsigned int}]' for array subscript
   68 |                 vl.emplace_back(vl.back() + arr[i].v);
      |                                                ^