Language: C++

#include "bits/stdc++.h"
#include <random>
#define REP(i, n) for (ll i = 0; i < ll(n); ++i)
#define RREP(i, n) for (ll i = ll(n) - 1; i >= 0; --i)
#define FOR(i, m, n) for (ll i = m; i < ll(n); ++i)
#define RFOR(i, m, n) for (ll i = ll(n) - 1; i >= ll(m); --i)
#define ALL(v) (v).begin(), (v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

constexpr int dx[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };
constexpr int dy[8] = { 0, 1, 1, 1, 0, -1, -1, -1 };

using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template <class T> bool chmin(T& a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<string> s(3);
  REP(i, 3)cin >> s[i];
  vi p = { 0,1,2 };
  auto f = [&](string a, string b) {
    int m = a.size();
    REP(i, a.size()) {
      bool ok = true;
      REP(j, min(a.size() - i, b.size())) {
        char c = a[i + j], d = b[j];
        if (c != '?' && d != '?' && c != d) {
          ok = false;
          break;
        }
      }
      if (ok) {
        m = i;
        break;
      }
    }
    return m;
  };
  int ans = INF;
  do {
    int m = f(s[p[0]], s[p[1]]);
    string t = s[p[0]];
    FOR(i, s[p[0]].size() - m, s[p[1]].size())t += s[p[1]][i];

    int mm = f(t, s[p[2]]);
    chmin(ans, max(mm + (int)s[p[2]].size(), (int)t.size()));
  } while (next_permutation(ALL(p)));
  cout << ans << endl;
}


Compiler output:
a.cc: In lambda function:
a.cc:51:17: error: no matching function for call to 'min(long long unsigned int, std::__cxx11::basic_string<char>::size_type)'
   51 |       REP(j, min(a.size() - i, b.size())) {
      |              ~~~^~~~~~~~~~~~~~~~~~~~~~~~
a.cc:3:41: note: in definition of macro 'REP'
    3 | #define REP(i, n) for (ll i = 0; i < ll(n); ++i)
      |                                         ^
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:51:17: note:   deduced conflicting types for parameter 'const _Tp' ('long long unsigned int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'})
   51 |       REP(j, min(a.size() - i, b.size())) {
      |              ~~~^~~~~~~~~~~~~~~~~~~~~~~~
a.cc:3:41: note: in definition of macro 'REP'
    3 | #define REP(i, n) for (ll i = 0; i < ll(n); ++i)
      |                                         ^
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:51:17: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long unsigned int'
   51 |       REP(j, min(a.size() - i, b.size())) {
      |              ~~~^~~~~~~~~~~~~~~~~~~~~~~~
a.cc:3:41: note: in definition of macro 'REP'
    3 | #define REP(i, n) for (ll i = 0; i < ll(n); ++i)
      |                                         ^