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

#include <iostream>
using namespace std;
int dp[101][100001];
int max(int a,int b){
  return (a>b)?a:b;
}
int knapsack(int v[],int w[],int n,int c){
  if(dp[n-1][c]!=0)
    return dp[n-1][c];
  if(n==0 || c==0)
    return 0;
  else if(w[n-1]>c){
    dp[n-1][c] = knapsack(v,w,n-1,c);
    return dp[n-1][c];
  }
  dp[n-1][c] = max(knapsack(v,w,n-1,c),v[n-1]+knapsack(v,w,n-1,c-w[n-1]));
  return dp[n-1][c];
}
int main(){
  ios::sync_with_sydio(false);
  cin.tie(NULL);
  cin.tie(NULL);
  int n,c;
  cin >> n >> c;
  int w[n],v[n];
  for(int i=0;i<n;i++){
  	cin >> w[i];
    cin >> v[i];
  }
  for(int i=0;i<n;i++){
  for(int j=0;j<=c;j++){
    dp[i][j]=0;
  }
     }
  knapsack(v,w,n,c);
  cout << dp[n-1][c] << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:20:8: error: 'sync_with_sydio' is not a member of 'std::ios' {aka 'std::basic_ios<char>'}
   20 |   ios::sync_with_sydio(false);
      |        ^~~~~~~~~~~~~~~
Language: C++

#include <iostream>
using namespace std;
int dp[101][1000000001];
int max(int a,int b){
  return (a>b)?a:b;
}
int knapsack(int v[],int w[],int n,int c){
  if(dp[n-1][c]!=0)
    return dp[n-1][c];
  if(n==0 || c==0)
    return 0;
  else if(w[n-1]>c){
    dp[n-1][c] = knapsack(v,w,n-1,c);
    return dp[n-1][c];
  }
  dp[n-1][c] = max(knapsack(v,w,n-1,c),v[n-1]+knapsack(v,w,n-1,c-w[n-1]));
  return dp[n-1][c];
}
int main(){
  ios::sync_with_sydio(false);
  cin.tie(NULL);
  cin.tie(NULL);
  int n,c;
  cin >> n >> c;
  int w[n],v[n];
  for(int i=0;i<n;i++){
  	cin >> w[i];
    cin >> v[i];
  }
  for(int i=0;i<n;i++){
  for(int j=0;j<=c;j++){
    dp[i][j]=0;
  }
     }
  knapsack(v,w,n,c);
  cout << dp[n-1][c] << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:20:8: error: 'sync_with_sydio' is not a member of 'std::ios' {aka 'std::basic_ios<char>'}
   20 |   ios::sync_with_sydio(false);
      |        ^~~~~~~~~~~~~~~
Language: C++

#include <iostream>
using namespace std;
int dp[101][101];
int max(int a,int b){
  return (a>b)?a:b;
}
int knapsack(int v[],int w[],int n,int c){
  if(dp[n-1][c]!=0)
    return dp[n-1][c];
  if(n==0 || c==0)
    return 0;
  else if(w[n-1]>c){
    dp[n-1][c] = knapsack(v,w,n-1,c);
    return dp[n-1][c];
  }
  dp[n-1][c] = max(knapsack(v,w,n-1,c),v[n-1]+knapsack(v,w,n-1,c-w[n-1]));
  return dp[n-1][c];
}
int main(){
  ios::sync_with_sydio(false);
  cin.tie(NULL);
  cin.tie(NULL);
  int n,c;
  cin >> n >> c;
  int w[n],v[n];
  for(int i=0;i<n;i++){
  	cin >> w[i];
    cin >> v[i];
  }
  for(int i=0;i<n;i++){
  for(int j=0;j<=c;j++){
    dp[i][j]=0;
  }
     }
  knapsack(v,w,n,c);
  cout << dp[n-1][c] << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:20:8: error: 'sync_with_sydio' is not a member of 'std::ios' {aka 'std::basic_ios<char>'}
   20 |   ios::sync_with_sydio(false);
      |        ^~~~~~~~~~~~~~~
Language: C++

#include <iostream>
using namespace std;
int dp[101][1000000001];
int max(int a,int b){
  return (a>b)?a:b;
}
int knapsack(int v,int w,int n,int c){
  if(dp[n-1][c]!=0)
    return dp[n-1][c];
  if(n==0 || c==0)
    return 0;
  else if(w[n-1]>c){
    dp[n-1][c] = knapsack(v,w,n-1,c);
    return dp[n-1][c];
  }
  dp[n-1][c] = max(knapsack(v,w,n-1,c),v[n-1]+knapsack(v,w,n-1,c-w[n-1]));
  return dp[n-1][c];
}
int main(){
  int n,c;
  cin >> n >> c;
  int w[n],v[n];
  for(int i=0;i<n;i++){
  	cin >> w[i];
    cin >> v[i];
  }
  for(int i=0;i<n;i++){
  for(int j=0;j<=c;j++){
    dp[i][j]=0;
  }
     }
  knapsack(v,w,n,c);
  cout << dp[n-1][c] << emdl;
  return 0;
}


Compiler output:
a.cc: In function 'int knapsack(int, int, int, int)':
a.cc:12:12: error: invalid types 'int[int]' for array subscript
   12 |   else if(w[n-1]>c){
      |            ^
a.cc:16:41: error: invalid types 'int[int]' for array subscript
   16 |   dp[n-1][c] = max(knapsack(v,w,n-1,c),v[n-1]+knapsack(v,w,n-1,c-w[n-1]));
      |                                         ^
a.cc:16:67: error: invalid types 'int[int]' for array subscript
   16 |   dp[n-1][c] = max(knapsack(v,w,n-1,c),v[n-1]+knapsack(v,w,n-1,c-w[n-1]));
      |                                                                   ^
a.cc: In function 'int main()':
a.cc:32:12: error: invalid conversion from 'int*' to 'int' [-fpermissive]
   32 |   knapsack(v,w,n,c);
      |            ^
      |            |
      |            int*
a.cc:7:18: note:   initializing argument 1 of 'int knapsack(int, int, int, int)'
    7 | int knapsack(int v,int w,int n,int c){
      |              ~~~~^
a.cc:32:14: error: invalid conversion from 'int*' to 'int' [-fpermissive]
   32 |   knapsack(v,w,n,c);
      |              ^
      |              |
      |              int*
a.cc:7:24: note:   initializing argument 2 of 'int knapsack(int, int, int, int)'
    7 | int knapsack(int v,int w,int n,int c){
      |                    ~~~~^
a.cc:33:25: error: 'emdl' was not declared in this scope
   33 |   cout << dp[n-1][c] << emdl;
      |                         ^~~~
Language: C++

#include <iostream>
using namespace std;
int dp[101][1000000001];
int max(int a,int b){
  return (a>b)?a:b;
}
int knapsack(int v,int w,int n,int c){
  if(dp[n-1][c]!=0)
    return dp[n-1][c];
  if(n==0 || c==0)
    return 0;
  else if(w[n-1]>c){
    dp[n-1][c] = knapsack(v,w,n-1,c);
    return dp[n-1][c];
  }
  dp[n-1][c] = max(knapsack(v,w,n-1,c),v[n-1]+knapsack(v,w,n-1,c-w[n-1]));
  return dp[n-1][c];
}
int main(){
  cin >> n >> c;
  int w[n],v[n];
  for(int i=0;i<n;i++){
  	cin >> w[i];
    cin >> v[i];
  }
  for(int i=0;i<n;i++){
  for(int j=0;j<=c;j++){
    dp[i][j]=0;
  }
     }
  knapsack(v,w,n,c);
  cout << dp[n-1][c] << emdl;
  return 0;
}

Compiler output:
a.cc: In function 'int knapsack(int, int, int, int)':
a.cc:12:12: error: invalid types 'int[int]' for array subscript
   12 |   else if(w[n-1]>c){
      |            ^
a.cc:16:41: error: invalid types 'int[int]' for array subscript
   16 |   dp[n-1][c] = max(knapsack(v,w,n-1,c),v[n-1]+knapsack(v,w,n-1,c-w[n-1]));
      |                                         ^
a.cc:16:67: error: invalid types 'int[int]' for array subscript
   16 |   dp[n-1][c] = max(knapsack(v,w,n-1,c),v[n-1]+knapsack(v,w,n-1,c-w[n-1]));
      |                                                                   ^
a.cc: In function 'int main()':
a.cc:20:10: error: 'n' was not declared in this scope
   20 |   cin >> n >> c;
      |          ^
a.cc:20:15: error: 'c' was not declared in this scope
   20 |   cin >> n >> c;
      |               ^
a.cc:23:16: error: 'w' was not declared in this scope
   23 |         cin >> w[i];
      |                ^
a.cc:24:12: error: 'v' was not declared in this scope
   24 |     cin >> v[i];
      |            ^
a.cc:31:12: error: 'v' was not declared in this scope
   31 |   knapsack(v,w,n,c);
      |            ^
a.cc:31:14: error: 'w' was not declared in this scope
   31 |   knapsack(v,w,n,c);
      |              ^
a.cc:32:25: error: 'emdl' was not declared in this scope
   32 |   cout << dp[n-1][c] << emdl;
      |                         ^~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define puts(i) cout<<i<<endl
#define pi 3.14159265358979323846264338
#define pb push_back
#define mp make_pair
#define INF 1e9
using ll = long long;
using P = pair<int,int>;
using Pll = pair<ll,ll>;

ll divisor=1000000007;

int main(){
	ll n,W;
	cin>>n>>W;
	ll w[n],v[n];
	rep(i,n)cin>>w[i]>>v[i];
	ll v_max=0;
	rep(i,n)v_max+=v[i];
	vector<ll> dp(v_max+1,INF);
	dp[0]=0;
	rep(i,n){
		for(ll j=v_max;j>=v[i];j--){
			dp[j]=min(dp[j],dp[j-v[i]]+w[i]);
		}
	}
	ll answer=0;
	rep(i,v_max+1){
		if(dp[i]<=W){
			answer=max(answer,i);
		}
	}
	puts(answer);
	
}


Compiler output:
a.cc: In function 'int main()':
a.cc:32:35: error: no matching function for call to 'max(ll&, int&)'
   32 |                         answer=max(answer,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: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:32:35: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   32 |                         answer=max(answer,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:32:35: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   32 |                         answer=max(answer,i);
      |                                ~~~^~~~~~~~~~
Language: C++

N, W = map(int, input().split())
wv = [list(map(int, input().split())) for i in range(N)]
 
table = [[0] * (W+1) for i in range(N+1)]
 
for i in range(1, N+1):
  for j in range(1, W+1):
    if(j - wv[i-1][0] >= 0):
      table[i][j] = max(table[i-1][j], table[i-1][j - wv[i-1][0]] + wv[i-1][1])
    else:
      table[i][j] = table[i-1][j]
 
print(table[N][W])

Compiler output:
a.cc:1:1: error: 'N' does not name a type
    1 | N, W = map(int, input().split())
      | ^
Language: C++

#include<bits/stdc++.h>
#define ll long long
#define f  first
#define s  second
#define Tsetso ios_base::sync_with_stdio(0) ; cin.tie(0) ;
using namespace std;
const int  N = 10050, mod = 1e9+7, inf = 2e9 ;
ll dp[101][N] , mx = 0;
int main()
{
    Tsetso
    ll n, w;
     cin >> n >> w ;
     pair < ll , ll > p[n];
     for ( int i = 0 ; i <n ; i++){
         cin >> p[i].s >> p[i].f ;
         mx += p[i].f ;
     }
     sort(p,p+n) ;
     for ( int i = 0 ; i <= n ; i++)
         for ( int j = 1 ; j <= mx ; j++)
             dp[i][j] = 2e9 ;
     for ( int i = 1 ; i <= n ; i++)
     {
         ll curw = p[i-1].s ;
         ll curv = p[i-1].f ;
         for ( int j = 0 ; j <= mx ; j++)
             dp[i][j] = min(curw+dp[i-1][max(0,j-curv)],dp[i-1][j]);
     }
     int  ans = 0;
     for ( int i = 0 ; i <= mx ; i++)
         if ( dp[n][i] <= w)
                ans = i ;
     cout << ans ;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:28:45: error: no matching function for call to 'max(int, long long int)'
   28 |              dp[i][j] = min(curw+dp[i-1][max(0,j-curv)],dp[i-1][j]);
      |                                          ~~~^~~~~~~~~~
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: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:28:45: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   28 |              dp[i][j] = min(curw+dp[i-1][max(0,j-curv)],dp[i-1][j]);
      |                                          ~~~^~~~~~~~~~
/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:28:45: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   28 |              dp[i][j] = min(curw+dp[i-1][max(0,j-curv)],dp[i-1][j]);
      |                                          ~~~^~~~~~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
 
ll KnapSack(ll val[], ll wt[], ll n, ll W) 
{ 
    // array to store final result 
    //dp[i] stores the profit with KnapSack capacity "i" 
    ll dp[W+1]; 
      
    //initially profit with 0 to W KnapSack capacity is 0 
    memset(dp, 0, sizeof(dp)); 
  
    // iterate through all items 
    for(ll i=0; i < n; i++)  
        //traverse dp array from right to left 
        for(ll j=W; j>=wt[i]; j--) 
            dp[j] = max(dp[j] , val[i] + dp[j-wt[i]]); 
    /*above line finds out maximum of  dp[j](excluding ith element value) 
      and val[i] + dp[j-wt[i]] (including ith element value and the 
      profit with "KnapSack capacity - ith element weight") */    
    return dp[W]; 
} 
 
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ll n,W;
  cin>>n>>W;
  ll w[n], v[n];
  for(ll i=0; i<n; i++){
    cin>>w[i]>>v[i];
  }
  ll ans = knapsack(v, w, n, W);
  cout<<ans<<"\n";   
  return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:35:12: error: 'knapsack' was not declared in this scope; did you mean 'KnapSack'?
   35 |   ll ans = knapsack(v, w, n, W);
      |            ^~~~~~~~
      |            KnapSack
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
int main()
{
    int n;
    cin>>n;
   ll wt[n],p[n],w,v=0;
   cin>>w;
    for(int i=0;i<n;i++){cin>>wt[i];cin>>p[i];v+=p[i];}
    
    ll dp[n+1][v+1]=INT_MAX;
    for(ll i=0;i<=n;i++)
    {
        for(ll j=0;j<=v;j++)
        {
          if(i==0)continue;
            if(j==0)
                dp[i][j]=0;
            else if(j<p[i-1])
                dp[i][j]=dp[i-1][j];
            else
                dp[i][j]=max(dp[i-1][j],dp[i-1][j-p[i-1]]+wt[i-1]);
        }
    }
       ll res=0;
     for(int i=0;i<=v;i++)
     if(dp[n-1][i]<=w)res=dp[n-1][i];
      cout<<res<<endl;
 
}


Compiler output:
a.cc: In function 'int main()':
a.cc:13:21: error: array must be initialized with a brace-enclosed initializer
   13 |     ll dp[n+1][v+1]=INT_MAX;
      |                     ^~~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
int main()
{
    int n;
    cin>>n;
   ll wt[n],p[n],w,v=0;
   cin>>w;
    for(int i=0;i<n;i++){cin>>wt[i];cin>>p[i];v+=p[i};}
    
    ll dp[n+1][v+1]=INT_MAX;
    for(ll i=0;i<=n;i++)
    {
        for(ll j=0;j<=v;j++)
        {
          if(i==0)continue;
            if(j==0)
                dp[i][j]=0;
            else if(j<p[i-1])
                dp[i][j]=dp[i-1][j];
            else
                dp[i][j]=max(dp[i-1][j],dp[i-1][j-p[i-1]]+wt[i-1]);
        }
    }
       ll res=0;
     for(int i=0;i<=v;i++)
     if(dp[n-1][v]<=w)res=dp[n-1][v];
      cout<<res<<endl;
 
}


Compiler output:
a.cc: In function 'int main()':
a.cc:11:53: error: expected ']' before '}' token
   11 |     for(int i=0;i<n;i++){cin>>wt[i];cin>>p[i];v+=p[i};}
      |                                                     ^
      |                                                     ]
a.cc:11:53: error: expected ';' before '}' token
   11 |     for(int i=0;i<n;i++){cin>>wt[i];cin>>p[i];v+=p[i};}
      |                                                     ^
      |                                                     ;
a.cc: At global scope:
a.cc:13:11: error: 'n' was not declared in this scope; did you mean 'yn'?
   13 |     ll dp[n+1][v+1]=INT_MAX;
      |           ^
      |           yn
a.cc:13:16: error: 'v' was not declared in this scope
   13 |     ll dp[n+1][v+1]=INT_MAX;
      |                ^
a.cc:14:5: error: expected unqualified-id before 'for'
   14 |     for(ll i=0;i<=n;i++)
      |     ^~~
a.cc:14:16: error: 'i' does not name a type
   14 |     for(ll i=0;i<=n;i++)
      |                ^
a.cc:14:21: error: 'i' does not name a type
   14 |     for(ll i=0;i<=n;i++)
      |                     ^
a.cc:28:6: error: expected unqualified-id before 'for'
   28 |      for(int i=0;i<=v;i++)
      |      ^~~
a.cc:28:18: error: 'i' does not name a type
   28 |      for(int i=0;i<=v;i++)
      |                  ^
a.cc:28:23: error: 'i' does not name a type
   28 |      for(int i=0;i<=v;i++)
      |                       ^
a.cc:30:7: error: 'cout' does not name a type
   30 |       cout<<res<<endl;
      |       ^~~~
a.cc:32:1: error: expected declaration before '}' token
   32 | }
      | ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
int main()
{
    int n;
    cin>>n;
   ll wt[n],p[n],w,v=0;
   cin>>w;
    for(int i=0;i<n;i++){cin>>wt[i];cin>>p[i];v+=p[i};}
    
    ll dp[n+1][v+1]=INT_MAX;
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=v;j++)
        {
          if(i==0)continue;
            if(j==0)
                dp[i][j]=0;
            else if(j<p[i-1])
                dp[i][j]=dp[i-1][j];
            else
                dp[i][j]=max(dp[i-1][j],dp[i-1][j-p[i-1]]+wt[i-1]);
        }
    }
       ll res=0;
     for(int i=0;i<=v;i++)
     if(dp[n-1][v]<=w)res=dp[n-1][v];
      cout<<res<<endl;
 
}


Compiler output:
a.cc: In function 'int main()':
a.cc:11:53: error: expected ']' before '}' token
   11 |     for(int i=0;i<n;i++){cin>>wt[i];cin>>p[i];v+=p[i};}
      |                                                     ^
      |                                                     ]
a.cc:11:53: error: expected ';' before '}' token
   11 |     for(int i=0;i<n;i++){cin>>wt[i];cin>>p[i];v+=p[i};}
      |                                                     ^
      |                                                     ;
a.cc: At global scope:
a.cc:13:11: error: 'n' was not declared in this scope; did you mean 'yn'?
   13 |     ll dp[n+1][v+1]=INT_MAX;
      |           ^
      |           yn
a.cc:13:16: error: 'v' was not declared in this scope
   13 |     ll dp[n+1][v+1]=INT_MAX;
      |                ^
a.cc:14:5: error: expected unqualified-id before 'for'
   14 |     for(int i=0;i<=n;i++)
      |     ^~~
a.cc:14:17: error: 'i' does not name a type
   14 |     for(int i=0;i<=n;i++)
      |                 ^
a.cc:14:22: error: 'i' does not name a type
   14 |     for(int i=0;i<=n;i++)
      |                      ^
a.cc:28:6: error: expected unqualified-id before 'for'
   28 |      for(int i=0;i<=v;i++)
      |      ^~~
a.cc:28:18: error: 'i' does not name a type
   28 |      for(int i=0;i<=v;i++)
      |                  ^
a.cc:28:23: error: 'i' does not name a type
   28 |      for(int i=0;i<=v;i++)
      |                       ^
a.cc:30:7: error: 'cout' does not name a type
   30 |       cout<<res<<endl;
      |       ^~~~
a.cc:32:1: error: expected declaration before '}' token
   32 | }
      | ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
int main()
{
    int n;
    cin>>n;
   ll wt[n],p[n],w,v=0;
   cin>>w;
    for(int i=0;i<n;i++){cin>>wt[i];cin>>p[i];v+p[i};}
    
    ll dp[n+1][v+1]=1000001;
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=v;j++)
        {
          if(i==0)continue;
            if(j==0)
                dp[i][j]=0;
            else if(j<p[i-1])
                dp[i][j]=dp[i-1][j];
            else
                dp[i][j]=max(dp[i-1][j],dp[i-1][j-p[i-1]]+wt[i-1]);
        }
    }
       ll res=0;
     for(int i=0;i<=v;i++)
     if(dp[n-1][v]<=w)res=dp[n-1][v];
      cout<<res<<endl;
 
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:52: error: expected ']' before '}' token
   11 |     for(int i=0;i<n;i++){cin>>wt[i];cin>>p[i];v+p[i};}
      |                                                    ^
      |                                                    ]
a.cc:11:52: error: expected ';' before '}' token
   11 |     for(int i=0;i<n;i++){cin>>wt[i];cin>>p[i];v+p[i};}
      |                                                    ^
      |                                                    ;
a.cc: At global scope:
a.cc:13:11: error: 'n' was not declared in this scope; did you mean 'yn'?
   13 |     ll dp[n+1][v+1]=1000001;
      |           ^
      |           yn
a.cc:13:16: error: 'v' was not declared in this scope
   13 |     ll dp[n+1][v+1]=1000001;
      |                ^
a.cc:14:5: error: expected unqualified-id before 'for'
   14 |     for(int i=0;i<=n;i++)
      |     ^~~
a.cc:14:17: error: 'i' does not name a type
   14 |     for(int i=0;i<=n;i++)
      |                 ^
a.cc:14:22: error: 'i' does not name a type
   14 |     for(int i=0;i<=n;i++)
      |                      ^
a.cc:28:6: error: expected unqualified-id before 'for'
   28 |      for(int i=0;i<=v;i++)
      |      ^~~
a.cc:28:18: error: 'i' does not name a type
   28 |      for(int i=0;i<=v;i++)
      |                  ^
a.cc:28:23: error: 'i' does not name a type
   28 |      for(int i=0;i<=v;i++)
      |                       ^
a.cc:30:7: error: 'cout' does not name a type
   30 |       cout<<res<<endl;
      |       ^~~~
a.cc:32:1: error: expected declaration before '}' token
   32 | }
      | ^
Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;



int main() {
    string s,t;
    cin >> s;
    cin >> t;
    int tlen = t.length();
    int slen = s.length();
    vector<vector<int>> dp(slen+1, vector<int>(tlen+1));
    // string dp[slen+1][tlen+1];
    // vector< vector<int> > dp(N);

    
    
    rep(i,tlen+1){
        dp[0][i] = "";
    }
    rep(i,slen+1){
        dp[i][0] = "";
    }

    rep(i,slen){
        rep(j,tlen){
            if(s.at(i) == t.at(j)){
                dp[i+1][j+1] = dp[i][j] + s.at(i);
            }else{
                if(dp[i+1][j].length() > dp[i][j+1].length()){
                    dp[i+1][j+1] = dp[i+1][j];
                }else{
                    dp[i+1][j+1] = dp[i][j+1];
                }
            }
        }      
    }
    
    cout << dp[slen][tlen] << endl;
    
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:22:20: error: invalid conversion from 'const char*' to '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} [-fpermissive]
   22 |         dp[0][i] = "";
      |                    ^~
      |                    |
      |                    const char*
a.cc:25:20: error: invalid conversion from 'const char*' to '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} [-fpermissive]
   25 |         dp[i][0] = "";
      |                    ^~
      |                    |
      |                    const char*
a.cc:33:31: error: request for member 'length' in '(& dp.std::vector<std::vector<int> >::operator[](((std::vector<std::vector<int> >::size_type)(i + 1))))->std::vector<int>::operator[](((std::vector<int>::size_type)j))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   33 |                 if(dp[i+1][j].length() > dp[i][j+1].length()){
      |                               ^~~~~~
a.cc:33:53: error: request for member 'length' in '(& dp.std::vector<std::vector<int> >::operator[](((std::vector<std::vector<int> >::size_type)i)))->std::vector<int>::operator[](((std::vector<int>::size_type)(j + 1)))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   33 |                 if(dp[i+1][j].length() > dp[i][j+1].length()){
      |                                                     ^~~~~~
Language: Java

import java.util.*;
import java.io.*;

 class Main{

public static long func(long weight[], long value[], long total, long weightnow, int index, int n, long dp[][] )
   { 
       
       if(index>=n)
       {
           return 0;
       }
       
       if(dp[index][weightnow]!=-1)
       {
           return dp[index][weightnow];
       }
       long sum=0l;
     //  int sum1=0;
    long ans =0l;
       
           if(weightnow+weight[index]>total)
           {  //System.out.println("weight"+weightnow+" "+weight[i]);
              // sum1+=func(weight,value,total,weightnow,i+1,n);
             sum=  func(weight,value,total,weightnow,index+1,n,dp);
           }
           else{
               ans=value[index]+func(weight,value,total,weightnow+weight[index],index+1,n,dp);
               long val1=func(weight,value,total,weightnow,index+1,n,dp);
               ans=Math.max(val1,ans);
           }
          
         ans=Math.max(ans,sum);
       
       dp[index][weightnow]=ans;
       return ans ;
   }
   
     public static void main(String []args) throws Exception{
        //System.out.println("Hello World");
        BufferedReader br =new BufferedReader(new InputStreamReader(System.in));
        String s =br.readLine();
       String ss[]=s.split(" ");
       long total=Integer.parseLong(ss[1]);
       int n =Integer.parseInt(ss[0]);
       long weight[]=new long[n];
       long value[]=new long[n];
       String temp;
       String tempo[];
        for(int i=0;i<n;i++)
        {
         temp=br.readLine();
         tempo=temp.split(" ");
         weight[i]=Integer.parseLong(tempo[0]);
         value[i]=Long.parseLong(tempo[1]);
        }
        
        
        
    long  sum=0l;
        
     long weightnow=0l;
        
      long dp[][]=new long[n][total+1];
        long ans =0l;
        for(int y=0;y<n;y++)
        {
            Arrays.fill(dp[y],-1);
        }
        int i=0;
        long val=0l;
            if(weight[i]>total)
           {
            val=func(weight,value,total,weightnow,i+1,n,dp);
            ans =Math.max(ans , val);  
           }
           else{
             val=value[i]+func(weight,value,total,weightnow+weight[i],i+1,n,dp);
             long val1=func(weight,value,total,weightnow,i+1,n,dp);
               val=Math.max(val1,val);
               ans =Math.max(ans , val);  
           }
           // System.out.println(val);
           //ans =Math.max(ans , val);    
            
        
        
        System.out.println(ans);
        
        
        
        
     }
}

 }

Compiler output:
Main.java:96: error: class, interface, enum, or record expected
 }
 ^
