Language: C++

#include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<sstream>
#include<algorithm>
#include<cmath>
#include<map>
#include<functional>
#include<queue>
#include<stack>
#include<set>
using namespace std;
int stoi(string x){stringstream ss;ss<<x;int tmp;ss>>tmp;return tmp;}
string itos(int x){stringstream ss;ss<<x;return ss.str();}
#define sz(n)  (int)n.size()
#define dump(x) cerr<<#x<<" = "<<(x)<<endl;
#define debug(x)cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define MP make_pair
#define PB push_back
	priority_queue<int,vector<int>,greater<int>() >ta;
	int n,m;
	string sn,sm;
	int ans=0;
	bool used[1000000];
	bool flag[100];
	vector<string>ab;
	void dfs(int h,int f){
		if(h==sz(sm)){
		//for(int i=0;i<sz(sm);i++)cout<<flag[i]<<" ";cout<<endl;
		int sum=0;
		string tmp="";
		flag[sz(sm)-1]=0;
		for(int i=0;i<sz(sm);i++){
			tmp.push_back(sm[i]);
			if(flag[i])sum+=stoi(tmp),tmp="";
		}
		if(sz(tmp)>=1)sum+=stoi(tmp);
		if(f==1&&sum==ans){
			//for(int i=0;i<sz(sm);i++)cout<<flag[i]<<" ";cout<<endl;
			tmp="";
			for(int i=0;i<sz(sm);i++){
			tmp.push_back(sm[i]);
			if(flag[i]){ab.push_back(tmp),tmp="";}
		}
		if(!tmp.empty())ab.push_back(tmp);
		return ;
		}
		
		
		if(sum<=n)ans=max(ans,sum);
		used[sum]++;
		//for(int i=0;i<sz(sm);i++)cout<<flag[i]<<" ";cout<<sum<<endl;
		return ;
		}
		
		flag[h]=1;
		dfs(h+1,f);
		flag[h]=0;
		if(h+1<sz(sm))dfs(h+1,f);
	}
	
	int main(){
	while(cin>>n>>m,n||m){
	sn=itos(n),sm=itos(m);
	fill(used,used+1000000,0);
	fill(flag,flag+100,0);
	ans=0;
	ab.clear();
	dfs(0,0);
	if(used[ans]>=2)cout<<"rejected"<<endl;
	else if (ans==0)cout<<"error"<<endl;
	else {
		cout<<ans<<" ";
		dfs(0,1);
		for(int i=0;i<sz(ab);i++){cout<<ab[i];(i==sz(ab)-1)?cout<<endl:cout<<" ";}
	}
	}
	return 0;
} 

Compiler output:
In file included from /usr/include/c++/14/queue:66,
                 from a.cc:10:
/usr/include/c++/14/bits/stl_queue.h: In instantiation of 'class std::priority_queue<int, std::vector<int>, std::greater<int>()>':
a.cc:21:49:   required from here
   21 |         priority_queue<int,vector<int>,greater<int>() >ta;
      |                                                        ^~
/usr/include/c++/14/bits/stl_queue.h:538:18: error: data member 'std::priority_queue<int, std::vector<int>, std::greater<int>()>::comp' invalidly declared function type
  538 |       _Compare   comp;
      |                  ^~~~
a.cc:21:56: error: no matching function for call to 'std::priority_queue<int, std::vector<int>, std::greater<int>()>::priority_queue()'
   21 |         priority_queue<int,vector<int>,greater<int>() >ta;
      |                                                        ^~
