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

#include <iostream>
using namespace std;
int knapsack(long long int arr[],long long int val[],long long int n,long long int W ){
   long long int dp[n+1][W+1];
   memset(dp,0,sizeof dp);
    //for(long long int i=0;i<=n;i++){
        //for(long long int j=0;j<=W;j++){
            //if(i==0||j==0){
               // dp[i][j]=0;

            //}
       // }
    //}
            for(long long int i=1;i<=n;i++){
                for(long long int j=0;j<=W;j++){

            
        
             if(arr[i]<=j){
                dp[i][j]=max(val[i]+dp[i-1][j-arr[i]],dp[i-1][j]);
            }
             else {
                dp[i][j]=dp[i-1][j];
            }
        }
    }
    return dp[n][W];
}
int main() {
    long long int n,W;
    cin>>n>>W;
   long long int arr[n+1],val[n+1];
    for(long long int i=1;i<=n;i++){
        cin>>arr[i]>>val[i];

    }
    cout<<knapsack(arr,val,n,W);


}


Compiler output:
a.cc: In function 'int knapsack(long long int*, long long int*, long long int, long long int)':
a.cc:5:4: error: 'memset' was not declared in this scope
    5 |    memset(dp,0,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 <stdio.h>
 
typedef long long ll;
 
ll dp[110][100010];
 
ll max(ll x, ll y)
{
	return x > y ? x : y;
}
 
int main()
{
	int n, w, weight[100], value[100];
 
	scanf("%d%d", &n, &w);
	for (int i = 0; i < n; i++)
	{
		scanf("%d%d", &weight[i], &value[i]);
	}
 
	for (int i = 0; i < n; i++)//品物の数
	{
		for (int j = w[i]; j <= w; j++)//重さ
		{
			dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
		}
	}
	printf("%lld\n", dp[n][w]);
	return 0;
}

Compiler output:
main.c: In function 'main':
main.c:24:31: error: subscripted value is neither array nor pointer nor vector
   24 |                 for (int j = w[i]; j <= w; j++)//重さ
      |                               ^
Language: Java

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

public class Knapsack1 {
//	3 8
//	3 30
//	4 50
//	5 60
	
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] numbersStr = br.readLine().split(" ");
		int n = Integer.parseInt(numbersStr[0]);
		int w = Integer.parseInt(numbersStr[1]);
		int[] weights = new int[n];
		int[] values = new int[n];
		for(int i = 0; i < n; i++){
			String[] ping = br.readLine().split(" ");
			weights[i] = Integer.parseInt(ping[0]);
			values[i] = Integer.parseInt(ping[1]);			
		}
		System.out.println(solver(weights, values, w, 0));
	}

	private static long solver(int[] weights, int[] values, int W, int index) {
		if(W < 0){
			return Integer.MIN_VALUE;
		}
		if(W==0){
			return 0;
		}
		if(index == weights.length){
			return 0;
		}
		
		long ans = 0;
		
		ans = Math.max(solver(weights, values, W-weights[index], index+1) + values[index], ans);
		ans = Math.max(solver(weights, values, W, index+1) , ans);
		return ans;
	}

}


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

#include<bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

int mod=10e8+7,maximum=-1;;

 long long int getmax(long long int n,long long int weight,long long int wt[],long long int values[])
{
  
    long long int i,j;
    long long int dp[n+1][weight+1];
   
    for(i=0;i<n+1;i++)
    dp[i][0]=0;
    for(j=0;j<weight+1;j++)
    dp[0][j]=0;
    
     for(i=1;i<n+1;i++)
     {
         for(j=1;j<weight+1;j++)
         {
             if(j>=wt[i-1])
             dp[i][j]=max(values[i-1]+dp[i-1][j-wt[i-1]],dp[i-1][j]);
             else
             {
                 dp[i][j]=dp[i-1][j];
             }
             
         }}
     
         
   
 
  
    return dp[n][weight];

    

}
int main()
{
     int n,weight;
    
    
   
        cin>>n>>weight;
         int wt[n],values[n];
        for( int i=0;i<n;i++)
   
        cin>>wt[i]>>values[i];
        cout<<getmax(n,weight,wt,values)<<"\n";
    
}

Compiler output:
a.cc: In function 'int main()':
a.cc:51:31: error: cannot convert 'int*' to 'long long int*'
   51 |         cout<<getmax(n,weight,wt,values)<<"\n";
      |                               ^~
      |                               |
      |                               int*
a.cc:7:74: note:   initializing argument 3 of 'long long int getmax(long long int, long long int, long long int*, long long int*)'
    7 |  long long int getmax(long long int n,long long int weight,long long int wt[],long long int values[])
      |                                                            ~~~~~~~~~~~~~~^~~~
Language: C++

// A Dynamic Programming based
// solution for 0-1 Knapsack problem
#include <stdio.h>
using namespace std; 
// A utility function that returns
// maximum of two integers
int max(int a, int b)
{
    return (a > b) ? a : b;
}
 
// Returns the maximum value that
// can be put in a knapsack of capacity W
int knapSack(int W, int wt[], int val[], int n)
{
    int i, w;
    int K[n + 1][W + 1];
 
    // Build table K[][] in bottom up manner
    for (i = 0; i <= n; i++) {
        for (w = 0; w <= W; w++) {
            if (i == 0 || w == 0)
                K[i][w] = 0;
            else if (wt[i - 1] <= w)
                K[i][w] = max(
                    val[i - 1] + K[i - 1][w - wt[i - 1]],
                    K[i - 1][w]);
            else
                K[i][w] = K[i - 1][w];
        }
    }
 
    return K[n][W];
}
 
