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

import sys
from collections import deque
import copy


def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def bfs(X, Ma, Mb):
    #node_list = deque([0, 1])
    drug_dict = {}
    drug_dict[(0, 0)] = 0
    drug_dict[(X[0][0], X[0][1])] = X[0][2]
##    drug_dict[0] = ((0, 0) ,0)
##    drug_dict[1] = ((X[0][0], X[0][1]), X[0][2])
##    depth = 1
    min_cost = sys.maxint
    new_drug_dict = copy.deepcopy(drug_dict)
    for i in range(1, len(X)):
        for drug in drug_dict:
            cost = drug_dict[drug]
            new_drug = (drug[0] + X[i][0], drug[1] + X[i][1])
            if new_drug not in drug_dict:
                new_drug_dict[new_drug] = cost + X[i][2]
            else:
                new_drug_dict[new_drug] = min(drug_dict[new_drug], cost + X[i][2])
            if new_drug[1] * Ma == new_drug[0] * Mb:
                if new_drug_dict[new_drug] < min_cost:
                    min_cost = new_drug_dict[new_drug]
        drug_dict = copy.deepcopy(new_drug_dict)
    return min_cost


def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, Ma, Mb] = [int(input_raw[0]), int(input_raw[1]), int(input_raw[2])]
    X = []
    for i in range(N):
        input_raw = read_func().strip().split()
        [a, b, c] = [int(input_raw[0]), int(input_raw[1]), int(input_raw[2])]
        X.append((a, b, c))

    cost = bfs(X, Ma, Mb)
    if cost < sys.maxint:
        print cost
    else:
        print -1


if __name__ == '__main__':
    main()

Compiler output:
a.cc:13:6: error: invalid preprocessing directive #node_list
   13 |     #node_list = deque([0, 1])
      |      ^~~~~~~~~
a.cc:17:1: error: stray '##' in program
   17 | ##    drug_dict[0] = ((0, 0) ,0)
      | ^~
a.cc:18:1: error: stray '##' in program
   18 | ##    drug_dict[1] = ((X[0][0], X[0][1]), X[0][2])
      | ^~
a.cc:19:1: error: stray '##' in program
   19 | ##    depth = 1
      | ^~
a.cc:58:16: warning: multi-character literal with 8 characters exceeds 'int' size of 4 bytes
   58 | if __name__ == '__main__':
      |                ^~~~~~~~~~
a.cc:1:1: error: 'import' does not name a type
    1 | import sys
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:15:5: error: 'drug_dict' does not name a type
   15 |     drug_dict[(0, 0)] = 0
      |     ^~~~~~~~~
a.cc:43:5: error: 'input_raw' does not name a type
   43 |     input_raw = read_func().strip().split()
      |     ^~~~~~~~~
Language: C++

 
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define INF 1e9
#define EPS 1e-9
#define MOD (1e9+7)
void put(string d){}template<class H,class...T>void put(string d,H&h,T&...t){cout<<h;if(sizeof...(t))cout<<d;put(d,t...);}
template<class T>void puti(T&a,string d=" "){bool f=1;for(auto&_:a)cout<<(exchange(f,0)?"":d)<<_;cout<<endl;}
template<class T>void putii(T&a,string d=" "){for(auto&_:a)puti(_,d);}

