Language: C++

#include <bits/stdc++.h>
using namespace std;
pair<long long, long long> p[101];
long long dp[100001];

int main() {
	int n, W;
    cin >> n >> W;
    for(int i = 0; i < n; i++)
       cin >> p[i].first >> p[i].second;
     sort(p, p+ n);
    memset(dp, 0x3f3f3f3f , sizeof dp);
    dp[0] = 0;
    int sum = 1;
    for(int j = 0; j < n; j++){
        sum += p[j].second;
       for(int i = 0; i < sum;  i++){
         if(i - p[j].second>= 0)
           dp[i] = min(dp[i], dp[i - p[j].second] + p[j].first);
       }
    }
    int ans = 0;
    for(int i = 0; i < 100001; i++)
      if(dp[i] <= W) ans = i;
    cout << ans;
	return 0;
}#include <bits/stdc++.h>
using namespace std;
pair<long long, long long> p[101];
long long dp[101][100001];

int main() {
	int n, W;
    cin >> n >> W;
    for(int i = 0; i < n; i++)
       cin >> p[i].first >> p[i].second;
    
    memset(dp, 0x3f3f3f3f , sizeof dp);
    for(int i = 0; i < n; i++) dp[i][0] = 0;
    dp[0][p[0].second]=p[0].first;
    for(int j = 1; j < n; j++){
       for(int i = 0; i < 100001; i++){
           dp[j][i] = dp[j-1][i];
            if(i - p[j].second>= 0)
              dp[j][i] = min(dp[j][i], dp[j-1][i - p[j].second] + p[j].first);
       }
    }
    int ans = 0;
    for(int i = 0; i < 100001; i++)
      if(dp[n-1][i] <= W) ans = i;
    cout << ans;
	return 0;
}

Compiler output:
a.cc:27:2: error: stray '#' in program
   27 | }#include <bits/stdc++.h>
      |  ^
a.cc:27:3: error: 'include' does not name a type
   27 | }#include <bits/stdc++.h>
      |   ^~~~~~~
a.cc:29:28: error: redefinition of 'std::pair<long long int, long long int> p [101]'
   29 | pair<long long, long long> p[101];
      |                            ^
a.cc:3:28: note: 'std::pair<long long int, long long int> p [101]' previously defined here
    3 | pair<long long, long long> p[101];
      |                            ^
a.cc:30:11: error: conflicting declaration 'long long int dp [101][100001]'
   30 | long long dp[101][100001];
      |           ^~
a.cc:4:11: note: previous declaration as 'long long int dp [100001]'
    4 | long long dp[100001];
      |           ^~
a.cc:32:5: error: redefinition of 'int main()'
   32 | int main() {
      |     ^~~~
a.cc:6:5: note: 'int main()' previously defined here
    6 | int main() {
      |     ^~~~
a.cc: In function 'int main()':
a.cc:39:37: error: invalid types 'long long int[int]' for array subscript
   39 |     for(int i = 0; i < n; i++) dp[i][0] = 0;
      |                                     ^
a.cc:40:10: error: invalid types 'long long int[long long int]' for array subscript
   40 |     dp[0][p[0].second]=p[0].first;
      |          ^
a.cc:43:17: error: invalid types 'long long int[int]' for array subscript
   43 |            dp[j][i] = dp[j-1][i];
      |                 ^
a.cc:43:30: error: invalid types 'long long int[int]' for array subscript
   43 |            dp[j][i] = dp[j-1][i];
      |                              ^
a.cc:45:20: error: invalid types 'long long int[int]' for array subscript
   45 |               dp[j][i] = min(dp[j][i], dp[j-1][i - p[j].second] + p[j].first);
      |                    ^
a.cc:45:35: error: invalid types 'long long int[int]' for array subscript
   45 |               dp[j][i] = min(dp[j][i], dp[j-1][i - p[j].second] + p[j].first);
      |                                   ^
a.cc:45:47: error: invalid types 'long long int[long long int]' for array subscript
   45 |               dp[j][i] = min(dp[j][i], dp[j-1][i - p[j].second] + p[j].first);
      |                                               ^
a.cc:50:17: error: invalid types 'long long int[int]' for array subscript
   50 |       if(dp[n-1][i] <= W) ans = i;
      |                 ^