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

#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
#define MAX 510000
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

//cout << fixed << setprecision(10);//
//最小公倍数//
ll gcd(ll x, ll y) {
	if (x == 0) return y;
	return gcd(y%x, x);
}
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

//逆元mod(mを法とするaの逆元)//
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}



//Cmonp//
ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
ll COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//nが大

ll com(ll n,ll m){
	if(n<=0 || m<=0 || n==m){
		return 1;
	}
	if(n<m){
		return 0;
	}
	ll k=1;
	for(ll i=1;i<=m;i++){
       k*=(n-i+1); 
	   k%=MOD;
	   k*=modinv(i,MOD);
	   k%=MOD;
	}

	return k;
}

////////////////////////////////////////////////////////////////////

int main(){
int n,t;
cin>>n>>t;

pair<int,int> a[n+1];
for(int i=1;i<=n;i++){
int p,q;
cin>>p>>q;
a[i]=make_pair(p,q);
}



int dp[6010][n+2];
for(int i=0;i<=6009;i++){
	for(int j=0;j<=n;j++){
		dp[i][j]=0;
	}
}

for(int i=0;i<=n;i++){
dp[0][i]=0;
}

sort(a[i]+1, a[i]+n+1)


int ans=0;

for(int j=1;j<=n;j++){
for(int i=0;i<=t-1;i++){
	
	dp[i][j]=max(dp[i][j], dp[i][j-1]);
if(dp[i][j-1]!=-1){
dp[i+a[j].first][j]=dp[i][j-1]+a[j].second;}

}
}

for(int i=0;i<=6009;i++){
	for(int j=1;j<=n;j++){
		ans=max(ans,dp[i][j]);
	}
}

cout<<ans<<endl;
return 0;





}


Compiler output:
a.cc: In function 'int main()':
a.cc:102:8: error: 'i' was not declared in this scope
  102 | sort(a[i]+1, a[i]+n+1)
      |        ^
a.cc:119:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
  119 |                 ans=max(ans,dp[i][j]);
      |                 ^~~
      |                 abs
a.cc:123:7: error: 'ans' was not declared in this scope; did you mean 'abs'?
  123 | cout<<ans<<endl;
      |       ^~~
      |       abs
Language: C++

3 60
30 10
30 20
30 30#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int a[3003],b[3003];
int dp1[3003][3003]; // dp1[i][j] := 左からi番目まで見て時刻jまでに食べる時の最大の美味しさ
int dp2[3003][3003]; // dp2[i][j] := 右からi番目まで見て時刻jまでに食べる時の最大の美味しさ
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int n,t;
    cin >> n >> t;
    rep(i,n)cin >> a[i] >> b[i];
    rep(i,n){
        rep(j,3000){
            dp1[i+1][j] = dp1[i][j];
            if(j-a[i]>=0)chmax(dp1[i+1][j],dp1[i][j-a[i]]+b[i]);
        }
    }
    for(int i=n-1;i>=0;i--){
        rep(j,3000){
            dp2[i][j] = dp2[i+1][j];
            if(j-a[i]>=0)chmax(dp2[i][j],dp2[i+1][j-a[i]]+b[i]);
        }
    }
    int ans = 0;
    rep(i,n){
        rep(j,t){
            int x = b[i];
            x += dp1[i][j] + dp2[i+1][t-j-1];
            ans = max(ans,x);
        }
    }
    cout << ans << endl;
}

Compiler output:
a.cc:4:6: error: stray '#' in program
    4 | 30 30#include <bits/stdc++.h>
      |      ^
a.cc:1:1: error: expected unqualified-id before numeric constant
    1 | 3 60
      | ^
a.cc: In function 'int main()':
a.cc:20:5: error: 'cin' was not declared in this scope
   20 |     cin.tie(0);
      |     ^~~
a.cc:21:5: error: 'ios' has not been declared
   21 |     ios::sync_with_stdio(false);
      |     ^~~
a.cc:22:5: error: 'cout' was not declared in this scope
   22 |     cout << fixed << setprecision(20);
      |     ^~~~
a.cc:22:13: error: 'fixed' was not declared in this scope
   22 |     cout << fixed << setprecision(20);
      |             ^~~~~
a.cc:22:22: error: 'setprecision' was not declared in this scope
   22 |     cout << fixed << setprecision(20);
      |                      ^~~~~~~~~~~~
a.cc:43:19: error: 'max' was not declared in this scope
   43 |             ans = max(ans,x);
      |                   ^~~
a.cc:46:20: error: 'endl' was not declared in this scope
   46 |     cout << ans << endl;
      |                    ^~~~
Language: C++

