Language: C++

#include <stack>
#include <vector>
#include <string>
#include <set>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int MOD = 1000000007;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

int main(){
    string s; cin >> s;
    string t; cin >> t;
    int ns = s.size();
    int nt = t.size();
    if (nt > ns){
        cout << "UNRESTORABLE" << endl;
        return 0;
    }
    bool at = true;
    for (int i = ns - nt; i >= 0; i--){
        at = true;
        string ss = s.substr(i,nt);
        rep(j,nt){
            if (ss[j] != '?' && ss[j] != t[j]){
                at = false;
                break;
            }
        }
        if (at){
            rep(j,nt){
                s[i+j] = t[j];
            }
            break;
        }
    }
    if (at){
        rep(i,ns){
            if (s[i] == '?') s[i] = 'a';
        }
        cout << s << endl;
    }
    else cout << "UNRESTORABLE" << endl;
}

Compiler output:
a.cc: In function 'void printvec(std::vector<_RealType>&)':
a.cc:19:24: error: 'cout' was not declared in this scope
   19 |     rep(i,ar.size()-1) cout << ar[i] << " ";
      |                        ^~~~
a.cc:6:1: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    5 | #include <random>
  +++ |+#include <iostream>
    6 | #define rep(i,n) for (int i = 0; i < (n); ++i)
a.cc:20:5: error: 'cout' was not declared in this scope
   20 |     cout << ar[ar.size()-1] << endl;
      |     ^~~~
a.cc:20:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:20:32: error: 'endl' was not declared in this scope
   20 |     cout << ar[ar.size()-1] << endl;
      |                                ^~~~
a.cc:6:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
    5 | #include <random>
  +++ |+#include <ostream>
    6 | #define rep(i,n) for (int i = 0; i < (n); ++i)
a.cc: In function 'void printvvec(std::vector<std::vector<_RealType> >&)':
a.cc:25:31: error: 'cout' was not declared in this scope
   25 |         rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
      |                               ^~~~
a.cc:25:31: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:26:9: error: 'cout' was not declared in this scope
   26 |         cout << ar[i][ar[0].size()-1] << endl;
      |         ^~~~
a.cc:26:9: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:26:42: error: 'endl' was not declared in this scope
   26 |         cout << ar[i][ar[0].size()-1] << endl;
      |                                          ^~~~
a.cc:26:42: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
a.cc: In function 'int main()':
a.cc:35:15: error: 'cin' was not declared in this scope
   35 |     string s; cin >> s;
      |               ^~~
a.cc:35:15: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:40:9: error: 'cout' was not declared in this scope
   40 |         cout << "UNRESTORABLE" << endl;
      |         ^~~~
a.cc:40:9: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:40:35: error: 'endl' was not declared in this scope
   40 |         cout << "UNRESTORABLE" << endl;
      |                                   ^~~~
a.cc:40:35: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
a.cc:64:9: error: 'cout' was not declared in this scope
   64 |         cout << s << endl;
      |         ^~~~
a.cc:64:9: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:64:22: error: 'endl' was not declared in this scope
   64 |         cout << s << endl;
      |                      ^~~~
a.cc:64:22: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
a.cc:66:10: error: 'cout' was not declared in this scope
   66 |     else cout << "UNRESTORABLE" << endl;
      |          ^~~~
a.cc:66:10: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:66:36: error: 'endl' was not declared in this scope
   66 |     else cout << "UNRESTORABLE" << endl;
      |                                    ^~~~
a.cc:66:36: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'