criyle/codenet-compile-errors huggingface dataset:
Language: Java

import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    int[][] edge = new int[N][N];
    for(int i = 0; i < M; i++) {
      int a = sc.nextInt();
      int b = sc.nextInt();
      edge[a - 1][b - 1] = 1;
      edge[b - 1][a - 1] = 1;
    }
    int[] p = new int[N];
    int count = 0;
    void dfs(int pos, int mask) {
      if(pos == N) {
        int c = 0;
        for(int i = 0; i < N - 1; i++) {
          if(edge[p[i]][p[i + 1]] == 0) {
            c++;
            break;
          }
        }
        if(c == 0) count++;
      }
      for(int i = 0; i < N; i++) {
        if(mask & (1 << i) != 0) {
          p[pos] = i;
          dfs(pos + 1, (mask ^ (1 << i)));
        }
      }
    }
    System.out.println(dfs(1, (1 << N) - 2));
  }
}

Compiler output:
Main.java:17: error: illegal start of expression
    void dfs(int pos, int mask) {
    ^
Main.java:17: error: ';' expected
    void dfs(int pos, int mask) {
            ^
Main.java:17: error: <identifier> expected
    void dfs(int pos, int mask) {
                     ^
Main.java:17: error: ';' expected
    void dfs(int pos, int mask) {
                              ^
4 errors
Language: C++

#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <limits.h>
#include <stdbool.h>

typedef struct edge{
	int u,v;
} EDGE;

int search(int n,int visited[],int node[n][n],int position){
	int node_local[n][n];
	int visited_local[n];
	memcpy(node_local,node,sizeof(int)*n*n);
	memcpy(visited_local,visited,sizeof(int)*n);
	int i,j;
	int sum=0;
	visited_local[position]=1;
	
	/* puts("==========");
	printf("node:%d\n",position+1);
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			printf("%d",node_local[i][j]);
		}puts("");
	}
	printf("visited node\n");
	for(i=0;i<n;i++){
		printf("%d",visited_local[i]);
	}puts("");
	puts("=========="); */
	
	visited_local[position]=1;
	for(i=0;i<n;i++){
		if(node_local[position][i]==1){
			node_local[position][i]=0;
			if(visited_local[i]==0){
				sum+=search(n,visited_local,node_local,i);
			}
		}
	}
	
	int allVisited=1;
	for(i=0;i<n;i++){
		if(visited_local[i]==0){
			allVisited=0;
			break;
		}
	}
	
	return sum+allVisited;
}

int main(){
	int n,m;
	scanf("%d %d",&n,&m);
	EDGE e[m];
	int node[n][n];
	int visited[n];
	int i,j;
	for(i=0;i<n;i++){
		visited[i]=0;
		for(j=0;j<n;j++){
			node[i][j]=0;
		}
	}
	
	for(i=0;i<m;i++){
		scanf("%d %d",&e[i].u,&e[i].v);
		e[i].u--;e[i].v--;
		node[e[i].u][e[i].v]=1;
		node[e[i].v][e[i].u]=1;
	}
	
	int position=0;
	printf("%d\n",search(n,visited,node,position));
	
	return 0;
}


Compiler output:
a.cc:13:42: error: use of parameter outside function body before ']' token
   13 | int search(int n,int visited[],int node[n][n],int position){
      |                                          ^
a.cc:13:45: error: use of parameter outside function body before ']' token
   13 | int search(int n,int visited[],int node[n][n],int position){
      |                                             ^
a.cc:13:46: error: expected ')' before ',' token
   13 | int search(int n,int visited[],int node[n][n],int position){
      |           ~                                  ^
      |                                              )
a.cc:13:47: error: expected unqualified-id before 'int'
   13 | int search(int n,int visited[],int node[n][n],int position){
      |                                               ^~~
Language: C++

#include <string>
#include <sstream>
#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
#include <functional>
#include <map>
#include <climits>
#include <queue>

using namespace std;

#define ll long long

class Main {
public:
	int rec(int n, vector<pair<int, int> >& edges, vector<bool>& prevs, int last) {
		bool isCleared = true;
		for (int i = 0;i < prevs.size();i++) {
			isCleared ^= prevs[i];
		}
		if (isCleared) {
			cout << last << endl;
			return 1;
		}

		int sum = 0;
		for (auto itr = edges.begin();itr != edges.end();++itr) {
			auto edge = (*itr);
			int v = last;

			if (edge.first == v || edge.second == v) {
				int u = (edge.first == v ? edge.second : edge.first);

				if (prevs[u]) continue;

				prevs[u] = true;
				sum += rec(n, edges, prevs, u);
				prevs[u] = false;
			}
		}

		return sum;
	}

	int getNum(int n,vector<pair<int, int> >& edges, int start){
		vector<bool> prevs(n, false);
		prevs[start] = true;

		return rec(n, edges, prevs, start);
	}
};

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

import java.util.*;
public class Main{
	static int result=0;
	static int N;
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		 N= sc.nextInt();
		int M=sc.nextInt();
		int[] a=new int[M];
		int[] b=new int[M];
		for(int i=0;i<M;i++){
			a[i]=sc.nextInt()-1;
			b[i]=sc.nextInt()-1;
		}
		sub2(a,b,(int)Math.pow(2, N)-2,0);
		System.out.println(result);				

	}

Compiler output:
Main.java:18: error: reached end of file while parsing
	}
	 ^
1 error
Language: C++

import java.util.*;
public class Main{
	static int result=0;
	static int N;
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		 N= sc.nextInt();
		int M=sc.nextInt();
		int[] a=new int[M];
		int[] b=new int[M];
		for(int i=0;i<M;i++){
			a[i]=sc.nextInt()-1;
			b[i]=sc.nextInt()-1;
		}
		sub2(a,b,(int)Math.pow(2, N)-2,0);
		System.out.println(result);				

	}
	public static void sub2(int[]a,int[]b,int pass,int pos){
		if(pass==0){
			result++;
			return;
		}
		for(int i=0;i<N;i++){
			if((pass/(int)Math.pow(2,i))%2==1){
				if(sub1(a,b,pos,i)){
					sub2(a,b,pass-(int)Math.pow(2,i),i);
				}
				
			}
		}
		return;
	}
	public static boolean sub1(int[] a,int[] b,int n,int m){
		for(int i=0;i<a.length;i++){
				if(a[i]==n&&b[i]==m){
					return true;
				}
				if(a[i]==m&&b[i]==n){
					return true;
				}
		}
		return false;
	}
}

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

#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <fstream>
#include <limits>

using namespace std;

template<class T = int,T divided_by = 10>
constexpr T PINF(){ return std::numeric_limits<T>::max()/divided_by; }
template<class T = int,T divided_by = 10>
constexpr T MINF(){ return std::numeric_limits<T>::lowest()/divided_by; }

template<class T = int> T gcd(T a, T b){ return b ? gcd(b,a%b) : a; }
template<class T = int> T lcm(T a, T b){ return a / gcd(a,b) * b; }
template<class T = int> T lcm_safe(T a, T b){ T p = a/gcd(a,b); return (b <= PINF<T>()/p) ? p*b:PINF<T>(); }
//オーバーフローするとき+INFを返す
//
int main() {
	cin.tie(nullptr); ios::sync_with_stdio(false);
	int n,m;
	cin >> n >> m;

	vector<set<int>> v(n);
	for(int i = 0; i < m; ++i){
		int a,b;
		cin >> a >> b;
		a--;
		b--;
		v[a].insert(b);
		v[b].insert(a);
	}

	vector<vector<int>> seqs(100000, vector<int>());

	vector<int> nodes(n-1);
    iota(nodes.begin(), nodes.end(), 1);       // v に 1, 2, ... N を設定
    int ans = 0;
    do {
    	// for(auto nextNode : nodes) cout << nextNode << " "; cout << "\n";    // v の要素を表示
    	int curNode = 0;
    	bool isOk = true;
        for(auto nextNode : nodes) {
        	bool hasNextNode = v[curNode].find(nextNode) != v[curNode].end();
        	isOk = isOk && hasNextNode;

        	curNode = nextNode;
        }
        if(isOk) ans++;
    } while( next_permutation(nodes.begin(), nodes.end()) );     // 次の順列を生成

    cout << ans << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:44:5: error: 'iota' was not declared in this scope
   44 |     iota(nodes.begin(), nodes.end(), 1);       // v に 1, 2, ... N を設定
      |     ^~~~
Language: C++

#include<iostream>
#include<algorithm>

using namespace std;

int main(){

   int N, M;
   cin>> N>> M;
   int g[10][10];
   for(int i=0; i<N; i++){
      for(int j=0; j<N; j++){
         g[i][j]=0;
      }
   }
   for(int i=0; i<M; i++){
      int a, b;
      cin>> a>> b;
      a--; b--;
//      g[a].push_back(b);
//      g[b].push_back(a);
      g[a][b]=g[b][a]=1;
   }

   vector<int> _v;
   int r=0;
   for(int i=1; i<N; i++) _v.push_back(i);
   do{
      bool ok=true;
      int p=0;
      for(int j: _v){
         ok&=g[p][j];
         p=j;
      }
      if(ok) r++;
   }while(next_permutation(_v.begin(), _v.end()));

   cout<< r<< endl;

   return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:25:4: error: 'vector' was not declared in this scope
   25 |    vector<int> _v;
      |    ^~~~~~
a.cc:3:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    2 | #include<algorithm>
  +++ |+#include <vector>
    3 | 
a.cc:25:11: error: expected primary-expression before 'int'
   25 |    vector<int> _v;
      |           ^~~
a.cc:27:27: error: '_v' was not declared in this scope
   27 |    for(int i=1; i<N; i++) _v.push_back(i);
      |                           ^~
a.cc:31:18: error: '_v' was not declared in this scope
   31 |       for(int j: _v){
      |                  ^~
a.cc:36:28: error: '_v' was not declared in this scope
   36 |    }while(next_permutation(_v.begin(), _v.end()));
      |                            ^~
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:7:1: error: 'cin' was not declared in this scope
    7 | cin >> n >> ma >> mb;
      | ^~~
a.cc:28:18: error: 'min' was not declared in this scope; did you mean 'main'?
   28 |  dp[i+1][ca][cb]=min(dp[i+1][ca][cb],dp[i][ca][cb]);
      |                  ^~~
      |                  main
a.cc:37:23: error: 'min' was not declared in this scope; did you mean 'main'?
   37 |  if(ca*mb==cb*ma) ans=min(ans,dp[n][ca][cb]);
      |                       ^~~
      |                       main
a.cc:42:2: error: 'cout' was not declared in this scope
   42 |  cout << ans << endl;
      |  ^~~~
a.cc:42:17: error: 'endl' was not declared in this scope
   42 |  cout << ans << endl;
      |                 ^~~~
Language: C++

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<iostream>
#include<cstdint>
#include<cstddef>
#include<vector>
#include<algorithm>
using namespace std;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
using usize = uint_fast64_t;
#define rep(i, n) for (usize i = 0; i < (usize)(n); i++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using P = pair<i64,i64>;
i64 dp[404][404][4004];//aの値,bの値,料金
int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
i32 n,m_a,m_b;
cin >> n >> m_a >> m_b;
vector<i32> a(n),b(n),c(n);
rep(i,n)cin >> a[i] >> b[i] >> c[i];
dp[0][0][0] = 1;
rep(i,n){
    for(i32 j = 400; 0 <= j; j--){
        for(i32 k = 400; 0 <= k; k--){
            for(i32 l = 4000; 0 <= l; l--){
                if(dp[j][k][l] != 0){
                    dp[j + a[i]][k + b[i]][l + c[i]] = 1;
                }
            }
        }
    }
}
i64 ans = 1e18;
for(i32 i = 1; i * max(m_a,m_b) <= 400; i++){
    for(i32 j = 0; j <= 4000; j++){
        if(dp[i * m_a][i * m_b][j])ans = min(ans,j);
    }
}
cout << (ans == 1e18 ? -1 : ans) << endl;
}

Compiler output:
In file included from /usr/include/c++/14/string:43,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:4:
/usr/include/c++/14/bits/allocator.h: In destructor 'std::_Vector_base<long int, std::allocator<long int> >::_Vector_impl::~_Vector_impl()':
/usr/include/c++/14/bits/allocator.h:182:7: error: inlining failed in call to 'always_inline' 'std::allocator< <template-parameter-1-1> >::~allocator() noexcept [with _Tp = long int]': target specific option mismatch
  182 |       ~allocator() _GLIBCXX_NOTHROW { }
      |       ^
In file included from /usr/include/c++/14/vector:66,
                 from a.cc:7:
/usr/include/c++/14/bits/stl_vector.h:132:14: note: called from here
  132 |       struct _Vector_impl
      |              ^~~~~~~~~~~~
Language: C++

#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<typename T> bool chmax(T &a,T b) {if(a<b) {a=b; return true;} return false;}
template<typename T> bool chmin(T &a,T b) {if(a>b) {a=b; return true;} return false;}
#define itn int
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>=1;i--)
#define all(vec) vec.begin(),vec.end()
#define sortt(vec) sort((vec).begin(),(vec).end())
#define rsort(vec) sort((vec).rbegin(), (vec).rend())
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> tlll;
typedef tuple<int,int,int> tiii;
const ll mod=1e9+7;
const int inf=2e9;
const ll lnf=9e18;

ll gcd(ll a,ll b){
  if(a%b==0)
    return b;
  return gcd(b,a%b);
}

ll dp[41][410][410];

int main(){
  int n,ma,mb; cin >> n >> ma >> mb;
  rep(z,41)rep(i,410)rep(j,410) dp]z][i][j]=inf;
  dp[0][0][0]=0;
  rep(z,n){
    int a,b,c;
    cin >> a >> b >> c;
    rep(i,410)rep(j,410){
      if(i+a<410&&j+b<410) chmin(dp[z+1][i+a][j+b],dp[z][i][j]+c);
    }
  }
  ll ans=inf;
  rep(i,410)rep(j,410){
    if(i==0||j==0) continue;
    ll GCD=gcd(i,j);
    if(i/GCD==ma&&j/GCD==mb) chmin(ans,dp[n][i][j]);
  }
  if(ans==inf) cout << -1 << endl;
  else cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:36:35: error: expected ';' before ']' token
   36 |   rep(z,41)rep(i,410)rep(j,410) dp]z][i][j]=inf;
      |                                   ^
      |                                   ;
Language: C++


import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner  sc=new Scanner(System.in);
	
	          int n=sc.nextInt();
	          int ma=sc.nextInt();
	          int mb=sc.nextInt();
	       int a[]=new int[n];
	       int b[]=new int[n];
	       int c[]=new int[n];
	       for(int i=0;i<n;i++) {
	       	int x=sc.nextInt();
	       	int y=sc.nextInt();
	       	int z=sc.nextInt();
	       	a[i]=x;
	       	b[i]=y;
	       	c[i]=z;
	       }
	       int dp[][][]=new int[n+1][601][601];
	     
	       for(int i=0;i<=n;i++) {
	       	for(int j=0;j<=500;j++) {
	       		for(int k=0;k<=500;k++) {
	       			dp[i][j][k]=Integer.MAX_VALUE;
	       		}
	       	}
	       }
	       dp[0][0][0]=0;
	       for(int i=1;i<=n;i++) {
	       	for(int j=0;j<=500;j++) {
	       		for(int k=0;k<=500;k++) {
	       			dp[i][j][k]=dp[i-1][j][k];
	       			if(j-a[i-1]>=0 && k-b[i-1]>=0 && dp[i-1][j-a[i-1]][k-b[i-1]]!=Integer.MAX_VALUE)
	       			dp[i][j][k]=Math.min(	dp[i-1][j-a[i-1]][k-b[i-1]]+c[i-1],dp[i][j][k]);
	       			
	       		}
	       	}
	       }
	       int ans=Integer.MAX_VALUE;
	      
	       	for(int j=1;j<=500;j++) {
	       		for(int k=1;k<=500;k++) {
	       			if(dp[n][j][k] !=Integer.MAX_VALUE) {
	       		if((j*mb)==(k*ma)) {
	       			ans=Math.min(ans,dp[n][j][k]);
	       		}
	       		}
	       		}
	       	}
	       if(ans==Integer.MAX_VALUE) {
	       	System.out.println(-1);
	       }else {
	       	System.out.println(ans);
	       }
	       
	       
	       
	       
	       
	       
	       
	       

		}
	static boolean isValid(int i,int j,int r,int c ) {
			return i>=0&&j>=0&&i<r&&j<c;
	}
	static int[] arr(int n,Scanner sc) {
		int a[]=new int[n];
		for(int i=0;i<n;i++) {
			a[i]=sc.nextInt();
		}
		return a;
}
	}
