criyle/codenet-compile-errors huggingface dataset:
Language: C++

#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;

int main()
{
int n,w;
cin>>n>>w;
int val[n],we[n];
  
  for(int i=0;i<n;i++)
  cin>>we[i]>>val[i];
   
 ll dp[n+1][w+1];
          
          for(int i=0;i<=n;i++)
          {
             for(int j=0;j<=w;j++)
             {
               if(i==0||j==0)
                 dp[i][j]=0;
               
               else if(wt[i-1]<=w)
               dp[i][j]=max(dp[i-1][j],dp[i-1][j-we[i-1]]+val[i-1]);
               
               else
                 dp[i][j]=dp[i-1][j];
                 
             
             }
          }
          
          cout<<dp[n][w];
return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:23:24: error: 'wt' was not declared in this scope; did you mean 'we'?
   23 |                else if(wt[i-1]<=w)
      |                        ^~
      |                        we
Language: C++

#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;

int main()
{
int n,w;
cin>>n>>w;
int val[n],we[n];
  
  for(int i=0;i<n;i++)
  cin>>we[i]>>val[i];
   
 ll dp[n+1][w+1];
          
          for(int i=0;i<=n;i++)
          {
             for(int j=0;j<=w;j++)
             {
               if(i==0||j==0)
                 dp[i][j]=0;
               
               else if(wt[i-1]<=w)
               dp[i][j]=max(dp[i-1][j],dp[i-1][j-wt[i-1]]+val[i-1]);
               
               else
                 dp[i][j]=dp[i-1][j];
                 
             
             }
          }
          
          cout<<dp[n][w];
return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:23:24: error: 'wt' was not declared in this scope; did you mean 'we'?
   23 |                else if(wt[i-1]<=w)
      |                        ^~
      |                        we
Language: C++

#inlclude <bits/stdc++.h>
typedef long long int ll;
using namespace std;

int main()
{
int n,w;
cin>>n>>w;
int val[n],we[n];
  
  for(int i=0;i<n;i++)
  cin>>we[i}>>val[i];
   
 ll dp[n+1][w+1];
          
          for(int i=0;i<=n;i++)
          {
             for(int j=0;j<=w;j++)
             {
               if(i==0||j==0)
                 dp[i][j]=0;
               
               else if(wt[i-1]<=w)
               dp[i][j]=max(dp[i-1][j],dp[i-1][j-wt[i-1]]+val[i-1]);
               
               else
                 dp[i][j]=dp[i-1][j];
                 
             
             }
          }
          
          cout<<dp[n][w];
return 0;
}

Compiler output:
a.cc:1:2: error: invalid preprocessing directive #inlclude; did you mean #include?
    1 | #inlclude <bits/stdc++.h>
      |  ^~~~~~~~
      |  include
a.cc: In function 'int main()':
a.cc:8:1: error: 'cin' was not declared in this scope
    8 | cin>>n>>w;
      | ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | #inlclude <bits/stdc++.h>
a.cc:12:12: error: expected ']' before '}' token
   12 |   cin>>we[i}>>val[i];
      |            ^
      |            ]
a.cc: At global scope:
a.cc:12:13: error: expected unqualified-id before '>>' token
   12 |   cin>>we[i}>>val[i];
      |             ^~
a.cc:14:8: error: 'n' was not declared in this scope
   14 |  ll dp[n+1][w+1];
      |        ^
a.cc:14:13: error: 'w' was not declared in this scope
   14 |  ll dp[n+1][w+1];
      |             ^
a.cc:16:11: error: expected unqualified-id before 'for'
   16 |           for(int i=0;i<=n;i++)
      |           ^~~
a.cc:16:23: error: 'i' does not name a type
   16 |           for(int i=0;i<=n;i++)
      |                       ^
a.cc:16:28: error: 'i' does not name a type
   16 |           for(int i=0;i<=n;i++)
      |                            ^
a.cc:33:11: error: 'cout' does not name a type
   33 |           cout<<dp[n][w];
      |           ^~~~
a.cc:34:1: error: expected unqualified-id before 'return'
   34 | return 0;
      | ^~~~~~
a.cc:35:1: error: expected declaration before '}' token
   35 | }
      | ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define int long long
uint32_t main(){
    int n, w;
    cin >> n>> w;
    int weight[n+1];
    int value[n+1];
    int dp[n+1][w+1];
    weight[0] = 0;
    value[0]=0;
    for(int i=1; i<=n; i++)
    {
        cin >> weight[i] >> value[i];
    }
    for(int i=0; i<=n ; i++)
    {
        for(int j=0; j<=w; j++)
        {
            if(i==0 || j==0)
                dp[i][j]=0;
            else if(weight[i] > j)  //if weight is exceding maximum allowable weight
                dp[i][j] = dp[i-1][j];
            else
                dp[i][j] = max(dp[i-1][j], value[i] + dp[i][j-weight[i]]);
        }
    }
    cout << dp[n][w] << endl;
}

