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

#include<bits/stdc++.h>
using namespace std;
int n;
long long value[2][3];
long long dfs(long long capital, long long i, vector<pair<long long,long long>> &product){
  if(product.size() == 0) return capital;
  else if(i == product.size()-1)　return capital/product[i].first*product[i].second + capital%product[i].first;
  long long ret=0;
  for(int j=0;j*product[i].first<=capital;j++)　ret=max(ret,dfs(capital-j*product[i].first,i+1,product) + j*product[i].second);
  return ret;
}
int main(){
  cin >> n;
  for(int i=0;i<2;i++) for(int j=0;j<3;j++) cin >> value[i][j];
  vector<pair<long long,long long>> forth,back;
  for(int j=0;j<3;j++){
    if(value[0][j]<value[1][j]) forth.push_back({value[0][j],value[1][j]});
    if(value[0][j]>value[1][j]) back.push_back({value[1][j],value[0][j]});                                             
  }
  cout << dfs(dfs(n,0,forth),0,back) << endl;
}

Compiler output:
a.cc:7:33: error: extended character 　 is not valid in an identifier
    7 |   else if(i == product.size()-1)　return capital/product[i].first*product[i].second + capital%product[i].first;
      |                                 ^
a.cc:9:47: error: extended character 　 is not valid in an identifier
    9 |   for(int j=0;j*product[i].first<=capital;j++)　ret=max(ret,dfs(capital-j*product[i].first,i+1,product) + j*product[i].second);
      |                                               ^
a.cc: In function 'long long int dfs(long long int, long long int, std::vector<std::pair<long long int, long long int> >&)':
a.cc:7:33: error: '\U00003000return' was not declared in this scope; did you mean 'sigreturn'?
    7 |   else if(i == product.size()-1)　return capital/product[i].first*product[i].second + capital%product[i].first;
      |                                 ^~~~~~~~
      |                                 sigreturn
a.cc:9:47: error: '\U00003000ret' was not declared in this scope
    9 |   for(int j=0;j*product[i].first<=capital;j++)　ret=max(ret,dfs(capital-j*product[i].first,i+1,product) + j*product[i].second);
      |                                               ^~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int f[4][25000001],v[4],c[4];
void beibao(int C){
	memset(f,0,sizeof(f));
	for(int i=1;i<=3;i++){
		for(int j=0;j<=C;j++){
			if(j>=v[i])f[i][j]=max(f[i-1][j],f[i][j-v[i]]+c[i]);
		}
	}
	return f[3][C];
}
int main()
{
	int n;cin>>n;
	int ga,sa,ba,gb,sb,bb;
	cin>>ga>>sa>>ba>>gb>>sb>>bb;
	long long ans=n;
	v[1]=ga;c[1]=gb-ga;
	v[2]=sa;c[2]=sb-sa;
	v[3]=ba;c[3]=bb-ba;
	ans+=beibao(ans);
	v[1]=gb;c[1]=-c[1];
	v[2]=sb;c[2]=-c[2];
	v[3]=bb;c[3]=-c[3];
	ans+=beibao(ans);
	cout<<ans<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'void beibao(int)':
a.cc:11:22: error: return-statement with a value, in function returning 'void' [-fpermissive]
   11 |         return f[3][C];
      |                ~~~~~~^
a.cc: In function 'int main()':
a.cc:22:20: error: void value not ignored as it ought to be
   22 |         ans+=beibao(ans);
      |              ~~~~~~^~~~~
a.cc:26:20: error: void value not ignored as it ought to be
   26 |         ans+=beibao(ans);
      |              ~~~~~~^~~~~
Language: C++

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

typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;
typedef vector< vector< vector<ll> > > vvvint;
typedef vector<string> vstring;
typedef vector< vector<string> > vvstring;
typedef vector<char> vchar;
typedef vector< vector<char> > vvchar;
typedef vector<long double> vdouble;
typedef vector< vector<long double> > vvdouble;
typedef vector< vector< vector<long double> > > vvvdouble;
typedef pair<ll,ll> pint;
typedef vector<pint> vpint;
typedef vector<bool> vbool;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define ALL(obj) (obj).begin(), (obj).end()
// #define LLONG_MAX 9223372036854775806
#define MOD 1000000007
const double PI=3.14159265358979323846;
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; }
template<typename T> T Ceil(T a, T b){return (a+b-1)/b;}

int dy[]={0, 0, 1, -1, 1, -1, -1, 1};
int dx[]={1, -1, 0, 0, 1, 1, -1, -1};

void printv(vint &v){
    for(auto e:v) cout<<e<<" ";
        cout<<endl;
    }

