Language: C++

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

#define MAX_N 10000
#define MAX_M 100000000

vector<vector<int> > ms;

void pf(int n, int max, int size, vector<int> &a) {
	if (n == 0) {
      if (std::find(a.begin(), a.end(), 1) == a.end() && a.size() == size) {
		    ms.push_back(a);
      }
		return;
	}
	for (int i = min(n, max); i > 0; --i) {
		a.push_back(i);
		pf(n -i, i, size, a);
		a.erase(a.end() - 1);
	}
}

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


int main() {
	vector<int> a;
  int N,  M;
  cin >> N >> M;
	pf(M, M, N, a);
  int max_gcd = -1;
  for (vector<int> m : ms) {
    int g = gcd(m[0], m[1]);
    for (int i = 2; i < m.size(); i++) {
      g = gcd(g, m[i]);
      if (max_gcd > 0 && g < max_gcd)
        break;
    }
    if (g >= max_gcd) {
      max_gcd = g;
    }
	}
  cout << max_gcd << endl;
}


Compiler output:
a.cc:8:1: error: 'vector' does not name a type
    8 | vector<vector<int> > ms;
      | ^~~~~~
a.cc:10:35: error: 'vector' has not been declared
   10 | void pf(int n, int max, int size, vector<int> &a) {
      |                                   ^~~~~~
a.cc:10:41: error: expected ',' or '...' before '<' token
   10 | void pf(int n, int max, int size, vector<int> &a) {
      |                                         ^
a.cc: In function 'void pf(int, int, int, int)':
a.cc:12:21: error: 'a' was not declared in this scope
   12 |       if (std::find(a.begin(), a.end(), 1) == a.end() && a.size() == size) {
      |                     ^
a.cc:13:21: error: 'ms' was not declared in this scope
   13 |                     ms.push_back(a);
      |                     ^~
a.cc:17:22: error: 'min' was not declared in this scope; did you mean 'std::min'?
   17 |         for (int i = min(n, max); i > 0; --i) {
      |                      ^~~
      |                      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:18:17: error: 'a' was not declared in this scope
   18 |                 a.push_back(i);
      |                 ^
a.cc: In function 'int main()':
a.cc:34:9: error: 'vector' was not declared in this scope
   34 |         vector<int> a;
      |         ^~~~~~
a.cc:34:9: note: suggested alternatives:
In file included from /usr/include/c++/14/vector:66,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_vector.h:428:11: note:   'std::vector'
  428 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
/usr/include/c++/14/vector:93:13: note:   'std::pmr::vector'
   93 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
a.cc:34:16: error: expected primary-expression before 'int'
   34 |         vector<int> a;
      |                ^~~
a.cc:36:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   36 |   cin >> N >> M;
      |   ^~~
      |   std::cin
In file included from a.cc:2:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:37:21: error: 'a' was not declared in this scope
   37 |         pf(M, M, N, a);
      |                     ^
a.cc:39:15: error: expected primary-expression before 'int'
   39 |   for (vector<int> m : ms) {
      |               ^~~
a.cc:50:3: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   50 |   cout << max_gcd << 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:50:22: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   50 |   cout << max_gcd << 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:51:1: error: expected primary-expression before '}' token
   51 | }
      | ^
a.cc:50:27: error: expected ')' before '}' token
   50 |   cout << max_gcd << endl;
      |                           ^
      |                           )
   51 | }
      | ~                          
a.cc:39:7: note: to match this '('
   39 |   for (vector<int> m : ms) {
      |       ^
a.cc:51:1: error: expected primary-expression before '}' token
   51 | }
      | ^