int main()
{
    int W,N;
    cin>>N>>W;
     int val[N];
    int wt[N];
  for(int i=0;i<N;i++){
    int w,v;
    cin>>w>>v;
    val[i] = v;
    wt[i] = w;
  }
 
    printf("%d", knapSack(W, wt, val, N));
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:39:5: error: 'cin' was not declared in this scope
   39 |     cin>>N>>W;
      |     ^~~
a.cc:4:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    3 | #include <stdio.h>
  +++ |+#include <iostream>
    4 | using namespace std;
Language: C++

// A Dynamic Programming based
// solution for 0-1 Knapsack problem
#include <stdio.h>

// A utility function that returns
// maximum of two integers
int max(int a, int b)
{
    return (a > b) ? a : b;
}

// Returns the maximum value that
// can be put in a knapsack of capacity W
int knapSack(int W, int wt[], int val[], int n)
{
    int i, w;
    int K[n + 1][W + 1];

    // Build table K[][] in bottom up manner
    for (i = 0; i <= n; i++) {
        for (w = 0; w <= W; w++) {
            if (i == 0 || w == 0)
                K[i][w] = 0;
            else if (wt[i - 1] <= w)
                K[i][w] = max(
                    val[i - 1] + K[i - 1][w - wt[i - 1]],
                    K[i - 1][w]);
            else
                K[i][w] = K[i - 1][w];
        }
    }

    return K[n][W];
}

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

    printf("%d", knapSack(W, wt, val, N));
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:39:5: error: 'cin' was not declared in this scope
   39 |     cin>>N>>W;
      |     ^~~
Language: C++

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

long long ans = 0, sumForWeight[101][100005], n, w, aux;
int a, b;
vector <pair<int,int>> v;

void solve(int i, long long weight, long long sum){
    //cout << i << " " <<  weight << " " << sum << '\n';
    ans = max(ans, sum);

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

        if(weight + v[i].first <= w){

            long long pSum = v[i].second + sum;
            long long pWeight = v[i].first + weight;

           // cout << i << " " << pSum << " " << sumForWeight[pWeight] <<" " << pWeight<< " -\n";
            if(pSum > sumForWeight[i][pWeight]){ //gasesc o suma mai mare in aceeasi greutate

                sumForWeight[i][pWeight] = pSum; // modific suma maxima din sir

                solve(i, pWeight, pSum); //si continui drumul cu suma mai mare
            }

        }

    }

   // cout << '\n';

}

int main() {
    cin >> n >> w;

    for(int i = 1; i <= n; ++i){
        cin >> a  >> b;
        v.push_back(make_pair(a, b));
    }

    for(int i = 0; i < n; ++i){
        //cout << "\n";
        solve(i, v[i].first, v[i].second);
    }

    fout << ans;

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:51:5: error: 'fout' was not declared in this scope
   51 |     fout << ans;
      |     ^~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int n,W,dp[110][110];
vector<pair<int,int>> w;
int solve(int i,int j)
{
  if(j<0)
    return INT_MIN;
  if(i==-1)
    return 0;
  if(dp[i][j]!=-1)
    return dp[i][j];
  return dp[i][j]=max(w[i].second+solve(i-1,j-w.first),solve(i-1,j));
}
signed main()
{
  cin>>n>>W;
  for(int i=0;i<n;i++)
  {
    int x,y;
    cin>>x>>y;
    w.push_back({x,y});
  }
  sort(w.begin(),w.end());
  cout<<solve()<<"\n";
  return 0;
}

Compiler output:
a.cc: In function 'int solve(int, int)':
a.cc:13:49: error: 'class std::vector<std::pair<int, int> >' has no member named 'first'
   13 |   return dp[i][j]=max(w[i].second+solve(i-1,j-w.first),solve(i-1,j));
      |                                                 ^~~~~
a.cc: In function 'int main()':
a.cc:25:14: error: too few arguments to function 'int solve(int, int)'
   25 |   cout<<solve()<<"\n";
      |         ~~~~~^~
a.cc:5:5: note: declared here
    5 | int solve(int i,int j)
      |     ^~~~~
Language: C++

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

long long ans = 0, sumForWeight[100005], n, w;
int a, b;
vector <pair<int,int>> v;

bool cmp(pair<int,int> a, pair<int,int> b){
    if(a.first == b.first){
        return (a.second > b.second);
    }
    else
        return (a.first < b.first);
}

void solve(int i, long long weight, long long sum){
    //cout << i << " " <<  weight << " " << sum << '\n';
    ans = max(ans, sum);

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

        if(weight + v[i].first <= w){

            long long pSum = v[i].second + sum;
            long long pWeight = v[i].first + weight;

            if(pSum > sumForWeight[pWeight]){ //gasesc o suma mai mare in aceeasi greutate

                sumForWeight[pWeight] = pSum; // modific suma maxima din sir

                solve(i, pWeight, pSum); //si continui drumul cu suma mai mare
                //cout <<"---" << i << " " <<  weight << " " << sum << "---\n";
            }

        }

    }

    //cout << '\n';

}

