Language: C++

#include <bits/stdc++.h>
using namespace std;
 
bool match(string a, string b, int c, int d)
{
for (int i=c; i<c+d; i++)
{
if (a[i]==b[i - c] || a[i]=='?') continue;
else return false;
}
return true;
}

int main()
{
string s, t;
set<string> kouho;
cin >> s >> t;
for (int i=0; i<s.size() - t.size(); i++)
{
if (match(s, t, i, t.size()))
{
string temp = s;
for(int j=i; j<i+t.size(); j++) temp[j] = t[j - i];
kouho.insert(temp);
}
}

if(kouho.empty())
{
cout << "UNRESTORABLE" << endl;
return 0;
}
else
{
for (int i = 0; i < kouho.size(); i++)
{
replace(kouho[i],begin(), kouho[i].end(), '?', 'a');
}
}
cout << kouho[0] << endl;
return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:38:14: error: no match for 'operator[]' (operand types are 'std::set<std::__cxx11::basic_string<char> >' and 'int')
   38 | replace(kouho[i],begin(), kouho[i].end(), '?', 'a');
      |              ^
a.cc:38:23: error: no matching function for call to 'begin()'
   38 | replace(kouho[i],begin(), kouho[i].end(), '?', 'a');
      |                  ~~~~~^~
In file included from /usr/include/c++/14/bits/algorithmfwd.h:39,
                 from /usr/include/c++/14/bits/stl_algo.h:59,
                 from /usr/include/c++/14/algorithm:61,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/initializer_list:88:5: note: candidate: 'template<class _Tp> constexpr const _Tp* std::begin(initializer_list<_Tp>)'
   88 |     begin(initializer_list<_Tp> __ils) noexcept
      |     ^~~~~
/usr/include/c++/14/initializer_list:88:5: note:   candidate expects 1 argument, 0 provided
In file included from /usr/include/c++/14/string:53,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52:
/usr/include/c++/14/bits/range_access.h:52:5: note: candidate: 'template<class _Container> constexpr decltype (__cont.begin()) std::begin(_Container&)'
   52 |     begin(_Container& __cont) -> decltype(__cont.begin())
      |     ^~~~~
/usr/include/c++/14/bits/range_access.h:52:5: note:   candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/range_access.h:63:5: note: candidate: 'template<class _Container> constexpr decltype (__cont.begin()) std::begin(const _Container&)'
   63 |     begin(const _Container& __cont) -> decltype(__cont.begin())
      |     ^~~~~
/usr/include/c++/14/bits/range_access.h:63:5: note:   candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/range_access.h:95:5: note: candidate: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::begin(_Tp (&)[_Nm])'
   95 |     begin(_Tp (&__arr)[_Nm]) noexcept
      |     ^~~~~
/usr/include/c++/14/bits/range_access.h:95:5: note:   candidate expects 1 argument, 0 provided
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:166:
/usr/include/c++/14/valarray:1227:5: note: candidate: 'template<class _Tp> _Tp* std::begin(valarray<_Tp>&)'
 1227 |     begin(valarray<_Tp>& __va) noexcept
      |     ^~~~~
/usr/include/c++/14/valarray:1227:5: note:   candidate expects 1 argument, 0 provided
/usr/include/c++/14/valarray:1238:5: note: candidate: 'template<class _Tp> const _Tp* std::begin(const valarray<_Tp>&)'
 1238 |     begin(const valarray<_Tp>& __va) noexcept
      |     ^~~~~
/usr/include/c++/14/valarray:1238:5: note:   candidate expects 1 argument, 0 provided
a.cc:38:32: error: no match for 'operator[]' (operand types are 'std::set<std::__cxx11::basic_string<char> >' and 'int')
   38 | replace(kouho[i],begin(), kouho[i].end(), '?', 'a');
      |                                ^
a.cc:41:14: error: no match for 'operator[]' (operand types are 'std::set<std::__cxx11::basic_string<char> >' and 'int')
   41 | cout << kouho[0] << endl;
      |              ^