Compiler output:
a.cc:4:1: error: '::main' must return 'int'
    4 | uint32_t main(){
      | ^~~~~~~~
Language: C++

#include <iostream>
#include <algorithm>
#include <cstdlib>
using namespace std;

int N, W;
int dp[200][100010] = {INT_MIN};
int v[200];
int w[200];

int main()
{
  cin >> N >> W ;

  for (int i = 0; i < N; i++)
  {
    cin >> w[i];
    cin >> v[i];
  }

  dp[0][0] = INT_MIN

  for (int i = 0; i < N; i++) {
    for (int sumWeight = 0; sumWeight <= W; sumWeight++) {
      // take
      if (sumWeight - w[i] >= 0)
      {
        if (dp[i + 1][sumWeight] < dp[i][sumWeight - w[i]] + v[i]) {
          dp[i + 1][sumWeight] = dp[i][sumWeight - w[i]] + v[i];
        }
      }

      //not take
      if (dp[i + 1][sumWeight] < dp[i][sumWeight]) {
        dp[i + 1][sumWeight] = dp[i][sumWeight];
      }
    }
  }

  cout << dp[N][W] << endl;
  return 0;
}


Compiler output:
a.cc:7:24: error: 'INT_MIN' was not declared in this scope
    7 | int dp[200][100010] = {INT_MIN};
      |                        ^~~~~~~
a.cc:4:1: note: 'INT_MIN' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    3 | #include <cstdlib>
  +++ |+#include <climits>
    4 | using namespace std;
a.cc: In function 'int main()':
a.cc:21:14: error: 'INT_MIN' was not declared in this scope
   21 |   dp[0][0] = INT_MIN
      |              ^~~~~~~
a.cc:21:14: note: 'INT_MIN' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
a.cc:23:19: error: 'i' was not declared in this scope
   23 |   for (int i = 0; i < N; i++) {
      |                   ^
Language: C++

    #include <iostream>
    #include <algorithm>
    #include <vector>
     
    int self_m(long long& a, long long b){
        a = std::max(a, b);
        return a;
    }
     
    int main() {
        int n, w, e_w, v;
        scanf("%d%d", &n, &w);
        std::vector<long long>dp(w+1, 0);
        
        for(int d =0; d<n; d++){
            //int e_w, v;
            scanf("%d%d", &e_w, &v);
            for(int al_w =w - e_w ; al_w>=0; al_w--){
                self_m(dp[e_w+al_w], dp[al_w] + v);
                
            }
        }
        
        std::cout<<*(std::max_element(std::begin(dp), std::end(dp))));
        
    }

Compiler output:
a.cc: In function 'int main()':
a.cc:24:69: error: expected ';' before ')' token
   24 |         std::cout<<*(std::max_element(std::begin(dp), std::end(dp))));
      |                                                                     ^
      |                                                                     ;
Language: C++

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

int main() 
{   int n,W;
 cin>>n>>W;
 
 int Wt[n],val[n];
 for(int i=0;i<n;i++)
   cin>>Wt[i]>>val[i];
  
 
  int i, w; 
   int K[n+1][W+1]; 
  
 
   for (i = 0; i <= n; i++) 
   { 
       for (w = 0; w <= W; w++) 
       { 
           if (i==0 || w==0) 
               K[i][w] = 0; 
           else if (wt[i-1] <= w) 
                 K[i][w] = max(val[i-1] + K[i-1][w-wt[i-1]],  K[i-1][w]); 
           else
                 K[i][w] = K[i-1][w]; 
       } 
   } 
  
   cout<<K[n][W]; 
    
    return 0; 
}

Compiler output:
a.cc: In function 'int main()':
a.cc:23:21: error: 'wt' was not declared in this scope; did you mean 'Wt'?
   23 |            else if (wt[i-1] <= w)
      |                     ^~
      |                     Wt
Language: C++

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

ll dp[100005];
int w[105], v[105];

int main() {
  int n, W; cin >> n >> W;
  for (int i = 1; i <= n; i++) dp[i] = -0x3f3f3f3f3f3f3f3fll;
  for (int i = 0; i < n; i++)
    cin >> w[i] >> v[i];
  for (int i = W; i >= 0; i--)
    for (int j = 0; j < n; j++)
      if (i - w[j] >= 0)
        dp[i] = max(dp[i], dp[i - w[j]] + v[j]);
  cout << *max_element(dp, dp + W + 1, 0ll) << endl;
}

Compiler output:
In file included from /usr/include/c++/14/bits/stl_algobase.h:71,
                 from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'constexpr bool __gnu_cxx::__ops::_Iter_comp_iter<_Compare>::operator()(_Iterator1, _Iterator2) [with _Iterator1 = long long int*; _Iterator2 = long long int*; _Compare = long long int]':