int main() {
  int n, t;
  cin >> n >> t;
  vector<pair<int,int> > v(n);
  for (int i=0; i<n; i++) cin >> v[i].first >> v[i].second;
  sort(v.begin(), v.end());

  vector<int> dp(t+1, 0);
  for (int i=0; i<n; i++) {
    for (int j=t-1; j>=0; j--) {
      int k = min(t, j + v[i].first);
      dp[k] = max(dp[k], dp[j] + v[i].second);
    }
  }
  cout << dp[t] << endl;

  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:3:3: error: 'cin' was not declared in this scope
    3 |   cin >> n >> t;
      |   ^~~
a.cc:4:3: error: 'vector' was not declared in this scope
    4 |   vector<pair<int,int> > v(n);
      |   ^~~~~~
a.cc:4:10: error: 'pair' was not declared in this scope
    4 |   vector<pair<int,int> > v(n);
      |          ^~~~
a.cc:4:15: error: expected primary-expression before 'int'
    4 |   vector<pair<int,int> > v(n);
      |               ^~~
a.cc:5:34: error: 'v' was not declared in this scope
    5 |   for (int i=0; i<n; i++) cin >> v[i].first >> v[i].second;
      |                                  ^
a.cc:6:8: error: 'v' was not declared in this scope
    6 |   sort(v.begin(), v.end());
      |        ^
a.cc:6:3: error: 'sort' was not declared in this scope; did you mean 'short'?
    6 |   sort(v.begin(), v.end());
      |   ^~~~
      |   short
a.cc:8:10: error: expected primary-expression before 'int'
    8 |   vector<int> dp(t+1, 0);
      |          ^~~
a.cc:11:15: error: 'min' was not declared in this scope; did you mean 'main'?
   11 |       int k = min(t, j + v[i].first);
      |               ^~~
      |               main
a.cc:12:7: error: 'dp' was not declared in this scope
   12 |       dp[k] = max(dp[k], dp[j] + v[i].second);
      |       ^~
a.cc:12:15: error: 'max' was not declared in this scope
   12 |       dp[k] = max(dp[k], dp[j] + v[i].second);
      |               ^~~
a.cc:15:3: error: 'cout' was not declared in this scope
   15 |   cout << dp[t] << endl;
      |   ^~~~
a.cc:15:11: error: 'dp' was not declared in this scope
   15 |   cout << dp[t] << endl;
      |           ^~
a.cc:15:20: error: 'endl' was not declared in this scope
   15 |   cout << dp[t] << endl;
      |                    ^~~~
Language: C++

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


int N,T;
int A[3030],B[3030];
int L[3030][3030];
int R[3030][3030];

#define FOR(i,N) for (int i = 0; i < N; ++i)


void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>T;
	FOR(i,N) {
		cin>>A[i]>>B[i];
		FOR(x,3030) {
			// L[i+1][x]=max(L[i+1][x],L[i][x]);
			if(x+A[i]<=T) L[i+1][x+A[i]]=max(L[i+1][x+A[i]],L[i][x]+B[i]);
		}
	}
	for(i=N-1;i>=0;i--) {
		FOR(x,3030) {
			// R[i][x]=max(R[i][x],R[i+1][x]);
			if(x+A[i]<=T) R[i][x+A[i]]=max(R[i][x+A[i]],R[i+1][x]+B[i]);
		}
	}
	FOR(i,N+1) {
		FOR(j,T) {
			L[i][j+1]=max(L[i][j],L[i][j+1]);
			R[i][j+1]=max(R[i][j],R[i][j+1]);
		}
	}
	
	
	int ma=0;
	FOR(i,N) {
		FOR(x,T) {
			y=B[i]+L[i][x]+R[i+1][T-1-x];
			ma=max(ma,y);
		}
	}
	cout<<ma<<endl;
}


