Language: C++

using namespace std;
 
const int Maxn = 52;
 
string S, T;
string res;
 
bool Restore(int pos, string &tmp)
{
	tmp = S;
	for (int i = 0; i < T.length(); i++)
		if (S[pos + i] != '?' && S[pos + i] != T[i]) return false;
		else tmp[pos + i] = T[i];
	for (int i = 0; i < tmp.length(); i++)
		if (tmp[i] == '?') tmp[i] = 'a';
	return true;
}
 
int main()
{
	cin >> S >> T;
	string tmp;
	for (int i = 0; i + T.length() <= S.length(); i++)
		if (Restore(i, tmp))
			if (res == "" || tmp < res) res = tmp;
	if (res == "") printf("UNRESTORABLE\n");
	else printf("%s\n", res.c_str());
	return 0;
}

Compiler output:
a.cc:5:1: error: 'string' does not name a type
    5 | string S, T;
      | ^~~~~~
a.cc:6:1: error: 'string' does not name a type
    6 | string res;
      | ^~~~~~
a.cc:8:23: error: 'string' has not been declared
    8 | bool Restore(int pos, string &tmp)
      |                       ^~~~~~
a.cc: In function 'bool Restore(int, int&)':
a.cc:10:15: error: 'S' was not declared in this scope
   10 |         tmp = S;
      |               ^
a.cc:11:29: error: 'T' was not declared in this scope
   11 |         for (int i = 0; i < T.length(); i++)
      |                             ^
a.cc:13:25: error: invalid types 'int[int]' for array subscript
   13 |                 else tmp[pos + i] = T[i];
      |                         ^
a.cc:14:33: error: request for member 'length' in 'tmp', which is of non-class type 'int'
   14 |         for (int i = 0; i < tmp.length(); i++)
      |                                 ^~~~~~
a.cc:15:24: error: invalid types 'int[int]' for array subscript
   15 |                 if (tmp[i] == '?') tmp[i] = 'a';
      |                        ^
a.cc:15:39: error: invalid types 'int[int]' for array subscript
   15 |                 if (tmp[i] == '?') tmp[i] = 'a';
      |                                       ^
a.cc: In function 'int main()':
a.cc:21:9: error: 'cin' was not declared in this scope
   21 |         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:21:16: error: 'S' was not declared in this scope
   21 |         cin >> S >> T;
      |                ^
a.cc:21:21: error: 'T' was not declared in this scope
   21 |         cin >> S >> T;
      |                     ^
a.cc:22:9: error: 'string' was not declared in this scope
   22 |         string tmp;
      |         ^~~~~~
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:24:32: error: 'tmp' was not declared in this scope
   24 |                 if (Restore(i, tmp))
      |                                ^~~
a.cc:25:29: error: 'res' was not declared in this scope
   25 |                         if (res == "" || tmp < res) res = tmp;
      |                             ^~~
a.cc:26:13: error: 'res' was not declared in this scope
   26 |         if (res == "") printf("UNRESTORABLE\n");
      |             ^~~
a.cc:26:24: error: 'printf' was not declared in this scope
   26 |         if (res == "") printf("UNRESTORABLE\n");
      |                        ^~~~~~
a.cc:1:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
  +++ |+#include <cstdio>
    1 | using namespace std;
a.cc:27:14: error: 'printf' was not declared in this scope
   27 |         else printf("%s\n", res.c_str());
      |              ^~~~~~
a.cc:27:14: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'