/usr/include/c++/14/bits/stl_algo.h:5626:12:   required from 'constexpr _ForwardIterator std::__max_element(_ForwardIterator, _ForwardIterator, _Compare) [with _ForwardIterator = long long int*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<long long int>]'
 5626 |         if (__comp(__result, __first))
      |             ~~~~~~^~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:5677:43:   required from 'constexpr _FIter std::max_element(_FIter, _FIter, _Compare) [with _FIter = long long int*; _Compare = long long int]'
 5677 |       return _GLIBCXX_STD_A::__max_element(__first, __last,
      |                                           ^
a.cc:17:23:   required from here
   17 |   cout << *max_element(dp, dp + W + 1, 0ll) << endl;
      |            ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/predefined_ops.h:158:30: error: expression cannot be used as a function
  158 |         { return bool(_M_comp(*__it1, *__it2)); }
      |                       ~~~~~~~^~~~~~~~~~~~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
ll dp[100005];
int w[105], v[105];
      
int main() {
  int n, W; cin >> n >> W;
  for (int i = 0; i < n; i++)
   	cin >> w[i] >> v[i];
  for (int i = 1; i <= W; i++)
   	for (int j = 0; j < n; j++)
      if (i - w[j] >= 0)
        dp[i] = max(dp[i], dp[i - w[j]] + v[j]);
  cout << *max_element(dp, dp + W + 1, 0ll) << endl;
}

Compiler output:
In file included from /usr/include/c++/14/bits/stl_algobase.h:71,
                 from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'constexpr bool __gnu_cxx::__ops::_Iter_comp_iter<_Compare>::operator()(_Iterator1, _Iterator2) [with _Iterator1 = long long int*; _Iterator2 = long long int*; _Compare = long long int]':
/usr/include/c++/14/bits/stl_algo.h:5626:12:   required from 'constexpr _ForwardIterator std::__max_element(_ForwardIterator, _ForwardIterator, _Compare) [with _ForwardIterator = long long int*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<long long int>]'
 5626 |         if (__comp(__result, __first))
      |             ~~~~~~^~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:5677:43:   required from 'constexpr _FIter std::max_element(_FIter, _FIter, _Compare) [with _FIter = long long int*; _Compare = long long int]'
 5677 |       return _GLIBCXX_STD_A::__max_element(__first, __last,
      |                                           ^
a.cc:16:23:   required from here
   16 |   cout << *max_element(dp, dp + W + 1, 0ll) << endl;
      |            ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/predefined_ops.h:158:30: error: expression cannot be used as a function
  158 |         { return bool(_M_comp(*__it1, *__it2)); }
      |                       ~~~~~~~^~~~~~~~~~~~~~~~
Language: C++

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

ll dp[100005];
int w[105], v[105];
      
int main() {
  int n, W; cin >> n >> W;
  for (int i = 0; i < n; i++)
   	cin >> w[i] >> v[i];
  for (int i = 1; i <= W; i++)
   	for (int j = 0; j < n; j++)
      if (i - w[j] >= 0)
        dp[i] = max(dp[i], dp[i - w[j]] + v[j]);
  cout << *max_element(dp, dp + W + 1, 0) << endl;
}

Compiler output:
In file included from /usr/include/c++/14/bits/stl_algobase.h:71,
                 from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'constexpr bool __gnu_cxx::__ops::_Iter_comp_iter<_Compare>::operator()(_Iterator1, _Iterator2) [with _Iterator1 = long long int*; _Iterator2 = long long int*; _Compare = int]':
/usr/include/c++/14/bits/stl_algo.h:5626:12:   required from 'constexpr _ForwardIterator std::__max_element(_ForwardIterator, _ForwardIterator, _Compare) [with _ForwardIterator = long long int*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<int>]'
 5626 |         if (__comp(__result, __first))
      |             ~~~~~~^~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:5677:43:   required from 'constexpr _FIter std::max_element(_FIter, _FIter, _Compare) [with _FIter = long long int*; _Compare = int]'
 5677 |       return _GLIBCXX_STD_A::__max_element(__first, __last,
      |                                           ^
a.cc:16:23:   required from here
   16 |   cout << *max_element(dp, dp + W + 1, 0) << endl;
      |            ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/predefined_ops.h:158:30: error: expression cannot be used as a function
  158 |         { return bool(_M_comp(*__it1, *__it2)); }
      |                       ~~~~~~~^~~~~~~~~~~~~~~~
Language: C++

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

vector< pair<long, long> > wv;
long dp[101][100001];

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

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: In function 'void knapsack(int, int)':
a.cc:14:40: error: no match for 'operator[]' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::pair<long int, long int> >, std::pair<long int, long int> >::value_type' {aka 'std::pair<long int, long int>'} and 'int')
   14 |                         else if(wv[i-1][0] <= w)
      |                                        ^
a.cc:15:55: error: no match for 'operator[]' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::pair<long int, long int> >, std::pair<long int, long int> >::value_type' {aka 'std::pair<long int, long int>'} and 'int')
   15 |                                 dp[i][w] = max(wv[i-1][1] + dp[i-1][w-wv[i-1][0]], dp[i-1][w]);
      |                                                       ^
a.cc:15:78: error: no match for 'operator[]' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::pair<long int, long int> >, std::pair<long int, long int> >::value_type' {aka 'std::pair<long int, long int>'} and 'int')
   15 |                                 dp[i][w] = max(wv[i-1][1] + dp[i-1][w-wv[i-1][0]], dp[i-1][w]);
      |                                                                              ^
Language: C++

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

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

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

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:5:9: error: 'n' was not declared in this scope; did you mean 'yn'?
    5 | long dp[n+1][w+1];
      |         ^
      |         yn
a.cc:5:14: error: 'w' was not declared in this scope; did you mean 'wv'?
    5 | long dp[n+1][w+1];
      |              ^
      |              wv
a.cc: In function 'void knapsack(int, int)':
a.cc:13:33: error: 'dp' was not declared in this scope; did you mean 'dup'?
   13 |                                 dp[i][w] = 0;
      |                                 ^~
      |                                 dup
a.cc:14:40: error: no match for 'operator[]' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::pair<long int, long int> >, std::pair<long int, long int> >::value_type' {aka 'std::pair<long int, long int>'} and 'int')
   14 |                         else if(wv[i-1][0] <= w)
      |                                        ^
a.cc:15:33: error: 'dp' was not declared in this scope; did you mean 'dup'?
   15 |                                 dp[i][w] = max(wv[i-1][1] + dp[i-1][w-wv[i-1][0]], dp[i-1][w]);
      |                                 ^~
      |                                 dup
a.cc:15:55: error: no match for 'operator[]' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::pair<long int, long int> >, std::pair<long int, long int> >::value_type' {aka 'std::pair<long int, long int>'} and 'int')
   15 |                                 dp[i][w] = max(wv[i-1][1] + dp[i-1][w-wv[i-1][0]], dp[i-1][w]);
      |                                                       ^
a.cc:15:78: error: no match for 'operator[]' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::pair<long int, long int> >, std::pair<long int, long int> >::value_type' {aka 'std::pair<long int, long int>'} and 'int')
   15 |                                 dp[i][w] = max(wv[i-1][1] + dp[i-1][w-wv[i-1][0]], dp[i-1][w]);
      |                                                                              ^
a.cc:17:18: error: 'dp' was not declared in this scope; did you mean 'dup'?
   17 |                  dp[i][w] = dp[i-1][w];
      |                  ^~
      |                  dup
a.cc:19:17: error: 'dp' was not declared in this scope; did you mean 'dup'?
   19 |         cout << dp[n][W] << endl;
      |                 ^~
      |                 dup
Language: C++

#include <string.h>
#include<iostream>
#include<vector>
#define ll long long
using namespace std;


const int MAX_N=100;
const int MAX_W=100000;
const ll MAX_V=1000000000;

ll weight[MAX_N],value[MAX_N];
 N,W;

cont ll INF=1LL<<60;

ll dp[MAX_N][MAX_W];

/*
    品0-iまでで重量sum_w以下となるときの最大価値をdpに保存
    return でdp[i][sum_w]　を返すことで部分問題に分解する
 */
ll rec(ll i,ll sum_w)
{
    if(dp[i][sum_w]!=-1) return dp[i][sum_w];

    //重量的に品iを選択できるとき
    if(W-sum_w-weight[i]>=0)
    {
        /*
            (i非選択)品i-1まででsum_w以下最大価値と
            (i選択)品i-1まででsum_w-weight[i]以下の最大価値+品iの価値
            の比較をして大きい方を取る
         */
        dp[i][sum_w]=max(rec(i-1,sum_w),rec(i-1,sum_w-weight[i])+value[i]);
    }
    /*
        品iを選ぶ重量的余裕がなければ
        (i非選択)品i-1まででsum_w以下最大価値
        のみとりうる
    */
    else dp[i][sum_w]=rec(i-1,sum_w);

    return dp[i][sum_w];


}

int main()
{
    memset(dp,-1,sizeof(dp));

    cin>>N>>W;

    for(int i=0;i<N;++i)
    {
        cin>>weight[i]>>value[i];
    }

    cout<<rec(N,0)<<endl;
}

Compiler output:
a.cc:13:2: error: 'N' does not name a type
   13 |  N,W;
      |  ^
a.cc:15:1: error: 'cont' does not name a type; did you mean 'const'?
   15 | cont ll INF=1LL<<60;
      | ^~~~
      | const
a.cc: In function 'long long int rec(long long int, long long int)':
a.cc:28:8: error: 'W' was not declared in this scope
   28 |     if(W-sum_w-weight[i]>=0)
      |        ^
a.cc: In function 'int main()':
a.cc:53:10: error: 'N' was not declared in this scope
   53 |     cin>>N>>W;
      |          ^
a.cc:53:13: error: 'W' was not declared in this scope
   53 |     cin>>N>>W;
      |             ^
Language: C++

//  Created by liszt on 2019/07/28.
#include<bits/stdc++.h>
using namespace std;

int main(){
    int n,w; cin>>n >>w;
    long long w[110],v[110];
    
    long long dp[110][100100]={0};
    
    for(int i=0;i<n;i++)cin>>w[i] >>v[i];
    
    for(int i=0;i<n;i++){
        for(int sum_w=0;sum_w<=w;sum_w++){
            
            if(sum_w-w[i]>=0){
                dp[i][sum_w]=max(dp[i+1][sum_w],dp[i][sum_w-w[i]]+v[i]);
            }else{
                dp[i][sum_w]=max(dp[i+1][sum_w],dp[i][sum_w]);
            }
            
        }
    }
    
    cout<<dp[n][w]<<endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:15: error: conflicting declaration 'long long int w [110]'
    7 |     long long w[110],v[110];
      |               ^
a.cc:6:11: note: previous declaration as 'int w'
    6 |     int n,w; cin>>n >>w;
      |           ^
a.cc:11:31: error: invalid types 'int[int]' for array subscript
   11 |     for(int i=0;i<n;i++)cin>>w[i] >>v[i];
      |                               ^
a.cc:16:23: error: invalid types 'int[int]' for array subscript
   16 |             if(sum_w-w[i]>=0){
      |                       ^
a.cc:17:62: error: invalid types 'int[int]' for array subscript
   17 |                 dp[i][sum_w]=max(dp[i+1][sum_w],dp[i][sum_w-w[i]]+v[i]);
      |                                                              ^
Language: C++

#include<iostream>
#include<algorithm>
using namespace std;
const int MAXN=100000;
long long w[MAXN],v[MAXN],f[MAXN];
long ans;
int main()
{
	int n,m;
	cin>>n>>m;
	for(int i=0;i<n;i++)
	{
		cin>>w[i]>>v[i];
	}
	for(int i=0;i<n;i++)
	{
		for(int j=m;j>=w[i];j--)
		{
			f[j]=max(f[j],f[j-w[i]]+v[i]);
			ans=max(f[j],ans);
		}
	}
	cout<<ans;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:32: error: no matching function for call to 'max(long long int&, long int&)'
   20 |                         ans=max(f[j],ans);
      |                             ~~~^~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:20:32: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'long int')
   20 |                         ans=max(f[j],ans);
      |                             ~~~^~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:20:32: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   20 |                         ans=max(f[j],ans);
      |                             ~~~^~~~~~~~~~
Language: C++

#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>
#define ll long long
#define ull unsigned long long
using namespace std;

ll main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll n, W;
    cin >> n >> W;
    vector<vector<ll>> dp(n, vector<ll>(W + 1));
    ll weight, value;
    cin >> weight >> value;
    fill(dp[0].begin() + weight, dp[0].end(), value);
    for (ll items = 1; items < n; items++){
        cin >> weight >> value;
        for (ll i = 0; i <= W; i++){
            if (i >= weight) dp[items][i] = max(dp[items - 1][i - weight] + value, dp[items - 1][i]);
            else dp[items][i] = dp[items - 1][i];
        }
    }
    cout << dp.back().back();
    return 0;
}

Compiler output:
cc1plus: error: '::main' must return 'int'
Language: C++

#include <iostream>
#include <string>
#include <vector>

void knapsack1(){
    vector<item> items;
    int n, w;
    cin >> n >> w;
    int maxVal[n + 1][w + 1];
    for (int i = 0; i < n; i++) {
        int wt, vl;
        cin >> wt >> vl;
        items.push_back({wt, vl});
    }
    for (int i = 0; i <= w; i++){
        maxVal[0][i] = 0;
    }
    for (int i = 0; i <= n; i++){
        maxVal[i][0] = 0;
    }
    for (int i = 1; i <= n; i++){
        for (int j = 1; j <= w; j++) {
            if (j < items[i].w)
                maxVal[i][j] = maxVal[i - 1][j];
            else
                maxVal[i][j] = max(maxVal[i - 1][j], maxVal[i - 1][j - items[i].w] + items[i].v);
        }
    }
    cout << maxVal[n][w];
}

int main() {
    knapsack1();
}

Compiler output:
a.cc: In function 'void knapsack1()':
a.cc:6:5: error: 'vector' was not declared in this scope
    6 |     vector<item> items;
      |     ^~~~~~
a.cc:6:5: note: suggested alternatives:
In file included from /usr/include/c++/14/vector:66,
                 from a.cc:3:
/usr/include/c++/14/bits/stl_vector.h:428:11: note:   'std::vector'
  428 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
/usr/include/c++/14/vector:93:13: note:   'std::pmr::vector'
   93 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
a.cc:6:12: error: 'item' was not declared in this scope; did you mean 'tm'?
    6 |     vector<item> items;
      |            ^~~~
      |            tm
a.cc:6:18: error: 'items' was not declared in this scope
    6 |     vector<item> items;
      |                  ^~~~~
a.cc:8:5: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
    8 |     cin >> n >> w;
      |     ^~~
      |     std::cin
In file included from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:26:32: error: 'max' was not declared in this scope; did you mean 'std::max'?
   26 |                 maxVal[i][j] = max(maxVal[i - 1][j], maxVal[i - 1][j - items[i].w] + items[i].v);
      |                                ^~~
      |                                std::max
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41:
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: 'std::max' declared here
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
a.cc:29:5: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   29 |     cout << maxVal[n][w];
      |     ^~~~
      |     std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
Language: Java

/*
Roses are red
Memes are neat
All my test cases time out
Lmao yeet
**************************
Time to solve: 
*/
import java.util.*;
import java.io.*;

   public class D
   {
      public static void main(String args[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));  
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int N = Integer.parseInt(st.nextToken());
         int W = Integer.parseInt(st.nextToken());
         int[] arr = new int[N];
         int[] arr2 = new int[N];
         for(int i=0; i < N; i++)
         {
            st = new StringTokenizer(infile.readLine());
            arr[i] = Integer.parseInt(st.nextToken());
            arr2[i] = Integer.parseInt(st.nextToken());
         }
         long res = knapSack(W, arr, arr2, N);
         System.out.println(res);
      }
      public static long knapSack(int W, int wt[], int val[], int n) 
       { 
            int i, w; 
           long K[][] = new long[n+1][W+1]; 
           // Build table K[][] in bottom up manner 
           for (i = 0; i <= n; i++) 
           { 
               for (w = 0; w <= W; w++) 
               { 
                   if (i==0 || w==0) 
                        K[i][w] = 0; 
                   else if (wt[i-1] <= w) 
                         K[i][w] = Math.max(val[i-1] + K[i-1][w-wt[i-1]],  K[i-1][w]); 
                   else
                         K[i][w] = K[i-1][w]; 
               } 
            } 
            return K[n][W]; 
       } 
   }
   

Compiler output:
Main.java:12: error: class D is public, should be declared in a file named D.java
   public class D
          ^
1 error
Language: Java


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class DKnapscak1 {
    static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		
		int n = sc.nextInt();
		int w = sc.nextInt();
		int[] weights = new int[n];
		int[] values = new int[n];
		long[][] dp = new long[n+1][w+1];
		
		for (int i = 0; i < n; i++) {
			weights[i] = sc.nextInt();
			values[i] = sc.nextInt();
		}
		
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= w; j++) {
				if (j >= weights[i-1]) {
					dp[i][j] = Math.max(dp[i-1][j], dp[i-1][j - weights[i-1]] + values[i-1]);
				} else {
					dp[i][j] = dp[i-1][j];
				}
			}
		}
		
		System.out.println(dp[n][w]);

	}

}