1 error
Language: C++

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

long long int topdown(long long int i, long long int w,long long  int n, long long int value[],long long int weight[], vector<vector<long long  int>> &dp){
    if(i == -1 || w <= 0) return 0;
    // if(dp[i][w] != -1) return dp[i][w];
    if(weight[i] > w) return dp[i][w] = topdown(i-1, w,n, value, weight, dp);
    return dp[i][w] = max(topdown(i-1, w, n, value, weight, dp), value[i] + topdown(i-1, w - weight[i], n, value, weight, dp));
}


int main() {
    long long int n,w;
    cin >> n >> w;
    vector<vector<long long int>>  dp(n+1, vector<long long int> (w+1,-1));
    for(int i=0;i<n+1;i++){

    long long int value[n], weight[n];
    for(long long int i=0;i<n;i++){
        cin >> weight[i] >> value[i];
    }
    for(long long int i=0;i<n+1;i++) dp[i][0] = 0;
    for(long long int j=0;j<w+1;j++) dp[0][j] = 0;

    cout <<  topdown(n-1, w, n, value, weight, dp);

	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:30:2: error: expected '}' at end of input
   30 | }
      |  ^
a.cc:14:12: note: to match this '{'
   14 | int main() {
      |            ^
Language: Java

import java.util.Scanner;

public class Solution {

	public static void main(String[] args) {

		Scanner in = new Scanner(System.in);
		int noOfItems = in.nextInt();
		long W = in.nextLong();
		Item[] items = new Item[noOfItems];

		for (int k = 0; k < noOfItems; k++) {
			items[k] = new Item(in.nextLong(), in.nextInt());
		}

		int pSum = 0;
		for (Item x : items) {
			pSum += x.price;
		}
		
		Long[] dp = new Long[pSum + 1];
		for (int k = 0; k <= pSum; k++) {
			dp[k] = Long.MAX_VALUE;
		}
		dp[0] = 0L;

		for (int i = 0; i < items.length; i++) {
			for (int j = pSum; j >= items[i].price; j--) {
				if (dp[j - items[i].price] != Long.MAX_VALUE) {
					dp[j] = Math.min(dp[j], items[i].weight + dp[j - items[i].price]);
				}

			}
		}
		int ans = 0;
		for (int k = 0; k <= pSum; k++) {
			if (dp[k] <= W) {
				ans = Math.max(ans, k);
			}

		}
		System.out.println(ans);
	}

	static class Item {
		Long weight;
		int price;

		public Item(Long w, int p) {
			this.weight = w;
			this.price = p;
		}

	}
}


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

#include <bits/stdc++.h>
#define mod 1000000007
#define ll long long 
#define f(j) for(ll i=0;i<j;i++)
#define pb(i) push_back(i)
#define faster ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;    
typedef vector<vector<long long> > matrix; 
ll dp[100][1000000001],w[100],v[100];
ll calc(int itmNum,int weight){ // recursive code - good for learning dp
	ll t1=0,t2=0;
	if(itmNum<0 || !weight)	return 0;
	if(dp[itmNum][weight])	return dp[itmNum][weight];
	t1 = calc(itmNum-1,weight);
	if(w[itmNum]<=weight)
		t2 = calc(itmNum-1,weight-w[itmNum])+v[itmNum];
	dp[itmNum][weight]=max(t1,t2);
	return dp[itmNum][weight];
}
int main(){
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
	// faster
	int n,weight;
	cin>>n>>weight;
	f(n)	cin>>w[i]>>v[i];
	cout<<calc(n-1,weight);

return 0;	
}

Compiler output:
/tmp/ccemmfZp.o: in function `calc(int, int)':
a.cc:(.text+0xb4): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccemmfZp.o
a.cc:(.text+0xda): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccemmfZp.o
a.cc:(.text+0x106): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccemmfZp.o
/tmp/ccemmfZp.o: in function `main':
a.cc:(.text+0x20d): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccemmfZp.o
a.cc:(.text+0x238): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccemmfZp.o
collect2: error: ld returned 1 exit status
Language: Java

public class Main {

	public static void main(String[] args) throws IOException {
		FastScanner fs = new FastScanner();
		int noOfIt = fs.nextInt();
		int capacity = fs.nextInt();
		int w[] = new int[noOfIt];
		int[] pr = new int[noOfIt];
		for (int i = 0; i < noOfIt; i++) {
			w[i] = fs.nextInt();
			pr[i] = fs.nextInt();

		}/*
		5 5
1 1000000000
1 1000000000
1 1000000000
1 1000000000
1 1000000000*/
		Long[][] dp = new Long[noOfIt][capacity+1];
		System.out.println(getMaxProfit(capacity, 0, w, pr, dp, noOfIt));
	}

	private static long getMaxProfit(int capacity, int idx, int[] w, int[] pr, Long[][] dp, int noOfIt) {
		// TODO Auto-generated method stub
		

		if (idx >= noOfIt || capacity <= 0)
			return 0;
		if(dp[idx][capacity]!=null)
			return dp[idx][capacity];
		long p1 = 0;
		if (capacity >= w[idx]) {
			p1 = pr[idx] + getMaxProfit(capacity - w[idx], idx + 1, w, pr, dp, noOfIt);
		}
		long p2 = getMaxProfit(capacity, idx + 1, w, pr, dp, noOfIt);

		dp[idx][capacity] = Math.max(p1, p2);

		return dp[idx][capacity];

	}

}

class FastScanner {
	StringTokenizer tok = new StringTokenizer("");
	BufferedReader in;

	FastScanner() {
		in = new BufferedReader(new InputStreamReader(System.in));
	}

	String next() throws IOException {
		while (!tok.hasMoreElements())
			tok = new StringTokenizer(in.readLine());
		return tok.nextToken();
	}

	int nextInt() throws IOException {
		return Integer.parseInt(next());
	}
}

Compiler output:
Main.java:3: error: cannot find symbol
	public static void main(String[] args) throws IOException {
	                                              ^
  symbol:   class IOException
  location: class Main
Main.java:47: error: cannot find symbol
	StringTokenizer tok = new StringTokenizer("");
	^
  symbol:   class StringTokenizer
  location: class FastScanner
Main.java:48: error: cannot find symbol
	BufferedReader in;
	^
  symbol:   class BufferedReader
  location: class FastScanner
Main.java:54: error: cannot find symbol
	String next() throws IOException {
	                     ^
  symbol:   class IOException
  location: class FastScanner
Main.java:60: error: cannot find symbol
	int nextInt() throws IOException {
	                     ^
  symbol:   class IOException
  location: class FastScanner
Main.java:47: error: cannot find symbol
	StringTokenizer tok = new StringTokenizer("");
	                          ^
  symbol:   class StringTokenizer
  location: class FastScanner
Main.java:51: error: cannot find symbol
		in = new BufferedReader(new InputStreamReader(System.in));
		         ^
  symbol:   class BufferedReader
  location: class FastScanner
Main.java:51: error: cannot find symbol
		in = new BufferedReader(new InputStreamReader(System.in));
		                            ^
  symbol:   class InputStreamReader
  location: class FastScanner
Main.java:56: error: cannot find symbol
			tok = new StringTokenizer(in.readLine());
			          ^
  symbol:   class StringTokenizer
  location: class FastScanner
9 errors
Language: C++

// #pragma GCC optimize("O3")
/* #pragma GCC target ("avx2") */
#pragma GCC optimize("Ofast")
/* #pragma GCC optimize("unroll-loops") */
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;

// #define int long long

vector<int> wt;
vector<int> val;
vector<unordered_map<int,int>> dp;

inline int solve(const int& n, cosnt int& w){
    for(int i=0; i<=n; i++){
        for(int j=0; j<=w; j++){
            if(i==0 || j==0) dp[n][w] = 0;
        }
    }
    for(int i=1; i<=n; i++){
        for(int j=1; j<=w; j++){
            if(wt[i-1] > j) dp[i][j] = dp[i-1][j];
            else dp[i][j] = max(dp[i-1][j-wt[i-1]] + val[i-1], dp[i-1][j]);
        }
    }
    return dp[n][w];
}

inline void test_case(){
    int n;
    cin>>n;
    int w;
    cin>>w;
    wt.resize(n);
    val.resize(n);
    dp.resize(n+1);
    for(int i=0; i<n; i++){
        cin>>wt[i]>>val[i];
    }
    cout<<solve(n, w)<<'\n';
}


int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    test_case();
}   



Compiler output:
a.cc:15:32: error: 'cosnt' has not been declared
   15 | inline int solve(const int& n, cosnt int& w){
      |                                ^~~~~
a.cc:15:32: error: two or more data types in declaration of 'w'
a.cc: In function 'int solve(...)':
a.cc:16:21: error: 'n' was not declared in this scope
   16 |     for(int i=0; i<=n; i++){
      |                     ^
a.cc:17:25: error: 'w' was not declared in this scope
   17 |         for(int j=0; j<=w; j++){
      |                         ^
a.cc:21:21: error: 'n' was not declared in this scope
   21 |     for(int i=1; i<=n; i++){
      |                     ^
a.cc:22:25: error: 'w' was not declared in this scope
   22 |         for(int j=1; j<=w; j++){
      |                         ^
a.cc:27:15: error: 'n' was not declared in this scope; did you mean 'yn'?
   27 |     return dp[n][w];
      |               ^
      |               yn
a.cc:27:18: error: 'w' was not declared in this scope; did you mean 'wt'?
   27 |     return dp[n][w];
      |                  ^
      |                  wt
Language: Java

import java.util.*;
import java.io.*;

public class Knapsack2 {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] s = br.readLine().split(" ");
		int n = Integer.parseInt(s[0]);
		int w = Integer.parseInt(s[1]);
		int[][] items = new int[n + 1][2];
		for (int i = 1; i < n + 1; i++) {
			s = br.readLine().split(" ");
			items[i][0] = Integer.parseInt(s[0]);
			items[i][1] = Integer.parseInt(s[1]);
		}

		long[][] dp = new long[n+1][100010];
		for (long[] l : dp)
			Arrays.fill(l, Integer.MAX_VALUE);
		for (int i = 0; i < n + 1; i++) {
			dp[i][0] = 0;
		}
		

		int max = -1;
		
		for (int i = 1; i < n + 1; i++) {
			for (int j = 1; j < 100009; j++) {
				if (items[i][1] <= j) {
					dp[i][j] = Math.min(dp[i - 1][j], items[i][0] + dp[i - 1][j - items[i][1]]);
				} else
					dp[i][j] = dp[i - 1][j];
				if (dp[i][j] <= w && j > max)
					max = j;
			}
		}

//		for (int i = 0; i < n + 1; i++) {
//			for (int j = 0; j < 19; j++) {
//				System.out.printf("%-11s", dp[i][j]);
//			}
//			System.out.println();
//		}

		System.out.println(max);
	}

}


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

#include <iostream>
using namespace std;
const long long INF = 1LL<<60;

const int MAX_N = 110;
const int MAX_V = 100100;

// 入力
int N;
long long W, weight[MAX_N], value[MAX_N];

// DPテーブル
long long dp[MAX_N][MAX_V];

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

    // 初期化
    for (int i = 0; i < MAX_N; ++i) for (int j = 0; j < MAX_V; ++j) dp[i][j] = INF;

    // 初期条件
    dp[0][0] = 0;

    for (int i = 0; i < N; ++i) {
        for (int sum_v = 0; sum_v < MAX_V; ++sum_v) {

            if (sum_v - value[i] >= 0) chmin(dp[i+1][sum_v], dp[i][sum_v - value[i]] + weight[i]);

            chmin(dp[i+1][sum_v], dp[i][sum_v]);
        }
    }

    long long res = 0;
    for (int sum_v = 0; sum_v < MAX_V; ++sum_v) {
        if (dp[N][sum_v] <= W) res = sum_v;
    }
    cout << res << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:28:40: error: 'chmin' was not declared in this scope
   28 |             if (sum_v - value[i] >= 0) chmin(dp[i+1][sum_v], dp[i][sum_v - value[i]] + weight[i]);
      |                                        ^~~~~
a.cc:30:13: error: 'chmin' was not declared in this scope
   30 |             chmin(dp[i+1][sum_v], dp[i][sum_v]);
      |             ^~~~~
Language: C++

#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <fstream>
#include<iostream>
#include <cmath>
#include <chrono>
#include <thread>
#include <stack>
#include <memory.h>
#include <numeric>
#include <iostream>
#include<climits>

//  vector<vector<int>> b(row_size, vector<int>(col_size,n));   //  n->initialized value

#define MOD 1000000007LL
#define ff first
#define fs second
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vll vector<long long>
#define vvi vector< vector <int> >
#define vpii vector< pair<int, int> >
#define pii pair<int,int>
#define mii map<int, int>
#define mp make_pair
#define tc                int T;cin>>T;while(T--)
#define fast_io            ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ll long long int

using namespace std;

vector<string> order;
map<string, bool> state;
map<string, vector<string>> path;


int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n, W, totval = 0; cin >> n >> W;
    vector<pair<ll, ll>> items(n);
    for (auto& p : items)cin >> p.first >> p.second;
    for (auto& p : items)totval += p.second;
	totval=n*1000;
  for (int i = 0; i <= totval; ++i)dp[1][i] = 1000000;
    //for (int i = 0; i <= n; ++i)dp[i][0] = 0;
    dp[1][0] = 0;
    dp[1][items[0].second] = items[0].first;
    for (int i = 2; i <= n; ++i)
        for (int j = 0; j <= totval; ++j) {
            dp[i][j] = dp[i - 1][j];
            if (j>=items[i - 1].second) {
                dp[i][j] = min(dp[i][j], items[i - 1].first + dp[i - 1][j - items[i - 1].second]);
            }

        }
    for (int i = totval; i > -1; --i)if (dp[n][i] <= W) {
        cout << i << '\n'; break;
    }
    // printtable(dp);
    return 0;

}


Compiler output:
a.cc: In function 'int main()':
a.cc:55:36: error: 'dp' was not declared in this scope; did you mean 'mp'?
   55 |   for (int i = 0; i <= totval; ++i)dp[1][i] = 1000000;
      |                                    ^~
      |                                    mp
a.cc:57:5: error: 'dp' was not declared in this scope; did you mean 'mp'?
   57 |     dp[1][0] = 0;
      |     ^~
      |     mp
Language: C++

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

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;

const int inf = 1e9+10;

void solve(){
	
	int n, w;#include <bits/stdc++.h>
//#define int long long
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;

const int inf = 1e9+10;

void solve(){
	
	int n, w;
	cin >> n >> w;
	
	vector<int> peso(n), value(n);
	for(int i = 0; i < n; i++)
		cin >> peso[i] >> value[i];
		
	vector<vector<int>> dp(2, vector<int>(1e6, inf));
	
	dp[0][0] = 0;
	dp[1][0] = 0;
	int ans = 0;
	for(int pos = 0; pos < n; pos++){
		int par = (pos & 1);
		int next = 1 - par;
		for(int val = 0; val <= 1e5; val++){
			dp[next][val+value[pos]] = min(dp[next][val+value[pos]], dp[par][val] + peso[pos]);
			dp[next][val] = min(dp[par][val], dp[next][val]);
			if(dp[next][val+value[pos]] <= w)
				ans = max(ans, val+value[pos]);
		}
	}
	
	cout << ans << endl;
}

int32_t main(){
	cin.tie(0);
	ios::sync_with_stdio(0);
	
	int tc = 1;
	//cin >> tc;
	while(tc--)
		solve();
}

	cin >> n >> w;
	
	vector<int> peso(n), value(n);
	for(int i = 0; i < n; i++)
		cin >> peso[i] >> value[i];
		
	vector<vector<int>> dp(2, vector<int>(1e6, inf));
	
	dp[0][0] = 0;
	dp[1][0] = 0;
	int ans = 0;
	for(int pos = 0; pos < n; pos++){
		int par = (pos & 1);
		int next = 1 - par;
		for(int val = 0; val <= 1e5; val++){
			dp[next][val+value[pos]] = min(dp[next][val+value[pos]], dp[par][val] + peso[pos]);
			dp[next][val] = min(dp[par][val], dp[next][val]);
			if(dp[next][val+value[pos]] <= w)
				ans = max(ans, val+value[pos]);
		}
	}
	
	cout << ans << endl;
}

int32_t main(){
	cin.tie(0);
	ios::sync_with_stdio(0);
	
	int tc = 1;
	//cin >> tc;
	while(tc--)
		solve();
}


Compiler output:
a.cc:13:18: error: stray '#' in program
   13 |         int n, w;#include <bits/stdc++.h>
      |                  ^
a.cc: In function 'void solve()':
a.cc:13:19: error: 'include' was not declared in this scope
   13 |         int n, w;#include <bits/stdc++.h>
      |                   ^~~~~~~
a.cc:13:28: error: 'bits' was not declared in this scope
   13 |         int n, w;#include <bits/stdc++.h>
      |                            ^~~~
a.cc:13:33: error: 'stdc' was not declared in this scope; did you mean 'std'?
   13 |         int n, w;#include <bits/stdc++.h>
      |                                 ^~~~
      |                                 std
a.cc:15:1: error: expected primary-expression before 'using'
   15 | using namespace std;
      | ^~~~~
a.cc:23:13: error: a function-definition is not allowed here before '{' token
   23 | void solve(){
      |             ^
a.cc:51:13: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   51 | int32_t main(){
      |             ^~
a.cc:51:13: note: remove parentheses to default-initialize a variable
   51 | int32_t main(){
      |             ^~
      |             --
a.cc:51:13: note: or replace parentheses with braces to value-initialize a variable
a.cc:51:15: error: a function-definition is not allowed here before '{' token
   51 | int32_t main(){
      |               ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long int i,j,a,b,t=0,n,wt;
  cin>>n>>wt;
  long long int v[n],w[n];
  for(i=0;i<n;i++)
  {
    cin>>w[i]>>v[i];
    t+=v[i];
  }
  long long int d[t];
  for(i=0;i<t;i++)
    d[i]=INF;
  d[0]=0;
  for(i=0;i<n;i++)
  {
    for(j=t;j>=v[i];j--)
    {
      d[j]=min(d[j],d[j-v[i]]+w[i]);
    }
  }
  //wt=INF;
  j=0;
  for(i=0;i<=t;i++)
  {
    if(d[i]<=wt)
      j=max(j,i);
  }
  cout<<j;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:10: error: 'INF' was not declared in this scope
   15 |     d[i]=INF;
      |          ^~~
Language: Java

import java.io.*;
import java.util.*;

/*
dp[i][j] = w ;  w is the min weight with which
		you can get total value j using the first
		i items...
*/
public class knapsack2 {

    private static int n;
    private static long c;
    private static long[] w, v;
    private static long[][] dp;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        c = sc.nextLong();
        w = new long[n + 1];
        v = new long[n + 1];
        int sum = 0;
        for (int i = 1; i <= n; i++) {
            w[i] = sc.nextLong();
            v[i] = sc.nextLong();
            sum += v[i];
        }
        dp = new long[n + 1][sum + 1];

        System.out.println(findknapsack(sum));

    }

    private static long findknapsack(int sum) {
        for (int i = 0; i <= sum; i++) {
            dp[0][i] = 1000 * 1000 * 1000;
        }

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

        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= sum; j++) {
                if (v[i] <= j) {
                    dp[i][j] = Math.min(w[i] + dp[i - 1][j - (int) v[i]], dp[i - 1][j]);
                } else {
                    dp[i][j] = dp[i - 1][j];
                }
            }
        }
        long ans = 0;
        for (int i = 0; i <= sum; i++) {
            if (dp[n][i] <= c) {
                ans = Math.max(i, ans);
            }
        }
        return ans;
    }

}

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

#include <iostream>
#include <vector>

template <class T> inline bool chmin(T &a, const T &b) {
  return (a > b) ? a = b, true : false;
}

int main() {
  int N, W;
  std::cin >> N >> W;
  std::vector<int> w(N);
  std::vector<int> v(N);
  for (int i = 0; i < N; ++i)
    std::cin >> w[i] >> v[i];

  int K = N * 1000;
  long long inf = 1LL << 60;
  std::vector<std::vector<long long>> dp(
      N + 7, std::vector<long long>(2 * K + 7, inf));
  // dp[i][k] = i 個目までみて価値の合計が k となる場合の重さの最小値

  dp[0][0] = 0;
  for (int i = 0; i < N; ++i) {
    for (int k = 0; k <= K; ++k) {
      chmin(dp[i + 1][k], dp[i][k]);
      chmin(dp[i + 1][k + v[i]], dp[i][k] + w[i]);
    }
  }

  long long res = -1;
  for (k = 0; k <= K; ++k) {
    if (dp[N][k] <= W)
      res = k;
  }
  std::cout << res << std::endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:31:8: error: 'k' was not declared in this scope
   31 |   for (k = 0; k <= K; ++k) {
      |        ^