Language: C++

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define gg(x) getInt(&x)
using namespace std;
typedef long long ll;
inline void getInt(int* p);
const int maxn=1000010;
const int inf=0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/
ll dp[maxn];
ll n,W;
ll v[maxn];
ll w[maxn];
int main()
{
    memset(dp,0x3f,sizeof(dp));
    gbtb;
    cin>>n>>W;
    repd(i,1,n)
    {
        cin>>w[i]>>v[i];
    }
    ll ans=0ll;
    dp[0]=0;
    repd(i,1,n)
    {
        for(int j=1e5;j>=v[i];--j)
        {
            {
                dp[j]=min(dp[j],dp[j-v[i]]+w[i]);
                if(dp[j]<=W)
                    ans=max(ans,(ll)(j));
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

inline void getInt(int* p) {
    char ch;
    do {
        ch = getchar();
    } while (ch == ' ' || ch == '\n');
    if (ch == '-') {
        *p = -(getchar() - '0');
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 - ch + '0';
        }
    }
    else {
        *p = ch - '0';
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 + ch - '0';
        }
    }
}#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define gg(x) getInt(&x)
using namespace std;
typedef long long ll;
inline void getInt(int* p);
const int maxn=1000010;
const int inf=0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/
ll dp[maxn];
ll n,W;
ll v[maxn];
ll w[maxn];
int main()
{
    memset(dp,0x3f,sizeof(dp));
    gbtb;
    cin>>n>>W;
    repd(i,1,n)
    {
        cin>>w[i]>>v[i];
    }
    ll ans=0ll;
    dp[0]=0;
    repd(i,1,n)
    {
        for(int j=1e5;j>=v[i];--j)
        {
            {
                dp[j]=min(dp[j],dp[j-v[i]]+w[i]);
                if(dp[j]<=W)
                    ans=max(ans,(ll)(j));
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

inline void getInt(int* p) {
    char ch;
    do {
        ch = getchar();
    } while (ch == ' ' || ch == '\n');
    if (ch == '-') {
        *p = -(getchar() - '0');
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 - ch + '0';
        }
    }
    else {
        *p = ch - '0';
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 + ch - '0';
        }
    }
}#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define gg(x) getInt(&x)
using namespace std;
typedef long long ll;
inline void getInt(int* p);
const int maxn=1000010;
const int inf=0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/
ll dp[maxn];
ll n,W;
ll v[maxn];
ll w[maxn];
int main()
{
    memset(dp,0x3f,sizeof(dp));
    gbtb;
    cin>>n>>W;
    repd(i,1,n)
    {
        cin>>w[i]>>v[i];
    }
    ll ans=0ll;
    dp[0]=0;
    repd(i,1,n)
    {
        for(int j=1e5;j>=v[i];--j)
        {
            {
                dp[j]=min(dp[j],dp[j-v[i]]+w[i]);
                if(dp[j]<=W)
                    ans=max(ans,(ll)(j));
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

inline void getInt(int* p) {
    char ch;
    do {
        ch = getchar();
    } while (ch == ' ' || ch == '\n');
    if (ch == '-') {
        *p = -(getchar() - '0');
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 - ch + '0';
        }
    }
    else {
        *p = ch - '0';
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 + ch - '0';
        }
    }
}

Compiler output:
a.cc:79:2: error: stray '#' in program
   79 | }#include <iostream>
      |  ^
a.cc:157:2: error: stray '#' in program
  157 | }#include <iostream>
      |  ^
a.cc:79:3: error: 'include' does not name a type
   79 | }#include <iostream>
      |   ^~~~~~~
a.cc:107:11: error: redefinition of 'const int maxn'
  107 | const int maxn=1000010;
      |           ^~~~
a.cc:29:11: note: 'const int maxn' previously defined here
   29 | const int maxn=1000010;
      |           ^~~~
a.cc:108:11: error: redefinition of 'const int inf'
  108 | const int inf=0x3f3f3f3f;
      |           ^~~
a.cc:30:11: note: 'const int inf' previously defined here
   30 | const int inf=0x3f3f3f3f;
      |           ^~~
a.cc:110:4: error: redefinition of 'll dp [1000010]'
  110 | ll dp[maxn];
      |    ^~
a.cc:32:4: note: 'll dp [1000010]' previously declared here
   32 | ll dp[maxn];
      |    ^~
a.cc:111:4: error: redefinition of 'll n'
  111 | ll n,W;
      |    ^
a.cc:33:4: note: 'll n' previously declared here
   33 | ll n,W;
      |    ^
a.cc:111:6: error: redefinition of 'll W'
  111 | ll n,W;
      |      ^
a.cc:33:6: note: 'll W' previously declared here
   33 | ll n,W;
      |      ^
a.cc:112:4: error: redefinition of 'll v [1000010]'
  112 | ll v[maxn];
      |    ^
a.cc:34:4: note: 'll v [1000010]' previously declared here
   34 | ll v[maxn];
      |    ^
a.cc:113:4: error: redefinition of 'll w [1000010]'
  113 | ll w[maxn];
      |    ^
a.cc:35:4: note: 'll w [1000010]' previously declared here
   35 | ll w[maxn];
      |    ^
a.cc:114:5: error: redefinition of 'int main()'
  114 | int main()
      |     ^~~~
a.cc:36:5: note: 'int main()' previously defined here
   36 | int main()
      |     ^~~~
a.cc:140:13: error: redefinition of 'void getInt(int*)'
  140 | inline void getInt(int* p) {
      |             ^~~~~~
a.cc:62:13: note: 'void getInt(int*)' previously defined here
   62 | inline void getInt(int* p) {
      |             ^~~~~~
a.cc:157:3: error: 'include' does not name a type
  157 | }#include <iostream>
      |   ^~~~~~~
a.cc:185:11: error: redefinition of 'const int maxn'
  185 | const int maxn=1000010;
      |           ^~~~
a.cc:29:11: note: 'const int maxn' previously defined here
   29 | const int maxn=1000010;
      |           ^~~~
a.cc:186:11: error: redefinition of 'const int inf'
  186 | const int inf=0x3f3f3f3f;
      |           ^~~
a.cc:30:11: note: 'const int inf' previously defined here
   30 | const int inf=0x3f3f3f3f;
      |           ^~~
a.cc:188:4: error: redefinition of 'll dp [1000010]'
  188 | ll dp[maxn];
      |    ^~
a.cc:32:4: note: 'll dp [1000010]' previously declared here
   32 | ll dp[maxn];
      |    ^~
a.cc:189:4: error: redefinition of 'll n'
  189 | ll n,W;
      |    ^
a.cc:33:4: note: 'll n' previously declared here
   33 | ll n,W;
      |    ^
a.cc:189:6: error: redefinition of 'll W'
  189 | ll n,W;
      |      ^
a.cc:33:6: note: 'll W' previously declared here
   33 | ll n,W;
      |      ^
a.cc:190:4: error: redefinition of 'll v [1000010]'
  190 | ll v[maxn];
      |    ^
a.cc:34:4: note: 'll v [1000010]' previously declared here
   34 | ll v[maxn];
      |    ^
a.cc:191:4: error: redefinition of 'll w [1000010]'
  191 | ll w[maxn];
      |    ^
a.cc:35:4: note: 'll w [1000010]' previously declared here
   35 | ll w[maxn];
      |    ^
a.cc:192:5: error: redefinition of 'int main()'
  192 | int main()
      |     ^~~~
a.cc:36:5: note: 'int main()' previously defined here
   36 | int main()
      |     ^~~~
a.cc:218:13: error: redefinition of 'void getInt(int*)'
  218 | inline void getInt(int* p) {
      |             ^~~~~~
a.cc:62:13: note: 'void getInt(int*)' previously defined here
   62 | inline void getInt(int* p) {
      |             ^~~~~~