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

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

using namespace std;

int main(){
    string s1,s2;
    cin>>s1>>s2;
    int l1,l2;
    l1=s1.size();
    l2=s2.size();
    
    int dp[1020][1020];
    
    for(int i=0;i<l1;i++){
        if(s1[i]==s2[0]) dp[i][0]=1;
        else             dp[i][0]=0;
    }
    for(int j=0;j<l2;j++){
        if(s1[0]==s2[j]) dp[0][j]=1;
        else             dp[0][j]=0;
    }
    
    for(int i=1;i<l1;i++){
        for(int j=1;j<l2;j++){
            if(s1[i]==s2[j]){
                dp[i][j]=max(dp[i-1][j],dp[i][j-1],dp[i-1][j-1])+1;
            }
            else    dp[i][j]=max(dp[i-1][j],dp[i][j-1],dp[i-1][j-1]);
        }
    }
    
    cout<<abs(l1-l2)+(min(l1,l2)-dp[l1-1][l2-1])<<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:2:
/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:30:29:   required from here
   30 |                 dp[i][j]=max(dp[i-1][j],dp[i][j-1],dp[i-1][j-1])+1;
      |                          ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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 <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

int main(){
    string s1,s2;
    cin>>s1>>s2;
    int l1,l2;
    l1=s1.size();
    l2=s2.size();
    
    int dp[1020][1020];
    
    for(int i=0;i<l1;i++){
        if(s1[i]==s2[0]) dp[i][0]=1;
        else             dp[i][0]=0;
    }
    for(int j=0;j<l2;j++){
        if(s1[0]==s2[j]) dp[0][j]=1;
        else             dp[0][j]=0;
    }
    
    for(int i=1;i<l1;i++){
        for(int j=1;j<l2;j++){
            if(s1[i]==s2[j]){
                dp[i][j]=max(max(dp[i-1][j],dp[i][j-1]),dp[i-1][j-1])+1;
            }
            else    dp[i][j]=max(max(dp[i-1][j],dp[i][j-1]),dp[i-1][j-1])
        }
    }
    
    cout<<abs(l1-l2)+(min(l1,l2)-dp[l1-1][l2-1])<<endl;
     
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:32:74: error: expected ';' before '}' token
   32 |             else    dp[i][j]=max(max(dp[i-1][j],dp[i][j-1]),dp[i-1][j-1])
      |                                                                          ^
      |                                                                          ;
   33 |         }
      |         ~
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>

#define rep(i,N) for(int i=0; i<(int)(N); i++)
using namespace std;


int levenshtein(string str1, string str2);

int main(){
        string s1,s2;
        cin >> s1 >> s2;
        cout << levenshtein(str1, str2) << endl;
        return 0;
}

int d[1010][1010];
int levenshtein(string str1, string str2){
        rep(i,str1.size()+1){
                rep(j,str2.size()+1){
                        if(i==0) {
                                d[i][j]=j;
                        }else{
                                if(j==0) {
                                        d[i][j]=i;
                                }else{
                                        if(str1[i-1]==str2[j-1]) {
                                                d[i][j]=min(d[i-1][j-1],min(d[i][j-1]+1,d[i-1][j]+1));
                                        }
                                        else{
                                                d[i][j]=min(d[i-1][j-1]+1,min(d[i][j-1]+1,d[i-1][j]+1));
                                        }
                                }
                        }
                        if(i==4 && j==5) {
                                cout << str1[j-1] << str2[i-1] << endl;
                        }

                }
        }

        return d[str1.size()][str2.size()];
}



Compiler output:
a.cc: In function 'int main()':
a.cc:14:29: error: 'str1' was not declared in this scope; did you mean 's1'?
   14 |         cout << levenshtein(str1, str2) << endl;
      |                             ^~~~
      |                             s1
a.cc:14:35: error: 'str2' was not declared in this scope; did you mean 's2'?
   14 |         cout << levenshtein(str1, str2) << endl;
      |                                   ^~~~
      |                                   s2
Language: C++

#include <bits/stdc++.h>
#define REP(i,n) for (long long i=0;i<(n);i++)
#define FOR(i,a,b) for (long long i=(a);i<(b);i++)
#define RREP(i,n) for(long long i=n;i>=0;i--)
#define RFOR(i,a,b) for(long long i=(a);i>(b);i--)
#define dump1d_arr(array) REP(i,array.size()) cerr << #array << "[" << (i) << "] ==> " << (array[i]) << endl
#define dump2d_arr(array) REP(i,array.size()) REP(j,array[i].size()) cerr << #array << "[" << (i) << "]" << "[" << (j) << "] ==> " << (array[i][j]) << endl
#define dump(x)  cerr << #x << " => " << (x) << endl
#define dumpP(p) cerr << "( " << p.first << " , " << p.second << " )" << ends
#define SORT(c) sort((c).begin(),(c).end())
#define MIN(vec) *min_element(vec.begin(), vec.end())
#define MAX(vec) *max_element(vec.begin(), vec.end())
#define UNIQ(vec) vec.erase(unique(vec.begin(), vec.end()),vec.end()) //ソートの必要あり
#define IN(n,m)  (!(m.find(n) == m.end()))
#define ENUM(m) for (auto itr = m.begin(); itr != m.end(); ++itr)
#define dump_MAP(m) for(auto itr = m.begin(); itr != m.end(); ++itr) { cerr << itr->first << " --> "  << itr->second << endl; }
#define FINDL(vec,x) (lower_bound(vec.begin(),vec.end(),x) - vec.begin())
#define FINDU(vec,x) (upper_bound(vec.begin(),vec.end(),x) - vec.begin())
#define ROUND(N) setprecision(N)
#define ROUND_PRINT(N,val) cout << fixed;cout << setprecision(N) << val << endl
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()

using namespace std;
constexpr long double pi = M_PI;
constexpr double eps = 1e-10;
constexpr long mod = 1000000007;
constexpr short shINF = 32767;
constexpr long loINF = 2147483647;
constexpr long long llINF = 9223372036854775807;
typedef long long LL;
typedef vector<LL> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<LL,LL> pr;
typedef vector<pr> VP;
struct Order {
	bool operator() (pr const& a,pr const& b) const {
		return a.first > b.first || ((a.first == b.first) && (a.second > b.second));
	}
};

template<typename T>
int diff(vector<T> &a,vector<T> &b) {
	int la = a.size();
	int lb = b.size();
	vector<vector<int>> dp(la+1,vector<int>(lb+1,numeric_limits<int>));
	dp[0][0] = 0;
	REP(i,la) {
		REP(j,lb) {
			if (a[i] == b[j]) dp[i+1][j+1] = dp[i][j];
			dp[i+1][j+1] = min({dp[i+1][j]+1,dp[i][j+1]+1,dp[i][j]+1,dp[i+1][j+1]});
		}
	}
	return dp[la][lb];
}
int main(void) {
	string s1,s2;
	cin >> s1 >> s2;
	vector<char> A(s1.size()),B(s2.size());
	REP(i,s1.size()) A[i] = s1[i];
	REP(i,s2.size()) B[i] = s2[i];
	cout << diff<char>(A,B) << endl;
}




Compiler output:
a.cc: In function 'int diff(std::vector<_Tp>&, std::vector<_Tp>&)':
a.cc:47:48: error: expected primary-expression before '(' token
   47 |         vector<vector<int>> dp(la+1,vector<int>(lb+1,numeric_limits<int>));
      |                                                ^
a.cc:47:73: error: expected primary-expression before ')' token
   47 |         vector<vector<int>> dp(la+1,vector<int>(lb+1,numeric_limits<int>));
      |                                                                         ^
Language: Java

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.Stream;
public class Main {
    public static class Solver {
        public int solve(int W, List<Integer> values, List<Integer> weights) {
            int[] dp = new int[W + 1];
            for (int i = 1; i <= values.size(); ++i) {
                for (int j = W; j >= 0; --j) {
                    int v = values.get(i - 1);
                    int w = weights.get(i - 1);
                    if (j - w >= 0) {
                        dp[j] = Math.max(dp[j], dp[j - w] + v);
                    }
                }
            }
            return dp[W];
        }
    }

    private static final Pattern SPLIT = Pattern.compile("\\s");
    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(SPLIT.split(scanner.nextLine())).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(SPLIT.split(scanner.nextLine())).map(Integer::valueOf)
                    .collect(Collectors.toList());
            values.add(collect.get(0));
            weights.add(collect.get(1));
        }
        System.out.println(new Main().solve(W, values, weights));
    }
}