class let{
	int x,y,z;
	let(int x,int y,int z){
		this.x=x;
		this.y=y;
		this.z=z;
	}
}


Compiler output:
a.cc:2:1: error: 'import' does not name a type
    2 | import java.util.*;
      | ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:3:1: error: expected unqualified-id before 'public'
    3 | public class Main {
      | ^~~~~~
a.cc:86:2: error: expected ';' after class definition
   86 | }
      |  ^
      |  ;
a.cc: In constructor 'let::let(int, int, int)':
a.cc:82:22: error: request for member 'x' in '(let*)this', which is of pointer type 'let*' (maybe you meant to use '->' ?)
   82 |                 this.x=x;
      |                      ^
a.cc:83:22: error: request for member 'y' in '(let*)this', which is of pointer type 'let*' (maybe you meant to use '->' ?)
   83 |                 this.y=y;
      |                      ^
a.cc:84:22: error: request for member 'z' in '(let*)this', which is of pointer type 'let*' (maybe you meant to use '->' ?)
   84 |                 this.z=z;
      |                      ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define all(n) begin(n), end(n)
typedef long long ll;

template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}

int main()
{
    int N, Ma, Mb;
    cin >> N >> Ma >> Mb;
    int ans = 1e9;

    vector<tuple<int, int, int>> t1(N / 2), t2(N - N / 2); //前半と後半
    for (size_t i = 0; i < N; i++)
    {
        int a, b, c;
        cin >> a >> b >> c;
        if (i < N / 2)
            t1[i] = {a, b, c};
        else
        {
            t2[i - N / 2] = {a, b, c};
        }
    }
    vector<pair<int, int>> T2; //探す値を持っておく配列 後半の配列をbit全探索して入れていく
    for (int bit = 0; bit < (1 << t2.size()); bit++)
    {
        int a = 0, b = 0, c = 0;
        for (int i = 0; i < t2.size(); i++)
        {
            auto [A, B, C] = t2[i];
            if (bit & (1 << i))
            {
                a += A;
                b += B;
                c += C;
            }
        }
        
        T2.push_back({b * Ma - a * Mb, c});
        int d=b*Na-a*Nb;
        if(d==0 && c>0){
            chmin(ans,c);
        }
    }
    sort(all(T2)); //普通のpair<int,int>の順序で昇順ソート
    for (int bit = 0; bit < (1LL << t1.size()); bit++)
    {
        int a = 0, b = 0, c = 0;
        for (size_t i = 0; i < t1.size(); i++)
        {
            auto [A, B, C] = t1[i];
            if (bit & (1LL << i))
            {
                a += A;
                b += B;
                c += C;
            }
        }
        
        int d = a * Mb - b * Ma; //このdの値がT2に入ってるか二分探索で調べる
        ll ok = T2.size() - 1, ng = -1;
        while (abs(ok - ng) > 1)
        {
            ll mid = (ok + ng) / 2;
            if (T2[mid].first >= d)
                ok = mid;
            else
                ng = mid;
        }
        //この時点でokは 「T2[i].second >= dを満たすようなiの集合」 の最小値になっているはず(あるいはその集合は空)
        if (T2[ok].first == d and c + T2[ok].second > 0) 
        {
                chmin(ans, c + T2[ok].second);
        }
        if(d==0 && c>0){
            chmin(ans,c);
        }
    }
    if (ans != 1e9)
        cout << ans << endl;
    else
        cout << -1 << endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:51:17: error: 'Na' was not declared in this scope; did you mean 'a'?
   51 |         int d=b*Na-a*Nb;
      |                 ^~
      |                 a
a.cc:51:22: error: 'Nb' was not declared in this scope; did you mean 'b'?
   51 |         int d=b*Na-a*Nb;
      |                      ^~
      |                      b
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
ll gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }     //最小公倍数
using Graph = vector<vector<ll>>;
ll inf=300000000000000000;
const double PI = 3.14159265358979323846;
int main(){
  int n,a,b;
  cin >> n >> a >> b;
  int x[n];
  int y[n];
  int z[n];
  rep(i,n)cin >> x[i] >> y[i] >> z[i];
  int dp[n+1][401][401];
  rep(i,n+1)rep(j,40i)rep(o,401)dp[i][j][o]=1000000000;
  dp[0][0][0]=[0];
  rep(i,n){
    rep(j,401)rep(o,401)dp[i+1][j][o]=dp[i][j][o];
    rep(j,401){
      rep(o,401){
        if(j-x[i]<0||o-y[i]<0)continue;
        dp[i+1][j][o]=min(dp[i+1][j][o],dp[i][j-x[i]][o-y[i]]+z[i]);
      }
    }
  }
  int ans=1000000000;
  rep(i,400){
    rep(j,400){
      if((i+1)/(gcd(i+1,j+1))==a&&(j+1)/(gcd(i+1,j+1)))ans=min(ans,dp[n][i+1][j+1])
    }
  }
  if(ans==1000000000){
    cout << -1 << endl;
  }
  else cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:3:39: error: invalid cast from type 'std::complex<double>' to type 'int'
    3 | #define rep(i, n) for (int i = 0; i < (int)(n); i++)
      |                                       ^~~~~~~~
a.cc:18:13: note: in expansion of macro 'rep'
   18 |   rep(i,n+1)rep(j,40i)rep(o,401)dp[i][j][o]=1000000000;
      |             ^~~
a.cc:19:16: error: expected identifier before numeric constant
   19 |   dp[0][0][0]=[0];
      |                ^
a.cc: In lambda function:
a.cc:19:18: error: expected '{' before ';' token
   19 |   dp[0][0][0]=[0];
      |                  ^
a.cc: In function 'int main()':
a.cc:19:15: error: invalid user-defined conversion from 'main()::<lambda()>' to 'int' [-fpermissive]
   19 |   dp[0][0][0]=[0];
      |               ^~~
a.cc:19:15: note: candidate is: 'constexpr main()::<lambda()>::operator void (*)()() const' (near match)
   19 |   dp[0][0][0]=[0];
      |               ^
a.cc:19:15: note:   no known conversion from 'void (*)()' to 'int'
a.cc:32:84: error: expected ';' before '}' token
   32 |       if((i+1)/(gcd(i+1,j+1))==a&&(j+1)/(gcd(i+1,j+1)))ans=min(ans,dp[n][i+1][j+1])
      |                                                                                    ^
      |                                                                                    ;
   33 |     }
      |     ~