Compiler output:
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x17): undefined reference to `main'
collect2: error: ld returned 1 exit status
Language: C++

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


int N,T;
int A[3030],B[3030];
int L[3030][3030];
int R[3030][3030];


void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>T;
	FOR(i,N) {
		cin>>A[i]>>B[i];
		FOR(x,3030) {
			// L[i+1][x]=max(L[i+1][x],L[i][x]);
			if(x+A[i]<=T) L[i+1][x+A[i]]=max(L[i+1][x+A[i]],L[i][x]+B[i]);
		}
	}
	for(i=N-1;i>=0;i--) {
		FOR(x,3030) {
			// R[i][x]=max(R[i][x],R[i+1][x]);
			if(x+A[i]<=T) R[i][x+A[i]]=max(R[i][x+A[i]],R[i+1][x]+B[i]);
		}
	}
	FOR(i,N+1) {
		FOR(j,T) {
			L[i][j+1]=max(L[i][j],L[i][j+1]);
			R[i][j+1]=max(R[i][j],R[i][j+1]);
		}
	}
	
	
	int ma=0;
	FOR(i,N) {
		FOR(x,T) {
			y=B[i]+L[i][x]+R[i+1][T-1-x];
			ma=max(ma,y);
		}
	}
	cout<<ma<<endl;
}


Compiler output:
a.cc: In function 'void solve()':
a.cc:15:9: error: 'FOR' was not declared in this scope
   15 |         FOR(i,N) {
      |         ^~~
Language: C++

#include <bits/stdc++.h>


int N,T;
int A[3030],B[3030];
int L[3030][3030];
int R[3030][3030];


void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>T;
	FOR(i,N) {
		cin>>A[i]>>B[i];
		FOR(x,3030) {
			// L[i+1][x]=max(L[i+1][x],L[i][x]);
			if(x+A[i]<=T) L[i+1][x+A[i]]=max(L[i+1][x+A[i]],L[i][x]+B[i]);
		}
	}
	for(i=N-1;i>=0;i--) {
		FOR(x,3030) {
			// R[i][x]=max(R[i][x],R[i+1][x]);
			if(x+A[i]<=T) R[i][x+A[i]]=max(R[i][x+A[i]],R[i+1][x]+B[i]);
		}
	}
	FOR(i,N+1) {
		FOR(j,T) {
			L[i][j+1]=max(L[i][j],L[i][j+1]);
			R[i][j+1]=max(R[i][j],R[i][j+1]);
		}
	}
	
	
	int ma=0;
	FOR(i,N) {
		FOR(x,T) {
			y=B[i]+L[i][x]+R[i+1][T-1-x];
			ma=max(ma,y);
		}
	}
	cout<<ma<<endl;
}


Compiler output:
a.cc: In function 'void solve()':
a.cc:11:28: error: 'string' was not declared in this scope
   11 |         int i,j,k,l,r,x,y; string s;
      |                            ^~~~~~
a.cc:11:28: note: suggested alternatives:
In file included from /usr/include/c++/14/string:41,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:1:
/usr/include/c++/14/bits/stringfwd.h:77:33: note:   'std::string'
   77 |   typedef basic_string<char>    string;
      |                                 ^~~~~~
/usr/include/c++/14/string:76:11: note:   'std::pmr::string'
   76 |     using string    = basic_string<char>;
      |           ^~~~~~
a.cc:13:9: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   13 |         cin>>N>>T;
      |         ^~~
      |         std::cin
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:14:9: error: 'FOR' was not declared in this scope
   14 |         FOR(i,N) {
      |         ^~~
a.cc:42:9: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   42 |         cout<<ma<<endl;
      |         ^~~~
      |         std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:42:19: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   42 |         cout<<ma<<endl;
      |                   ^~~~
      |                   std::endl
In file included from /usr/include/c++/14/istream:41,
                 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:
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~
Language: C++

int N,T;
int A[3030],B[3030];
int L[3030][3030];
int R[3030][3030];


void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>T;
	FOR(i,N) {
		cin>>A[i]>>B[i];
		FOR(x,3030) {
			// L[i+1][x]=max(L[i+1][x],L[i][x]);
			if(x+A[i]<=T) L[i+1][x+A[i]]=max(L[i+1][x+A[i]],L[i][x]+B[i]);
		}
	}
	for(i=N-1;i>=0;i--) {
		FOR(x,3030) {
			// R[i][x]=max(R[i][x],R[i+1][x]);
			if(x+A[i]<=T) R[i][x+A[i]]=max(R[i][x+A[i]],R[i+1][x]+B[i]);
		}
	}
	FOR(i,N+1) {
		FOR(j,T) {
			L[i][j+1]=max(L[i][j],L[i][j+1]);
			R[i][j+1]=max(R[i][j],R[i][j+1]);
		}
	}
	
	
	int ma=0;
	FOR(i,N) {
		FOR(x,T) {
			y=B[i]+L[i][x]+R[i+1][T-1-x];
			ma=max(ma,y);
		}
	}
	cout<<ma<<endl;
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:8:28: error: 'string' was not declared in this scope
    8 |         int i,j,k,l,r,x,y; string s;
      |                            ^~~~~~
a.cc:10:9: error: 'cin' was not declared in this scope
   10 |         cin>>N>>T;
      |         ^~~
a.cc:11:9: error: 'FOR' was not declared in this scope
   11 |         FOR(i,N) {
      |         ^~~
a.cc:39:9: error: 'cout' was not declared in this scope
   39 |         cout<<ma<<endl;
      |         ^~~~
a.cc:39:19: error: 'endl' was not declared in this scope
   39 |         cout<<ma<<endl;
      |                   ^~~~
Language: C++

#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>

using namespace std;

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

int main(){
  int n , t , dp[3050][6100] = {-100000009};
  cin >> n >> t;
  vector<pair<int,int>> s(n);
  
  for(int i=0;i<n;i++){
    
  cin >> s[i].first >> s[i].second;
    
  }
  
  sort(s.begin(),s.end());
  
  dp[0][0] =0;
  for(int i=0;i<n;i++){
    
   for(int j=0;j<3100;j++){
     
     if(j < t) chmax(dp[i+1][j+s[i].first],dp[i][j]+s[i].second);
     chmax(dp[i+1][j],dp[i][j]);
   }
  }
  
  int res = 0;
  
    for(int i=0;i<=n;i++){
  for(int j=0;j<6100;j++){
    
       chmax(res , dp[i][j]);
  }
  
  
  cout << res << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:42:2: error: expected '}' at end of input
   42 | }
      |  ^
a.cc:9:11: note: to match this '{'
    9 | int main(){
      |           ^
Language: C++

#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>

using namespace std;

int main(){
  int n , t , dp[3050][6100] = {-1e9};
  cin >> n >> t;
  vector<pair<int,int>> s(n);
  
  for(int i=0;i<n;i++){
    
  cin >> s[i].first >> s[i].second;
    
  }
  
  sort(s.begin(),s.end());
  dp[0][0] =0;
  for(int i=0;i<n;i++){
    
   for(int j=0;j<6050;j++){
     
     if(j < t) dp[i+1][j+s[i].first] = max(dp[i+1][j+s[i].first],dp[i][j]+s[i].second);
     dp[i+1][j] = max(dp[i+1][j],dp[i][j]);
   }
  }
  
  int res = 0;
  for(int i=0;i<=n;i++){
    
  for(int j=0;j<6100;j++){
    
       max(res , dp[i][j]);
  }
  }
  
  cout << res << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:8:33: error: narrowing conversion of '-1.0e+9' from 'double' to 'int' [-Wnarrowing]
    8 |   int n , t , dp[3050][6100] = {-1e9};
      |                                 ^~~~
a.cc:34:11: warning: ignoring return value of 'constexpr const _Tp& std::max(const _Tp&, const _Tp&) [with _Tp = int]', declared with attribute 'nodiscard' [-Wunused-result]
   34 |        max(res , dp[i][j]);
      |        ~~~^~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: declared here
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
Language: C++

#include <iostream>
#include <bits/stdc++.h>
#include <slgorithm>

using namespace std;

int main(){
  int n , t , dp[3050][6100];
  cin >> n >> t;
  vector<pair<int,int>> s(n);
  
  for(int i=0;i<n;i++){
    
  cin >> s[i].first >> s[i].second;
    
  }
  
  sort(s.begin(),s.end());
  
  for(int i=0;i<n;i++){
    
   for(int j=0;j<6050;j++){
     
     if(j < t) dp[i+1][j+s[i].first] = max(dp[i+1][j+s[i].first],dp[i][j]+s[i].second);
     dp[i+1][j] = max(dp[i+1][j],dp[i][j]);
   }
  }
  
  int res = 0;
  for(int i=0;i<n;i++){
    
  for(int j=0;j<6100;j++){
    
       max(res , dp[i][j]);
  }
  }
  
  cout << res << endl;
}

Compiler output:
a.cc:3:10: fatal error: slgorithm: No such file or directory
    3 | #include <slgorithm>
      |          ^~~~~~~~~~~
compilation terminated.
Language: C++

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

int dp[3000][3000];
int main() {
  int n, t;
  cin>>n>>t;
  pair<int, int> ab[n];
  for (int i=0; i<n; i++) cin>>ab[i].first>>ab[i].second;
  sort(ab, ab + n);
  for (int j=0; j<t; j++) {
    if (j < ab[0].first) {
      dp[0][j] = 0;
    } else {
      dp[0][j] = ab[0].second;
    }
  }
  for (int i=1; i<n; i++) {
    dp[i][j] = 0;
    for (int j=1; j<t; j++) {
      dp[i][j] = max(dp[i][j-1], dp[i-1][j]);
      if (j >= ab[i].first) {
        dp[i][j] = max(dp[i-1][j-ab[i].first] + ab[i].second, dp[i][j]);
      }
    }
  }
  int ans = 0;
  for (int i=0; i<n-1; i++) {
    ans = max(dp[i][t-1] + ab[i+1].second, ans);
  }
  cout<<ans<<endl;

}

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

#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int dp[3005];

int main(){
  for(int i=0;i<3005;i++) dp[i] = 0;
  
  int n,t; cin >> n >> t;
  vector<pair<int,int>> v(n);
  for(int i=0;i<n;i++) cin >> v[i].second >> v.first;
  sort(v.begin(), v.end());
  int ans = 0;
  for(int i=0;i<n;i++){
    for(int j=0;j<t;j++){
      if(j + v.first > t) ans = max(ans, dp[j] + v.second);
      else dp[j + v.first] = max(dp[j + v.first], dp[j] + v.second);
    }
  }
  
  cout << ans << endl;
  return 0;
}
  

Compiler output:
a.cc: In function 'int main()':
a.cc:13:48: error: 'class std::vector<std::pair<int, int> >' has no member named 'first'
   13 |   for(int i=0;i<n;i++) cin >> v[i].second >> v.first;
      |                                                ^~~~~
a.cc:18:16: error: 'class std::vector<std::pair<int, int> >' has no member named 'first'
   18 |       if(j + v.first > t) ans = max(ans, dp[j] + v.second);
      |                ^~~~~
a.cc:18:52: error: 'class std::vector<std::pair<int, int> >' has no member named 'second'
   18 |       if(j + v.first > t) ans = max(ans, dp[j] + v.second);
      |                                                    ^~~~~~
a.cc:19:21: error: 'class std::vector<std::pair<int, int> >' has no member named 'first'
   19 |       else dp[j + v.first] = max(dp[j + v.first], dp[j] + v.second);
      |                     ^~~~~
a.cc:19:43: error: 'class std::vector<std::pair<int, int> >' has no member named 'first'
   19 |       else dp[j + v.first] = max(dp[j + v.first], dp[j] + v.second);
      |                                           ^~~~~
a.cc:19:61: error: 'class std::vector<std::pair<int, int> >' has no member named 'second'
   19 |       else dp[j + v.first] = max(dp[j + v.first], dp[j] + v.second);
      |                                                             ^~~~~~
Language: C++

#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VRSORT(v) sort(v.begin(), v.end(),[](int a, int b){return a > b;});
#define ALL(X) (X).begin(),(X).end()
#define INF 999999999
#define M_PI 3.14159265358979323846
#define MOD 1000000007

#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

#ifdef __LOCAL
    #include <filesystem>
    namespace fs = std::filesystem;
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 0};
int dy[]={0, 1, 0, -1, 0};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
const int NIL = -1;
static mt19937 _g(time(nullptr));
 
std::string pad(int num){ char buffer[4]; std::snprintf(buffer, sizeof(buffer), "%03d", num); return buffer;}
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

// ナップサック問題の拡張版
struct menu{
    int time,value;
    menu(int t, int v):time(t),value(v){}
};

int N,T;
vector<menu> M;
int dp_d[3010][3010][9000010];

int dp(int const& i, int const& t, int const& v){
    if(dp_d[i][t][v]) return dp_d[i][t][v];
    if(2*t > 2*T-1) return dp_d[i][t][v] = v;
    else if(i==N-1) return dp_d[i][t][v] = v + M[i].value;
    else return dp_d[i][t][v] = max(dp(i+1,t,v), dp(i+1,t+M[i].time,v+M[i].value)); 
}

int main()
{
    #ifdef __LOCAL
        fs::path p = __FILE__;
        fs::path input,output;
        input = output = p.parent_path();
        input += string("/input/") + string(p.stem()) + string(".txt");
        output += string("/output/") + string(p.stem()) + string(".txt");
        freopen(input.c_str(), "r", stdin);
        freopen(output.c_str(), "w", stdout);
    #endif


    cin >> N >> T;
    M.assign(N,menu(0,0));
    FOR(i,0,N) cin >> M[i].time >> M[i].value;
    sort(M.begin(),M.end(),[](menu a, menu b){return a.time < b.time;});

    cout << dp(0,0,0) << endl;

    return 0;
}


Compiler output:
/tmp/ccuKVO0N.o: in function `__static_initialization_and_destruction_0()':
a.cc:(.text+0x1316): relocation truncated to fit: R_X86_64_PC32 against `.bss'
collect2: error: ld returned 1 exit status
Language: C++

#include<iostream>
#include<algorithm>
using namespace std;
const int N_FOOD = 3005;
const int TIME = 6005;


int nFood, limit;
int cost[N_FOOD], val[N_FOOD];

void read() {
    cin >> nFood >> limit;
    for (int i = 0; i < nFood; ++i) {
        cin >> cost[i] >> val[i];
    }
}


void work() {
    int dp[TIME];
    memset(dp, -1, sizeof(dp));
    
    dp[0] = 0;
    for (int i = 0; i < nFood; ++i) {
        for (int j = limit - 1; j >= 0; --j) {
            if (dp[j] == -1) continue;
            dp[j + cost[i]] = max(dp[j + cost[i]], dp[j] + val[i]);
        }
    }

    cout << *max_element(dp, dp + TIME) << endl;
}


int main() {
    read();
    work();
    return 0;
}


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

#include<iostream>
#include<fstream>
#include<sstream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<cmath>
#include<cstdio>
#include<cassert>
using namespace std;

#define REP(i,m,n) for(int i=(m); i<(int)(n); i++)
#define RREP(i,m,n) for(int i=(int)(n-1); i>=m; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aut(r,v) __typeof(v) r = (v)
#define each(it,o) for(aut(it,(o).begin()); it!=(o).end(); ++it)
#define reach(it,o) for(aut(it,(o).rbegin()); it!=(o).rend(); ++it)
#define fi first
#define se second
#define debug(...) {cerr<<"[L"<<__LINE__<<"] "; _debug(__VA_ARGS__);}

template<typename T1, typename T2> ostream& operator<<(ostream& o, const pair<T1, T2>& p)
{return o<<"("<<p.first<<", "<<p.second<<")";}
template<typename T>string join(const vector<T>&v, string del=", ")
{stringstream s;rep(i,v.size())s<<del<<v[i];return s.str().substr(del.size());}
template<typename T>ostream& operator<<(ostream& o, const vector<T>&v)
{if(v.size())o<<"["<<join(v)<<"]";return o;}
template<typename T>ostream& operator<<(ostream& o, const vector<vector<T> >&vv)
{int l=vv.size();if(l){o<<endl;rep(i,l){o<<(i==0?"[ ":",\n  ")<<vv[i]<<(i==l-1?" ]":"");}}return o;}
template<typename T>ostream& operator<<(ostream& o, const set<T>& st)
{vector<T> v(st.begin(),st.end());o<<"{ "<<join(v)<<" }";return o;}
template<typename T1, typename T2>ostream& operator<<(ostream& o, const map<T1, T2>& m)
{each(p,m){o<<(p==m.begin()?"{ ":",\n  ")<<*p<<(p==--m.end()?" }":"");}return o;}
inline void _debug(){cerr<<endl;}
template<class First, class... Rest>
void _debug(const First& first, const Rest&... rest){cerr<<first<<" ";_debug(rest...);}

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

const double PI = (1*acos(0.0));
const double INF = 0x3f3f3f3f;
const double INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;
const double mod = 1e9 + 7;

inline void finput(string filename) {
    freopen(filename.c_str(), "r", stdin);
}

int main(){
    ios_base::sync_with_stdio(0);
    // finput("./input");

    int n, t;
    cin >> n >> t;
    vector<pii> P(n);
    rep(i,n){
        int a, b;
        cin >> a >> b;
        P[i] = pii(a, b);
    }
    sort(all(P) ;

    vi dp(t+1, 0);
    rep(i,n){
        int a = P[i].fi;
        int b = P[i].se;
        dp[t] = max(dp[t], dp[t-1] + b);
        RREP(j,a,t){
            dp[j] = max(dp[j], dp[j-a] + b);
        }
    }
    cout << dp[t] << endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:73:17: error: expected ')' before ';' token
   73 |     sort(all(P) ;
      |         ~       ^
Language: C++

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

using namespace std;

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

    int n, t;

    cin >> n >> t;

    vector<pair<int, int>> a(n);

    for (int i = 0; i < n; i++)
        cin >> a[i].first >> a[i].second;

    sort(a.begin(), a.end());

    vector<int> d(t, INT_MIN);
    d[0] = 0;

    int ans = 0;

    for (int i = 0; i < n; i++)
        for (int j = t - 1; j >= 0; j--) {
            if (d[j] == INT_MIN)
                continue;

            int f = a[i].first;
            int s = a[i].second;

            ans = max(ans, d[j] + s);

            if (j + f < t)
                d[j + f] = max(d[j + f], d[j] + s);
        }

    cout << ans << "\n";

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:23:22: error: 'INT_MIN' was not declared in this scope
   23 |     vector<int> d(t, INT_MIN);
      |                      ^~~~~~~
a.cc:4:1: note: 'INT_MIN' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    3 | #include <vector>
  +++ |+#include <climits>
    4 |
Language: C++

#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <set>
#include <bitset>
#include <unordered_map>
#include <queue>
#include <stdio.h>
#include <stdlib.h>

using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)


int main(){
    int N,T;
    cin >> N >> T;
    int ans = 0;
    int dp[N+1][T];
    vector<pair<int,int> > dishes(N);
    rep(i,N){
        int a,b;
        cin >> a >> b;
        dishes[i] = make_pair(a, b);
    }

    sort(dishes.begin(), dishes.end());
    memset(dp, 0, sizeof(dp));
    rep(i,N-1){
        rep(j,T){
            dp[i+1][j] = max(dp[i][j], dp[i+1][j]);
            int nextj = j+dishes[i].first;
            if( T > nextj ){
                dp[i+1][nextj] = max(dp[i][j] + dishes[i].second, dp[i][nextj]);
            }
        }
        ans = max(ans, dp[i+1][T-1] + dishes[i+1].second);
    }
    cout << ans << endl;

}

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

#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <set>
#include <bitset>
#include <unordered_map>
#include <queue>

using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)


int main(){
    int N,T;
    cin >> N >> T;
    int ans = 0;
    int dp[N+1][T];
    vector<pair<int,int> > dishes(N);
    rep(i,N){
        int a,b;
        cin >> a >> b;
        dishes[i] = make_pair(a, b);
    }

    sort(dishes.begin(), dishes.end());
    memset(dp, 0, sizeof(dp));
    rep(i,N-1){
        rep(j,T){
            dp[i+1][j] = max(dp[i][j], dp[i+1][j]);
            int nextj = j+dishes[i].first;
            if( T > nextj ){
                dp[i+1][nextj] = max(dp[i][j] + dishes[i].second, dp[i][nextj]);
            }
        }
        ans = max(ans, dp[i+1][T-1] + dishes[i+1].second);
    }
    cout << ans << endl;

}

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

long long time[3000], umami[3000], n, t, dp1[3000][3001], dp2[3000][3001], max;

main ()
{
    scanf("%lld %lld", &n, &t);

    for(long long i = 0; i < n; i++) scanf("%lld %lld", &time[i], &umami[i]);

    /* dp */
    for(long long tt = 0; tt < t; tt++)
    {
        for (long long nn = 0; nn < n; nn++)
        {
            long long taberu = 0, tabenai = 0;

            if (tt >= time[nn])
            {
                taberu += umami[nn];
                if (nn > 0) taberu += dp1[tt - time[nn]][nn - 1];
            }

            if (tt > 0 && nn > 0)
            {
                tabenai += dp1[tt - 1][nn - 1];
            }

            dp1[tt][nn] = taberu > tabenai ? taberu : tabenai;
        }

        for (long long nn = n - 1; nn >= 0; nn--)
        {
            long long taberu = 0, tabenai = 0;

            if (tt >= time[nn])
            {
                taberu += umami[nn];
                if (nn < n - 1) taberu += dp2[tt - time[nn]][nn + 1];
            }

            if (tt > 0 && nn < n - 1)
            {
                tabenai += dp2[tt - 1][nn + 1];
            }

            dp2[tt][nn] = taberu > tabenai ? taberu : tabenai;
        }
    }

    for (long long tt = 0; tt < t; tt++)
    {
        for (long long nn = 0; nn < n; nn++)
        {
            long long score = umami[nn];
            if (nn > 0) score += dp1[tt][nn - 1];
            if (nn < n - 1) score += dp2[t - 1 - tt][nn + 1];
            if (score > max) max = score;
        }
    }

    print longf("%lld\n", max);
}


Compiler output:
main.c:3:1: error: return type defaults to 'int' [-Wimplicit-int]
    3 | main ()
      | ^~~~
main.c: In function 'main':
main.c:5:5: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
    5 |     scanf("%lld %lld", &n, &t);
      |     ^~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
  +++ |+#include <stdio.h>
    1 | long long time[3000], umami[3000], n, t, dp1[3000][3001], dp2[3000][3001], max;
main.c:5:5: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
    5 |     scanf("%lld %lld", &n, &t);
      |     ^~~~~
main.c:5:5: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c:60:5: error: unknown type name 'print'; did you mean 'int'?
   60 |     print longf("%lld\n", max);
      |     ^~~~~
      |     int
main.c:60:17: error: expected declaration specifiers or '...' before string constant
   60 |     print longf("%lld\n", max);
      |                 ^~~~~~~~
main.c:60:27: error: expected declaration specifiers or '...' before 'max'
   60 |     print longf("%lld\n", max);
      |                           ^~~
Language: C

long long time[3000], umami[3000], n, t, dp1[3000][3001], dp2[3000][3001], max;

main ()
{
    scanf("%d %d", &n, &t);

    for(long long i = 0; i < n; i++) scanf("%d %d", &time[i], &umami[i]);

    /* dp */
    for(long long tt = 0; tt < t; tt++)
    {
        for (long long nn = 0; nn < n; nn++)
        {
            long long taberu = 0, tabenai = 0;

            if (tt >= time[nn])
            {
                taberu += umami[nn];
                if (nn > 0) taberu += dp1[tt - time[nn]][nn - 1];
            }

            if (tt > 0 && nn > 0)
            {
                tabenai += dp1[tt - 1][nn - 1];
            }

            dp1[tt][nn] = taberu > tabenai ? taberu : tabenai;
        }

        for (long long nn = n - 1; nn >= 0; nn--)
        {
            long long taberu = 0, tabenai = 0;

            if (tt >= time[nn])
            {
                taberu += umami[nn];
                if (nn < n - 1) taberu += dp2[tt - time[nn]][nn + 1];
            }

            if (tt > 0 && nn < n - 1)
            {
                tabenai += dp2[tt - 1][nn + 1];
            }

            dp2[tt][nn] = taberu > tabenai ? taberu : tabenai;
        }
    }

    for (long long tt = 0; tt < t; tt++)
    {
        for (long long nn = 0; nn < n; nn++)
        {
            long long score = umami[nn];
            if (nn > 0) score += dp1[tt][nn - 1];
            if (nn < n - 1) score += dp2[t - 1 - tt][nn + 1];
            if (score > max) max = score;
        }
    }

    print longf("%d\n", max);
}


Compiler output:
main.c:3:1: error: return type defaults to 'int' [-Wimplicit-int]
    3 | main ()
      | ^~~~
main.c: In function 'main':
main.c:5:5: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
    5 |     scanf("%d %d", &n, &t);
      |     ^~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
  +++ |+#include <stdio.h>
    1 | long long time[3000], umami[3000], n, t, dp1[3000][3001], dp2[3000][3001], max;
main.c:5:5: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
    5 |     scanf("%d %d", &n, &t);
      |     ^~~~~
main.c:5:5: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c:60:5: error: unknown type name 'print'; did you mean 'int'?
   60 |     print longf("%d\n", max);
      |     ^~~~~
      |     int
main.c:60:17: error: expected declaration specifiers or '...' before string constant
   60 |     print longf("%d\n", max);
      |                 ^~~~~~
main.c:60:25: error: expected declaration specifiers or '...' before 'max'
   60 |     print longf("%d\n", max);
      |                         ^~~
Language: C++

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

using lli = long long;
using pii = pair<int, int>;
using pll = pair<lli, lli>;
template <typename T>
using Vector = vector<vector<T>>;
template <typename T>
using Prior = priority_queue<T>;
template <typename T>
using prior = priority_queue<T, vector<T>, greater<T>>;

#define IOS() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define X first
#define Y second
#define Push push_back
#define ALL(x) x.begin(), x.end()
#define RALL(x) x.rbegin(), x.rend()

const lli mod = 1E9 + 7;

void solve() {
	int n, t;
	cin >> n >> t;

	vector<pii> dish(n + 1);
	for (int i = 1; i <= n; ++i) {
		cin >> dish[i].X >> dish[i].Y;
	}

	int dp[n + 1][t + 1], maxAns = 0;
	memset(dp, 0, sizeof(dp));
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j < t; ++j) {
			dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
			if (j >= dish[i].X) {
				dp[i][j] = max(dp[i][j], dp[i - 1][j - dish[i].X] + dish[i].Y);
			}
			// printf("dp[%d][%d]: %d\n", i, j, dp[i][j]);
		}
		if (dish[i].Y >= T) dp[i][t] = dish[i].Y;
		for (int j = i+1; j <= n; ++j) {
			dp[i][t] = max(dp[i][t], dish[j].Y);
		}
		dp[i][t] += dp[i][t - 1];
		// printf("dp[%d][%d]: %d\n", i, t, dp[i][t]);
		maxAns = max(maxAns, dp[i][t]);
	}

	cout << maxAns << "\n";
}

int main() {
	int t = 1;
	// cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:42:34: error: 'T' was not declared in this scope
   42 |                 if (dish[i].Y >= T) dp[i][t] = dish[i].Y;
      |                                  ^
Language: C++

#include <iostream>
#include <iomanip>
#include <math.h>
#include <algorithm>
#include <vector>
using namespace std;

const int N = 3005;

int dp[N][N];
pair<int, int>a[N];
int n;
int solve(int idx, int rem) {
	if (rem<= 0||idx>=n) {
		return 0;
	}
	int& ret = dp[idx][rem];
	if (ret != -1) {
		return ret;
	}
	int choice1 = solve(idx + 1, rem);
	int choice2 = solve(idx + 1, rem - a[idx].first) + a[idx].second;
	ret = max(choice1, choice2);
	return ret;

	
}

int main() {

	memset(dp, -1, sizeof(dp));
	int  t;
	cin >> n >> t;
	for (int i = 0; i < n; i++) {
		cin >> a[i].first >> a[i].second;
	}
	cout << solve(0, t);


}

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

#include<bits/stdc++.h>
using namespace std;
const int N=3e3+7;
int weight[N],bag[N];
int dp1[N],dp[N];
int pre[N][N];
int mark[N];
struct stu{
    int a,b;
    bool friend operator <(const stu &x,const stu &y){
        return x.b>y.b;
    }
}arr[N];
int main(){
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;i++)
        cin>>arr[i].a>>arr[i].b;

    sort(arr+1,arr+1+n);
    for(int i=2;i<=n;i++){
        for(int j=m-1;j>=arr[i].a;j--){
            if(dp[j]<dp[j-arr[i].a]+arr[i].b){
                dp[j]=dp[j-arr[i].a]+arr[i].b;
                pre[i][j]=1;
            }
        }
    }
    int i=n,j=m;
    while(i>=1&&j>=0){
        if(pre[i][j]) {
            mark[i]=1;
            j=j-weight[i];//第i张歌曲放在了第当背包容量为j-v[i]时，下一步找第i-1张歌曲.（由此的来dp[j]=dp[j-v[i]]+v[i];）
        }
        i--;
    }
    int aa=0;
    if(dp[m]==dp[m-1]) {
        for(int i=1;i<=n;i++) {
            if(mark[i]) conti
                nue ;
            aa=arr[i].b;
            break;
        }
        dp[m]+=aa;
    }
    for(int i=1;i<=n;i++){
        for(int j=m-1;j>=arr[i].a;j--){
            dp1[j]=max(dp1[j],dp1[j-arr[i].a]+arr[i].b);
        }
    }
    cout<<max(dp1[m],dp[m-1]+arr[1].b)<<endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:40:25: error: 'conti' was not declared in this scope
   40 |             if(mark[i]) conti
      |                         ^~~~~
Language: C++

#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>

using namespace std;

const int MAXN = 3050;

int n, tm;
int a[MAXN], b[MAXN];
int dp[2 * MAXN];

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

  scanf("%d %d", &n, &tm);

  for (int i = 0; i < n; i++) {
    scanf("%d %d", &a[i], &b[i]);
  }

  dp[0] = 0;
  for (int i = 0; i < n; i++) {
    for (int j = tm - 1 + a[i]; j >= a[i]; j--) {
      int prev = j - a[i];
      if (prev <= tm - 1) {
        dp[j] = max(dp[j], dp[prev] + b[i]);
      }
    }
  }

  int ans = 0;
  for (int i = 0; i <= tm * 2; i++) {
    ans = max(ans, dp[i]);
  }

  cout << ans << endl;

  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:30:23: error: reference to 'tm' is ambiguous
   30 |   scanf("%d %d", &n, &tm);
      |                       ^~
In file included from /usr/include/time.h:39,
                 from /usr/include/pthread.h:23,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr-default.h:35,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr.h:157,
                 from /usr/include/c++/14/ext/atomicity.h:35,
                 from /usr/include/c++/14/bits/ios_base.h:39,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/x86_64-linux-gnu/bits/types/struct_tm.h:7:8: note: candidates are: 'struct tm'
    7 | struct tm
      |        ^~
a.cc:22:8: note:                 'int tm'
   22 | int n, tm;
      |        ^~
a.cc:38:18: error: reference to 'tm' is ambiguous
   38 |     for (int j = tm - 1 + a[i]; j >= a[i]; j--) {
      |                  ^~
/usr/include/x86_64-linux-gnu/bits/types/struct_tm.h:7:8: note: candidates are: 'struct tm'
    7 | struct tm
      |        ^~
a.cc:22:8: note:                 'int tm'
   22 | int n, tm;
      |        ^~
a.cc:40:19: error: reference to 'tm' is ambiguous
   40 |       if (prev <= tm - 1) {
      |                   ^~
/usr/include/x86_64-linux-gnu/bits/types/struct_tm.h:7:8: note: candidates are: 'struct tm'
    7 | struct tm
      |        ^~
a.cc:22:8: note:                 'int tm'
   22 | int n, tm;
      |        ^~
a.cc:47:24: error: reference to 'tm' is ambiguous
   47 |   for (int i = 0; i <= tm * 2; i++) {
      |                        ^~
/usr/include/x86_64-linux-gnu/bits/types/struct_tm.h:7:8: note: candidates are: 'struct tm'
    7 | struct tm
      |        ^~
a.cc:22:8: note:                 'int tm'
   22 | int n, tm;
      |        ^~
Language: C++

//#include <bits/stdc++.h>
#include <iostream>
using namespace std;
typedef pair <int,int> pii;
int N, T;
pii dish[3005];
int dp[6005];
int main() {
    cin >> N >> T;
    for (int i=1; i<=N; i++){
        scanf("%d %d", &dish[i].first, &dish[i].second);
    }
    sort(dish+1, dish+N+1);
    int ans = 0;
    for (int i=1; i<=N; i++){
        for (int j=0; j<=T-1; j++){
            ans = max(ans, dp[j]+dish[i].second);
        }
        for (int j=T-1; j>=dish[i].first; j--){
            dp[j] = max(dp[j], dp[j-dish[i].first]+dish[i].second);
        }
    }
    cout << ans << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   13 |     sort(dish+1, dish+N+1);
      |     ^~~~
      |     short
Language: C++

const int maxn=3050;
int n,m;
int v[maxn],w[maxn],f[maxn][maxn];
int p[maxn],num;
int main()
{
	cin>>n>>m;
	int maxx=0,pos=0;
	for(int i=1;i<=n;i++) cin>>v[i]>>w[i];
	for(int i=1;i<=n;i++)
    {
        for(int j=0;j<=m-1;j++)
        {
            f[i][j]=f[i-1][j];
            if(j-v[i]>=0) f[i][j]=max(f[i][j],f[i-1][j-v[i]]+w[i]);
        }
    }
	int temp=m-1;
	for(int i=n;i>=1;i--)
    {
        if(temp-v[i]>=0&&f[i][temp]==f[i-1][temp-v[i]]+w[i])
        {
            temp-=v[i];
        }
        else p[++num]=w[i];
    }
	sort(p+1,p+num+1);
	cout<<f[n][m-1]+p[num]<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:9: error: 'cin' was not declared in this scope
    7 |         cin>>n>>m;
      |         ^~~
a.cc:15:35: error: 'max' was not declared in this scope; did you mean 'maxx'?
   15 |             if(j-v[i]>=0) f[i][j]=max(f[i][j],f[i-1][j-v[i]]+w[i]);
      |                                   ^~~
      |                                   maxx
a.cc:27:9: error: 'sort' was not declared in this scope; did you mean 'short'?
   27 |         sort(p+1,p+num+1);
      |         ^~~~
      |         short
a.cc:28:9: error: 'cout' was not declared in this scope
   28 |         cout<<f[n][m-1]+p[num]<<endl;
      |         ^~~~
a.cc:28:33: error: 'endl' was not declared in this scope
   28 |         cout<<f[n][m-1]+p[num]<<endl;
      |                                 ^~~~
Language: C++

#include<iostream>
#include<queue>
#include<memory>
#include<map>
#include<set>
#include<unordered_map>
#include<array>
#include<vector>

using namespace std;
using vec = vector<int>;
using mat = vector<vec>;

int main()
{
	int N, T;
	cin >> N >> T;

	mat dp(N + 1, vec(T + 1));
	vector<pair<int, int>> Dish;

	for (int i = 0; i < N; ++i)
	{
		pair<int, int> p;
		cin >> p.first >> p.second;
		Dish.emplace_back(p);
	}

	sort(Dish.begin(), Dish.end());

	for (int i = 0; i < N; ++i)
	{
		for (int j = 0; j < T + 1; ++j)
		{
			int k = min(j + Dish[i].first, T);
			dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
			if (j != T)
			{
				dp[i + 1][k] = max(dp[i + 1][j], dp[i][j] + Dish[i].second);
			}
		}
	}

	int ans = 0;
	for (int i = 0; i < T + 1; ++i)
	{
		ans = max(ans, dp[N][i]);
	}
	cout << ans << endl;

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:29:9: error: 'sort' was not declared in this scope; did you mean 'short'?
   29 |         sort(Dish.begin(), Dish.end());
      |         ^~~~
      |         short
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define pb push_back
#define lb(v,k) lower_bound(all(v),k)-v.begin()
#define chmin(x,y) if(x>y)x=y
#define chmax(x,y) if(x<y)x=y
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll,vector<ll>,greater<ll>> SPQ;
using vi=vector<ll>;
using vvi=vector<vector<ll>>;
using vc=vector<char>;
using vvc=vector<vector<char>>;
ll inf=100100100100;
const int mod=1000000007;
int main(){
   int n,w;cin>>n>>w;w--;
   vvi dp(n,vi(w+1));
   vi omosa(n),kachi(n);
   rep(i,n)cin>>omosa[i]>>kachi[i];
   rep(i,n){
      rep(j,w+1){
         if(j>=omosa[i]){
            dp[i][j]=kachi[i];
            if(i>0){
               chmax(dp[i][j],dp[i-1][j-omosa[i]]+kachi[i]);
               chmax(dp[i][j],dp[i-1][j]);
            }
         }
         else{
            if(i>0)dp[i][j]=dp[i-1][j];
         }
      }
   }
  reverse(all(omosa));
  reverse(all(kachi));
  vvi dp2(n,vi(w+1));
  rep(i,n){
      rep(j,w+1){
         if(j>=omosa[i]){
            dp2[i][j]=kachi[i];
            if(i>0){
               chmax(dp2[i][j],dp2[i-1][j-omosa[i]]+kachi[i]);
               chmax(dp2[i][j],dp2[i-1][j]);
            }
         }
         else{
            if(i>0)dp2[i][j]=dp2[i-1][j];
         }
      }
   }
  rep(k,w+1)chmax(ans,max(dp[n-2][w-k]+kachi[0],dp2[n-2][k]+kachi[n-1]));
   REP(i,1,n-1)rep(k,w+1)chmax(ans,dp[n-i-2][w-k]+dp2[i-1][k]+kachi[i]);
  cout<<ans<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:58:19: error: 'ans' was not declared in this scope; did you mean 'abs'?
   58 |   rep(k,w+1)chmax(ans,max(dp[n-2][w-k]+kachi[0],dp2[n-2][k]+kachi[n-1]));
      |                   ^~~
a.cc:10:23: note: in definition of macro 'chmax'
   10 | #define chmax(x,y) if(x<y)x=y
      |                       ^
a.cc:59:32: error: 'ans' was not declared in this scope; did you mean 'abs'?
   59 |    REP(i,1,n-1)rep(k,w+1)chmax(ans,dp[n-i-2][w-k]+dp2[i-1][k]+kachi[i]);
      |                                ^~~
a.cc:10:23: note: in definition of macro 'chmax'
   10 | #define chmax(x,y) if(x<y)x=y
      |                       ^
a.cc:60:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   60 |   cout<<ans<<endl;
      |         ^~~
      |         abs