Language: C++

#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <string>
#include <string.h>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
int GCD(int a, int b) {
	return b ? GCD(b, a%b) : a;
}
//sort(a, a + N, greater<int>())   // descend
//sort(a, a+N)                    //  ascend

using ll = long long;
using namespace std;

int wh = 0;

int main() {
	string s, t;
	cin >> s >> t;
	bool ppx = true;
	int x = s.length() - t.length();
	for (int i =x; i >=0; i--) {
		int p = i;
		int h = 0;
		wh = i;
		ppx = true;
		while (p < i + t.length()) {
			if (s[p] == t[h] || s[p] == '?') {
				p++;
				h++;
			}
			else  {
				ppx = false;
				break;
			}
		}
		if (ppx) break;
	}

	string ans = s;

	for (int i = wh; i < wh + t.length(); i++) {
		if (ans[i] != '?') ans.replace(i, 1, t[i]);
	}

	for (int i = 0; i < s.length(); i++) {
		if (ans[i] == '?') ans[i] = 'a';
	}


	if(ppx) cout << ans;
	else cout<< "UNRESTORABLE";

}


Compiler output:
a.cc: In function 'int main()':
a.cc:53:47: error: no matching function for call to 'std::__cxx11::basic_string<char>::replace(int&, int, __gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type&)'
   53 |                 if (ans[i] != '?') ans.replace(i, 1, t[i]);
      |                                    ~~~~~~~~~~~^~~~~~~~~~~~
In file included from /usr/include/c++/14/string:54,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:2:
/usr/include/c++/14/bits/basic_string.h:2275:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::replace(size_type, size_type, const _CharT*) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]' (near match)
 2275 |       replace(size_type __pos, size_type __n1, const _CharT* __s)
      |       ^~~~~~~
/usr/include/c++/14/bits/basic_string.h:2275:7: note:   conversion of argument 3 would be ill-formed:
/usr/include/c++/14/bits/basic_string.h:2275:7: error: invalid conversion from '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type' {aka 'char'} to 'const char*' [-fpermissive]
 2275 |       replace(size_type __pos, size_type __n1, const _CharT* __s)
      |       ^~~~~~~
      |       |
      |       __gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type {aka char}