Compiler output:
Main.java:39: error: cannot find symbol
        System.out.println(new Main().solve(W, values, weights));
                                     ^
  symbol:   method solve(int,List<Integer>,List<Integer>)
  location: class Main
1 error
Language: Java

package org.zlambda.sandbox.puzzle;

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

/**
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_1_F

0-1 ???????????¶???????????? II
????????? vi ????????? wi ??§??????????????? N ??????????????¨???????????? W ??????????????¶?????????????????????????¬?????????¶?????????????????????????????????????????§???????????¶???????????\????????????

???????????????????????????????¨??????§???????????????????????????
???????????????????????????????????? W ????¶?????????????
?????????????¨?????????§???????±??????????????????????

??\???
???????????????????????´??°???N???W???????????????????????§?????????????????????????????? ?¶???? N ?????§ i ???????????????????????? vi ??¨?????? wi ????????????????????§?????????????????????

??????
?????????????¨?????????§??????????????????????????????????????????

??¶?´?
1 ??? N ??? 100
1 ??? vi ??? 100
1 ??? wi ??? 10,000,000
1 ??? W ??? 1,000,000,000
??\?????????

??\?????? 1
4 5
4 2
5 2
2 1
8 3
????????? 1
13

??\?????? 2
2 20
5 9
4 10
????????? 2
9
 */
public class Main {
    public static class Solver {
        public int solve(int W, List<Integer> values, List<Integer> weights) {
            int[] dp = new int[W + 1];
            for (int i = 1; i <= values.size(); ++i) {
                for (int j = W; j >= 0; --j) {
                    int v = values.get(i - 1);
                    int w = weights.get(i - 1);
                    if (j - w >= 0) {
                        dp[j] = Math.max(dp[j], dp[j - w] + v);
                    }
                }
            }
            return dp[W];
        }
    }

    private static final Pattern SPLIT = Pattern.compile("\\s");
    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(SPLIT.split(scanner.nextLine())).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(SPLIT.split(scanner.nextLine())).map(Integer::valueOf)
                    .collect(Collectors.toList());
            values.add(collect.get(0));
            weights.add(collect.get(1));
        }
        System.out.println(new Main().solve(W, values, weights));
    }
}

Compiler output:
Main.java:81: error: cannot find symbol
        System.out.println(new Main().solve(W, values, weights));
                                     ^
  symbol:   method solve(int,List<Integer>,List<Integer>)
  location: class Main
1 error
Language: Java


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

/**
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_1_F

0-1 ???????????¶???????????? II
????????? vi ????????? wi ??§??????????????? N ??????????????¨???????????? W ??????????????¶?????????????????????????¬?????????¶?????????????????????????????????????????§???????????¶???????????\????????????

???????????????????????????????¨??????§???????????????????????????
???????????????????????????????????? W ????¶?????????????
?????????????¨?????????§???????±??????????????????????

??\???
???????????????????????´??°???N???W???????????????????????§?????????????????????????????? ?¶???? N ?????§ i ???????????????????????? vi ??¨?????? wi ????????????????????§?????????????????????

??????
?????????????¨?????????§??????????????????????????????????????????

??¶?´?
1 ??? N ??? 100
1 ??? vi ??? 100
1 ??? wi ??? 10,000,000
1 ??? W ??? 1,000,000,000
??\?????????

??\?????? 1
4 5
4 2
5 2
2 1
8 3
????????? 1
13

??\?????? 2
2 20
5 9
4 10
????????? 2
9
 */