Language: C++

#include <bits/stdc++.h>

#include <boost/rational.hpp>

using namespace std;
using i64 = long long;
using u64 = unsigned long long;
#define REP(i, n) for (int i = 0; (i64)(i) < (i64)(n); ++i)

const int INF = 1 << 30;

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

  int N, ma, mb;
  cin >> N >> ma >> mb;

  int mincost = INF;
  vector<tuple<int, int>> x_minus, x_plus;
  REP(i, N) {
    int a, b, c;
    cin >> a >> b >> c;
    int x = a * mb - ma * b;
    if (x == 0) {
      if (mincost > c) {
        mincost = c;
        // cerr << "x = 0, cost = " << c << endl;
      }
    } else if (x < 0) {
      x_minus.emplace_back(c, -x);
    } else {
      x_plus.emplace_back(c, x);
    }
  }

  // dp_*[i] := mincost of total weight i.
  const int XMAX = 1000;
  vector<int> dp_plus(XMAX + 1, INF), dp_minus(XMAX + 1, INF);
  dp_plus[0] = dp_minus[0] = 0;
  REP(i, x_plus.size()) {
    auto [ci, xi] = x_plus[i];
    for (int w = XMAX - xi; w >= 0; --w) {
      dp_plus[w + xi] = min(dp_plus[w + xi], dp_plus[w] + ci);
    }
  }
  REP(i, x_minus.size()) {
    auto [ci, xi] = x_minus[i];
    for (int w = XMAX - xi; w >= 0; --w) {
      dp_minus[w + xi] = min(dp_minus[w + xi], dp_minus[w] + ci);
    }
  }
  REP(w, XMAX) {
    int wp = dp_plus[w + 1], wm = dp_minus[w + 1];
    if (wp != INF && wm != INF && mincost > wp + wm) {
      //   cerr << "Found: weight = " << (wp + wm) << " (" << wp << " + " << wm
      //        << ")\n";
      mincost = wp + wm;
    }
  }
  cout << (mincost == INF ? -1 : mincost) << endl;
}

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

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