Compiler output:
Main.java:7: error: class DKnapscak1 is public, should be declared in a file named DKnapscak1.java
public class DKnapscak1 {
       ^
1 error
Language: Java

import java.util.Scanner;

public class DKnapscak1 {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int w = sc.nextInt();
		int[] weights = new int[n];
		int[] values = new int[n];
		int[][] dp = new int[n+1][w+1];
		
		for (int i = 0; i < n; i++) {
			weights[i] = sc.nextInt();
			values[i] = sc.nextInt();
		}
		
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= w; j++) {
				if (j >= weights[i-1]) {
					dp[i][j] = Math.max(dp[i-1][j], dp[i-1][j - weights[i-1]] + values[i-1]);
				} else {
					dp[i][j] = dp[i-1][j];
				}
			}
		}
		
		System.out.println(dp[n][w]);
		
		sc.close();
	}

}


Compiler output:
Main.java:3: error: class DKnapscak1 is public, should be declared in a file named DKnapscak1.java
public class DKnapscak1 {
       ^
1 error
Language: C++

#include#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll dp[200005];
int main(){
    ll n,w;cin>>n>>w;
    ll weights[200005];
    ll prices[200005];
    for(ll i=0;i<n;i++){
        cin>>weights[i]>>prices[i];
    }

    

    for(ll i=0;i<n;i++){
        for(ll u=w;u>=weights[i];u--){
            dp[u]=max(dp[u],prices[i]+dp[u-weights[i]]);
        }
    }
    ll ans=0;
    for(ll i=0;i<=w;i++){
        ans=max(ans,dp[i]);
    }
    cout<<ans;
}

Compiler output:
a.cc:1:9: error: #include expects "FILENAME" or <FILENAME>
    1 | #include#include<bits/stdc++.h>
      |         ^
a.cc: In function 'int main()':
a.cc:6:12: error: 'cin' was not declared in this scope
    6 |     ll n,w;cin>>n>>w;
      |            ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | #include#include<bits/stdc++.h>
a.cc:17:19: error: 'max' was not declared in this scope
   17 |             dp[u]=max(dp[u],prices[i]+dp[u-weights[i]]);
      |                   ^~~
a.cc:22:13: error: 'max' was not declared in this scope
   22 |         ans=max(ans,dp[i]);
      |             ^~~
a.cc:24:5: error: 'cout' was not declared in this scope
   24 |     cout<<ans;
      |     ^~~~
a.cc:24:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
Language: C++

//
// Created by sark2 on 07-07-2019.
//

#include "bits/stdc++.h"

using namespace std;
#define IOS cin.sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define cases int t;cin>>t;while(t--)
typedef long double ld;
int Knapsack(int n, int W, int wt[], long long int p[]){

    int dp[n+1][W+1];

    for(int i = 0; i <= W; i++)dp[0][i] = 0;

    for(int i = 0; i <= n; i++)dp[i][0] = 0;

    for(int i = 1; i <= n; i++){
        for(int  j = 1; j <= W; j++){

            dp[i][j] = dp[i-1][j];
            if(j >= wt[i]){
                dp[i][j] = max(dp[i][j], dp[i-1][j-wt[i]] + p[i]);
            }
         /*   cout<<dp[i][j]<<" ";*/
        }
        /*cout<<endl;*/
    }

    return dp[n][W];
}

int main() {
    IOS


     int n;
     cin>>n;
     int W;
     cin>>W;
     int wt[n+1];
     long long int p[n+1];
        for(int i = 1; i <= n; i++)cin>>wt[i]>>p[i];
    
     cout<<Knapsack(n,W,wt,p);
}


Compiler output:
a.cc: In function 'int Knapsack(int, int, int*, long long int*)':
a.cc:24:31: error: no matching function for call to 'max(int&, long long int)'
   24 |                 dp[i][j] = max(dp[i][j], dp[i-1][j-wt[i]] + p[i]);
      |                            ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:5:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:24:31: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   24 |                 dp[i][j] = max(dp[i][j], dp[i-1][j-wt[i]] + p[i]);
      |                            ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:24:31: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   24 |                 dp[i][j] = max(dp[i][j], dp[i-1][j-wt[i]] + p[i]);
      |                            ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
using namespace std;

int main(){
  int N,W;
  cin>>N>>W;
  long long int W[N+1],V[N+1],DP[N+1][W+1];
  //DP[i][j] i番目までの品物を、重さがj以下になるように選んだ時の価値の最大値
  
  for(int i=0; i<=N; ++i){
    if(i>0) cin>>W[i]>>V[i];
    for(int j=0; j<=W; ++j){
      DP[i][j]=0;
    }
  }
  
  for(int i=1; i<=N; ++i){
    for(int j=0; j<=W; ++j){
      if(j>W[i]) DP[i][j]=max(DP[i-1][j],DP[i-1][j-W[i]]+V[i]);
      else DP[i][j]=DP[i-1][j];
    }
  }
  
  cout<<DP[N][W]<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:13:17: error: conflicting declaration 'long long int W [(N + 1)]'
   13 |   long long int W[N+1],V[N+1],DP[N+1][W+1];
      |                 ^
a.cc:11:9: note: previous declaration as 'int W'
   11 |   int N,W;
      |         ^
a.cc:17:19: error: invalid types 'int[int]' for array subscript
   17 |     if(i>0) cin>>W[i]>>V[i];
      |                   ^
a.cc:25:13: error: invalid types 'int[int]' for array subscript
   25 |       if(j>W[i]) DP[i][j]=max(DP[i-1][j],DP[i-1][j-W[i]]+V[i]);
      |             ^
a.cc:25:53: error: invalid types 'int[int]' for array subscript
   25 |       if(j>W[i]) DP[i][j]=max(DP[i-1][j],DP[i-1][j-W[i]]+V[i]);
      |                                                     ^
Language: C++

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


Compiler output:
a.cc: In function 'int main()':
a.cc:12:7: error: 'dp' was not declared in this scope; did you mean 'dup'?
   12 | cout<<dp[n][W];
      |       ^~
      |       dup
Language: C++

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


Compiler output:
a.cc: In function 'int main()':
a.cc:9:10: error: no matching function for call to 'std::vector<std::vector<long long int> >::assign(int, std::vector<int>)'
    9 | dp.assign(n+1,vector<int> (W+1,0));
      | ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/vector:66,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_vector.h:828:9: note: candidate: 'template<class _InputIterator, class> void std::vector<_Tp, _Alloc>::assign(_InputIterator, _InputIterator) [with <template-parameter-2-2> = _InputIterator; _Tp = std::vector<long long int>; _Alloc = std::allocator<std::vector<long long int> >]'
  828 |         assign(_InputIterator __first, _InputIterator __last)
      |         ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:828:9: note:   template argument deduction/substitution failed:
a.cc:9:10: note:   deduced conflicting types for parameter '_InputIterator' ('int' and 'std::vector<int>')
    9 | dp.assign(n+1,vector<int> (W+1,0));
      | ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:808:7: note: candidate: 'void std::vector<_Tp, _Alloc>::assign(size_type, const value_type&) [with _Tp = std::vector<long long int>; _Alloc = std::allocator<std::vector<long long int> >; size_type = long unsigned int; value_type = std::vector<long long int>]'
  808 |       assign(size_type __n, const value_type& __val)
      |       ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:808:47: note:   no known conversion for argument 2 from 'std::vector<int>' to 'const std::vector<std::vector<long long int> >::value_type&' {aka 'const std::vector<long long int>&'}
  808 |       assign(size_type __n, const value_type& __val)
      |                             ~~~~~~~~~~~~~~~~~~^~~~~
/usr/include/c++/14/bits/stl_vector.h:855:7: note: candidate: 'void std::vector<_Tp, _Alloc>::assign(std::initializer_list<_Tp>) [with _Tp = std::vector<long long int>; _Alloc = std::allocator<std::vector<long long int> >]'
  855 |       assign(initializer_list<value_type> __l)
      |       ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:855:7: note:   candidate expects 1 argument, 2 provided
Language: C++

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

using ll = long long;
const ll inf = 1e18;
const int  N = 1e5 + 10;

ll n, W;
ll dp[102][N];

std::vector<pair<ll, ll>> v;
ll go(ll idx, ll pick){
	if(idx == v.size()) return 0;
	if(dp[idx][pick] != -1)return dp[idx][pick];
	ll xx = -inf, yy = -inf;
	if(pic + v[idx].second <= W)
	xx = v[idx].second + go(idx + 1, pick + v[idx].first);
	yy = go(idx + 1, pick);
	return dp[idx][pick] = max(xx, yy);
}
int main(int argc, char const *argv[]){
	
	cin >> n >> W;
	for (int i = 0; i < n; ++i){
		ll x, y;
		cin >> x >> y;
		v.push_back({x, y});
	}
	sort(v.begin(), v.end());
	memset(dp, -1, sizeof dp);
	cout << go(0, 0);
	return 0;
}

Compiler output:
a.cc: In function 'll go(ll, ll)':
a.cc:16:12: error: 'pic' was not declared in this scope; did you mean 'pick'?
   16 |         if(pic + v[idx].second <= W)
      |            ^~~
      |            pick
Language: C++

#include "bits/stdc++.h"
using namespace std;
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define N           100001
#define rep(i,a,b)  for(int i=a;i<b;i++)
typedef long long ll;
void self_max(ll  &a, ll b) {
        a = max(a, b);
}
int main() {
        int n, w;
        cin>>n>>w; 
        vector<ll> dp(w + 1); 
        for(int i = 0; i < n; ++i) {
                int weight, value;
                cin>>weight>> value;
                for(int wt = w - weight;   wt >= 0; wt--) {
                        if(!wt || dp[wt])
                                self_max(dp[wt + weight], dp[wt] + value);
                }
        }
        ll ans = 0;
        rep(i, 0, w + 1)                                                                                                   1,9           Top
               self_max(ans, dp[i]);
        cout<<ans<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:35:127: error: expected ';' before 'Top'
   35 |         rep(i, 0, w + 1)                                                                                                   1,9           Top
      |                                                                                                                               ^          ~~~
      |                                                                                                                               ;
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void self_max(ll  &a, ll b) {
        a = max(a, b);
}
int main() {
        int n, w;
        cin>>n>>w; 
        vector<ll> dp(w + 1); 
        for(int i = 0; i < n; ++i) {
                int weight, value;
                cin>>weight>> value;
                for(int wt = w - weight;   wt >= 0; wt--) {
                        if(!wt || dp[wt])
                                self_max(dp[wt + weight], dp[wt] + value);
                }
        }
        ll ans = 0;
        for(int i = 0; i < w + 1; i++)
                self_max(ans, dp[i]);
        cout<<ans<<endl;
}       
~

Compiler output:
a.cc:24:2: error: expected class-name at end of input
   24 | ~
      |  ^
Language: C++

import java.util.Scanner;
public class knapSack{
	public static void main(String[] args){
		Scanner input = new Scanner(System.in);
		int N = input.nextInt();
		int W = input.nextInt();

		int[] weights = new int[N];
		int[] values = new int[N];

		for(int i = 0; i < N; i++){
			weights[i] = input.nextInt();
			values[i] = input.nextInt();
		}

		long[][] memo = new long[N+1][W+1];

		for(int i = 1; i < N+1; i++){
			for(int j = 0; j <= W; j++){
				if(weights[i-1] <= j) memo[i][j] = Math.max(memo[i-1][j], memo[i-1][j-weights[i-1]] + values[i-1]);
				else memo[i][j] = memo[i-1][j];
			}
		}

		System.out.println(memo[N][W]);
	}
}

Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import java.util.Scanner;
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:2:1: error: expected unqualified-id before 'public'
    2 | public class knapSack{
      | ^~~~~~
Language: C++

#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int N;
ll W, weight[110], value[110];
ll dp[110][100100] = {0};
 
int main() {
    cin >> N >> W;
    rep(i, N) {
        cin >> weight[i] >> value[i];
    }

    rep(i, N) {
        for(int sum_w = 0; sum_w <= W; sum_w++) {
            if(sum_w - weight[i] >= 0) {
                chmax(dp[i+1][sum_w], dp[i][sum_w - weight] + value[i]);
            }

            chmax(dp[i+1][sum_w], dp[i][sum_w]);
        }
    }

    cout << dp[N][W];
    
    cout << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:51: error: invalid operands of types 'int' and 'll [110]' {aka 'long long int [110]'} to binary 'operator-'
   26 |                 chmax(dp[i+1][sum_w], dp[i][sum_w - weight] + value[i]);
      |                                             ~~~~~ ^ ~~~~~~
      |                                             |       |
      |                                             int     ll [110] {aka long long int [110]}