Language: C++

#include <bits/stdc++.h>

vector< pair<long, long> > wv;
int dp[n+1][w+1];

void knapsack(int n,int W)
{
	for(i = 0; i <= n; i++)
		for (w = 0; w <= W; w++)
		{
			if(i == 0|| w == 0)
				dp[i][w] = 0;
			else if(wt[i-1] <= w)
				dp[i][w] = max(wv[i-1][1] + dp[i-1][w-wv[i-1][0]], dp[i-1][w]);
			else
                 K[i][w] = K[i-1][w];
		}
}

int main()
{
	int n, w;
	for(int i = 0; i < n; i++)
	{
		long w, v;
		cin >> w >> v;

		wv.push_back(make_pair(w,v));
	}

	knapsack(n,w);
	return 0;
}

Compiler output:
a.cc:3:1: error: 'vector' does not name a type
    3 | vector< pair<long, long> > wv;
      | ^~~~~~
a.cc:4:8: error: 'n' was not declared in this scope; did you mean 'yn'?
    4 | int dp[n+1][w+1];
      |        ^
      |        yn
a.cc:4:13: error: 'w' was not declared in this scope
    4 | int dp[n+1][w+1];
      |             ^
a.cc: In function 'void knapsack(int, int)':
a.cc:8:13: error: 'i' was not declared in this scope
    8 |         for(i = 0; i <= n; i++)
      |             ^
a.cc:9:22: error: 'w' was not declared in this scope
    9 |                 for (w = 0; w <= W; w++)
      |                      ^
a.cc:12:33: error: 'dp' was not declared in this scope; did you mean 'dup'?
   12 |                                 dp[i][w] = 0;
      |                                 ^~
      |                                 dup
a.cc:13:33: error: 'wt' was not declared in this scope
   13 |                         else if(wt[i-1] <= w)
      |                                 ^~
a.cc:14:33: error: 'dp' was not declared in this scope; did you mean 'dup'?
   14 |                                 dp[i][w] = max(wv[i-1][1] + dp[i-1][w-wv[i-1][0]], dp[i-1][w]);
      |                                 ^~
      |                                 dup
a.cc:14:48: error: 'wv' was not declared in this scope
   14 |                                 dp[i][w] = max(wv[i-1][1] + dp[i-1][w-wv[i-1][0]], dp[i-1][w]);
      |                                                ^~
a.cc:14:44: error: 'max' was not declared in this scope; did you mean 'std::max'?
   14 |                                 dp[i][w] = max(wv[i-1][1] + dp[i-1][w-wv[i-1][0]], dp[i-1][w]);
      |                                            ^~~
      |                                            std::max
In file included from /usr/include/c++/14/algorithm:61,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: 'std::max' declared here
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
a.cc:16:18: error: 'K' was not declared in this scope
   16 |                  K[i][w] = K[i-1][w];
      |                  ^
a.cc: In function 'int main()':
a.cc:26:17: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   26 |                 cin >> w >> v;
      |                 ^~~
      |                 std::cin
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:28:17: error: 'wv' was not declared in this scope; did you mean 'v'?
   28 |                 wv.push_back(make_pair(w,v));
      |                 ^~
      |                 v
a.cc:28:30: error: 'make_pair' was not declared in this scope; did you mean 'std::make_pair'?
   28 |                 wv.push_back(make_pair(w,v));
      |                              ^~~~~~~~~
      |                              std::make_pair
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
                 from /usr/include/c++/14/algorithm:60:
/usr/include/c++/14/bits/stl_pair.h:1132:5: note: 'std::make_pair' declared here
 1132 |     make_pair(_T1&& __x, _T2&& __y)
      |     ^~~~~~~~~