Problem:
Score : 300 points

Problem Statement

E869120 found a chest which is likely to contain treasure.

However, the chest is locked. In order to open it, he needs to enter a string S consisting of lowercase English letters.

He also found a string S', which turns out to be the string S with some of its letters (possibly all or none) replaced with ?.

One more thing he found is a sheet of paper with the following facts written on it:

Condition 1: The string S contains a string T as a contiguous substring.

Condition 2: S is the lexicographically smallest string among the ones that satisfy Condition 1.

Print the string S.

If such a string does not exist, print UNRESTORABLE.

Constraints

1 \leq |S'|, |T| \leq 50

S' consists of lowercase English letters and ?.

T consists of lowercase English letters.

Input

Input is given from Standard Input in the following format:

S
T'

Output

Print the string S.

If such a string does not exist, print UNRESTORABLE instead.

Sample Input 1

?tc????
coder

Sample Output 1

atcoder

There are 26 strings that satisfy Condition 1: atcoder, btcoder, ctcoder,..., ztcoder.
Among them, the lexicographically smallest is atcoder, so we can say S = atcoder.

Sample Input 2

??p??d??
abc

Sample Output 2

UNRESTORABLE

There is no string that satisfies Condition 1, so the string S does not exist.

Solution in C++14 (GCC 5.4.1) (judge verdict: Wrong Answer)

#include <bits/stdc++.h>
using namespace std;

int main() {
	vector <int >vec;
	string str,str2;
	cin>>str>>str2;
	int i,j,count=0,k,count1=0,sw=0;
	
	for(i=1;i<str.size()-1;i++)
	   {
	   	  if(str[i]!='?')
	   	    vec.push_back(i);
	   }
	
	for(i=str.size()-1;i>=0;i--)
	  {
	  	for(j=0;j<str2.size();j++)
	  	   {	
	  	   	   if(str[i]==str2[j])
	  	   	       {  count=0;
	  	   	          count1=0;
	  	   	          //cout<<i<<" "<<j<<" ";
	  	   	       	   for(k=i-1;k>=0;k--)
	  	   	       	      {
	  	   	       	      	  if(str[k]=='?')
	  	   	       	      		++count;
	  	   	       	      	  else
	  	   	       	      	     break;
	  	   	       	      }
	  	   	       	   for(k=i+1;k<str.size();k++)
	  	   	       	      {
	  	   	       	      	if(str[k]=='?')
	  	   	       	      	  ++count1;
	  	   	       	      	else
	  	   	       	      	   break;
	  	   	       	      }
	  	   	       	      //cout<<count<<" "<<count1<<" "<<str2.size()<<'\n';
	  	   	       }
	  	   	       	      
	  	   	       	   if(count==j && count1==str2.size()-1-j && j>0 && j<str2.size()-1)
	  	   	       	     {	sw=1;
	  	   	       	     	//cout<<'a';
	  	   	       	     	break;
	  	   	       	     	
	  	   	       	     }
	  	   	       	     
	  	   	       	    if(j==0 && count1==str2.size()-1-j)
	  	   	       	      {
	  	   	       	      	sw=1;
	  	   	       	      	//cout<<'b';
	  	   	       	      	break;
	  	   	       	      }
	  	   	       	   if(j==str2.size()-1 && count==j)   
	  	   	       		{
	  	   	       			//cout<<'c';
	  	   	       			sw=1;
	  	   	       	      	            break;
	  	   	       		}
	  	   	       }
	  	   	      if(sw==1)
	  	   	        break;
	  	   
	  	   
	  }
	 //cout<<vec.size();
	 if(sw==0 && vec.size()==0 && str2.size()<=str.size())
	    {
	    	for(k=0;k<str.size()-str2.size();k++)
	    	  cout<<'a';
	    	cout<<str2;  
	    }
	 else if(sw==0)
	   cout<<"UNRESTORABLE"<<'\n';   
	 else
	   { //cout<<i;
	     for(k=0;k<i-j;k++)
	      {	
	      	if(str[k]=='?')
	                 cout<<'a';
	         else  
	      	cout<<str[k];
	      }		
	      cout<<str2;
	    for(k=str2.size()+i-j;k<str.size();k++)
	      {
	      	if(str[k]=='?')
	                  cout<<'a';
	         else  
	      	cout<<str[k];
	      }
	   } 
	// your code goes here
	return 0;
}