B - Four Hidden
Source: atcoder
Difficulty: 250

Problem Statement
You are given a string
T
consisting of lowercase English letters and
?
, and a string
U
consisting of lowercase English letters.
The string
T
is obtained by taking some lowercase-only string
S
and replacing exactly four of its characters with
?
.
Determine whether it is possible that the original string
S
contained
U
as a contiguous substring.
Constraints
T
is a string of length between
4
and
10
, inclusive, consisting of lowercase letters and
?
.
T
contains exactly four occurrences of
?
.
U
is a string of length between
1
and
|T|
, inclusive, consisting of lowercase letters.
Input
The input is given from Standard Input in the following format:
T
U
Output
Print
Yes
if it is possible that the original string
S
contained
U
as a contiguous substring; otherwise, print
No
.
Sample Input 1
tak??a?h?
nashi
Sample Output 1
Yes
For example, if
S
is
takanashi
, it contains
nashi
as a contiguous substring.
Sample Input 2
??e??e
snuke
Sample Output 2
No
No matter what characters replace the
?
s in
T
,
S
cannot contain
snuke
as a contiguous substring.
Sample Input 3
????
aoki
Sample Output 3
Yes

C++ solution:
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define fast ios_base::sync_with_stdio(false);cin.tie(0);

signed main(){
  fast;
  string t,u;
  cin >> t >> u;
  int j =0;
  bool ok = false;
  for(int i=0,k=0;i<t.size();i++){
    k = i;
    while(k < t.size() && j < u.size() && (t[k] == '?' || t[k] == u[j])){
      j++;
      k++;
    }
    if(j == u.size()){
      ok = true;
      break;
    }
    j = 0;
  }
  cout << (ok ? "Yes" : "No");
}

Go solution:
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

const (
	inf = 1 << 60
	MOD = 998244353
)

func main() {
	/*** INIT ***/
	defer wt.Flush()
	sc.Buffer([]byte{}, inf)
	sc.Split(bufio.ScanWords)

	t, u := InputString(), InputString()
	flag := false
	for i := 0; i+len(u) <= len(t); i++ {
		s := t[i : i+len(u)]
		tflag := true
		for j := 0; j < len(s); j++ {
			if s[j] != '?' && s[j] != u[j] {
				tflag = false
				break
			}
		}
		if tflag == true {
			flag = true
			break
		}
	}

	if flag {
		fmt.Fprintln(wt, "Yes")
	} else {
		fmt.Fprintln(wt, "No")
	}
}

/*** I/O ***/
func InputInt() int {
	sc.Scan()
	val, _ := strconv.Atoi(sc.Text())
	return val
}

func InputString() string {
	sc.Scan()
	return sc.Text()
}

func OutInt(val int) {
	fmt.Fprintln(wt, val)
}

func OutString(s string) {
	fmt.Fprintln(wt, s)
}

Java solution:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.StringTokenizer;

public class Main {
    static QuickReader fs = new QuickReader();
    static PrintWriter out = new PrintWriter(System.out);

    static void output() {
        char[] a = fs.next().toCharArray(),b = fs.next().toCharArray();
        int n = a.length,m = b.length;
        boolean flag = false;
        outer:for(int i=0;i<n-m+1;i++){
            for(int j=0;j<m;j++){
                if(a[i+j] == b[j] || a[i+j] == '?')continue;
                continue outer;
            }
            flag = true;
            break;
        }
        out.println(flag ? "Yes" : "No");
    }

    public static void main(String[] args) {
        int T = 1;
        //T = fs.nextInt();
        for (int tt = 0; tt < T; tt++) {
            output();
            out.flush();
        }
    }

    static void printArray(int[] a) {
        for (int i : a) out.print(i + " ");
        out.println();
    }

    static void printlnArray(int[] a) {
        for (int i : a) out.println(i);
    }

    static void printMatrix(int[][] a) {
        for (int[] i : a)
            printArray(i);
    }

    static void sortA(int[] a) {
        ArrayList<Integer> l = new ArrayList<>();
        for (int i : a) l.add(i);
        Collections.sort(l);
        for (int i = 0; i < a.length; i++) a[i] = l.get(i);
    }

    static void sortD(int[] a) {
        ArrayList<Integer> l = new ArrayList<>();
        for (int i : a) l.add(i);
        Collections.sort(l, (i, j) -> j - i);
        for (int i = 0; i < a.length; i++) a[i] = l.get(i);
    }

    static class QuickReader {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

        String next() {
            while (!st.hasMoreTokens())
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        int[] readIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) a[i] = nextInt();
            return a;
        }

        long[] readLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++) a[i] = nextLong();
            return a;
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}

JavaScript solution:
function Main(input) {
  const data = input.split("\n");
  const t = data[0];
  const u = data[1];
  let ans = 'No';

  for (let i = 0; i < t.length; i++) {
    const s = t.slice(i, i + u.length);
    if (s.length < u.length) break;

    let ok = false;
    for (let j = 0; j < s.length; j++) {
      const ss = s[j];

      if (ss === '?' || ss === u[j]) {
        ok = true;
      }
      else {
        ok = false;
        break;
      }
    }

    if (ok) {
      ans = 'Yes'
      break;
    }
  }

  console.log(`${ans}`);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());

Python solution:
T = list(input())
U = list(input())

ans = False
for i in range(len(T) - len(U) + 1):
    index = 0
    while index < len(U):
        if U[index] == T[i + index] or T[i + index] == "?":
            index += 1
        else:
            break
    
    if index == len(U):
        ans = True
        break

if ans:
    print("Yes")
else:
    print("No")

Ruby solution:
T = gets.chomp
U = gets.chomp
list = []
l = 0
r = U.size-1

while r < T.size
  str = T[l..r]
  list << str
  l += 1
  r += 1
end
# puts list.inspect
list.each do |arr|
  # puts arr
  calc = 0
  (0...U.size).each do |i|
    calc +=1 if arr[i] != "?" && arr[i] != U[i]
  end
  if calc == 0
    puts "Yes"
    exit
  end
end

puts "No"