/usr/include/c++/14/bits/basic_string.h:2413:9: note: candidate: 'template<class _InputIterator, class> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::replace(const_iterator, const_iterator, _InputIterator, _InputIterator) [with <template-parameter-2-2> = _InputIterator; _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
 2413 |         replace(const_iterator __i1, const_iterator __i2,
      |         ^~~~~~~
/usr/include/c++/14/bits/basic_string.h:2413:9: note:   candidate expects 4 arguments, 3 provided
/usr/include/c++/14/bits/basic_string.h:2522:9: note: candidate: 'template<class _Tp> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_If_sv<_Tp, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::replace(size_type, size_type, const _Tp&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
 2522 |         replace(size_type __pos, size_type __n, const _Tp& __svt)
      |         ^~~~~~~
/usr/include/c++/14/bits/basic_string.h:2522:9: note:   template argument deduction/substitution failed:
In file included from /usr/include/c++/14/bits/stl_pair.h:60,
                 from /usr/include/c++/14/bits/stl_algobase.h:64,
                 from /usr/include/c++/14/algorithm:60,
                 from a.cc:1:
/usr/include/c++/14/type_traits: In substitution of 'template<bool _Cond, class _Tp> using std::enable_if_t = typename std::enable_if::type [with bool _Cond = false; _Tp = std::__cxx11::basic_string<char>&]':
/usr/include/c++/14/bits/basic_string.h:149:8:   required by substitution of 'template<class _CharT, class _Traits, class _Alloc> template<class _Tp, class _Res> using std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_If_sv = std::enable_if_t<((bool)std::__and_<std::is_convertible<const _Tp&, std::basic_string_view<_CharT, _Traits> >, std::__not_<std::is_convertible<const _Tp*, const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>*> >, std::__not_<std::is_convertible<const _Tp&, const _CharT*> > >::value), _Res> [with _Tp = char; _Res = std::__cxx11::basic_string<char>&; _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
  149 |         using _If_sv = enable_if_t<
      |               ^~~~~~
/usr/include/c++/14/bits/basic_string.h:2522:2:   required by substitution of 'template<class _Tp> std::__cxx11::basic_string<char>::_If_sv<_Tp, std::__cxx11::basic_string<char>&> std::__cxx11::basic_string<char>::replace(size_type, size_type, const _Tp&) [with _Tp = char]'
 2522 |         replace(size_type __pos, size_type __n, const _Tp& __svt)
      |         ^~~~~~~
a.cc:53:33:   required from here
   53 |                 if (ans[i] != '?') ans.replace(i, 1, t[i]);
      |                                    ~~~~~~~~~~~^~~~~~~~~~~~
/usr/include/c++/14/type_traits:2711:11: error: no type named 'type' in 'struct std::enable_if<false, std::__cxx11::basic_string<char>&>'
 2711 |     using enable_if_t = typename enable_if<_Cond, _Tp>::type;
      |           ^~~~~~~~~~~
/usr/include/c++/14/bits/basic_string.h:2540:9: note: candidate: 'template<class _Tp> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_If_sv<_Tp, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::replace(size_type, size_type, const _Tp&, size_type, size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
 2540 |         replace(size_type __pos1, size_type __n1, const _Tp& __svt,
      |         ^~~~~~~
/usr/include/c++/14/bits/basic_string.h:2540:9: note:   candidate expects 4 arguments, 3 provided
/usr/include/c++/14/bits/basic_string.h:2562:9: note: candidate: 'template<class _Tp> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_If_sv<_Tp, std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::replace(const_iterator, const_iterator, const _Tp&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
 2562 |         replace(const_iterator __i1, const_iterator __i2, const _Tp& __svt)
      |         ^~~~~~~
/usr/include/c++/14/bits/basic_string.h:2562:9: note:   template argument deduction/substitution failed:
a.cc:53:48: note:   cannot convert 'i' (type 'int') to type 'std::__cxx11::basic_string<char>::const_iterator'
   53 |                 if (ans[i] != '?') ans.replace(i, 1, t[i]);
      |                                                ^
/usr/include/c++/14/bits/basic_string.h:2200:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::replace(size_type, size_type, const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]'
 2200 |       replace(size_type __pos, size_type __n, const basic_string& __str)
      |       ^~~~~~~
/usr/include/c++/14/bits/basic_string.h:2200:67: note:   no known conversion for argument 3 from '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type' {aka 'char'} to 'const std::__cxx11::basic_string<char>&'
 2200 |       replace(size_type __pos, size_type __n, const basic_string& __str)
      |                                               ~~~~~~~~~~~~~~~~~~~~^~~~~
/usr/include/c++/14/bits/basic_string.h:2223:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::replace(size_type, size_type, const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&, size_type, size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]'
 2223 |       replace(size_type __pos1, size_type __n1, const basic_string& __str,
      |       ^~~~~~~
/usr/include/c++/14/bits/basic_string.h:2223:7: note:   candidate expects 5 arguments, 3 provided
/usr/include/c++/14/bits/basic_string.h:2249:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::replace(size_type, size_type, const _CharT*, size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]'
 2249 |       replace(size_type __pos, size_type __n1, const _CharT* __s,
      |       ^~~~~~~
/usr/include/c++/14/bits/basic_string.h:2249:7: note:   candidate expects 4 arguments, 3 provided
/usr/include/c++/14/bits/basic_string.h:2300:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::replace(size_type, size_type, size_type, _CharT) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]'
 2300 |       replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
      |       ^~~~~~~
/usr/include/c++/14/bits/basic_string.h:2300:7: note:   candidate expects 4 arguments, 3 provided
/usr/include/c++/14/bits/basic_string.h:2319:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::replace(__const_iterator, __const_iterator, const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; __const_iterator = std::__cxx11::basic_string<char>::const_iterator]'
 2319 |       replace(__const_iterator __i1, __const_iterator __i2,
      |       ^~~~~~~
/usr/include/c++/14/bits/basic_string.h:2319:32: note:   no known conversion for argument 1 from 'int' to 'std::__cxx11::basic_string<char>::__const_iterator' {aka 'std::__cxx11::basic_string<char>::const_iterator'}
 2319 |       replace(__const_iterator __i1, __const_iterator __i2,
      |               ~~~~~~~~~~~~~~~~~^~~~
/usr/include/c++/14/bits/basic_string.h:2340:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::replace(__const_iterator, __const_iterator, const _CharT*, size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; __const_iterator = std::__cxx11::basic_string<char>::const_iterator; size_type = long unsigned int]'
 2340 |       replace(__const_iterator __i1, __const_iterator __i2,
      |       ^~~~~~~
/usr/include/c++/14/bits/basic_string.h:2340:7: note:   candidate expects 4 ar