public class Main {
    public static class Solver {
        public int solve(int W, List<Integer> values, List<Integer> weights) {
            int[] dp = new int[W + 1];
            for (int i = 1; i <= values.size(); ++i) {
                for (int j = W; j >= 0; --j) {
                    int v = values.get(i - 1);
                    int w = weights.get(i - 1);
                    if (j - w >= 0) {
                        dp[j] = Math.max(dp[j], dp[j - w] + v);
                    }
                }
            }
            return dp[W];
        }
    }

    private static final Pattern SPLIT = Pattern.compile("\\s");

    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(SPLIT.split(scanner.nextLine())).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(SPLIT.split(scanner.nextLine())).map(Integer::valueOf)
                    .collect(Collectors.toList());
            values.add(collect.get(0));
            weights.add(collect.get(1));
        }
        System.out.println(new Main().solve(W, values, weights));
    }
}

Compiler output:
Main.java:81: error: cannot find symbol
        System.out.println(new Main().solve(W, values, weights));
                                     ^
  symbol:   method solve(int,List<Integer>,List<Integer>)
  location: class Main
1 error
Language: C

#include<stdio.h>
#define MAX 100000

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

return b;
}



void func(int N,int W,int v[],int w[]){
int X[MAX]={0};
int Y[MAX]={0};
int i,j;

for(i=1;i<=W;i++){X[i]=-1;Y[i]=-1;}

X[w[0]]=v[0];


for(i=1;i<N;i++){

 if(i%2==1){

   for(j=0;j<=W;j++){
    if(X[j]!=-1){
       if(Y[j]<X[j])Y[j]=X[j];
       if(j+w[i]<=W)
         if(X[j]+v[i]>Y[j+w[i]])Y[j+w[i]]=X[j]+v[i];
         else Y[j+w[i]]=X[j][j+w[i]];
    }
   }

 }

 else if(i%2==0){

   for(j=0;j<=W;j++){
    if(Y[j]!=-1){
      if(X[j]<Y[j])X[j]=Y[j];
       if(j+w[i]<=W)
         if(Y[j]+v[i]>X[j+w[i]])X[j+w[i]]=Y[j]+v[i];
         else X[j+w[i]]=Y[j][j+w[i]];
    }
   }

 }




 

}/*たて*/

if(N%2==0)for(i=0;i<W;i++)j=max(Y[i],Y[i+1]);

if(N%2==1)for(i=0;i<W;i++)j=max(X[i],X[i+1]);

printf("%d\n",j);

return;
}

int main(){
int N,W;
int v[MAX];
int w[MAX];
int i;

scanf("%d %d",&N,&W);

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

func(N,W,v,w);

return 0;
}


Compiler output:
main.c: In function 'func':
main.c:31:29: error: subscripted value is neither array nor pointer nor vector
   31 |          else Y[j+w[i]]=X[j][j+w[i]];
      |                             ^
main.c:44:29: error: subscripted value is neither array nor pointer nor vector
   44 |          else X[j+w[i]]=Y[j][j+w[i]];
      |                             ^
Language: C++

#include <bits/stdc++.h>
#include <afxres.h>

int main(){
    int n, w = 0;
    std::cin>>n>>w;
    std::vector<std::vector<long> > dp(static_cast<unsigned int>(n + 1), std::vector<long>(n * w+1, 0));
    dp[0][0]=0;
    for (int i = 1; i <=n*w ; ++i) {
        dp[0][i]=1000000001;
    }
    std::vector<int> iv;
    std::vector<long> iw;
    for (int i = 0; i < n; ++i) {
        int a, b = 0;
        std::cin>>a>>b;
        iv.emplace_back(a);
        iw.emplace_back(b);
    }
    for (int i = 1; i <= n; ++i) {
        for (int j = 0; j <= n*w; ++j) {
            if (j < iv[i - 1]) {
                dp[i][j] = dp[i - 1][j];
            } else {
                dp[i][j] = std::min(dp[i - 1][j], dp[i - 1][j - iv[i - 1]] + iw[i - 1]);
            }
        }
    }
    int ans=0;
    for (int i = 0; i <= n * w; ++i) {
        if(dp[n][i]<=w)ans=i;
    }
    std::cout<<ans<<std::endl;
    return 0;
}


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

#include <vector>
#include <set>
#include <cstdio>
using namespace std;
 