int main() {
    cin >> n >> w;

    for(int i = 1; i <= n; ++i){
        fin >> a  >> b;
        v.push_back(make_pair(a, b));
    }

    sort(v.begin(), v.end(), cmp);

    for(int i = 0; i < n; ++i){
        if(v[i].second > sumForWeight[v[i].first] && v[i].first <= w){

            sumForWeight[v[i].first] = v[i].second;

            solve(i, v[i].first, v[i].second);

        }
    }

    cout << ans;

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:50:9: error: 'fin' was not declared in this scope
   50 |         fin >> a  >> b;
      |         ^~~
Language: C++

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

#define ll long long int
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mp make_pair
#define pb push_back
#define count_bits __builtin_popcount

const int N = 1e5+7;

ll dp[100001][101];

int main(){
		fast;
		int n  >> w;
		cin >> n >> w;
		ll val[n + 1] , wt[n + 1];

		for(int i = 1 ; i <= n ; i ++){
			cin >> wt[i] >> val[i];
		}

		for(int i = 1 ; i <= n ; i++)
			for(int j = 1; j <= w ;j++){
				if(wt[i] > w)
					dp[i][j] = dp[i-1][j];
				else{
					dp[i][j] = max(val[i] + dp[i-1][j - wt[i]] , dp[i-1][j]);
				}
			}

			cout << dp[n][w];

}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:24: error: expected initializer before '>>' token
   16 |                 int n  >> w;
      |                        ^~
a.cc:17:24: error: 'n' was not declared in this scope
   17 |                 cin >> n >> w;
      |                        ^
a.cc:17:29: error: 'w' was not declared in this scope
   17 |                 cin >> n >> w;
      |                             ^
a.cc:21:32: error: 'wt' was not declared in this scope
   21 |                         cin >> wt[i] >> val[i];
      |                                ^~
a.cc:21:41: error: 'val' was not declared in this scope
   21 |                         cin >> wt[i] >> val[i];
      |                                         ^~~
a.cc:26:36: error: 'wt' was not declared in this scope
   26 |                                 if(wt[i] > w)
      |                                    ^~
a.cc:29:56: error: 'val' was not declared in this scope
   29 |                                         dp[i][j] = max(val[i] + dp[i-1][j - wt[i]] , dp[i-1][j]);
      |                                                        ^~~
Language: C++

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

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

#include <bits/stdc++.h>
using namespace std;
 
const int N = 105;
const int W = 1e5 + 5;
int w[N], v[N];
int dp[N][W];
int n, wt;
 
int dynamic(int pos, int we)
{
 
    if (we > wt)
        return INT_MIN;
    if (pos >= n)
        return 0;
    if (dp[pos][we] != -1)
        return dp[pos][we];
    int ans;
    ans = max(dynamic(pos + 1, we + w[pos]) + v[pos], dynamic(pos + 1, we));
    dp[pos][we] = ans;
    return ans;
}
 
int main() {
    cin >> n >> wt;
    memset(dp,-1,sizeof(dp));
    for (int i = 0; i < n; i++)
        cin >> w[i] >> v[i];
    cout << dynamic(0, 0);
}
+

Compiler output:
a.cc:32:1: error: expected unqualified-id before '+' token
   32 | +
      | ^
Language: C++

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

int main(){
    int n,w;
    cin>>n>>w;
    int products[N][2];
    int dp[N+1][W+1];
    for(int i=0;i<n;i++){
        int a,b;
        cin>>a>>b;
        products[i][0]=a;
        products[i][1]=b;
    }
    for(int i=0;i<=n;i++){
        for(int j=0;j<=w;j++){
            if(i==0 || j==0) dp[i][j]=0;
            else{
                if(products[i-1][1]>=j)
                    dp[i][j]=min(dp[i-1][j],dp[i-1][j-products[i-1][1]]+products[i-1][0])
                else
                    dp[i][j]=dp[i-1][j]
            }
        }
    }
    cout<<dp[n][w]<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:18: error: 'N' was not declared in this scope
    7 |     int products[N][2];
      |                  ^
a.cc:8:17: error: 'W' was not declared in this scope
    8 |     int dp[N+1][W+1];
      |                 ^
a.cc:12:9: error: 'products' was not declared in this scope
   12 |         products[i][0]=a;
      |         ^~~~~~~~
a.cc:17:30: error: 'dp' was not declared in this scope; did you mean 'dup'?
   17 |             if(i==0 || j==0) dp[i][j]=0;
      |                              ^~
      |                              dup
a.cc:19:20: error: 'products' was not declared in this scope
   19 |                 if(products[i-1][1]>=j)
      |                    ^~~~~~~~
a.cc:20:21: error: 'dp' was not declared in this scope; did you mean 'dup'?
   20 |                     dp[i][j]=min(dp[i-1][j],dp[i-1][j-products[i-1][1]]+products[i-1][0])
      |                     ^~
      |                     dup
a.cc:26:11: error: 'dp' was not declared in this scope; did you mean 'dup'?
   26 |     cout<<dp[n][w]<<endl;
      |           ^~
      |           dup
Language: Java

import java.util.*;
public class Main{
public static void sortbyColumn(int arr[][], int col) 
    { 
        // Using built-in sort function Arrays.sort 
        Arrays.sort(arr, new Comparator<int[]>() { 
            
          @Override              
          // Compare values according to columns 
          public int compare(final int[] entry1,  
                             final int[] entry2) { 
  
            // To sort in descending order revert  
            // the '>' Operator 
            if (entry1[col] > entry2[col]) 
                return 1; 
            else
                return -1; 
          } 
        });  // End of function call sort(). 
    } 
public static void main(String args[]){
     int N,W;
    Scanner obj=new Scanner(System.in);
    N=obj.nextInt();
    W=obj.nextInt();
    int arr[][]=new int[N+1][2];
    arr[0][0] = 0;
    arr[0][1] = 0;
    for(int i=1;i<=N;i++){
    for(int j=1;j<=2;j++){
     arr[i][j]=obj.nextInt();
   }
   
   }

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


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

}


Compiler output:
Main.java:41: error: ';' expected
     dp[i][j]=arr[i][0]+dp[i][j-arr[i][0]]
                                          ^
1 error
Language: Java

import java.util.*;
public class Main{
public static void sortbyColumn(int arr[][], int col) 
    { 
        // Using built-in sort function Arrays.sort 
        Arrays.sort(arr, new Comparator<int[]>() { 
            
          @Override              
          // Compare values according to columns 
          public int compare(final int[] entry1,  
                             final int[] entry2) { 
  
            // To sort in descending order revert  
            // the '>' Operator 
            if (entry1[col] > entry2[col]) 
                return 1; 
            else
                return -1; 
          } 
        });  // End of function call sort(). 
    } 
public static void main(String args[]){
     int N,W;
    Scanner obj=new Scanner(System.in);
    N=obj.nextInt();
    W=obj.nextInt();
    int arr[][]=new int[N+1][2];
    arr[0][0] = 0;
    arr[0][1] = 0;
    for(int i=1;i<=N;i++){
    for(int j=1;j<=2;j++){
     arr[i][j]=obj.nextInt();
   }
   
   }
  long v=0;
int max=0;
sortbyColumn(arr,0);
int dp[][]=new  int[N][W];
for(int i=1;i<=N;i++){
   for(int j=arr[0][0];j<=W;j++){
     dp[i][j]=arr[i][0]+dp[i][j-arr[i][0]]
   }
}

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

}


Compiler output:
Main.java:42: error: ';' expected
     dp[i][j]=arr[i][0]+dp[i][j-arr[i][0]]
                                          ^
Main.java:47: error: <identifier> expected
System.out.println(dp[N][W]);
                  ^
Main.java:47: error: ']' expected
System.out.println(dp[N][W]);
                      ^
Main.java:47: error: ',', ')', or '[' expected
System.out.println(dp[N][W]);
                       ^
Main.java:51: error: class, interface, enum, or record expected
}
^
5 errors
Language: C++

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

#define int long long

void maxself(int &a, int b) {a=max(a,b);}

int main(){
    int n,w;cin>>n>>w;
    vector<int> dp(w+1);
    //dp[i] is the maximum total value of the items with total weight <=i
    for(int i=0;i<n;i++){
        int weight, value;cin>>weight>>value;
        for(int wt_already=w-weight;wt_already>=0;wt_already--){
            maxself(dp[wt_already+weight], dp[wt_already]+value);
        }
    }
    cout<<dp[w]<<endl;
    
    return 0ll;
}


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

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

#define int long long

void maxself(int &a, int b) {a=max(a,b);}

int main(){
    int n,w;cin>>n>>w;
    vector<int> dp(w+1);
    //dp[i] is the maximum total value of the items with total weight <=i
    for(int i=0;i<n;i++){
        int weight, value;cin>>weight>>value;
        for(int wt_already=w-weight;wt_already>=0;wt_already--){
            maxself(dp[wt_already+weight], dp[wt_already]+value);
        }
    }
    cout<<dp[w]<<endl;
    
    return 0;
}


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

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

int knapsack(int si, int wt[], int val[], int capacity, int n)
{
    if(si==n)         //base case
        return 0;

    int include =INT_MIN;

    if(wt[si] <= capacity)
    {
        include =val[si] + knapsack(si+1, wt, val, capacity-wt[si], n);
    }

    int skip =knapsack(si+1, wt, val, capacity, n);
    int result =max(include, skip);
    return result;

}

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int n,w;
    cin>>n>>w;
     int weight[102];
    int value[102];
  for(int i=0; i<n; i++)
  {
    cin>>weight[i]>>value[i];
  }

	// returns the maximum value which can be obtained within the bag capacity
	cout<<knapsack(0, weight, value, capacity, n)<<'\n';
    return 0;
}


Compiler output:
a.cc: In function 'int32_t main()':
a.cc:38:42: error: 'capacity' was not declared in this scope
   38 |         cout<<knapsack(0, weight, value, capacity, n)<<'\n';
      |                                          ^~~~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define int long long
int knapsack(int si, int wt[], int val[], int capacity, int n)
{
    if(si==n)         //base case
        return 0;

    int include =INT_MIN;

    if(wt[si] <= capacity)
    {
        include =val[si] + knapsack(si+1, wt, val, capacity-wt[si], n);
    }

    int skip =knapsack(si+1, wt, val, capacity, n);
    int result =max(include, skip);
    return result;

}

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
  
     int n,w;
     cin>>n>>w;
      int weight[102];
     int value[102];
      for(int i=0; i<n; i++)
        cin>>weight[i];
      for(int i=0; i<n; i++)
        cin>>value[i];
  
  
  
	// returns the maximum value which can be obtained within the bag capacity
	cout<<knapsack(0, weight, value, w, n)<<'\n;

/*
	vector<vector<int> > dp(n+1, vector<int> (capacity+1, -1));
    cout<<knapsack_memo(0, weight, value, capacity, n, dp)<<endl;
*/

    return 0;
}


Compiler output:
a.cc:39:49: warning: missing terminating ' character
   39 |         cout<<knapsack(0, weight, value, w, n)<<'\n;
      |                                                 ^
a.cc:39:49: error: missing terminating ' character
   39 |         cout<<knapsack(0, weight, value, w, n)<<'\n;
      |                                                 ^~~~
a.cc: In function 'int32_t main()':
a.cc:46:5: error: expected primary-expression before 'return'
   46 |     return 0;
      |     ^~~~~~
Language: Java

import java.util.*;
public class Main{
public static void sortbyColumn(int arr[][], int col) 
    { 
        // Using built-in sort function Arrays.sort 
        Arrays.sort(arr, new Comparator<int[]>() { 
            
          @Override              
          // Compare values according to columns 
          public int compare(final int[] entry1,  
                             final int[] entry2) { 
  
            // To sort in descending order revert  
            // the '>' Operator 
            if (entry1[col] > entry2[col]) 
                return 1; 
            else
                return -1; 
          } 
        });  // End of function call sort(). 
    } 
public static void main(String args[]){
     int N,W;
    Scanner obj=new Scanner(System.in);
    N=onj.nextInt();
    W=obj.nextInt();
    int arr[][]=new int[N][3];
    for(int i=0;i<N;i++){
    for(int j=0;j<2;j++){
     arr[i][j]=obj.nextInt();
   }
   arr[i][2]=arr[i][1]/arr[i][0];
   }
  int v=0;
int max=0;
sortbyColumn(arr,2);
for(int i=0;i<N&&W>0;i++){
   if(W>arr[i][0]){
    v+=arr[i][1];
    W=W-arr[i][0];
}
else {
   v+=arr[i][2]*W;
   W=0;
}

}
return v;
 
}

}

Compiler output:
Main.java:25: error: cannot find symbol
    N=onj.nextInt();
      ^
  symbol:   variable onj
  location: class Main
Main.java:48: error: incompatible types: unexpected return value
return v;
       ^
2 errors
Language: C++

#include<bits/stdc++.h>

using namespace std;

int knapSack(int n, int W, vector<int> wt, vector<int> val) 
{ 
    int i, w; 
    int K[n + 1][W + 1]; 
  
    // Build table K[][] in bottom up manner 
    for (i = 0; i <= n; i++) { 
        for (w = 0; w <= W; w++) { 
            if (i == 0 || w == 0) 
                K[i][w] = 0; 
            else if (wt[i - 1] <= w) 
                K[i][w] = max( 
                    val[i - 1] + K[i - 1][w - wt[i - 1]], 
                    K[i - 1][w]); 
            else
                K[i][w] = K[i - 1][w]; 
        } 
    } 
  
    return K[n][W]; 
} 


int main()
{
  	int n,W;
  	cin>>n>>W;
  	vector<int> v; vector<int> W;
    for(int i=0; i<n; i++)
    {
    	int temp, temp1;
      	cin>>temp>>temp1;
      	a.push_back(temp); b.push_back(temp1);
    }
  cout<<knapsack(n,W,a,b);
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:32:36: error: conflicting declaration 'std::vector<int> W'
   32 |         vector<int> v; vector<int> W;
      |                                    ^
a.cc:30:15: note: previous declaration as 'int W'
   30 |         int n,W;
      |               ^
a.cc:37:9: error: 'a' was not declared in this scope
   37 |         a.push_back(temp); b.push_back(temp1);
      |         ^
a.cc:37:28: error: 'b' was not declared in this scope
   37 |         a.push_back(temp); b.push_back(temp1);
      |                            ^
a.cc:39:22: error: 'a' was not declared in this scope
   39 |   cout<<knapsack(n,W,a,b);
      |                      ^
a.cc:39:24: error: 'b' was not declared in this scope
   39 |   cout<<knapsack(n,W,a,b);
      |                        ^
a.cc:39:9: error: 'knapsack' was not declared in this scope; did you mean 'knapSack'?
   39 |   cout<<knapsack(n,W,a,b);
      |         ^~~~~~~~
      |         knapSack
Language: C++

#include<bits/stdc++.h>

using namespace std;

int knapSack(int n, int W, vector<int> wt, vector<int> val) 
{ 
    int i, w; 
    int K[n + 1][W + 1]; 
  
    // Build table K[][] in bottom up manner 
    for (i = 0; i <= n; i++) { 
        for (w = 0; w <= W; w++) { 
            if (i == 0 || w == 0) 
                K[i][w] = 0; 
            else if (wt[i - 1] <= w) 
                K[i][w] = max( 
                    val[i - 1] + K[i - 1][w - wt[i - 1]], 
                    K[i - 1][w]); 
            else
                K[i][w] = K[i - 1][w]; 
        } 
    } 
  
    return K[n][W]; 
} 


int main()
{
  	int n,W;
  	cin>>n>>W;
  	vector<int> v; vector<int> W
    for(int i=0; i<n; i++)
    {
    	int temp, temp1;
      	cin>>temp>>temp1;
      	a.push_back(temp); b.push_back(temp1);
    }
  cout<<knapsack(n,W,a,b);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:33:5: error: expected initializer before 'for'
   33 |     for(int i=0; i<n; i++)
      |     ^~~
a.cc:33:18: error: 'i' was not declared in this scope
   33 |     for(int i=0; i<n; i++)
      |                  ^
a.cc:39:22: error: 'a' was not declared in this scope
   39 |   cout<<knapsack(n,W,a,b);
      |                      ^
a.cc:39:24: error: 'b' was not declared in this scope
   39 |   cout<<knapsack(n,W,a,b);
      |                        ^
a.cc:39:9: error: 'knapsack' was not declared in this scope; did you mean 'knapSack'?
   39 |   cout<<knapsack(n,W,a,b);
      |         ^~~~~~~~
      |         knapSack
Language: C++

#include <bits/stdc++.h>
#define fly ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr)
#define ll long long
const ll mod = 1e9 + 7;

using namespace std;
ll dp[100010][101] = {0};
ll main(int argc, char const *argv[]) {
  fly;
  ll n,w;
  cin >> n >> w;
  vector<ll>weigth(n);
  vector<ll>cst(n);
  for(int i = 1;i<=n;i++){
    cin >> weigth[i] >> cst[i];
  }
  for(ll i = 0;i<=w;i++){
    for(ll j = 0;j<=n;j++){
      dp[i][j] = 0;
      if(i == 0 || j == 0)
        continue;
      dp[i][j] = max(dp[i][j], dp[i][j-1]);
      if(i>=weigth[j]){
        dp[i][j] = max(dp[i][j], dp[i-weigth[j]][j-1] + cst[j]);
      }
    }
  }
  ll ans = 0;
  for(ll i = 0;i<=w;i++){
    ans = max(ans, dp[i][n]);
  }
  cout << ans << endl;

  return 0;
}


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

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

template<class T> void chmax(T &a, T b) {
    if (a < b) {
        a = b;
    }
}

int main() {
    int N;
    long long W;
    cin >> N >> W;
    vector<int> weight(N), value(N);
    for (int i = 0; i < N; ++i) cin >> weight[i] >> value[i];
    
    vector<vector<long long>> dp(N+1, vector<long long>(W+1, 0));
    
    for (int i = 0; i < N; ++i) {
        for (int w = 0; w <= W; ++w) {
            if (w - weight[i] >= 0) {
                chmax(dp[i+1][w], dp[i][w-weight[i]] + value[i]);
            }
            chmax(dp[i+1][w], dp[i][w]);
        }
    }
    cout << dp[N][W] << endl;
}
}

Compiler output:
a.cc:30:1: error: expected declaration before '}' token
   30 | }
      | ^
Language: C++

#include <bits/stdc++.h> 
using namespace std; 
int main(){
    long long int n,c;
cin>>n>>c;
long long int vals[n][2];
for (int i=0;i<n;i++)
{
    cin>>vals[i][0]>>vals[i][1];
}
long long int dp[n+1][c+1];
for (int i=0;i<=n;i++){
	for(int j=0;j<=c;j++){
		
		dp[i][j]=0;
	}
}
for (int i=1;i<n+1;i++){
	
	for(int j=1;j<c+1;j++){
		if (vals[i-1][0]>j){
			dp[i][j]=dp[i-1][j];
		}
		else{
			dp[i][j]=max(dp[i-1][j],dp[i-1][j-vals[i-1][0]]+vals[i-1][1]);
		}
		
	}
	
}
cout<<dp[n][c];

Compiler output:
a.cc: In function 'int main()':
a.cc:31:16: error: expected '}' at end of input
   31 | cout<<dp[n][c];
      |                ^
a.cc:3:11: note: to match this '{'
    3 | int main(){
      |           ^
Language: C++

#include<iostream>

using namespace std;

typedef long long int ll;
int main(){
	int N,W,i,j;
	cin>>N>>W;
	vector<int> wt(N);
	vector<int> val(N);
	for(i=0;i<N;i++){
		cin>>wt[i];
		cin>>val[i];
	}
	long long int ans;
	
	vector<vector<ll>> dp(N+1,vector<ll>(W+1,0));
	for(i=1;i<=N;i++){
		for(j=1;j<=W;j++){
			if(wt[i-1]>j)
				dp[i][j]=dp[i-1][j];
			else{
				dp[i][j]=dp[i-1][j];
				dp[i][j]=max(dp[i][j],val[i-1]+dp[i-1][j-wt[i-1]]);
			}
		}
	}
	cout<<dp[N][W]<<endl;
	
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:9: error: 'vector' was not declared in this scope
    9 |         vector<int> wt(N);
      |         ^~~~~~
a.cc:2:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    1 | #include<iostream>
  +++ |+#include <vector>
    2 | 
a.cc:9:16: error: expected primary-expression before 'int'
    9 |         vector<int> wt(N);
      |                ^~~
a.cc:10:16: error: expected primary-expression before 'int'
   10 |         vector<int> val(N);
      |                ^~~
a.cc:12:22: error: 'wt' was not declared in this scope
   12 |                 cin>>wt[i];
      |                      ^~
a.cc:13:22: error: 'val' was not declared in this scope
   13 |                 cin>>val[i];
      |                      ^~~
a.cc:17:25: error: expected primary-expression before '>>' token
   17 |         vector<vector<ll>> dp(N+1,vector<ll>(W+1,0));
      |                         ^~
a.cc:17:44: error: expected primary-expression before '>' token
   17 |         vector<vector<ll>> dp(N+1,vector<ll>(W+1,0));
      |                                            ^
a.cc:17:28: error: 'dp' was not declared in this scope
   17 |         vector<vector<ll>> dp(N+1,vector<ll>(W+1,0));
      |                            ^~
a.cc:20:28: error: 'wt' was not declared in this scope
   20 |                         if(wt[i-1]>j)
      |                            ^~
a.cc:24:55: error: 'val' was not declared in this scope
   24 |                                 dp[i][j]=max(dp[i][j],val[i-1]+dp[i-1][j-wt[i-1]]);
      |                                                       ^~~
Language: C++

#include <iostream>
#include <algorithm>
#define ll long long

using namespace std;

const int NMAX = 205, MMAX = 105;
struct OBJECT {
    ll v, w;
} v[NMAX];
int matrix[MMAX][MMAX];

ll n, w;
ll a, b;
ll val;

ll solve(int pos, int weight) {
    if(weight > w)
        return INT_MIN;
    if(pos > n)
        return 0;
    if(matrix[pos][weight] != 0)
        return matrix[pos][weight];
    val = max(solve(pos + 1, weight + v[pos].w) + v[pos].v, solve(pos + 1, weight));
    matrix[pos][weight] = val;
    return val;
}

int main()
{
    cin >> n >> w;
    for(int i = 1; i <= n; i++) {
        cin >> a >> b;
        v[i].w = a;
        v[i].v = b;
    }
    cout << solve(1, 0);
    return 0;
}


Compiler output:
a.cc: In function 'long long int solve(int, int)':
a.cc:19:16: error: 'INT_MIN' was not declared in this scope
   19 |         return INT_MIN;
      |                ^~~~~~~
a.cc:3:1: note: 'INT_MIN' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    2 | #include <algorithm>
  +++ |+#include <climits>
    3 | #define ll long long
Language: C++

#include "stdafx.h"
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
using namespace std;

# define ll long long
//#define forn(i,n) for(int i = 0; i < (n); ++i)

const int N = 100001;
ll dp[N];

int main()
{
	int n, tot;
	cin >> n >> tot;
	for (int i = 0; i < n; i++)
	{
		ll x, y;
		cin >> x >> y;
		for (int j = tot - x; j >= 0; j--) {
			dp[j + x] = max(dp[j + x], dp[j] + y);
		}
	}
	cout << dp[tot] << endl;
	return 0;
}

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

import java.util.*;
import java.io.*;
 
 
class Main{
  public static void main(String args[]) throws IOException
  {
    BufferedReader reader = new BufferedReader(new InputStreamBuffer(System.in));
    int N = Integer.parseInt(reader.readLine());
    int w[] = new int[N];
    int v[] = new int[N];
    for(int i=0; i<N; i++)
    {
      String str[] = reader.readLine().split(" ");
      w[i] = Integer.parseInt(str[0]);
      v[i] = Integer.parseInt(str[1]);
    }
    
    int res = Solution(w, v, N);
  }
  
  public static int Solution(int w[], int v[], int N)
  {
     int tw =0;
    for(int i=0; i<N; i++) tw = tw + w[i];
    
    int dp[][] = new int[N+1][tw + 1];
    
    for(int i=0; i<=N; i++)
    {
      for(int j = 0; j<=tw; j++)
      {
         if(i==0 ||j==0)
           dp[i][j] = 0;
         else
         {
             if(v[j] <=j)
                dp[i][j] = Math.max(dp[i-1][j], v[i] + dp[i-1][j-w[i]]);
              else
                 dp[i][j] = dp[i-1][j];
                                                               
        }                                                            
     }                                                      
                                                               
   }
       return dp[N][tw];
  }  
}
                   
import java.util.*;
import java.io.*;
 
 
class Main{
  public static void main(String args[]) throws IOException
  {
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    int N = Integer.parseInt(reader.readLine());
    int w[] = new int[N];
    int v[] = new int[N];
    for(int i=0; i<N; i++)
    {
      String str[] = reader.readLine().split(" ");
      w[i] = Integer.parseInt(str[0]);
      v[i] = Integer.parseInt(str[1]);
    }
    
    int res = Solution(w, v, N);
  }
  
  public static int Solution(int w[], int v[], int N)
  {
     int tw =0;
    for(int i=0; i<N; i++) tw = tw + w[i];
    
    int dp[][] = new int[N+1][tw + 1];
    
    for(int i=0; i<=N; i++)
    {
      for(int j = 0; j<=tw; j++)
      {
         if(i==0 ||j==0)
           dp[i][j] = 0;
         else
         {
             if(v[j] <=j)
                dp[i][j] = Math.max(dp[i-1][j], v[i] + dp[i-1][j-w[i]]);
              else
                 dp[i][j] = dp[i-1][j];
                                                               
        }                                                            
     }                                                      
                                                               
   }
       return dp[N][tw];
  }  
}
                   

Compiler output:
Main.java:50: error: class, interface, enum, or record expected
import java.util.*;
^
Main.java:51: error: class, interface, enum, or record expected
import java.io.*;
^
2 errors
Language: Java

import java.util.*;
import java.io.*;
 
 
class Main{
  public static void main(String args[]) throws IOException
  {
    BufferedReader reader = new BufferedReader(new InputStreamBuffer(System.in));
    int N = Integer.parseInt(reader.readLine());
    int w[] = new int[N];
    int v[] = new int[N];
    for(int i=0; i<N; i++)
    {
      String str[] = reader.readLine().split(" ");
      w[i] = Integer.parseInt(str[0]);
      v[i] = Integer.parseInt(str[1]);
    }
    
    int res = Solution(w, v, N);
  }
  
  public static int Solution(int w[], int v[], int N)
  {
     int tw =0;
    for(int i=0; i<N; i++) tw = tw + w[i];
    
    int dp[][] = new int[N+1][tw + 1];
    
    for(int i=0; i<=N; i++)
    {
      for(int j = 0; j<=tw; j++)
      {
         if(i==0 ||j==0)
           dp[i][j] = 0;
         else
         {
             if(v[j] <=j)
                dp[i][j] = Math.max(dp[i-1][j], v[i] + dp[i-1][j-w[i]]);
              else
                 dp[i][j] = dp[i-1][j];
                                                               
        }                                                            
     }                                                      
                                                               
   }
       return dp[N][tw];
  }  
}
                   

Compiler output:
Main.java:8: error: cannot find symbol
    BufferedReader reader = new BufferedReader(new InputStreamBuffer(System.in));
                                                   ^
  symbol:   class InputStreamBuffer
  location: class Main
1 error
Language: Java

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


class Main{
  public static void main(String args[]) throws IOException
  {
    BufferedReader reader = new BufferedReader(new InputStreamBuffer(System.in));
    int N = Integer.parseInt(reader.readLine());
    int w[] = new int[N];
    int v[] = new int[N];
    for(int i=0; i<N; i++)
    {
      String str[] = reader.readLine().split(" ");
      w[i] = Integer.parseInt(str[0]);
      v[i] = Integer.parseInt(str[1]);
    }
    
    int res = Solution(w, v, N);
  }
  
  public static int Solution(int w[], int v[], int N)
  {
     int tw =0;
    for(int i=0; i<N; i++) tw = tw + w[i];
    
    int dp[][] = new int[N+1][tw + 1];
    
    for(int i=0; i<=N; i++)
    {
      for(int j = 0; j<=tw; j++)
      {
         if(i==0 ||j==0)
           dp[i][j] = 0;
         else
         {
             if(v[j] <=j)
                dp[i][j] = Math.max(dp[i-1][j], v[i] + dp[i-1][j-w[i]);
              else
                 dp[i][j] = dp[i-1][j];
                                                               
        }                                                            
    }                                                      
                                                               
   }
       return dp[N][tw];
     }    }
                                         
    

Compiler output:
Main.java:38: error: ']' expected
                dp[i][j] = Math.max(dp[i-1][j], v[i] + dp[i-1][j-w[i]);
                                                                     ^
1 error
Language: Java

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

public class E {
	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

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

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}

	public static void main(String[] args) {
		FastReader fr = new FastReader();

		int N = fr.nextInt();
		int W = fr.nextInt(); // upto 10^5
		int[] w = new int[N];
		long[] v = new long[N]; 
		
		for(int i = 0; i < N; i++) {
			w[i] = fr.nextInt();
			v[i] = fr.nextLong();
		}
		
		long[][] dp = new long[N+1][W+1];
		
		for(int i = 1; i <= N; i++) {
			for(int j = 1; j <= W; j++) {
				if (w[i-1] > j) dp[i][j] = dp[i-1][j];
				else dp[i][j] = Math.max(dp[i-1][j], dp[i-1][j-w[i-1]] + v[i-1]);
			}
		}
		
		System.out.println(dp[N][W]);
	}

}


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

import java.util.Arrays;
import java.util.Scanner;

public class knap1 {
	public static int n,w;
	public static int [] wi,vi;
	public static int [][] dp;
	public static int maxpro(int pos,int rem)
	{   if(pos>=n)
			return dp[pos][rem]=0;
		if(dp[pos][rem]!=-1)
			return dp[pos][rem];
		int ex;
		int in=Integer.MIN_VALUE;
		if(rem-wi[pos]>=0)
			in=vi[pos]+maxpro(pos+1,rem-wi[pos]);
		ex=maxpro(pos+1,rem);
		return dp[pos][rem]=Math.max(in, ex);
	}
	
	public static void Main(String[] args) {
		// TODO Auto-generated method stub
		
		Scanner in=new Scanner(System.in);
		n=in.nextInt();
		w=in.nextInt();
		wi=new int[n];
		vi=new int[n];
		dp=new int[n+1][w+1];
		for(int i=0;i<n;i++)
			{ wi[i]=in.nextInt();
			  vi[i]=in.nextInt();
			}
		for(int i=0;i<=n;i++)
			Arrays.fill(dp[i],-1);
	
		System.out.println(maxpro(0,w));
	}

}


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

import java.util.Arrays;
import java.util.Scanner;

public class knap1 {
	public static int n,w;
	public static int [] wi,vi;
	public static int [][] dp;
	public static int maxpro(int pos,int rem)
	{   if(pos>=n)
			return dp[pos][rem]=0;
		if(dp[pos][rem]!=-1)
			return dp[pos][rem];
		int ex;
		int in=Integer.MIN_VALUE;
		if(rem-wi[pos]>=0)
			in=vi[pos]+maxpro(pos+1,rem-wi[pos]);
		ex=maxpro(pos+1,rem);
		return dp[pos][rem]=Math.max(in, ex);
	}
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		Scanner in=new Scanner(System.in);
		n=in.nextInt();
		w=in.nextInt();
		wi=new int[n];
		vi=new int[n];
		dp=new int[n+1][w+1];
		for(int i=0;i<n;i++)
			{ wi[i]=in.nextInt();
			  vi[i]=in.nextInt();
			}
		for(int i=0;i<=n;i++)
			Arrays.fill(dp[i],-1);
	
		System.out.println(maxpro(0,w));
	}

}


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

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


int dp[100][100] = {0};
// for (int i = 0; i < n; i++) {
//   for (int j = 0; j < n; j++) {
//     dp[i][j] = 0;
//   }
// }
int f(int *value, int *weight, int n, int w ) {
  if (dp[n - 1][w] != 0) return dp[n - 1][w];
  if (n == 0 || w == 0) return 0;
  int a, b;
  a = b = INT_MIN;
  if (weight[n - 1] <= w)
    a = value[n - 1] + f(value, weight, n - 1, w - weight[n - 1]);
  b = f(value, weight, n - 1, w);
  return dp[n - 1][w] = max(a, b);
}

int32_t main() {
  
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

  int n, w;
  cin >> n >> w;
  int value[n ];
  int weight[n ];

  for (int i = 0; i < n; i++) {
    cin >> weight[i] >> value[i];
  }
  cout << f(value, weight, n, w);


  return 0;
}

Compiler output:
a.cc: In function 'void c_p_c()':
a.cc:14:47: error: a function-definition is not allowed here before '{' token
   14 | int f(int *value, int *weight, int n, int w ) {
      |                                               ^
a.cc:25:13: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   25 | int32_t main() {
      |             ^~
a.cc:25:13: note: remove parentheses to default-initialize a variable
   25 | int32_t main() {
      |             ^~
      |             --
a.cc:25:13: note: or replace parentheses with braces to value-initialize a variable
a.cc:25:16: error: a function-definition is not allowed here before '{' token
   25 | int32_t main() {
      |                ^
a.cc:41:2: error: expected '}' at end of input
   41 | }
      |  ^
a.cc:5:1: note: to match this '{'
    5 | {
      | ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, x;
  cin >> n >> x;
  vector<int> price(n), pages(n);
  for (int&v : price) cin >> v;
  for (int&v : pages) cin >> v;
  vector<int> dp(x+1,0);
  for(int i=0; i < n; i++) {
    for(int j=x; j>=price[i]; j--)
        dp[j] = max(dp[j] , pages[i] + dp[j-price[i]]);
  }
  cout<<dp[x]<<endl;
 

Compiler output:
a.cc: In function 'int main()':
a.cc:15:21: error: expected '}' at end of input
   15 |   cout<<dp[x]<<endl;
      |                     ^
a.cc:4:12: note: to match this '{'
    4 | int main() {
      |            ^
Language: C++



#include <bits/stdc++.h>
using namespace std;
using ll = long long ;
#define pb push_back

struct item
{
	int wt ;
	ll val ;
};
ll knapsack(vector<item>v, int n , int W)
{
	ll dp[n][W] ;
	for (int i = 0 ; i <= W ; i++)
	{
		dp[0][i] = 0 ;
	}
	dp[0][v[0].wt] = v[0].val ;
	for (int i = 1 ; i < n ; i++)
	{
		for (int w = 0 ; w <= W ; w++)
		{
			dp[i][w] = dp[i - 1][w];
			if (v[i].wt > w)
				continue ;
			dp[i][w] = max(dp[i][w], v[i].val + dp[i - 1][w - v[i].wt]);
		}
	}
	return *max_element(dp[n-1], dp[n-1] + W + 1) ;
}
int main()
{
	FAST
	int n , W ; cin >> n >> W ;
	vector<item> v(n);
	for (int i = 0 ; i < n ; i++)
	{
		cin >> v[i].wt >> v[i].val ;
	}
	cout << knapsack(v, n, W) << endl;
	return 0 ;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:35:9: error: 'FAST' was not declared in this scope
   35 |         FAST
      |         ^~~~
a.cc:36:28: error: 'n' was not declared in this scope; did you mean 'yn'?
   36 |         int n , W ; cin >> n >> W ;
      |                            ^
      |                            yn
a.cc:36:33: error: 'W' was not declared in this scope
   36 |         int n , W ; cin >> n >> W ;
      |                                 ^
Language: C++

#include "bits/stdc++.h"
using namespace std;
 
int main(){
  int n,c;
  cin >> n >>c ;
  
  long long val[n],wt[n];
  for(int i=0;i<n;i++){
 	cin >> wt[i] >> val[i] ;
  }
  
  long long  dp[n+1][c+1] ;
  
  for(int i=0;i<=n;i++){
    for(int j=0;j<=c;j++){
      if(i==0 || j==0)
        dp[i][j]=0;
      else if(wt[i-1]<=j){
        dp[i][j]=max(val[i-1]+dp[i-1][j-wt[i-1]] , dp[i-1][j]) ;
      }else{
        dp[i][j]=dp[i-1][j];
      }
      
    }
  }
  
  cout<<dp[n][c] ;
  
  return 0;
}
#include "bits/stdc++.h"
using namespace std;

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


Compiler output:
a.cc:35:5: error: redefinition of 'int main()'
   35 | int main(){
      |     ^~~~
a.cc:4:5: note: 'int main()' previously defined here
    4 | int main(){
      |     ^~~~