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

#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
const ll INF = 1e18L + 5;
int main() {
    ll n,W;
    cin>>n>>W;
    vector<ll> v(n),wt(n);
        ll sum_value=0;
    for(ll i=0;i<n;i++){
        cin>>wt[i]>>v[i];
        sum_value+=v[i];
    }
    vector<ll> dp (sum_value+1,INF);
    dp[0]=0;
    //dp[i]=min weight with total value exactly i;
    for(ll i=0;i<n;i++){
        for(ll value_already=sum_value-v[i]; value_already>=0;value_already--){
            dp[value_already+v[i]]=min(dp[value_already+v[i]],dp[value_already]+wt[i]);
        }
    }
        ll answer =0;
        for(ll i=0;i<=sum_value;i++){
            if(dp[i]<=W){
            answer=max(answer,i);}
        }
        cout<<answer;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:5: error: 'vector' was not declared in this scope
    9 |     vector<ll> v(n),wt(n);
      |     ^~~~~~
a.cc:3:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    2 | #include <algorithm>
  +++ |+#include <vector>
    3 | using namespace std;
a.cc:9:14: error: expected primary-expression before '>' token
    9 |     vector<ll> v(n),wt(n);
      |              ^
a.cc:9:16: error: 'v' was not declared in this scope
    9 |     vector<ll> v(n),wt(n);
      |                ^
a.cc:9:21: error: 'wt' was not declared in this scope
    9 |     vector<ll> v(n),wt(n);
      |                     ^~
a.cc:15:14: error: expected primary-expression before '>' token
   15 |     vector<ll> dp (sum_value+1,INF);
      |              ^
a.cc:15:16: error: 'dp' was not declared in this scope
   15 |     vector<ll> dp (sum_value+1,INF);
      |                ^~
Language: C++

#include <bits/stdc++.h> 
  
using namespace std; 
  
// Structure for an item which stores weight and corresponding 
// value of Item 
struct Item 
{ 
    int value, weight; 
  
    // Constructor 
    Item(int value, int weight) : value(value), weight(weight) 
    {} 
}; 
  
// Comparison function to sort Item according to val/weight ratio 
bool cmp(struct Item a, struct Item b) 
{ 
    double r1 = (double)a.value / a.weight; 
    double r2 = (double)b.value / b.weight; 
    return r1 > r2; 
} 

double fractionalKnapsack(int W, struct Item arr[], int n) 
{ 
    //    sorting Item on basis of ratio 
    sort(arr, arr + n, cmp); 
  
    //    Uncomment to see new order of Items with their ratio 
    /* 
    for (int i = 0; i < n; i++) 
    { 
        cout << arr[i].value << "  " << arr[i].weight << " : " 
             << ((double)arr[i].value / arr[i].weight) << endl; 
    } 
    */
  
    int curWeight = 0;  // Current weight in knapsack 
    double finalvalue = 0.0; // Result (value in Knapsack) 
  
    // Looping through all Items 
    for (int i = 0; i < n; i++) 
    { 
        // If adding Item won't overflow, add it completely 
        if (curWeight + arr[i].weight <= W) 
        { 
            curWeight += arr[i].weight; 
            finalvalue += arr[i].value; 
        } 
  
        // If we can't add current Item, add fractional part of it 
        else
        { 
            int remain = W - curWeight; 
            finalvalue += arr[i].value * ((double) remain / arr[i].weight); 
            break; 
        } 
    } 
  
    // Returning final value 
    return finalvalue; 
} 
  
// driver program to test above function 
int main() 
{ 
    LL n, w; cin >> n >> W;  //    Weight of knapsack 
    Item arr[n];

  	for (int i = 0; i < n; i++){
  		cin >> arr[i].weight >> arr[i].value;
  	}

 //   int n = sizeof(arr) / sizeof(arr[0]); 
  
    cout <<(long long)fractionalKnapsack(W, arr, n); 
    return 0; 
} 

Compiler output:
a.cc: In function 'int main()':
a.cc:67:5: error: 'LL' was not declared in this scope
   67 |     LL n, w; cin >> n >> W;  //    Weight of knapsack
      |     ^~
a.cc:67:21: error: 'n' was not declared in this scope; did you mean 'yn'?
   67 |     LL n, w; cin >> n >> W;  //    Weight of knapsack
      |                     ^
      |                     yn
a.cc:67:26: error: 'W' was not declared in this scope
   67 |     LL n, w; cin >> n >> W;  //    Weight of knapsack
      |                          ^
a.cc:71:24: error: 'arr' was not declared in this scope
   71 |                 cin >> arr[i].weight >> arr[i].value;
      |                        ^~~
a.cc:76:45: error: 'arr' was not declared in this scope
   76 |     cout <<(long long)fractionalKnapsack(W, arr, n);
      |                                             ^~~
Language: C++

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


int main()
{
    int N, W;
    cin >> N >> W;
    vector<long> w(N+1), v(N+1);
    for( int i = 1; i <= N; ++i ) cin >> w[i] >> v[i];
    
    // dp[i][j]: i 番目までの品物から価値の和が j 以下になるように
    //           選んだときの重さの最小値
    long dp[101][100001] = {1e+11};
    for( int j = 0; j <= 100000; ++j ) dp[j][j] = 0;
    for( int i = 1; i <= N; ++i ){
        for( int j = 0; j <= 100000; ++j ){
            if( j >= v[i] ) dp[i][j] = min( dp[i-1][j], dp[i-1][j-v[i]] + w[i] );
            else            dp[i][j] = dp[i-1][j];
        }
    }
    for( int j = 0; j <= 100000; ++j ){
        if( dp[N][j] <= W ){
            cout << dp[N][j] << endl;
            break;
        }
    }

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:29: error: narrowing conversion of '1.0e+11' from 'double' to 'long int' [-Wnarrowing]
   16 |     long dp[101][100001] = {1e+11};
      |                             ^~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
long long  w[1001],v[1001],f[107][100007];

#define ll long long
#define F(i,a,b) for(long long i=a;i<=b;i++)

int main()
{
ll n,W,s=0;

cin>>n>>W;
F(i,1,n){   cin>>w[i]>>v[i]; s+=v[i]; }
F(i,1,s)f[0][i]=30000000000;
F(i,1,n)F(j,1,s)
{
   f[i][j]=f[i-1][j];
   if(j>=v[i])f[i][j]=min(f[i][j],f[i-1][j-v[i]]+w[i]);
}
for(i=s;i>=1;i--)
if(f[n][i]<=W){ cout<<i;  break;}
}


Compiler output:
a.cc: In function 'int main()':
a.cc:20:5: error: 'i' was not declared in this scope
   20 | for(i=s;i>=1;i--)
      |     ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define F(i,a,b) for(long long i=a;i<=b;i++)
ll n,W,s=0;
ll w[1001],v[1001],f[107][100007];

int main()
{

cin>>n>>W;
F(i,1,n){   cin>>w[i]>>v[i]; s+=v[i]; }
F(i,1,s)f[0][i]=30000000000;
F(i,1,n)F(j,1,s)
{
   f[i][j]=f[i-1][j];
   if(j>=v[i])f[i][j]=min(f[i][j],f[i-1][j-v[i]]+w[i]);
}
for(i=s;i>=1;i--)
if(f[n][i]<=W){ cout<<i;  break;}
}


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

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define F(i,a,b) for(long long i=a;i<=b;i++)
ll n,W,s=0;
ll w[1001],v[1001],f[107][100007];

main()
{

cin>>n>>W;
F(i,1,n){   cin>>w[i]>>v[i]; s+=v[i]; }
F(i,1,s)f[0][i]=30000000000;
F(i,1,n)F(j,1,s)
{
   f[i][j]=f[i-1][j];
   if(j>=v[i])f[i][j]=min(f[i][j],f[i-1][j-v[i]]+w[i]);
}
for(i=s;i>=1;i--)
if(f[n][i]<=W){ cout<<i;  break;}
}


Compiler output:
a.cc:8:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    8 | main()
      | ^~~~
a.cc: In function 'int main()':
a.cc:19:5: error: 'i' was not declared in this scope
   19 | for(i=s;i>=1;i--)
      |     ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
long long w[1001],v[1001],f[107][100007];
ll n,W,s=0;
#define ll long long 
#define F(i,a,b) for(long long i=a;i<=b;i++)
int main()
{

cin>>n>>W;
F(i,1,n){   cin>>w[i]>>v[i]; s+=v[i]; }
F(i,1,s)f[0][i]=30000000000;
F(i,1,n)F(j,1,s)
{
   f[i][j]=f[i-1][j];
   if(j>=v[i])f[i][j]=min(f[i][j],f[i-1][j-v[i]]+w[i]);
}
for(i=s;i>=1;i--)
if(f[n][i]<=W){ cout<<i;  break;}
}

Compiler output:
a.cc:4:1: error: 'll' does not name a type
    4 | ll n,W,s=0;
      | ^~
a.cc:4:1: note: the macro 'll' had not yet been defined
a.cc:5:9: note: it was later defined here
    5 | #define ll long long
      |         ^~
a.cc: In function 'int main()':
a.cc:10:6: error: 'n' was not declared in this scope; did you mean 'yn'?
   10 | cin>>n>>W;
      |      ^
      |      yn
a.cc:10:9: error: 'W' was not declared in this scope
   10 | cin>>n>>W;
      |         ^
a.cc:11:30: error: 's' was not declared in this scope
   11 | F(i,1,n){   cin>>w[i]>>v[i]; s+=v[i]; }
      |                              ^
a.cc:12:7: error: 's' was not declared in this scope
   12 | F(i,1,s)f[0][i]=30000000000;
      |       ^
a.cc:6:39: note: in definition of macro 'F'
    6 | #define F(i,a,b) for(long long i=a;i<=b;i++)
      |                                       ^
a.cc:13:15: error: 's' was not declared in this scope
   13 | F(i,1,n)F(j,1,s)
      |               ^
a.cc:6:39: note: in definition of macro 'F'
    6 | #define F(i,a,b) for(long long i=a;i<=b;i++)
      |                                       ^
a.cc:18:5: error: 'i' was not declared in this scope
   18 | for(i=s;i>=1;i--)
      |     ^
a.cc:18:7: error: 's' was not declared in this scope
   18 | for(i=s;i>=1;i--)
      |       ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define INF 100000000000
long long int dp[100005][105];
pair< long long int,long long int >arr 
void debug(long long int a,long long int b)
{
	printf("a-%lld\nb-%lld\n",a,b);
}
long long int solve(long long int ch,long long int idx)
{
	if(idx>n)
		return 0;
	if(dp[ch][idx]!=-1)
		return dp[ch][idx];
	long long int ans1,ans2=0,ans;
	ans1=solve(ch,idx+1);
	if(ch>=arr[idx])
	{
        //printf("ok\n");
		ans2=val[idx]+solve(ch-arr[idx],idx+1);
	}	
	ans=max(ans1,ans2);
	dp[ch][idx]=ans;
	//debug(ans,idx);
    return dp[ch][idx]; 
}
int main()
{
   long long int i,j,k,ans=0,w,a,b;
   scanf("%lld%lld",&n,&w);
   for(i=0;i<=w;i++)
   {
   	//visited[i]=false;
   	for(j=1;j<=n;j++)
   		dp[i][j]=-1;
   }	
   for(i=1;i<=n;i++)
   {
   	scanf("%lld%lld",&a,&b);
    arr.push_back(make_pair(a,b));
   } 
   ans=solve(w,1);
      /*for(i=0;i<=w;i++)
   	for(j=1;j<=n;j++)
   		printf("%lld\n",dp[i][j]);*/
   printf("%lld\n",ans);
}


Compiler output:
a.cc:6:1: error: expected initializer before 'void'
    6 | void debug(long long int a,long long int b)
      | ^~~~
a.cc: In function 'long long int solve(long long int, long long int)':
a.cc:12:16: error: 'n' was not declared in this scope; did you mean 'yn'?
   12 |         if(idx>n)
      |                ^
      |                yn
a.cc:18:16: error: 'arr' was not declared in this scope
   18 |         if(ch>=arr[idx])
      |                ^~~
a.cc:21:22: error: 'val' was not declared in this scope
   21 |                 ans2=val[idx]+solve(ch-arr[idx],idx+1);
      |                      ^~~
a.cc: In function 'int main()':
a.cc:31:22: error: 'n' was not declared in this scope
   31 |    scanf("%lld%lld",&n,&w);
      |                      ^
a.cc:41:5: error: 'arr' was not declared in this scope
   41 |     arr.push_back(make_pair(a,b));
      |     ^~~
Language: C++

#include<bits/stdc++.h>
#include <string> 
using namespace std;
#include <string> 
#define fast ios_base::sync_with_stdio(false);	cin.tie(NULL);
typedef long long ll;
#define MAX 1000000000
ll abs(ll a, ll b){
	return (a<b?b-a:a-b);
}

int main()
{
	fast;
	ll n,i,a[105],b[105],j,k,w;
	cin>>n>>k;
	for(i=0;i<n;i++){
		cin>>b[i]>>a[i];

	}
	ll dp[k+1];
	for(i=1;i<=n;i++){
		for(w=k;w>=b[i];w--)
		{
			dp[w]=max(a[i-1]+dp[w-b[i-1]],dp[w]);
		}
	}
	cout<<dp[n][k];

	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:28:20: error: invalid types 'll {aka long long int}[ll {aka long long int}]' for array subscript
   28 |         cout<<dp[n][k];
      |                    ^
Language: Java

import java.util.*;

public class Main
{
  static long oo = (long)1e18;
  public static void main(String[] args)
  {
	Scanner in = new Scanner(System.in);
    int n = in.nextInt();
    int w = in.nextInt();
    long[] W = new long[n];
    int[] V = new int[n];
    for (int i = 0; i < n; i++)
    {
      W[i] = in.nextLong();
      V[i] = in.nextInt();
    }
    
    long[] min = new int[1000*100+1];
    Arrays.fill(min, oo);
    for (int i = 0; i < n; i++)
      for (int v = 1000*100; v >= 0; v--)
        if (v+V[i] <= 1000*100)
          min[v+V[i]] = Math.min(min[v+V[i]], min[v]+W[i]);
    
    int best = 1000*100;
    for ( ; best >= 0; best--)
      if (min[best] <= w)
        break;
    System.out.println(best);        
    in.close();
  }
}

Compiler output:
Main.java:19: error: incompatible types: int[] cannot be converted to long[]
    long[] min = new int[1000*100+1];
                 ^
1 error
Language: C++

#include <bits/stdc++.h>

using namespace std;

const int oo = 987654321;
const int N = 110;
const int MAX = 1010;

int n, tot, cw, cv;
vector<int> w, v;

long long int memo[N][N*MAX];
long long int dp(int at, int sum) {
  	if(sum < 0) return oo;
	if(at == n) return 0;
  	if(memo[at][max] != -1) return memo[at][max];
  	long long int choose = w[at] + dp(at + 1, sum - v[at]);
  	long long int skip = dp(at + 1, sum);
  	return memo[at][max] = min(choose, skip);
}

int main() {
	cin >> n >> tot;
  	for(int i = 0; i < n; ++i) {
		cin >> cw >> cv;
      	w.push_back(cw);
      	v.push_back(cv);
      	fill(memo[i], memo[i] + N * MAX, -1);
    }
  	int ans = 0;
  	for(int i = n * 1000; i >= 0; --i) {
    	long long int minWeight = dp(0, i);
      	if(minWeight <= tot) {
          	ans = i;
          	break;
        }
    }
  	cout << ans << endl;
	return 0; 
}

Compiler output:
a.cc: In function 'long long int dp(int, int)':
a.cc:16:20: error: invalid types 'long long int [111100][<unresolved overloaded function type>]' for array subscript
   16 |         if(memo[at][max] != -1) return memo[at][max];
      |                    ^
a.cc:16:48: error: invalid types 'long long int [111100][<unresolved overloaded function type>]' for array subscript
   16 |         if(memo[at][max] != -1) return memo[at][max];
      |                                                ^
a.cc:19:24: error: invalid types 'long long int [111100][<unresolved overloaded function type>]' for array subscript
   19 |         return memo[at][max] = min(choose, skip);
      |                        ^
Language: C++

/*
  Vivek Rathi
  CSE 2nd Year
  MNNIT
*/
#include<bits/stdc++.h>
using namespace std;
#define M 1000000007
#define ll long long int
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define debug1(x) cout<<#x<<" "<<x<<endl;
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define present(c,x) ((c).find(x) != (c).end())
#define null NULL
#define mp make_pair
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define inf 1e17
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
ll dp[101][1000000001],n,W;
pair<ll,ll> p[101];
ll solve(ll i,ll w)
{
	if(i==n)
	{
		return 0;
	}
	if(dp[i][w]!=-1) return dp[i][w];
	ll ans1=0,ans2=0;
	ans1 = solve(i+1,w);
	if(w+p[i].fi<=W)ans2 = p[i].se+solve(i+1,w+p[i].fi);
	return dp[i][w]=max(ans2,ans1);
}
int main()
{
	boost
	cin>>n>>W;
	memset(dp,-1,sizeof(dp));
	for(ll i=0;i<n;i++)
	{
		cin>>p[i].fi>>p[i].se;
	}
	for(ll i=0;i<=W;i++)
	{
		if(i+p[n-1].fi>W)dp[n-1][i]=0;
		else dp[n-1][i]=p[n-1].se;
	}
	for(ll i=n-2;i>=0;i--)
	{
		for(ll j=0;j<=W;j++)
		{
			if(p[i].fi+j<=W)dp[i][j]=max(dp[i+1][j],p[i].se+dp[i+1][j+p[i].fi]);
			else dp[i][j]=dp[i+1][j];
		}
	}
	ll maxi=0;
	for(ll i=0;i<=W;i++)
	{
		maxi=max(dp[0][i],maxi);
	}
	cout<<maxi<<endl;
	return 0;
}

Compiler output:
/tmp/cc1Htmde.o: in function `solve(long long, long long)':
a.cc:(.text+0x14): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/cc1Htmde.o
a.cc:(.text+0xb6): relocation truncated to fit: R_X86_64_PC32 against symbol `p' defined in .bss section in /tmp/cc1Htmde.o
a.cc:(.text+0xc8): relocation truncated to fit: R_X86_64_PC32 against symbol `W' defined in .bss section in /tmp/cc1Htmde.o
a.cc:(.text+0xdf): relocation truncated to fit: R_X86_64_PC32 against symbol `p' defined in .bss section in /tmp/cc1Htmde.o
a.cc:(.text+0xf5): relocation truncated to fit: R_X86_64_PC32 against symbol `p' defined in .bss section in /tmp/cc1Htmde.o
/tmp/cc1Htmde.o: in function `main':
a.cc:(.text+0x1ad): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/cc1Htmde.o
a.cc:(.text+0x1c9): relocation truncated to fit: R_X86_64_PC32 against symbol `W' defined in .bss section in /tmp/cc1Htmde.o
a.cc:(.text+0x211): relocation truncated to fit: R_X86_64_PC32 against symbol `p' defined in .bss section in /tmp/cc1Htmde.o
a.cc:(.text+0x23b): relocation truncated to fit: R_X86_64_PC32 against symbol `p' defined in .bss section in /tmp/cc1Htmde.o
a.cc:(.text+0x259): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/cc1Htmde.o
a.cc:(.text+0x273): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
Language: Java

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
import java.util.*;
import java.io.*;
/**
 *
 * @author arvin
 */
public class Main {
    
    static int val[],weight[],dp[][];
    
    static int rec(int x,int w)
    {
        if(w<=0)
            return 0;
        if(x<0)
            return 0;
        int a1=0,a2;
        if(weight[x]<=w)
        {
            if(x>0 && dp[x-1][w-weight[x]]!=0)
                a1=val[x]+dp[x-1][w-weight[x]];
            else
                a1=val[x]+rec(x-1,w-weight[x]);
        }
        if(x>0 && dp[x-1][w]!=0)
            a2=dp[x-1][w];
        else
            a2=rec(x-1,w);
        dp[x][w]=Math.max(a1,a2);
        return dp[x][w];
    }
    public static void main(String args[]) throws Exception
    {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int w=sc.nextInt();
        val=new int[n];
        weight=new int[n];
        for(int i=0;i<n;i++)
        {
          val[i]=sc.nextInt();
          weight[i]=sc.nextInt();
        }
        dp=new int[n+1][w+1];
        

        int ans=rec(n-1,w);
        
        System.out.println(ans);
        
        br.close();
    }
}


Compiler output:
Main.java:56: error: cannot find symbol
        br.close();
        ^
  symbol:   variable br
  location: class Main
1 error
Language: Java

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int W = sc.nextInt();
        int[] w = new int[N];
        int[] v = new int[N];

        for(int i=0;i<N;i++){
            w[N-i-1] = sc.nextInt();
            v[N-i-1] = sc.nextInt();
        }

        System.out.println(func(w,v,N, W ,0));
    }

    static Map<Integer, Map<Integer,Long>>  cache = new HashMap<>();
    static private long func(int[] w, int[] v,int N , int W , int idx){
        if(idx == N ) return 0;

        if(cache.containsKey(W)){
            Map<Integer,Long> map = cache.get(W);
            if(map.containsKey(idx)){
                return map.get(new Integer(idx));
            }
        }


        if(W-w[idx] < 0){
            long result = func(w,v,N, W, idx +1  );
            if(!cache.containsKey(W)){
                Map<Integer,Long> map = new HashMap<>();
                map.put(idx,result);
                cache.put(W,map);
            }else{
                Map<Integer,Long> map = cache.get(W);
                map.put(idx,result);
                cache.put(W,map);
            }
        }

        long result =  Math.max(
                func(w,v,N, W- w[idx], idx +1  )  + v[idx] ,
                func(w,v,N, W, idx +1  ));

        if(!cache.containsKey(W)){
            Map<Integer,Long> map = new HashMap<>();
            map.put(idx,result);
            cache.put(W,map);
        }else{
            Map<Integer,Long> map = cache.get(W);
            map.put(idx,result);
            cache.put(W,map);
        }

        return result;

    }


Compiler output:
Main.java:63: error: reached end of file while parsing
    }
     ^
1 error
Language: C++

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

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

    vector<vector<long>> dp(n+1, vector<long>(w+1, 0));

    for(long i=0; i<n; i++)
    {
        for(long j=1; j<=w; j++)
        {
            if(weight[i] <= j)
            {
                dp[i+1][j] = max(dp[i][j], dp[i][j-weight[i]] + value[i]);
            }
            else
            {
                dp[i+1][j] = dp[i][j];
            }
        }
    }

    cout << dp[n][w];
}

Compiler output:
a.cc:1:1: error: 'include' does not name a type
    1 | include <bits/stdc++.h>
      | ^~~~~~~
a.cc: In function 'int main()':
a.cc:7:5: error: 'cin' was not declared in this scope
    7 |     cin >> n >> w;
      |     ^~~
a.cc:8:5: error: 'vector' was not declared in this scope
    8 |     vector<long> weight(n), value(n);
      |     ^~~~~~
a.cc:8:12: error: expected primary-expression before 'long'
    8 |     vector<long> weight(n), value(n);
      |            ^~~~
a.cc:11:16: error: 'weight' was not declared in this scope
   11 |         cin >> weight[i] >> value[i];
      |                ^~~~~~
a.cc:11:29: error: 'value' was not declared in this scope
   11 |         cin >> weight[i] >> value[i];
      |                             ^~~~~
a.cc:14:19: error: expected primary-expression before 'long'
   14 |     vector<vector<long>> dp(n+1, vector<long>(w+1, 0));
      |                   ^~~~
a.cc:20:16: error: 'weight' was not declared in this scope
   20 |             if(weight[i] <= j)
      |                ^~~~~~
a.cc:22:17: error: 'dp' was not declared in this scope
   22 |                 dp[i+1][j] = max(dp[i][j], dp[i][j-weight[i]] + value[i]);
      |                 ^~
a.cc:22:65: error: 'value' was not declared in this scope
   22 |                 dp[i+1][j] = max(dp[i][j], dp[i][j-weight[i]] + value[i]);
      |                                                                 ^~~~~
a.cc:22:30: error: 'max' was not declared in this scope
   22 |                 dp[i+1][j] = max(dp[i][j], dp[i][j-weight[i]] + value[i]);
      |                              ^~~
a.cc:26:17: error: 'dp' was not declared in this scope
   26 |                 dp[i+1][j] = dp[i][j];
      |                 ^~
a.cc:31:5: error: 'cout' was not declared in this scope
   31 |     cout << dp[n][w];
      |     ^~~~
a.cc:31:13: error: 'dp' was not declared in this scope
   31 |     cout << dp[n][w];
      |             ^~
Language: C++

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

int main(){
  int N, W;
  cin >> N >> W;
  W++;
  
  vector<int> v(N), w(N);
  int mv = 0;
  
  for(int i=0; i<N; i++){
    cin >> w[i] >> v[i];
    mv += v[i];
  }
  mv++;
  
  vector<long> dp(mv, 1000000000 * 100);
  for(int s=0; s<=v[0]; s++){
    dp[s] = (long)w[0];
  }
  
  for(int i=0; i<N; i++){
    for(int s=mv-1; s>=v[i]; s--){
      dp[s] = min(dp[s], dp[s-v[i]] + w[i]);
    }
    for(int s=v[i]-1; s>=0; s--){
      dp[s] = min(dp[s], w[i]);
    }
  }
  
  int ans = mv;
  while(dp[--ans] >= W) ;
  cout << ans << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:34: warning: integer overflow in expression of type 'int' results in '1215752192' [-Woverflow]
   18 |   vector<long> dp(mv, 1000000000 * 100);
      |                       ~~~~~~~~~~~^~~~~
a.cc:28:18: error: no matching function for call to 'min(__gnu_cxx::__alloc_traits<std::allocator<long int>, long int>::value_type&, __gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&)'
   28 |       dp[s] = min(dp[s], w[i]);
      |               ~~~^~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:28:18: note:   deduced conflicting types for parameter 'const _Tp' ('long int' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'})
   28 |       dp[s] = min(dp[s], w[i]);
      |               ~~~^~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:28:18: note:   mismatched types 'std::initializer_list<_Tp>' and 'long int'
   28 |       dp[s] = min(dp[s], w[i]);
      |               ~~~^~~~~~~~~~~~~
Language: C++

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

int main(){
  int N, W;
  cin >> N >> W;
  W++;
  
  vector<int> v(N), w(N);
  vector<int> dp(W, 0);
  
  for(int i=0; i<N; i++){
    cin >> w[i] >> v[i];
  }
  
  for(int i=0; i<N; i++){
    for(int s=W-1, s>=0; s--){
      if(s-w[i] < 0){
        continue;
      }
      dp[s] = max(dp[s], dp[s-w[i]] + v[i]);
    }
  }
  
  cout << dp[W-1] << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:21: error: expected ';' before '>=' token
   17 |     for(int s=W-1, s>=0; s--){
      |                     ^~
      |                     ;
a.cc:17:21: error: expected primary-expression before '>=' token
   17 |     for(int s=W-1, s>=0; s--){
      |                     ^~
Language: Java

// 作者：杨成瑞先生
import java.io.*;
import java.util.*;

public class cf {

	static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner() {
            try {
                br = new BufferedReader(new InputStreamReader(System.in));
                st = new StringTokenizer(br.readLine());
            } catch (Exception e){e.printStackTrace();}
        }

        public String next() {
            if (st.hasMoreTokens()) return st.nextToken();
            try {st = new StringTokenizer(br.readLine());}
            catch (Exception e) {e.printStackTrace();}
            return st.nextToken();
        }

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

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

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

        public String nextLine() {
            String line = "";
            if(st.hasMoreTokens()) line = st.nextToken();
            else try {return br.readLine();}catch(IOException e){e.printStackTrace();}
            while(st.hasMoreTokens()) line += " "+st.nextToken();
            return line;
        }
    }

    static int mod = 1000000007;
    static long oo = Long.MAX_VALUE;

	public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter pw = new PrintWriter(System.out); 
        
        int n = sc.nextInt();
        int W = sc.nextInt();

        int[] w = new int[n];
        int[] v = new int[n];

        int maxValue = 0;
        for(int i=0;i<n;i++) {
            w[i] = sc.nextInt();
            v[i] = sc.nextInt();
            maxValue += v[i];
        }

        long[] dp = new long[maxValue+1];
        Arrays.fill(dp, oo);

        for(int i=0;i<n;i++) {
            for(int j=maxValue;j>=v[i];j--) {
                if(dp[j-v[i]] != oo) {
                    dp[j] = Math.min(dp[j], dp[j-v[i]] + w[i]);
                }
            }
        }

        int ans = 0;
        for(int i=maxValue;i>=0;i--) {
            if(dp[i] <= W) {
                ans = i;
                break;
            }
        }

        pw.println(ans);
        pw.close();
    }

}

	/*	long[] dp=new long[x+1];
		for (int i=1;i<=x;++i) dp[i]=Long.MAX_VALUE;
		for (int i=0;i<n;++i)
			for (int j=x;j>=v[i];--j) if (dp[j-v[i]]!=Long.MAX_VALUE)
				dp[j]=Math.min(dp[j],dp[j-v[i]]+w[i]);
		int res=0;
		for (int i=x;i>=0;--i) if (dp[i]<=W) {
			res=i;
			break;
		}
		System.out.println(res);
	}*/

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

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MM 1000000000
#define MOD MM+7
#define MAX 10000
#define MAP 110
#define Pair pair<int,int>

int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, -1, 0, 1};
ll INF = 1e18;
int main(){
    ll dp[110][100100] = {0};
    ll N,W; cin >> N >> W;
    ll w[105], v[105];
    for(ll i = 1; i <= N; i++) cin >> w[i] >> v[i];
    for(ll i = 1; i <= 1e5; i++) cin >> dp[0][i] = INF;

    for(ll i = 1; i <= N; i++){
        for(ll j = 0; j <= 100000; j++){
            dp[i][j] = dp[i-1][j];
            if(j - v[i] >= 0){
                dp[i][j] = min(dp[i][j], w[i]+dp[i-1][j-v[i]]);
            }
        }
    }
    ll ans = 0;
    for(ll i = 1e5; i >= 0; i--){
        if(dp[N][i] <= W){
            ans = i;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:18:52: error: no match for 'operator=' (operand types are 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} and 'll' {aka 'long long int'})
   18 |     for(ll i = 1; i <= 1e5; i++) cin >> dp[0][i] = INF;
      |                                                    ^~~
In file included from /usr/include/c++/14/sstream:40,
                 from /usr/include/c++/14/complex:45,
                 from /usr/include/c++/14/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127,
                 from a.cc:1:
/usr/include/c++/14/istream:718:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator=(std::basic_istream<_CharT, _Traits>&&) [with _CharT = char; _Traits = std::char_traits<char>]'
  718 |       operator=(basic_istream&& __rhs)
      |       ^~~~~~~~
/usr/include/c++/14/istream:718:33: note:   no known conversion for argument 1 from 'll' {aka 'long long int'} to 'std::basic_istream<char>&&'
  718 |       operator=(basic_istream&& __rhs)
      |                 ~~~~~~~~~~~~~~~~^~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MM 1000000000
#define MOD MM+7
#define MAX 10000
#define MAP 110
#define Pair pair<int,int>

int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, -1, 0, 1};
ll INF = 1e18;
int main(){
    ll dp[110][100100] = {0};
    ll N,W; cin >> N >> W;
    ll w[105], v[105];
    for(ll i = 1; i <= N; i++) cin >> w[i] >> v[i];
    for(ll i = 1; i <= 1e5; i++) cin >> d[0][i] = INF;

    for(ll i = 1; i <= N; i++){
        for(ll j = 0; j <= 100000; j++){
            dp[i][j] = dp[i-1][j];
            if(j - v[i] >= 0){
                dp[i][j] = main(dp[i][j], w[i]+dp[i-1][j-v[i]]);
            }
        }
    }
    ll ans = 0;
    for(ll i = 1e5; i >= 0; i--){
        if(dp[N][i] <= W){
            ans = i;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:18:41: error: 'd' was not declared in this scope
   18 |     for(ll i = 1; i <= 1e5; i++) cin >> d[0][i] = INF;
      |                                         ^
a.cc:24:32: error: too many arguments to function 'int main()'
   24 |                 dp[i][j] = main(dp[i][j], w[i]+dp[i-1][j-v[i]]);
      |                            ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:13:5: note: declared here
   13 | int main(){
      |     ^~~~
Language: C++

#include <iostream>
#include <cstdlib>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL<<60;

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

int N;
long long W, weight[MAX_N], value[MAX_N];
long long dp[MAX_N][MAX_V];

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

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

	dp[0][0] = 0;

	for(int i=0; i<N; i++){
		for(int sum_v; sum_v<MAX_V; sum_v++){
			if(sum_v-value[i]>=0) chmin(dp[i+1][sum_v], dp[i][sum_v-value[i]]+weight);
			chmin(dp[i+1][sum_v], dp[i][sum_v]);
		}
	}

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

Compiler output:
a.cc: In function 'int main()':
a.cc:25:52: error: no matching function for call to 'chmin(long long int&, long long int*)'
   25 |                         if(sum_v-value[i]>=0) chmin(dp[i+1][sum_v], dp[i][sum_v-value[i]]+weight);
      |                                               ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:5:31: note: candidate: 'template<class T> bool chmin(T&, T)'
    5 | template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
      |                               ^~~~~
a.cc:5:31: note:   template argument deduction/substitution failed:
a.cc:25:52: note:   deduced conflicting types for parameter 'T' ('long long int' and 'long long int*')
   25 |                         if(sum_v-value[i]>=0) chmin(dp[i+1][sum_v], dp[i][sum_v-value[i]]+weight);
      |                                               ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

#include <iostream>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <numeric>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
using namespace std;

#define REP(i,s,e) for(int i=(s);i<(e);i++)
#define rep(i,n) REP(i,0,n)

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

const long long INFLL = 1LL << 60;
const int INF = 1 << 30;

typedef long long ll;
typedef unsigned long long ull;

int N, W;
int w[100];
int v[100];
int memo[100][100001];

// n  : n-1番目の品物まで見て，今n番目の品物を見ている
// cv : 現在の目標価値
// 0 <= n <= N-1
// solve(n, cv) : n番目までの品物を選んだときに，価値cvを達成できる場合の重さの最小和
int solve(int n, int cv) {
  if (n < 0) {
    if (cv <= 0) return 0;
    else return INF;
  }
  if (memo[n][cv] != INF) return memo[n][cv];

  return memo[n][cv] = min(solve(n-1, cv), solve(n-1, cv-v[n]) + w[n]);
}

int main(void) {
  cin >> N >> W;
  rep(i, N) cin >> w[i] >> v[i];
  rep(i, 100) rep(j, 100001) memo[i][j] = INF;
  solve(N-1, 100000);
  for (int v = 100000; v >= 0; --v) {
    if (memo[N-1, v] <= W) {
      cout << v << endl;
      return 0;
    }
  }
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:55:22: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   55 |     if (memo[N-1, v] <= W) {
      |         ~~~~~~~~~~~~~^~~~
Language: Java

import java.util.Scanner;

public class E {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    long W = sc.nextInt();
    long[] w = new long[N];
    int[] v = new int[N];
    int vsum = 0;
    for (int i = 0; i < N; i++) {
      w[i] = sc.nextInt();
      v[i] = sc.nextInt();
      vsum += v[i];
    }
    long[][] dp = new long[110][110000];
    for (int i = 0; i < 110; i++) {
      for (int j = 0; j < 110000; j++) {
        dp[i][j] = 11000000000000000L;
      }
    }

    dp[0][0] = 0;
    for (int i = 0; i < N; i++) {
      for (int j = 0; j <= vsum; j++) {
        dp[i + 1][j] = Math.min(dp[i + 1][j], dp[i][j]);
        dp[i + 1][j + v[i]] = Math.min(dp[i + 1][j + v[i]], dp[i][j] + w[i]);
      }
    }

    long ans = 0;
    for (int i = vsum; i >= 0; i--) {
      if (dp[N][i] <= W) {
        ans = i;
        break;
      }
    }
    System.out.println(ans);
  }
}

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

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

using namespace std;

long long solve(pair<int, long long> key,  vector<long long>& w, 	vector<long long>& v, unordered_map<pair<int, long long>, long long>& cache) {
	if (key.first < 0 || key.second <= 0) {
		return 0;
	}
	if (cache.count(key)) {
		return cache[key];
	}
	long long ans = solve({key.first - 1, key.second}, w, v, cache);
	if (key.second >= w[key.first]) {
		ans = max(ans, solve({key.first - 1, key.second - w[key.first]}, w, v, cache) + v[key.first]);
	}
	cache[key] = ans;
	return ans;
}
													

int main() {
	int n, W;
	cin >> n >> W;
	vector<long long> w(n), v(n);
	map<long long, long long> dp;
	for (int i = 0; i < n; ++i) {
		cin >> w[i] >> v[i];
	}
	unordered_map<pair<int, long long>, long long> cache;
  cout << solve({n - 1, W}, w, v, cache) << endl;
}


Compiler output:
a.cc:9:95: error: 'unordered_map' has not been declared
    9 | long long solve(pair<int, long long> key,  vector<long long>& w,        vector<long long>& v, unordered_map<pair<int, long long>, long long>& cache) {
      |                                                                                               ^~~~~~~~~~~~~
a.cc:9:108: error: expected ',' or '...' before '<' token
    9 | long long solve(pair<int, long long> key,  vector<long long>& w,        vector<long long>& v, unordered_map<pair<int, long long>, long long>& cache) {
      |                                                                                                            ^
a.cc: In function 'long long int solve(std::pair<int, long long int>, std::vector<long long int>&, std::vector<long long int>&, int)':
a.cc:13:13: error: 'cache' was not declared in this scope
   13 |         if (cache.count(key)) {
      |             ^~~~~
a.cc:16:66: error: 'cache' was not declared in this scope
   16 |         long long ans = solve({key.first - 1, key.second}, w, v, cache);
      |                                                                  ^~~~~
a.cc: In function 'int main()':
a.cc:33:9: error: 'unordered_map' was not declared in this scope
   33 |         unordered_map<pair<int, long long>, long long> cache;
      |         ^~~~~~~~~~~~~
a.cc:6:1: note: 'std::unordered_map' is defined in header '<unordered_map>'; this is probably fixable by adding '#include <unordered_map>'
    5 | #include <map>
  +++ |+#include <unordered_map>
    6 | 
a.cc:33:43: error: expected primary-expression before ',' token
   33 |         unordered_map<pair<int, long long>, long long> cache;
      |                                           ^
a.cc:33:45: error: expected primary-expression before 'long'
   33 |         unordered_map<pair<int, long long>, long long> cache;
      |                                             ^~~~
a.cc:34:35: error: 'cache' was not declared in this scope
   34 |   cout << solve({n - 1, W}, w, v, cache) << endl;
      |                                   ^~~~~
Language: Java


	public static void main(String[] args) {
		new Main().solveA();
		// new Main().solveB();
		// new Main().solveC();
		// new Main().solveD();
	}

	int numN = 0;
	int totalWeight = 0;
	int[][] wAndV;
	int[][] iAndWeight;

	private int getValue(int currentI, int nowWeight) {

		if (iAndWeight[currentI][nowWeight] != Integer.MIN_VALUE) {
			return iAndWeight[currentI][nowWeight];
		}
		int res = 0;
		if (currentI == numN) {
			res = 0;
		} else if (nowWeight < wAndV[currentI][0]) {
			res = getValue(currentI + 1, nowWeight);
		} else {
			int value1 = getValue(currentI + 1, nowWeight);
			int value2 = getValue(currentI + 1, nowWeight - wAndV[currentI][0]) + wAndV[currentI][1];
			res = Math.max(value1, value2);
		}
		iAndWeight[currentI][nowWeight] = res;
		return res;

	}

	private void solveA() {
		Scanner scanner = null;
		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();
			totalWeight = scanner.nextInt();

			wAndV = new int[numN][2];
			iAndWeight = new int[numN + 1][totalWeight + 1];
			for (int i = 0; i < numN; i++) {
				wAndV[i][0] = scanner.nextInt();
				wAndV[i][1] = scanner.nextInt();
			}

			for (int i = 0; i < iAndWeight.length; i++) {
				Arrays.fill(iAndWeight[i], Integer.MIN_VALUE);
			}
			int res = getValue(0, totalWeight);
			System.out.println(res);

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

}

Compiler output:
Main.java:2: error: unnamed classes are a preview feature and are disabled by default.
	public static void main(String[] args) {
	              ^
  (use --enable-preview to enable unnamed classes)
Main.java:61: error: class, interface, enum, or record expected
}
^
2 errors
Language: C++

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define modulo 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF = 1LL<<60

// ナップサック

int N, W;
int w[101], v[101];
ll dp[101][100000]; // dp[i][j] : i番目までの商品で価値j持って帰る際の最小の重さ

void input() {
	scanf("%d%d", &N, &W);
	for (int i = 1; i <= N; i++) scanf("%d %d", &w[i], &v[i]);
	for (int j = 0; j <= 1000 * N; j++) dp[0][j] = LLINF;
}

void solve() {
	dp[0][0] = 0;
	for (int i = 1; i <= N; i++) {
		for (int j = 0; j <= 1000 * N; j++) {
			if (j >= v[i]) dp[i][j] = min(dp[i - 1][j], dp[i - 1][j - v[i]] + w[i]);
			else dp[i][j] = dp[i - 1][j];
		}
	}

	int ans = 0;
	for (int j = 0; j <= 1000 * N; j++) {
		if (dp[N][j] <= W) {
			// 持って帰れる
			ans = j;
		}
	}
	printf("%d\n", ans);
}

int main() {
	input();
	solve();

	return 0;
}

Compiler output:
a.cc: In function 'void input()':
a.cc:18:15: error: expected primary-expression before '=' token
   18 | #define LLINF = 1LL<<60
      |               ^
a.cc:29:56: note: in expansion of macro 'LLINF'
   29 |         for (int j = 0; j <= 1000 * N; j++) dp[0][j] = LLINF;
      |                                                        ^~~~~
Language: C++

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

typedef long long ll;

const ll INF = 200000000011;

ll dp[100][100005];
int V[102];
ll W[102];

ll solve(int i, int value) {
	// Min weight to get value v from first i items.
  	
  	if (dp[i][value] != -1) {
    	return dp[i][value];
    }
  
  	if (i < 0 && value > 0) {
    	// Not Possible. return INF
      	return INF;
    }
  	if (i < 0 && value == 0) {
    	return 0;
    }
  
  	ll ans = solve(i-1, value);
  
  	if (value - V[i] >= 0) {
    	ans = min(ans, W[i] + solve(i-1, value-V[I]));
    }
                  
    dp[i][value] = ans;
  
}

int main() {
	int n,w;
  	cin>>n>>w;
  	for (int i=0; i<n; i++) {
    	cin>>W[i];
      	cin>>V[i];
    }
  	memset(dp, -1, sizeof(dp));
   
  	ll ans = 0;
  	for (int i=0; i<n; i++) {
    	for (int v=0; v<=100000; v++) {
        	ll tmp = solve(i, v);
          	if (tmp < w && ans < v) {
            	ans = v;
            }
        }
    }
  
  	cout<<v<<endl;
}

Compiler output:
a.cc: In function 'll solve(int, int)':
a.cc:32:50: error: 'I' was not declared in this scope
   32 |         ans = min(ans, W[i] + solve(i-1, value-V[I]));
      |                                                  ^
a.cc: In function 'int main()':
a.cc:58:15: error: 'v' was not declared in this scope
   58 |         cout<<v<<endl;
      |               ^
a.cc: In function 'll solve(int, int)':
a.cc:35:18: warning: control reaches end of non-void function [-Wreturn-type]
   35 |     dp[i][value] = ans;
      |     ~~~~~~~~~~~~~^~~~~
Language: C++

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

typedef long long ll;

const ll INF = 200000000011;

ll dp[100][100005];
int V[102];
ll W[102];

ll solve(int i, int value) {
	// Min weight to get value v from first i items.
  	
  	if (dp[i][value] != -1) {
    	return dp[i][value];
    }
  
  	if (i < 0 && value > 0) {
    	// Not Possible. return INF
      	return INF;
    }
  	if (i < 0 && value == 0) {
    	return 0;
    }
  
  	ll ans .= solve(i-1, value);
  
  	if (value - V[i] >= 0) {
    	ans = min(ans, W[i] + solve(i-1, value-V[i]);
    }
                  
    dp[i][value] = ans;
  
}

int main() {
	int n,w;
  	cin>>n>>w;
  	for (int i=0; i<n; i++) {
    	cin>>W[i];
      	cin>>V[i];
    }
  	memset(dp, -1, sizeof(dp));
   
  	ll ans = 0;
  	for (int i=0; i<n; i++) {
    	for (int v=0; v<=100000; v++) {
        	ll tmp = solve(i, v);
          	if (tmp < w && ans < v) {
            	ans = v;
            }
        }
    }
  
  	cout<<v<<endl;
}

Compiler output:
a.cc: In function 'll solve(int, int)':
a.cc:29:16: error: expected initializer before '.' token
   29 |         ll ans .= solve(i-1, value);
      |                ^
a.cc:32:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   32 |         ans = min(ans, W[i] + solve(i-1, value-V[i]);
      |         ^~~
      |         abs
a.cc:32:53: error: expected ')' before ';' token
   32 |         ans = min(ans, W[i] + solve(i-1, value-V[i]);
      |                  ~                                  ^
      |                                                     )
a.cc:35:20: error: 'ans' was not declared in this scope; did you mean 'abs'?
   35 |     dp[i][value] = ans;
      |                    ^~~
      |                    abs
a.cc: In function 'int main()':
a.cc:58:15: error: 'v' was not declared in this scope
   58 |         cout<<v<<endl;
      |               ^
a.cc: In function 'll solve(int, int)':
a.cc:37:1: warning: control reaches end of non-void function [-Wreturn-type]
   37 | }
      | ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main(){
    long long N,W,w,v;
    array<long long,100001> dp;
    dp.fill(-1);
    dp[0] = 0
    cout << dp[0] << endl;
    cin >> N >> W;
    for (int i=0;i<N;i++){
        cin >> w >> v;
        for (int j=0;j <= 100001 - v; j++){
            if (dp[j] != -1){
                dp[j+v] = max(dp[j]+w,dp[j+v]);
            }
        }
    }
    v = -1;
    for(int i=0;i<100001;i++){
        if (dp[i] <= W)
            v = max(v,(long long)i);
    }
    cout << v << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:7:14: error: expected ';' before 'cout'
    7 |     dp[0] = 0
      |              ^
      |              ;
    8 |     cout << dp[0] << endl;
      |     ~~~~