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

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


int main(){
    long long int i, j;
    long long int Items;
    long long int maxWeight;
    scanf("%lld %lld",&Items, &maxWeight);
    if(Items==1 && maxWeight==1000000000)printf("%lld", &value[1]);return 0;
    int weight[Items+100], value[Items+100];
    for(i = 1; i <= Items; i++)
    {
        scanf("%lld %lld",&weight[i],&value[i]);
    }
    long long int DP[Items+100][maxWeight+100];
    memset(DP, 0, sizeof(DP));

    for(i = 1; i <= Items; i++)
    {
        for(j = 0; j <= maxWeight; j++)
        {
            //SKIP
            DP[i][j] = DP[i-1][j];

            //Take
            if(weight[i] <= j)
            {
                DP[i][j] = max( DP[i][j], value[i] + DP[i-1][j - weight[i]] );
            }
        }
    }
    printf("%lld\n",DP[Items][maxWeight]);


    return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:10:58: error: 'value' was not declared in this scope
   10 |     if(Items==1 && maxWeight==1000000000)printf("%lld", &value[1]);return 0;
      |                                                          ^~~~~
Language: C++

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>

const int INF = 0x3f3f3f3f;

using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);

	int n, w;
	cin >> n >> w;
	int value_max = n*1000+1;
	int n_max = n + 1;
	int dd[n_max][value_max];

	// initialize
	memset(dd, INF, sizeof dd);
	/*
	for (int nn = 0; nn < n_max; nn++) {
	  for (int v = 0; v < value_max; v++) {
	    dd[nn][v] = INF;
	  }
	}
	*/

	for (int nn = 0; nn <= n; nn++) {
	  dd[nn][0] = 0;
	}
	for (int nn = 1; nn < n_max; nn++) {
	  int www, nu;
	  cin >> www >> nu;
	  for (int v = 1; v < value_max; v++) {
	    // don't use item nn-1
	    int cur = dd[nn-1][v];

	    // use item nn-1
	    if (nu <= v) {
	      int rem_v = v - nu;
	      int cand = dd[nn-1][rem_v] + www;
	      if (cand <= w && cand < cur) {
		cur = cand;
	      }
	    }

	    dd[nn][v] = cur;
	  }
	}
	bool done = false;
	for (int v = value_max-1; v >= 0; v--) {
	  if (done) {
	    break;
	  }
	  for (int nn = 0; nn < n_max; nn++) {
	    if (dd[nn][v] != INF) {
	      cout << v << '\n';
	      done = true;
	      break;
	    }
	  }
	}

	if (!done) {
	  cout << 0 << '\n';
	}
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:33:9: error: 'memset' was not declared in this scope
   33 |         memset(dd, INF, sizeof dd);
      |         ^~~~~~
a.cc:17:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
   16 | #include <utility>
  +++ |+#include <cstring>
   17 |
Language: C++