int main(){
	int N;
	long long W,tV=0,tW=0,x=0;
	scanf("%d%lld",&N,&W);
	vector<pair<int,int> >v(N);
	for(int i=0;i<N;i++)scanf("%d%d",&v[i].first,&v[i].second),tV+=v[i].first,tW+=v[i].second;
	if(tW<2000000){
		vector<long long>bag(tW+1);
		bag[0]=1;
		for(auto &e:v){
			x+=e.second;
			for(int j=x;j>=e.second;j--)if(bag[j-e.second]&&bag[j]<bag[j-e.second]+e.first)
				bag[j]=bag[j-e.second]+e.first;
		}
		for(int i=0;i<W;i++)bag[i+1]=max(bag[i+1],bag[i]);
		printf("%lld\n",bag[W]-1);
	}else{
		vector<long long>bag(tV+1);
		bag[0]=1;
		for(auto &e:v){
			x+=e.first;
			for(int j=x;j>=e.first;j--)if(bag[j-e.first]&&(!bag[j]||bag[j]>bag[j-e.first]+e.second))
				bag[j]=bag[j-e.first]+e.second;
		}
		int i=0,mi;
		for(;i<=tV;i++)if(bag[i]&&bag[i]-1<=W)mi=i;
		printf("%d\n",mi);
	}else{
		return 1;
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:33:10: error: 'else' without a previous 'if'
   33 |         }else{
      |          ^~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
int N, W;
int main() {
	cin >> N >> W;
	vector<int> v(N), w(N);
	int sum = 0;
	for(int i = 0; i < N; i++) {
		cin >> v[i] >> w[i];
		sum += v[i];
	}
	vector<vector<int> > dp(N + 1, vector<int>(sum + 1, 99999999));
	fill(dp[0].begin(), dp[0].end(), 0);
	for(int i = 0; i < N; i++) {
		for(int j = 0; j <= sum; j++) {
			dp[i + 1][j] = dp[i][j];
			if(j >= v[i]) dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - v[i]] + w[i]);
		}
	}
	for(int i = sum; i >= 0; i--) {
		if(dp[N][j] <= W) {
			cout << i << endl;
			break;
		}
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:26: error: 'j' was not declared in this scope
   21 |                 if(dp[N][j] <= W) {
      |                          ^
Language: C++

#include <iostream>
using namespace std;
#define MAX 100

int N,W;
int v[MAX],w[MAX];
int dp[MAX+1][1000001];

int func(int i,int j){
    int res;
    if(dp[i][j]>=0)return dp[i][j];
    if(i==N){
        res=0;
    }
    else if (j<w[i]){
        res=func(i+1,j);
    }
    else{
        res=max(func(i+1,j), func(i+1,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:27:5: error: 'memset' was not declared in this scope
   27 |     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 <iostream>
#include <ccomplex>
#include <vector>
#include <cassert>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>
#include <time.h>
#include <stack>
#include <locale>
#include <clocale>
#include <ctype.h>
#include <wchar.h>
#include <random>
#include <vector>

using namespace std;
typedef long long int LL;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)


int xcomp(pair<LL, LL>& a, pair<LL, LL>& b) {
	if (a.first == b.first) {
		return a.second<b.second;
	}
	return a.first < b.first;
}

#define XSORT(c) sort((c).begin(),(c).end(),xcomp)

#define ALL(x) (x).begin(),(x).end()
LL mod = 1000000007;

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

	vector<LL> ans(10001, LLONG_MAX/2);

	ans[0] = 0;

	//v,w;
	vector<pair<LL, LL>> nimotu(N);

	REP(i, N) {
		LL a, b;
		cin >> a >> b;
		nimotu[i] = make_pair(a, b);
	}

	REP(i, N) {
		//nimotu[i]を取った場合
		for(int j=ans.size()-1;j>=0;--j){
			if (j - nimotu[i].first >= 0) {
				ans[j]=min(ans[j],ans[j - nimotu[i].first]+nimotu[i].second);
			}
		}
	}

	LL answer = -1;
	REP(i, ans.size()) {
		if (ans[i] <= W) {
			answer = i;
		}
	}
	cout << answer << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:60:31: error: 'LLONG_MAX' was not declared in this scope
   60 |         vector<LL> ans(10001, LLONG_MAX/2);
      |                               ^~~~~~~~~
a.cc:31:1: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
   30 | #include <random>
  +++ |+#include <climits>
   31 | #include <vector>
Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,x,n) for(int i=(x);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define int long long
using namespace std;
const int MOD=1e9+7;
const int INF=1e10;

signed main(){
  int N,W;
  cin>>N>>W;
  vector<int> v(N+10),w(N+10);
  rep(i,N)cin>>v[i]>>w[i];

  vector<vector<int>> dp(N+10,vector<int>(10004,INF));

  dp[0][0]=0;

  rep(i,N+1){
    rep(j,10004){
      if(j-v[i]>=0)
        dp[i+1][j]=min(dp[i+1][j],dp[i][j-v[i]]+w[i]);
      dp[i+1][j]=min(dp[i+1][j],dp[i][j]);
    }
  }
  for(int j=10003;i>=0;i--){
    if(dp[N][j]<=W){
      cout<<j<<endl;
      return 0;
    }
  }

  return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:27:19: error: 'i' was not declared in this scope
   27 |   for(int j=10003;i>=0;i--){
      |                   ^
Language: C++

#include <iostream>
using namespace std;

int main(void) {
   long long dp[10010];
   int n, m;
   int v, w, k=0, sum=0;
   cin >> n >> m;
   
   dp[0] = 0;
   for(int i=1; i<=10000; i++) dp[i] = 1000000010;
   
   for (int j = 0; j < n; j++){
       cin >> v >> w;
       sum += v;
       for(int i=sum; i>=1; i--){
       dp[i] = min(dp[i], dp[i-v]+w);
       }
   }
   
   for(int i=sum; i>=1; i--){
       if(dp[i] <= m){
           k = i;    break;　//**
       }
   }
   
   cout << k << endl;

   return 0;
}


Compiler output:
a.cc:23:28: error: extended character 　 is not valid in an identifier
   23 |            k = i;    break;　//**
      |                            ^
a.cc: In function 'int main()':
a.cc:23:28: error: '\U00003000' was not declared in this scope
   23 |            k = i;    break;　//**
      |                            ^~
Language: C++

#include <iostream>
using namespace std;

int main(void) {
   long long dp[10010];
   int n, m;
   int v, w, k=0, sum=0;
   cin >> n >> m;
   
   dp[0] = 0;
   for(int i=1; i<=10000; i++) dp[i] = 1000000010;
   
   for (int j = 0; j < n; j++){
       cin >> v >> w;
       sum += v;
       for(int i=sum; i>=v; i--){
       dp[i] = min(dp[i], dp[i-v]+w);
       }
   }
   
   for(int i=sum; i>=1; i--){
       if(dp[i] <= m){
          k = i;    break;　//**
       }
   }
   
   cout << k << endl;

   return 0;
}


Compiler output:
a.cc:23:27: error: extended character 　 is not valid in an identifier
   23 |           k = i;    break;　//**
      |                           ^
a.cc: In function 'int main()':
a.cc:23:27: error: '\U00003000' was not declared in this scope
   23 |           k = i;    break;　//**
      |                           ^~
Language: C++

#include <iostream>
using namespace std;

int main(void) {
   long long dp[10010];
   int n, m;
   int v, w, k=0, sum=0;
   cin >> n >> m;
   
   dp[0] = 0;
   for(int i=1; i<=10000; i++) dp[i] = 1000000010;
   
   for (int j = 0; j < n; j++){
       cin >> v >> w;
       sum += v;
       for(int i=sum; i>=v; i--){
       dp[i] = min(dp[i], dp[i-v]+w);
       }
   }
   
   for(int i=sum; i>=1; i--){
       if(dp[i] <= m){
          k = i;    break;　
       }
   }
   
   cout << k << endl;

   return 0;
}


Compiler output:
a.cc:23:27: error: extended character 　 is not valid in an identifier
   23 |           k = i;    break;　
      |                           ^
a.cc: In function 'int main()':
a.cc:23:27: error: '\U00003000' was not declared in this scope
   23 |           k = i;    break;　
      |                           ^~
Language: Java

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.Stream;
public class Main {
    public long solve(int W, List<Integer> values, List<Integer> weights)  {
        int[] dp = new int[W + 1];
        for (int i = 1; i <= values.size(); ++i) {
            for (int j = W; j >= 0; --j) {
                int w = weights.get(i - 1);
                int v = values.get(i - 1);
                if (j - w >= 0) {
                    dp[j] = Math.max(dp[j], dp[j - w] + v);
                }
            }
        }
        return dp[W];
    }

    private static List<Integer> transform(int num) {
        List<Integer> ret = new ArrayList<>();
        int ele = 1;
        while (num - ele + 1 > 0) {
            ret.add(ele);
            ele = ele * 2;
        }
        int lst = ret.size() - 1;
        ret.set(lst, num - ret.get(lst) + 1);
        return ret;
    }

    private static final Pattern SPLIT = Pattern.compile("\\s");
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        List<Integer> weights = new ArrayList<>();
        List<Integer> values = new ArrayList<>();
        List<Integer> nums = new ArrayList<>();
        List<Integer> NW = Stream.of(SPLIT.split(scanner.nextLine())).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(SPLIT.split(scanner.nextLine())).map(Integer::valueOf)
                                          .collect(Collectors.toList());
            values.add(collect.get(0));
            weights.add(collect.get(1));
            nums.add(collect.get(2));
        }

        {
            List<Integer> newWeights = new ArrayList<>();
            List<Integer> newValues = new ArrayList<>();
            List<List<Integer>> numsList = nums.stream().map(KnapsackWithLimitation::transform).collect(Collectors.toList());
            for (int i = 0; i < numsList.size(); ++i) {
                int w = weights.get(i);
                int v = values.get(i);
                newWeights.addAll(numsList.get(i).stream().map(ele -> ele * w).collect(Collectors.toList()));
                newValues.addAll(numsList.get(i).stream().map(ele -> ele * v).collect(Collectors.toList()));
            }
            System.out.println(new Main().solve(W, newValues, newWeights));
        }
    }
}

Compiler output:
Main.java:55: error: cannot find symbol
            List<List<Integer>> numsList = nums.stream().map(KnapsackWithLimitation::transform).collect(Collectors.toList());
                                                             ^
  symbol:   variable KnapsackWithLimitation
  location: class Main
1 error
Language: Java

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

public class Main {
    public long solve(int W, List<Integer> values, List<Integer> weights)  {
        int[] dp = new int[W + 1];
        for (int i = 1; i <= values.size(); ++i) {
            for (int j = W; j >= 0; --j) {
                int w = weights.get(i - 1);
                int v = values.get(i - 1);
                if (j - w >= 0) {
                    dp[j] = Math.max(dp[j], dp[j - w] + v);
                }
            }
        }
        return dp[W];
    }
 
    private static List<Integer> transform(int num) {
        List<Integer> ret = new ArrayList<>();
        int ele = 1;
        while (num - ele + 1 > 0) {
            ret.add(ele);
            ele = ele * 2;
        }
        int lst = ret.size() - 1;
        ret.set(lst, num - ret.get(lst) + 1);
        return ret;
    }
 
    private static final Pattern SPLIT = Pattern.compile("\\s");
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        List<Integer> weights = new ArrayList<>();
        List<Integer> values = new ArrayList<>();
        List<Integer> nums = new ArrayList<>();
        List<Integer> NW = Stream.of(SPLIT.split(scanner.nextLine())).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(SPLIT.split(scanner.nextLine())).map(Integer::valueOf)
                                          .collect(Collectors.toList());
            values.add(collect.get(0));
            weights.add(collect.get(1));
            nums.add(collect.get(2));
        }
 
        {
            List<Integer> newWeights = new ArrayList<>();
            List<Integer> newValues = new ArrayList<>();
            List<List<Integer>> numsList = nums.stream().map(KnapsackWithLimitation::transform).collect(Collectors.toList());
            for (int i = 0; i < numsList.size(); ++i) {
                int w = weights.get(i);
                int v = values.get(i);
                newWeights.addAll(numsList.get(i).stream().map(ele -> ele * w).collect(Collectors.toList()));
                newValues.addAll(numsList.get(i).stream().map(ele -> ele * v).collect(Collectors.toList()));
            }
            System.out.println(new Main().solve(W, newValues, newWeights));
        }
    }
}

Compiler output:
Main.java:56: error: cannot find symbol
            List<List<Integer>> numsList = nums.stream().map(KnapsackWithLimitation::transform).collect(Collectors.toList());
                                                             ^
  symbol:   variable KnapsackWithLimitation
  location: class Main
1 error
Language: C++

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

using namespace std;

int main(){
	int N,W;
	int ans=0;
	
	scanf("%d %d",&N,&W);
	vector<int> dp(W+1,0);
	
	for(int i=0;i<N;i++){
		int v,w,m;
		scanf("%d %d %d",&v,&w,&m);
		for(int k=0;m>0;k++){
			int key=min(m,(1<<k));
			m-=key;
			for(int j=W;j>=key*w;j--){
				dp[j]=max(dp[j],dp[j-key*w]+key*v);
			}
		}
	}
	int ans=0;
	for(int i=0;i<=W;i++) ans=max(ans,dp[i]);
	printf("%d\n",ans);
}


Compiler output:
a.cc: In function 'int main()':
a.cc:31:13: error: redeclaration of 'int ans'
   31 |         int ans=0;
      |             ^~~
a.cc:15:13: note: 'int ans' previously declared here
   15 |         int ans=0;
      |             ^~~
Language: C++

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

   typedef long long ll;

   const double EPS = (1e-7);
   const ll INF =(1e9);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
   template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

   #define dump(x) cerr<< #x << "= " << (x) << endl;

   int gcd(int a,int b){return b?gcd(b,a%b):a;};

   int dx[4]={1,0,-1,0};
   int dy[4]={0,1,0,-1};


const ll MAX_N = 40;

ll n, W;
ll w[MAX_N], v[MAX_N];

pair<ll, ll> ps[1 << (MAX_N / 2)] //(weight, value)

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    //input
    cin >> n >> W;
    REP(i, n){
        cin >> v[i] >> w[i];
    }

    //前半 n/2個から自由に選ぶ組み合わせを全列挙
    //(w, v)の和をps[i]に保存
    int n2 = n / 2;
    REP(i, 1 << n2){
        ll sw = 0, sv = 0;
        REP(j, n2){
            if ((i >> j) & 1){
                sw += w[j];
                sv += v[j];
            }
        }
        ps[i] = mp(sw, sv);
    }

    //wの小さい順->vの小さい順、でソートする
    sort(ps, ps + 1 << n2);
    ll m = 1;
    FOR(i, 1, 1 << n2){
        if (ps[m - 1].second < ps[i].second){
            ps[m++] = ps[i];
        }
    }
    //m = psから(w, v)の関係が逆転している要素を覗いたときの要素数

    //後半を全列挙
    ll res = 0;
    REP(i, 1 << (n - n2)){
        ll sw = 0, sv = 0;
        REP(j, n - n2){
            if ((i >> j) & 1){
                sw += w[n2 + j];
                vw += v[n2 + j];
            }
        }
        if (sw <= W){
            ll tv = (lower_bound(ps, ps + m, mp(W - sw, INF)) - 1) -> second;
            res = max(res, sv + tv);
        }
    }
    cout << res << endl;


    return 0;
}


Compiler output:
a.cc:41:1: error: expected initializer before 'int'
   41 | int main(){
      | ^~~
Language: C++

#include<bits/stdc++.h>
typedef long long ll;
ll MAX_N=40;
using namespace std;
int main(){
    ll n,W;
    ll w[MAX_N],v[MAX_N];
    cin>>n>>W;
    for(int i=0; i<n; i++){
        cin>>w[i]>>v[i];
    }
    pair<ll,ll>ps[1<<(MAX_N/2)];

    int n2=n/2;
    for(int i=0; i<1<<n2; i++){
        ll sw=0,sv=0;
        for(int j=0; j<n2; j++){
            if(i>>j&1){
                sw+=w[j];
                sv+=v[j];
            }
        }
    ps[i]=make_pair(sw,sv);
    }
    sort(ps,ps+(1<<n2));
    int m=1;
    for(int i=1; i<1<<n2; i++){
        if(ps[m-1].second<ps[i].second){
            ps[m++]==ps[i];
        }
    }
    ll res=0;
    for(int i=0; i<1<<(n-n2); i++){
        ll sw=0,sv=0;
        for(int j=0; j<n-n2; j++){
            if(i>>j&1){
                sw+=w[n2+j];
                sv+=v[n2+j];
            }
        }
        if(sw<=W){
            ll tv=(lower_bound(ps,ps+m,make_pair(W-sw,INF))-1)->second;
            res=max(res,sv+tv);
        }
    }
    cout<<res<<endl;
    
}


Compiler output:
a.cc: In function 'int main()':
a.cc:42:55: error: 'INF' was not declared in this scope
   42 |             ll tv=(lower_bound(ps,ps+m,make_pair(W-sw,INF))-1)->second;
      |                                                       ^~~
Language: C++

#pragma GCC optimize("O3")
#pragma GCC target("avx2")
 
#include <vector>
#include <algorithm>
#include <cstdio>
using namespace std;
  
int main(){
    int N;
    long long W,tV=0,tW=0,x=0;
    scanf("%d%lld",&N,&W);
    vector<pair<long long,long long> >v(N);
    for(int i=0;i<N;i++)scanf("%lld%lld",&v[i].first,&v[i].second),tV+=v[i].first,tW+=v[i].second;
 
        int n=N/2;
        vector<pair<long long,long long> >se1,se2;
        for(int i=0;i<1<<n;i++){
            long long V=0,w=0;
            for(int j=0;j<n;j++)if(i&(1<<j))V+=v[j].first,w+=v[j].second;
            se1.emplace_back(w,V);
        }
        for(int i=0;i<1<<(N-n);i++){
            long long V=0,w=0;
            for(int j=0;j<(N-n);j++)if(i&(1<<j))V+=v[j+n].first,w+=v[j+n].second;
            se2.emplace_back(w,V);
        }
sort(se1.begin(),se1.end());
sort(se2.begin(),se2.end());
        for(auto it=se1.begin();it!=se1.end();){
            auto it2=it;
            for(++it2;it2!=se1.end()&&it->second>=it2->second;)it2=se1.erase(it2);
            ++it;
        }
        for(auto it=se2.begin();it!=se2.end();){
            auto it2=it;
            for(++it2;it2!=se2.end()&&it->second>=it2->second;)it2=se2.erase(it2);
            ++it;
        }
        long long r=0;
        for(auto &e1:se1){
            auto it=lower_bound(se2.begin(),se2.end(),{W-e1.first+1,0});
            if(it!=se2.begin()){
                --it;
                r=max(r,e1.second+it->second);
            }
        }
        printf("%lld\n",r);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:42:32: error: no matching function for call to 'lower_bound(std::vector<std::pair<long long int, long long int> >::iterator, std::vector<std::pair<long long int, long long int> >::iterator, <brace-enclosed initializer list>)'
   42 |             auto it=lower_bound(se2.begin(),se2.end(),{W-e1.first+1,0});
      |                     ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/vector:62,
                 from a.cc:4:
/usr/include/c++/14/bits/stl_algobase.h:1530:5: note: candidate: 'template<class _ForwardIterator, class _Tp> _ForwardIterator std::lower_bound(_ForwardIterator, _ForwardIterator, const _Tp&)'
 1530 |     lower_bound(_ForwardIterator __first, _ForwardIterator __last,
      |     ^~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:1530:5: note:   template argument deduction/substitution failed:
a.cc:42:32: note:   couldn't deduce template parameter '_Tp'
   42 |             auto it=lower_bound(se2.begin(),se2.end(),{W-e1.first+1,0});
      |                     ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:5:
/usr/include/c++/14/bits/stl_algo.h:1963:5: note: candidate: 'template<class _FIter, class _Tp, class _Compare> _FIter std::lower_bound(_FIter, _FIter, const _Tp&, _Compare)'
 1963 |     lower_bound(_ForwardIterator __first, _ForwardIterator __last,
      |     ^~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:1963:5: note:   candidate expects 4 arguments, 3 provided
Language: C++

#pragma GCC optimize("O3")
#pragma GCC target("avx2")
 
#include <vector>
#include <algorithm>
#include <cstdio>
using namespace std;
  
int main(){
    int N;
    long long W,tV=0,tW=0,x=0;
    scanf("%d%lld",&N,&W);
    vector<pair<long long,long long> >v(N);
    for(int i=0;i<N;i++)scanf("%lld%lld",&v[i].first,&v[i].second),tV+=v[i].first,tW+=v[i].second;
 
        int n=N/2;
        vector<pair<long long,long long> >se1,se2;
        for(int i=0;i<1<<n;i++){
            long long V=0,w=0;
            for(int j=0;j<n;j++)if(i&(1<<j))V+=v[j].first,w+=v[j].second;
            se1.emplace_back(w,V);
        }
        for(int i=0;i<1<<(N-n);i++){
            long long V=0,w=0;
            for(int j=0;j<(N-n);j++)if(i&(1<<j))V+=v[j+n].first,w+=v[j+n].second;
            se2.emplace_back(w,V);
        }
sort(se1.begin(),se1.end());
sort(se2.begin(),se2.end());
        for(auto it=se1.begin();it!=se1.end();){
            auto it2=it;
            for(++it2;it2!=se1.end()&&it->second>=it2->second;)it2=se1.erase(it2);
            ++it;
        }
        for(auto it=se2.begin();it!=se2.end();){
            auto it2=it;
            for(++it2;it2!=se2.end()&&it->second>=it2->second;)it2=se2.erase(it2);
            ++it;
        }
        long long r=0;
        for(auto &e1:se1){
            auto it=lower_bound(se2.begin(),se2.end(),{W-e1.first+1,0LL});
            if(it!=se2.begin()){
                --it;
                r=max(r,e1.second+it->second);
            }
        }
        printf("%lld\n",r);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:42:32: error: no matching function for call to 'lower_bound(std::vector<std::pair<long long int, long long int> >::iterator, std::vector<std::pair<long long int, long long int> >::iterator, <brace-enclosed initializer list>)'
   42 |             auto it=lower_bound(se2.begin(),se2.end(),{W-e1.first+1,0LL});
      |                     ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/vector:62,
                 from a.cc:4:
/usr/include/c++/14/bits/stl_algobase.h:1530:5: note: candidate: 'template<class _ForwardIterator, class _Tp> _ForwardIterator std::lower_bound(_ForwardIterator, _ForwardIterator, const _Tp&)'
 1530 |     lower_bound(_ForwardIterator __first, _ForwardIterator __last,
      |     ^~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:1530:5: note:   template argument deduction/substitution failed:
a.cc:42:32: note:   couldn't deduce template parameter '_Tp'
   42 |             auto it=lower_bound(se2.begin(),se2.end(),{W-e1.first+1,0LL});
      |                     ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:5:
/usr/include/c++/14/bits/stl_algo.h:1963:5: note: candidate: 'template<class _FIter, class _Tp, class _Compare> _FIter std::lower_bound(_FIter, _FIter, const _Tp&, _Compare)'
 1963 |     lower_bound(_ForwardIterator __first, _ForwardIterator __last,
      |     ^~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:1963:5: note:   candidate expects 4 arguments, 3 provided
Language: C++

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <utility>

using namespace std;

#define int long long

typedef pair<int, int> pii;

int N, W;

int v[45], w[45];

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

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

    vector<pii> arr1, arr2;

    int len1 = N / 2, len2 = N - len1;

    for (int bit = 0; bit < (1 << len1); ++bit) {
        pii hoge(0, 0);

        for (int j = 0; j < len1; ++j) {
            if (bit >> j & 1) {
                hoge.first += w[j], hoge.second -= v[j];
            }
        }

        arr1.push_back(hoge);
    }

    for (int bit = 0; bit < (1 << len2); ++bit) {
        pii hoge(0, 0);

        for (int j = 0; j < len2; ++j) {
            if (bit >> j & 1) {
                hoge.first += w[j + len1], hoge.second -= v[j + len1];
            }
        }

        arr2.push_back(hoge);
    }

    sort(begin(arr1), end(arr1));
    sort(begin(arr2), end(arr2));

    int ma = 0;

    int now = -1, idx = (int)arr2.size() - 1;;
    for (int i = 0; i < arr1.size(); ++i) {
        if (arr1[i].first == now) {
            continue;
        }

        now = arr1[i].first;

        while (idx && now + arr2[idx].first > W) idx--;
        while (idx - 1 >= 0 && arr2[idx].first == arr2[idx - 1].first) idx--;

        ma = max(ma, -(arr1[i].second + arr2[idx].second));
    }

    cout << ma << endl;
}

Compiler output:
cc1plus: error: '::main' must return 'int'
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 = 40;

ll v[MAX_N];
ll w[MAX_N];
vector<P> x,y;

void solve(int s,int t,vector<int> &x)
{
	int z = t-s;
	rep(i,1<<z){
		P p = P(0,0);
		rep(j,z){
			if(i&(1<<j)){
				p.first += w[s+j];
				p.second += v[s+j];
			]
		]
		x.push_back(p);
	}
}

int main()
{
	int n;
	cin >> n >> w;
	rep(i,n){
		cin >> v[i] >> w[i];
	}
	solve(0,n/2,x);
	solve(n/2,n,y);
	sort(x.begin(),x.end());
	sort(y.begin(),y.end());
	ll t=0;
	ll maxv = 0;
	ll ans = 0;
	for(int i=x.size()-1;i>=0;i++){
		while(t < y.size() && x[i].first+y[t].first <= w){
			maxv = max(maxv,y[i].second);
		}
		ans = max(ans,x[i].second+maxv);
	}
	cout << ans << "\n";
	return 0;
}

Compiler output:
a.cc: In function 'void solve(int, int, std::vector<int>&)':
a.cc:26:25: error: expected primary-expression before ']' token
   26 |                         ]
      |                         ^
a.cc:32:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   32 | int main()
      |         ^~
a.cc:32:9: note: remove parentheses to default-initialize a variable
   32 | int main()
      |         ^~
      |         --
a.cc:32:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:33:1: error: a function-definition is not allowed here before '{' token
   33 | {
      | ^
a.cc:54:2: error: expected '}' at end of input
   54 | }
      |  ^
a.cc:20:20: note: to match this '{'
   20 |         rep(i,1<<z){
      |                    ^
a.cc:54:2: error: expected '}' at end of input
   54 | }
      |  ^
a.cc:18:1: note: to match this '{'
   18 | {
      | ^
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;
typedef pair<ll,ll>pl;

const int MAX_N = 40;

ll v[MAX_N];
ll w[MAX_N];
vector<pl> x,y;

void solve(int s,int t,vector<pl> &x)
{
	int z = t-s;
	for(ll i=0,i<(1<<z);i++){
		P p = P(0,0);
		rep(j,z){
			if(i&(1<<j)){
				p.first += w[s+j];
				p.second += v[s+j];
			}
		}
		x.push_back(p);
	}
}

int main()
{
	int n;
	ll lm;
	cin >> n >> lm;
	rep(i,n){
		cin >> v[i] >> w[i];
	}
	solve(0,n/2,x);
	solve(n/2,n,y);
	sort(x.begin(),x.end());
	sort(y.begin(),y.end());
	ll t=0;
	ll maxv = 0;
	ll ans = 0;
	for(ll i=x.size()-1;i>=0;i--){
		while(t < y.size() && x[i].first+y[t].first <= lm){
			maxv = max(maxv,y[t].second);
			t++;
		}
		ans = max(ans,x[i].second+maxv);
	}
	cout << ans << "\n";
	return 0;
}

Compiler output:
a.cc: In function 'void solve(int, int, std::vector<std::pair<long long int, long long int> >&)':
a.cc:21:21: error: expected ';' before '<' token
   21 |         for(ll i=0,i<(1<<z);i++){
      |                     ^
      |                     ;
a.cc:21:21: error: expected primary-expression before '<' token
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;
typedef pair<ll,ll>pl;

const int MAX_N = 40;

ll v[MAX_N];
ll w[MAX_N];
vector<pl> x,y;

void solve(int s,int t,vector<pl> &x)
{
	int z = t-s;
	for(int i=0;i<(1<<z);i++){
		P p = P(0,0);
		rep(j,z){
			if(i>>j&1){
				p.first += w[s+j];
				p.second += v[s+j];
			}
		}
		x.push_back(p);
	}
}

int main()
{
	ll n;
	ll lm;
	cin >> n >> lm;
	rep(i,n){
		cin >> v[i] >> w[i];
	}
	solve(0,n/2,x);
	solve(n/2,n,y);
	sort(x.begin(),x.end());
	sort(y.begin(),y.end());
	ll t=0;
	ll maxv = -(1LL<<60);
	ll ans = 0;
	for(int i=(int)x.size()-1;i>=0;i--){
		P p = x[i]
		while(t < (int)y.size() && p.first+y[t].first <= lm){
			maxv = max(maxv,y[t].second);
			t++;
		}
		ans = max(ans,p.second+maxv);
	}
	cout << ans << "\n";
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:50:17: error: expected ',' or ';' before 'while'
   50 |                 while(t < (int)y.size() && p.first+y[t].first <= lm){
      |                 ^~~~~