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

#include <iostream>
2.using namespace std;
3.const int INF = 10000 ;
4.int main(void){
5.     int N , Ma , Mb ;
6.     int a[45] , b[45] , c[45] ;
7.     cin >> N >> Ma >> Mb ;
8.     for(int i=1;i<=N;i++){
9.          cin >> a[i] >> b[i] >> c[i] ;
10.     }
11.     
12.     int dp[N+1][500][500] ;
13.     for(int i=1;i<=N;i++){
14.          for(int j=0;j<500;j++){
15.               for(int k=0;k<500;k++){
16.                    dp[i][j][k] = INF ;
17.               }
18.          }
19.     }
20.    
21.    for(int i=1;i<=N;i++){
22.         dp[i][0][0] = 0 ;
23.    }
24.    for(int i=1;i<N;i++){
25.         
26.         for(int j=0;j<500;j++){
27.              
28.              for(int k=0;k<500;k++){
29.                   
30.                   if(a[i]>j || b[i]>k){
31.                        dp[i+1][j][k] = dp[i][j][k] ; 
32.                   }else{
33.                        dp[i+1][j][k] = min(dp[i][j][k] , dp[i][j-a[i]][k-b[i]] + c[i]) ;
34.                   }
35.                   
36.              }
37.         }
38.    }
39.    
40.    int ans = INF ;
41.    
42.    for(int i=1;i<=40;i++){
43.         ans = min(ans , dp[N][i*Ma][i*Mb]) ;
44.    }
45.    if(ans >= INF){
46.         cout << -1 << endl ;
47.    }else{
48.         cout << ans << endl ;
49.    }
50. 
51.}


Compiler output:
a.cc:2:1: error: expected unqualified-id before numeric constant
    2 | 2.using namespace std;
      | ^~~~~~~
a.cc:3:1: error: expected unqualified-id before numeric constant
    3 | 3.const int INF = 10000 ;
      | ^~~~~~~