int main() {
  int N,A,B;
  cin>>N>>A>>B;
  vector<vector<vector<int>>> dp(N,vector<vector<int>>(401,vector<int>(401,5000)));
  int a,b,c;
  cin>>a>>b>>c;
  dp.at(0).at(0).at(0)=0,dp.at(0).at(a).at(b)=c;
  for(int i=1;i<N;i++){
    cin>>a>>b>>c;
    for(int j=0;j<401;j++){
      for(int k=0;k<401;k++){
        if(j>=a&&k>=b){
          dp.at(i).at(j).at(k)=min(dp.at(i-1).at(j).at(k),dp.at(i-1).at(j-a).at(k-b)+c);
        }
        else{
          dp.at(i).at(j).at(K)=dp.at(i-1).at(j).at(k);
        }
      }
    }
  }
  int X=A,Y=B,Z=5000;
  while(X<=400&&Y<=400){
    Z=min(Z,dp.at(N-1).at(X).at(Y));
    X+=A,Y+=B;
  }
  if(Z==5000){
    cout<<"-1"<<endl;
  }
  else{
    cout<<Z<<endl;
  }
                        
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:29: error: 'K' was not declared in this scope
   19 |           dp.at(i).at(j).at(K)=dp.at(i-1).at(j).at(k);
      |                             ^
Language: C++

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

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

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

//べき//
ll squ(ll n, ll p, ll m){
	if(p==0) return 1;
	if(p%2==0){
		ll t=squ(n, p/2, m);
		return t*t%m;
	}
	return n*squ(n,p-1,m);
	
}


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

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

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

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

//nが大

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

	return k;
}


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


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

