criyle/codenet-compile-errors huggingface dataset:
Language: Java


import java.util.ArrayList;
import java.util.Scanner;

public class KnapSackProblem {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(), s = sc.nextInt();
		ArrayList <KnapSackItem> items = new ArrayList<KnapSackItem>();
		for (int i =0 ;i < n; i++) {
			items.add(new KnapSackItem(sc.nextInt(), sc.nextInt()));
		}
		
		int[][] dp = new int[s+1][n+1];
		for (int i = 0; i < n ; i++) {
			dp[0][i] = 0;
		}
		for (int i = 0; i <= s ; i++) {
			dp[i][0] = 0;
		}
		for (int i = 1; i <= n ; i++) {
			for (int j = 1; j <= s ; j++) {
				for (int k = 0; k <= j; k++) {
					dp[j][i] = Math.max(dp[j][i], dp[k][i-1] + (j-k)/items.get(i-1).size * items.get(i-1).value);
				}
			}
		}
		System.out.println(dp[s][n]);
	}
	private static class KnapSackItem{
		int size, value;
		public KnapSackItem (int v, int s) {
			size = s; 
			value = v;
		}
	}
}

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

import java.util.ArrayList;
import java.util.Scanner;

public class KnapSackProblem {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(), s = sc.nextInt();
		ArrayList <KnapSackItem> items = new ArrayList<KnapSackItem>();
		for (int i =0 ;i < n; i++) {
			items.add(new KnapSackItem(sc.nextInt(), sc.nextInt()));
		}
		
		int[][] dp = new int[s+1][n+1];
		for (int i = 0; i < n ; i++) {
			dp[0][i] = 0;
		}
		for (int i = 0; i <= s ; i++) {
			dp[i][0] = 0;
		}
		for (int i = 1; i <= n ; i++) {
			for (int j = 1; j <= s ; j++) {
				for (int k = 0; k <= j; k++) {
					dp[j][i] = Math.max(dp[j][i], dp[k][i-1] + (j-k)/items.get(i-1).size * items.get(i-1).value);
				}
			}
		}
		System.out.println(dp[s][n]);
	}
	private static class KnapSackItem{
		int size, value;
		public KnapSackItem (int v, int s) {
			size = s; 
			value = v;
		}
	}
}

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

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class KnapsackProblem {
    public int solve(int W, List<Integer> weights, List<Integer> values) {
        int N = values.size();
        int[] dp = new int[W + 1];
        for (int i = 1; i <= N; ++i) {
            for (int j = 1; j <= W; ++j) {
                int w = weights.get(i - 1);
                if (j >= w) {
                    dp[j] = Math.max(dp[j], dp[j - w] + values.get(i - 1));
                }
            }
        }
        return dp[W];
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        List<Integer> weights = new ArrayList<>();
        List<Integer> values = new ArrayList<>();
        List<Integer> NW = Stream.of(scanner.nextLine().split("\\s")).map(Integer::valueOf)
                                      .collect(Collectors.toList());
        final int N = NW.get(0);
        final int W = NW.get(1);
        for (int i = 0; i < N; ++i) {
            List<Integer> collect = Stream.of(scanner.nextLine().split("\\s")).map(Integer::valueOf)
                                          .collect(Collectors.toList());
            values.add(collect.get(0));
            weights.add(collect.get(1));
        }
        System.out.println(new KnapsackProblem().solve(W, weights, values));
    }
}

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

#include<iostream>
#include<memory.h>
#include<algorithm>
using namespace std;
int main()
{
	int n, W;
	int v[101], w[101];
	int dp[101][100001];
	cin >> n >> W;
	for (int i = 0; i < n; i++){
		cin >> v[i] >> w[i];
	}
	for (int i = 1; i <= n; i++){
		for (int i2 = 0; i2 <= W; i2++){
			if (i2 - w[i - 1] >= 0)dp[i][i2] = max(dp[i - 1][i2], dp[i][i2 - w[i]] + v[i]);
			else dp[i][i2] = dp[i - 1][i2];
		}
	}
	cout << dp[n][W] << endl;
}

Compiler output:
main.c:1:9: fatal error: iostream: No such file or directory
    1 | #include<iostream>
      |         ^~~~~~~~~~
compilation terminated.
Language: C

#include<iostream>
#include<memory.h>
#include<algorithm>
using namespace std;
int main()
{
	int n, W;
	int v[101], w[101];
	int dp[101][1001];
	cin >> n >> W;
	for (int i = 0; i < n; i++){
		cin >> v[i] >> w[i];
	}
	for (int i = 1; i <= n; i++){
		for (int i2 = 0; i2 <= W; i2++){
			if (i2 - w[i - 1] >= 0)dp[i][i2] = max(dp[i - 1][i2], dp[i][i2 - w[i]] + v[i]);
			else dp[i][i2] = dp[i - 1][i2];
		}
	}
	cout << dp[n][W] << endl;
}

Compiler output:
main.c:1:9: fatal error: iostream: No such file or directory
    1 | #include<iostream>
      |         ^~~~~~~~~~
compilation terminated.
Language: C

#include <stdio.h>
#include <stdlib.h>