int main(){
	int n,ma,mb;
	cin>>n>>ma>>mb;
	vvi med(n,vi(3));
	for(auto&l:med)for(auto&i:l)cin>>i;
	
	int dp[n+1][401][401];
	fill(dp[0][0],dp[n+1][0],10000);
	dp[0][0][0]=0;
	
	for(int i=1;i<=n;i++){
		for(int j=0;j<=10*(i-1);j++){
			for(int k=0;k<=10*(i-1);k++){
				if(dp[i-1][j][k]!=10000){
					dp[i][j][k]=min(dp[i][j][k],dp[i-1][j][k]);
					dp[i][j+med[i-1][0]][k+med[i-1][1]]=
						min(dp[i][j+med[i-1][0]][k+med[i-1][1]],
							dp[i-1][j][k]+med[i-1][2]);
				}
			}
		}
	}
	int ans=10000;
	for(int i=1;i*max(ma,mb)<=n*10+1 && i<dp[n].size();i++){
		ans=min(ans,dp[n][ma*i][mb*i]);
	}
	cout<<(ans==10000?-1:ans)<<endl;
	
	
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:41:53: error: request for member 'size' in 'dp[n]', which is of non-class type 'int [401][401]'
   41 |         for(int i=1;i*max(ma,mb)<=n*10+1 && i<dp[n].size();i++){
      |                                                     ^~~~
Language: C++

 
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define INF 1e9
#define EPS 1e-9
#define MOD (1e9+7)
void put(string d){}template<class H,class...T>void put(string d,H&h,T&...t){cout<<h;if(sizeof...(t))cout<<d;put(d,t...);}
template<class T>void puti(T&a,string d=" "){bool f=1;for(auto&_:a)cout<<(exchange(f,0)?"":d)<<_;cout<<endl;}
template<class T>void putii(T&a,string d=" "){for(auto&_:a)puti(_,d);}

int main(){
	int n,ma,mb;
	cin>>n>>ma>>mb;
	vvi med(n,vi(3));
	for(auto&l:med)for(auto&i:l)cin>>i;
	
	int dp[n+1][401][401];
	fill(dp[0],dp[n],10000);
	dp[0][0][0]=0;
	
	for(int i=1;i<=n;i++){
		for(int j=0;j<=10*(i-1);j++){
			for(int k=0;k<=10*(i-1);k++){
				dp[i][j][k]=min(dp[i][j][k],dp[i-1][j][k]);
				dp[i][j+med[i-1][0]][k+med[i-1][1]]=
					min(dp[i][j+med[i-1][0]][k+med[i-1][1]],
						dp[i-1][j][k]+med[i-1][2]);
			}
		}
	}
	int ans=10000;
	for(int i=1;i*max(ma,mb)<=401;i++){
		ans=min(ans,dp[n][ma*i][mb*i]);
	}
	cout<<(ans==10000?-1:ans)<<endl;
	
	
	return 0;
}


Compiler output:
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_algobase.h: In instantiation of 'typename __gnu_cxx::__enable_if<std::__is_scalar<_Tp>::__value, void>::__type std::__fill_a1(_ForwardIterator, _ForwardIterator, const _Tp&) [with _ForwardIterator = int (*)[401]; _Tp = int; typename __gnu_cxx::__enable_if<__is_scalar<_Tp>::__value, void>::__type = void]':
/usr/include/c++/14/bits/stl_algobase.h:998:21:   required from 'void std::__fill_a(_FIte, _FIte, const _Tp&) [with _FIte = int (*)[401]; _Tp = int]'
  998 |     { std::__fill_a1(__first, __last, __value); }
      |       ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:1029:20:   required from 'void std::fill(_ForwardIterator, _ForwardIterator, const _Tp&) [with _ForwardIterator = int (*)[401]; _Tp = int]'
 1029 |       std::__fill_a(__first, __last, __value);
      |       ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:25:6:   required from here
   25 |         fill(dp[0],dp[n],10000);
      |         ~~~~^~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:952:18: error: incompatible types in assignment of 'const int' to 'int [401]'
  952 |         *__first = __tmp;
      |         ~~~~~~~~~^~~~~~~
Language: C++

 
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define INF 1e9
#define EPS 1e-9
#define MOD (1e9+7)
void put(string d){}template<class H,class...T>void put(string d,H&h,T&...t){cout<<h;if(sizeof...(t))cout<<d;put(d,t...);}
template<class T>void puti(T&a,string d=" "){bool f=1;for(auto&_:a)cout<<(exchange(f,0)?"":d)<<_;cout<<endl;}
template<class T>void putii(T&a,string d=" "){for(auto&_:a)puti(_,d);}

int main(){
	int n,ma,mb;
	cin>>n>>ma>>mb;
	vvi med(n,vi(3));
	for(auto&l:med)for(auto&i:l)cin>>i;
	
	int dp[n+1][401][401];
	fill(dp,10000);
	dp[0][0][0]=0;
	
	for(int i=1;i<=n;i++){
		for(int j=0;j<=10*(i-1);j++){
			for(int k=0;k<=10*(i-1);k++){
				dp[i][j][k]=min(dp[i][j][k],dp[i-1][j][k]);
				dp[i][j+med[i-1][0]][k+med[i-1][1]]=
					min(dp[i][j+med[i-1][0]][k+med[i-1][1]],
						dp[i-1][j][k]+med[i-1][2]);
			}
		}
	}
	int ans=10000;
	for(int i=1;i*max(ma,mb)<=401;i++){
		ans=min(ans,dp[n][ma*i][mb*i]);
	}
	cout<<(ans==10000?-1:ans)<<endl;
	
	
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:25:13: error: no matching function for call to 'fill(int [(n + 1)][401][401], int)'
   25 |         fill(dp,10000);
      |         ~~~~^~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_algobase.h:1022:5: note: candidate: 'template<class _ForwardIterator, class _Tp> void std::fill(_ForwardIterator, _ForwardIterator, const _Tp&)'
 1022 |     fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value)
      |     ^~~~
/usr/include/c++/14/bits/stl_algobase.h:1022:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:86:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:191:1: note: candidate: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::fill(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)'
  191 | fill(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value);
      | ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:191:1: note:   candidate expects 4 arguments, 2 provided
Language: C++

 
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define INF 1e9
#define EPS 1e-9
#define MOD (1e9+7)
void put(string d){}template<class H,class...T>void put(string d,H&h,T&...t){cout<<h;if(sizeof...(t))cout<<d;put(d,t...);}
template<class T>void puti(T&a,string d=" "){bool f=1;for(auto&_:a)cout<<(exchange(f,0)?"":d)<<_;cout<<endl;}
template<class T>void putii(T&a,string d=" "){for(auto&_:a)puti(_,d);}

int main(){
	int n,ma,mb;
	cin>>n>>ma>>mb;
	vvi med(n,vi(3));
	for(auto&l:med)for(auto&i:l)cin>>i;
	
	int dp[n+1],[401][401]={{{10000}}};
	dp[0][0][0]=0;
	for(int i=1;i<=n;i++){
		for(int j=0;j<=10*(i-1);j++){
			for(int k=0;k<=10*(i-1);k++){
				dp[i][j][k]=min(dp[i][j][k],dp[i-1][j][k]);
				dp[i][j+med[i-1][0]][k+med[i-1][1]]=
					min(dp[i][j+med[i-1][0]][k+med[i-1][1]],
						dp[i-1][j][k]+med[i-1][2]);
			}
		}
	}
	int ans=10000;
	for(int i=1;i*max(ma,mb)<=401;i++){
		ans=min(ans,dp[n][ma*i][mb*i]);
	}
	cout<<(ans==10000?-1:ans)<<endl;
	
	
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:24:21: error: expected unqualified-id before '[' token
   24 |         int dp[n+1],[401][401]={{{10000}}};
      |                     ^
a.cc:25:14: error: invalid types 'int[int]' for array subscript
   25 |         dp[0][0][0]=0;
      |              ^
a.cc:29:38: error: invalid types 'int[int]' for array subscript
   29 |                                 dp[i][j][k]=min(dp[i][j][k],dp[i-1][j][k]);
      |                                      ^
a.cc:29:54: error: invalid types 'int[int]' for array subscript
   29 |                                 dp[i][j][k]=min(dp[i][j][k],dp[i-1][j][k]);
      |                                                      ^
a.cc:29:68: error: invalid types 'int[int]' for array subscript
   29 |                                 dp[i][j][k]=min(dp[i][j][k],dp[i-1][j][k]);
      |                                                                    ^
a.cc:30:38: error: invalid types 'int[int]' for array subscript
   30 |                                 dp[i][j+med[i-1][0]][k+med[i-1][1]]=
      |                                      ^
a.cc:31:50: error: invalid types 'int[int]' for array subscript
   31 |                                         min(dp[i][j+med[i-1][0]][k+med[i-1][1]],
      |                                                  ^
a.cc:32:56: error: invalid types 'int[int]' for array subscript
   32 |                                                 dp[i-1][j][k]+med[i-1][2]);
      |                                                        ^
a.cc:38:34: error: invalid types 'int[int]' for array subscript
   38 |                 ans=min(ans,dp[n][ma*i][mb*i]);
      |                                  ^
Language: C++

const int nmax=40,abmax=10,inf = 1000000;
int a[nmax],b[nmax],c[nmax];
int dp[nmax+1][nmax*abmax+1][nmax*abmax+1];
int main(void){
    int n,ma,mb;
    cin >> n >> ma >> mb;
    for(int i=0;i<n;++i){
        cin >> a[i] >> b[i] >> c[i];
}
    for(int i = 0; i <= n; ++i){
        for(int ca = 0; ca <= nmax*abmax; ++ca){
            for(int cb = 0; cb <= nmax*abmax; ++cb){
                dp[i][ca][cb]=inf;
} }
    }
    dp[0][0][0]=0;

for(inti=0;i<n;++i){
for(int ca = 0; ca <= nmax*abmax; ++ca){
            for(int cb = 0; cb <= nmax*abmax; ++cb){
                if(dp[i][ca][cb]==inf) continue;
                dp[i+1][ca][cb]=min(dp[i+1][ca][cb],dp[i][ca][cb]);
                dp[i+1][ca+a[i]][cb+b[i]]=min(dp[i+1][ca+a[i]][cb+b[i]],dp[i][ca][cb]+c[i]);
} }
}
    int ans=inf;
    for(int ca = 1; ca <= nmax*abmax; ++ca){
        for(int cb = 1; cb <= nmax*abmax; ++cb){
            if(ca*mb==cb*ma) ans=min(ans,dp[n][ca][cb]);
} }
    if(ans==inf) ans=-1;
    cout << ans << endl;
return 0; }

Compiler output:
a.cc: In function 'int main()':
a.cc:6:5: error: 'cin' was not declared in this scope
    6 |     cin >> n >> ma >> mb;
      |     ^~~
a.cc:18:5: error: 'inti' was not declared in this scope; did you mean 'int'?
   18 | for(inti=0;i<n;++i){
      |     ^~~~
      |     int
a.cc:18:12: error: 'i' was not declared in this scope
   18 | for(inti=0;i<n;++i){
      |            ^
a.cc:22:33: error: 'min' was not declared in this scope; did you mean 'main'?
   22 |                 dp[i+1][ca][cb]=min(dp[i+1][ca][cb],dp[i][ca][cb]);
      |                                 ^~~
      |                                 main
a.cc:29:34: error: 'min' was not declared in this scope; did you mean 'main'?
   29 |             if(ca*mb==cb*ma) ans=min(ans,dp[n][ca][cb]);
      |                                  ^~~
      |                                  main
a.cc:32:5: error: 'cout' was not declared in this scope
   32 |     cout << ans << endl;
      |     ^~~~
a.cc:32:20: error: 'endl' was not declared in this scope
   32 |     cout << ans << endl;
      |                    ^~~~
Language: C++

#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}
#define N 500

ll dp[N][N];

int main(){
	ll n, ma, mb;
	cin>>n>>ma>>mb;
	rep(i, N) fill(dp, dp+N, INF);
	dp[0][0] = 0;
	rep(i, n){
		int a, b, c;
		cin>>a>>b>>c;
		for(int i = a; i < N; i++) for(int j = b; j < N; j++) chmin(dp[i][j], dp[i-a][j-b]+c);
	}
	ll res = INF;
	for(int i = 1; i*max(ma, mb)<N; i++) chmin(res, dp[i*ma][i*mb]);
	cout<<(res==INF?-1:res)<<endl;
	return 0;
}


Compiler output:
In file included from /usr/include/c++/14/algorithm:60,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h: In instantiation of 'typename __gnu_cxx::__enable_if<std::__is_scalar<_Tp>::__value, void>::__type std::__fill_a1(_ForwardIterator, _ForwardIterator, const _Tp&) [with _ForwardIterator = long long int (*)[500]; _Tp = long long int; typename __gnu_cxx::__enable_if<__is_scalar<_Tp>::__value, void>::__type = void]':
/usr/include/c++/14/bits/stl_algobase.h:998:21:   required from 'void std::__fill_a(_FIte, _FIte, const _Tp&) [with _FIte = long long int (*)[500]; _Tp = long long int]'
  998 |     { std::__fill_a1(__first, __last, __value); }
      |       ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:1029:20:   required from 'void std::fill(_ForwardIterator, _ForwardIterator, const _Tp&) [with _ForwardIterator = long long int (*)[500]; _Tp = long long int]'
 1029 |       std::__fill_a(__first, __last, __value);
      |       ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:47:16:   required from here
   47 |         rep(i, N) fill(dp, dp+N, INF);
      |                   ~~~~^~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:952:18: error: incompatible types in assignment of 'const long long int' to 'long long int [500]'
  952 |         *__first = __tmp;
      |         ~~~~~~~~~^~~~~~~
Language: C++

#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<functional>
#include<queue>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(int (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cerr << v[i] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

#define INF 10000000

int dp[2][401][401];

int main()
{
	REP(k,2)REP(i,401)REP(j,401)dp[k][i][j] = INF;
	dp[0][0][0] = dp[1][0][0] = 0;
	
	int n,ma,mb;
	cin >> n >> ma >> mb;
	
	REP(v,n)
	{
		int a,b,c;
		cin >> a >> b >> c;
		REP(i,401-a)REP(j,401-b)
		{
			if(dp[v%2][i][j] != INF)
			{
				dp[(v+1)%2][i][j] = min(dp[v%2][i][j],vp[(v+1)][i][j]);
				dp[(v+1)%2][i+a][j+b] = min(dp[(v+1)%2][i+a][j+b],min(dp[v%2][i+a][j+b],dp[v%2][i][j] + c));
			}
		}
		
	}
	int ans = INF;
		
	rep(i,1,401)rep(j,1,401)
	{
		if(ma*j == mb*i)
			ans = min(ans,min(dp[0][i][j],dp[1][i][j]));
	}
	
	if(ans != INF)
	{
		cout << ans << endl;
	}
	else
	{
		cout << -1 << endl;
	}
	
	
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:57:71: error: 'vp' was not declared in this scope; did you mean 'v'?
   57 |                                 dp[(v+1)%2][i][j] = min(dp[v%2][i][j],vp[(v+1)][i][j]);
      |                                                                       ^~
      |                                                                       v
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define e8 100000000
#define r(i,n) for(int i=0;i<n;i++)
int dp[42][4001][4001];
int a,b,c,a1,a2,n,b1;
int u[42][4001][4001];
int main(){
  r(i,42)r(j,4001)r(k,4001)dp[i][j][k]=e8;
  dp[0][0][0]=0;
  u[0][0][0]=1;
  cin>>n>>a1>>b1;
  r(i,n){
    cin>>a>>b>>c;
    r(j,4001)r(k,4001)
      if(!u[i][j][k]){
        if(dp[i+1][j+a][k+b]!=e8)dp[i+1][j+a][k+b]=min(dp[i+1][j+a][k+b],dp[i][j][k]+c);
        else dp[i+1][j+a][k+b]=dp[i][j][k]+c;
      }
    r(j,4001)r(k,4001)
      if(dp[i][j][k]!=e8){
        dp[i+1][j][k]=min(dp[i][j][k],dp[i+1][j][k]);
        u[i+1][j][k]=1;
    }
  }
  int ans=e8;
  r(j,4001)r(k,4001)if(u[n][j][k])if(j&&k){
    if(k*a1==j*b1){
      ans=min(ans,dp[n][j][k]);
    }
  }
  cout<<ans<<endl;
}

Compiler output:
/tmp/ccZRFzlk.o: in function `main':
a.cc:(.text+0x8e): relocation truncated to fit: R_X86_64_PC32 against symbol `u' defined in .bss section in /tmp/ccZRFzlk.o
a.cc:(.text+0x99): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccZRFzlk.o
a.cc:(.text+0xb5): relocation truncated to fit: R_X86_64_PC32 against symbol `a1' defined in .bss section in /tmp/ccZRFzlk.o
a.cc:(.text+0xca): relocation truncated to fit: R_X86_64_PC32 against symbol `b1' defined in .bss section in /tmp/ccZRFzlk.o
a.cc:(.text+0xe8): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccZRFzlk.o
a.cc:(.text+0x104): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/ccZRFzlk.o
a.cc:(.text+0x119): relocation truncated to fit: R_X86_64_PC32 against symbol `c' defined in .bss section in /tmp/ccZRFzlk.o
a.cc:(.text+0x170): relocation truncated to fit: R_X86_64_PC32 against symbol `u' defined in .bss section in /tmp/ccZRFzlk.o
a.cc:(.text+0x187): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccZRFzlk.o
a.cc:(.text+0x193): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/ccZRFzlk.o
a.cc:(.text+0x20e): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define e8 100000000
#define r(i,n) for(int i=0;i<n;i++)
int dp[42][4001][4001],a,b,c,a1,a2,n,b1;
int u[42][4001][4001];
main(){
  r(i,42)r(j,4001)r(k,4001)dp[i][j][k]=e8;
  dp[0][0][0]=0;
  u[0][0][0]=1;
  cin>>n>>a1>>b1;
  r(i,n){
    cin>>a>>b>>c;
    r(j,4001)r(k,4001)
      if(!u[i][j][k]){
        if(dp[i+1][j+a][k+b]!=e8)dp[i+1][j+a][k+b]=min(dp[i+1][j+a][k+b],dp[i][j][k]+c);
        else dp[i+1][j+a][k+b]=dp[i][j][k]+c;
      }
    r(j,4001)r(k,4001)
      if(dp[i][j][k]!=e8){
        dp[i+1][j][k]=min(dp[i][j][k],dp[i+1][j][k]);
        u[i+1][j][k]=1;
    }
  }
  int ans=e8;
  r(j,4001)r(k,4001)if(u[n][j][k])if(j&&k){
    if(k*a1==j*b1){
      ans=min(ans,dp[n][j][k]);
    }
  }
  cout<<ans<<endl;
}

Compiler output:
a.cc:7:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    7 | main(){
      | ^~~~
/tmp/ccDjDdBz.o: in function `main':
a.cc:(.text+0x8e): relocation truncated to fit: R_X86_64_PC32 against symbol `u' defined in .bss section in /tmp/ccDjDdBz.o
a.cc:(.text+0x99): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccDjDdBz.o
a.cc:(.text+0xb5): relocation truncated to fit: R_X86_64_PC32 against symbol `a1' defined in .bss section in /tmp/ccDjDdBz.o
a.cc:(.text+0xca): relocation truncated to fit: R_X86_64_PC32 against symbol `b1' defined in .bss section in /tmp/ccDjDdBz.o
a.cc:(.text+0xe8): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccDjDdBz.o
a.cc:(.text+0x104): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/ccDjDdBz.o
a.cc:(.text+0x119): relocation truncated to fit: R_X86_64_PC32 against symbol `c' defined in .bss section in /tmp/ccDjDdBz.o
a.cc:(.text+0x170): relocation truncated to fit: R_X86_64_PC32 against symbol `u' defined in .bss section in /tmp/ccDjDdBz.o
a.cc:(.text+0x187): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccDjDdBz.o
a.cc:(.text+0x193): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/ccDjDdBz.o
a.cc:(.text+0x20e): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
Language: C++

#include <bits/stdc++.h>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

struct Data {
    int a, b, c;
    Data(int a = 1, int b = 1, int c = 0) : a(a), b(b), c(c) {
        int g = __gcd(a, b);
        a /= g;
        b /= g;
    }
    bool operator<(const Data &rhs) const {
        int c = rhs.a;
        int d = rhs.b;
        return make_pair(a * d, c) < make_pair(c * b, rhs.c);
    }
};
int N, M[2];
int a[50], b[50], c[50];
vector<int> s[2];
vector<Data> d[2];
int main() {
    cin >> N >> M[0] >> M[1];
    rep(i, N) cin >> a[i] >> b[i] >> c[i];
    rep(i, N) { s[i % 2].push_back(i); }
    rep(i, 2) rep(S, 1 << s[i].size()) {
        int A = 0, B = 0, C = 0;
        if (S == 0) continue;
        rep(j, s[i].size()) if (S >> j & 1) {
            A += a[s[j]];
            B += b[s[j]];
            C += c[s[j]];
        }
        d[i].push_back(Data(A, B, C));
    }
    rep(i, 2) sort(all(d[i]));
    const int INF = 1e8;
    int ans = INF;
    rep(i, d[0].size()) {
        Data t(M[0] * d[0][i].b, M[1] * d[0][i].a, 0);
        int idx = lower_bound(all(d[1]), t) - d[1].begin();
        if (idx == d[1].size()) continue;
        int A = d[0][i].a * d[1][idx].a;
        int B = d[0][i].b * d[1][idx].b;
        int G = __gcd(A, B);
        A /= G;
        B /= G;
        if (M[0] == A && M[1] == B) {
            ans = min(ans, d[0][i].c + d[1][idx].c);
        }
    }
    if (ans == INF) ans = -1;
    cout << ans << endl;

    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:36:19: error: no match for 'operator[]' (operand types are 'int [50]' and 'std::vector<int>')
   36 |             A += a[s[j]];
      |                   ^
a.cc:37:19: error: no match for 'operator[]' (operand types are 'int [50]' and 'std::vector<int>')
   37 |             B += b[s[j]];
      |                   ^
a.cc:38:19: error: no match for 'operator[]' (operand types are 'int [50]' and 'std::vector<int>')
   38 |             C += c[s[j]];
      |                   ^
Language: C++

const int nmax=40,abmax=10,inf = 1000000;

int a[nmax],b[nmax],c[nmax];
int dp[nmax+1][nmax*abmax+1][nmax*abmax+1];

int main(void){
int n,ma,mb;
cin >> n >> ma >> mb;

for(int i=0;i<n;++i){
        cin >> a[i] >> b[i] >> c[i];
}

for(int i = 0; i <= n; ++i){
        for(int ca = 0; ca <= nmax*abmax; ++ca){
                for(int cb = 0; cb <= nmax*abmax; ++cb){
                        dp[i][ca][cb]=inf;
                }
        }
}

dp[0][0][0]=0;


for(int i = 0; i < n; ++i){
        for(int ca = 0; ca <= nmax*abmax; ++ca){
                for(int cb = 0; cb <= nmax*abmax; ++cb){
                        if(dp[i][ca][cb]==inf) continue;
                        dp[i+1][ca][cb]=min(dp[i+1][ca][cb],dp[i][ca][cb]);
                        dp[i+1][ca+a[i]][cb+b[i]]=min(dp[i+1][ca+a[i]][cb+b[i]],dp[i][ca][cb]+c[i]);
                }
        }
}

int ans=inf;
for(int ca = 1; ca <= nmax*abmax; ++ca){
        for(int cb = 1; cb <= nmax*abmax; ++cb){
                if(ca*mb==cb*ma) ans=min(ans,dp[n][ca][cb]);
        }
}
        if(ans==inf) ans=-1;
        cout << ans << endl;

        return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:8:1: error: 'cin' was not declared in this scope
    8 | cin >> n >> ma >> mb;
      | ^~~
a.cc:29:41: error: 'min' was not declared in this scope; did you mean 'main'?
   29 |                         dp[i+1][ca][cb]=min(dp[i+1][ca][cb],dp[i][ca][cb]);
      |                                         ^~~
      |                                         main
a.cc:38:38: error: 'min' was not declared in this scope; did you mean 'main'?
   38 |                 if(ca*mb==cb*ma) ans=min(ans,dp[n][ca][cb]);
      |                                      ^~~
      |                                      main
a.cc:42:9: error: 'cout' was not declared in this scope
   42 |         cout << ans << endl;
      |         ^~~~
a.cc:42:24: error: 'endl' was not declared in this scope
   42 |         cout << ans << endl;
      |                        ^~~~
Language: C++

#include"bits/stdc++.h"
//#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define print(x) cout<<x<<endl;
typedef long long ll;

const int nmax = 40, abmax = 10, inf = 1000000;

int a[nmax], b[nmax], c[nmax];
int dp[nmax + 1][nmax*abmax + 1][nmax*abmax + 1];

int main() {
	int n, ma, mb;
	cin >> n >> ma >> mb;
	rep(i, 0, n) {
		cin >> a[i] >> b[i] >> c[i];
	}
	for (int i = 0; i <= n; i++) {
		for (int ca = 0; ca <= nmax*abmax; ca++) {
			for (int cb = 0; cb <= nmax*abmax; cb++) {
				dp[i][ca][cb] = inf;
			}
		}
	}
	dp[0][0][0] = 0;
	for (int i = 0; i <= n; i++) {
		for (int ca = 0; ca <= nmax*abmax; ca++) {
			for (int cb = 0; cb <= nmax*abmax; cb++) {
				if (dp[i][ca][cb] == inf)continue;
				dp[i + 1][ca][cb] = min(dp[i + 1][ca][cb], dp[i][ca][cb]);
				dp[i + 1][ca + a[i]][cb + b[i]] = mindp([i + 1][ca + a[i]][cb + b[i]], dp[i][ca][cb] + c[i]);
			}
		}
	}

	int ans = inf;
	for (int ca = 1; ca <= nmax*abmax; ca++) {
		for (int cb = 1; cb <= nmax*abmax; cb++) {
			if (ca*mb == cb*ma)ans = min(ans, dp[n][ca][cb]);
		}
	}

	if (ans == inf)ans = -1;
	print(ans);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:32:75: error: expected ',' before '+' token
   32 |                                 dp[i + 1][ca + a[i]][cb + b[i]] = mindp([i + 1][ca + a[i]][cb + b[i]], dp[i][ca][cb] + c[i]);
      |                                                                           ^~
      |                                                                           ,
a.cc:32:76: error: expected identifier before '+' token
   32 |                                 dp[i + 1][ca + a[i]][cb + b[i]] = mindp([i + 1][ca + a[i]][cb + b[i]], dp[i][ca][cb] + c[i]);
      |                                                                            ^
a.cc: In lambda function:
a.cc:32:80: error: expected '{' before '[' token
   32 |                                 dp[i + 1][ca + a[i]][cb + b[i]] = mindp([i + 1][ca + a[i]][cb + b[i]], dp[i][ca][cb] + c[i]);
      |                                                                                ^
a.cc: In function 'int main()':
a.cc:32:80: error: no match for 'operator[]' (operand types are 'main()::<lambda()>' and 'int')
a.cc:32:67: error: 'mindp' was not declared in this scope
   32 |                                 dp[i + 1][ca + a[i]][cb + b[i]] = mindp([i + 1][ca + a[i]][cb + b[i]], dp[i][ca][cb] + c[i]);
      |                                                                   ^~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef long long ll;
typedef pair<ll,ll> P;
const int INF=INT_MAX / 3;
const ll LINF=LLONG_MAX / 3LL;
#define CONST 1000000007
#define EPS (1e-8)
#define PB push_back
#define MP make_pair
#define sz(a) ((int)(a).size())
#define reps(i,n,m) for(int i=(n);i<int(m);i++)
#define rep(i,n) reps(i,0,n)
#define SORT(a) sort((a).begin(),(a).end())
ll mod(ll a,ll m){return (a%m+m)%m;}
int dx[9]={0,1,0,-1,1,1,-1,-1,0},dy[9]={1,0,-1,0,1,-1,1,-1,0};
ll n,ma, mb;

int main(){
  vector<ll> as, bs, cs;
  cin >> n >> ma >> mb;
  ll suma = 0, sumb = 0;
  rep(i, n) {
    ll a, b, c;
    cin >> a >> b >> c;
    as.PB(a);
    bs.PB(b);
    cs.PB(c);
    suma += a;
    sumb += b;
  }

  map<P, ll> mp;
  for(ll x=0; x < (1<<(n/2)); ++x) {
    ll a = 0, b = 0, c = 0;
    rep(i, n/2) {
      if((x >> i) & 1LL) {
        a += as[i];
        b += bs[i];
        c += cs[i];
      }
    }
    if(mp[P(a,b)] == 0 || mp[P(a, b)] > c) {
      mp[P(a,b)] = c;
    }
  }


  ll ans = LINF;

  for(ll x=0; x < (1<<(n - n/2)); ++x) {
    ll a = 0, b = 0, c = 0;
    rep(i, n-n/2) {
      if((x >> i) & 1LL) {
        a += as[i+n/2];
        b += bs[i+n/2];
        c += cs[i+n/2];
      }
    }

    for (int i = 1;; i++) {
      if (suma < i*ma || sumb < i*mb) break;a
      ll xa = i * ma;
      ll xb = i * mb;
      ll da = xa - a;
      ll db = xb - b;

      if(da <= 0 || db <= 0) {
        continue;
      }
      if(mp[P(da, db)] != 0) {
        ans = min(ans, mp[P(da, db)] + c);
      }
    }
  }

  cout << ((ans==LINF) ? -1 : ans) << endl;

  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:64:46: error: expected ';' before 'll'
   64 |       if (suma < i*ma || sumb < i*mb) break;a
      |                                              ^
      |                                              ;
   65 |       ll xa = i * ma;
      |       ~~                                      
a.cc:67:15: error: 'xa' was not declared in this scope; did you mean 'da'?
   67 |       ll da = xa - a;
      |               ^~
      |               da
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define inf 5000
#define priMax 100
#define perMax 10
#define NMax 40

int Calc(int *a,int *b,int *c,int N,int Ma,int Mb,int SN,int **dat){
    int **sum;
    sum=new int**[SN*perMax+1];
    for(int i=0;i<=SN;i++)
        sum[i]=new int*[SN*perMax+1];
    for(int i=0;i<=SN*perMax;i++)
            for(int j=0;j<=N*perMax;j++)
                sum[i][j]=inf;

    sum[0][0]=0; 
    if(SN==0) return Calc(a,b,c,N,Ma,Mb,SN+1,sum);
    for(int an=0;an<=SN*perMax;an++)
        for(int bn=0;bn<=SN*perMax;bn++){
            sum[an][bn] = min(sum[an][bn],dat[an][bn]);
            sum[an+a[n]][bn+b[n]] = min(dat[an][bn]+c[n],sum[an+a[n]][bn+b[n]]);
        }
    if(SN!=N) return Calc(a,b,c,N,Ma,Mb,SN+1,sum);
    int res=inf;
    for(int an=0;an<=N*perMax;an++)
        for(int bn=0;bn<=N*perMax;bn++)
            if((an!=0||bn!=0)&&an*Mb==bn*Ma)res=min(sum[an][bn],res);
    if(res==inf) return -1;
    else return res;
}

int main(){
    int N,Ma,Mb;
    cin>>N;
    cin>>Ma;
    cin>>Mb;
    int a[N],b[N],c[N];
    for(int i=0;i<N;i++){
        cin>>a[i];
        cin>>b[i];
        cin>>c[i];
    }
    cout<<Calc(a,b,c,N,Ma,Mb,0,NULL)<<endl;
    return 0;
}

Compiler output:
a.cc: In function 'int Calc(int*, int*, int*, int, int, int, int, int**)':
a.cc:10:9: error: cannot convert 'int***' to 'int**' in assignment
   10 |     sum=new int**[SN*perMax+1];
      |         ^~~~~~~~~~~~~~~~~~~~~~
      |         |
      |         int***
a.cc:12:16: error: cannot convert 'int**' to 'int*' in assignment
   12 |         sum[i]=new int*[SN*perMax+1];
      |                ^~~~~~~~~~~~~~~~~~~~~
      |                |
      |                int**
a.cc:22:22: error: 'n' was not declared in this scope
   22 |             sum[an+a[n]][bn+b[n]] = min(dat[an][bn]+c[n],sum[an+a[n]][bn+b[n]]);
      |                      ^
Language: C++

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

struct Med
{
	int a, b, c;
};

int N, Ma,Mb;
std::vector<Med>  vMed;

int ans = INT_MAX;

int eval(int seek,Med sum)
{
	if (seek == N)
		return -1;

	if (!(sum.a ==0 && sum.b == 0) && sum.a*Mb == sum.b*Ma)
		return sum.c;

	int ans_0 = eval(seek + 1, sum);

	Med sum2 = sum;

	sum2.a += vMed[seek].a;
	sum2.b += vMed[seek].b;
	sum2.c += vMed[seek].c;

	int ans_1 = eval(seek + 1, sum2);

	if (ans_0 == -1 && ans_1 == -1)
		return -1;
	else if (ans_0 == -1)
		return ans_1;
	else if (ans_1 == -1)
		return ans_0;
	else return std::min(ans_0, ans_1);
	
}

int main()
{


	std::cin >> N >> Ma >> Mb;
	
	for (int i = 0; i < N; i++)
	{
		Med m;

		std::cin >> m.a >> m.b >> m.c;

		vMed.push_back(m);
	}

	Med m;

	m.a = 0;
	m.b = 0;
	m.c = 0;

	std::cout << eval(0, m) << std::endl;

	return 0;
}

Compiler output:
a.cc:14:11: error: 'INT_MAX' was not declared in this scope
   14 | int ans = INT_MAX;
      |           ^~~~~~~
a.cc:5:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    4 | #include <utility>
  +++ |+#include <climits>
    5 |
Language: C++

#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
const ll MOD = 1000000007;
const int INF = 1000000;
int N,M,x,y,ans=1,temp,A[45],B[45],C[60];
int dp[402][402][402]={INF};

int main(){
    dp[0][0][0]=0;
    scanf("%d %d %d",&N,&x,&y);
    REP(i,N){
        scanf("%d %d %d",&A[i],&B[i],&C[i]);
    }
    REP(i,N)
        REP(a,400)
            REP(b,400){
                if(dp[i][a][b])continue;
        dp[i+1][a][b]=min(dp[i+1][a][b],dp[i][a][b]);
        dp[i+1][a+A[i]][b+B[i]]=min(dp[i+1][a+A[i]][b+B[i]],dp[i][a][b]+C[i]);

    }
    ans=INF;
    EREP(i,400)
        EREP(j,400){
        if(x*j==y*i)ans=min(ans,dp[N][i][j]);
    }
    if(ans==INF)ans=-1;
    cout<<ans;
    return 0;
}


Compiler output:
/tmp/cc3jBrWS.s: Assembler messages:
/tmp/cc3jBrWS.s: Fatal error: can't fill 256 bytes in section .data of /tmp/ccnzT6XU.o: 'No space left on device'
/tmp/cc3jBrWS.s: Fatal error: /tmp/ccnzT6XU.o: No such file or directory
Language: C++

#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
const ll MOD = 1000000007;
const int INF = 1000000;
int N,M,x,y,ans=1,temp,A[45],B[45],C[60];
double per;
bool vis[100][100][100]={0};
int dp[402][402][402]={INF};

int main(){
    dp[0][0][0]=0;
    scanf("%d %d %d",&N,&x,&y);
    REP(i,N){
        scanf("%d %d %d",&A[i],&B[i],&C[i]);
    }
    REP(i,N)
        REP(a,400)
            REP(b,400){
                if(dp[i][a][b])continue;
        dp[i+1][a][b]=min(dp[i+1][a][b],dp[i][a][b]);
        dp[i+1][a+A[i]][b+B[i]]=min(dp[i+1][a+A[i]][b+B[i]],dp[i][a][b]+C[i]);

    }
    ans=INF;
    EREP(i,400)
        EREP(j,400){
        if(x*j==y*i)ans=min(ans,dp[N][i][j]);
    }
    if(ans==INF)ans=-1;
    cout<<ans;
    return 0;
}


Compiler output:
/tmp/cczbGr4B.s: Assembler messages:
/tmp/cczbGr4B.s: Fatal error: can't fill 256 bytes in section .data of /tmp/ccBZvhnl.o: 'No space left on device'
/tmp/cczbGr4B.s: Fatal error: /tmp/ccBZvhnl.o: No such file or directory
Language: C++

#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
const ll MOD = 1000000007;
const int INF = 1000000;
int N,M,x,y,ans=1,temp,A[45],B[45],C[60];
double per;
bool vis[100][100][100]={0};
int dp[402][402][402]={INF};

int main(){
    dp[0][0][0]=0;
    scanf("%d %d %d",N,x,y);
    per=x/y;
    REP(i,N){
        scanf("%d %d %d",&A[i],&B[i],&C[i]);
    }
    REP(i,N)
        REP(a,400)
            REP(b,400){
                if(dp[i][a][b])continue;
        dp[i+1][a][b]=min(dp[i+1][a][b],dp[i][a][b]);
        dp[i+1][a+A[i]][b+B[i]]=min(dp[i+1][a+A[i]][b+B[i]],dp[i][a][b]+C[i]);

    }
    ans=INF;
    EREP(i,400)
        EREP(j,400){
        if(x*j==y*i)ans=min(ans,dp[N][i][j]);
    }
    if(ans==INF)ans=-1;
    cout<<ans;
    return 0;
}

Compiler output:
/tmp/ccQdbzeH.s: Assembler messages:
/tmp/ccQdbzeH.s: Fatal error: can't fill 256 bytes in section .data of /tmp/ccTt8nLH.o: 'No space left on device'
/tmp/ccQdbzeH.s: Fatal error: /tmp/ccTt8nLH.o: No such file or directory
Language: C++

#include<iostream>
using namespace std;


int main(void){


	int N,Ma,Mb;
	cin>>N>>Ma>>Mb;

	//それぞれ物質Aの含有量,Bの含有量,値段の合計の最大値
	const int amax=400;
	const int bmax=400;
	const int pmax=100000;

	//リストを作成してすべてを最大値に初期化
	int list[N+1][amax+1][bmax+1];
	for(int i=0;i<N+1;i++){
		for(int a=0;a<amax+1;a++){
			for(int b=0;b<bmax+1;b++){
				list[i][a][b]=pmax;
			}
		}
	}

	//物質AもBもないのは何も買わず、コストも0
	for(int i=0;i<=N;i++){
		list[i][0][0]=0;
	}

	//動的計画法のメイン部分
	int a,b,p;
	for(int i=1;i<=N;i++){

		cin>>a>>b>>p;
		for(int anow=a;anow<=amax;anow++){
			for(int bnow=b;bnow<=bmax;bnow++){
				if( (list[i-1][anow-a][bnow-b]+p)<list[i-1][anow][bnow] ){
					list[i][anow][bnow]=list[i-1][anow-a][bnow-b]+p;
				}
				else list[i][anow][bnow]=list[i-1][anow][bnow];
			}
		}


	}

/*
	for(a=0;a<=bmax;a++){
		for(b=0;b<=bmax;b++){
			cout<<list[N][a][b];
		}
		cout<<endl;
	}
*/

	int cost=INF;
	for(a=1;a<=bmax;a++){
		for(b=1;b<=bmax;b++){
			if(a*Mb==b*Ma&&list[N][a][b]<cost) cost=list[N][a][b];
		}
	}

	if(cost==INF) cout<<"-1";
	else cout<<cost;

	return 0;

}






Compiler output:
a.cc: In function 'int main()':
a.cc:57:18: error: 'INF' was not declared in this scope
   57 |         int cost=INF;
      |                  ^~~
Language: C++

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

int main()
{
	int N, Ma, Mb, a, b, c;
	cin >> N >> Ma >> Mb;

	vector<int> veca(N);
	vector<int> vecb(N);
	vector<int> vecc(N);
	for (int i = 0; i < N; i++)
		cin >> veca[i] >> vecb[i] >> vecc[i];

	int ZaiMax = N * 10;
	vector<int> vecCB(ZaiMax +1, INT_MAX);
	vector<vector<int>> vecCAB(ZaiMax +1, vecCB);
	vector<vector<vector<int>>> dp(N+1, vecCAB);
	
	dp[0][0][0] = 0;

	for (int i = 0; i < N; i++) {
		for (int ca = 0; ca <= ZaiMax; ca++) {
			for (int cb = 0; cb <= ZaiMax; cb++) {
				if (dp[i][ca][cb] == INT_MAX)
					continue;
				dp[i + 1][ca][cb] = min(dp[i + 1][ca][cb], dp[i][ca][cb]);
				dp[i + 1][ca + veca[i]][cb + vecb[i]] = min(dp[i + 1][ca + veca[i]][cb + vecb[i]], dp[i][ca][cb] + vecc[i]);
			}
		}
	}

	int res = INT_MAX;
	for (int ca = 1; ca <= ZaiMax; ca++) {
		for (int cb = 1; cb <= ZaiMax; cb++) {
			if (ca * Mb == cb * Ma)
				res = min(res, dp[N][ca][cb]);
		}
	}
	if (res == INT_MAX)
		res = -1;

	cout << res << endl;

	return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:19:38: error: 'INT_MAX' was not declared in this scope
   19 |         vector<int> vecCB(ZaiMax +1, INT_MAX);
      |                                      ^~~~~~~
a.cc:5:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    4 | #include <limits>
  +++ |+#include <climits>
    5 | using namespace std;
Language: C++

#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <functional>

using namespace std;
typedef long long ll;
#define pl pair<ll,ll>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define foreach(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); itr++)
#define dbg(x) cout << #x"="<< (x) << endl
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back(a) 
#define in(x) cin >> x;
#define all(x) (x).begin(), (x).end()
#define INF 2147483600
#define fi first
#define se second

ll ans=0,ll ansc=0;
//あとiだけ入る.今のスコア. どこまで見たか
ll solve(int i, int j, int k, vector<pl> a){
	if(i==0){
		return j;
	}else if(i<0||k>=a.size()){
		return INF;
	}else if(ans<j){
		return INF;
	}else{
		ans = min(ans,min(solve(i,j,k+1,a),solve(i-a[k].fi,j+a[k].se,k+1,a)));
		return ans;
	}
}

int main(){
	ll n, ma, mb, temp1, temp2, temp3;
	cin>>n>>ma>>mb;
	//ans=0,INFになるならエラー
	vector<pl> a,b;
	vector<pl> total;
	vector<ll> c;
	rep(i,n){
		cin>>temp1>>temp2>>temp3;
		//数学的考察から式を単純に
		temp1=mb*temp1-ma*temp2;
		if(temp1>0){
			a.pb(mp(temp1,temp3));
		}else if(temp1<0){
			b.pb(mp(-1*temp1,temp3));
		}else{
			c.pb(temp3);
		}
	}
	if(c.size()!=0){
		sort(all(c));
		ansc=min(ansc,c[0]);
	}
	//2つに分けれた.
	if(a.size()==0||b.size()==0){
		if(ans==0){
			cout<<-1<<endl;
		}else{
			cout<<ans<<endl;
		}
	}else{
		ans=INF;
		sort(all(a));
		sort(all(b));
		if(a.size()<b.size()){
			//これで2^20まで落とせたのでループで全探索できる.
			total.pb(mp(0,0));
			rep(i,a.size()){
				temp1=total.size();
				rep(j,temp1){
					temp2=total[j].fi+a[i].fi;
					temp3=total[j].se+a[i].se;
					total.pb(mp(temp2,temp3));
				}
			}
			//全状態を列挙したらナップサック問題.
			FOR(i,1,total.size()){
				//total[i].fiになる詰め込み方.
				solve(total[i].fi,total[i].se,0,b);
			}
		}else{
			total.pb(mp(0,0));
			rep(i,b.size()){
				temp1=total.size();
				rep(j,temp1){
					temp2=total[j].fi+b[i].fi;
					temp3=total[j].se+b[i].se;
					total.pb(mp(temp2,temp3));
				}
			}
			FOR(i,1,total.size()){
				//total[i].fiになる詰め込み方.
				// dbg(ans);
				// dbg(solve(total[i].fi,total[i].se,0,a));
				solve(total[i].fi,total[i].se,0,a);
			}
		}
		ans=min(ansc,ans);
		if(ans==0||ans==INF){
			cout<<-1<<endl;
		}else{
			cout<<ans<<endl;
		}
	}
	return 0;
}














Compiler output:
a.cc:32:13: error: expected initializer before 'ansc'
   32 | ll ans=0,ll ansc=0;
      |             ^~~~
a.cc: In function 'int main()':
a.cc:68:17: error: 'ansc' was not declared in this scope; did you mean 'ans'?
   68 |                 ansc=min(ansc,c[0]);
      |                 ^~~~
      |                 ans
a.cc:114:25: error: 'ansc' was not declared in this scope; did you mean 'ans'?
  114 |                 ans=min(ansc,ans);
      |                         ^~~~
      |                         ans
Language: C

#include<stdio.h>
#include<stdlib.h>

int main(){
  long int N,Ma,Mb,**abc,i,j,k,x[2],ans=INT32_MAX,tmp;
  scanf("%ld%ld%ld",&N,&Ma,&Mb);
  abc=malloc(sizeof(int)*N*3);
  for(i=0;i<N;i++)abc[i]=malloc(sizeof(int)*3);
  for(i=0;i<N;i++)for(j=0;j<3;j++)scanf("%ld",&abc[i][j]);

  for(i=0;i<N;i++){
    for(j=i;j<N;j++){
      x[0]= Ma*abc[j][1]-Mb*abc[j][0];
      x[1]=-Ma*abc[i][1]+Mb*abc[i][0];
      if (x[0]*x[1]>0){
        tmp=x[0]*abc[i][2]+x[1]*abc[j][2];
        if(tmp<0)tmp=-tmp;
        ans+=(tmp-ans)&(tmp-ans>>31);
      }
    }
  }
  if(ans^INT32_MAX)printf("%d\n",ans);
  else puts("-1");
}

Compiler output:
main.c: In function 'main':
main.c:5:41: error: 'INT32_MAX' undeclared (first use in this function)
    5 |   long int N,Ma,Mb,**abc,i,j,k,x[2],ans=INT32_MAX,tmp;
      |                                         ^~~~~~~~~
main.c:3:1: note: 'INT32_MAX' is defined in header '<stdint.h>'; this is probably fixable by adding '#include <stdint.h>'
    2 | #include<stdlib.h>
  +++ |+#include <stdint.h>
    3 | 
main.c:5:41: note: each undeclared identifier is reported only once for each function it appears in
    5 |   long int N,Ma,Mb,**abc,i,j,k,x[2],ans=INT32_MAX,tmp;
      |                                         ^~~~~~~~~
Language: C

#include <stdio.h>
#define inf 4001

int main(void)
{
  int N;
  int Ma, Mb;
  int a[41], b[41], c[41];
  static int dp[41][401][401];
  int i, ca, cb;
  int amax = 0;
  int bmax = 0;
  int ans;
  int tmp1;
  int tmp2;

  scanf("%d %d %d", &N, &Ma, &Mb);
  for(i = 0; i < N; i++) {
    scanf("%d %d %d", &a[i], &b[i], &c[i]);
    amax += a[i];
    bmax += b[i];
  }
  
  for(i = 0; i < N; i++) {
    for(ca = 0; ca <= amax; ca++) {
      for(cb = 0; cb <= bmax; cb++) {
	dp[i][ca][cb] = inf;
      }
    }
  }  
  dp[0][a[0]][b[0]] = c[0];
  dp[0][0][0] = 0;
  
  for(i = 1; i < N; i++) {
    for(ca = 0; ca <= amax; ca++) {
      for(cb = 0; cb <= bmax; cb++) {
	// iを入れる
	if(ca >= a[i] && cb >= b[i]) {
	  tmp1 = dp[i-1][ca-a[i]][cb-b[i]] + c[i];
	} else {
	  tmp1 = inf;
	}
	// iをいれない
	tmp2 = dp[i-1][ca][cb];
	if(tmp1 < tmp2) {
	  dp[i][ca][cb] = tmp1;
	} else {
	  dp[i][ca][cb] = tmp2;
	}
      }
    }
  }
  
  ans = inf;
  for(ca = 0; ca <= amax; ca++) {
    for(cb = 0; cb <= bmax; cb++) {
      if(ca*Mb == cb*Ma && dp[N-1][ca][cb] != 0) {
	if(ans > dp[N-1][ca][cb]) {
	  ans = dp[N-1][ca][cb];
	}
      }
    }
  }
  if(ans == inf) {
    printf("%d\n", -1);
  } else {
    printf("%d\n", and);
  }
  return 0;
}


Compiler output:
main.c: In function 'main':
main.c:67:20: error: 'and' undeclared (first use in this function); did you mean 'ans'?
   67 |     printf("%d\n", and);
      |                    ^~~
      |                    ans
main.c:67:20: note: each undeclared identifier is reported only once for each function it appears in