ll med[n+1][3];
for(ll i=0;i<=n;i++){
for(int j=0;j<=2;j++){
	if(i==0){med[i][j]=0;
	continue;}
	cin>>med[i][j];
}
}

ll ans=1000000;
ll dp[401][401][n+1];

for(int k=0;k<=n;k++){
	
	ll p=med[k][0];
		ll q=med[k][1];
		ll val=med[k][2];
	
for(ll i=0;i<=400;i++){
for(ll j=0;j<=400;j++){

if(i==0 && j==0 ){dp[i][j][k]=0;
continue;}
if(k==0){dp[i][j][k]=1000000;
continue;}
if(i>=p && j>=q){
	dp[i][j][k]=min(dp[i-p][j-q][k-1]+val,dp[i][j][k-1]);
	continue;
}
dp[i][j][k]=dp[i][j][k-1];

}

}
}


for(ll i=1;i<=400;i++){
for(ll j=1;j<=400;j++){
if(i/ma==j/mb　&& i%ma==0 && j%mb==0){
	ans=min(ans,dp[i][j][n]);
	
}
}
}



if(ans==1000000){cout<<-1<<endl;}
else {cout<<ans<<endl;}
return 0;


}




Compiler output:
a.cc:137:12: error: extended character 　 is not valid in an identifier
  137 | if(i/ma==j/mb　&& i%ma==0 && j%mb==0){
      |            ^
a.cc: In function 'int main()':
a.cc:137:12: error: 'mb\U00003000' was not declared in this scope
  137 | if(i/ma==j/mb　&& i%ma==0 && j%mb==0){
      |            ^~~~
Language: C++

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

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

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

//べき//
ll squ(ll n, ll p, ll m){
	if(p==0) return 1;
	if(p%2==0){
		ll t=squ(n, p/2, m);
		return t*t%m;
	}
	return n*squ(n,p-1,m);
	
}


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

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

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

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

//nが大

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

	return k;
}


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


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

ll med[n+1][3];
for(ll i=0;i<=n;i++){
for(int j=0;j<=2;j++){
	if(i==0){med[i][j]=0;
	continue;}
	cin>>med[i][j];
}
}

ll ans=1000000;
ll dp[401][401][n+1];

for(int k=0;k<=n;k++){
	
	ll p=med[k][0];
		ll q=med[k][1];
		ll val=med[k][2];
	
for(ll i=0;i<=400;i++){
for(ll j=0;j<=400;j++){

if(i==0 && j==0 ){dp[i][j][k]=0;
continue;}
if(k==0){dp[i][j][k]=1000000;
continue;}
if(i>=p && j>=q){
	dp[i][j][k]=min(dp[i-p][j-q][k-1]+val,dp[i][j][k-1]);
	continue;
}
dp[i][j][k]=dp[i][j][k-1];

}

}
}


for(int i=1;i<=400;i++){
for(int j=1;j<=400;j++){
if(i/ma==j/mb　&& i%ma==0 && j%mb==0){
	ans=min(ans,dp[i][j][n]);
	
}
}
}



if(ans==1000000){cout<<-1<<endl;}
else {cout<<ans<<endl;}
return 0;


}