a.cc:4:1: error: expected unqualified-id before numeric constant
    4 | 4.int main(void){
      | ^~~~~
Language: C++

#include <iostream>
#include <vector>
using namespace std;
#define INF 1e9;
int N,a,b,c,Ma,Mb;
int dp[2][401][401];
int main(){
	cin >> N >> Ma >> Mb;
	for(int k=0;k<2;++k)
		for(int i=0;i<=400;++i){
			for(int j=0;j<=400;++j){
				dp[k][i][j] = INF;
			}
		}
	dp[0][0][0] = dp[1][0][0] = 0;
	int cur = 1;
	while(N--){
		cin >> a >> b >> c;
		for(int i=0;i<=400;++i){
			for(int j=0;j<=400;++j){
				if(i >= a && j >= b){
					dp[cur][i][j] = min(dp[(cur+1)%2][i][j],dp[(cur+1)%2][i-a][j-b]+c);
				}
			}
		}

		++cur;
		cur %= 2;
	}
	++cur;
	cur%=2;
	int res = INF;
	for(int i=1;i*Ma<=400;++i){
		if(i*Mb <= 400) res = min(res,dp[cur][i*Ma][i*Mb]);
	}
	if(res == INF) cout << -1 << endl;
	else cout << res << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:36:22: error: expected primary-expression before ')' token
   36 |         if(res == INF) cout << -1 << endl;
      |                      ^
Language: C++

<?php
class main {
    function run () {
        fscanf(STDIN, "%d %d %d", $n, $ma, $mb);
        $drug = array();
        for ($i = 0; $i < $n; $i++) {
            fscanf(STDIN, "%d %d %d", $a, $b, $c);
            $drug[$i]["a"] = $a;
            $drug[$i]["b"] = $b;
            $drug[$i]["c"] = $c;
        }

        $price_map = array();
        $maxa = $n * 10;
        $maxb = $n * 10;
        $maxc = $n * 100;
        for ($i = 0; $i < $n; $i++) {
            for ($a = 0; $a < $maxa; $a++) {
                for ($b = 0; $b < $maxb; $b++) {
                    $price_map[$i][$a][$b] = $maxc;
                }
            }
        }
        $price_map[0][0][0] = 0;
        for ($i = 0; $i < $n; $i++) {
            for ($a = 0; $a < $maxa; $a++) {
                for ($b = 0; $b < $maxb; $b++) {
                    if ($price_map[$i][$a][$b] < $maxc) {
                        $price_map[$i + 1][$a][$b] = $drug[$i]["c"];
                        $price_map[$i + 1][$a + $drug[$i]["a"]][$b + $drug[$i]["b"]] = $price_map[$i][$a][$b] + $drug[$i]["c"];
                    }
                }
            }
        }
        $min_c = $maxc;
        for ($i = 0; $i < $n; $i++) {
            for ($a = 0; $a < $maxa; $a++) {
                for ($b = 0; $b < $maxb; $b++) {
                    if ($price_map[$i][$a][$b] < $maxc) {
                        $min_c = $price_map[$i][$a][$b];
                    }
                }
            }
        }
        if ($min_c == $maxc) {
            echo "-1";
        } else {
            echo $min_c;
        }
    }
}

$object = new main();
$object->run();

Compiler output:
a.cc:1:1: error: expected unqualified-id before '<' token
    1 | <?php
      | ^
a.cc:53:1: error: '$object' does not name a type
   53 | $object = new main();
      | ^~~~~~~
a.cc:54:1: error: '$object' does not name a type
   54 | $object->run();
      | ^~~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
struct node{
	int a, b, c;
}a[1000100];

int n, ma, mb;

ll dp[60][500][500];
bool check(int cura, int curb){
	if(cura == 0 && cura == curb){
		return false;
	}
	return ma*curb == mb*cura;
}





ll cool(){

	for(int i = 0;i<60;i+=1){
		for(int j=0 ; j<500 ; j++){
			for(int k=0 ; k<500 ; k++){
				dp[i][j][k] = (ll)1e18;
			}		
		}	
	}
	
	for(int i =  0 ;i<n-1;i+=1)
	{
		for(int j = 0 ;j<500;j+=1){
			for(int k = 0 ;k<500;k+=1){

			dp[i+1][j][k] = min(dp[i+1][j][k],dp[i][j][k]);
				if(j + a[i].a < 499 && k + a[i].b < 499){
					dp[i+1][j+a[i].a][k+a[i].b] = min(a[i].c + dp[i][j][k],dp[i+1][j+a[i].a][k+a[i].b]);
				}
			}
		}
	}
	ll ans = (ll)1e18;

	for(int j = 0;j<499;j+=1){
		for(int k = 0;k<499;k+=1){

			if(check(j,k)){
				ans =min(ans,dp[n-1][j][k]);
			}
		}
	}

	return ans;
//:)

}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> ma >> mb;
	for(int i=0 ; i<n ; i++){
		cin >> a[i].a >> a[i].b >> a[i].c;
	}
	memset(m, -1, sizeof(m));	
	ll r = cool();
	if(r > (ll)1e12){
		cout << "-1\n";
	} else {
		cout << r;
	}	
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:67:16: error: 'm' was not declared in this scope; did you mean 'tm'?
   67 |         memset(m, -1, sizeof(m));
      |                ^
      |                tm
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
struct node{
	int a, b, c;
}a[1000100];

int n, ma, mb;
int m[60][510][510];

ll dp[60][500][500];
bool check(int cura, int curb){
	if(cura == 0 && cura == curb){
		return false;
	}
	return ma*curb == mb*cura;
}





ll cool(){

	for(int i = 0;i<60;i+=1){
		for(int j=0 ; j<500 ; j++){
			for(int k=0 ; k<500 ; k++){
				dp[i][j][k] = (ll)1e18;
			}		
		}	
	}
	
for(int i =  0 ;i<n-1;i+=1)
{

for(int j = 0 ;j<500;j+=1)
{
for(int k = 0 ;k<500;k+=1){



dp[i+1][j][k] = min(dp[i+1][j][k],dp[i][j][k]);
if(j + a[i].a < 499 && k + a[i].b < 499){
	dp[i+1][j+a[i].a][k+a[i].b] = min(a[i].c + dp[i][j][k],dp[i+1][j+a[i].a][k+a[i].b]);
}
}
}

ll ans = (ll)1e18;

for(int j = 0;j<499;j+=1)
{
for(int k = 0;k<499;k+=1)
{

if(check(j,k))
{
ans =min(ans,dp[n-1][j][k]);
}
}
}

return ans;


//:)

}

ll memo(int curr, int wa, int wb){
	if(curr == n){
		if(check(wa, wb)){
			return 0;
		} else {
			return (ll)1e16;	
		}
	}
	if(m[curr][wa][wb] != -1){
		return m[curr][wa][wb];	
	}
	ll ans = (ll)1e18;
	ans = min(ans, a[curr].c + memo(curr+1, wa+a[curr].a, wb+a[curr].b));
	ans = min(ans, memo(curr+1, wa, wb));
	m[curr][wa][wb] = ans;
	return ans;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> ma >> mb;
	for(int i=0 ; i<n ; i++){
		cin >> a[i].a >> a[i].b >> a[i].c;
	}
	memset(m, -1, sizeof(m));	
	//ll r = memo(0, 0, 0);
	ll r = cool();
	if(r > (ll)1e12){
		cout << "-1\n";
	} else {
		cout << r;
	}	
	return 0;
}

Compiler output:
a.cc: In function 'll cool()':
a.cc:70:34: error: a function-definition is not allowed here before '{' token
   70 | ll memo(int curr, int wa, int wb){
      |                                  ^
a.cc:88:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   88 | int main(){
      |         ^~
a.cc:88:9: note: remove parentheses to default-initialize a variable
   88 | int main(){
      |         ^~
      |         --
a.cc:88:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:88:11: error: a function-definition is not allowed here before '{' token
   88 | int main(){
      |           ^
a.cc:104:2: error: expected '}' at end of input
  104 | }
      |  ^
a.cc:23:10: note: to match this '{'
   23 | ll cool(){
      |          ^
a.cc:104:2: warning: control reaches end of non-void function [-Wreturn-type]
  104 | }
      |  ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
struct node{
	int a, b, c;
}a[1000100];

int n, ma, mb;
int m[60][510][510];

ll dp[60][500][500];
bool check(int cura, int curb){
	if(cura == 0 && cura == curb){
		return false;
	}
	return ma*curb == mb*cura;
}





ll cool(){

	for(int i = 0;i<60;i+=1){
		for(int j=0 ; j<500 ; j++){
			for(int k=0 ; k<500 ; k++){
				dp[i][j][k] = (ll)1e18;
			}		
		}	
	}
	
for(int i =  0 ;i<n-1;i+=1)
{

for(int j = 0 ;j<500;j+=1)
{
for(int k = 0 ;k<500;k+=1)



dp[i+1][j][k] = min(dp[i+1][j][k],dp[i][j][k]);
if(j + a[i].a < 499 && k + a[i].b < 499){
	dp[i+1][j+a[i].a][k+a[i].b] = min(a[i].c + dp[i][j][k],dp[i+1][j+a[i].a][k+a[i].b]);
}
}
}

ll ans = (ll)1e18;

for(int j = 0;j<499;j+=1)
{
for(int k = 0;k<499;k+=1)
{

if(check(j,k))
{
ans =min(ans,dp[n-1][j][k]);
}
}
}

return ans;


//:)

}

ll memo(int curr, int wa, int wb){
	if(curr == n){
		if(check(wa, wb)){
			return 0;
		} else {
			return (ll)1e16;	
		}
	}
	if(m[curr][wa][wb] != -1){
		return m[curr][wa][wb];	
	}
	ll ans = (ll)1e18;
	ans = min(ans, a[curr].c + memo(curr+1, wa+a[curr].a, wb+a[curr].b));
	ans = min(ans, memo(curr+1, wa, wb));
	m[curr][wa][wb] = ans;
	return ans;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> ma >> mb;
	for(int i=0 ; i<n ; i++){
		cin >> a[i].a >> a[i].b >> a[i].c;
	}
	memset(m, -1, sizeof(m));	
	//ll r = memo(0, 0, 0);
	ll r = cool();
	if(r > (ll)1e12){
		cout << "-1\n";
	} else {
		cout << r;
	}	
	return 0;
}

Compiler output:
a.cc: In function 'll cool()':
a.cc:43:24: error: 'k' was not declared in this scope
   43 | if(j + a[i].a < 499 && k + a[i].b < 499){
      |                        ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
struct node{
	int a, b, c;
}a[1000100];

int n, ma, mb;
int m[60][510][510];

ll dp[60][500][500];
bool check(int cura, int curb){
	if(cura == 0 && cura == curb){
		return false;
	}
	return ma*curb == mb*cura;
}





ll cool(){

	for(int i = 0;i<60;i+=1){
		for(int j=0 ; j<500 ; j++){
			for(int k=0 ; i<500 ; k++{
				dp[i][j][k] = (ll)1e18;
			}		
		}	
	}
	
for(int i =  0 ;i<n-1;i+=1)
{

for(int j = 0 ;j<500;j+=1)
{
for(int k = 0 ;k<500;k+=1)



dp[i+1][j][k] = min(dp[i+1][j][k],dp[i][j][k]);
if(j + a[i].a < 499 && k + a[i].b < 499){
	dp[i+1][j+a[i].a][k+a[i].b] = min(a[i].c + dp[i][j][k],dp[i+1][j+a[i].a][k+a[i].b]);
}
}
}

ll ans = (ll)1e18;

for(int j = 0;j<499;j+=1)
{
for(int k = 0;k<499;k+=1)
{

if(check(j,k))
{
ans =min(ans,dp[n-1][j][k]);
}
}
}

return ans;


//:)

}

ll memo(int curr, int wa, int wb){
	if(curr == n){
		if(check(wa, wb)){
			return 0;
		} else {
			return (ll)1e16;	
		}
	}
	if(m[curr][wa][wb] != -1){
		return m[curr][wa][wb];	
	}
	ll ans = (ll)1e18;
	ans = min(ans, a[curr].c + memo(curr+1, wa+a[curr].a, wb+a[curr].b));
	ans = min(ans, memo(curr+1, wa, wb));
	m[curr][wa][wb] = ans;
	return ans;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> ma >> mb;
	for(int i=0 ; i<n ; i++){
		cin >> a[i].a >> a[i].b >> a[i].c;
	}
	memset(m, -1, sizeof(m));	
	//ll r = memo(0, 0, 0);
	ll r = cool();
	if(r > (ll)1e12){
		cout << "-1\n";
	} else {
		cout << r;
	}	
	return 0;
}

Compiler output:
a.cc: In function 'll cool()':
a.cc:27:50: error: expected ')' before '{' token
   27 |                         for(int k=0 ; i<500 ; k++{
      |                            ~                     ^
      |                                                  )
a.cc:43:24: error: 'k' was not declared in this scope
   43 | if(j + a[i].a < 499 && k + a[i].b < 499){
      |                        ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define int long long
#define F first
#define S second
const ll INF = 1LL * 1000 * 1000 * 1000 * 1000 * 1000 * 1000;
const int inf = 1000 * 1000 * 1000;

// Bedone harf !

const int N = 40,
	  		M = 10;

int a[N], b[N], c[N];
int n, ma, mb, dp[N][N * M + 30][N * M + 30];


int32_t main(){
	ios::sync_with_stdio(false);cin.tie(0);	

	for(int z = 0; z <= n; z++)
		for(int i = 0; i <= N * M; i++)
			for(int j = 0; j <= N * M; j++)
				dp[z][i][j] = INF;
	dp[0][0][0] = 0;

	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 x = 0; x <= N * M; x++)
			for(int y = 0; y <= N * M; y++)
				if(dp[i][x][y] != INF){
					dp[i + 1][x][y] = min(dp[i + 1][x][y], dp[i][x][y]);
					dp[i + 1][x + a[i]][y + b[i]] = min(dp[i + 1][x + a[i]][y + b[i]], dp[i][x][y] + c[i]);

	// ghalat nist ? :-?
	int ans = INF;
	for(int i = 1; i <= N * M; i++)
		for(int j = 1; j <= N * M; j++)
			if(ma * j == mb * i)
				ans = min(ans, dp[n][i][j]);
	if(ans == INF)
		cout << -1 << '\n';
	else
		cout << ans << '\n';
	return 0;
}

Compiler output:
a.cc: In function 'int32_t main()':
a.cc:52:2: error: expected '}' at end of input
   52 | }
      |  ^
a.cc:20:15: note: to match this '{'
   20 | int32_t main(){
      |               ^
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 ratioA = sc.nextInt();
    int ratioB = sc.nextInt();
    int[] a = new int[N];
    int[] b = new int[N];
    int[] c = new int[N];
    int sumA = 0;
    int sumB = 0;
    for(int i = 0; i < N; i++) {
      a[i] = sc.nextInt();
      b[i] = sc.nextInt();
      c[i] = sc.nextInt();
      sumA += a[i];
      sumB += b[i];
    }
    int[][][] dp = new int[401][401][N];
    for(int i = 0; i < N; i++) {
      for(int j = 0; j < 401; j++) {
        for(int k = 0; k < 401; k++) {
          dp[j][k][i] = -1;
        }
      }
    }
    dp[a[0]][b[0]][0] = c[0];
    for(int i = 1; i < N; i++) {
      for(int j = 0; j < 401; j++) {
        for(int k = 0; k < 401; k++) {
          if(a[i] <= j && b[i] <= k) {
            int m = Integer.MAX_VALUE;
            if(a[i] == j && b[i] == k) {
              m = c[i];
            } else {
              if(dp[j - a[i]][k - b[i]][i - 1] != -1) m = c[i] + dp[j - a[i]][k - b[i]][i - 1];
            }
            if(dp[j][k][i - 1] == -1) {
              if(m == Integer.MAX_VALUE) {
                dp[j][k][i] = -1;
              } else {
                dp[j][k][i] = m;
              }
            } else {
              dp[j][k][i] = Math.min(m, dp[j][k][i - 1]);
            }
          } else {
            dp[j][k][i] = dp[j][k][i - 1];
          }
        }
      }
    }
    int cost = Integer.MAX_VALUE;
    for(int i = 1; i <= Math.min(sumA / ratioA, sumB / ratioB); i++) {
      if(dp[ratioA * i][ratioB * i][N - 1] != -1) {
        cost = Math.min(cost, dp[ratioA * i][ratioB * i]);
      }
    }
    int res = "";
    if(cost != Integer.MAX_VALUE) {
      res = cost;
    } else {
      res = -1;
    }
    System.out.println(res);
  }
}

Compiler output:
Main.java:58: error: no suitable method found for min(int,int[])
        cost = Math.min(cost, dp[ratioA * i][ratioB * i]);
                   ^
    method Math.min(int,int) is not applicable
      (argument mismatch; int[] cannot be converted to int)
    method Math.min(long,long) is not applicable
      (argument mismatch; int[] cannot be converted to long)
    method Math.min(float,float) is not applicable
      (argument mismatch; int[] cannot be converted to float)
    method Math.min(double,double) is not applicable
      (argument mismatch; int[] cannot be converted to double)
Main.java:61: error: incompatible types: String cannot be converted to int
    int res = "";
              ^
2 errors
Language: C++

#include <iostream>

using namespace std;

int n, a, b, ans = 1e9;
int A[100], B[100], C[100];
int dp[555][555];

int main()
{
	cin >> n >> a >> b;
	double d = a/b;
	
	for(int i=1; i <= n; i++)
		cin >> A[i] >> B[i] >> C[i];
	for(int i=0; i <= 400; i++)
		for(int h=0; h <= 400; h++)
			dp[i][h] = 1e9;
	
	dp[0][0] = 0;
	for(int i=1; i <= n; i++)
		for(int h=400; h >= 0; h--)
			for(int j=400; j >= 0; j--)
				if(dp[h][j] != 1e9) {
					int x = h+A[i];
					int y = j+B[i];
					
					if(dp[x][y] > dp[h][j]+C[i])
						dp[x][y] = dp[h][j]+C[i];
				}
	
	for(int i=1; i <= 400; i++)
		if (x*i <= 400 && y*i <= 400)
		ans = min(ans, cp[x*i][y*i]);

	if(ans == 1e9)
		ans = -1;
	cout << ans;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:33:21: error: 'x' was not declared in this scope
   33 |                 if (x*i <= 400 && y*i <= 400)
      |                     ^
a.cc:33:35: error: 'y' was not declared in this scope
   33 |                 if (x*i <= 400 && y*i <= 400)
      |                                   ^
a.cc:34:32: error: 'cp' was not declared in this scope; did you mean 'dp'?
   34 |                 ans = min(ans, cp[x*i][y*i]);
      |                                ^~
      |                                dp
Language: C++

#include<iostream>

using namespace std;
int N, A, B;
int a[50], b[50], c[50];
const int inf=1001001;
int memo[41][401][401];

int rec(int i, int _a, int _b){

   if(memo[i][_a][_b]!=inf) return memo[i][_a][_b];
   if(_a==0&&_b==0) return 0;
   if(i==N) return inf;
   int ret=inf;
   ret=min(ret, rec(i+1, _a, _b));
   if(_a-a[i]>=0&&_b-b[i]>=0) ret=min(ret, rec(i+1, _a-a[i], _b-b[i])+c[i]);

   return memo[i][_a][_b]=ret;
}

int main(){

   cin>> N>> A>> B;
   int x=0, y=0;
   for(int i=0; i<N; i++){
      cin>> a[i]>> b[i]>> c[i];
      x+=a[i]; y+=b[i];
   }

   for(int i=0; i<41; i++){
      for(int j=0; j<401; j++){
         for(int k=0; k<401; k++){
            memo[i][j][k]=inf;
         }
      }
   }
   int mi=inf;
   for(int k=1; max(k*A, k*B)<=40*10; k++){
      if(k*A>x||b*A>y) continue;
      mi=min(mi, rec(0, k*A, k*B));
   }

   if(mi==inf){
      cout<< -1<< endl;
   }else{
      cout<< mi<< endl;
   }

   return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:39:18: error: invalid operands of types 'int [50]' and 'int' to binary 'operator*'
   39 |       if(k*A>x||b*A>y) continue;
      |                 ~^~
      |                 | |
      |                 | int
      |                 int [50]
Language: C++

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

int n,ma,mb;
int a[40],b[40],c[40];
map<pair<int,int>,int> min_cost;

void res(int cur,pair<int,int> m,int used[]){
    //for(int i=0; i<n; i++)cout<<used[i]<<' ';cout<<endl;
    if(min_cost[make_pair(m.first,m.second)]==0){
        min_cost[make_pair(m.first,m.second)]=cur;
        //cout<<'a'<<endl;
    }
    else if(min_cost[make_pair(m.first,m.second)]>cur){
        min_cost[make_pair(m.first,m.second)]=cur;
    }else{
        //cout<<'b'<<endl; 
        return;
    }
    for(int i=0; i<n; i++){
        if(!used[i]){
            used[i]=true;
            res(cur+c[i],make_pair(m.first+a[i],m.second+b[i]),used);
            used[i]=false;
        }
    }
}

int main(){
    cin>>n>>ma>>mb;
    int used[n];for(int i=0; i<n; i++)used[i]=0;
    for(int i=0; i<n; i++){
        int in1,in2,in3;
        cin>>in1>>in2>>in3;
        a[i]=in1;b[i]=in2;c[i]=in3;
    }
    res(0,make_pair(0,0),used);

    bool flag=true;
    for(int i=1; i<401; i++){
        if(min_cost[make_pair(ma*i,mb*i)]!=0){
            flag=false;
            cout<<min_cost[make_pair(ma*i,mb*i)]<<endl;
            break;
        }
    }
    if(flag){
        cout<<-1<<endl;
        return;
    }
    //cout<<min_cost[make_pair(3,3)]<<endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:49:9: error: return-statement with no value, in function returning 'int' [-fpermissive]
   49 |         return;
      |         ^~~~~~
Language: C++

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

#define FOR(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define rep(i,n) FOR((i),0,(n))

typedef long long ll;

const int INF=1e9+7;
const int MAX_N=43;
int a[MAX_N],b[MAX_N],c[MAX_N];
int dp[450][450][43];
int main(){
	rep(i,450)rep(j,450)rep(k,43)dp[i][j][k]=INF;
	int n,m_a,m_b;
	cin>>n>>m_a>>m_b;
	rep(i,n)cin>>a[i]>>b[i]>>c[i];
	dp[0][0][0]=0;
	rep(l,n){
		rep(i,400){rep(j,400){dp[i][j][l+1]=min(dp[i][j][l+1],dp[i][j][l]),dp[i+a[l]][j+b[l]][l+1]=min(dp[i+a[l]][j+b[l]][l],dp[i][j][l]+c[l])}};
	}
	int ans=INF;
	for(int i=1;i*(max(m_a,m_b))<450;i++){
		ans=min(ans,dp[i*m_a][i*m_b][n]);
	}
	rep(i,450)rep(j,450)if(i*m_b==j*m_a)ans=min(ans,dp[i][j][n]);
	if(ans==INF)ans=-1;
	cout<<ans<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:22:151: error: expected ';' before '}' token
   22 |                 rep(i,400){rep(j,400){dp[i][j][l+1]=min(dp[i][j][l+1],dp[i][j][l]),dp[i+a[l]][j+b[l]][l+1]=min(dp[i+a[l]][j+b[l]][l],dp[i][j][l]+c[l])}};
      |                                                                                                                                                       ^
      |                                                                                                                                                       ;
Language: C++

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
#include <bitset>
#include <map>
#include <cstring>
#include <cstdlib>

#define INF_LL 9000000000000000000
#define INF 2000000000

#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)

using namespace std;

typedef long long ll;
typedef pair<int, int> PII;

class Union_find{
private:
	vector<int> par;
	vector<int> rank;
	int n;

public:
	Union_find(int a){
		n = a;
		for(int i = 0;i < n;i++){
			par.push_back(i);
			rank.push_back(0);
		}
	}

	int find(int x){
		if(par[x] == x){
			return x;
		}else{
			return par[x] = find(par[x]);
		}
	}

	void unite(int x, int y){
		x = find(x);
		y = find(y);
		if(x == y) return;

		if(rank[x] < rank[y]){
			par[x] = y;
		}else{
			par[y] = x;
			if(rank[x] == rank[y]) rank[x]++;
		}
	}

	bool same(int x, int y){
		return find(x) == find(y);
	}
};

int flag[10] = {};
int N, M;
vector<int> G[9];

int dfs(int x, int be, int cnt){
	if(cnt == N) return 1;
	
	ll res = 0;
	REP(i, G[x].size()){
		if(flag[G[x][i]]) continue;
		flag[G[x][i]] = true;
		res += dfs(G[x][i], x, cnt+1);
		flag[G[x][i]] = false;
	}
	return res;
}
int dp[41][401][401];

int main(void){
	int N, Ma, Mb;
	int a[41], b[41], c[41];
	REP(i, 41) REP(j, 401) REP(k, 401) dp[i][j][k] = INF;

	cin >> N >> Ma >> Mb;
	REP(i, N){
		cin >> a[i] >> b[i] >> c[i];
	}
	dp[0][0][0] = 0;
	REP(i, N){
		REP(j, N*10+1){
			REP(k, N*10+1){
				if(j >= a[i] && k >= b[i])
					dp[i+1][j][k] = min(dp[i][j][k], dp[i][j-a[i]][k-b[i]]+c[i]);
			}
		}
	}
	int res = INF;
	REP(k, N+1){
	REP(i, N*10+1){
		REP(j, N*10+1){
			if(dp[N][i][j] != INF dp[N][i][j] != 0 && i*Mb - j*Ma == 0){
				res = min(res, dp[k][i][j]);
			}
		}
	}
	}
	if(res == INF)
		cout << -1 << endl;
	else
		cout << res << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:106:47: error: expected ')' before 'dp'
  106 |                         if(dp[N][i][j] != INF dp[N][i][j] != 0 && i*Mb - j*Ma == 0){
      |                           ~                   ^~
Language: Java

import java.util.*;
import java.io.*;

public class Coin {
    
    static int n;
    static int m1,m2;
    static final long INF=1000000000000000000L;
    static long min=INF;
    static int[] a;
    static int[] b;
    static int[] c;
    static long[][][] dp=new long[41][401][401];
    
    public static void main(String[] args) throws IOException {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st=new StringTokenizer(br.readLine());
        n=Integer.parseInt(st.nextToken());
        m1=Integer.parseInt(st.nextToken());
        m2=Integer.parseInt(st.nextToken());
        a=new int[n];
        b=new int[n];
        c=new int[n];
        for(int i=0;i<n;i++){
            st=new StringTokenizer(br.readLine());
            a[i]=Integer.parseInt(st.nextToken());
            b[i]=Integer.parseInt(st.nextToken());
            c[i]=Integer.parseInt(st.nextToken());
        }
        long sum=dfs(0,0,0);
        System.out.println(sum==INF ? -1:sum);
    }
    
    static long dfs(int index,int c_a,int c_b){
        long ret;
        if(dp[index][c_a][c_b]!=0){ ret=dp[index][c_a][c_b]; }
        else if(index==n){ ret=  INF; }
        else if((c_b!=0 && c_a!=0)&& (long)m1*c_b==(long)m2*c_a){ ret= 0; }
        else{ ret=Math.min(dfs(index+1,c_a+a[index],c_b+b[index])+c[index],dfs(index+1,c_a,c_b)); }
        dp[index][c_a][c_b]=ret;
        return ret;
    }
    

    
}


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

#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

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

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

    int is_ok = false;
    int min = 5000;

    for (int i = 0; i < n; i++) {
        int suma = 0, sumb = 0, sumc = 0;
        for (int j = i; j < n; j++) {
            suma += a[j];
            sumb += b[j];
            sumc += c[j];

            if (suma * mb == sumb * ma) {
                if (min > sumc) {
                    min = sumc;
                    is_ok = true;
                }
            }
        }
        if (is_ok) { break; }
    }

    if (is_ok) {
        cout << min << endl;
    } else {
        cout << -1 << endl;
    }

    return 0;

Compiler output:
a.cc: In function 'int main()':
a.cc:42:14: error: expected '}' at end of input
   42 |     return 0;
      |              ^
a.cc:7:12: note: to match this '{'
    7 | int main() {
      |            ^
Language: C++

#include <iostream> 
#include <string> 
#include <vector> 
#include <cmath> 
#include <algorithm> 
#include <cstdlib> 
#include <ctime> 
#include <cstdio> 
#include <functional> 
#include <set> 
#include <sstream> 
#include <cctype>
#include <stack>
#include <queue>
#include <cstring>
#include <map>
#include <list>
#include <cassert>
 
using namespace std; 

int gcd(int x,int y){
	return y==0?x:gcd(y,x%y);
}

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

int main(){

	int n,ma,mb;
	cin>>n>>ma>>mb;

	vector<int> a(n),b(n),c(n);
	for(int i=0;i<40;i++){
		for(int j=0;j<401;j++){
			for(int k=0;k<401;k++) dp[i][j][k]=1e8;
		}
	}

	for(int j=0;j<401;j++){
		for(int k=0;k<401;k++) dp[0][j][k]=0;
	}

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

	for(int i=0;i<n;i++){
		for(int j=0;j<=400;j++){
			for(int k=0;k<=400;k++){
				if(j-a[i]>=0 && k-b[i]>=0){
					int g=gcd(j,k);
					int j2=j/g,k2=k/g;

					g=gcd(j-a[i],k-b[i]);
					dp[i+1][j2][k2]=min(dp[i+1][j2][k2],dp[i][(j-a[i])/g][(k-b[i])/g]+c[i]);
				}else{
					dp[i+1][j2][k2]=dp[i][j][k];
				}
			}
		}
	}

	int res=1e8;
	for(int i=1;i<=100;i++){
		res=min(res,dp[n][i*ma][i*mb]);
	}

	if(res==1e8) res=-1;
	cout<<res<<endl;


}

Compiler output:
a.cc: In function 'int main()':
a.cc:60:49: error: 'j2' was not declared in this scope; did you mean 'j'?
   60 |                                         dp[i+1][j2][k2]=dp[i][j][k];
      |                                                 ^~
      |                                                 j
a.cc:60:53: error: 'k2' was not declared in this scope; did you mean 'k'?
   60 |                                         dp[i+1][j2][k2]=dp[i][j][k];
      |                                                     ^~
      |                                                     k
Language: C++

#include <iostream>
using namespace std;
 
int main(){
	int n, ma, mb;
	cin >> n >> ma >> mb;
	int a[n], b[n], c[n];
	for(int i = 0; i < n; i++) cin >> a[i] >> b[i] >> c[i];
	int minic = 1e9;
	for(int i = 1; i < (1 << n); i++){
		int suma = 0, sumb = 0, sumc = 0, ii = i, count = 0;
		while(ii){
			if(ii & 1){
				suma += a[count];
				sumb += b[count];
				sumc += c[count];
			}
			ii >>= 1;
			count++;
		}
		if(suma % ma == 0 && sumb % mb == 0 && ma * b == mb * a){
			minic = min(minic, sumc);
		}
	}
	cout << (minic == 1e9 ? -1 : minic) << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:59: error: invalid operands of types 'int' and 'int [n]' to binary 'operator*'
   21 |                 if(suma % ma == 0 && sumb % mb == 0 && ma * b == mb * a){
      |                                                        ~~ ^ ~
      |                                                        |    |
      |                                                        int  int [n]
a.cc:21:69: error: invalid operands of types 'int' and 'int [n]' to binary 'operator*'
   21 |                 if(suma % ma == 0 && sumb % mb == 0 && ma * b == mb * a){
      |                                                                  ~~ ^ ~
      |                                                                  |    |
      |                                                                  int  int [n]
Language: Java


import java.util.*;


	public class Main {
		public static void main(String[] args){
			Scanner sc = new Scanner(System.in);
			long N = Integer.parseInt(sc.next());
			int Ma = Integer.parseInt(sc.next());
			int Mb = Integer.parseInt(sc.next());
			int[][] abc = new int[N][2];
			int a;
			int b;
			int c;
			int answer=-1;
			for(int i = 0;i<N;i++){
				abc[i][0]=Integer.parseInt(sc.next());
				abc[i][1]=Integer.parseInt(sc.next());
				abc[i][2]=Integer.parseInt(sc.next());
			}
			for(long i = 1;i<(1+2^N);i++){
				a=0;b=0;c=0;
				for(int j = 0;j<N;j++){
					if(((i-(i/(2^j))*(2^j))/(2^(j-1)))==0){
						a=a+abc[j][0];
						b=b+abc[j][1];
						c=c+abc[j][2];
						}
				}
				if((Ma*b-Mb*a)==0){
					if(answer==-1){
						answer=c;
					} else{
						answer=Math.min(answer, c);
					}
				}
			}			System.out.println(answer);
			sc.close();
		}	//private static final int imax = 110;
	
}




Compiler output:
Main.java:11: error: incompatible types: possible lossy conversion from long to int
			int[][] abc = new int[N][2];
			                      ^
1 error
Language: Java


import java.util.*;


	public class Main {
		public static void main(String[] args){
			Scanner sc = new Scanner(System.in);
			long N = Integer.parseInt(sc.next());
			int Ma = Integer.parseInt(sc.next());
			int Mb = Integer.parseInt(sc.next());
			int[][] abc;
			int a;
			int b;
			int c;
			int answer=-1;
			for(int i = 0;i<N;i++){
				abc[i][0]=Integer.parseInt(sc.next());
				abc[i][1]=Integer.parseInt(sc.next());
				abc[i][2]=Integer.parseInt(sc.next());
			}
			for(long i = 1;i<(1+2^N);i++){
				a=0;b=0;c=0;
				for(int j = 0;j<N;j++){
					if(((i-(i/(2^j))*(2^j))/(2^(j-1)))==0){
						a=a+abc[j][0];
						b=b+abc[j][1];
						c=c+abc[j][2];
						}
				}
				if((Ma*b-Mb*a)==0){
					if(answer==-1){
						answer=c;
					} else{
						answer=Math.min(answer, c);
					}
				}
			}			System.out.println(answer);
			sc.close();
		}	//private static final int imax = 110;
	
}




Compiler output:
Main.java:17: error: variable abc might not have been initialized
				abc[i][0]=Integer.parseInt(sc.next());
				^
Main.java:25: error: variable abc might not have been initialized
						a=a+abc[j][0];
						    ^
2 errors
Language: Java


import java.util.*;


	public class Main {
		public static void main(String[] args){
			Scanner sc = new Scanner(System.in);
			long N = Integer.parseInt(sc.next());
			int Ma = Integer.parseInt(sc.next());
			int Mb = Integer.parseInt(sc.next());
			int[][] abc;
			int a;
			int b;
			int c;
			int answer=-1;
			for(int i = 0;i<N;i++){
				abc[i][0]=Integer.parseInt(sc.next());
				abc[i][1]=Integer.parseInt(sc.next());
				abc[i][2]=Integer.parseInt(sc.next());
			}
			for(long i = 1;i<(1+2^N);i++){
				a=0;b=0;c=0;
				for(int j = 0;j<N;j++){
					if(((i-(i/(2^j))*(2^j))/(2^(j-1)))==0){
						a=a+abc[i][0];
						b=b+abc[i][1];
						c=c+abc[i][2];
						}
				}
				if((Ma*b-Mb*a)==0){
					if(answer==-1){
						answer=c;
					} else{
						answer=Math.min(answer, c);
					}
				}
			}			System.out.println(answer);
			sc.close();
		}	//private static final int imax = 110;
	
}




Compiler output:
Main.java:25: error: incompatible types: possible lossy conversion from long to int
						a=a+abc[i][0];
						        ^
Main.java:26: error: incompatible types: possible lossy conversion from long to int
						b=b+abc[i][1];
						        ^
Main.java:27: error: incompatible types: possible lossy conversion from long to int
						c=c+abc[i][2];
						        ^
3 errors
Language: C++

#include <bits/stdc++.h>
using namespace std; 
const int dx[]={1,0,-1,0,1,-1,-1,1}; 
const int dy[]={0,1,0,-1,1,1,-1,-1}; 
const int INF = 1e9; 
const long long LINF = 1e18; 
const double EPS = 1e-8; 
#define pb push_back
#define mk make_pair 
#define fr first 
#define sc second 
#define ll long long 
#define reps(i,j,k) for(int i = (j); i < (k); ++i) 
#define rep(i,j) reps(i,0,j) 
#define all(a) (a).begin(),(a).end() 
#define MOD 1000000007 
typedef pair<int,int> Pii;
typedef pair<Pii,int> P;
typedef vector<int> vi;

vector < P > memo;
void calc(const vi &a,const vi &b,const vi &c, int prev, P p){
    if(prev == a.size()){
        return ;
    }
    p.fr.fr += a[prev];
    p.fr.sc += b[prev];
    p.sc    += c[prev];
    calc(a,b,c,prev+1,p);
    memo.pb(p);
    p.fr.fr -= a[prev];
    p.fr.sc -= b[prev];
    p.sc    -= c[prev];
    calc(a,b,c,prev+1,p);
    return ;
}
int main(){
    int N;
    cin >> N;
    int Ma,Mb;
    cin >> Ma >> Mb;
    vector < Pii > M;
    rep(i,500){
        M.pb(mk(Ma*(i+1),Mb*(i+1)));
    }

    int a[50],b[50],c[50];
    vi a1,b1,c1;
    vi a2,b2,c2;
    rep(i,N){
        cin >> a[i] >> b[i] >> c[i];
        if(i < N/2){
            a1.pb(a[i]);
            b1.pb(b[i]);
            c1.pb(c[i]);
        }
        else{
            a2.pb(a[i]);
            b2.pb(b[i]);
            c2.pb(c[i]);
        }
    }
    P ini = mk(mk(0,0),0);
    memo.pb(ini);
    calc(a1,b1,c1,0,ini);
    vector < P > sum1 = memo;
    sort(sum1.begin(),sum1.end());
    memo.clear();
    memo.pb(ini);
    calc(a2,b2,c2,0,ini);
    vector < P > sum2 = memo;
    sort(sum2.begin(),sum2.end());
    map < Pii,int > tar;

    rep(i,sum2.size()){
        p = tar[mk(sum2[i].fr.fr,sum2[i].fr.sc)];
        if(p == 0){
            p = INF;
        }
        tar[mk(sum2[i].fr.fr,sum2[i].fr.sc)] = min(INF,sum2[i].sc);
    }

    // puts("sum1");
    // rep(i,sum1.size()){
    //     cout << sum1[i].fr.fr << " " << sum1[i].fr.sc << " " << sum1[i].sc << endl;
    // }

    // puts("sum2");
    // rep(i,sum2.size()){
    //     cout << sum2[i].fr.fr << " " << sum2[i].fr.sc << " " << sum2[i].sc << endl;
    // }

    int ans = INF;
    rep(i,sum1.size()){
        rep(j,M.size()){
            Pii m = M[j];
            P p = sum1[i];
            if(m.fr < p.fr.fr && m.sc < p.fr.sc)break;
            if(m.fr < p.fr.fr || m.sc < p.fr.sc)continue;
            m.fr -= p.fr.fr;
            m.sc -= p.fr.sc;
            if(tar[m] != 0 || (m.fr == 0 && m.sc == 0)){
                ans = min(ans,p.sc + tar[m]);
            }
        }
        //cout << ans << endl;
    }
    if(ans == INF){
        ans = -1;
    }
    cout << ans << endl;

    return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:76:9: error: 'p' was not declared in this scope
   76 |         p = tar[mk(sum2[i].fr.fr,sum2[i].fr.sc)];
      |         ^
Language: C++

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

using namespace std;
#define int long long
const int mod = 1000000007;
int dp[1000][1000][50] = {};

signed main(){
	int N, Ma, Mb;
	int a[100] = {}, b[100] = {}, c[100] = {};
	cin >> N >> Ma >> Mb;
	for (int i = 0; i < N; i++) {
		int a, b, c;
		cin >> a >> b >> c;
		for (int i = 999; i >= 0; i--) {
			for (int j = 999; j >= 0; j--) {
				for (int k = N; k >= 0; k--) {
					if (dp[i][j][k] != 0) {
						dp[i + a][j + b][k + 1] = dp[i][j][k]+ c;
					}
				}
			}
		}
		dp[a][b][1] = c;
	}
	int m = 999999999999;
	for (int i = 999; i >= 0; i--) {
		for (int j = 999; j >= 0; j--) {
			for (int k = N; k >= 0; k--) {
				if (dp[i][j][k] != 0) {
					if (fabs(double(i/j) - (double)(Ma/Mb)) < DBL_EPSILON) {
						m = min(m, dp[i][j][k]);
					}
				}
			}
		}
	}
	if (m == 999999999999) {
		cout << "-1" << endl;
		return 0;
	}
	cout << m << endl;
	

	
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:45:83: error: 'DBL_EPSILON' was not declared in this scope
   45 |                                         if (fabs(double(i/j) - (double)(Ma/Mb)) < DBL_EPSILON) {
      |                                                                                   ^~~~~~~~~~~
Language: C++

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

using namespace std;
#define int long long
const int mod = 1000000007;
int dp[1000][1000][50] = {};

signed main(){
	int N, Ma, Mb;
	int a[100] = {}, b[100] = {}, c[100] = {};
	cin >> N >> Ma >> Mb;
	for (int i = 0; i < N; i++) {
		int a, b, c;
		cin >> a >> b >> c;
		for (int i = 999; i >= 0; i--) {
			for (int j = 999; j >= 0; j--) {
				for (int k = N; k >= 0; k--) {
					if (dp[i][j][k] != 0&&l\k!=1) {
						dp[i + a][j + b][k + 1] = dp[i][j][k]+ c;
					}
				}
			}
		}
		dp[a][b][1] = c;
	}
	int m = 999999999999;
	for (int i = 999; i >= 0; i--) {
		for (int j = 999; j >= 0; j--) {
			for (int k = N; k >= 0; k--) {
				if (dp[i][j][k] != 0) {
					if ((double)(i / j) == (double)(Ma / Mb)) {
						m = min(m, dp[i][j][k]);
					}
				}
			}
		}
	}
	if (m == 999999999999) {
		cout << "-1" << endl;
		return 0;
	}
	cout << m << endl;
	

	
	return 0;
}


Compiler output:
a.cc:32:64: error: stray '\' in program
   32 |                                         if (dp[i][j][k] != 0&&l\k!=1) {
      |                                                                ^
a.cc: In function 'int main()':
a.cc:32:63: error: 'l' was not declared in this scope
   32 |                                         if (dp[i][j][k] != 0&&l\k!=1) {
      |                                                               ^
a.cc:32:64: error: expected ')' before 'k'
   32 |                                         if (dp[i][j][k] != 0&&l\k!=1) {
      |                                            ~                   ^~
      |                                                                )
Language: C++

#include <stdio.h>

/*

i-1番目まで調べて、物質aがAグラム、bがBグラムのときの最低価格をp[i][A][B]と置く。
A,Bは0から400まで、iは0から41まで

p[i][A][B] = 5000と置いておけば十分。

漸化式は、
p[i][A][B] = min(p[i-1][A-a[i-1]][B-b[i-1]] + c[i-1] , p[i-1][A][B])

p[0][0][0] = 0, 残りはp[0][A][B] = 5000。

*/
int a[40]; b[40]; c[40];

int p[41][401][401];
int memo[41][401][401];

int min(int i, int j){
	if(i<j){return i;}else{return j;}
}

int dp(int i,int A,int B){
	int PP;
	if(memo[i][A][B] == 1){
		return p[i][A][B];
	}
	if(A<0){return 5000;}
	if(B<0){return 5000;}
	
	PP = min(dp(i-1,A-a[i-1],B-b[i-1]) + c[i-1] , dp(i-1,A,B));
	memo[i][A][B] = 1;
	p[i][A][B] = PP;
	return PP;
}


int main() {
	int N,Ma,Mb,i,j,k,ans;
	scanf("%d %d %d",&N,&Ma,&Mb);
	for(i=0;i<N;i++){
		scanf("%d %d %d",&a[i],&b[i],&c[i]);
	}

	for(i=0;i<41;i++){
		for(j=0;j<401;j++){
			for(k=0;k<401;k++){
				memo[i][j][k] = 0;
				p[i][j][k] = 5000;
			}
		}
	}
	for(j=0;j<401;j++){
		for(k=0;k<401;k++){
			memo[0][j][k] = 1;
		}
	}
	p[0][0][0] = 0;

	ans = 5000;
	for(i=1;(i*Ma<=400) && (i*Mb<=400); i++){
		ans = min(ans, dp(N+1,Ma*i,Mb*i));
	}

	if(ans==5000){
		printf("-1\n");
	}else{
		printf("%d\n",ans);
	}
}


Compiler output:
a.cc:16:12: error: 'b' does not name a type
   16 | int a[40]; b[40]; c[40];
      |            ^
a.cc:16:19: error: 'c' does not name a type
   16 | int a[40]; b[40]; c[40];
      |                   ^
a.cc: In function 'int dp(int, int, int)':
a.cc:33:36: error: 'b' was not declared in this scope
   33 |         PP = min(dp(i-1,A-a[i-1],B-b[i-1]) + c[i-1] , dp(i-1,A,B));
      |                                    ^
a.cc:33:46: error: 'c' was not declared in this scope
   33 |         PP = min(dp(i-1,A-a[i-1],B-b[i-1]) + c[i-1] , dp(i-1,A,B));
      |                                              ^
a.cc: In function 'int main()':
a.cc:44:41: error: 'b' was not declared in this scope
   44 |                 scanf("%d %d %d",&a[i],&b[i],&c[i]);
      |                                         ^
a.cc:44:47: error: 'c' was not declared in this scope
   44 |                 scanf("%d %d %d",&a[i],&b[i],&c[i]);
      |                                               ^
Language: C++

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define vint vector<int>
#define vdouble vector<double>
#define vstring vector<string>
using namespace std;

#include<map>
#include<set>
#include<queue>

typedef long long ll;
typedef unsigned long long ull;

const int MAX_G = 401;
int N, MA, MB;
int A[40];
int B[40];
int C[40];
int G[MAX_G][MAX_G];

int main() {

	cin >> N >> MA >> MB;
	rep(i, N){
		cin >> A[i] >> B[i] >> C[i];
	}

	rep(i, MAX_G)
		rep(j, MAX_G)
	{
		G[i][j] = 999999;
	}
	G[0][0] = 0;

	rep(i, N){
		rep(a, MAX_G)
			rep(b, MAX_G)
		{
			if (G[a][b] != 999999){
				int aa = a + A[i];
				int bb = b + B[i];
				G[aa][bb] = min(G[aa][bb], G[a][b] + C[i]);
			}
		}
	}

	if (ret == 999999) ret = -1;
	cout << ret << endl;

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:56:13: error: 'ret' was not declared in this scope; did you mean 'rep'?
   56 |         if (ret == 999999) ret = -1;
      |             ^~~
      |             rep
a.cc:57:17: error: 'ret' was not declared in this scope; did you mean 'rep'?
   57 |         cout << ret << endl;
      |                 ^~~
      |                 rep
Language: C++

#include <stdio.h>
#include <algorithm>
#include <vector>

struct PatternA {
	int a, b, c;
	PatternA(int a0, int b0, int c0) : a(a0), b(b0), c(c0) {}
	PatternA() : a(0), b(0), c(0) {}
	bool operator<(const PatternA& o) const {
		if (a * o.b == o.a * b) {
			return c < o.c;
		}
		else {
			return a*o.b < o.a*b;
		}
	}
};
struct PatternB {
	int a, b, c;
	PatternB(int a0, int b0, int c0) : a(a0), b(b0), c(c0) {}
	PatternB() : a(0), b(0), c(0) {}
	bool operator<(const PatternB& o) const {
		if (a * o.b == o.a * b) {
			return c < o.c;
		}
		else {
			return a*o.b > o.a*b;
		}
	}
};

int main()
{
	int n, ma, mb;
	int a[40], b[40], c[40];
	scanf("%d%d%d", &n, &ma, &mb);
	for (int i = 0; i < n; i++) {
		scanf("%d%d%d", &a[i], &b[i], &c[i]);
	}
	std::vector<PatternA> va;
	std::vector<PatternB> vb;
	int pan = std::min(20, n);
	int pbn = n - pan;
	for (int i = 0; i < (1<<pan); i++) {
		PatternA p;
		for (int j = 0; j < pan; j++) {
			if (i&(1 << j)) {
				p.a += a[j];
				p.b += b[j];
				p.c += c[j];
			}
		}
		va.push_back(p);
	}
	for (int i = 0; i < (1<<pbn); i++) {
		PatternB p;
		for (int j = 0; j < pan; j++) {
			if (i&(1 << j)) {
				p.a += a[j];
				p.b += b[j];
				p.c += c[j];
			}
		}
		vb.push_back(p);
	}
	std::sort(va.begin(), va.end());
	std::sort(vb.begin(), vb.end());
	int ia = 0;
	int ib = 0;
	int ret = INT_MAX;
	while (ia < (int)va.size() && ib < (int)vb.size()) {
		int aa = va[ia].a + vb[ib].a;
		int bb = va[ia].b + vb[ib].b;
		int cc = va[ia].c + vb[ib].c;
		if (aa * mb == bb * ma && aa*mb > 0) {
			ret = std::min(ret, cc);
			ia++;
			continue;
		}
		if (aa * mb < bb * ma) {
			if (ia < (int)va.size() - 1) {
				ia++;
				continue;
			}
			else if (ib < (int)vb.size() - 1) {
				ib++;
				continue;
			}
			else {
				break;
			}
		} else  {
			if (ib < (int)vb.size() - 1) {
				ib++;
				continue;
			}
			else if (ia < (int)va.size() - 1) {
				ia++;
				continue;
			}
			else {
				break;
			}
		}
	}
	if (ret == INT_MAX) {
		ret = -1;
	}
	printf("%d\n", ret);
	return 0;
}


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

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

long long dp[1001][1001];

int main(void){
	int N,Ma,Mb;
	cin >> N >> Ma >> Mb;
	vector<int> a(N),b(N),c(N);
	for(int i=0;i<N;i++){
		cin >> a[i] >> b[i] >> c[i];
	}

	for(int i=0;i<=1000;i++)for(int j=0;j<=1000;j++)
		dp[i][j] = 1e18;

	dp[0][0] = 0;
	for(int i=0;i<=1000;i++){
		for(int j=0;j<=1000;j++){
			for(int k=0;k<N;k++){
				if(i+a[k] > 1000 || j+b[k] > 1000)continue;
				dp[i+a[k]][j+b[k]] = min(dp[i][j] + c[k],dp[i+a[k]][j+b[k]]);
			}
		}
	}

	int ret = 1e18;
	for(int i=1;i<100;i++){
		ret = min(ret,dp[Ma*i][Mb*i]);
	}
	if(ret == 1e18)cout << -1 << endl;
	else cout << ret << endl;

	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:27:19: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
   27 |         int ret = 1e18;
      |                   ^~~~
a.cc:29:26: error: no matching function for call to 'min(int&, long long int&)'
   29 |                 ret = min(ret,dp[Ma*i][Mb*i]);
      |                       ~~~^~~~~~~~~~~~~~~~~~~~
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:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:29:26: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   29 |                 ret = min(ret,dp[Ma*i][Mb*i]);
      |                       ~~~^~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:29:26: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   29 |                 ret = min(ret,dp[Ma*i][Mb*i]);
      |                       ~~~^~~~~~~~~~~~~~~~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,odd=0,even=0;
  cin >> n;
  int a[n];
  for(int i=0;i<n;i++){
    cin >> a[i];
    if(a[i]%2==0)even++;
    else odd++;
  }
  if(odd%2==1)cout << "NO" << endl;
  else cout << "YES" << endl;
  sort(a,a+n);

Compiler output:
a.cc: In function 'int main()':
a.cc:14:15: error: expected '}' at end of input
   14 |   sort(a,a+n);
      |               ^
a.cc:3:11: note: to match this '{'
    3 | int main(){
      |           ^