Language: C++

pair<bool, int> findValueFirst(vector<pair<int, int> > x, int f){
	int s = x.size();
	for(int i = 0; i < s; i++){
		if(x[i].first == f){
			return make_pair(true, i);
		}
	}
	return make_pair(false, -1);
}

int solve(int n, int s, vector<int> d, vector<pair<int, int> > m){
	int smallest = 2147483647; //Starter Smallest Value
	for(int i = 0; i < s; i++){ //Iterate Through d
		if(d[i] <= n){ //If d[i] is greater than n, do not Continue
			int remainder = n%d[i];
			int quotient = n/d[i]; //Generate Remainder and Quotient
			int result = 0;
			if(remainder == 0){
				result = quotient; //No Remainder, so the Result is the Quotient
				                   //More Efficient to Give Result the Value of Quotient than to Search through m
			} else {
				pair<bool, int> attemptToFindVal = findValueFirst(m, remainder);
				if(attemptToFindVal.first == false){ //First Time Attempting this Tree Branch
					result = quotient + solve(remainder, s, d, m); //Remainder Exists, so Compute the Remainder as solve(remainder, s, d) (Recursive)
					m.push_back(make_pair(remainder, result-quotient)); //Store the Value of Remainder and its Result
				} else { //Already Attempted this Tree Branch Before
					result = quotient + m[attemptToFindVal.second].second;
				}
			}
			if(result < smallest){ //If the New Result is Less than the Smallest Value Recorded, Replace it
				smallest = result;
			}
		}
	}
	return smallest; //Return Final Smallest Value
}

int main(){
	int n, m;
	cin >> n >> m;
	vector<int> x(m);
	for(int i = 0; i < m; i++){
		cin >> x[i];
	} //Finished Resolving Inputs
	sort(x.rbegin(), x.rend()); //Reverse-Sort Denominations
	vector<pair<int, int> > p;
	cout << solve(n, m, x, p) << endl; //Perform Solve Function
}


Compiler output:
a.cc:1:1: error: 'pair' does not name a type
    1 | pair<bool, int> findValueFirst(vector<pair<int, int> > x, int f){
      | ^~~~
a.cc:11:25: error: 'vector' has not been declared
   11 | int solve(int n, int s, vector<int> d, vector<pair<int, int> > m){
      |                         ^~~~~~
a.cc:11:31: error: expected ',' or '...' before '<' token
   11 | int solve(int n, int s, vector<int> d, vector<pair<int, int> > m){
      |                               ^
a.cc: In function 'int solve(int, int, int)':
a.cc:14:20: error: 'd' was not declared in this scope
   14 |                 if(d[i] <= n){ //If d[i] is greater than n, do not Continue
      |                    ^
a.cc:22:33: error: 'pair' was not declared in this scope
   22 |                                 pair<bool, int> attemptToFindVal = findValueFirst(m, remainder);
      |                                 ^~~~
a.cc:22:38: error: expected primary-expression before 'bool'
   22 |                                 pair<bool, int> attemptToFindVal = findValueFirst(m, remainder);
      |                                      ^~~~
a.cc:23:36: error: 'attemptToFindVal' was not declared in this scope
   23 |                                 if(attemptToFindVal.first == false){ //First Time Attempting this Tree Branch
      |                                    ^~~~~~~~~~~~~~~~
a.cc:24:84: error: 'm' was not declared in this scope
   24 |                                         result = quotient + solve(remainder, s, d, m); //Remainder Exists, so Compute the Remainder as solve(remainder, s, d) (Recursive)
      |                                                                                    ^
a.cc:25:53: error: 'make_pair' was not declared in this scope
   25 |                                         m.push_back(make_pair(remainder, result-quotient)); //Store the Value of Remainder and its Result
      |                                                     ^~~~~~~~~
a.cc:27:61: error: 'm' was not declared in this scope
   27 |                                         result = quotient + m[attemptToFindVal.second].second;
      |                                                             ^
a.cc: In function 'int main()':
a.cc:40:9: error: 'cin' was not declared in this scope
   40 |         cin >> n >> m;
      |         ^~~
a.cc:41:9: error: 'vector' was not declared in this scope
   41 |         vector<int> x(m);
      |         ^~~~~~
a.cc:41:16: error: expected primary-expression before 'int'
   41 |         vector<int> x(m);
      |                ^~~
a.cc:43:24: error: 'x' was not declared in this scope
   43 |                 cin >> x[i];
      |                        ^
a.cc:45:14: error: 'x' was not declared in this scope
   45 |         sort(x.rbegin(), x.rend()); //Reverse-Sort Denominations
      |              ^
a.cc:45:9: error: 'sort' was not declared in this scope; did you mean 'short'?
   45 |         sort(x.rbegin(), x.rend()); //Reverse-Sort Denominations
      |         ^~~~
      |         short
a.cc:46:16: error: 'pair' was not declared in this scope
   46 |         vector<pair<int, int> > p;
      |                ^~~~
a.cc:46:21: error: expected primary-expression before 'int'
   46 |         vector<pair<int, int> > p;
      |                     ^~~
a.cc:47:9: error: 'cout' was not declared in this scope
   47 |         cout << solve(n, m, x, p) << endl; //Perform Solve Function
      |         ^~~~
a.cc:47:32: error: 'p' was not declared in this scope
   47 |         cout << solve(n, m, x, p) << endl; //Perform Solve Function
      |                                ^
a.cc:47:38: error: 'endl' was not declared in this scope
   47 |         cout << solve(n, m, x, p) << endl; //Perform Solve Function
      |                                      ^~~~