Language: C++

#include <bits/stdc++.h>
using namespace std;
 
long knapsack1(vector<int>w,vector<int >v,long W)
{
    long n=w.size();
    vector<vector<int>>dp(n+1,vector<int>(W+1,0));
   
    for(int i=1;i<=n;i++)
    {
        for(long j=1;j<=W;j++)
        {
            if(j-w[i-1]>=0)
                dp[i][j]=max(dp[i-1][j],v[i-1]+dp[i-1][j-w[i-1]]);
            else dp[i][j]=dp[i-1][j];
        }
    }
    
    return dp[n][W];
   
}
 
int main() {
	int n;
	long W;
	cin>>n>>W;
	vector<long>w(n);
	vector<long>v(n);
	for(int i=0;i<n;i++)cin>>w[i]>>v[i];
	
	cout<<knapsack1(w,v,W);
	return 0;
}#include <bits/stdc++.h>
using namespace std;
 
long knapsack1(vector<int>w,vector<int >v,long W)
{
    long n=w.size();
    vector<vector<int>>dp(n+1,vector<int>(W+1,0));
   
    for(int i=1;i<=n;i++)
    {
        for(long j=1;j<=W;j++)
        {
            if(j-w[i-1]>=0)
                dp[i][j]=max(dp[i-1][j],v[i-1]+dp[i-1][j-w[i-1]]);
            else dp[i][j]=dp[i-1][j];
        }
    }
    
    return dp[n][W];
   
}
 
int main() {
	int n;
	long W;
	cin>>n>>W;
	vector<long>w(n);
	vector<long>v(n);
	for(int i=0;i<n;i++)cin>>w[i]>>v[i];
	
	cout<<knapsack1(w,v,W);
	return 0;
}#include <bits/stdc++.h>
using namespace std;
 
long knapsack1(vector<int>w,vector<int >v,long W)
{
    long n=w.size();
    vector<vector<int>>dp(n+1,vector<int>(W+1,0));
   
    for(int i=1;i<=n;i++)
    {
        for(long j=1;j<=W;j++)
        {
            if(j-w[i-1]>=0)
                dp[i][j]=max(dp[i-1][j],v[i-1]+dp[i-1][j-w[i-1]]);
            else dp[i][j]=dp[i-1][j];
        }
    }
    
    return dp[n][W];
   
}
 
int main() {
	int n;
	long W;
	cin>>n>>W;
	vector<long>w(n);
	vector<long>v(n);
	for(int i=0;i<n;i++)cin>>w[i]>>v[i];
	
	cout<<knapsack1(w,v,W);
	return 0;
}#include <bits/stdc++.h>
using namespace std;
 
long knapsack1(vector<int>w,vector<int >v,long W)
{
    long n=w.size();
    vector<vector<int>>dp(n+1,vector<int>(W+1,0));
   
    for(int i=1;i<=n;i++)
    {
        for(long j=1;j<=W;j++)
        {
            if(j-w[i-1]>=0)
                dp[i][j]=max(dp[i-1][j],v[i-1]+dp[i-1][j-w[i-1]]);
            else dp[i][j]=dp[i-1][j];
        }
    }
    
    return dp[n][W];
   
}
 
int main() {
	int n;
	long W;
	cin>>n>>W;
	vector<long>w(n);
	vector<long>v(n);
	for(int i=0;i<n;i++)cin>>w[i]>>v[i];
	
	cout<<knapsack1(w,v,W);
	return 0;
}

Compiler output:
a.cc:33:2: error: stray '#' in program
   33 | }#include <bits/stdc++.h>
      |  ^
a.cc:65:2: error: stray '#' in program
   65 | }#include <bits/stdc++.h>
      |  ^
a.cc:97:2: error: stray '#' in program
   97 | }#include <bits/stdc++.h>
      |  ^
a.cc: In function 'int main()':
a.cc:31:25: error: could not convert 'w' from 'vector<long int>' to 'vector<int>'
   31 |         cout<<knapsack1(w,v,W);
      |                         ^
      |                         |
      |                         vector<long int>
a.cc: At global scope:
a.cc:33:3: error: 'include' does not name a type
   33 | }#include <bits/stdc++.h>
      |   ^~~~~~~
a.cc:36:6: error: redefinition of 'long int knapsack1(std::vector<int>, std::vector<int>, long int)'
   36 | long knapsack1(vector<int>w,vector<int >v,long W)
      |      ^~~~~~~~~
a.cc:4:6: note: 'long int knapsack1(std::vector<int>, std::vector<int>, long int)' previously defined here
    4 | long knapsack1(vector<int>w,vector<int >v,long W)
      |      ^~~~~~~~~
a.cc:55:5: error: redefinition of 'int main()'
   55 | int main() {
      |     ^~~~
a.cc:23:5: note: 'int main()' previously defined here
   23 | int main() {
      |     ^~~~
a.cc: In function 'int main()':
a.cc:63:25: error: could not convert 'w' from 'vector<long int>' to 'vector<int>'
   63 |         cout<<knapsack1(w,v,W);
      |                         ^
      |                         |
      |                         vector<long int>
a.cc: At global scope:
a.cc:65:3: error: 'include' does not name a type
   65 | }#include <bits/stdc++.h>
      |   ^~~~~~~
a.cc:68:6: error: redefinition of 'long int knapsack1(std::vector<int>, std::vector<int>, long int)'
   68 | long knapsack1(vector<int>w,vector<int >v,long W)
      |      ^~~~~~~~~
a.cc:4:6: note: 'long int knapsack1(std::vector<int>, std::vector<int>, long int)' previously defined here
    4 | long knapsack1(vector<int>w,vector<int >v,long W)
      |      ^~~~~~~~~
a.cc:87:5: error: redefinition of 'int main()'
   87 | int main() {
      |     ^~~~
a.cc:23:5: note: 'int main()' previously defined here
   23 | int main() {
      |     ^~~~
a.cc: In function 'int main()':
a.cc:95:25: error: could not convert 'w' from 'vector<long int>' to 'vector<int>'
   95 |         cout<<knapsack1(w,v,W);
      |                         ^
      |                         |
      |                         vector<long int>
a.cc: At global scope:
a.cc:97:3: error: 'include' does not name a type
   97 | }#include <bits/stdc++.h>
      |   ^~~~~~~
a.cc:100:6: error: redefinition of 'long int knapsack1(std::vector<int>, std::vector<int>, long int)'
  100 | long knapsack1(vector<int>w,vector<int >v,long W)
      |      ^~~~~~~~~
a.cc:4:6: note: 'long int knapsack1(std::vector<int>, std::vector<int>, long int)' previously defined here
    4 | long knapsack1(vector<int>w,vector<int >v,long W)
      |      ^~~~~~~~~
a.cc:119:5: error: redefinition of 'int main()'
  119 | int main() {
      |     ^~~~
a.cc:23:5: note: 'int main()' previously defined here
   23 | int main() {
      |     ^~~~
a.cc: In function 'int main()':
a.cc:127:25: error: could not convert 'w' from 'vector<long int>' to 'vector<int>'
  127 |         cout<<knapsack1(w,v,W);
      |                         ^
      |                         |
      |                         vector<long int>