Language: C++

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

int max = INT_MAX;
vector<vector<int>> n;
bool finding = false;
int max1 = INT_MAX;

int calcPattern(long long sum, vector<int> pattern, int nextNumber,int just) {
	long long temp = sum;
	vector<int> tempPattern = pattern;
	sum += nextNumber;
	if (nextNumber > max1)return 0;
	if (nextNumber >= max)return 0;
	if (sum == just/* && !finding*/) {
		pattern.push_back(nextNumber);
		if (nextNumber > max1)return 0;
		max1 = nextNumber;
		n.push_back(pattern);
		finding = true;
		return 1;
	}
	else if (sum > just) {
		return 0;
	}
	else {
		pattern.push_back(nextNumber);
		nextNumber++;
		return calcPattern(sum, pattern, nextNumber, just)+ calcPattern(temp, tempPattern, nextNumber, just);
	}
}


int main() {
	int N, check;
	vector<int> pattern;
	cin >> N;
	if (N >= 8)max = (N + 1) / 2;
	check = calcPattern(0, pattern, 1, N);
	int min = INT_MAX, select;
	for (unsigned i = 0; i < n.size(); i++) {
		if (n[i][n[i].size() - 1] < min) {
			min = n[i][n[i].size() - 1];
			select = i;
		}
	}
	for (unsigned i = 0; i < n[select].size(); i++) {
		cout << n[select][i] << endl;
	}
	return 0;
}

Compiler output:
a.cc:6:11: error: 'INT_MAX' was not declared in this scope
    6 | int max = 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 | using namespace std;
a.cc:9:12: error: 'INT_MAX' was not declared in this scope
    9 | int max1 = INT_MAX;
      |            ^~~~~~~
a.cc:9:12: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
a.cc: In function 'int calcPattern(long long int, std::vector<int>, int, int)':
a.cc:16:27: error: reference to 'max' is ambiguous
   16 |         if (nextNumber >= max)return 0;
      |                           ^~~
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:303:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:                 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
a.cc:6:5: note:                 'int max'
    6 | int max = INT_MAX;
      |     ^~~
a.cc: In function 'int main()':
a.cc:40:20: error: reference to 'max' is ambiguous
   40 |         if (N >= 8)max = (N + 1) / 2;
      |                    ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:                 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
a.cc:6:5: note:                 'int max'
    6 | int max = INT_MAX;
      |     ^~~
a.cc:42:19: error: 'INT_MAX' was not declared in this scope
   42 |         int min = INT_MAX, select;
      |                   ^~~~~~~
a.cc:42:19: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
a.cc:46:32: error: assignment of function 'int select(int, fd_set*, fd_set*, fd_set*, timeval*)'
   46 |                         select = i;
      |                         ~~~~~~~^~~
a.cc:49:36: error: invalid conversion from 'int (*)(int, fd_set*, fd_set*, fd_set*, timeval*)' to 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-fpermissive]
   49 |         for (unsigned i = 0; i < n[select].size(); i++) {
      |                                    ^~~~~~
      |                                    |
      |                                    int (*)(int, fd_set*, fd_set*, fd_set*, timeval*)
In file included from /usr/include/c++/14/vector:66,
                 from a.cc:3:
/usr/include/c++/14/bits/stl_vector.h:1128:28: note:   initializing argument 1 of 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](size_type) [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >; reference = std::vector<int>&; size_type = long unsigned int]'
 1128 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~
a.cc:50:27: error: invalid conversion from 'int (*)(int, fd_set*, fd_set*, fd_set*, timeval*)' to 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-fpermissive]
   50 |                 cout << n[select][i] << endl;
      |                           ^~~~~~
      |                           |
      |                           int (*)(int, fd_set*, fd_set*, fd_set*, timeval*)
/usr/include/c++/14/bits/stl_vector.h:1128:28: note:   initializing argument 1 of 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](size_type) [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >; reference = std::vector<int>&; size_type = long unsigned int]'
 1128 |       operator[](size_type __n) _GLIBCXX_NOEXCEPT
      |                  ~~~~~~~~~~^~~