/usr/include/c++/14/bits/stl_queue.h:691:9: note: candidate: 'template<class _InputIterator, class _Alloc, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(_InputIterator, _InputIterator, const _Compare&, _Sequence&&, const _Alloc&) [with _Alloc = _InputIterator; _Requires = _Alloc; _Tp = int; _Sequence = std::vector<int>; _Compare = std::greater<int>()]'
  691 |         priority_queue(_InputIterator __first, _InputIterator __last,
      |         ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:691:9: note:   candidate expects 5 arguments, 0 provided
/usr/include/c++/14/bits/stl_queue.h:679:9: note: candidate: 'template<class _InputIterator, class _Alloc, class, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(_InputIterator, _InputIterator, const _Compare&, const _Sequence&, const _Alloc&) [with _Alloc = _InputIterator; <template-parameter-2-3> = _Alloc; _Requires = <template-parameter-1-3>; _Tp = int; _Sequence = std::vector<int>; _Compare = std::greater<int>()]'
  679 |         priority_queue(_InputIterator __first, _InputIterator __last,
      |         ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:679:9: note:   candidate expects 5 arguments, 0 provided
/usr/include/c++/14/bits/stl_queue.h:671:9: note: candidate: 'template<class _InputIterator, class _Alloc, class, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(_InputIterator, _InputIterator, const _Compare&, const _Alloc&) [with _Alloc = _InputIterator; <template-parameter-2-3> = _Alloc; _Requires = <template-parameter-1-3>; _Tp = int; _Sequence = std::vector<int>; _Compare = std::greater<int>()]'
  671 |         priority_queue(_InputIterator __first, _InputIterator __last,
      |         ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:671:9: note:   candidate expects 4 arguments, 0 provided
/usr/include/c++/14/bits/stl_queue.h:663:9: note: candidate: 'template<class _InputIterator, class _Alloc, class, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(_InputIterator, _InputIterator, const _Alloc&) [with _Alloc = _InputIterator; <template-parameter-2-3> = _Alloc; _Requires = <template-parameter-1-3>; _Tp = int; _Sequence = std::vector<int>; _Compare = std::greater<int>()]'
  663 |         priority_queue(_InputIterator __first, _InputIterator __last,
      |         ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:663:9: note:   candidate expects 3 arguments, 0 provided
/usr/include/c++/14/bits/stl_queue.h:649:9: note: candidate: 'template<class _InputIterator, class> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(_InputIterator, _InputIterator, const _Compare&, _Sequence&&) [with <template-parameter-2-2> = _InputIterator; _Tp = int; _Sequence = std::vector<int>; _Compare = std::greater<int>()]'
  649 |         priority_queue(_InputIterator __first, _InputIterator __last,
      |         ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:649:9: note:   candidate expects 4 arguments, 0 provided
/usr/include/c++/14/bits/stl_queue.h:638:9: note: candidate: 'template<class _InputIterator, class> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(_InputIterator, _InputIterator, const _Compare&, const _Sequence&) [with <template-parameter-2-2> = _InputIterator; _Tp = int; _Sequence = std::vector<int>; _Compare = std::greater<int>()]'
  638 |         priority_queue(_InputIterator __first, _InputIterator __last,
      |         ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:638:9: note:   candidate expects 4 arguments, 0 provided
/usr/include/c++/14/bits/stl_queue.h:629:9: note: candidate: 'template<class _InputIterator, class> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(_InputIterator, _InputIterator, const _Compare&) [with <template-parameter-2-2> = _InputIterator; _Tp = int; _Sequence = std::vector<int>; _Compare = std::greater<int>()]'
  629 |         priority_queue(_InputIterator __first, _InputIterator __last,
      |         ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:629:9: note:   candidate expects 2 arguments, 0 provided
/usr/include/c++/14/bits/stl_queue.h:594:9: note: candidate: 'template<class _Alloc, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(std::priority_queue<_Tp, _Sequence, _Compare>&&, const _Alloc&) [with _Requires = _Alloc; _Tp = int; _Sequence = std::vector<int>; _Compare = std::greater<int>()]'
  594 |         priority_queue(priority_queue&& __q, const _Alloc& __a)
      |         ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:594:9: note:   candidate expects 2 arguments, 0 provided
/usr/include/c++/14/bits/stl_queue.h:590:9: note: candidate: 'template<class _Alloc, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(const std::priority_queue<_Tp, _Sequence, _Compare>&, const _Alloc&) [with _Requires = _Alloc; _Tp = int; _Sequence = std::vector<int>; _Compare = std::greater<int>()]'
  590 |         priority_queue(const priority_queue& __q, const _Alloc& __a)
      |         ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:590:9: note:   candidate expects 2 arguments, 0 provided
/usr/include/c++/14/bits/stl_queue.h:585:9: note: candidate: 'template<class _Alloc, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(const _Compare&, _Sequence&&, const _Alloc&) [with _Requires = _Alloc; _Tp = int; _Sequence = std::vector<int>; _Compare = std::greater<int>()]'
  585 |         priority_queue(const _Compare& __x, _Sequence&& __c, const _Alloc& __a)
      |         ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:585:9: note:   candidate expects 3 arguments, 0 provided
/usr/include/c++/14/bits/stl_queue.h:579:9: note: candidate: 'template<class _Alloc, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(const _Compare&, const _Sequence&, const _Alloc&) [with _Requires = _Alloc; _Tp = int; _Sequence = std::vector<int>; _Compare = std::greater<int>()]'
  579 |         priority_queue(const _Compare& __x, const _Sequence& __c,
      |         ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:579:9: note:   candidate expects 3 arguments, 0 provided
/usr/include/c++/14/bits/stl_queue.h:573:9: note: candidate: 'template<class _Alloc, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(const _Compare&, const _Alloc&) [with _Requires = _Alloc; _Tp = int; _Sequence = std::vector<int>; _Compare = std::greater<int>()]'
  573 |         priority_queue(const _Compare& __x, const _Alloc& __a)
      |         ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:573:9: note:   candidate expects 2 arguments, 0 provided
/usr/include/c++/14/bits/stl_queue.h:569:9: note: candidate: 'template<class _Alloc, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(const _Alloc&) [with _Requires = _Alloc; _Tp = int; _Sequence = std::vector<int>; _Compare = std::greater<int>()]'
  569 |         priority_queue(const _Alloc& __a)
      |         ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:569:9: note:   candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/stl_queue.h:554:9: note: candidate: 'template<class _Seq, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue() [with _Requires = _Seq; _Tp = int; _Sequence = std::vector<int>; _Compare = std::greater<int>()]'
  554 |         priority_queue()
      |         ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:554:9: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_queue.h:551:43: error: no type named 'type' in 'struct std::enable_if<false, void>'
  551 |       template<typename _Seq = _Sequence, typename _Requires = typename
      |                                           ^~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:563:7: note: candidate: 'std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(const _Compare&, _Sequence&&) [with _Tp = int; _Sequence = std::vector<int>; _Compare = std::greater<int>()]'
  563 |       priority_queue(const _Compare& __x, _Sequence&& __s = _Sequence())
      |       ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:563:7: note:   candidate expects 2 arguments, 0 provided
/usr/include/c++/14/bits/stl_queue.h:558:7: note: candidate: 'std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(const _Compare&, const _Sequence&) [with _Tp = int; _Sequence = std::vector<int>; _Compare = std::greater<int>()]'
  558 |       priority_queue(const _Compare& __x, const _Sequence& __s)
      |       ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:558:7: note:   candidate expects 2 arguments, 0 provided
/usr/include/c++/14/bits/stl_queue.h:496:11: note: candidate: 'std::priority_queue<int, std::vector<int>, std::greater<int>()>::priority_queue(const std::priority_queue<int, std::vector<int>, std::greater<int>()>&)'
  496 |     class priority_queue
      |           ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:496:11: note:   candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/stl_queue.h:496:11: note: candidate: 'std::priority_queue<int, std::vector<int>, std::greater<int>()>::priority_queue(std::priority_queue<int, std::vector<int>, std::greater<int>()>&&)'
/usr/include/c++/14/bits/stl_queue.h