Language: C++

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
#define PAUSE \
	int t;    \
	cin >> t
#define int long long
#define vi vector<long long>
#define mapii map<long long, int>
#define mapci map<char, int>
#define append(x) push_back(x)
#define tcase          \
	long long t;       \
	scanf("%lld", &t); \
	while (t--)
#define prq priority_queue
#define fio                           \
	ios_base::sync_with_stdio(false); \
	cin.tie(NULL)
// #define debug(x, y) cout<<"case #"<<x<<" at itr #"<<y<<endl
#define debug(x) cout << "case #" << x << endl
#define ff first
#define ss second
#define range(ini, x) for (int itr = ini; itr < x; itr++)
#define takearr(x)    \
	for (auto &i : x) \
	cin >> i
#define print(x)     \
	for (auto i : x) \
		cout << i << " ";
#define FOR(x, y) for (int i = x; i < y; i++)
#define for0(i, n) for (int i = 0; i < n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define foreach(i, x) for (auto i : x)
#define vi2d vector <array<int,2>>
#define setbitcount __builtin_popcount
//******************/
// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// #endif
//******************/
// #define range(ini, x, step) for( int itr = ini, i < x; itr += step )
using namespace std;
// using namespace __gnu_pbds;
// template < class type > using oset=tree<type, null_type,less<type>, rb_tree_tag,tree_order_statistics_node_update>;
const int mmx = 1e9 + 5;
const int mnx = 1e4 + 1;
const int mmod = 1e9 + 7;

int dp[105][mmx];
int n, w;
vi2d arr;

int func( int index, int weight ){

if( dp[index][weight] != -1 ) return dp[index][weight];

if( index >= n ){
	dp[index][weight] = 0;
	return dp[index][weight];
}
if( weight <= 0 ){
	dp[index][weight] = 0;
	return dp[index][weight];
}

int a = 0, b = 0;
if( arr[index][0] <= weight ){
	a = ( arr[index][1] ) + func( index + 1, weight - arr[index][0] );
}

	dp[index][weight] =  max( a, func( index + 1, weight ) );
	return dp[index][weight];

}

signed main()
{

	memset( dp, -1, sizeof dp );

	cin>>n>>w;
	for0(i,n){
		int x, y;
		cin>>x>>y;
		arr.push_back({ x, y });
	}

	cout<<func(0,w);

	return 0;
}

Compiler output:
/tmp/ccbDwlvC.o: in function `func(long long, long long)':
a.cc:(.text+0x69): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccbDwlvC.o
a.cc:(.text+0x13a): relocation truncated to fit: R_X86_64_PC32 against symbol `arr' defined in .bss section in /tmp/ccbDwlvC.o
a.cc:(.text+0x16b): relocation truncated to fit: R_X86_64_PC32 against symbol `arr' defined in .bss section in /tmp/ccbDwlvC.o
a.cc:(.text+0x191): relocation truncated to fit: R_X86_64_PC32 against symbol `arr' defined in .bss section in /tmp/ccbDwlvC.o
/tmp/ccbDwlvC.o: in function `main':
a.cc:(.text+0x27b): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccbDwlvC.o
a.cc:(.text+0x297): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccbDwlvC.o
a.cc:(.text+0x2f2): relocation truncated to fit: R_X86_64_PC32 against symbol `arr' defined in .bss section in /tmp/ccbDwlvC.o
a.cc:(.text+0x306): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccbDwlvC.o
a.cc:(.text+0x313): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccbDwlvC.o
/tmp/ccbDwlvC.o: in function `__static_initialization_and_destruction_0()':
a.cc:(.text+0x344): relocation truncated to fit: R_X86_64_PC32 against symbol `arr' defined in .bss section in /tmp/ccbDwlvC.o
a.cc:(.text+0x35d): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status