Language: C++

using namespace std;
string S, T, B = "~";
bool isOK(string A1, string A2) {
	for (int i = 0; i < A1.size(); i++) {
		if (A1[i] != '?' && A1[i] != A2[i])return false;
	}
	return true;
}
int main() {
	cin >> S >> T;
	for (int i = 0; i <= (int)S.size() - (int)T.size(); i++) {
		string U = S.substr(i, T.size());
		if (isOK(U, T) == true) {
			string V = S;
			for (int j = i; j < i + T.size(); j++)V[j] = T[j - i];
			for (int j = 0; j < i; j++) { if (V[j] == '?')V[j] = 'a'; }
			for (int j = i + T.size(); j < V.size(); j++) { if (V[j] == '?')V[j] = 'a'; }
			B = min(B, V);
		}
	}
	if (B == "~")cout << "UNRESTORABLE" << endl;
	else cout << B << endl;
	return 0;
}


Compiler output:
a.cc:2:1: error: 'string' does not name a type
    2 | string S, T, B = "~";
      | ^~~~~~
a.cc:3:11: error: 'string' was not declared in this scope
    3 | bool isOK(string A1, string A2) {
      |           ^~~~~~
a.cc:1:1: note: 'std::string' is defined in header '<string>'; this is probably fixable by adding '#include <string>'
  +++ |+#include <string>
    1 | using namespace std;
a.cc:3:22: error: 'string' was not declared in this scope
    3 | bool isOK(string A1, string A2) {
      |                      ^~~~~~
a.cc:3:22: note: 'std::string' is defined in header '<string>'; this is probably fixable by adding '#include <string>'
a.cc:3:31: error: expression list treated as compound expression in initializer [-fpermissive]
    3 | bool isOK(string A1, string A2) {
      |                               ^
a.cc: In function 'int main()':
a.cc:10:9: error: 'cin' was not declared in this scope
   10 |         cin >> S >> T;
      |         ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | using namespace std;
a.cc:10:16: error: 'S' was not declared in this scope
   10 |         cin >> S >> T;
      |                ^
a.cc:10:21: error: 'T' was not declared in this scope
   10 |         cin >> S >> T;
      |                     ^
a.cc:12:17: error: 'string' was not declared in this scope
   12 |                 string U = S.substr(i, T.size());
      |                 ^~~~~~
a.cc:12:17: note: 'std::string' is defined in header '<string>'; this is probably fixable by adding '#include <string>'
a.cc:13:26: error: 'U' was not declared in this scope
   13 |                 if (isOK(U, T) == true) {
      |                          ^
a.cc:13:25: error: 'isOK' cannot be used as a function
   13 |                 if (isOK(U, T) == true) {
      |                     ~~~~^~~~~~
a.cc:14:31: error: expected ';' before 'V'
   14 |                         string V = S;
      |                               ^~
      |                               ;
a.cc:15:63: error: 'V' was not declared in this scope
   15 |                         for (int j = i; j < i + T.size(); j++)V[j] = T[j - i];
      |                                                               ^
a.cc:16:59: error: 'V' was not declared in this scope
   16 |                         for (int j = 0; j < i; j++) { if (V[j] == '?')V[j] = 'a'; }
      |                                                           ^
a.cc:17:56: error: 'V' was not declared in this scope
   17 |                         for (int j = i + T.size(); j < V.size(); j++) { if (V[j] == '?')V[j] = 'a'; }
      |                                                        ^
a.cc:18:25: error: 'B' was not declared in this scope
   18 |                         B = min(B, V);
      |                         ^
a.cc:18:36: error: 'V' was not declared in this scope
   18 |                         B = min(B, V);
      |                                    ^
a.cc:18:29: error: 'min' was not declared in this scope; did you mean 'main'?
   18 |                         B = min(B, V);
      |                             ^~~
      |                             main
a.cc:21:13: error: 'B' was not declared in this scope
   21 |         if (B == "~")cout << "UNRESTORABLE" << endl;
      |             ^
a.cc:21:22: error: 'cout' was not declared in this scope
   21 |         if (B == "~")cout << "UNRESTORABLE" << endl;
      |                      ^~~~
a.cc:21:22: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:21:48: error: 'endl' was not declared in this scope
   21 |         if (B == "~")cout << "UNRESTORABLE" << endl;
      |                                                ^~~~
a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
  +++ |+#include <ostream>
    1 | using namespace std;
a.cc:22:14: error: 'cout' was not declared in this scope
   22 |         else cout << B << endl;
      |              ^~~~
a.cc:22:14: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:22:27: error: 'endl' was not declared in this scope
   22 |         else cout << B << endl;
      |                           ^~~~
a.cc:22:27: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'