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

#include <utility>
#include <vector>

using namespace std;

//重さの和j以下で最初からi個まで選べるときの最大の価値
long weights[100],values[100];
map<pair<int,int>,long> table;

int max_value(const pair<int,int> &p){
  int i = p.first,j = p.second;
  auto p1 = make_pair(i-1,j);
  if(table.count(p1)==0) table[p1] = max_value(p1);
  if(j-weights[i-1]<0) return table[p1];

  auto p2 = make_pair(i-1,j-weights[i-1]);
  if(table.count(p2)==0) table[p2] = max_value(p2);

  return max(table[p1],table[p2]+values[i-1]);
}

int main(){
  int N,W;
  cin>>N>>W;
  for(int i=0;i<N;++i){
    cin>>weights[i]>>values[i];
  }
  
  for(int i=0;i<=N;++i) table[make_pair(i,0)]=0;
  for(int j=0;j<=W;++j) table[make_pair(0,j)]=0;

  cout<<max_value(make_pair(N,W))<<endl;

  return 0;
}

Compiler output:
a.cc:8:1: error: 'map' does not name a type
    8 | map<pair<int,int>,long> table;
      | ^~~
a.cc: In function 'int max_value(const std::pair<int, int>&)':
a.cc:13:6: error: 'table' was not declared in this scope; did you mean 'mutable'?
   13 |   if(table.count(p1)==0) table[p1] = max_value(p1);
      |      ^~~~~
      |      mutable
a.cc:14:31: error: 'table' was not declared in this scope; did you mean 'mutable'?
   14 |   if(j-weights[i-1]<0) return table[p1];
      |                               ^~~~~
      |                               mutable
a.cc:17:6: error: 'table' was not declared in this scope; did you mean 'mutable'?
   17 |   if(table.count(p2)==0) table[p2] = max_value(p2);
      |      ^~~~~
      |      mutable
a.cc:19:14: error: 'table' was not declared in this scope; did you mean 'mutable'?
   19 |   return max(table[p1],table[p2]+values[i-1]);
      |              ^~~~~
      |              mutable
a.cc: In function 'int main()':
a.cc:24:3: error: 'cin' was not declared in this scope
   24 |   cin>>N>>W;
      |   ^~~
a.cc:3:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    2 | #include <vector>
  +++ |+#include <iostream>
    3 | 
a.cc:29:25: error: 'table' was not declared in this scope; did you mean 'mutable'?
   29 |   for(int i=0;i<=N;++i) table[make_pair(i,0)]=0;
      |                         ^~~~~
      |                         mutable
a.cc:30:25: error: 'table' was not declared in this scope; did you mean 'mutable'?
   30 |   for(int j=0;j<=W;++j) table[make_pair(0,j)]=0;
      |                         ^~~~~
      |                         mutable
a.cc:32:3: error: 'cout' was not declared in this scope
   32 |   cout<<max_value(make_pair(N,W))<<endl;
      |   ^~~~
a.cc:32:3: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:32:36: error: 'endl' was not declared in this scope
   32 |   cout<<max_value(make_pair(N,W))<<endl;
      |                                    ^~~~
a.cc:3:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
    2 | #include <vector>
  +++ |+#include <ostream>
    3 |
Language: C++

#include <iostream>
#include <vector>
#include <numeric>
using namespace std;