int main() {
    cout<<fixed<<setprecision(10);

    ll n; cin>>n;
    vvint a(2, vint(4, 1));
    rep(i,2)rep(j,3) cin>>a[i][j];

    auto f = [&](ll N, vint &w, vint &v){
        vvint dp(5, vint(N+1, -1));
        dp[0][0] = 0;
        rep(i,4){
            rep(j,N+1){
                chmax(dp[i+1][j], dp[i][j]);
                if(j+w[i] > N) continue;
                if(dp[i][j] != -1){
                    chmax(dp[i+1][j+w[i]], dp[i][j] + v[i]);
                }
                if(dp[i+1][j] != -1){
                    chmax(dp[i+1][j+w[i]], dp[i+1][j] + v[i]);
                }
            }
        }

        return *max_element(ALL(dp[4]));
    };

    cout<<f(f(n, v[0], v[1]), v[1], v[0])<<endl;


    return 0;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:72:18: error: 'v' was not declared in this scope
   72 |     cout<<f(f(n, v[0], v[1]), v[1], v[0])<<endl;
      |                  ^
Language: C++

#include <iostream>

using namespace std;

const int METALS = 3;

int trades(int acorns, const int * pricesSrc, const int * pricesDst) {
    int profit[3];
    for(int i = 0; i < 3; i++) {
        profit[i] = pricesDst[i] - pricesSrc[i];
    }

    int gains[acorns + 1];
    memset(gains, 0, sizeof gains);

    for(int i = 0; i <= acorns; i++) {
        for(int j = 0; j < METALS; j++) {
            if (pricesSrc[j] <= i) {
                gains[i] = max(gains[i], gains[i - pricesSrc[j]] + profit[j]);
            }
        }
    }
    return gains[acorns];
}

int main() {
    int acorns;
    cin >> acorns;
    int pricesA[METALS];
    for(int i = 0; i < METALS; i++) {
        cin >> pricesA[i];
    }
    int pricesB[METALS];
    for(int i = 0; i < METALS; i++) {
        cin >> pricesB[i];
    }

    int acornsAB = acorns + trades(acorns, pricesA, pricesB);
    int acornsBA = acornsAB + trades(acornsAB, pricesB, pricesA);

    cout << acornsBA;

    return 0;
}


Compiler output:
a.cc: In function 'int trades(int, const int*, const int*)':
a.cc:14:5: error: 'memset' was not declared in this scope
   14 |     memset(gains, 0, sizeof gains);
      |     ^~~~~~
a.cc:2:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    1 | #include <iostream>
  +++ |+#include <cstring>
    2 |
Language: C++

//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define trav(x,a) for (const auto& x: a)
#define sz(x) (int)(x).size()
#define mem(a,v) memset((a), (v), sizeof (a))
#define enl printf("\n")
#define case(t) printf("Case #%d: ", (t))
#define ni(n) scanf("%d", &(n))
#define nl(n) scanf("%lld", &(n))
#define nai(a, n) for (int _i = 0; _i < (n); _i++) ni(a[_i])
#define nal(a, n) for (int _i = 0; _i < (n); _i++) nl(a[_i])
#define pri(n) printf("%d\n", (n))
#define prl(n) printf("%lld\n", (n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define vii vector<pii>
#define vll vector<pll>
#define vi vector<int>
#define vl vector<long long>
#define pb push_back
#define mp make_pair
#define st first
#define nd second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef cc_hash_table<int,int,hash<int>> ht;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;
const double pi = acos(-1);
const int mod = 1e9 + 7;
const int inf = 1e9 + 7;
const int N = 1e6 + 5;
const double eps = 1e-9;
ll a[3][3], b[3], it[3];

int main() {
  int n; scanf("%d", &n);
  for (int i = 0; i < 2; i++)
    for (int j = 0; j < 3; j++)
      scanf("%lld", &a[i][j]);
  ll ans = n;
  int c = 0;
  for (int i = 0; i < 3; i++)
    c += a[0][i] < a[1][i];
  for (int i = 0; i < 3; i++)
    it[i] = i;
  sort(it, it+3, [](int x, int y) { return a[1][x]-a[0][x] > a[1][y]-a[0][y]; });
  if (c == 3 || c == 0) {
    for (int i = 0; i < 3; i++) {
      b[i] = abs(a[0][i] - a[1][i]);
      a[0][i] = max(a[0][i], a[1][i]);
      a[1][i] = a[0][i] - b[i];
    }
    for (int i = 0; i <= n; i += a[1][0])
      for (int j = 0; j+i <= n; j += a[1][1])
        ans = max(ans, i/a[1][0] * a[0][0] + j/a[1][1] * a[0][1] + ((n-i-j)/a[1][2]) * a[0][2] + ((n-i-j) % a[1][2]));
  } else if (c == 2) {
    for (int i = 0; i <= n; i += a[0][it[0]])
      for (int j = 0; j+i <= n; j += a[0][it[1]]) {
        ll nx = i/a[0][it[0]] * a[1][it[0]] + j/a[0][it[1]] * a[1][it[1]] + (n-i-j);
        ans = max(ans, (nx/a[1][it[2]]) * a[0][it[2]] + (nx % a[1][it[2]]));
      }
  } else {
    for (int i = 0; i <= n; i += a[0][it[0]]) {
      ll nx = i/a[0][it[0]] * a[1][it[0]] + n - i;
      // for (int j = 0; j <= nx; j += a[1][it[1]])
      for (ll j: {0, nx})
        ans = max(ans, j/a[1][it[1]]*a[0][it[1]] + ((nx-j)/a[1][it[2]]) * a[0][it[2]] + ((nx-j) % a[1][it[2]]));
    }
  }
  printf("%lld\n", ans);
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:69:24: error: unable to deduce 'std::initializer_list<auto>&&' from '{0, nx}'
   69 |       for (ll j: {0, nx})
      |                        ^
a.cc:69:24: note:   deduced conflicting types for parameter 'auto' ('int' and 'long long int')
Language: C++

#include<bits/stdc++.h>
using namespace std ; 
#define ll long long 
signed main()
{
	ll g[3],b[3],s[3],cnt=0,n; 
	cin >> n ; 
	cin >> g[1] >> s[1] >> b[1] ; 
	cin >> g[2] >> s[2] >> b[2] ; 
	ll p1 = 0 , p2 = 0 , p3 = 0 ; 
	p1 ^= ( g[1] >= g[2] ) ;
	p2 ^= ( s[1] >= s[2] ) ; 
	p3 ^= ( b[1] >= b[2] ) ;
	if ( p1 && p2 && p3 ) {
		for ( ll i = 0 ; i <= n/g[2] ; i++ ) {
			for ( ll j = 0 ; j <= (n-i*g[2])/s[2] ; j++ ) {
				int k = (n-i*g[2]-j*s[2])/b[2] ; 
				cnt = max(cnt,i*(g[1]-g[2])+j*(s[1]-s[2])+k*(b[1]-b[2])) ;
			}
		}
		n += cnt ; 
	}
	else if ( p1 && p2 )
	{	
		n += n/b[1]*(b[2]-b[1]) ; 
		for ( ll i = 0 ; i <= n/g[2] ; i++ ) {
			ll k = (n-i*g[2])/s[2] ; 
			cnt = max(cnt,i*(g[1]-g[2])+k*(s[1]-s[2])) ; 
		}
		n += cnt ; 
	}		
 	else if ( p2 && p3 ) {
 		n += n/g[1]*(g[2]-g[1]) ; 
 		for ( l i = 0 ; i <= n/s[2] ; i++ ) {
			ll k = (n-i*s[2])/b[2] ; 
			cnt = max(cnt,i*(s[1]-s[2])+k*(b[1]-b[2])) ; 
		}
		n += cnt ; 
 	}
	else if ( p1 && p3 ) {
		n += n/s[1]*(s[2]-s[1]) ;
		for ( l i = 0 ; i <= n/g[2] ; i++ ) {
			ll k = (n-i*g[2])/b[2] ; 
			cnt = max(cnt,i*(g[1]-g[2])+k*(b[1]-b[2])) ; 
		}
		n += cnt ;
	}
	else if ( p1 ) {
		for ( ll i = 0 ; i <= n/s[1] ; i++ ) {
			ll k = (n-i*s[1])/b[1] ; 
			cnt = max(cnt,i*(s[2]-s[1])+k*(b[2]-b[1])) ; 
		}
		n += cnt ;
		n += n/g[2]*(g[1]-g[2]) ;
	}
	else if ( p2 ) {
		for ( ll i = 0 ; i <= n/g[1] ; i++ ) {
			ll k = (n-i*g[1])/b[1] ; 
			cnt = max(cnt,i*(g[2]-g[1])+k*(b[2]-b[1])) ; 
		}
		n += cnt ; 
		n += n/s[2]*(s[1]-s[2]) ;
	}
	else if ( p3 ) {
		for ( ll i = 0 ; i <= n/g[1] ; i++ ) {
			 ll  k = (n-i*g[1])/s[1] ; 
			cnt = max(cnt,i*(g[2]-g[1])+k*(s[2]-s[1])) ; 
		}
		n += cnt ; 
		n += n/b[2]*(b[1]-b[2]) ;
	}
	else {
		for ( ll i = 0 ; i <= n/g[1] ; i++ ) {
			for ( ll j = 0 ; j <= (n-i*g[1])/s[1] ; j++ ) {
				int k = n - i*g[1] - j*s[1] ; 
				cnt= max(cnt,i*(g[2]-g[1])+j*(s[2]-s[1])+k*(b[2]-b[1])) ; 
			}
		}
		n += cnt ; 
	}
	cout << n ; 
}

Compiler output:
a.cc: In function 'int main()':
a.cc:34:23: error: 'l' was not declared in this scope
   34 |                 for ( l i = 0 ; i <= n/s[2] ; i++ ) {
      |                       ^
a.cc:34:33: error: 'i' was not declared in this scope
   34 |                 for ( l i = 0 ; i <= n/s[2] ; i++ ) {
      |                                 ^
a.cc:42:23: error: 'l' was not declared in this scope
   42 |                 for ( l i = 0 ; i <= n/g[2] ; i++ ) {
      |                       ^
a.cc:42:33: error: 'i' was not declared in this scope
   42 |                 for ( l i = 0 ; i <= n/g[2] ; i++ ) {
      |                                 ^
Language: C++

#include<bits/stdc++.h>
using namespace std ; 
#define int long long 
signed main()
{
	int g[3],b[3],s[3],cnt=0,n; 
	cin >> n ; 
	cin >> g[1] >> s[1] >> b[1] ; 
	cin >> g[2] >> s[2] >> b[2] ; 
	int p1 = 0 , p2 = 0 , p3 = 0 ; 
	p1 ^= ( g[1] >= g[2] ) ;
	p2 ^= ( s[1] >= s[2] ) ; 
	p3 ^= ( b[1] >= b[2] ) ;
	if ( p1 && p2 && p3 ) {
		for ( int i = 0 ; i <= n/g[2] ; i++ ) {
			for ( int j = 0 ; j <= (n-i*g[2])/s[2] ; j++ ) {
				int k = (n-i*g[2]-j*s[2])/b[2] ; 
				cnt = max(cnt,i*(g[1]-g[2])+j*(s[1]-s[2])+k*(b[1]-b[2])) ;
			}
		}
		n += cnt ; 
	}
	else if ( p1 && p2 )
	{	
		n += n/b[1]*(b[2]-b[1]) ; 
		for ( int i = 0 ; i <= n/g[2] ; i++ ) {
			int k = (n-i*g[2])/s[2] ; 
			cnt = max(cnt,i*(g[1]-g[2])+k*(s[1]-s[2])) ; 
		}
		n += cnt ; 
	}		
 	else if ( p2 && p3 ) {
 		n += n/g[1]*(g[2]-g[1]) ; 
 		for ( int i = 0 ; i <= n/s[2] ; i++ ) {
			int k = (n-i*s[2])/b[2] ; 
			cnt = max(cnt,i*(s[1]-s[2])+k*(b[1]-b[2])) ; 
		}
		n += cnt ; 
 	}
	else if ( p1 && p3 ) {
		n += n/s[1]*(s[2]-s[1]) ;
		for ( int i = 0 ; i <= n/g[2] ; i++ ) {
			int k = (n-i*g[2])/b[2] ; 
			cnt = max(cnt,i*(g[1]-g[2])+k*(b[1]-b[2])) ; 
		}
		n += cnt  
	}
	else if ( p1 ) {
		for ( int i = 0 ; i <= n/s[1] ; i++ ) {
			int k = (n-i*s[1])/b[1] ; 
			cnt = max(cnt,i*(s[2]-s[1])+k*(b[2]-b[1])) ; 
		}
		n += cnt + (n+cnt)/g[2]*(g[1]-g[2]) ;
	}
	else if ( p2 ) {
		for ( int i = 0 ; i <= n/g[1] ; i++ ) {
			int k = (n-i*g[1])/b[1] ; 
			cnt = max(cnt,i*(g[2]-g[1])+k*(b[2]-b[1])) ; 
		}
		n += cnt + (n+cnt)/s[2]*(s[1]-s[2]) ;
	}
	else if ( p3 ) {
		for ( int i = 0 ; i <= n/g[1] ; i++ ) {
			int k = (n-i*g[1])/s[1] ; 
			cnt = max(cnt,i*(g[2]-g[1])+k*(s[2]-s[1])) ; 
		}
		n += cnt + (n+cnt)/b[2]*(b[1]-b[2]) ;
	}
	else {
		for ( int i = 0 ; i <= n/g[1] ; i++ ) {
			for ( int j = 0 ; j <= (n-i*g[1])/s[1] ; j++ ) {
				int k = n - i*g[1] - j*s[1] ; 
				cnt= max(cnt,i*(g[2]-g[1])+j*(s[2]-s[1])+k*(b[2]-b[1])) ; 
			}
		}
		n += cnt ; 
	}
	cout << n ; 
}

Compiler output:
a.cc: In function 'int main()':
a.cc:46:25: error: expected ';' before '}' token
   46 |                 n += cnt
      |                         ^
      |                         ;
   47 |         }
      |         ~
Language: C++

#include<bits/stdc++.h>
using namespace std ; 
#define int long long 
signed main()
{
	int g[3],b[3],s[3],cnt=0,n; 
	cin >> n ; 
	cin >> g[1] >> s[1] >> b[1] ; 
	cin >> g[2] >> s[2] >> b[2] ; 
	int p1 = 0 , p2 = 0 , p3 = 0 ; 
	p1 ^= ( g[1] >= g[2] ) ;
	p2 ^= ( s[1] >= s[2] ) ; 
	p3 ^= ( b[1] >= b[2] ) ;
	if ( p1 && p2 && p3 ) {
		for ( int i = 0 ; i <= n/g[2] ; i++ ) {
			for ( int j = 0 ; j <= (n-i*g[2])/s[2] ; j++ ) {
				int k = (n-i*g[2]-j*s[2])/b[2] ; 
				cnt = max(cnt,i*(g[1]-g[2])+j*(s[1]-s[2])+k*(b[1]-b[2])) ;
			}
		}
		n += cnt ; 
	}
	else if ( p1 && p2 )
	{
		for ( int i = 0 ; i <= n/g[2] ; i++ ) {
			int k = (n-i*g[2])/s[2] ; 
			cnt = max(cnt,i*(g[1]-g[2])+k*(s[1]-s[2])) ; 
		}
		n += cnt + (n+cnt)/b[1]*(b[2]-b[1]) ; 
	}		
 	else if ( p2 && p3 ) {
 		for ( int i = 0 ; i <= n/s[2] ; i++ ) {
			int k = (n-i*s[2])/b[2] ; 
			cnt = max(cnt,i*(s[1]-s[2])+k*(b[1]-b[2])) ; 
		}
		n += cnt + (n+cnt)/g[1]*(g[2]-g[1]) ;
 	}
	else if ( p1 && p3 ) {
		for ( int i = 0 ; i <= n/g[2] ; i++ ) {
			int k = (n-i*g[2])/b[2] ; 
			cnt = max(cnt,i*(g[1]-g[2])+k*(b[1]-b[2])) ; 
		}
		n += cnt + (n+cnt)/s[1]*(s[2]-s[1]) ;
	}
	else if ( p1 ) {
		for ( int i = 0 ; i <= n/s[1] ; i++ ) {
			int k = (n-i*s[1])/b[1] ; 
			cnt = max(cnt,i*(s[2]-s[1])+k*(b[2]-b[1])) ; 
		}
		n += cnt + (n+cnt)/g[2]*(g[1]-g[2]) ;
	}
	else if ( p2 ) {
		for ( int i = 0 ; i <= n/g[1] ; i++ ) {
			int k = (n-i*g[1])/b[1] ; 
			cnt = max(cnt,i*(g[2]-g[1])+k*(b[2]-b[1])) ; 
		}
		n += cnt + (n+cnt)/s[2]*(s[1]-s[2]) ;
	}
	else if ( p3 ) {
		for ( int i = 0 ; i <= n/g[1] ; i++ ) {
			int k = (n-i*g[1])/s[1] ; 
			cnt = max(cnt,i*(g[2]-g[1])+k*(s[2]-s[1])) ; 
		}
		n += cnt + (n+cnt)/b[2]*(b[1]-b[2]) ;
	}
	else {
		for ( int i = 0 ; i <= n/g[1] ; i++ ) {
			for ( int j = 0 ; j <= (n-i*g[1])/s[1] ; j++ ) {
				int k = n - i*g[1] - h*s[1] ; 
				cnt= max(cnt,i*(g[2]-g[1])+j*(s[2]-s[1])+k*(b[2]-b[1])) ; 
			}
		}
	}
	cout << n ; 
}

Compiler output:
a.cc: In function 'int main()':
a.cc:69:54: error: 'h' was not declared in this scope
   69 |                                 int k = n - i*g[1] - h*s[1] ;
      |                                                      ^
Language: C++

#include<bits/stdc++.h>
using namespace std ; 
#define int long long
int main()
{
	long long g[3],b[3],s[3],cnt=0,n; 
	cin >> n ; 
	for ( int i = 1 ; i <= 3 ; i++ ) cin >> g[1] >> s[1] >> b[1] ; 
	for ( int i = 1 ; i <= 3 ; i++ ) cin >> g[2] >> s[2] >> b[2] ; 
	int p1 = 1 , p2 = 1 , p3 = 1 ; 
	p1 ^= ( g[1] < g[2] ) ;
	p2 ^= ( s[1] < s[2] ) ; 
	p3 ^= ( b[1] < b[2] ) ; 
	if ( p1 && p2 && p3 ) {
		for ( long long i = 0 ; i <= n/g[1] ; i++ ) {
			for ( long long j = 0 ; j <= (n-i*g[1])/s[1] ; j++ ) {
				int k = (n-i*g[1]-j*s[1])/b[1] ; 
				cnt = max(cnt,i*(g[1]-g[2])+j*(s[1]-s[2])+k*(b[1]-b[2])) ;
			}
		}
		n += cnt ; 
	}
	else if ( p1 && p2 )
	{
		for ( int i = 0 ; i <= n/g[1] ; i++ ) {
			int k = (n-i*g[1])/s[1] ; 
			cnt = max(cnt,i*(g[1]-g[2])+k*(s[1]-s[2])) ; 
		}
		n += cnt + (n+cnt)/b[2]*(b[2]-b[1]) ; 
	}		
 	else if ( p2 && p3 ) {
 		for ( int i = 0 ; i <= n/s[1] ; i++ ) {
			int k = (n-i*s[1])/b[1] ; 
			cnt = max(cnt,i*(s[1]-s[2])+k*(b[1]-b[2])) ; 
		}
		n += cnt + (n+cnt)/g[2]*(g[2]-g[1]) ;
 	}
	else if ( p1 && p3 ) {
		for ( int i = 0 ; i <= n/g[1] ; i++ ) {
			int k = (n-i*g[1])/b[1] ; 
			cnt = max(cnt,i*(g[1]-g[2])+k*(b[1]-b[2])) ; 
		}
		n += cnt + (n+cnt)/s[2]*(s[2]-s[1]) ;
	}
	else if ( p1 ) {
		for ( int i = 0 ; i <= n/s[2] ; i++ ) {
			int k = (n-i*s[2])/b[2] ; 
			cnt = max(cnt,i*(s[2]-s[1])+k*(b[2]-b[1])) ; 
		}
		n += cnt + (n+cnt)/s[1]*(s[1]-s[2]) ;
	}
	else if ( p2 ) {
		for ( int i = 0 ; i <= n/g[2] ; i++ ) {
			int k = (n-i*g[2])/b[2] ; 
			cnt = max(cnt,i*(g[2]-g[1])+k*(b[2]-b[1])) ; 
		}
		n += cnt + (n+cnt)/s[1]*(s[1]-s[2]) ;
	}
	else {
		for ( int i = 0 ; i <= n/g[2] ; i++ ) {
			int k = (n-i*g[2])/s[2] ; 
			cnt = max(cnt,i*(g[2]-g[1])+k*(s[2]-s[1])) ; 
		}
		n += cnt + (n+cnt)/b[1]*(b[1]-b[2]) ;
	}
	cout << n ; 
}

Compiler output:
cc1plus: error: '::main' must return 'int'
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
 
int n;
ll knap(ll n, vector<pair<int,int>> &v) {
  vector<ll> dp(n+10, 0);
  iota(dp.begin(), dp.end(), 0);
  for(int j=0;j<v.size();j++) {
    //cout << "knap " << v[j].first  << " " << v[j].second <<endl;
    for(int i=0;i<=n-v[j].first;i++) {
      //cout << dp[i+v[j].first] << " " << dp[i] + v[j].second <<endl;
      dp[i+v[j].first] = max(dp[i+v[j].first],dp[i]+v[j].second);
    }
  }
//  for(int i=0;i<n;i++) cout << dp[i] <<" "; cerr <<endl;
  return dp[n];
}
int main(){
  cin.tie(0); ios_base::sync_with_stdio(0);
  cin >> n;
  vector<int> A(3), B(3);
  for(int i=0;i<3;i++) cin >> A[i];
  for(int i=0;i<3;i++) cin >> B[i];
  for(int i=0;i<3;i++) {
    if (A[i] > B[i]) {
      swap(A[i], A[2]), swap(B[i], B[2]);
    }
  }
  int cnt = 0;
  vector<pair<int,int>> v1, v2;
  v1.push_back(1,1);
  for(int i=0;i<3;i++) {
    if (A[i]<=B[i]) {
      cnt++;
      v1.push_back({A[i], B[i]});
    }
    else v2.push_back({B[i], A[i]});
  }
  ll tot=knap(n, v1);
  tot=knap(tot,v2);
  cout << tot <<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:33:15: error: no matching function for call to 'std::vector<std::pair<int, int> >::push_back(int, int)'
   33 |   v1.push_back(1,1);
      |   ~~~~~~~~~~~~^~~~~
In file included from /usr/include/c++/14/vector:66,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_vector.h:1283:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; value_type = std::pair<int, int>]'
 1283 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1283:7: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_vector.h:1300:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(value_type&&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; value_type = std::pair<int, int>]'
 1300 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1300:7: note:   candidate expects 1 argument, 2 provided
Language: C++

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		String[] sa = br.readLine().split(" ");
		int[] a = new int[3];
		for (int i = 0; i < 3; i++) {
			a[i] = Integer.parseInt(sa[i]);
		}
		sa = br.readLine().split(" ");
		int[] b = new int[3];
		for (int i = 0; i < 3; i++) {
			b[i] = Integer.parseInt(sa[i]);
		}
		int[] ab = new int[3];
		int[] ba = new int[3];
		for (int i = 0; i < 3; i++) {
			ab[i] = b[i] - a[i];
			ba[i] = a[i] - b[i];
		}
		br.close();

		int[] dp1 = new int[n + 1];
		for (int i = 0; i < 3; i++) {
			for (int w = 0; w + a[i] <= n; w++) {
				dp1[w + a[i]] = Math.max(dp1[w + a[i]], dp1[w] + ab[i]);
			}
		}
		int m = dp1[n] + n;
		long[] dp2 = new long[m + 1];
		for (int i = 0; i < 3; i++) {
			for (int w = 0; w + b[i] <= m; w++) {
				dp2[w + b[i]] = Math.max(dp2[w + b[i]], dp2[w] + ba[i]);
			}
		}
		System.out.println(dp2[m] + m);
	}
}


Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import java.io.BufferedReader;
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:2:1: error: 'import' does not name a type
    2 | import java.io.InputStreamReader;
      | ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:4:1: error: expected unqualified-id before 'public'
    4 | public class Main {
      | ^~~~~~
Language: C++

#include "bits/stdc++.h"
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

using ll = long long;

int main() {
    ll N, gA, sA, bA, gB, sB, bB;
    cin >> N >> gA >> sA >> bA >> gB >> sB >> bB;
    if (gA <= gB && sA <= sB && bA <= bB) {
        ll ans = 0;
        rep(g, N / gA + 1) {
            rep(s, (N - g * gA) / sA + 1) {
                ll b = (N - g * gA - s * sA) / bA;
                ll c = N + g * (gB - gA) + s * (sB - sA) + b * (bB - bA);
                if (c > ans) ans = c;
            }
        }
        cout << ans << endl;
        return 0;
    }
    if (gA >= gB && sA >= sB && bA >= bB) {
        ll ans = 0;
        rep(g, N / gB + 1) {
            rep(s, (N - g * gB) / sB + 1) {
                ll b = (N - g * gB - s * sB) / bB;
                ll c = N + g * (gA - gB) + s * (sA - sB) + b * (bA - bB);
                if (c > ans) ans = c;
            }
        }
        cout << ans << endl;
        return 0;
    }
    ll ans = 0;
    vector<vector<ll>> v = {{gA * sB * bB, gA, gB}, {gB * sA * bB, sA, sB}, {gB * sB * bA, bA, bB}};
    sort(v.begin(), v.end());
    if (v[1][0] < gB * sB * bB) {
        rep(i, N / v[0][1] + 1) {
            ll M = N - i * v[0][1];
            ll j = M / v[1][1];
            ll c = M - j * v[1][1] + i * v[0][2] + j * v[1][2];
            if (c > ans) ans = c;
        }
        ans = ans - ans / v[2][2] + ans / v[2][2] * v[2][1];
        ans += ans / v[2][1] * (virtual[2][2] -v[2][1]);
    } else {
        ll L = N - N / v[0][1] + N / v[0][1] * v[0][2];
        rep(k, 10000) {
            ll i = L / v[2][1] - k;
            if (i < 0) break;
            ll M = L - i * v[2][1];
            ll j = M / v[1][1];
            ll c = M - j * v[1][1] + i * v[2][2] + j * v[1][2];
            if (c > ans) ans = c;
        }
    }
    cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:45:33: error: expected primary-expression before 'virtual'
   45 |         ans += ans / v[2][1] * (virtual[2][2] -v[2][1]);
      |                                 ^~~~~~~
a.cc:45:33: error: expected ')' before 'virtual'
   45 |         ans += ans / v[2][1] * (virtual[2][2] -v[2][1]);
      |                                ~^~~~~~~
      |                                 )
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)n; i++)
using ll = long long;
using P = pair<int,int>;
using int = ll;

int solve(vector<P> p, int n) {
  int ans = n;
  if(p.size() == 1) {
    ans = n/p[0].first*p[0].second +  n % p[0].first; 
  } else if(p.size() == 2) {
    for(int i = 0; i < n; i++) {
      int d = n - p[0].first*i;
      if(d < 0) break;
      ans = max(ans,p[0].second*i + d/p[1].first*p[1].second + d % p[1].first);
    }
  } else if(p.size() == 3) {
    for(int i = 0; i < n; i++) {
      for(int j = 0; j < n; j++) {
      int d = n - p[0].first*i - p[1].first*j;
      if(d < 0) continue;
      ans = max(ans,p[0].second*i + p[1].second*j + d/p[2].first*p[2].second + d % p[2].first);
      }
    } 
  }
  return ans;
}

int main(){
  int n;
  cin >> n;
  int a[3], b[3];
  rep(i,3) cin >> a[i];
  rep(i,3) cin >> b[i];
  vector<P> p, q;
  rep(i,3) {
    if(a[i] < b[i]) p.push_back(P(a[i],b[i]));
    else if(b[i] < a[i]) q.push_back(P(b[i],a[i]));
  }
  n = solve(p,n); n = solve(q,n);
  cout << n << endl;
  return 0;
}

Compiler output:
a.cc:6:7: error: expected nested-name-specifier before 'int'
    6 | using int = ll;
      |       ^~~
Language: C++

#pragma GCC optimize("Ofast")
#include<cstdio>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include <map>
#include<set>
using namespace std;
#define INF 1LL<<62
#define MAX 100000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;
typedef pair<pair<int,int>,int> p;
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
struct edge{ll to,cost,val;};
template<class T,class U>bool chmin(T&a,const U&b){if(a<=b)return false;a=b;return true;}
template<class T,class U>bool chmax(T&a,const U&b){if(a>=b)return false;a=b;return true;}
//__builtin_popcount(S);
//C.erase(unique(C.begin(),C.end()),C.end());
//#define int ll

int dp[5100];
ll dp2[25100000];

signed main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int N;
    cin>>N;
    int a[3],b[3];
    for(int i=0;i<3;i++) cin>>a[i];
    for(int i=0;i<3;i++) cin>>b[i];

    dp[0]=0;
    for(int i=1;i<=N;i++){
        dp[i]=i;
        for(int j=0;j<3;j++){
            chmax(dp[i],dp[max(i-a[j],0)]+b[j]);
        }
    }
    dp2[0]=0;
    for(int i=1;i<=dp[N];i++){
        dp2[i]=i;
        for(int j=0;j<3;j++){
            chmax(dp2[i],maxdp2[max(0,i-b[j])]+a[j]);
        }
    }
    cout<<dp2[dp[N]]<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:55:26: error: 'maxdp2' was not declared in this scope
   55 |             chmax(dp2[i],maxdp2[max(0,i-b[j])]+a[j]);
      |                          ^~~~~~
Language: C++

#pragma GCC optimize("Ofast")
#include<cstdio>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include <map>
#include<set>
using namespace std;
#define INF 1LL<<62
#define MAX 100000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;
typedef pair<pair<int,int>,int> p;
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
struct edge{ll to,cost,val;};
template<class T,class U>bool chmin(T&a,const U&b){if(a<=b)return false;a=b;return true;}
template<class T,class U>bool chmax(T&a,const U&b){if(a>=b)return false;a=b;return true;}
//__builtin_popcount(S);
//C.erase(unique(C.begin(),C.end()),C.end());
#define int ll

ll dp[5100],dp2[25100000];

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int N;
    cin>>N;
    int a[3],b[3];
    for(int i=0;i<3;i++) cin>>a[i];
    for(int i=0;i<3;i++) cin>>b[i];

    dp[0]=0;
    for(int i=1;i<=N;i++){
        dp[i]=i;
        for(int j=0;j<3;j++){
            chmax(dp[i],dp[i-a[j]]+b[j]);
        }
    }
    dp2[0]=0;
    for(int i=1;i<=dp[N];i++){
        dp2[i]=i;
        for(int j=0;j<3;j++){
            chmax(dp2[i],dp2[i-b[j]]+a[j]);
        }
    }
    cout<<dp2[dp[N]]<<endl;
}


Compiler output:
a.cc:29:13: error: '::main' must return 'int'
   29 | #define int ll
      |             ^~
a.cc:33:1: note: in expansion of macro 'int'
   33 | int main(void){
      | ^~~
Language: C++

#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const ll mod = 1000000007;
const ll INF = mod * mod;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
typedef vector<int> vec;
typedef vector<string> svec;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
//#define int long long

ll n;
ll a[3], b[3];

//きちんと場合分けしないと、ループが２重のうえ、後半で値が大きくなっていてTLEする
//ループには細心の注意を払うべし

ll calc(vector<ll> buy, vector<ll> sell, ll m) {
    if(buy.size() == 0) return m;
    if(buy.size() == 1) {
        ll rem = m;
        ll p = m / buy[0];
        ll r = m % buy[0];
        return p * sell[0] + r;
    }
    if(buy.size() == 2) {
        ll res = m;
        for(ll x = 0; x * buy[0] <= m; x++) {
            ll rem = m - x * buy[0];
            ll p = rem / buy[1];
            ll r = rem % buy[1];
            res = max(res, x * sell[0] + p * sell[1] + r);
        }
        return res;
    }
    if(buy.size() == 3) {
        ll res = m;
        for(ll x = 0; x * buy[0] <= m; x++) {
            for(y = 0; y * buy[1] <= m - x * buy[0]; y++) {
                ll rem = m - x * buy[0] - y * buy[1];
                ll p = rem / buy[2];
                ll r = rem % buy[2];
                res = max(res, x * sell[0] + y * sell[1] + p * sell[2] + r);
            }
        }
        return res;
    }
}

void solve() {
    cin >> n;
    rep(i, 3) cin >> a[i];
    rep(i, 3) cin >> b[i];

    vector<ll> buy, sell;
    rep(i, 3) {
        if(a[i] < b[i]) {
            buy.pb(a[i]);
            sell.pb(b[i]);
        }
    }
    n = calc(buy, sell, n);

    buy.clear(); sell.clear();
    rep(i, 3) {
        if(b[i] < a[i]) {
            buy.pb(b[i]);
            sell.pb(a[i]);
        }
    }
    n = calc(buy, sell, n);

    cout << n << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

Compiler output:
a.cc: In function 'll calc(std::vector<long long int>, std::vector<long long int>, ll)':
a.cc:76:17: error: 'y' was not declared in this scope
   76 |             for(y = 0; y * buy[1] <= m - x * buy[0]; y++) {
      |                 ^
a.cc:85:1: warning: control reaches end of non-void function [-Wreturn-type]
   85 | }
      | ^
Language: C++

#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const ll mod = 1000000007;
const ll INF = mod * mod;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
typedef vector<int> vec;
typedef vector<string> svec;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
//#define int long long

void solve() {
    int n; cin >> n;
    int ga, sa, ba, gb, sb, bb;
    cin >> ga >> sa >> ba >> gb >> sb >> bb;

    int res = n;

    for(int cntg = 0; cntg <= n / ga; cntg++) {
        if(ga >= gb && cntg != 0) continue;
        int n_ = n - cntg * ga;
        int res_ = n + cntg * (gb - ga);
        for(int cnts = 0; cnts <= n_ / sa ; cnts++) {
            if(sa >= sb && cnts != 0) continue;
            n__ = n_ - cnts * sa;
            int cntb = (ba >= bb ? 0 : n__ / ba);
            int res__ = res_ + cnts * (sb - sa) + cntb * (bb - ba);
            res = max(res, res__);
        }
    }

    int ans = n;

    for(int cntg = 0; cntg <= n / gb; cntg++) {
        if(ga <= gb && cntg != 0) continue;
        int n_ = n - cntg * gb;
        int res_ = res + cntg * (ga - gb);
        for(int cnts = 0; cnts <= n_ / sb ; cnts++) {
            if(sa <= sb && cnts != 0) continue;
            n__ = n_ - cnts * sb;
            int cntb = (ba <= bb ? 0 : n__ / bb);
            int res__ = res_ + cnts * (sa - sb) + cntb * (ba - bb);
            ans = max(ans, res__);
        }
    }

    cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:62:13: error: 'n__' was not declared in this scope; did you mean 'n_'?
   62 |             n__ = n_ - cnts * sa;
      |             ^~~
      |             n_
a.cc:77:13: error: 'n__' was not declared in this scope; did you mean 'n_'?
   77 |             n__ = n_ - cnts * sb;
      |             ^~~
      |             n_
Language: C++

#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};


  
int main(){
  int n;
  cin>>n;
  long long ga,sa,ba,gb,sb,bb;
  cin>>ga>>sa>>ba;
  cin>>gb>>sb>>bb;
  
  int max_n = 5000+1;
  int max_x = 5000*5000+1;
  long long dp[max_n];
  //Aでどんぐりをどんぐりと金属が混ざったものに変え、Bでどんぐりと金属が混ざったものをどんぐりのみにする。
  for(long long i=0;i<=n;i++){
    dp[i] = i;//とくに取引を行わない場合
    if(i-ga>=0){
      dp[i] = max(dp[i],dp[i-ga]+gb);
    }
    if(i-sa>=0){
      dp[i] = max(dp[i],dp[i-sa]+sb);
    }
    if(i-ba>=0){
      dp[i] = max(dp[i],dp[i-ba]+bb);
    }
  }
  
  long long dp2[max_x];
  //Bでどんぐりをどんぐりと金属が混ざったものに変え、Aでどんぐりと金属が混ざったものをどんぐりのみにする。
  for(long long i=0;i<=dp[n];i++){
    dp2[i] = i;//とくに取引を行わない場合
    if(i-gb>=0){
      dp2[i] = max(d2p[i],dp2[i-gb]+ga);
    }
    if(i-sb>=0){
      dp2[i] = max(dp2[i],dp2[i-sb]+sa);
    }
    if(i-bb>=0){
      dp2[i] = max(dp2[i],dp2[i-bb]+ba);
    }
  }
  
  long long ans;
  ans = dp2[dp[n]];
  cout<<ans<<endl;
  
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:120:20: error: 'd2p' was not declared in this scope; did you mean 'dp2'?
  120 |       dp2[i] = max(d2p[i],dp2[i-gb]+ga);
      |                    ^~~
      |                    dp2
Language: C++

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

const int MAX_N = 25e6 + 150, inf = 1e9 + 7;
int n, A1, A2, A3, B1, B2, B3;
int dp[MAX_N];

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> n  >> A1 >> A2 >> A3 >> B1 >> B2 >> B3;
	dp[0] = 0;
	for (int i = 1; i <= n; i++) {
		dp[i] = dp[i - 1];
		if (A1 <= i)
			dp[i] = max(dp[i], dp[i - A1] + B1);
		if (A2 <= i)
			dp[i] = max(dp[i], dp[i - A2] + B2);
		if (A3 <= i)
			dp[i] = max(dp[i], dp[i - A3] + B3);
	}

	n = dp[n];

	memset(dp, 0, sizeof dp);
	for (int i = 1; i <= n; i++) {
		dp[i] = dp[i - 1];
		if (B1 <= i)
			dp[i] = max(dp[i], dp[i - B1] + A1);
		if (B2 <= i)
			dp[i] = max(dp[i], dp[i - B2] + A2);
		if (B3 <= i)
			dp[i] = max(dp[i], dp[i - B3] + A3);
	}

	cout << dp[n] << "\n";
	return 0;
}

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

#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FI first
#define SE second
//#define endl "\n"
#define ciosup  \
    cin.tie(0); \
    ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e9 + 7;
constexpr ll MOD = 1e9 + 7;

int main()
{
    ciosup;
    int n;
    cin >> n;
    pint s[3];
    REP(i, 3) { cin >> s[i].FI; }
    REP(i, 3) { cin >> s[i].SE; }
    int g[3];
    REP(i,3){
        g[i] = s[i].SE - s[i].FI;
    }
    int dp[4][n + 1];
    REP(i, n + 1) { dp[0][i] = 0; }
    REP(i,3){
        REP(j,n+1){
            if (j - s[i].FI < 0 || g[i] <= 0)
            {
                dp[i + 1][j] = dp[i][j];
            }else
            {
                dp[i + 1][j] = max(dp[i][j], dp[i + 1][j - s[i].FI] + g[i]);
            }
        }
    }
    int resdon = n + dp[3][n];
    REP(i,3){
        g[i] *= -1;
    }
    cout << resdon2 << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:50:13: error: 'resdon2' was not declared in this scope; did you mean 'resdon'?
   50 |     cout << resdon2 << endl;
      |             ^~~~~~~
      |             resdon
Language: C++

#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<cstring>
 
 
using namespace std;
#define int long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back

int N;
int ga,sa,ba,gb,sb,bb;
int ans=0;
struct Napsack_multiok{
    int C;//容量
    int N;//商品数
    pair<int,int> *prods;//(容積、価値)
    int *dp;//dp[N][C]:dp[x][y]容積をy使ってxまでの商品で埋めた時の最大
    int prod_count=0; 
    Napsack_multiok(int c,int n): C(c),N(n){ //make table
        prods = new pair<int,int>[N];
        dp = new int[(C+1)*(N+1)];
        rep(i,C+1){
            rep(j,N+1){
                dp[mkitr(i,j)]=0;
            }
        }
    }
    int mkitr(int x,int y){
        return x*C+y;
    }
    void push_prods(int c,int p){//(容積、価値)
        prods[prod_count++]=mp(c,p);
    }
    int solve(){//価値の最大値を返す。
        rep(i,N+1){
            if(i==0)continue;
            rep(j,C+1){
                if(C-j<=prods[i-1].first){//容積が足りない時
                    dp[mkitr(i,j)]=dp[mkitr(i,j-1)];
                }else{//prods[i]を入れられる時
                    int p=prods[i].second;
                    int c=prods[i].first;
                    if(j-c>-1)dp[mkitr(i,j)]=max(dp[mkitr(i,j-1)],max(dp[mkitr(i,j-c)],dp[mkitr(i-1,j-c)]));
                    else dp[mkitr(i,j)]=dp[mkitr(i,j-1)];
                }
            }
        }
        return dp[mkitr(N,C)];
    }
    void free_(){
        delete[] prods;
        delete[] dp;
    }
    
};
signed main(){
    scanf("%lld",&N);
    scanf("%lld %lld %lld",&ga,&sa,&ba);
    scanf("%lld %lld %lld",&gb,&sb,&bb);
    //(a)(c)
    Napsack_multiok AC(N,3);
    AC.push_prods(ga,gb-ga);AC.push_prods(sa,sb-sa);AC.push_prods(ba,bb-ba);
    int M=AC.solve();
    AC.free_();
    Napsack_multiok BD(M,3);
    BD.push_prods(gb,ga-gb);BD.push_prods(sb,sa-sb);BD.push_prods(bb,ba-bb);
    ans=BD.solve();
    BD.free_;
    printf("%lld\n",ans);
}


Compiler output:
a.cc: In function 'int main()':
a.cc:77:8: error: invalid use of non-static member function 'void Napsack_multiok::free_()'
   77 |     BD.free_;
      |     ~~~^~~~~
a.cc:59:10: note: declared here
   59 |     void free_(){
      |          ^~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
bool cmp(pair<int,int> a,pair<int,int> b)
{
	return abs(a.first) > abs(b.first);
}
int main() {
int N;
int a[3],b[3];
	 cin>>N>>a[0]>>a[1]>>a[2]>>b[0]>>b[1]>>b[2];
	 pair<int,int> bonus[3];
	 for(int i=0;i<3;i++)
	 {
	 	bonus[i].first = a[i]-b[i];
		 bonus[i].second = i; 
	 }
	 sort(bonus,bonus+3,cmp);
	 int even=0,after_last=N,middle=N,ans=N;
	 for(int i=0;i<3;i++)
	 {
	 	if(bonus[i].first < 0)
	 	{
	 		middle += (after_last/a[bonus[i].second])*abs(bonus[i].first);
	 		after_last = N%a[bonus[i].second];
	 		ans = middle;
		 }
		 else
		 {
			int al=(i < 2 ? 2 : 1)
		 	ans += (middle/b[bonus[al].second])*abs(bonus[al].first);
		 	middle = middle%b[bonus[al].second];
		 }
	 }
	 cout<<ans;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:30:25: error: expected ',' or ';' before 'ans'
   30 |                         ans += (middle/b[bonus[al].second])*abs(bonus[al].first);
      |                         ^~~
Language: C++

#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
bool chmax(ll &a, ll b){if(a<b){a=b;return 1;}return 0;}
typedef long long int LL;

const LL inf = 1123456789012;
LL N, ga, sa, ba, gb, sb, bb;
std::vector<LL>memo1, memo2;

LL dp1(LL i)
{
	if (i == 0) return 0;
	if (memo1[i] != -1) return memo1[i];
	if(i >= ga) chmax(memo1[i], dp1(i - ga) + gb - ga);
	if(i >= sa) chmax(memo1[i], dp1(i - sa) + sb - sa);
	if(i >= ba) chmax(memo1[i], dp1(i - ba) + bb - ba);
    chmax(memo1[i], 0);
	return memo1[i];
}

LL dp2(LL i)
{
	if (i == 0) return 0;
	if (memo2[i] != -1) return memo2[i];
	if(i >= gb) chmax(memo2[i], dp1(i - gb) + ga - gb);
	if(i >= sb) chmax(memo2[i], dp1(i - sb) + sa - sb);
	if(i >= bb) chmax(memo2[i], dp1(i - bb) + ba - bb);
    chmax(memo2[i], 0);
	return memo2[i];
}

int main()
{
	in >> N >> ga >> sa >> ba >> gb >> sb >> bb;

	memo1.resize(N + 1, -1);
	N += dp1(N);
	memo2.resize(N + 1, -1);
	out << N + dp2(N) << std::endl;
}


Compiler output:
a.cc:5:12: error: 'll' was not declared in this scope
    5 | bool chmax(ll &a, ll b){if(a<b){a=b;return 1;}return 0;}
      |            ^~
a.cc:5:16: error: 'a' was not declared in this scope
    5 | bool chmax(ll &a, ll b){if(a<b){a=b;return 1;}return 0;}
      |                ^
a.cc:5:19: error: 'll' was not declared in this scope
    5 | bool chmax(ll &a, ll b){if(a<b){a=b;return 1;}return 0;}
      |                   ^~
a.cc:5:23: error: expression list treated as compound expression in initializer [-fpermissive]
    5 | bool chmax(ll &a, ll b){if(a<b){a=b;return 1;}return 0;}
      |                       ^
a.cc: In function 'LL dp1(LL)':
a.cc:16:26: error: 'chmax' cannot be used as a function
   16 |         if(i >= ga) chmax(memo1[i], dp1(i - ga) + gb - ga);
      |                     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:17:26: error: 'chmax' cannot be used as a function
   17 |         if(i >= sa) chmax(memo1[i], dp1(i - sa) + sb - sa);
      |                     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:18:26: error: 'chmax' cannot be used as a function
   18 |         if(i >= ba) chmax(memo1[i], dp1(i - ba) + bb - ba);
      |                     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:19:10: error: 'chmax' cannot be used as a function
   19 |     chmax(memo1[i], 0);
      |     ~~~~~^~~~~~~~~~~~~
a.cc: In function 'LL dp2(LL)':
a.cc:27:26: error: 'chmax' cannot be used as a function
   27 |         if(i >= gb) chmax(memo2[i], dp1(i - gb) + ga - gb);
      |                     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:28:26: error: 'chmax' cannot be used as a function
   28 |         if(i >= sb) chmax(memo2[i], dp1(i - sb) + sa - sb);
      |                     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:29:26: error: 'chmax' cannot be used as a function
   29 |         if(i >= bb) chmax(memo2[i], dp1(i - bb) + ba - bb);
      |                     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:30:10: error: 'chmax' cannot be used as a function
   30 |     chmax(memo2[i], 0);
      |     ~~~~~^~~~~~~~~~~~~
Language: C++

#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif



const int MOD = 1000000007, INF = 1111111111;
using namespace std;
typedef long long lint;

#define int lint

int tran(vector<pair<int, int>> &vec, int n) {

	int res, tmp;
	if (vec.size() == 3) {
		for (int i = 0; i * vec[0].first <= n; i++) {
			for (int j = 0; i * vec[0].first + j * vec[1].first <= n; j++) {
				tmp = n - i * vec[0].first - j * vec[1].first;
				res = max(res, i * vec[0].second + j * vec[1].second +
					tmp / vec[2].first * vec[2].second +
					tmp % vec[2].first);
			}
		}
	}	

	if (vec.size() == 2) {
		for (int i = 0; i * vec[0].first <= n; i++) {
			tmp = n - i * vec[0].first;
			res = max(res, i * vec[0].second +
				tmp / vec[1].first * vec[1].second +
				tmp % vec[1].first);
		}
	}

	if (vec.size() == 1) { res = n / vec[0].first * vec[0].second; }
	if (vec.size() == 0) { res = n; }
	return res;
}

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;

	vector<int> a(3), b(3);
	for (int i = 0; i < 3; i++) cin >> a[i];
	for (int i = 0; i < 3; i++) cin >> b[i];

	vector<pair<int, int>> ab, ba;
	for (int i = 0; i < 3; i++) {
		if (a[i] < b[i]) ab.emplace_back(make_pair(a[i], b[i]));
		if (a[i] > b[i]) ba.emplace_back(make_pair(b[i], a[i]));
	}

	cout << tran(ba, tran(ab, N)) << "\n";

	return 0;
}


Compiler output:
a.cc:23:13: error: '::main' must return 'int'
   23 | #define int lint
      |             ^~~~
a.cc:53:1: note: in expansion of macro 'int'
   53 | int main() {
      | ^~~