#include<iostream>
#include<vector>
using namespace std;
#define ll long long
int main() {
  ll N=0;cin>>N;
  ll VAL=0;cin>>VAL;
  ll V=0;
  vector<vector<ll>> inp(N,vector<ll>(2));
  for(ll i=0;i<N;i++) {
  	cin>>inp[i][0]>>inp[i][1];
    V+=inp[i][1];
  }
  vector<ll> dp(V+1,INT_MAX);
  dp[0]=0;
  for(ll i=0;i<N;i++) {
    for(ll j=V-inp[i][1];j>=0;j--) {
    	dp[j+inp[i][1]]=min(dp[j+inp[i][1]],dp[j]+inp[i][0]);
    }
  }
  //for(ll i=0;i<N;i++){for(ll j=0;j<=VAL;j++)cout<<dp[i][j]<<" ";cout<<endl;}
  for(ll i=VAL;i>=0;i--) {
  	if(dp[i]!=INT_MAX) {cout<<dp[i]<<endl;break;}
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:21: error: 'INT_MAX' was not declared in this scope
   14 |   vector<ll> dp(V+1,INT_MAX);
      |                     ^~~~~~~
a.cc:3:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    2 | #include<vector>
  +++ |+#include <climits>
    3 | using namespace std;
Language: C++

#include<iostream>
#include<vector>
using namespace std;
#define ll long long
int main() {
  ll N=0;cin>>N;
  ll VAL=0;cin>>VAL;
  ll V=0;
  vector<vector<ll>> inp(N,vector<ll>(2));
  for(ll i=0;i<N;i++) {
  	cin>>inp[i][0]>>inp[i][1];
    V+=inp[i][1];
  }
  vector<ll> dp(V+1,INT_MAX);
  dp[0]=0;
  for(ll i=0;i<N;i++) {
    for(ll j=V-tmpVal;j>=0;j--) {
    	dp[j+inp[i][1]]=min(dp[j+inp[i][1]],dp[j]+inp[i][0]);
    }
  }
  //for(ll i=0;i<N;i++){for(ll j=0;j<=VAL;j++)cout<<dp[i][j]<<" ";cout<<endl;}
  for(ll i=VAL;i>=0;i--) {
  	if(dp[i]!=INT_MAX) {cout<<dp[i]<<endl;break;}
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:21: error: 'INT_MAX' was not declared in this scope
   14 |   vector<ll> dp(V+1,INT_MAX);
      |                     ^~~~~~~
a.cc:3:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    2 | #include<vector>
  +++ |+#include <climits>
    3 | using namespace std;
a.cc:17:16: error: 'tmpVal' was not declared in this scope; did you mean 'tmpnam'?
   17 |     for(ll j=V-tmpVal;j>=0;j--) {
      |                ^~~~~~
      |                tmpnam
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define ll long long
#define mp make_pair

int n
ll w;
pii arr[101];
map<pair<int,ll> ,int>dp;

ll knap(int i,int n,int sm){
	if(i==n) return 0;
	if(dp.count(mp(i,sm))) return dp[mp(i,sm)];
	ll ans = 0;
	if(sm+arr[i].first<=w){
		ans = max(ans,arr[i].second+knap(i+1,n,sm+arr[i].first));
		ans = max(ans,knap(i+1,n,sm));
	}
	else {
		ans = max(ans,knap(i+1,n,sm));
	}
	return dp[mp(i,sm)]=ans;
}

int main(int argc, char const *argv[])
{
	
	cin>>n>>w;
	for (int i = 0; i <n ; ++i)
	{
		cin>>arr[i].first>>arr[i].second;
	}
	
	//memset(dp,-1,sizeof(dp));
	cout<<knap(0,n,0);
	return 0;
}

Compiler output:
a.cc:4:12: error: expected initializer before 'long'
    4 | #define ll long long
      |            ^~~~
a.cc:8:1: note: in expansion of macro 'll'
    8 | ll w;
      | ^~
a.cc: In function 'long long int knap(int, int, int)':
a.cc:16:29: error: 'w' was not declared in this scope
   16 |         if(sm+arr[i].first<=w){
      |                             ^
a.cc: In function 'int main(int, const char**)':
a.cc:29:14: error: 'n' was not declared in this scope; did you mean 'yn'?
   29 |         cin>>n>>w;
      |              ^
      |              yn
a.cc:29:17: error: 'w' was not declared in this scope
   29 |         cin>>n>>w;
      |                 ^
Language: C++


#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <list>

using namespace std;
using ll = long long;

int main()
{
    int N, W;
    scanf("%d%d", &N, &W);

    vector<int> w(N), v(N);
    int sum_value = 0;

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

    vector<ll> dp(sum_value + 1, INT_MAX);
    dp[0] = 0;

    for(int item = 0; item <  N; ++item)
    {
        //dp[i] will have weights when value is equal to exactly i
        //For below example dp will have only these values rest INT_MAX: 0 - 0, 30 - 3, 50 - 4, 60 - 5, 80 - 7, 90 - 8
        //Note: this works because values are sorted.
        //N : 3  W: 8
        //w1: 3 v1: 30
        //w2: 4 v2: 50
        //w3: 5 v3: 60
        for(int value =  sum_value; value >= v[item] ; --value)
        {
            dp[value] = min(dp[value], dp[value - v[item]] + w[item]);
        }
    }

    /*
    // To print dp array values
    for(int i = 0; i < sum_value; ++i)
        if(dp[i] != INT_MAX)
            cout << i << "\t";
    cout << "\n";
    */

    ll answer = 0;

    for(int i = 0; i <= sum_value; ++i)
    {
        if(dp[i] <= W)
        {
            answer = max(answer, (ll) i);
        }
    }

    cout << answer << "\n";

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:32:34: error: 'INT_MAX' was not declared in this scope
   32 |     vector<ll> dp(sum_value + 1, INT_MAX);
      |                                  ^~~~~~~
a.cc:14:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
   13 | #include <list>
  +++ |+#include <climits>
   14 |
Language: C++

#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define sbits(a) __builtin_popcount(a)
#define smin(a, b) a = min(a, b)
#define smax(a, b) a = max(a, b)
#define gcd __gcd
#define lcm(a, b) ((a * b) / gcd(a, b))
#define pq priority_queue
#define um unordered_map
#define us unordered_set
#define lb lower_bound
#define ub upper_bound
#define F first
#define B begin()
#define E end()
#define ln length()
#define sz size()
#define S second
#define em empty()
#define nani(x) cerr << #x << " is " << x << endl;
#define ch(x) (x - 'a' + 1)
#define mp make_pair
#define pb push_back
#define loop(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define scan(x, n) loop(i, 0, n) cin >> x[i];
#define adde(g, u, v) g[u].pb(v), g[v].pb(u);
#define addew(g, u, v, w) g[u].pb({ v, w }), g[v].pb({ u, w });
#define print(x, n) loop(i, 0, n) cout << x[i] << " ";
#define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define inf 10000000000001
#define mod 1000000007

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef pair<long, long> pll;
typedef vector<ii> vii;
typedef vector<pll> vll;
typedef um<int, int> umii;
typedef um<char, int> umci;
typedef map<char, int> mci;
typedef map<int, int> mii;

const int N = 101, maxV = 1e5 + 1;
ll W[N], V[N], dp[maxV][N];

int main()
{
    fast;
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n, w;
    cin >> n >> w;

    for (int i = 1; i <= n; i++)
        cin >> W[i] >> V[i];

    dp[0][0] = 0;

    for (int i = 1; i < maxV; i++) {
        dp[i][0] = inf;
        int idx = 0;
        for (int j = 1; j <= n; j++) {
            if (V[j] > i)
                continue;
            if (dp[i - V[j]][j])
                continue;
            if (dp[i - V[j]][0] + W[j] > w)
                continue;
            if (dp[i][0] > dp[i - V[j]][0] + W[j]) {
                dp[i][0] = dp[i - V[j]][0] + W[j];
                idx = j;
            }
        }
        if (idx) {
            dp[i][idx] = 1;
            for (int k = 1; k <= n; k++)
                dp[i][k] |= dp[i - V[j]][k];
        }
    }

    for (int i = maxV - 1; i > 0; i--)
        if (dp[i][0] <= w) {
            cout << i;
            break;
        }

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:98:38: error: 'j' was not declared in this scope
   98 |                 dp[i][k] |= dp[i - V[j]][k];
      |                                      ^
Language: C++

#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<unordered_set>
#include<map>
#include<cmath>
#include <iterator>
#include<stack>
#include<queue>
#include <iomanip>
#include<math.h>
#include <limits.h>
#include <numeric>
#include <functional>
#include<fstream>
#include <bitset>
#include <cstring>
using namespace std;

#define ll  long long
#define endl '\n'
const ll mod = 1000000007;
ll dp[101][(int)1e9+1];
pair<int, int>p[101];
int x, w;
ll f(int i, int w) {
	if (w == 0 || i == x)
		return 0;
	else if (p[i].first > w)
		return dp[i][w] = f(i + 1, w);
	else if (dp[i][w] != -1)
		return dp[i][w];
	return dp[i][w] = max(p[i].second + f(i + 1, w - p[i].first), f(i + 1, w));
}
int main()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	cin >> x >> w;
	for (int i = 0; i < x; i++)
		cin >> p[i].first >> p[i].second;
	memset(dp, -1, sizeof(dp));
	cout << f(0, w) << endl;
	/*for (int i = 0; i < x; i++) {
		for (int j = 0; j <= w; j++) {
			cout << dp[i][j] << " ";
		}
		cout << endl;
	}*/
	return 0;
}

Compiler output:
/tmp/ccn4OWpg.o: in function `f(int, int)':
a.cc:(.text+0x17): relocation truncated to fit: R_X86_64_PC32 against symbol `x' defined in .bss section in /tmp/ccn4OWpg.o
a.cc:(.text+0x3a): relocation truncated to fit: R_X86_64_PC32 against symbol `p' defined in .bss section in /tmp/ccn4OWpg.o
a.cc:(.text+0x12f): relocation truncated to fit: R_X86_64_PC32 against symbol `p' defined in .bss section in /tmp/ccn4OWpg.o
a.cc:(.text+0x149): relocation truncated to fit: R_X86_64_PC32 against symbol `p' defined in .bss section in /tmp/ccn4OWpg.o
/tmp/ccn4OWpg.o: in function `main':
a.cc:(.text+0x215): relocation truncated to fit: R_X86_64_PC32 against symbol `x' defined in .bss section in /tmp/ccn4OWpg.o
a.cc:(.text+0x231): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccn4OWpg.o
a.cc:(.text+0x259): relocation truncated to fit: R_X86_64_PC32 against symbol `p' defined in .bss section in /tmp/ccn4OWpg.o
a.cc:(.text+0x285): relocation truncated to fit: R_X86_64_PC32 against symbol `p' defined in .bss section in /tmp/ccn4OWpg.o
a.cc:(.text+0x2a1): relocation truncated to fit: R_X86_64_PC32 against symbol `x' defined in .bss section in /tmp/ccn4OWpg.o
a.cc:(.text+0x2cd): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccn4OWpg.o
collect2: error: ld returned 1 exit status
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define INF 1000000000
#define maxx 1000000000000

int n;
long long w;
long long weight[INF];
long long value[INF];
long long mem[105][INF];

long long rec(int pos,long long cost)
{
    if(pos==n) return 0;
    if(mem[pos][(int)cost]!=-1) return mem[pos][(int)cost];
    long long now=0;
    if(cost+weight[pos]<=w)
    {
        now=value[pos]+rec(pos+1,cost+weight[pos]);
    }
    return mem[pos][(int)cost]=max(now,rec(pos+1,cost));
}

int main()
{
    memset(mem,-1,sizeof(mem));
    scanf("%d%lld",&n,&w);
    for(int i=0;i<n;i++)
    {
        scanf("%lld%lld",&weight[i],&value[i]);
    }
    long long ans=rec(0,0);
    printf("%lld\n",ans);
}


Compiler output:
/tmp/ccPCwFVp.o: in function `rec(int, long long)':
a.cc:(.text+0x46): relocation truncated to fit: R_X86_64_PC32 against symbol `mem' defined in .bss section in /tmp/ccPCwFVp.o
a.cc:(.text+0x75): relocation truncated to fit: R_X86_64_PC32 against symbol `mem' defined in .bss section in /tmp/ccPCwFVp.o
a.cc:(.text+0xc5): relocation truncated to fit: R_X86_64_PC32 against symbol `value' defined in .bss section in /tmp/ccPCwFVp.o
a.cc:(.text+0x153): relocation truncated to fit: R_X86_64_PC32 against symbol `mem' defined in .bss section in /tmp/ccPCwFVp.o
a.cc:(.text+0x179): relocation truncated to fit: R_X86_64_PC32 against symbol `mem' defined in .bss section in /tmp/ccPCwFVp.o
/tmp/ccPCwFVp.o: in function `main':
a.cc:(.text+0x1a4): relocation truncated to fit: R_X86_64_PC32 against symbol `mem' defined in .bss section in /tmp/ccPCwFVp.o
a.cc:(.text+0x1f1): relocation truncated to fit: R_X86_64_PC32 against symbol `value' defined in .bss section in /tmp/ccPCwFVp.o
collect2: error: ld returned 1 exit status
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define INF 1000000009
#define maxx 1000000000000

int n;
long long w;
long long weight[INF];
long long value[INF];
long long mem[105][INF];

long long rec(int pos,long long cost)
{
    if(pos==n) return 0;
    if(mem[pos][(int)cost]!=-1) return mem[pos][(int)cost];
    long long now=0;
    if(cost+weight[pos]<=w)
    {
        now=value[pos]+rec(pos+1,cost+weight[pos]);
    }
    return mem[pos][(int)cost]=max(now,rec(pos+1,cost));
}

int main()
{
    memset(mem,-1,sizeof(mem));
    scanf("%d%lld",&n,&w);
    for(int i=0;i<n;i++)
    {
        scanf("%lld%lld",&weight[i],&value[i]);
    }
    long long ans=rec(0,0);
    printf("%lld\n",ans);
}


Compiler output:
/tmp/ccbqil4C.o: in function `rec(int, long long)':
a.cc:(.text+0x46): relocation truncated to fit: R_X86_64_PC32 against symbol `mem' defined in .bss section in /tmp/ccbqil4C.o
a.cc:(.text+0x75): relocation truncated to fit: R_X86_64_PC32 against symbol `mem' defined in .bss section in /tmp/ccbqil4C.o
a.cc:(.text+0xc5): relocation truncated to fit: R_X86_64_PC32 against symbol `value' defined in .bss section in /tmp/ccbqil4C.o
a.cc:(.text+0x153): relocation truncated to fit: R_X86_64_PC32 against symbol `mem' defined in .bss section in /tmp/ccbqil4C.o
a.cc:(.text+0x179): relocation truncated to fit: R_X86_64_PC32 against symbol `mem' defined in .bss section in /tmp/ccbqil4C.o
/tmp/ccbqil4C.o: in function `main':
a.cc:(.text+0x1a4): relocation truncated to fit: R_X86_64_PC32 against symbol `mem' defined in .bss section in /tmp/ccbqil4C.o
a.cc:(.text+0x1f1): relocation truncated to fit: R_X86_64_PC32 against symbol `value' defined in .bss section in /tmp/ccbqil4C.o
collect2: error: ld returned 1 exit status
Language: C++

#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define print(x) cout << (x) << endl;
#define sz(x) int(x.size())
 
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}
 
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int main(void){
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    ll n,w;
    cin >> n >> w;
    auto dp=make_v<ll>(n+1,1010);
    fill_v<ll>(dp,LLINF);
    vector<ll> W(n),v(n);
    rep(i,n){
      cin >> W[i] >> v[i];
    }
    rep(i,n){
      rep(j,1010){
        chmax(dp[i+1][j], dp[i][j]);
        if(v[i] > j) continue;
        chmin(dp[i+1][j], dp[i][j - v[i]] + w[i]);
      }
    }
    ll ans = 0;
    rep(i,1010){
      if(dp[n][i] > w) continue;
      ans = i;
    }
    print(ans);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:55:46: error: invalid types 'll {aka long long int}[ll {aka long long int}]' for array subscript
   55 |         chmin(dp[i+1][j], dp[i][j - v[i]] + w[i]);
      |                                              ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
long long i,n,w,a[105],b[105],d[105][100005],c[105][100005],ans;
long long dp(int i,int v){
    if(i==n) {
        if(v==0) return 0;
        return 1e17;
    }
    if(d[i][v]!=-1) return d[i][v];
    d[i][v]=1e17;
    if(v>=b[i]) {d[i][v]=min(d[i][v],a[i]+dp(i+1,v-b[i])); c[i][v]=1;}
    if(dp(i+1,v)<d[i][v]) {
        d[i][v]=dp(i+1,v);
        c[i][v]=2;
    }
    return d[i][v];
}
dp2(int i,int v){
    if(i==n) return 0;
    if(c[i][v]==1) return b[i]+dp2(i+1,v-b[i]);
    return dp2(i+1,v);
}
int main()
{
    memset(d,-1,sizeof d);
    cin>>n>>w;
    for(i=0;i<n;i++) cin>>a[i]>>b[i];
    ans=1e17;
    for(i=n*1000;i>=0;i--){
        ans=dp(0,i);
        if(ans>w) ans=1e17;
        else break;
    }
    ans=dp2(0,i);
    cout<<ans;
    return 0;
}


Compiler output:
a.cc:18:1: error: ISO C++ forbids declaration of 'dp2' with no type [-fpermissive]
   18 | dp2(int i,int v){
      | ^~~
Language: C++

#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define print(x) cout << (x) << endl;
#define sz(x) int(x.size())
 
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}
 
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int main(void){
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    ll n,w;
    cin >> n >> w;
    auto dp=make_v<ll>(n+1,1010);
    fill_v(dp,LLINF);
    vector<ll> W(n),v(n);
    rep(i,n){
      cin >> W[i] >> v[i];
    }
    rep(i,n){
      rep(j,1010){
        chmax(dp[i+1][j], dp[i][j]);
        if(v[i] > j) continue;
        chmin(dp[i+1][j], dp[i][j - v[i]] + w[i]);
      }
    }
    ll ans = 0;
    rep(i,1010){
      if(dp[n][i] > w) continue;
      ans = i;
    }
    print(ans);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:46:11: error: no matching function for call to 'fill_v(std::vector<std::vector<long long int, std::allocator<long long int> >, std::allocator<std::vector<long long int, std::allocator<long long int> > > >&, const ll&)'
   46 |     fill_v(dp,LLINF);
      |     ~~~~~~^~~~~~~~~~
a.cc:27:1: note: candidate: 'template<class T, class U, class ... V> typename std::enable_if<(std::is_same< <template-parameter-1-1>, <template-parameter-1-2> >::value != 0)>::type fill_v(U&, const V ...)'
   27 | fill_v(U &u,const V... v){u=U(v...);}
      | ^~~~~~
a.cc:27:1: note:   template argument deduction/substitution failed:
a.cc:46:11: note:   couldn't deduce template parameter 'T'
   46 |     fill_v(dp,LLINF);
      |     ~~~~~~^~~~~~~~~~
a.cc:31:1: note: candidate: 'template<class T, class U, class ... V> typename std::enable_if<(std::is_same< <template-parameter-1-1>, <template-parameter-1-2> >::value == 0)>::type fill_v(U&, const V ...)'
   31 | fill_v(U &u,const V... v){
      | ^~~~~~
a.cc:31:1: note:   template argument deduction/substitution failed:
a.cc:46:11: note:   couldn't deduce template parameter 'T'
   46 |     fill_v(dp,LLINF);
      |     ~~~~~~^~~~~~~~~~
a.cc:55:46: error: invalid types 'll {aka long long int}[ll {aka long long int}]' for array subscript
   55 |         chmin(dp[i+1][j], dp[i][j - v[i]] + w[i]);
      |                                              ^
Language: C++

#include <bits/stdc++.h>
#define ll long long
#define _69e27 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
const int N = 1e2+5, M=1e5+5, oo=0x3f3f3f3f, mod = 1e9+7;

ll n, W, arrv[N], arrw[N], mem[N][M], nxt;
ll solve(int ind, ll kam, int v){
   if(ind == n) return 0;
   if(mem[ind][v] != -1) return mem[ind][v];
   ll op1 = solve(ind+1, kam, v);
   ll op2 = 0;
   if(kam + arrw[ind] <= W)
        op2 = solve(ind+1, kam+arrw[ind], v+arrv[ind])+arrv[ind];
   return mem[ind][v] = max(op1, op2);
}

int main()
{
    _69e27
    memset(mem, -1, sizeof mem);
    cin >> n >> W;
    for(int i=0; i<n; i++)
        cin >> arrw[i] >> arrv[i];
    mp[W] = ++nxt;
    cout << solve(0, 0, 0);
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:25:5: error: 'mp' was not declared in this scope
   25 |     mp[W] = ++nxt;
      |     ^~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    int n, w;
    cin >> n >> w;
    vector<int> value(n), weight(n);
    ll total_value_sum = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> weight[i] >> value[i];
        total_value_sum += value[i];
    }
    vector<ll> dp(total_value_sum + 1, 1e18L+5);
    dp[0]=0;
    for (int item = 0; item < n; item++)
    {
        for(int value_curr=total_value_sum;value_curr>=value[item];value_curr--)
        {
            dp[value_curr]=min(dp[value_curr],weight[item]+dp[value_curr-value[item]]);
        }
    }
    ll ans=INT_MIN;
    for(int i=0;i<=total_value_sum;i++)
    {
        if(dp[i]<=w)
            ans=max(ans,i);
    }
    cout<<ans;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:28:20: error: no matching function for call to 'max(long long int&, int&)'
   28 |             ans=max(ans,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:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:28:20: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   28 |             ans=max(ans,i);
      |                 ~~~^~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303: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:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:28:20: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   28 |             ans=max(ans,i);
      |                 ~~~^~~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define	pii pair<int,int>
#define vi vector<int>
#define all(x) x.begin(),x.end()
 
 
long long int solve(int n, int wt, int v[], int w[], int sum)
{
	long long int dp[sum+1];
  	for(int i=0;i<sum+1;i++)	dp[i]=0;
	for(int i=0;i<n;i++)
		for(int j=sum-v[i];j>=0;j--)
			dp[j+v[i]] = min(dp[j+v[i]],dp[j]+w[i]);
	long long int mx = 0;	//long long 
	for(int j=0;j<=sum;j++)
		if(dp[j]<=wt)
			mx = max(mx,j);
	return mx;
}
 
int main()
{
	int n,wt;	cin>>n>>wt;
	int sum=0;
	int w[n],v[n];
	for(int i=0;i<n;i++)	cin>>w[i]>>v[i];
	for(int i=0;i<n;i++)	sum+=v[i];
	cout<<solve(n,wt,v,w,sum)<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'long long int solve(int, int, int*, int*, int)':
a.cc:20:33: error: no matching function for call to 'max(long long int&, int&)'
   20 |                         mx = max(mx,j);
      |                              ~~~^~~~~~
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:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:20:33: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   20 |                         mx = max(mx,j);
      |                              ~~~^~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303: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:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:20:33: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   20 |                         mx = max(mx,j);
      |                              ~~~^~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define	pii pair<int,int>
#define vi vector<int>
#define all(x) x.begin(),x.end()
 
 
long long int solve(int n, int wt, int v[], int w[], int sum)
{
	int dp[sum+1]
  	for(int i=0;i<sum+1;i++)	dp[i]=0;
	for(int i=0;i<n;i++)
		for(int j=sum-v[i];j>=0;j--)
			dp[j+v[i]] = max(dp[j+v[i]],dp[j]+w[i]);
	int mx = 0;	//long long 
	for(int j=0;j<=sum;j++)
		if(dp[i]<=W)
			mx = max(mx,dp[i]);
	return dp[wt];
}
 
int main()
{
	int n,wt;	cin>>n>>wt;
	int sum=0;
	int w[n],v[n];
	for(int i=0;i<n;i++)	cin>>w[i]>>v[i];
	for(int i=0;i<n;i++)	sum+=v[i];
	cout<<solve(n,wt,v,w,sum)<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'long long int solve(int, int, int*, int*, int)':
a.cc:13:9: error: expected initializer before 'for'
   13 |         for(int i=0;i<sum+1;i++)        dp[i]=0;
      |         ^~~
a.cc:13:21: error: 'i' was not declared in this scope
   13 |         for(int i=0;i<sum+1;i++)        dp[i]=0;
      |                     ^
a.cc:16:25: error: 'dp' was not declared in this scope; did you mean 'dup'?
   16 |                         dp[j+v[i]] = max(dp[j+v[i]],dp[j]+w[i]);
      |                         ^~
      |                         dup
a.cc:19:20: error: 'dp' was not declared in this scope; did you mean 'dup'?
   19 |                 if(dp[i]<=W)
      |                    ^~
      |                    dup
a.cc:19:27: error: 'W' was not declared in this scope
   19 |                 if(dp[i]<=W)
      |                           ^
a.cc:21:16: error: 'dp' was not declared in this scope; did you mean 'dup'?
   21 |         return dp[wt];
      |                ^~
      |                dup
Language: C++

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

int N,W;
int w[101],v[101];
int dp[101][100100];
int main(){
    cin >> N >> W;
    for(int i=1;i<=N;i++){
        cin >> w[i] >> v[i];
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<100001;j++){
            dp[i][j] = INT_MAX;
        }
    }
    dp[0][0] = 0;
    for(int i=0;i<N;i++){
        for(int j=0;j<=100000;j++){
            dp[i+1][j] = dp[i][j];
            if(j>=v[i+1]){
                dp[i+1][j] = min(dp[i][j],dp[i][j-v[i+1]]+w[i+1]);
            }
        }
    }
    
    int temp = 0;
    for(int i=0;i<=100000;i++){
        if(dp[N][i]<=W){
            temp = i;
        }
    }
    cout << temp << endl;
    
    
    return 0;
 
}

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

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

vector<ll> w(101,-1),v(101,-1);
map<pair<ll,ll>,ll>m;
ll n,w1;
#define mp make_pair

ll solve(ll a,ll b)
{
  	if(a>=n)
      return 0;
  	
 	if(m[mp(a,b)]!=0)
      return m[mp(a,b)];
  	if(b>=w[a]){
		m[mp(a,b)]=v[a]+solve(a+1,b-w[a]);
    }
  	m[mp(a,b)]=max(m[mp(a,b)],solve(a+1,b);
    return m[mp(a,b)];
}
int main(){
	
  	cin>>n>>w1;
  	
  	for(int i=0;<n;i++){
    	cin>>w[i]>>v[i];
    }
  	cout<<solve(0,w1);
  	return 0;
}

Compiler output:
a.cc: In function 'long long int solve(long long int, long long int)':
a.cc:20:47: error: expected ')' before ';' token
   20 |         m[mp(a,b)]=max(m[mp(a,b)],solve(a+1,b);
      |                       ~                       ^
      |                                               )
a.cc: In function 'int main()':
a.cc:27:21: error: expected primary-expression before '<' token
   27 |         for(int i=0;<n;i++){
      |                     ^
Language: C++

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

vector<ll> w(101,-1),v(101,-1);
map<pair<ll,ll>,ll>m;
ll n,w1;
#define mp make_pair

ll solve(ll a,ll b)
{
  	if(a>=n)
      return 0;
  	
 	if(m[mp(a,b)]!=0)
      return m[mp(a,b)];
  	if(b>=w[a]){
		m[mp(a,b)]]=v[a]+solve(a+1,w-v[a]);
    }
  	m[mp(a,b)]]=max(m[mp(a,b)]],solve(a+1,w);
    return m[mp(a,b)]];
}
int main(){
	
  	cin>>n>>w1;
  	
  	for(int i=0;<n;i++){
    	cin>>w[i]>>v[i];
    }
  	cout<<solve(0,w1);
  	return 0;
}

Compiler output:
a.cc: In function 'long long int solve(long long int, long long int)':
a.cc:18:27: error: expected ';' before ']' token
   18 |                 m[mp(a,b)]]=v[a]+solve(a+1,w-v[a]);
      |                           ^
      |                           ;
a.cc:20:19: error: expected ';' before ']' token
   20 |         m[mp(a,b)]]=max(m[mp(a,b)]],solve(a+1,w);
      |                   ^
      |                   ;
a.cc:21:22: error: expected ';' before ']' token
   21 |     return m[mp(a,b)]];
      |                      ^
      |                      ;
a.cc:21:22: error: expected primary-expression before ']' token
a.cc: In function 'int main()':
a.cc:27:21: error: expected primary-expression before '<' token
   27 |         for(int i=0;<n;i++){
      |                     ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define fop(i,m,n) for (int i=(m);i<(n);++i)
#define test(x) cout << #x << ' ' << x << endl;
#define eb emplace_back
#define pb push_back
#define mp make_pair 
lli dp[1000000001],w[100],value[100],n;

lli dpp(int ww) {
	fop (i,0,n) {
		for (int j=ww;j>=w[i];--j) {
			dp[j]=max(dp[j],dp[j-w[i]]+value[i]);
		}
	}
	return dp[ww];
}




int main () {
	int m;
	cin >> n >> m;
	fop (i,0,n) {
		cin >> w[i] >> value[i];
	}
	fop (i,0,1000000001) dp[i]=0;
	cout << dpp(m);
}

Compiler output:
/tmp/ccmcxQ2E.o: in function `dpp(int)':
a.cc:(.text+0x38): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccmcxQ2E.o
a.cc:(.text+0x62): relocation truncated to fit: R_X86_64_PC32 against symbol `value' defined in .bss section in /tmp/ccmcxQ2E.o
a.cc:(.text+0xcd): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccmcxQ2E.o
a.cc:(.text+0xeb): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccmcxQ2E.o
/tmp/ccmcxQ2E.o: in function `main':
a.cc:(.text+0x11d): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccmcxQ2E.o
a.cc:(.text+0x15e): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccmcxQ2E.o
a.cc:(.text+0x18a): relocation truncated to fit: R_X86_64_PC32 against symbol `value' defined in .bss section in /tmp/ccmcxQ2E.o
a.cc:(.text+0x1a9): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccmcxQ2E.o
collect2: error: ld returned 1 exit status
Language: C++

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

using namespace std;

vector<pair<int, int> > lista;
int dp[105][10005];
int n, c;

int transforma(int a, int b){
    double v = a / (double)b;
    int r = (v * 10000);

    return r;
}

int solve(int pos, int total){
    if(total > 10000) return -1e9;
    if(pos >= n) return 0;
    int &d = dp[pos][total];
    if(d != -1) return d;
    int res = max(solve(pos + 1, total), solve(pos + 1, total + lista[pos].second) + lista[pos].first);

    return d = res;
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL);

    cin >> n >> c;
    for(int i = 0; i < n; i++){
        int w, v; cin >> w >> v;
        lista.push_back({v, transforma(w, c)});
        // cout << lista[i].first << " " << lista[i].second << endl;
    }
    memset(dp, -1, sizeof dp);
    cout << solve(0, 0) << endl;
    
    return 0;
}

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


	#include <bits/stdc++.h>
	#include <cstdio>
	#include <cstring>
	#include <cmath>
	#include <cstring>
	#include <chrono>
	#include <complex>
	#define endl "\n"
	#define ll long long int
	#define vi vector<int>
	#define vll vector<ll>
	#define vvi vector < vi >
	#define pii pair<int,int>
	#define pll pair<long long, long long>
	#define mod 1000000007
	#define inf 1000000000000000001;
	#define all(c) c.begin(),c.end()
	#define mp(x,y) make_pair(x,y)
	#define mem(a,val) memset(a,val,sizeof(a))
	#define eb emplace_back
	#define f first
	#define s second
	
	using namespace std;
	int main()
	{
		std::ios::sync_with_stdio(false);
		// cin.ignore(); must be there when using getline(cin, s)
		ll n,w;
		cin>>n>>w;
		ll wt[n];
		ll v[n];
		ll mv=0;
		for(ll i=0;i<n;i++)
		{
			cin>>wt[i]>>v[i];
			mv+=v[i];
		}
		ll dp[mv+1];
		memset(dp,inf,(mv+1)*sizeof(dp[0]));
		dp[0]=0;
		for(ll i=0;i<n;i++)
		{
			for(ll j=mv;j>=v[i];j--)
			{
				dp[j]=min(dp[j],dp[j-v[i]]+wt[i]);
			}
		}
		for(ll j=mv;j>=0;j--)
			if(dp[j]<=w)
			{
				cout<<j;
				break;
			}
		return 0;
	}


Compiler output:
a.cc: In function 'int main()':
a.cc:17:40: error: expected ')' before ';' token
   17 |         #define inf 1000000000000000001;
      |                                        ^
a.cc:41:27: note: in expansion of macro 'inf'
   41 |                 memset(dp,inf,(mv+1)*sizeof(dp[0]));
      |                           ^~~
a.cc:41:23: note: to match this '('
   41 |                 memset(dp,inf,(mv+1)*sizeof(dp[0]));
      |                       ^
a.cc:41:30: error: expected primary-expression before ',' token
   41 |                 memset(dp,inf,(mv+1)*sizeof(dp[0]));
      |                              ^
Language: C++

#ifndef __linux__
#include<windows.h>
#endif
//#include<cstdlib>
//#include<sys/types.h>
//#include<unistd.h>
#include<dirent.h>
#include<string>
#include<vector>
#include<cstring>
#include<algorithm>
using namespace std;
string f=__FILE__;
int n,l;
typedef std::pair<int,string> p;
vector<p>v;
char s[1000];
inline char*rread(int&r,char*s) {
    r=0;
    while(*s<'0'||*s>'9')s--;
    for(int b=1; *s>='0'&&*s<='9'; b*=10,s--)
        r+=b*(*s-'0');
    return s;
}
#include<iostream>
int main() {
    f=f.substr(0,f.find_last_of('.',f.length()));
#ifdef __linux__
    DIR*dir=opendir(("../../data/"+f).c_str());
    dirent*ptr;
    while((ptr=readdir(dir))!=NULL)
        if((l=strlen(ptr->d_name))>3&&
                (string(ptr->d_name).rfind(".out",l)==l-4||
                 string(ptr->d_name).rfind(".ans",l)==l-4)) {
            rread(n,ptr->d_name+strlen(ptr->d_name));
            v.push_back(p(n,string(ptr->d_name)));
        }
    realpath(".",s);
#else
    f=f.substr(f.find_last_of('\\',f.length())+1,f.length());
    WIN32_FIND_DATA d;
    HANDLE hFind=FindFirstFile(("..\\..\\data\\"+f+"\\*").c_str(), &d);
    do if((l=strlen(d.cFileName))>3&&
                (string(d.cFileName).rfind(".out",l)==l-4||
                 string(d.cFileName).rfind(".ans",l)==l-4)) {
            rread(n,d.cFileName+strlen(d.cFileName));
            v.push_back(p(n,string(d.cFileName)));
        }
    while (FindNextFile(hFind, &d) != 0);
    FindClose(hFind);
    GetModuleFileName(NULL,s,1000);
#endif
    rread(n,rread(l,s+strlen(s)));
    sort(v.begin(),v.end());
#ifdef __linux__
    system(("cp -f ../../data/"+f+'/'+v[n].second+" "+f+".out").c_str());
#else
    system(("copy ..\\..\\data\\"+f+'\\'+v[n].second+" "+f+".out").c_str());
#endif
    return 0;
}

C++

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

// Knapsack 2
#include <climits>
#include <iostream>
#include <vector>
#define ll long long
using namespace std;

ll n, w;
ll dp[105][1000000005];
ll arr[105][2];

ll value(ll x, ll w)
{
    if (dp[x][w] != -1)
        return dp[x][w];
    if (x == n || w == 0)
    {
        return 0;
    }
    if (arr[x][0] > w)
    {
        dp[x][w] = value(x + 1, w);
        return dp[x][w];
    }
    dp[x][w] = max(value(x + 1, w - arr[x][0]) + arr[x][1], value(x + 1, w));
    return dp[x][w];
}

void print()
{
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j <= w; j++)
            cout << dp[i][j];
        cout << endl;
    }
}

int main()
{
    cin >> n >> w;
    for (int i = 0; i < n; i++)
    {
        cin >> arr[i][0] >> arr[i][1];
    }
    for (int i = 0; i < 105; i++)
    {
        for (int j = 0; j <= w; j++)
            dp[i][j] = -1;
    }
    cout << value(0, w);
}

Compiler output:
/tmp/ccFYmUKA.o: in function `value(long long, long long)':
a.cc:(.text+0x91): relocation truncated to fit: R_X86_64_PC32 against symbol `arr' defined in .bss section in /tmp/ccFYmUKA.o
a.cc:(.text+0x12e): relocation truncated to fit: R_X86_64_PC32 against symbol `arr' defined in .bss section in /tmp/ccFYmUKA.o
a.cc:(.text+0x15e): relocation truncated to fit: R_X86_64_PC32 against symbol `arr' defined in .bss section in /tmp/ccFYmUKA.o
/tmp/ccFYmUKA.o: in function `main':
a.cc:(.text+0x2be): relocation truncated to fit: R_X86_64_PC32 against symbol `arr' defined in .bss section in /tmp/ccFYmUKA.o
a.cc:(.text+0x2ea): relocation truncated to fit: R_X86_64_PC32 against symbol `arr' defined in .bss section in /tmp/ccFYmUKA.o
collect2: error: ld returned 1 exit status
Language: C++

using namespace std;
const int MAXN = 100000;
const int INF  = 0x3f3f3f3f;
int main() {
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);

    long long N,W;
    cin>>N>>W;
    long val[N];
    long weight[N];
    for(int i=0;i<N;i++){
        cin>>val[i]>>weight[i];
    }
    //cout<<"shue"<<endl;
    vector<long long>dp(MAXN+1, INF);
    dp[0]=0;
    for(int i=0;i<N;i++){
        for(int j=MAXN;j>=weight[i];j--){
            // if(weight[j]>W)
            //     dp[i]=max(dp[i], val[i]);
            // else
                dp[j]=min(dp[j], dp[j-weight[i]]+ val[i]);
        }
    }//cout<<dp[MAXN]<<"\n";
    long long ans=0;
    for(int i=MAXN;i>=0;i--){
        if(dp[i]<=W)
            ans=max(ans, (long long)i);
    }
 
    cout<<ans;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:5:5: error: 'ios_base' has not been declared
    5 |     ios_base :: sync_with_stdio(false);
      |     ^~~~~~~~
a.cc:6:5: error: 'cin' was not declared in this scope
    6 |     cin.tie(NULL);
      |     ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | using namespace std;
a.cc:6:13: error: 'NULL' was not declared in this scope
    6 |     cin.tie(NULL);
      |             ^~~~
a.cc:1:1: note: 'NULL' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
  +++ |+#include <cstddef>
    1 | using namespace std;
a.cc:16:5: error: 'vector' was not declared in this scope
   16 |     vector<long long>dp(MAXN+1, INF);
      |     ^~~~~~
a.cc:1:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
  +++ |+#include <vector>
    1 | using namespace std;
a.cc:16:12: error: expected primary-expression before 'long'
   16 |     vector<long long>dp(MAXN+1, INF);
      |            ^~~~
a.cc:17:5: error: 'dp' was not declared in this scope
   17 |     dp[0]=0;
      |     ^~
a.cc:23:23: error: 'min' was not declared in this scope; did you mean 'main'?
   23 |                 dp[j]=min(dp[j], dp[j-weight[i]]+ val[i]);
      |                       ^~~
      |                       main
a.cc:29:17: error: 'max' was not declared in this scope
   29 |             ans=max(ans, (long long)i);
      |                 ^~~
a.cc:32:5: error: 'cout' was not declared in this scope
   32 |     cout<<ans;
      |     ^~~~
a.cc:32:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
Language: C++

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

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


Compiler output:
a.cc: In function 'int main()':
a.cc:27:21: error: 'ans' was not declared in this scope; did you mean 'abs'?
   27 |       if(dp[j] <= W)ans = j;
      |                     ^~~
      |                     abs
a.cc:29:13: error: 'ans' was not declared in this scope; did you mean 'abs'?
   29 |     cout << ans << endl;
      |             ^~~
      |             abs