Compiler output:
a.cc:137:12: error: extended character 　 is not valid in an identifier
  137 | if(i/ma==j/mb　&& i%ma==0 && j%mb==0){
      |            ^
a.cc: In function 'int main()':
a.cc:137:12: error: 'mb\U00003000' was not declared in this scope
  137 | if(i/ma==j/mb　&& i%ma==0 && j%mb==0){
      |            ^~~~
Language: C++

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

#define fr(i,n) _back
#define pb	push_back
#define eb	emplace_back
#define mk	make_pair
#define fi	first
#define se	second
#define endl	'\n'

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<ii> vii;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);
const int Z = 4e2 + 10;
int n, ma,mb;
int dp[Z][Z];

int main() {
    ios_base::sync_with_stdio(false);
    cin >> n >> ma >> mb;

    memset(dp, INF, sizeof dp);
    dp[0][0] = 0;
    while(n--) {
        int a,b,c; cin >> a >> b >> c;
        for(int j = 0; j+a < Z; j++)
            for(int k = 0; k+b < Z; k++) {
                int &r = dp[j+a][k+b];
                r = min(r, dp[j][k]+c);
            }
    }

    int ans = INF;
    for(int i = 1; i*ma < Z and i*mb < Z; i++) ans = min(ans,dp[i*ma][i*mb]);
    cout << (ans == INF? -1 : ans) << endl;
    return 0;
}



Compiler output:
a.cc:1:3: error: stray '#' in program
    1 | +a#include <bits/stdc++.h>
      |   ^
a.cc:1:1: error: expected unqualified-id before '+' token
    1 | +a#include <bits/stdc++.h>
      | ^
a.cc:13:9: error: 'pair' does not name a type
   13 | typedef pair<int,int> ii;
      |         ^~~~
a.cc:14:9: error: 'vector' does not name a type
   14 | typedef vector<ii> vii;
      |         ^~~~~~
a.cc:16:19: error: 'acos' was not declared in this scope
   16 | const double PI = acos(-1.0);
      |                   ^~~~
a.cc: In function 'int main()':
a.cc:22:5: error: 'ios_base' has not been declared
   22 |     ios_base::sync_with_stdio(false);
      |     ^~~~~~~~
a.cc:23:5: error: 'cin' was not declared in this scope
   23 |     cin >> n >> ma >> mb;
      |     ^~~
a.cc:25:5: error: 'memset' was not declared in this scope
   25 |     memset(dp, INF, sizeof dp);
      |     ^~~~~~
a.cc:1:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
  +++ |+#include <cstring>
    1 | +a#include <bits/stdc++.h>
a.cc:32:21: error: 'min' was not declared in this scope; did you mean 'main'?
   32 |                 r = min(r, dp[j][k]+c);
      |                     ^~~
      |                     main
a.cc:37:54: error: 'min' was not declared in this scope; did you mean 'main'?
   37 |     for(int i = 1; i*ma < Z and i*mb < Z; i++) ans = min(ans,dp[i*ma][i*mb]);
      |                                                      ^~~
      |                                                      main
a.cc:38:5: error: 'cout' was not declared in this scope
   38 |     cout << (ans == INF? -1 : ans) << endl;
      |     ^~~~
Language: C++


N, Ma, Mb = map(int,input().split())
rate = Ma / Mb
a = [0] * N
b = [0] * N
c = [0] * N
MA = 0
MB = 0
MC = 0
for i in range(N):
    a[i], b[i], c[i] = map(int, input().split())
    MA += a[i]
    MB += b[i]
    MC += c[i]

dp = [[[MC for i in range(MB+1)] for j in range(MA+1)] for k in range(N+1)]
dp[0][0][0] = 0

for it_N in range(N):
    for it_MA in range(MA+1):
        for it_MB in range(MB+1):
            if it_MA >= a[it_N] and it_MB >= b[it_N]:
                if dp[it_N][it_MA-a[it_N]][it_MB-b[it_N]] != MC:
                    dp[it_N+1][it_MA][it_MB] = min(dp[it_N][it_MA-a[it_N]][it_MB-b[it_N]] + c[it_N], dp[it_N][it_MA][it_MB])
                else:
                    dp[it_N+1][it_MA][it_MB]=dp[it_N][it_MA][it_MB]
            else:
                dp[it_N+1][it_MA][it_MB]=dp[it_N][it_MA][it_MB]

ans = -1
for a in range(1, MA+1):
    for b in range(1, MB+1):
        if a/b == rate and dp[N][a][b] != MC:
            if ans == -1:
                ans = dp[N][a][b]
            else:
                ans = min(dp[N][a][b], ans)
print(ans)


Compiler output:
a.cc:2:1: error: 'N' does not name a type
    2 | N, Ma, Mb = map(int,input().split())
      | ^
Language: C++

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

#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for (int i = (n); i >= 0; i--)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

const int inf = 1000000;

int dp[41][401][401];

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

    int a[n], b[n], c[n];

    rep(i, n) cin >> a[i] >> b[i] >> c[i];

    rep(i, n + 1) rep(j, ) rep(k, ) dp[i][j][k] = inf;

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

    rep(i, n)
    {
        rep(j, )
        {
            rep(k, )
            {
                if (j - a[i] >= 0 && k - b[i] >= 0)
                    dp[i + 1][j][k] = min(dp[i][j - a[i]][k - b[i]] + c[i], dp[i + 1][j][k]);
                dp[i + 1][j][k] = min(dp[i + 1][j][k], dp[i][j][k]);
            }
        }
    }
    int ans = 1e7;

    rep(j, 401)
    {
        rep(k, 401)
        {
            if (j * k == 0)
                continue;
            if (j * mb == k * ma)
                ans = min(ans, dp[n][j][k]);
        }
    }

    OP((ans == inf ? -1 : ans));

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:43: error: expected primary-expression before ';' token
    9 | #define REP(i, x, n) for (int i = x; i < n; i++)
      |                                           ^
a.cc:5:19: note: in expansion of macro 'REP'
    5 | #define rep(i, n) REP(i, 0, n)
      |                   ^~~
a.cc:28:19: note: in expansion of macro 'rep'
   28 |     rep(i, n + 1) rep(j, ) rep(k, ) dp[i][j][k] = inf;
      |                   ^~~
a.cc:9:43: error: expected primary-expression before ';' token
    9 | #define REP(i, x, n) for (int i = x; i < n; i++)
      |                                           ^
a.cc:5:19: note: in expansion of macro 'REP'
    5 | #define rep(i, n) REP(i, 0, n)
      |                   ^~~
a.cc:28:28: note: in expansion of macro 'rep'
   28 |     rep(i, n + 1) rep(j, ) rep(k, ) dp[i][j][k] = inf;
      |                            ^~~
a.cc:9:43: error: expected primary-expression before ';' token
    9 | #define REP(i, x, n) for (int i = x; i < n; i++)
      |                                           ^
a.cc:5:19: note: in expansion of macro 'REP'
    5 | #define rep(i, n) REP(i, 0, n)
      |                   ^~~
a.cc:34:9: note: in expansion of macro 'rep'
   34 |         rep(j, )
      |         ^~~
a.cc:9:43: error: expected primary-expression before ';' token
    9 | #define REP(i, x, n) for (int i = x; i < n; i++)
      |                                           ^
a.cc:5:19: note: in expansion of macro 'REP'
    5 | #define rep(i, n) REP(i, 0, n)
      |                   ^~~
a.cc:36:13: note: in expansion of macro 'rep'
   36 |             rep(k, )
      |             ^~~
Language: C++

#include "iostream"
#include "vector"
#include "iomanip"
#include "algorithm"
#include "vector"

typedef struct {
	int a;
	int b;
	int c;
	int exist;
}Drag;

bool next_choice(std::vector<Drag> *d, long int *n, int *keta) {
	for(int i = 0; i < (*d).size(); ++i)
		if ((*d)[i].exist)
			(*d)[i].exist = false;
		else {
			(*d)[i].exist = true;
			(*n)++;
			*keta = log2(*n) + 1;
			return true;
		}
	return false;
}

Drag drag_mix(std::vector<Drag> d, int min, int keta) {
	Drag price = {0, 0, 0, 1};
	for (int i = 0; i < keta; ++i)
		if (d[i].exist) {
			price.a += d[i].a;
			price.b += d[i].b;
			price.c += d[i].c;
			if (price.c >= min && min != -1) {
				price.exist = 0;
				return price;
			}
		}
	return price;
}

int main() {
	int n;
	double ma, mb;
	std::cin >> n;
	std::cin >> ma;
	std::cin >> mb;

	std::vector<Drag> drag(n);
	for (int i = 0; i < n; ++i) {
		std::cin >> drag[i].a;
		std::cin >> drag[i].b;
		std::cin >> drag[i].c;
	}

	long int num = 0;
	int keta;
	double m = ma / mb;
	Drag mix;
	int min = -1;
	while(next_choice(&drag, &num, &keta)){
		mix = drag_mix(drag, min, keta);
		if (mix.exist && (double)mix.a / mix.b == m)
			if(min == -1 || mix.c < min)
				min = mix.c;
	};

	std::cout << min;
}

Compiler output:
a.cc: In function 'bool next_choice(std::vector<Drag>*, long int*, int*)':
a.cc:21:33: error: 'log2' was not declared in this scope
   21 |                         *keta = log2(*n) + 1;
      |                                 ^~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
const int MAXN = 40;
const int abmax = 10;
const int inf = 1000000;
int a[MAXN], b[MAXN],c[MAXN];
int dp[MAXN+1][MAXN*abmax+1][MAXN*abmax+1];

int main(){
    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<=MAXN;i++){
        for(int j=0;j<=MAXN*abmax;j++){
            for(int k=0;k<=MAXN*abmax;k++){
            dp[i][j][k]=inf;
            }
        }
    }
    dp[0][0][0] = 0;

    for(int i=0;i<N;i++){
        for(int j=0;j<=MAXN*abmax){
            for(int k=0;k<=MAXN*abmax){
                if(dp[i][j][k]==inf) continue;
                dp[i+1][j][k] = min(dp[i][j][k],dp[i+1][j][k]);
                dp[i+1][j+a[i]][k+b[i]] = min(dp[i+1][j][k],dp[i][j][k]+c[i]);
            }
        }
    }

    int ans=inf;
    for(int i=1;i<=MAXN*abmax; ++i){
        for(int j = 1;j<=MAXN*abmax;++j){
            if(i*Mb==j*Ma) ans = min(ans,dp[N][i][j]);
        }
    }

    if(ans==inf) ans=-1;
    cout << ans << endl;

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:34: error: expected ';' before ')' token
   26 |         for(int j=0;j<=MAXN*abmax){
      |                                  ^
      |                                  ;
a.cc:27:38: error: expected ';' before ')' token
   27 |             for(int k=0;k<=MAXN*abmax){
      |                                      ^
      |                                      ;
Language: C++

#include <bits/stdc++.h>
using namespace std;
const int MAXN = 40;
const int abmax = 10;
const int inf = 1000000;
int a[MAXN], b[MAXN],c[MAXN];
int dp[MAXN+1][MAXN*abmax+1][MAXN*abmax+1];

int main(){
    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<=MAXN;i++){
        for(int j=0;j<=MAXN*abmax){
            for(int k=0;k<=MAXN*abmax){
            dp[i][j][k]=inf;
            }
        }
    }
    dp[0][0][0] = 0;

    for(int i=0;i<N;i++){
        for(int j=0;j<=MAXN*abmax){
            for(int k=0;k<=MAXN*abmax){
                if(dp[i][j][k]==inf) continue;
                dp[i+1][j][k] = min(dp[i][j][k],dp[i+1][j][k]);
                dp[i+1][j+a[i]][k+b[i]] = min(dp[i+1][j][k],dp[i][j][k]+c[i]);
            }
        }
    }

    int ans=inf;
    for(int i=1;i<=MAXN*abmax; ++i){
        for(int j = 1;j<=MAXN*abmax;++j){
            if(i*Mb==j*Ma) ans = min(ans,dp[N][i][j]);
        }
    }

    if(ans==inf) ans=-1;
    cout << ans << endl;

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:34: error: expected ';' before ')' token
   17 |         for(int j=0;j<=MAXN*abmax){
      |                                  ^
      |                                  ;
a.cc:18:38: error: expected ';' before ')' token
   18 |             for(int k=0;k<=MAXN*abmax){
      |                                      ^
      |                                      ;
a.cc:26:34: error: expected ';' before ')' token
   26 |         for(int j=0;j<=MAXN*abmax){
      |                                  ^
      |                                  ;
a.cc:27:38: error: expected ';' before ')' token
   27 |             for(int k=0;k<=MAXN*abmax){
      |                                      ^
      |                                      ;
Language: C++

#include <bits/stdc++.h>
using namespace std;
const int MAXN = 40;
const int abmax = 10;
const int inf = 1000000;
int a[MAXN], b[MAXN],c[MAXN];
int dp[MAXN+1][MAXN*abmax+1][MAXN*abmax+1];

int main(){
    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<=MAXN;i++){
        for(int j=0;j<=MAXN*abmax){
            for(int k=0;k<=MAXN*abmax)
            dp[i][j][k]=inf;
        }
    }
    dp[0][0][0] = 0;

    for(int i=0;i<N;i++){
        for(int j=0;j<=MAXN*abmax){
            for(int k=0;k<=MAXN*abmax){
                if(dp[i][j][k]==inf) continue;
                dp[i+1][j][k] = min(dp[i][j][k],dp[i+1][j][k]);
                dp[i+1][j+a[i]][k+b[i]] = min(dp[i+1][j][k],dp[i][j][k]+c[i]);
            }
        }
    }

    int ans=inf;
    for(int i=1;i<=MAXN*abmax; ++i){
        for(int j = 1;j<=MAXN*abmax;++j){
            if(i*Mb==j*Ma) ans = min(ans,dp[N][i][j]);
        }
    }

    if(ans==inf) ans=-1;
    cout << ans << endl;

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:34: error: expected ';' before ')' token
   17 |         for(int j=0;j<=MAXN*abmax){
      |                                  ^
      |                                  ;
a.cc:18:38: error: expected ';' before ')' token
   18 |             for(int k=0;k<=MAXN*abmax)
      |                                      ^
      |                                      ;
a.cc:25:34: error: expected ';' before ')' token
   25 |         for(int j=0;j<=MAXN*abmax){
      |                                  ^
      |                                  ;
a.cc:26:38: error: expected ';' before ')' token
   26 |             for(int k=0;k<=MAXN*abmax){
      |                                      ^
      |                                      ;
Language: C++

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

using namespace std;

int main(){
  int n,m,l,a[45],b[45],c[45],dp[45][410][410]={1e9},ans =1e9;
  cin >> n >> m >> l;
  
  for(int i=0;i<n;i++){
    cin >> a[i] >> b[i] >> c[i];
  }
  
  
  dp[0][0][0] =0;
  
  
  for(int i=0;i<n;i++){
    for(int j=0;j<410;j++){
      for(int k=0;k<410;k++){
        if(dp[i][j][k] == 1e9){
          continue;
        }
        dp[i+1][j][k] = min(dp[i][j][k],dp[i+1][j][k]);
        dp[i+1][j+a[i]][k+b[i]] = min(dp[i+1][j+a[i]][k+b[i]],dp[i][j][k]+c[i]);
      }
    }
  }
  
  for(int j=0;j<410;j++){
    for(int k=0;k<410;k++){
      if(k*m ==j*l){
        ans = min(dp[n][j][k],ans);
      }
    }
  }
  
  cout << ans << endl;
}
  

Compiler output:
a.cc: In function 'int main()':
a.cc:8:49: error: narrowing conversion of '1.0e+9' from 'double' to 'int' [-Wnarrowing]
    8 |   int n,m,l,a[45],b[45],c[45],dp[45][410][410]={1e9},ans =1e9;
      |                                                 ^~~
Language: Java

import java.util.*;

public class ABC054{
    static int[] a, b, c;
    static int n, ma, mb;
    static int opt=Integer.MAX_VALUE;
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        n=Integer.parseInt(sc.next());
        ma=Integer.parseInt(sc.next());
        mb=Integer.parseInt(sc.next());
        a=new int[n];
        b=new int[n];
        c=new int[n];
        for(int i=0;i<n;i++){
            a[i]=Integer.parseInt(sc.next());
            b[i]=Integer.parseInt(sc.next());
            c[i]=Integer.parseInt(sc.next());
        }
        sc.close();
        int ans=search(0, 0, 0, 0);
        if(ans==Integer.MAX_VALUE) ans=-1;
        System.out.println(ans);
    }

    public static int search(int sumA, int sumB, int sumC, int st){
        if(sumC>=opt) return opt;
        if((sumA+a[st])*mb==(sumB+b[st])*ma){
            opt=Math.min(opt,sumC+c[st]);
            if(st==n-1) return opt;
            return Math.min(opt, search(sumA, sumB, sumC, st+1));
        }
        if(st==n-1) return opt;
        return Math.min(Math.min(opt,search(sumA, sumB, sumC, st+1)), search(sumA+a[st], sumB+b[st], sumC+c[st], st+1));
    }
}

Compiler output:
Main.java:3: error: class ABC054 is public, should be declared in a file named ABC054.java
public class ABC054{
       ^
1 error
Language: C++

#include <iostream>
#define MAX 5000
using namespace std ;

int a[40],b[40],c[40],n,ma,mb,opt;
int search(int sumA, int sumB, int sumC, int st){
    if(sumC>=opt) return opt;  
    if((sumA+a[st])*mb==(sumB+b[st])*ma){
        opt=min(opt,sumC+c[st]);
        if(st==n-1) return opt;
        return min(opt, search(sumA, sumB, sumC, st+1));
    }
    if(st==n-1) return opt;
    return min(opt, search(sumA, sumB, sumC, st+1), search(sumA+a[st], sumB+b[st], sumC+c[st], st+1));
}
int main(void){
    opt=MAX;
    cin>>n>>ma>>mb;
    for(int i=0;i<n;i++) cin>>a[i]>>b[i]>>c[i];
    opt=search(0,0,0,0);
    if(opt>=MAX) opt=-1;
    cout<<opt<<endl;
}

Compiler output:
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h: In instantiation of 'constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare) [with _Tp = int; _Compare = int]':
a.cc:14:15:   required from here
   14 |     return min(opt, search(sumA, sumB, sumC, st+1), search(sumA+a[st], sumB+b[st], sumC+c[st], st+1));
      |            ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:284:17: error: '__comp' cannot be used as a function
  284 |       if (__comp(__b, __a))
      |           ~~~~~~^~~~~~~~~~