int main(void){
  
  int i,j,k,w1;
  int v[100],w[100];
  int *last,*next,*temp;

  scanf("%d %d",&n,&w1);
  for(i=0;i<n;i++) scanf("%d %d",&v[i],&w[i]);

  w1++;
  last=(int *)calloc(w1,sizeof(int));
  next=(int *)calloc(w1,sizeof(int));

  for(i=0;i<w1;i++){
    last[i]=0;
    next[i]=0;
  }

  for(i=0;i<n;i++){
    for(j=0;j<w1;j++){
      if(j-w[i]>=0 && next[j-w[i]]+v[i]>last[j]){
	next[j]=next[j-w[i]]+v[i];
      }
      else{
	next[j]=last[j];
	  }
    }
    last=temp;
    last=next;
    next=temp;
  }

  printf("%d\n",next[j]);
  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:10:18: error: 'n' undeclared (first use in this function)
   10 |   scanf("%d %d",&n,&w1);
      |                  ^
main.c:10:18: note: each undeclared identifier is reported only once for each function it appears in
Language: C

#include<iostream>
#include<algorithm>

using namespace std;

#define nMAX 100 
#define vMAX 1000
#define WMAX 100

int main(){

	int n,W;
	int v[nMAX+1],w[nMAX+1];
	int dp[nMAX+1][WMAX+1];

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

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

	for(int i=0;i<n;i++){
		for(int j=0;j<=W;j++){
			if(j<w[i]){
				dp[i+1][j]=dp[i][j];
			}
			else{
				dp[i+1][j]=max(dp[i][j-w[i]]+v[i],max(dp[i][j],dp[i+1][j-w[i]]+v[i]));
			}
		}
	}
	cout<<dp[n][W]<<endl;
}

Compiler output:
main.c:1:9: fatal error: iostream: No such file or directory
    1 | #include<iostream>
      |         ^~~~~~~~~~
compilation terminated.
Language: C

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

struct item{
  int value;
  int weight;
};

int max(int a,int b)
{
  if(a>b)
    return a;
  else 
    return b;
}

int main(void)
{
  int N,W,i,j,**c,**g,w;
  struct item *a;
  scanf("%d %d",&N,&W);
  a=malloc(sizeof(struct item)*N);
  for(i=0;i<N;i++)
    scanf("%d %d",&a[i].value,&a[i].weight);

  c=malloc(sizeof(int *)*(N+1));
  for(i=0;i<M+1;i++)
    c[i]=malloc(sizeof(int)*(W+1));
  
  for(i=0;i<W+1;i++)
    c[0][i]=0;
  for(i=1;i<N+1;i++)
    c[i][0]=0;
  
  for(i=1;i<N+1;i++)
    for(w=1;w<W+1;w++){
      if(a[i].item<=w)
	c[i][w]=max(c[i-1][w],c[i-1][w-a[i].weight]);
      else 
	c[i][w]=c[i-1][w];
    }
  printf("%d\n",c[N][W]);

  return 0;
}

Compiler output:
main.c: In function 'main':
main.c:29:13: error: 'M' undeclared (first use in this function)
   29 |   for(i=0;i<M+1;i++)
      |             ^
main.c:29:13: note: each undeclared identifier is reported only once for each function it appears in
main.c:39:14: error: 'struct item' has no member named 'item'
   39 |       if(a[i].item<=w)
      |              ^
Language: C++

#include<iostream>
#include<map>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
using namespace std;
#define REP(i,b,e) for(int i=(int)b;i<(int)e;i++)
#define rep0(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n+1)
typedef long long ll;

struct Item{
    int value;
    int weight;
};
int N,W;
Item items[102];
int C[102][10003];
//C[i][j]:=items[0]~[i]までを使って重さjまでのうちの価値の最大値
int main(){
    cin>>N>>W;
    REP(i,1,N+1){
        cin>>items[i].value>>items[i].weight;
    }
    REP(i,1,N+1){
        REP(j,0,W+1){
            int w=items[i].weight;
            int v=items[i].value;
            if(w<=j){
                C[i][j]=max(C[i-1][j],C[i-1][j-w]+v,C[i][j-w]+v);
            }
            else C[i][j]=C[i-1][j];
        }
    }
    cout<<C[N][W]<<endl;

    return 0;
}



Compiler output:
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: In instantiation of 'constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare) [with _Tp = int; _Compare = int]':
a.cc:31:28:   required from here
   31 |                 C[i][j]=max(C[i-1][j],C[i-1][j-w]+v,C[i][j-w]+v);
      |                         ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:306:17: error: '__comp' cannot be used as a function
  306 |       if (__comp(__a, __b))
      |           ~~~~~~^~~~~~~~~~
Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const ll INF = (ll)1e17;

int N, W;
int v[101], w[101];
int dp[101][10001]; //dp[i][j]:商品1~iの中から選び、ナップサックの容量がjの時に入れられる商品の価値の合計の最大値

int main(void) {
	cin >> N >> W;
	for (int i = 0; i < N; i++) cin >> v[i] >> w[i];
	memset(dp, 0, sizeof(dp));

	for (int i = 0; i < N; i++) {
		for (int j = 0; j <= W; j++) {                                       //容量ははWまで
			if (j - w[i] >= 0) {                                             //商品iが入れられるとき
				dp[i + 1][j] = max(dp[i][j], dp[i + 1][j - w[i]] + v[i]);    //商品iを入れない場合と入れる場合の価値の大きい方
			}
			else {                       //商品iは入れられないとき
				dp[i + 1][j] = dp[i][j]; //価値はそのまま
			}
		}
	}

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


Compiler output:
a.cc: In function 'int main()':
a.cc:18:9: error: 'memset' was not declared in this scope
   18 |         memset(dp, 0, sizeof(dp));
      |         ^~~~~~
a.cc:5:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    4 | #include <utility>
  +++ |+#include <cstring>
    5 | using namespace std;
Language: C++

//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define d(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;


#define MAX 1001
LL N,W,dp[MAX][MAX],v[MAX],w[MAX],maxv=0;

int main(void){
    cin>>N>>W;
    REP(i,N){
        cin>>v[i]>>w[i];
    }
    REP(i,N)REP(j,W+1){
        if(j<w[i])dp[i+1][j]=dp[i][j];
        else　dp[i+1][j]=max(dp[i][j],dp[i+1][j-w[i]]+v[i]);
    }
    cout<<dp[N][W]<<endl;
    return 0;
}



Compiler output:
a.cc:83:9: error: extended character 　 is not valid in an identifier
   83 |         else　dp[i+1][j]=max(dp[i][j],dp[i+1][j-w[i]]+v[i]);
      |         ^
a.cc: In function 'int main()':
a.cc:83:9: error: 'else\U00003000dp' was not declared in this scope
   83 |         else　dp[i+1][j]=max(dp[i][j],dp[i+1][j-w[i]]+v[i]);
      |         ^~~~~~~~
Language: C++

#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <map>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define INF ((int)1e9)
#define INFLL ((ll)1e18)
#define MOD (1000000007LL)


int main(int argc, const char * argv[]) {
    int N, W;
    cin >> N >> W;
    vector<int> v(N), w(N);
    for (int n = 0; n < N; ++n) {
        cin >> v[n] >> w[n];
    }
    
    int DP[101][10001];
    memset(DP, 0, sizeof(DP));
    for (int n = 1; n <= N; ++n) {
        for (int wt = 0; wt <= W; ++wt) {
            DP[n][wt] = DP[n-1][wt];
            if (wt >= w[n-1]) {
                DP[n][wt] = max(DP[n][wt], DP[n-1][wt-w[n-1]] + v[n-1]);
                DP[n][wt] = max(DP[n][wt], DP[n][wt-w[n-1]] + v[n-1]);
            }
        }
    }
    cout << DP[N][W] << endl;

    return 0;
}



Compiler output:
a.cc: In function 'int main(int, const char**)':
a.cc:33:5: error: 'memset' was not declared in this scope
   33 |     memset(DP, 0, sizeof(DP));
      |     ^~~~~~
a.cc:8:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    7 | #include <map>
  +++ |+#include <cstring>
    8 |
Language: C++

#include <stdio.h>
//#include <iostream>
//#define int long long
#define SIZE 101
#define VALUE 10001
//#define _DEBUG
using namespace std;
int N, W, Vs[SIZE], Ws[SIZE] , T[SIZE][VALUE];
int solve(){
    for(int i=0; i<=N; i++){
        for(int w=0; w<=W; w++){
            if(i==0 || w==0){
                T[i][w] = 0;
            }else{
                int m = T[i-1][w];
                for(int k=1; Ws[i-1]*k <= w; k++){
                    m = max(m, T[i-1][w-Ws[i-1]*k]+Vs[i-1]*k);
                }
                T[i][w] = m;
            }
        }
    }
#ifdef _DEBUG
    for(int i=0; i<=N; i++){
        if(i>0)cout << Vs[i-1] << "," << Ws[i-1] << "\t";
        else cout << "\t";
        for(int w=0; w<=W; w++){
            cout << T[i][w] << " ";
        }cout << endl;
    }
#endif
    return T[N][W];
}
signed main(){
    //while(
        scanf("%d%d", &N, &W);//){
        for(int i=0; i<N; i++){
            scanf("%d%d", &Vs[i], &Ws[i]);
        }
        printf("%d\n", solve());
    //}
}


Compiler output:
a.cc: In function 'int solve()':
a.cc:17:25: error: 'max' was not declared in this scope
   17 |                     m = max(m, T[i-1][w-Ws[i-1]*k]+Vs[i-1]*k);
      |                         ^~~
Language: C++

#include<iostream>
//#include<algorithm>
#include<utility>
//#include<cmath>
#define MAX 1000
using namespace std;
int main()
{
    int N,W,sum=0;
    int v[MAX],w[MAX]={0};
    float per[MAX];
    pair<float,int> pp[MAX];
    cin>>N>>W;
    int i;
    for(i=0;i<N;i++)
    {
        cin>>v[i]>>w[i];
        per[i]=1.0*v[i]/w[i];
        pp[i]=make_pair(per[i],i);
    }
    sort(pp,pp+N);
    for(i=N-1;i>=0;i--)
    {
        sum+=(W/w[pp[i].second])*v[pp[i].second];
        W=W%w[pp[i].second];
    }
    cout<<sum<<endl;
    return 0;
}




Compiler output:
a.cc: In function 'int main()':
a.cc:21:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   21 |     sort(pp,pp+N);
      |     ^~~~
      |     short
Language: C++

#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
using namespace std;
typedef pair<int,int> product;

int main() {
    int n,w;
    cin >> n >> w;
    vector<product> products(n);    // <value,weight>
    for(int i=0;i<n;i++){
        cin >> products.at(i).first >> products.at(i).second;

    //　個数制限なし
    vector<int> dp(w+1,0);
    for(int weight=0;weight<=w;weight++){
        vector<int> tmp(n,0);
        for(int i=0;i<n;i++){
            if (weight - products[i].second >= 0){
                tmp[i] = dp[weight - products[i].second] + products[i].first;
            }
        }
        dp[weight] = *max_element(tmp.begin(),tmp.end());
    }
    cout << dp[w] << endl;
}


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

#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <cstring>
#include <sstream>
#include <iomanip>//小数精度 	cout << fixed << setprecision(5) << tmp << endl;
using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define All(X)      (X).begin(),(X).end()

int n,w;
int dp[101][100001];
int val[101];
int wei[101];
int rec(int i,int j){
  if(dp[i][j] >= 0) return dp[i][j];
  int res;
  if(i==n){
    res = 0;
  }else if(j<wei[i]){
    res = rec(i+1,j);
  }else{
    res = max(rec(i+1,j),rec(i,j-wei[i]) + val[i]);
  }
  return dp[i][j] = res;
}

int main(){

  cin >> n >> w;
  REP(i,n) cin >> val[i] >> wei[i];

  memset(dp,-1,sizeof(dp));
  cout << rec(0,w) <<endl;
  return 0;
}
javascript:void(0)

Compiler output:
a.cc:46:1: error: 'javascript' does not name a type
   46 | javascript:void(0)
      | ^~~~~~~~~~
Language: C++

import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;

class Main{

static final PrintWriter out=new PrintWriter(System.out);
static final int INF=Integer.MAX_VALUE/2;

public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String line="";
while((line=br.readLine())!=null&&!line.isEmpty()){
int n=Integer.parseInt(line.split(" ")[0]);
int wmax=Integer.parseInt(line.split(" ")[1]);
int[] v=new int[n];
int[] w=new int[n];
for(int i=0;i<n;i++){
line=br.readLine();
v[i]=Integer.parseInt(line.split(" ")[0]);
w[i]=Integer.parseInt(line.split(" ")[1]);
}
int[][] dp=new int[n+1][wmax+1];
for(int j=n-1;j>=0;j--){
for(int i=0;i<=wmax;i++){
if(i<w[j]) dp[j][i]=dp[j+1][i];
else dp[j][i]=Math.max(dp[j+1][i],dp[j][i-w[j]]+v[j]);
}
}
out.println(dp[0][wmax]);
}
out.flush();
}
}

Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import java.io.*;
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:2:1: error: 'import' does not name a type
    2 | import java.util.Arrays;
      | ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:3:1: error: 'import' does not name a type
    3 | import java.util.StringTokenizer;
      | ^~~~~~
a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:7:8: error: 'final' does not name a type
    7 | static final PrintWriter out=new PrintWriter(System.out);
      |        ^~~~~
a.cc:8:8: error: 'final' does not name a type
    8 | static final int INF=Integer.MAX_VALUE/2;
      |        ^~~~~
a.cc:10:7: error: expected ':' before 'static'
   10 | public static void main(String[] args) throws IOException{
      |       ^~~~~~~
      |       :
a.cc:10:25: error: 'String' has not been declared
   10 | public static void main(String[] args) throws IOException{
      |                         ^~~~~~
a.cc:10:34: error: expected ',' or '...' before 'args'
   10 | public static void main(String[] args) throws IOException{
      |                                  ^~~~
a.cc:10:38: error: expected ';' at end of member declaration
   10 | public static void main(String[] args) throws IOException{
      |                                      ^
      |                                       ;
a.cc:10:40: error: 'throws' does not name a type
   10 | public static void main(String[] args) throws IOException{
      |                                        ^~~~~~
a.cc:34:2: error: expected ';' after class definition
   34 | }
      |  ^
      |  ;
Language: C++

#include <stdio.h>
#include <algorithm>
#include <string.h>

const int MAX_N=100;
const int MAX_W=1000;
const int dp[MAX_N+1][MAX_W+1];
const int N,W;
const int w[MAX_N];
const int v[MAX_N];
void solve(){
	for(int i=0;i<N;i++){
		for(int j=0;j<W;j++){
			if(j<w[i]){
				dp[i+1][j]=dp[i][j];
			}
			else{
				dp[i+1][j]=max(dp[i][j],dp[i+1][j-w[i]]+v[i]);
			}
		}
	}
}
int main(){
	scanf("%d%d",&N,&W);
	for(int i=0;i<N;i++){
		scanf("%d%d",&v[i]&w[i]);
		dp[0][i]=0;
	}
	
	solve();
	printf("%d\n",dp[N][W]);
	return 0;
	
}

Compiler output:
a.cc:7:11: error: uninitialized 'const dp' [-fpermissive]
    7 | const int dp[MAX_N+1][MAX_W+1];
      |           ^~
a.cc:8:11: error: uninitialized 'const N' [-fpermissive]
    8 | const int N,W;
      |           ^
a.cc:8:13: error: uninitialized 'const W' [-fpermissive]
    8 | const int N,W;
      |             ^
a.cc:9:11: error: uninitialized 'const w' [-fpermissive]
    9 | const int w[MAX_N];
      |           ^
a.cc:10:11: error: uninitialized 'const v' [-fpermissive]
   10 | const int v[MAX_N];
      |           ^
a.cc: In function 'void solve()':
a.cc:15:43: error: assignment of read-only location 'dp[(i + 1)][j]'
   15 |                                 dp[i+1][j]=dp[i][j];
      |                                 ~~~~~~~~~~^~~~~~~~~
a.cc:18:44: error: 'max' was not declared in this scope; did you mean 'std::max'?
   18 |                                 dp[i+1][j]=max(dp[i][j],dp[i+1][j-w[i]]+v[i]);
      |                                            ^~~
      |                                            std::max
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: 'std::max' declared here
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
a.cc: In function 'int main()':
a.cc:26:35: error: invalid operands of types 'const int*' and 'const int' to binary 'operator&'
   26 |                 scanf("%d%d",&v[i]&w[i]);
      |                              ~~~~~^~~~~
      |                              |        |
      |                              |        const int
      |                              const int*
a.cc:27:25: error: assignment of read-only location 'dp[0][i]'
   27 |                 dp[0][i]=0;
      |                 ~~~~~~~~^~
Language: C++

#include <stdio.h>
#include <algorithm>
#include <string.h>
using namespace std;

const int MAX_N=100;
const int MAX_W=1000;
const int dp[MAX_N+1][MAX_W+1];
const int N,W;
const int w[MAX_N];
const int v[MAX_N];
void solve(){
	for(int i=0;i<N;i++){
		for(int j=0;j<W;j++){
			if(j<w[i]){
				dp[i+1][j]=dp[i][j];
			}
			else{
				dp[i+1][j]=max(dp[i][j],dp[i+1][j-w[i]]+v[i]);
			}
		}
	}
}
int main(){
	scanf("%d%d",&N,&W);
	for(int i=0;i<N;i++){
		scanf("%d%d",&v[i]&w[i]);
		dp[0][i]=0;
	}
	
	solve();
	printf("%d\n",dp[N][W]);
	return 0;
	
}

Compiler output:
a.cc:8:11: error: uninitialized 'const dp' [-fpermissive]
    8 | const int dp[MAX_N+1][MAX_W+1];
      |           ^~
a.cc:9:11: error: uninitialized 'const N' [-fpermissive]
    9 | const int N,W;
      |           ^
a.cc:9:13: error: uninitialized 'const W' [-fpermissive]
    9 | const int N,W;
      |             ^
a.cc:10:11: error: uninitialized 'const w' [-fpermissive]
   10 | const int w[MAX_N];
      |           ^
a.cc:11:11: error: uninitialized 'const v' [-fpermissive]
   11 | const int v[MAX_N];
      |           ^
a.cc: In function 'void solve()':
a.cc:16:43: error: assignment of read-only location 'dp[(i + 1)][j]'
   16 |                                 dp[i+1][j]=dp[i][j];
      |                                 ~~~~~~~~~~^~~~~~~~~
a.cc:19:43: error: assignment of read-only location 'dp[(i + 1)][j]'
   19 |                                 dp[i+1][j]=max(dp[i][j],dp[i+1][j-w[i]]+v[i]);
      |                                 ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc: In function 'int main()':
a.cc:27:35: error: invalid operands of types 'const int*' and 'const int' to binary 'operator&'
   27 |                 scanf("%d%d",&v[i]&w[i]);
      |                              ~~~~~^~~~~
      |                              |        |
      |                              |        const int
      |                              const int*
a.cc:28:25: error: assignment of read-only location 'dp[0][i]'
   28 |                 dp[0][i]=0;
      |                 ~~~~~~~~^~
Language: C++

#include <stdio.h>
#include <algorithm>
#include <string.h>
using namespace std;

const int MAX_N=100;
const int MAX_W=1000;
const int dp[MAX_N+1][MAX_W+1];
int N,W;
int w[MAX_N];
int v[MAX_N];
void solve(){
	for(int i=0;i<N;i++){
		for(int j=0;j<W;j++){
			if(j<w[i]){
				dp[i+1][j]=dp[i][j];
			}
			else{
				dp[i+1][j]=max(dp[i][j],dp[i+1][j-w[i]]+v[i]);
			}
		}
	}
}
int main(){
	scanf("%d%d",&N,&W);
	for(int i=0;i<N;i++){
		scanf("%d%d",&v[i]&w[i]);
		dp[0][i]=0;
	}
	
	solve();
	printf("%d\n",dp[N][W]);
	return 0;
	
}

Compiler output:
a.cc:8:11: error: uninitialized 'const dp' [-fpermissive]
    8 | const int dp[MAX_N+1][MAX_W+1];
      |           ^~
a.cc: In function 'void solve()':
a.cc:16:43: error: assignment of read-only location 'dp[(i + 1)][j]'
   16 |                                 dp[i+1][j]=dp[i][j];
      |                                 ~~~~~~~~~~^~~~~~~~~
a.cc:19:43: error: assignment of read-only location 'dp[(i + 1)][j]'
   19 |                                 dp[i+1][j]=max(dp[i][j],dp[i+1][j-w[i]]+v[i]);
      |                                 ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc: In function 'int main()':
a.cc:27:35: error: invalid operands of types 'int*' and 'int' to binary 'operator&'
   27 |                 scanf("%d%d",&v[i]&w[i]);
      |                              ~~~~~^~~~~
      |                              |        |
      |                              int*     int
a.cc:28:25: error: assignment of read-only location 'dp[0][i]'
   28 |                 dp[0][i]=0;
      |                 ~~~~~~~~^~
Language: C++

#include <stdio.h>
#include <algorithm>
#include <string.h>
using namespace std;

const int MAX_N=100;
const int MAX_W=1000;
int dp[MAX_N+1][MAX_W+1];
int N,W;
int w[MAX_N];
int v[MAX_N];
void solve(){
	for(int i=0;i<N;i++){
		for(int j=0;j<W;j++){
			if(j<w[i]){
				dp[i+1][j]=dp[i][j];
			}
			else{
				dp[i+1][j]=max(dp[i][j],dp[i+1][j-w[i]]+v[i]);
			}
		}
	}
}
int main(){
	scanf("%d%d",&N,&W);
	for(int i=0;i<N;i++){
		scanf("%d%d",&v[i]&w[i]);
		dp[0][i]=0;
	}
	
	solve();
	printf("%d\n",dp[N][W]);
	return 0;
	
}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:35: error: invalid operands of types 'int*' and 'int' to binary 'operator&'
   27 |                 scanf("%d%d",&v[i]&w[i]);
      |                              ~~~~~^~~~~
      |                              |        |
      |                              int*     int
Language: C++

#include<bits/std.c++>
using namespace std;
const int MAX_N = 25;
int n,W;
int w[MAX_N],v[MAX_N];

int solve(int i,int j){
  int res;
  if(i == n){
    res = 0;
  }else if(j < w[i]){
    res = solve(i+1,j);
  }else{
    res = max(solve(i+1,j),solve(i+1,j-w[i])+v[i]);
  }

  return res;
}
int main(){
  cout << solve(0,W) << endl;
}

Compiler output:
a.cc:1:9: fatal error: bits/std.c++: No such file or directory
    1 | #include<bits/std.c++>
      |         ^~~~~~~~~~~~~~
compilation terminated.
Language: C++

package dp;

import java.util.ArrayList;
import java.util.Scanner;

public class KnapSackProblem {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(), s = sc.nextInt();
		ArrayList <KnapSackItem> items = new ArrayList<KnapSackItem>();
		for (int i =0 ;i < n; i++) {
			items.add(new KnapSackItem(sc.nextInt(), sc.nextInt()));
		}
		
		int[][] dp = new int[s+1][n+1];
		for (int i = 0; i < n ; i++) {
			dp[0][i] = 0;
		}
		for (int i = 0; i <= s ; i++) {
			dp[i][0] = 0;
		}
		for (int i = 1; i <= n ; i++) {
			for (int j = 1; j <= s ; j++) {
				for (int k = 0; k <= j; k++) {
					dp[j][i] = Math.max(dp[j][i], dp[k][i-1] + (j-k)/items.get(i-1).size * items.get(i-1).value);
				}
			}
		}
		System.out.println(dp[s][n]);
	}
	private static class KnapSackItem{
		int size, value;
		public KnapSackItem (int v, int s) {
			size = s; 
			value = v;
		}
	}
}

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

#include <iostream>
#include <algorithm>
using namespace std;
int n, m, v[100], w[100], dp[10007];
int main() {
	cin >> n >> m;
	for(int i = 0; i < n; i++) cin >> v[i] >> w[i];
	for(int i = 1; i <= m; i++) {
		for(int j = 0; j < n; j++) {
			if(i >= w[j]) dp[i] = max(dp[i], dp[i - w[j]] + v[j]);
		}
	}
	cout << dp[n][m] << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:22: error: invalid types 'int[int]' for array subscript
   13 |         cout << dp[n][m] << endl;
      |                      ^
Language: C++

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

#define INF 1e+9

int main(){

	  int N,W;
	  cin >> N >> W;

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

	  int dp[N][W+1]={};
	  for(int i=0; i<N; i++)
			for(int j=0; j<=W; j++)
				  dp[i][j] = -INF;

	  for(int i=0; i<N; i++){
			for(int j=0; j<=W; j++){
				  dp[i+1][j] = max(dp[i+1][j],dp[i][j]);
				  if(j+w[i] > W) continue;
				  dp[i][j+w[i]] = max(dp[i][j+w[i]], dp[i][j] + v[i]);
			}
	  }
	  itn ans = 0;
	  for(int i=0; i<=W; i++)
			ans = max(ans,dp[N-1][i]);
	  cout << ans << endl;
				  
	  

}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:11: error: 'itn' was not declared in this scope; did you mean 'int'?
   26 |           itn ans = 0;
      |           ^~~
      |           int
a.cc:28:25: error: 'ans' was not declared in this scope; did you mean 'abs'?
   28 |                         ans = max(ans,dp[N-1][i]);
      |                         ^~~
      |                         abs
a.cc:29:19: error: 'ans' was not declared in this scope; did you mean 'abs'?
   29 |           cout << ans << endl;
      |                   ^~~
      |                   abs
Language: C++

#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt" > "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\b.txt"
 


int main() {
	int N, W; cin >> N >> W;
	vector<pair<int, int>>ps;
	for (int i = 0; i < N; ++i) {
		int v, w; cin >> v >> w;
		ps.emplace_back(v, w);
	}
	vector<vector<int>>dp(N + 1, vector<int>(W + 1));
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j <= W; ++j) {
			dp[i + 1][j] = max(dp[i][j], dp[i + 1][j]);
			if (j + ps[i].first <= W) {
				dp[i + 1][j + ps[i].first] = max(dp[i + 1][j + ps[i].first], dp[i][j] + ps[i].second);
			}
		}
	}
	int ans = 0;
	for (int i = 0; i <= W; ++i) {
		ans = max(ans, sp[N][i]);
	}
	cout << ans << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:33:32: error: 'sp' was not declared in this scope; did you mean 'dp'?
   33 |                 ans = max(ans, sp[N][i]);
      |                                ^~
      |                                dp
Language: C++

// dp[i][j] := i???????????§????????£?????????j??\??????????¨????????????????????????????????????§????????\??¬???????????????i???
#include <iostream>
using namespace std;

int dp[105][10005], v[1001], w[1001];

int main(void) {
  int N, W;

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

  for (int i = 0; i < N; i++) {
    for (int j = 1; j < W + 1; j++) {
      if (!i) {
        if (j - w[i] >= 0) dp[i][j] = dp[i][j - w[i]] + v[i];
      } else {
        if (j - w[i] >= 0) {
          dp[i][j] = max(dp[i-1][j], dp[i][j - w[i]] + v[i]);
        } else {
          dp[i][j] = dp[i-1][j];
        }
      }
    }
  }

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

Compiler output:
a.cc:30:1: error: 'sakamot' does not name a type
   30 | sakamot
      | ^~~~~~~
Language: C++

#endif
#include<iostream>
#include<utility>
using namespace std;
int main(){
    int N,W;
    int p,w;
    pair<int,int>m[101];
    cin>>N>>W;
    for(int i=1;i<=N;++i){
        cin>>p>>w;
        m[i]=make_pair(p,w);
    }
    int V[101][10001];
    for(int i=1;i<=N;++i){
        for(int j=1;j<=W;++j){
            if(j-m[i].second<0){
                V[i][j]=V[i-1][j];
            }
            else{
                int temp;
                temp=m[i].first+V[i][j-m[i].second];
                V[i][j]=max(temp,V[i-1][j]);
            }
        }
    }
    cout<<V[N][W]<<endl;
}

Compiler output:
a.cc:1:2: error: #endif without #if
    1 | #endif
      |  ^~~~~
Language: C++

// 2-3 ???????????????????????¨"???????¨???????" P.59 ??¢?´¢????????¢?????¨???????¨???????????????°??¶????????????????????????????????????

#include <stdio.h>
#include <algorithm>
#include <conio.h>
using namespace std;

int n, w[112], v[112], W;

int dp[100 + 1][10000 + 1];		// DP????????????

void solve() {
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j <= W; ++j) {
			if (j < w[i]) {
				dp[i + 1][j] = dp[i][j];
			}
			else {
				dp[i + 1][j] = max(dp[i][j], dp[i + 1][j - w[i]] + v[i]);
			}
		}
	}
	printf("%d\n", dp[n][W]);
}

int main() {
	scanf("%d", &n);
	scanf("%d", &W);
	for (int i = 0; i < n; ++i) { scanf("%d%d", &v[i], &w[i]); }

	solve();

	return 0;
}

Compiler output:
a.cc:5:10: fatal error: conio.h: No such file or directory
    5 | #include <conio.h>
      |          ^~~~~~~~~
compilation terminated.
Language: C++

#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    int n, w;
    int dp[500][500];
    cin >> n >> w;
    for(i=0;i<n;i++){
        cin >> v[i] >> w[i];
    }

    for(int i = n - 1; i >= 0; i--){
        for(int j = 0; j <= w; j++){
            if(j < w[i]){
                dp[i][j]=dp[i+1][j];
            }else{
                dp[i][j]=max(dp[i+1][j], dp[i+1][j-w[i]]+v[i]);
            }
        }
    }
    pritnf("%d\n", dp[0][w]);

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:9: error: 'i' was not declared in this scope
    8 |     for(i=0;i<n;i++){
      |         ^
a.cc:9:16: error: 'v' was not declared in this scope
    9 |         cin >> v[i] >> w[i];
      |                ^
a.cc:14:21: error: invalid types 'int[int]' for array subscript
   14 |             if(j < w[i]){
      |                     ^
a.cc:17:53: error: invalid types 'int[int]' for array subscript
   17 |                 dp[i][j]=max(dp[i+1][j], dp[i+1][j-w[i]]+v[i]);
      |                                                     ^
a.cc:17:58: error: 'v' was not declared in this scope
   17 |                 dp[i][j]=max(dp[i+1][j], dp[i+1][j-w[i]]+v[i]);
      |                                                          ^
a.cc:21:5: error: 'pritnf' was not declared in this scope; did you mean 'printf'?
   21 |     pritnf("%d\n", dp[0][w]);
      |     ^~~~~~
      |     printf
Language: C++

#include<iostream>
#include<algorithm>
using namespace std;
const int max_n = 100;
const int max_v = 1000;
const int max_w = 1000;
const int max_c = 10000;

int n, w;
int w[max_n], v[max_n];

int rec (int i, int j){
    int ans;
    if(i == n){
        ans = 0;   
    }else if( j <w[i]){
        ans = rec(i+1, j);
    }else{
        ans = max(rec(i+1, j), rec(i+1, j-w[i]) + v[i]);
    }
    return ans;
}

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

    cout << rec(0, w);

    return;
}

Compiler output:
a.cc:10:5: error: conflicting declaration 'int w [100]'
   10 | int w[max_n], v[max_n];
      |     ^
a.cc:9:8: note: previous declaration as 'int w'
    9 | int n, w;
      |        ^
a.cc: In function 'int rec(int, int)':
a.cc:16:19: error: invalid types 'int[int]' for array subscript
   16 |     }else if( j <w[i]){
      |                   ^
a.cc:19:44: error: invalid types 'int[int]' for array subscript
   19 |         ans = max(rec(i+1, j), rec(i+1, j-w[i]) + v[i]);
      |                                            ^
a.cc: In function 'int main()':
a.cc:26:9: error: 'i' was not declared in this scope
   26 |     for(i=0;i<n;i++){
      |         ^
a.cc:32:5: error: return-statement with no value, in function returning 'int' [-fpermissive]
   32 |     return;
      |     ^~~~~~
Language: C++

#include<iostream>
#include<algorithm>
using namespace std;
const int max_n = 100;
// const int max_v = 1000;
// // const int max_w = 1000;
// const int max_w = 10000;

int n, w;
int w[max_n], v[max_n];

int rec (int i, int j){
    int ans;
    if(i == n){
        ans = 0;   
    }else if( j <w[i]){
        ans = rec(i+1, j);
    }else{
        ans = max(rec(i+1, j), rec(i+1, j-w[i]) + v[i]);
    }
    return ans;
}

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

    cout << rec(0, w) << endl;

    return 0;
}

Compiler output:
a.cc:10:5: error: conflicting declaration 'int w [100]'
   10 | int w[max_n], v[max_n];
      |     ^
a.cc:9:8: note: previous declaration as 'int w'
    9 | int n, w;
      |        ^
a.cc: In function 'int rec(int, int)':
a.cc:16:19: error: invalid types 'int[int]' for array subscript
   16 |     }else if( j <w[i]){
      |                   ^
a.cc:19:44: error: invalid types 'int[int]' for array subscript
   19 |         ans = max(rec(i+1, j), rec(i+1, j-w[i]) + v[i]);
      |                                            ^
a.cc: In function 'int main()':
a.cc:26:9: error: 'i' was not declared in this scope
   26 |     for(i=0;i<n;i++){
      |         ^
Language: C++

#include<iostream>
#include<algorithm>
using namespace std;
const int max_n = 100;
// const int max_v = 1000;
// // const int max_w = 1000;
// const int max_w = 10000;

int n, W;
int w[max_n], v[max_n];

int rec (int i, int j){
    int ans;
    if(i == n){
        ans = 0;   
    }else if( j <w[i]){
        ans = rec(i+1, j);
    }else{
        ans = max(rec(i+1, j), rec(i+1, j-w[i]) + v[i]);
    }
    return ans;
}

int main(void){
    cin >> n >> W;
    for(i=0;i<n;i++){
        cin >> v[i] >> w[i];
    }

    cout << rec(0, W) << endl;

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:9: error: 'i' was not declared in this scope
   26 |     for(i=0;i<n;i++){
      |         ^
Language: C++

#include <bits/stdc++.h>
#define ll long long
#define INF 999999999
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 100;
const int MAX_W = 10000;
int DP[MAX_N+1][MAX_W+1];
int v[MAX_N];
int w[MAX_N];

int main()
{
	int n,W;
	scanf("%d%d",&n,&W);
	rep(i,n){
		scanf("%d%d",&v[i],&w[i]);
	}
	rep(i,n){
		rep(j,W+1){
			if(j<w[i]){
				DP[i+1][j] = DP[i][j];
			}else{
				DP[i+1][j] = max(DP[i][j],DP[i+1][j-w[i]] + v[i]);
			}
		}
	}
	cout("%d\n",DP[n][W]);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:33:13: error: no match for call to '(std::ostream {aka std::basic_ostream<char>}) (const char [4], int&)'
   33 |         cout("%d\n",DP[n][W]);
      |         ~~~~^~~~~~~~~~~~~~~~~
Language: C++

#include <iostream>
#include <algorithm>
using namespace std;
const int num = 10001, num1 = 101;
int dp[num1][num];
int w[num1], v[num1];
int n, W;
int main() {
	cin >> n >> W;
	for (int i = 0; i < n; i++)
		cin >> v[i] >> w[i];
	memset(dp, 0, sizeof(dp));
	for (int i = 0; i < n; i++)
		for (int j = 0; j <= W; j++) {
			if (w[i] > j) dp[i + 1][j] = dp[i][j];
			else dp[i + 1][j] = max(dp[i][j], dp[i + 1][j - w[i]] + v[i]);
		}
	cout << dp[n][W] << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:9: error: 'memset' was not declared in this scope
   12 |         memset(dp, 0, sizeof(dp));
      |         ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    2 | #include <algorithm>
  +++ |+#include <cstring>
    3 | using namespace std;
Language: C++

#include <iostream>
using namespace std;

int main(){
  int N,W;
  cin >> N >> W;
  int v[128],w[128];
  for(int i=1; i<=N; ++i){
    cin >> v[i] >> w[i];
  }

  int V[128][16384] = {};
  for(int i=0; i<=127; ++i) V[i][0] = 0;
  for(int i=0; i<=16383; ++i) V[0][i] = 0;
    
  for(int i=1; i<=N; ++i){
    for(int c=1; c<=W; ++c){
      int d = c / w[i];
      for(int k=0; k <= d; ++1){
        V[i][c] = max(V[i-1][c- k*w[i]] + k*v[i],V[i-1][c]);
      }
    }
  }

  cout << V[N][W] << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:30: error: lvalue required as increment operand
   19 |       for(int k=0; k <= d; ++1){
      |                              ^
Language: C++

#include<iostream>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<cmath>
#include<string>

using namespace std;

int main(){
int INF=1000000000;
int dp[1010][1010];
for(int i=0;i<=101;i++)for(int j=0;j<=1001;j++)dp[i][j]=-INF;
dp[0][0]=0;

int N,W;
cin >> N >> W;

for(int i=0;i<N;i++){
for(int j=0;j<=W;j++){
if(dp[i][j]==INF)continue;
if(dp[i][j]==dp[i][j+1]){
dp[i][j+1]=0;
}

if(j+w[i]<=W){
dp[i+1][j+w[i]]=max(v[i]+dp[i][j],dp[i+1][j+w[i]);
}
}
}
int ans=dp[0][0];
for(int b=0;b<N;b++){
for(int c=0;c<=w;j++){
if(ans<=dp[i][j])ans=dp[i][j];
}
}

cout << ans << endl;

  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:6: error: 'w' was not declared in this scope
   26 | if(j+w[i]<=W){
      |      ^
a.cc:27:21: error: 'v' was not declared in this scope
   27 | dp[i+1][j+w[i]]=max(v[i]+dp[i][j],dp[i+1][j+w[i]);
      |                     ^
a.cc:27:49: error: expected ']' before ')' token
   27 | dp[i+1][j+w[i]]=max(v[i]+dp[i][j],dp[i+1][j+w[i]);
      |                                                 ^
      |                                                 ]
a.cc:33:16: error: 'w' was not declared in this scope
   33 | for(int c=0;c<=w;j++){
      |                ^
a.cc:33:18: error: 'j' was not declared in this scope
   33 | for(int c=0;c<=w;j++){
      |                  ^
a.cc:34:12: error: 'i' was not declared in this scope
   34 | if(ans<=dp[i][j])ans=dp[i][j];
      |            ^
Language: C++

#include<iostream>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<cmath>
#include<string>

using namespace std;

int main(){
int INF=1000000000;
int dp[1010][1010];
for(int i=0;i<=101;i++)for(int j=0;j<=1001;j++)dp[i][j]=-INF;
dp[0][0]=0;

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

for(int i=0;i<N;i++){
for(int j=0;j<=W;j++){
if(dp[i][j]==INF)continue;
if(dp[i][j]==dp[i][j+1]){
dp[i][j+1]=0;
}

if(j+w[i]<=W){
dp[i+1][j+w[i]]=max(v[i]+dp[i][j],dp[i+1][j+w[i]);
}
}
}
int ans=dp[0][0];
for(int b=0;b<N;b++){
for(int c=0;c<=w;c++){
if(ans<=dp[i][j])ans=dp[i][j];
}
}

cout << ans << endl;

  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:32:49: error: expected ']' before ')' token
   32 | dp[i+1][j+w[i]]=max(v[i]+dp[i][j],dp[i+1][j+w[i]);
      |                                                 ^
      |                                                 ]
a.cc:38:14: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   38 | for(int c=0;c<=w;c++){
      |             ~^~~
a.cc:39:12: error: 'i' was not declared in this scope
   39 | if(ans<=dp[i][j])ans=dp[i][j];
      |            ^
a.cc:39:15: error: 'j' was not declared in this scope
   39 | if(ans<=dp[i][j])ans=dp[i][j];
      |               ^
Language: C++

#include<iostream>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<cmath>
#include<string>

using namespace std;

int main(){
int INF=1000000000;
int dp[1010][1010];
for(int i=0;i<=101;i++)for(int j=0;j<=1001;j++)dp[i][j]=-INF;
dp[0][0]=0;

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

for(int s=0;s<N;s++){
for(int t=0;t<=W;t++){
if(dp[s][t]==INF)continue;
if(dp[s][t]==dp[s][t+1]){
dp[s][t+1]=0;
}

if(t+w[s]<=W){
dp[s+1][t+w[s]]=max(v[s]+dp[s][t],dp[s+1][t+w[s]]);
}
}
}
int ans=dp[0][0];
for(int b=0;b<N;b++){
for(int c=0;c<=w;c++){
if(ans<=dp[b][c])ans=dp[b][c];
}
}

cout << ans << endl;

  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:10: error: 'i' was not declared in this scope
   21 | cin >> v[i] >> w[i];
      |          ^
a.cc:38:14: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   38 | for(int c=0;c<=w;c++){
      |             ~^~~
Language: C++

// ConsoleApplication3.cpp : ??????????????? ??¢????????±????????§????????¨????????? ?????????????????????????????????
//

#include "stdafx.h"
#include <iostream>
using namespace std;

int N;//??°
int W;//?????§???
int v[1000], w[1000];
int DP[10000][10000];

int main()
{
	cin >> N >> W;
	for (int j = 0; j < N; j++)
	{
		cin >> v[j];
		cin >> w[j];

	}
	for (int i = 0; i < W; i++)
	{
		for (int j = 0; j < N+1; j++)
		{

		DP[j][i] = 0;
	}
}


	for (int i = 1; i <= N; i++)
	{
		for (int j = 0; j <= W; j++)
		{
			if (j < w[i-1]) {//??????????????????????\?(????????¶???)
				DP[i][j] = DP[i - 1][j];

			}
			else	if (DP[i - 1][j] > DP[i][j - w[i - 1]] + v[i-1])//???:???????¶????
			{
				DP[i][j] = DP[i - 1][j];
			
			}
			else
			{
				DP[i][j] = DP[i][j-w[i-1]] + v[i-1];//DP[i][j] ?????????????????´DP[i][j-w[i-1]],i?????????N????????§v[i-1]
			
			}

		}
	}



	



cout << DP[N][W] << endl;

return 0;
}

Compiler output:
a.cc:4:10: fatal error: stdafx.h: No such file or directory
    4 | #include "stdafx.h"
      |          ^~~~~~~~~~
compilation terminated.
Language: C++

#include <iostream>
using namespace std;

int n,W;
int v[100],w[100];
int dp[101][10001];

int func(int i,int j){
    if(dp[i][j]>=0)return dp[i][j];
    int res;
    if(i==n){
        res=0;
    }
    else if (j<w[i]){
        res=func(i+1, j);
    }
    else{
        res=max(func(i+1, j-w[i])+v[i], max(func(i+1, j), func(i, j-w[i])+v[i]));
    }
    return dp[i][j]=res;
}

int main(){
    cin>>n>>W;
    for (int i=0; i<n; i++) {
        cin>>v[i]>>w[i];
    }
    memset(dp, -1, sizeof(dp));
    cout<<func(0,W)<<endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:28:5: error: 'memset' was not declared in this scope
   28 |     memset(dp, -1, sizeof(dp));
      |     ^~~~~~
a.cc:2:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    1 | #include <iostream>
  +++ |+#include <cstring>
    2 | using namespace std;