Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <list>
#include <map>

int main(){

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

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



    for(int ii = 0 ; ii < 50 ; ii ++){
        for(int ai = 0 ; ai < nmax*abmax ; ai ++) {
            for (int bi = 0; bi < nmax*abmax ; bi++) {

                dp[ii][ai][bi] = INF;
            }
        }
    }

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


    for(int ii = 0 ; ii < N ; ii ++){
        for(int ai = 0 ; ai < nmax*abmax ; ai ++) {
            for (int bi = 0; bi < nmax*abmax ; bi++) {
                if(dp[ii][ai][bi] == INF) continue;
                dp[ii+1][ai][bi] = min(dp[ii][ai][bi] , dp[ii+1][ai][bi]);
                dp[ii+1][ai+a[ii]][bi+b[ii]] = min(dp[ii+1][ai+a[ii]][bi+b[ii]] , dp[ii][ai][bi]+c[ii]);
            }
        }
    }


    int res = INF;
    for(int ma = 1 ; ma <= nmax*abmax ; ma ++) {
        for (int mb = 1; mb <= nmax*abmax; mb++) {
            if(ma*Mb == Ma*mb){
                res = min(res , dp[N-1][ma][mb]);
            }
        }
    }

    if(res == INF) cout << -1 << endl;
    else cout << res << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:10:5: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   10 |     cin >> N >> Ma >> Mb;
      |     ^~~
      |     std::cin
In file included from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:20:31: error: 'nmax' was not declared in this scope
   20 |         for(int ai = 0 ; ai < nmax*abmax ; ai ++) {
      |                               ^~~~
a.cc:20:36: error: 'abmax' was not declared in this scope
   20 |         for(int ai = 0 ; ai < nmax*abmax ; ai ++) {
      |                                    ^~~~~
a.cc:23:17: error: 'dp' was not declared in this scope
   23 |                 dp[ii][ai][bi] = INF;
      |                 ^~
a.cc:23:34: error: 'INF' was not declared in this scope
   23 |                 dp[ii][ai][bi] = INF;
      |                                  ^~~
a.cc:28:5: error: 'dp' was not declared in this scope
   28 |     dp[0][0][0] = 0;
      |     ^~
a.cc:32:31: error: 'nmax' was not declared in this scope
   32 |         for(int ai = 0 ; ai < nmax*abmax ; ai ++) {
      |                               ^~~~
a.cc:32:36: error: 'abmax' was not declared in this scope
   32 |         for(int ai = 0 ; ai < nmax*abmax ; ai ++) {
      |                                    ^~~~~
a.cc:34:38: error: 'INF' was not declared in this scope
   34 |                 if(dp[ii][ai][bi] == INF) continue;
      |                                      ^~~
a.cc:35:36: error: 'min' was not declared in this scope; did you mean 'std::min'?
   35 |                 dp[ii+1][ai][bi] = min(dp[ii][ai][bi] , dp[ii+1][ai][bi]);
      |                                    ^~~
      |                                    std::min
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:3:
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: 'std::min' declared here
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
a.cc:42:15: error: 'INF' was not declared in this scope
   42 |     int res = INF;
      |               ^~~
a.cc:43:28: error: 'nmax' was not declared in this scope; did you mean 'ma'?
   43 |     for(int ma = 1 ; ma <= nmax*abmax ; ma ++) {
      |                            ^~~~
      |                            ma
a.cc:43:33: error: 'abmax' was not declared in this scope
   43 |     for(int ma = 1 ; ma <= nmax*abmax ; ma ++) {
      |                                 ^~~~~
a.cc:46:23: error: 'min' was not declared in this scope; did you mean 'std::min'?
   46 |                 res = min(res , dp[N-1][ma][mb]);
      |                       ^~~
      |                       std::min
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: 'std::min' declared here
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
a.cc:51:20: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   51 |     if(res == INF) cout << -1 << endl;
      |                    ^~~~
      |                    std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:51:34: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   51 |     if(res == INF) cout << -1 << endl;
      |                                  ^~~~
      |                                  std::endl
In file included from /usr/include/c++/14/iostream:41:
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~
a.cc:52:10: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   52 |     else cout << res << endl;
      |          ^~~~
      |          std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:52:25: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   52 |     else cout << res << endl;
      |                         ^~~~
      |                         std::endl
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~