Language: C++

#include <bits/stdc++.h>
using namespace std;

/***** type *****/
using ll = long long;
using ld = long double;
template <class T> using vt = vector<T>;
template <class T> using vvt = vector<vector<T>>;
template <class T> using vvvt = vector<vector<vector<T>>>;
template <class T1, class T2> using umap = unordered_map<T1, T2>;

/***** define *****/
#define all(c) (c).begin(), (c).end()            // begin to end
#define rep(i, b, e) for (ll i = b; i < e; i++)  // repeat
#define repr(i, b, e) for (ll i = b; e < i; i--) // repeat reverse
#define val(itr) *(itr)                          // get value
#define f first                                  // pair first
#define s second                                 // pair second
/***** const value *****/
#define llong_max 9223372036854775807            // 9 * 10^18
#define ldbl_max 1.79769e+308                    // 1.7 * 10^308
#define pi 3.1415926535897932                    // 3.14 ...
/***** for each macro *****/
#define fori(i, ...) if(ll i = -1) for(__VA_ARGS__) if(i++, true)
#define each(i, e, c) fori(i, auto e = c.begin(); e != c.end(); ++e)
#define forir(i, v, ...) if(ll i=(ll)v.size())for(__VA_ARGS__)if(i--,true)
#define eachr(i, e, c) forir(i, auto e = c.rbegin(); e != c.rend(); ++e)

/***** lambda *****/
auto Count = [] // long long count value
(auto b, auto e, auto x) { return (ll)count(b, e, x); };
auto CtoN = [] // char to number
(auto c) { return (ll)(c - '0'); };
auto DivC = [] // long double div ceiling
(auto a, auto b) { return ceil((ld)a / (ld)b); };
auto Fix = [] // fix value
(auto b, auto e, auto fix)
{ for (auto it = b; it != e; ++it)*it += fix; };
auto Pow = [] // long long pow
(auto a, auto b) { return (ll)pow(a, b); };
auto Pow2 = [] // long long pow2
(auto n) { return (1LL << n); };
auto Pow10 = [] // long long pow10
(auto n) { return (ll)pow(10, n); };
auto Size = []  // long long collection size
(auto& c) { return (ll)(c).size(); };
auto Sum = [] // long long accumulate
(auto b, auto e) { return accumulate(b, e, 0LL); };

/***** template *****/
template <class T> void MakeVVT
(ll ys, ll xs, vvt<T>& v, T fill = T())
{	// vector<vector<T>> resize + fill
	v.resize(ys); rep(y, 0, ys) v[y].resize(xs, fill);
}
template <class T> void MakeVVVT
(ll zs, ll ys, ll xs, vvvt<T>& v, T fill = T())
{	// vector<vector<vector<T>>> resize + fill
	v.resize(zs); rep(z, 0, zs) MakeVVT(ys, xs, v[z], fill);
}
template <class T> void InputVT
(ll xs, vt<T>& v, T fix = T())
{	// input vector<T> (T != struct) + fix
	v.resize(xs); rep(i, 0, xs) { cin >> v[i]; v[i] += fix; }
}
template <class T> void InputVVT
(ll ys, ll xs, vvt<T>& v, T fix = T())
{	// input vector<vector<T>> (T != struct) + fix
	MakeVVT(ys, xs, v, fix);
	rep(y, 0, ys) rep(x, 0, xs) { cin >> v[y][x]; v[y][x] += fix; }
}
template <class T> void InputVVVT
(ll zs, ll ys, ll xs, vvvt<T>& v, T fix = T())
{	// input vector<vector<vector<T>>> (T != struct) + fix
	v.resize(zs); rep(z, 0, zs) InputVVT(ys, xs, v[z], fix);
}

/**************************************/
/********** BEGIN OF NYA LIB **********/
/**************************************/

namespace NyaGadget {}

namespace NyaGadget
{
	struct NyaKnapsackDP
	{	/*** ナップサックDPライブラリ ***/
		struct Item
		{
			long long w; // 重さ
			long long v; // 価値
		};
		vector<Item> item;

		/**
		@brief ナップサックDP実行関数
		@param ysize 通常はアイテム最大値
		@param wsize 通常は大きさ最大値
		@note
		 wsizeは制約10^5以下なら様々な要素に変更可能
		**/
		void Run(long long ysize, long long wsize)
		{	// 0番目にダミーのアイテムを追加
			item.insert(item.begin(), { 0,0 });

			// DPは通常は価値だが変更可能
			vector<vector<long long>> dp(ysize + 1);
			for (long long y = 0; y < ysize + 1; y++) dp[y].resize(wsize + 1);
			for (long long y = 1; y < ysize + 1; y++) for (long long w = 1; w < wsize + 1; w++)
			{	// DPの実行
				if (0 <= w - item[y].w) dp[y][w] = max(dp[y - 1][w], dp[y - 1][w - item[y].w] + item[y].v);
				else dp[y][w] = dp[y - 1][w];
			}

			// 答えの出力
			cout << *max_element(dp.back.begin(), dp.back.end());
		}
	};
}

/**************************************/
/*********** END OF NYA LIB ***********/
/**************************************/

using namespace NyaGadget;
//using mll = ModLL< 1000000007 >;

int main(void)
{
	ll N, W; cin >> N >> W;
	NyaKnapsackDP nkdp;
	nkdp.item.resize(N); for(auto &e: nkdp.item) cin >> e.w >> e.v;

	nkdp.Run(N, W);
	return 0;
}


Compiler output:
a.cc: In member function 'void NyaGadget::NyaKnapsackDP::Run(long long int, long long int)':
a.cc:116:49: error: invalid use of member function 'std::vector<std::vector<long long int> >::back' (did you forget the '()' ?)
  116 |                         cout << *max_element(dp.back.begin(), dp.back.end());
      |                                              ~~~^~~~
a.cc:116:66: error: invalid use of member function 'std::vector<std::vector<long long int> >::back' (did you forget the '()' ?)
  116 |                         cout << *max_element(dp.back.begin(), dp.back.end());
      |                                                               ~~~^~~~