int main () {
    long N, W;
    cin >> N >> W;
    long w[101], v[101];
    for (int i = 0; i < N ; i++) {
        cin >> w[i] >> v[i];
    }
    vector<long> v0, v1, v2, v3;
    for (int i = 0; i < N; i++) {
        if (w[i] == w[0]) {
            v0.push_back(v[i]);
        }
        else if (w[i] == w[0] + 1) {
            v1.push_back(v[i]);
        }
        else if (w[i] == w[0] + 2) {
            v2.push_back(v[i]);
        }
        else {
            v3.push_back(v[i]);
        }
    }
    
    sort(v0.begin(), v0.end(), greater<long>());
    sort(v1.begin(), v1.end(), greater<long>());
    sort(v2.begin(), v2.end(), greater<long>());
    sort(v3.begin(), v3.end(), greater<long>());
    
    int l0 = v0.size();
    int l1 = v1.size();
    int l2 = v2.size();
    int l3 = v3.size();
    
    long sum = 0;
    
    for (int a = 0; a <= l0; a++) {
        for (int b = 0; b <= l1; b++) {
            for (int c = 0; c <= l2; c++) {
                for (int d = 0; d <= l3; d++) {
                    long s = accumulate(v0.begin(), v0.begin() + a, 0) + accumulate(v1.begin(), v1.begin() + b, 0) + accumulate(v2.begin(), v2.begin() + c, 0) + accumulate(v3.begin(), v3.begin() + d, 0);
                    if (w[0] * a + (w[0] + 1) * b + (w[0] + 2) * c + (w[0] + 3) * d <= W and sum < s) {
                        sum = s;
                    }
                }
            }
        }
    }
    cout << sum << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:29:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   29 |     sort(v0.begin(), v0.end(), greater<long>());
      |     ^~~~
      |     short
Language: C++

#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>

#define CH(N,A,B) (A<=N&&N<B)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define RREP(i,a,b) for(int i=(b-1);a<=i;i--)

using namespace std;

int INF = 1000000005;

int main() {

  int N, W, w[105], v[105];
  int minw = INF;
  cin>>N>>W;
  REP(i,0,N){
    cin>>w[i]>>v[i];
    minw = min(minw, w[i]);
  }

  long long dp[105][310];
  REP(i,0,105)REP(j,0,310) dp[i][j] = 0;

  REP(i,1,N+1){
    REP(j,0,(W-minw)+2){
      //if(j < w[i-1]-minw+1) continue;
      long long  tmp = (j+minw-1)-w[i-1]
      int ind;

      if(0 <= tmp && tmp < minw) ind = 0;
      else if(minw <= tmp) ind = (j+minw-1) - w[i-1]-1;

      if(0 <= ind && j >= w[i-1]-minw+1) dp[i][j] = max(dp[i-1][j], dp[i-1][ind] + v[i-1]);
      else dp[i][j] = dp[i-1][j];
    }
  }

  cout<<dp[N][W-minw+1]<<endl;

  //test
/*
  REP(i,0,N+1){
    REP(j,0,(W-minw)+5){
      cout<<dp[i][j]<<" ";
    }
    cout<<endl;
  }
*/

  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:39:7: error: expected ',' or ';' before 'int'
   39 |       int ind;
      |       ^~~
a.cc:41:34: error: 'ind' was not declared in this scope; did you mean 'int'?
   41 |       if(0 <= tmp && tmp < minw) ind = 0;
      |                                  ^~~
      |                                  int
a.cc:42:28: error: 'ind' was not declared in this scope; did you mean 'int'?
   42 |       else if(minw <= tmp) ind = (j+minw-1) - w[i-1]-1;
      |                            ^~~
      |                            int
a.cc:44:15: error: 'ind' was not declared in this scope; did you mean 'int'?
   44 |       if(0 <= ind && j >= w[i-1]-minw+1) dp[i][j] = max(dp[i-1][j], dp[i-1][ind] + v[i-1]);
      |               ^~~
      |               int
Language: C++

#include<iostream>
#include <algorithm>
#include<stdint>
using namespace std;
#define MAX 100
#define PATURN 4
int knapsack(int W, int w, int wm, int *ws, int wv[][MAX], int s[][MAX+1], int c, int v) {
	int ret = v;
	if (c >= PATURN) return 0;
	for (int i = 0;i <= ws[c];i ++) {
		if (w+(wm+c)*i<=W) ret = max(ret, knapsack(W, w+(wm+c)*i, wm, ws, wv, s, c+1, v+s[c][i]));
	}
	return ret;
}
int main() {
	int n, w, wm, ws[PATURN], wv[PATURN][MAX], wc, s[PATURN][MAX+1];
	for (int i = 0;i < PATURN;i ++) {
		ws[i] = 0;
	}
	cin >> n >> w;
	cin >> wm >> wv[0][0];
	ws[0] ++;
	for (int i = 1;i < n;i ++) {
		cin >> wc;
		cin >> wv[wc-wm][ws[wc-wm]];
		ws[wc-wm] ++;
	}
	for (int i = 0;i < PATURN;i ++) {
		sort(wv[i], wv[i]+ws[i]);
		s[i][0] = 0;
		for (int j = 0;j < ws[i];j ++) {
			s[i][j+1] = s[i][j] + wv[i][j];
		}
	}
	int ret = 0;
	for (int i = 0;i <= ws[0];i ++) {
		if (wm*i<=w) ret = max(ret, knapsack(w, wm*i, wm, ws, wv, s, 1, s[0][i]));
	}
	cout << ret;
}

Compiler output:
a.cc:3:9: fatal error: stdint: No such file or directory
    3 | #include<stdint>
      |         ^~~~~~~~
compilation terminated.
Language: C++

#include <iostream>
#include <cstdio>
using namespace std;
typedef long long ll;
ll dp[1000000100];
int v[100000010],w[100000010];
const ll INF=(ll)1<<62;
int main()
{
    int T;
        int n,b;
        scanf("%d%d",&n,&b);

        ll tot_w=0,tot_v=0;
        for(int i=0 ; i<n ; ++i)
        {
            scanf("%d%d",&w[i],&v[i]);
            tot_v+=v[i];
            tot_w+=w[i];
        }
        for(int i=0 ; i<=tot_v ; ++i)
        {
            dp[i]=INF;
        }
        dp[tot_v]=tot_w;
        for(int i=0 ; i<n ; ++i)
        {
            for(int j=0 ; j<=tot_v ; ++j)
            {
                if(j-v[i]>=0)
                {
                    if(dp[j]-w[i]>=0)
                        dp[j-v[i]]=min(dp[j-v[i]],dp[j]-w[i]);
                }
            }
        }
        for(int i=tot_v ; i>=0 ; --i)
        {
            if(dp[i]<=b)
            {
                printf("%d\n",i);
                break;
            }
        }
    return 0;
}

Compiler output:
/tmp/ccnB2VFA.o: in function `main':
a.cc:(.text+0x53): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccnB2VFA.o
a.cc:(.text+0x6a): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccnB2VFA.o
a.cc:(.text+0x98): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccnB2VFA.o
a.cc:(.text+0xb5): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccnB2VFA.o
a.cc:(.text+0x14f): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccnB2VFA.o
a.cc:(.text+0x18b): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccnB2VFA.o
a.cc:(.text+0x1c8): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccnB2VFA.o
a.cc:(.text+0x1e8): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccnB2VFA.o
a.cc:(.text+0x229): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccnB2VFA.o
collect2: error: ld returned 1 exit status
Language: C++

#include <iostream>
#include <string>
#define REP(i,k,n) for(int(i)=(k);(i)<(n);(i)++)
using namespace std;

const int MAX_N = 100;
const long MAX_W = (long)1e9;

int N;
long w[MAX_N], v[MAX_N];
// メモ化テーブル
long dp[MAX_N + 1][MAX_W + 1];

// i番目以降の品物から重さの総和が
// j以下となるように選ぶ
// 戻り値: その選び方をしたときの価値の総和
// j: 残りの容量 (重さ)
long rec(int i, long j)
{
  // メモを利用
  if (dp[i][j] >= 0) return dp[i][j];

  int res;
  if (i == N) res = 0;
  // 商品 i は入らない
  // 他の商品が入るか試す
  else if (j < w[i]) res = rec(i+1, j);
  // 商品 i を入れる場合・入れない場合を両方とも試して、
  // たくさん入る方をとる
  else res = max(rec(i+1, j),
                 rec(i+1, j - w[i]) + v[i]);
  dp[i][j] = res;
  return res;
}

int main()
{
  long W;
  cin >> N >> W;
  REP(i,0,N) cin >> w[i] >> v[i];
  // dp テーブル初期化 (-1 で)
  memset(dp, -1, sizeof(dp));
  // REP(i,0,N+1) {
  //   for (long j = 0; j < W + 1; ++j) dp[i][j] = -1;
  // }

  long res = rec(0, W);
  cout << res << endl;

  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:42:3: error: 'memset' was not declared in this scope
   42 |   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 | #include <string>
Language: C++

#include<bits/stdc++.h>

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

ll N;
ll W;
ll w[100];
ll v[100];
ll dp[100 + 1][100 + 1];

ll DP(ll i, ll j) {	//i番目以降重さj以下
	if (dp[i][j] != -1) {
		return dp[i][j];
	}
	ll res;
	if (i == N) {
		res = 0;
	}
	else if (j < w[i]) {
		res = DP(i + 1, j);
	}
	else {
		res = max(DP(i + 1, j), DP(i + 1, j - w[i]) + v[i]);
	}
	return dp[i][j] = res;
}

int main() {
	cin.sync_with_stdio(false);
	cin >> N >> W;
	
	rep(i, N) {
		cin >> w[i] >> v[i];
		if (W >= w[0]) {
			w[i] = w[i] - (w[0] - 1);
			if (i == 0) {
				W = W - (w[0] - 1);
			}
		else {
			w[i] = w[i]-W+1;
			W = 1;
			}
	}
	
	memset(dp, -1, sizeof(dp));
	
	cout << DP(0, W) << endl;
	return 0;
}

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

#include <bits/stdc++.h>
#include <stdio.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,b) FOR(i,0,b)
#define INF 1e9

int N,W,w[100],v[100],dp[100][10000];

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 < w[i]) {
    res = rec(i+1,j);
  } else {
    res = max(rec(i+1,j), rec(i+1,j-w[i])+v[i]);
  }

  return dp[i][j] = res;
}

void solve(){
  menset(dp,-1,sizeof(dp));
  printf("%d\n", rec(0, W));
}

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

  REP(i,N){
    cin>>w[i]>>v[i];
  }

  return 0;
}


Compiler output:
a.cc: In function 'void solve()':
a.cc:28:3: error: 'menset' was not declared in this scope; did you mean 'memset'?
   28 |   menset(dp,-1,sizeof(dp));
      |   ^~~~~~
      |   memset
Language: C++

#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <numeric>
#include <limits>
#include <utility>
using namespace std;
long long n, W;
vector<long long> w(100);
vector<long long> v(100);
vector< vector<long long> > dp(101, vector<long long>(101));

long long dpp(long long, long long);

int main(void) {
	long long i, j;
	cin >> n >> W;
	vector< vector<long long> > m(101, vector<long long>(101));

	for (i = 0; i < n; i++) {
		cin >> w[i] >> v[i];
	}
	for (int i = 0; i < 101; i++) {
		for (int j = 0; j < 101; j++) {
			dp[i][j] = -1;
		}
	}
	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]);
		}
	}
	cout << dpp(0,W) << endl;

	return 0;
}

Compiler output:
/usr/bin/ld: /tmp/ccu5IXZd.o: in function `main':
a.cc:(.text+0x326): undefined reference to `dpp(long long, long long)'
collect2: error: ld returned 1 exit status
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,b) FOR(i,0,b)
#define INF 1e9

int N,W,w[100],v[100],dp[100][10000];

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 < w[i]) {
    res = rec(i+1,j);
  } else {
    res = max(rec(i+1,j), rec(i+1,j-w[i])+v[i]);
  }

  return dp[i][j] = res;
}

void solve(){
  menset(dp,-1,sizeof(dp));
  printf("%d\n", rec(0, W));
}

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

  REP(i,N){
    cin>>w[i]>>v[i];
  }

  return 0;
}


Compiler output:
a.cc: In function 'void solve()':
a.cc:27:3: error: 'menset' was not declared in this scope; did you mean 'memset'?
   27 |   menset(dp,-1,sizeof(dp));
      |   ^~~~~~
      |   memset
Language: C

#include <stdio.h>

void max_value(const int N, const long weight, long w[], long v[], double*ans, double *box, double *rweight, int *a)
{
	int i, b;
	double bweight = 0;

	for (i = 0; i + a < N; i++)
	{
		b = a;
		if(rweight + w[i+b] <= weight)
		{
			bweight = w[i + b];
			rweight += w[i+b];
			box += v[i+ b];
			a++;
			max_value(N, weight, w, v, ans, box, rweight, a);
		}
		else {
			if (box > ans)
				ans = box;
		}
		a = 0;
		rweight -= bweight;
	}
}

int main()
{
	int n, a;
	long weight, i;
	double ans, box, rweight;

	rweight = 0; a = 0;

	scanf("%d %ld", &n, &weight);

	long w[100], v[100];

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

	ans = 0;	box = 0;

	max_value(n, weight, w, v, &ans, &box, &rweight, &a);

	printf("%ld", ans);

		
	return 0;
}

Compiler output:
main.c: In function 'max_value':
main.c:8:27: warning: comparison between pointer and integer
    8 |         for (i = 0; i + a < N; i++)
      |                           ^
main.c:10:19: error: assignment to 'int' from 'int *' makes integer from pointer without a cast [-Wint-conversion]
   10 |                 b = a;
      |                   ^
main.c:11:37: warning: comparison between pointer and integer
   11 |                 if(rweight + w[i+b] <= weight)
      |                                     ^~
main.c:24:25: error: invalid operands to binary - (have 'double *' and 'double')
   24 |                 rweight -= bweight;
      |                         ^~
Language: C++

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

int main(void) {
  int N, W;
	cin >> N >> W;
  int w[N], v[N];
  REP(i,N) cin >> w[i] >> v[i];

  int dp[N+1][W];

  for (int j = 0; j <= W; j++) {
    dp[N][j] = 0;
  }
  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]);
    }
  }

  solve_dp(N,W,w,v,dp);
  cout << dp[0][W] << '\n';
}



Compiler output:
a.cc: In function 'int main()':
a.cc:25:3: error: 'solve_dp' was not declared in this scope
   25 |   solve_dp(N,W,w,v,dp);
      |   ^~~~~~~~
Language: C++

#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<utility>
#include<memory>
#include<cmath>
 
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define pb push_back
 
using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const int MAX_N=102,MAX_W=100002;

ll dp[MAX_N][MAX_W];
int N; ll W;
ll w[MAX_N],v[MAX_N];

void calc(){
  fill(dp[0],dp[N+1],0);
  rep(i,N){
    rep(j,W+1){
      dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
      if(j+w[i]<=W){
        dp[i+1][j+w[i]]=max(dp[i+1][j+w[i]],dp[i][j]+v[i]);
      }
    }
  }
  return;
}

int main(){
  cin >> N >> W ;
  ll temp=0;
  int N2=0;
  rep(i,N){
    ll a,b;
    scanf("%lld%lld",&a,&b);
    if(a<=W){
      N2++;
      w[i]=a; v[i]=b;
      temp=max(temp,a);
    }
  }
  N=N2;
  if(W<MAX_W-2){
    calc();
    printf("%lld\n",dp[N][W]);
  }else{
    W/=temp;
    cout << W << endl;
    rep(i,N){
      w[i]=(w[i]+temp-1)/temp;
      cout << w[i] << endl;
    }
    if(W<MAX_W-2){
      calc();
      printf("%lld\n",dp[N][W]);
    }else{
      ll S=0;
      rep(i,N) S+=v[i];
      printf("%lld\n",S);
    // sort(v,v+N);
    // reverse(v,v+N);
    // ll S=0;
    // rep(i,min(W,(ll)N)){
    //   S+=v[i];
    // }
    // printf("%lld\n",S);
  }

  return 0;
}


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

#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,b) FOR(i,0,b)
#define INF 1e9

int N,W,w[100],v[100],dp[100][10000];

cin>>N>>W;

REP(i,N){
  cin>>w[i]>>v[i];
}

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 < w[i]) {
    res = rec(i+1,j);
  } else {
    res = max(rec(i+1,j), rec(i+1,j-w[i])+v[i]);
  }

  return dp[i][j] = res;
}

void solve(){
  menset(dp,-1,sizeof(dp));
  printf("%d\n", rec(0, W));
}

int main(){
  return 0;
}


Compiler output:
a.cc:9:1: error: 'cin' does not name a type
    9 | cin>>N>>W;
      | ^~~
a.cc:3:20: error: expected unqualified-id before 'for'
    3 | #define FOR(i,a,b) for(int i=a;i<b;i++)
      |                    ^~~
a.cc:4:18: note: in expansion of macro 'FOR'
    4 | #define REP(i,b) FOR(i,0,b)
      |                  ^~~
a.cc:11:1: note: in expansion of macro 'REP'
   11 | REP(i,N){
      | ^~~
a.cc:11:5: error: 'i' does not name a type
   11 | REP(i,N){
      |     ^
a.cc:3:32: note: in definition of macro 'FOR'
    3 | #define FOR(i,a,b) for(int i=a;i<b;i++)
      |                                ^
a.cc:11:1: note: in expansion of macro 'REP'
   11 | REP(i,N){
      | ^~~
a.cc:11:5: error: 'i' does not name a type
   11 | REP(i,N){
      |     ^
a.cc:3:36: note: in definition of macro 'FOR'
    3 | #define FOR(i,a,b) for(int i=a;i<b;i++)
      |                                    ^
a.cc:11:1: note: in expansion of macro 'REP'
   11 | REP(i,N){
      | ^~~
a.cc: In function 'void solve()':
a.cc:33:3: error: 'menset' was not declared in this scope; did you mean 'memset'?
   33 |   menset(dp,-1,sizeof(dp));
      |   ^~~~~~
      |   memset
Language: C++

#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cctype>
#define rep(i,a,b) for(int (i)=(a);i<(b);i++)
#define MAX_N 105
#define MAX_V 10000000
#define INF 10000000
using namespace std;
bool debug=false;

long long dp[MAX_N][MAX_V+1];
int N,W;
int w[MAX_N],v[MAX_V];

long long solve(){
  rep(i,0,MAX_N)rep(j,0,MAX_V*MAX_N+1)dp[i][j]=INF;
  for(int i=0;i<=N;i++)dp[i][0]=0;
  
  for(int i=1;i<=N;i++){
    for(int j=0;j<MAX_V*MAX_N+1;j++){
      if (j-v[i]<0)dp[i][j]=dp[i-1][j];
	else dp[i][j]=min(dp[i-1][j],dp[i-1][j-v[i]]+w[i]);
    }
  }
  
  long long maxi=0;
  //for(int i=0;i<=10005;i++)if(dp[N][i]!=INF)cout<<dp[N][i]<<endl;
  for(int i=0;i<=MAX_N*MAX_V;i++)if(dp[N][i]<=W)maxi=i;
  return maxi;
}

int main(){
  cin>>N>>W;
  for(int i=1;i<=N;i++)cin>>w[i]>>v[i];
  cout<<solve()<<endl;
  return 0;
}


Compiler output:
/tmp/ccPOoeko.o: in function `solve()':
a.cc:(.text+0x87): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/ccPOoeko.o
a.cc:(.text+0xb8): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccPOoeko.o
a.cc:(.text+0x137): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccPOoeko.o
a.cc:(.text+0x176): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccPOoeko.o
a.cc:(.text+0x203): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/ccPOoeko.o
a.cc:(.text+0x223): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/ccPOoeko.o
a.cc:(.text+0x24e): relocation truncated to fit: R_X86_64_PC32 against symbol `W' defined in .bss section in /tmp/ccPOoeko.o
/tmp/ccPOoeko.o: in function `main':
a.cc:(.text+0x280): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/ccPOoeko.o
a.cc:(.text+0x29c): relocation truncated to fit: R_X86_64_PC32 against symbol `W' defined in .bss section in /tmp/ccPOoeko.o
a.cc:(.text+0x2c4): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccPOoeko.o
a.cc:(.text+0x2f0): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
Language: C++

    #include<bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    #define loop(i,a,b) for(i=a;i<b;i++)
    #define rloop(i,a,b) for(i=a;i>=b;i--)
    #define vi vector<int>
    #define vs vector<string>
    const int inf=1000000001;
    const ll INF=1e16;
    #define MOD 1000000007
    #define mod 1000000009
    #define pi 3.14159265358979323846
     
     
    int main(){
    	ll n,w,i,j,k;
    	cin>>n>>w;
    	vector<ll> weight(n),value(n);
    	loop(i,0,n){
    		cin>>weight[i]>>value[i];
    	}
    	vector<ll> dp(w+1,-1);
    	dp[0]=0;
    	loop(i,0,n){
    		rloop(j,w,0){
    			if(dp[j]!=-1 && j+weight[i]<=w){
    				dp[j+w[i]]=min(dp[j+weight[i]],dp[j]+value[i]);
    			}
    		}
    	}
    	ll m=0;
    	loop(i,0,w+1){
    		if(dp[i]!=-1){
    			m=max(m,dp[i]);
    		}
    	}
    	cout<<m<<endl;
    }

Compiler output:
a.cc: In function 'int main()':
a.cc:27:39: error: invalid types 'll {aka long long int}[ll {aka long long int}]' for array subscript
   27 |                                 dp[j+w[i]]=min(dp[j+weight[i]],dp[j]+value[i]);
      |                                       ^
Language: C++

    #include<bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    #define loop(i,a,b) for(i=a;i<b;i++)
    #define rloop(i,a,b) for(i=a;i>=b;i--)
    #define vi vector<int>
    #define vs vector<string>
    const int inf=1000000001;
    const ll INF=1e16;
    #define MOD 1000000007
    #define mod 1000000009
    #define pi 3.14159265358979323846
     
     
    int main(){
    	int n,w,i,j,k;
    	cin>>n>>w;
    	vi weight(n),value(n);
    	loop(i,0,n){
    		cin>>weight[i]>>value[i];
    	}
    	vector<ll> dp(w+1,-1);
    	dp[0]=0;
    	loop(i,0,n){
    		rloop(j,w,0){
    			if(dp[j]!=-1 && j+weight[i]<=w){
    				dp[j+w[i]]=min(dp[j+weight[i]],dp[j]+value[i]);
    			}
    		}
    	}
    	ll m=0;
    	loop(i,0,w+1){
    		if(dp[i]!=-1){
    			m=max(m,dp[i]);
    		}
    	}
    	cout<<m<<endl;
    }

Compiler output:
a.cc: In function 'int main()':
a.cc:27:39: error: invalid types 'int[int]' for array subscript
   27 |                                 dp[j+w[i]]=min(dp[j+weight[i]],dp[j]+value[i]);
      |                                       ^
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <string.h>
using namespace std;
int dp[101][1000000001];
int n,w;
vector<int> W(101),V(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< W[i]) {
        res = rec(i+1, j);
    } else {
        res = max(rec(i+1, j), rec(i+1, j-W[i]) + V[i]);
    }
    return dp[i][j] = res;
}

int main(int argc, const char * argv[]) {
    cin >> n >> w;
    
    for (int i=0; i<n; i++) {
        cin >> W[i] >> V[i];
    }
    memset(dp, -1, sizeof(dp));
    cout << rec(0, w);
    return 0;
}

Compiler output:
/tmp/ccFxNfi9.o: in function `rec(int, int)':
a.cc:(.text+0x68): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccFxNfi9.o
a.cc:(.text+0x88): relocation truncated to fit: R_X86_64_PC32 against symbol `W' defined in .bss section in /tmp/ccFxNfi9.o
a.cc:(.text+0xc2): relocation truncated to fit: R_X86_64_PC32 against symbol `W' defined in .bss section in /tmp/ccFxNfi9.o
a.cc:(.text+0xf1): relocation truncated to fit: R_X86_64_PC32 against symbol `V' defined in .bss section in /tmp/ccFxNfi9.o
/tmp/ccFxNfi9.o: in function `main':
a.cc:(.text+0x19b): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccFxNfi9.o
a.cc:(.text+0x1b7): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccFxNfi9.o
a.cc:(.text+0x1da): relocation truncated to fit: R_X86_64_PC32 against symbol `W' defined in .bss section in /tmp/ccFxNfi9.o
a.cc:(.text+0x206): relocation truncated to fit: R_X86_64_PC32 against symbol `V' defined in .bss section in /tmp/ccFxNfi9.o
a.cc:(.text+0x223): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccFxNfi9.o
a.cc:(.text+0x24f): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccFxNfi9.o
/tmp/ccFxNfi9.o: in function `__static_initialization_and_destruction_0()':
a.cc:(.text+0x29d): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
Language: C++

#include <iostream>
#include <fstream>
#include <cstring>
#include <algorithm>
#include <vector>

using namespace std;
struct obj{int val, g;} x,v1[105],a[9];
int l1,l2,b,c,n,T,d[50001],i,gmax,dif,maxi,poz,nrv,nr2,iok,jok,j;
long long sumg,sumval;
vector<obj> v[5];

bool cmp(obj a, obj b)
{
    return a.g>b.g || (a.g==b.g && a.val<b.val);
}

int main()
{
    cin>>n>>gmax;
    cin>>x.g>>x.val;
    v[0].push_back(x);
    v1[1]=x;
    for(i=2;i<=n;i++)
    {
        cin>>x.g>>x.val;
        v1[i]=x;
        dif=x.g-v[0][0].g;
        v[dif].push_back(x);
    }
    if(gmax<=40000)
    {
        d[0]=1;
        for(i=1;i<=n;i++)
        {
            for(poz=gmax-v1[i].g;poz>=0;poz--)
            {
                if(d[poz] && d[poz+v1[i].g]<d[poz]+v1[i].val) d[poz+v1[i].g]=d[poz]+v1[i].val;
            }
        }
        for(i=0;i<=gmax;i++) if(d[i]>maxi) maxi=d[i];
        cout<<maxi-1<<'\n';
    }
    else
    {
        for(i=1;i<=n;i++) sumg+=v1[i].g, sumval+=v1[i].val;
        if(sumg<=gmax) //cout<<sumval<<'\n';
        else
        {
            for(i=0;i<=3;i++) sort(v[i].begin(),v[i].end(),cmp);
            sumval=0;
            while(gmax>=2*(v1[1].g+3))
            {
                maxi=0;
                nrv=-1;
                for(i=0;i<=3;i++) if(!v[i].empty() && v[i].back().val>maxi) maxi=v[i].back().val, nrv=i;
                sumval+=v[nrv].back().val;
                gmax-=v[nrv].back().g;
                v[nrv].pop_back();
            }
            nr2=0;
            for(i=0;i<=3;i++)
            {
                if(v[i].size()==1) a[++nr2]=v[i].back();
                if(v[i].size()>=2)
                {
                    a[++nr2]=v[i].back();
                    v[i].pop_back();
                    a[++nr2]=v[i].back();
                }
            }
            maxi=0; iok=0; jok=0;
            for(i=1;i<nr2;i++)
            {
                for(j=i+1;j<=nr2;j++)
                {
                    if(a[i].g+a[j].g<=gmax && a[i].val+a[j].val>=maxi) maxi=a[i].val+a[j].val, iok=i, jok=j;
                }
            }
            cout<<sumval+maxi<<'\n';
        }
    }
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:48:9: error: expected primary-expression before 'else'
   48 |         else
      |         ^~~~
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int dp[101][101];
int n,w;
vector<int> W(101),V(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< W[i]) {
        res = rec(i+1, j);
    } else {
        res = max(rec(i+1, j), rec(i+1, j-W[i]) + V[i]);
    }
    return dp[i][j] = res;
}

int main(int argc, const char * argv[]) {
    cin >> n >> w;
    
    for (int i=0; i<n; i++) {
        cin >> W[i] >> V[i];
    }
    memset(dp, -1, sizeof(dp));
    cout << rec(0, w);
    return 0;
}


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

#include <iostream>
#include <vector>

using namespace std;
//table[w][i]:重さw1以上w以下でi番目まで入れたときの最大の価値
int main(){
  int N,W;
  cin>>N>>W;
  vector<int> weights(N),values(N);
  for(int i=0;i<N;++i){
    cin>>weights[i]>>values[i];
  }

  // int first_weight = weights[0];
  // if(first_weight>W){
  //   cout<<0<<endl;
  //   return 0;
  // }
  // for(auto &w:weights) w -= first_weight;
  // W -= first_weight;
  // vector<vector<int>> table(W+1,vector<int>(N+1));

  for(int w=1;w<=W;++w){
    for(int i=1;i<=N;++i){
      if(w<weights[i-1]){
        table[w][i] = table[w][i-1];
      }else{
        table[w][i] = max(table[w-weights[i-1]][i-1]+values[i-1],table[w][i-1]);
      }
    }
  }
  cout<<table[W][N]<<endl;

  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:9: error: 'table' was not declared in this scope; did you mean 'mutable'?
   26 |         table[w][i] = table[w][i-1];
      |         ^~~~~
      |         mutable
a.cc:28:9: error: 'table' was not declared in this scope; did you mean 'mutable'?
   28 |         table[w][i] = max(table[w-weights[i-1]][i-1]+values[i-1],table[w][i-1]);
      |         ^~~~~
      |         mutable
a.cc:32:9: error: 'table' was not declared in this scope; did you mean 'mutable'?
   32 |   cout<<table[W][N]<<endl;
      |         ^~~~~
      |         mutable
Language: C++

#include <iostream>
#include <vector>

using namespace std;
int dp[101][101];
int n,w;
vector<int> W(101),V(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< W[i]) {
        res = rec(i+1, j);
    } else {
        res = max(rec(i+1, j), rec(i+1, j-W[i]) + V[i]);
    }
    return dp[i][j] = res;
}

int main(int argc, const char * argv[]) {
    cin >> n >> w;
    
    for (int i=0; i<n; i++) {
        cin >> W[i] >> V[i];
    }
    memset(dp, -1, sizeof(dp));
    cout << rec(0, w);
    return 0;
}

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

#include"bits/stdc++.h"
//#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define print(x) cout<<x<<endl;
typedef long long ll;

int N;
ll W;
ll w[105], v[105];
ll table[102][1000002];

ll dp(int now, ll mergin) {
	ll sum = 0;
	if (table[now][mergin] != -1) return table[now][mergin];
	if (now == N) { sum = 0; }
	else if (mergin < w[now]) { sum = 0; }
	else {
		sum = max(dp(now + 1, mergin), dp(now + 1, mergin - w[now]) + v[now]);
	}
	return table[now][mergin] = sum;
}

int main() {
	memset(dp, -1, sizeof(table));
	cin >> N >> W;
	rep(i, 0, N) cin >> w[i] >> v[i];
	print(dp(0,W));
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:16: error: invalid conversion from 'll (*)(int, ll)' {aka 'long long int (*)(int, long long int)'} to 'void*' [-fpermissive]
   25 |         memset(dp, -1, sizeof(table));
      |                ^~
      |                |
      |                ll (*)(int, ll) {aka long long int (*)(int, long long int)}
In file included from /usr/include/c++/14/cstring:43,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:121,
                 from a.cc:1:
/usr/include/string.h:61:28: note:   initializing argument 1 of 'void* memset(void*, int, size_t)'
   61 | extern void *memset (void *__s, int __c, size_t __n) __THROW __nonnull ((1));
      |                      ~~~~~~^~~
Language: C++

#include <bits/stdc++.h>

using namespace std;

#define MAX_N 100
#define MAX_W 1000
long long n;
long long dp[MAX_N+1][MAX_W+1];
long long weight[MAX_N+1];
long long cost[MAX_N+1];
long long CAP;
long long func(long long i,long long w)
{
    if(i==n+1) return 0;
    if(dp[i][w]!=-1) return dp[i][w];
    long long profit1=0,profit2=0;
    if(w+weight[i]<=CAP)
        profit1=cost[i]+func(i+1,w+weight[i]);

    profit2=func(i+1,w);
    dp[i][w]=max(profit1,profit2);
    return dp[i][w];
}
void main()
{

    //freopen("in","r",stdin);
    memset(dp,-1,sizeof(dp));
    scanf("%lld%lld",&n,&CAP);
    for(long long i=1; i<=n; i++)
    {
        scanf("%lld %lld",&weight[i],&cost[i]);
    }
    printf("%lld\n",func(1,0));
}

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

#include<iostream>
//#define int long long int
using namespace std;
int dp[105][105];
int n,tw,v[105],w[105],i,j;
knap(int n,int tw)
{
    int i,j;
     for(i=0; i<n; i++)
    {
        for(j=0; j<=tw; j++)
        {
            if(j==0) dp[i][j]=0;
            else if(j<w[i])dp[i][j]=dp[i-1][j];
            else dp[i][j]=max(v[i]+dp[i-1][j-w[i]],dp[i-1][j]);
        }
    }
    return dp[n-1][tw];
}
 int main()
{

    while(cin>>n>>tw)
    {
        for(i=0;i<n;i++)
        {
            cin>>w[i]>>v[i];
        }
        cout<<knap(n,tw)<<endl;
    }
    return 0;
}


Compiler output:
a.cc:6:1: error: ISO C++ forbids declaration of 'knap' with no type [-fpermissive]
    6 | knap(int n,int tw)
      | ^~~~
Language: C++

#include<bits/stdc++.h>
//#define int long long int
using namespace std;
int dp[105][105];
int n,tw,v[105],w[105],i,j;
knap(int n,int tw)
{
    int i,j;
     for(i=0; i<n; i++)
    {
        for(j=0; j<=tw; j++)
        {
            if(j==0) dp[i][j]=0;
            else if(j<w[i])dp[i][j]=dp[i-1][j];
            else dp[i][j]=max(v[i]+dp[i-1][j-w[i]],dp[i-1][j]);
        }
    }
    return dp[n-1][tw];
}
 int main()
{

    while(cin>>n>>tw)
    {
        for(i=0;i<n;i++)
        {
            cin>>w[i]>>v[i];
        }
        cout<<knap(n,tw)<<endl;
    }
    return 0;
}


Compiler output:
a.cc:6:1: error: ISO C++ forbids declaration of 'knap' with no type [-fpermissive]
    6 | knap(int n,int tw)
      | ^~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int dp[105][105];
int n,tw,v[105],w[105],i,j;
knap(int n,int tw)
{
    int i,j;
     for(i=0; i<n; i++)
    {
        for(j=0; j<=tw; j++)
        {
            if(j==0) dp[i][j]=0;
            else if(j<w[i])dp[i][j]=dp[i-1][j];
            else dp[i][j]=max(v[i]+dp[i-1][j-w[i]],dp[i-1][j]);
        }
    }
    return dp[n-1][tw];
}
int main()
{

    while(cin>>n>>tw)
    {
        for(i=0;i<n;i++)
        {
            cin>>w[i]>>v[i];
        }
        cout<<knap(n,tw)<<endl;
    }
}


Compiler output:
a.cc:5:1: error: ISO C++ forbids declaration of 'knap' with no type [-fpermissive]
    5 | knap(int n,int tw)
      | ^~~~
Language: C++

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

const int MAX_N = 100; // nの最大値
const int MAX_W = 810; // Wの最大値

int N, W;
int w[810], v[810];
int standard[1];

// メモ化テーブル。
// dp[i][j]はi番目以降の品物から重さの和がj以下なるように選んだときの価値の和の最大値を表す。
// -1なら値が未決定であることを表す
int dp[MAX_N + 1][MAX_W + 1];

// i番目以降の品物から重さの和がj以下なるように選んだときの、
// 取りうる価値の総和の最大値を返す関数
int rec_dp(int i, int j) {
	if (dp[i][j] != -1) {
		// すでに調べたことがあるならその結果を再利用
		return dp[i][j];
	}
	int res;
	if (i == N) {
		// 品物がもう残っていないときは、価値の和の最大値は0で確定
		res = 0;
	}
	else if (j < w[i]) {
		// 残りの容量が足りず品物iを入れられないので、入れないパターンだけ処理
		res = rec_dp(i + 1, j);
	}
	else {
		// 品物iを入れるか入れないか選べるので、両方試して価値の和が大きい方を選ぶ
		res = max(
			rec_dp(i + 1, j),
			rec_dp(i + 1, j - w[i]) + v[i]
		);
	}
	// 結果をテーブルに記憶する
	return dp[i][j] = res;
}

int solve_dp(int W) {
	memset(dp, -1, sizeof(dp)); // メモ化テーブルを-1で初期化　以下のforループと等価
								//  for (int i = 0; i < MAX_N + 1; i++)
								//    for (int j = 0; j < MAX_W + 1; j++)
								//      dp[i][j] = -1;

								// 0番目以降で容量W以下の場合の結果を表示する
	return rec_dp(0, W);
}

int main() {
	cin >> N >> W;
	for (int i = 0; i < N; i++)cin >> w[i] >> v[i];
	standard[1] = w[0];
	for (int i = 0; i < N; i++)w[i] -= standard[1];
	int ans = 0;
	for (int i = 0; i < N; i++) {
		ans = max(ans, rec_dp(0, W - standard[1] * i));
	}
	cout << ans << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int solve_dp(int)':
a.cc:45:9: error: 'memset' was not declared in this scope
   45 |         memset(dp, -1, sizeof(dp)); // メモ化テーブルを-1で初期化　以下のforループと等価
      |         ^~~~~~
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 <cstdio>
#include <vector>
#include <algorithm>
#define NMAX 105
#define WMAX 1000000005
#define DIAGONAL 1
#define TOP 0

using namespace std;

struct Item {
    int value, weight;
};

int N, W;
Item items[NMAX + 1];
int C[NMAX + 1][WMAX + 1], G[NMAX + 1][WMAX + 1];

void compute(int &maxValue, vector<int> &selection) {
    for (int w = 0; w <= W; w++) {
        C[0][w] = 0;
        C[0][w] = DIAGONAL;
    }

    for (int i = 1; i <= N; i++) C[i][0] = 0;

    for (int i = 1; i <= N; i++) {
        for (int w = 1; w <= W; w++) {
            C[i][w] = C[i - 1][w];
            G[i][w] = TOP;
            if (items[i].weight > w) continue;
            if (items[i].value + C[i - 1][w - items[i].weight] > C[i - 1][w]) {
                C[i][w] = items[i].value + C[i - 1][w - items[i].weight];
                G[i][w] = DIAGONAL;
            }
        }
    }

    maxValue = C[N][W];
    selection.clear();
    for (int i = N, w = W; i >= 1; i--) {
        if (G[i][w] == DIAGONAL) {
            selection.push_back(i);
            w -= items[i].weight;
        }
    }

    reverse(selection.begin(), selection.end());
}

void input() {
    scanf("%d%d", &N, &W);
    for (int i = 1; i <= N; i++) {
        scanf("%d%d", &items[i].value, &items[i].weight);
    }
}

int main() {
    int maxValue;
    vector<int> selection;
    input();
    compute(maxValue, selection);

    printf("%d", maxValue);

    return 0;
}


Compiler output:
/tmp/cc8CH3D0.o: in function `compute(int&, std::vector<int, std::allocator<int> >&)':
a.cc:(.text+0x11d): relocation truncated to fit: R_X86_64_PC32 against symbol `G' defined in .bss section in /tmp/cc8CH3D0.o
a.cc:(.text+0x27d): relocation truncated to fit: R_X86_64_PC32 against symbol `G' defined in .bss section in /tmp/cc8CH3D0.o
a.cc:(.text+0x324): relocation truncated to fit: R_X86_64_PC32 against symbol `G' defined in .bss section in /tmp/cc8CH3D0.o
collect2: error: ld returned 1 exit status
Language: C++

#include <iostream>
using namespace std;

long* w;
long* v;
long dp[1000000000 + 1][100 + 1];

long solve(long weight, int select) {
  if (dp[weight][select] >= 0) {
    return dp[weight][select];
  }
  if (weight < 0 || select < 0) {
    return 0;
  } else if (weight - w[select] >= 0){
    return max(solve(weight - w[select], select - 1) + v[select], solve(weight, select - 1));
  } else {
    return solve(weight, select - 1);
  }
}

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

  w = (long*)malloc(sizeof(long) * N);
  v = (long*)malloc(sizeof(long) * N);
  for (int i = 0; i < N; i++) {
    cin >> w[i];
    cin >> v[i];
  }
  memset(dp, -1, sizeof(dp));
  cout << solve(W, N - 1) << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:33:3: error: 'memset' was not declared in this scope
   33 |   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;
Language: C++

#include <bits/stdc++.h>

//#define DEBUG

#define INF ll_MAX
#define BEAMMAX 10

typedef long long ll;

using namespace std;
 
int main() {
    ll N, W;
    cin >> N >> W;
    vector<ll> v(N), w(N);
    for(int i=0; i<N; ++i) {
        cin >> v[i] >> w[i];
    }
    if(N <= 30) {
        int s = N/2;
        vector< pair<ll,ll> > dp(1 << s);
        for(int i=0; i<(1 << s); ++i) {
            ll sw = 0, sv = 0;
            for(int j=0; j<s; ++j) {
                if(i >> j & 1) {
                    sw += w[j];
                    sv += v[j];
                }
            }
            dp[i] = make_pair(sw, sv);
        }
        sort(dp.begin(), dp.end());
        int m = 1;
        for(int i=1; i<1<<s; ++i) {
            if(dp[m-1].second < dp[i].second) {
                dp[m++] = dp[i];
            }
        }
        ll res = 0;
        for(int i=0; i<1<<(N - s); ++i) {
            ll sw = 0, sv = 0;
            for(int j=0; j<N-s; ++j) {
                if(i >> j & 1) {
                    sw += w[j+s];
                    sv += v[j+s];
                }
            }
            if(sw <= W) {
                ll tv = (lower_bound(dp.begin(), dp.begin()+m, make_pair(W-sw, INF)) - 1)->second;
                res = max(res, sv+tv);
            }
        }
        cout << res << endl;
    } else if(*max_element(v.begin(), v.end()) <= 1000) {
        ll V = accumulate(v.begin(), v.end(), 0LL);
        vector<ll> dp(V+1, INF);
        dp[0] = 0;
        for(int i=0; i<N; ++i) {
            for(int j=V-v[i]; j>=0; --j) {
                dp[j+v[i]] = min(dp[j+v[i]], dp[j] + w[i]);
            }
        }
        for(int i=V; i>=0; --i) {
            if(dp[i] <= W) {
                cout << i << endl;
                return 0;
            }
        }
    } else {
        vector<ll> dp(W+1, -1);
        dp[0] = 0;
        for(int i=0; i<N; ++i) {
            for(int j=W-w[i]; j>=0; --j) {
                if(dp[j] == -1) {
                    continue;
                }
                dp[j+w[i]] = max(dp[j+w[i]], dp[j] + v[i]);
            }
        }
        cout << *max_element(dp.begin(), dp.end()) << endl;
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:5:13: error: 'll_MAX' was not declared in this scope
    5 | #define INF ll_MAX
      |             ^~~~~~
a.cc:49:80: note: in expansion of macro 'INF'
   49 |                 ll tv = (lower_bound(dp.begin(), dp.begin()+m, make_pair(W-sw, INF)) - 1)->second;
      |                                                                                ^~~
a.cc:5:13: error: 'll_MAX' was not declared in this scope
    5 | #define INF ll_MAX
      |             ^~~~~~
a.cc:56:28: note: in expansion of macro 'INF'
   56 |         vector<ll> dp(V+1, INF);
      |                            ^~~
Language: C++

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<stack>
#include<queue>
#include<string>
#include<cstring>
#include<cctype>
#define itn int
#define pritnf printf
#define xlm mylove
#define maxt 1000000010
#define maxm 110
using namespace std;
int w[maxm],c[maxm];int t,m;int f[maxt][maxm];
inline void readln(){
	scanf("%d%d",&m,&t);
	for (int i=1;i<=m;i++){
		scanf("%d%d",&w[i],&c[i]);
		//if (w[i]>t){w[i]=c[i]=0;}
	}
}
inline void dp(){
	for (int i=1;i<=m;i++){
		for (int v=t;v>=0;v--){
			if (w[i]<=v) f[i][v]=max(f[i-1][v],f[i-1][v-w[i]]+c[i]);
			else f[i][v]=f[i-1][v];
		}
	}
}
inline void p(){
	printf("%d",f[m][t]);
	fclose(stdin);fclose(stdout);
}
int Main(){
	readln();
	dp();
	p();
	return 0;
}
int main(){;}
int xlm=Main();

Compiler output:
/tmp/ccDT2N82.o: in function `__static_initialization_and_destruction_0()':
a.cc:(.text+0x30): relocation truncated to fit: R_X86_64_PC32 against symbol `mylove' defined in .bss section in /tmp/ccDT2N82.o
collect2: error: ld returned 1 exit status
Language: Java

public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		final int N = sc.nextInt();
		final int W = sc.nextInt();
		int[] w = new int[N];
		int[] v = new int[N];
		for(int i=0; i<N; i++){
			w[i] = sc.nextInt();
			v[i] = sc.nextInt();
		}
		sc.close();
		
		int[][] dp = new int[N+1][W+1];
		int ret = 0;

		for (int i = 0; i < N; i++) {
		    for (int j = 0; j <= W; j++) {
		        dp[i + 1][j] = Math.max(dp[i + 1][j], dp[i][j]);
		        if (j + w[i] <= W) {
		            dp[i + 1][j + w[i]] = Math.max(dp[i + 1][j + w[i]], dp[i][j] + v[i]);
		            ret = Math.max(ret, dp[i + 1][j + w[i]]);
		        }
		    }
		}
	
		System.out.println(ret);

	}

}

Compiler output:
Main.java:5: error: cannot find symbol
		Scanner sc = new Scanner(System.in);
		^
  symbol:   class Scanner
  location: class Main
Main.java:5: error: cannot find symbol
		Scanner sc = new Scanner(System.in);
		                 ^
  symbol:   class Scanner
  location: class Main
2 errors
Language: C++

#include<iostream>  
using namespace std;  
#define  V 1000000000
unsigned int f[100][V];
unsigned int weight[100];  
unsigned int value[100];  
#define  max(x,y)   (x)>(y)?(x):(y)  
int main()  
{  
    int N,M;  
    cin>>N;
    cin>>M;
    for (int i=1;i<=N; i++)  
    {  
        cin>>weight[i]>>value[i];  
    }  
    for (int i=1; i<=N; i++)  
        for (int j=1; j<=M; j++)  
        {  
            if (weight[i]<=j)  
            {  
                f[i][j]=max(f[i-1][j],f[i-1][j-weight[i]]+value[i]);  
            }  
            else  
                f[i][j]=f[i-1][j];  
        }  
      
    cout<<f[N][M]<<endl;
  
}  

Compiler output:
/tmp/ccC7vP70.o: in function `main':
a.cc:(.text+0x4d): relocation truncated to fit: R_X86_64_PC32 against symbol `weight' defined in .bss section in /tmp/ccC7vP70.o
a.cc:(.text+0x79): relocation truncated to fit: R_X86_64_PC32 against symbol `value' defined in .bss section in /tmp/ccC7vP70.o
a.cc:(.text+0xbf): relocation truncated to fit: R_X86_64_PC32 against symbol `weight' defined in .bss section in /tmp/ccC7vP70.o
a.cc:(.text+0xea): relocation truncated to fit: R_X86_64_PC32 against symbol `weight' defined in .bss section in /tmp/ccC7vP70.o
a.cc:(.text+0x124): relocation truncated to fit: R_X86_64_PC32 against symbol `value' defined in .bss section in /tmp/ccC7vP70.o
collect2: error: ld returned 1 exit status