Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  string s, t, u, w, x, y;
  ll a, b, c, k;
  k = 999999999;
  in3(s, t, u);
  bool h;
  rep(i, s.size()){
    h = true;
    rep(j, min(t.size(), s.size() - i)){
      if(s[i + j] != t[j] && s[i + j] != '?' && t[j] != '?')
        h = false;
    }
    if(h){
      a = i;
      break;
    }
    else if(i == n - 1)
      a = n;
  }
  w = "";
  x = "";
  if(a + t.size() >= s.size()){
    rep(i, a){
      x = s[i];
      w = w + x;
    }
    rep(i, t.size()){
      x = t[i];
      w = w + x;
    }
  }
  else
    w = s;
  rep(i, w.size()){
    h = true;
    rep(j, min(u.size(), w.size() - i)){
      if(w[i + j] != u[j] && w[i + j] != '?' && u[j] != '?')
        h = false;
    }
    if(h){
      a = i;
      break;
    }
    else if(i == n - 1)
      a = n;
  }
  w = "";
  x = "";
  y = "";
  if(a + u.size() >= w.size()){
    rep(i, a){
      x = w[i];
      y = y + x;
    }
    rep(i, u.size()){
      x = u[i];
      y = y + x;
    }
  }
  else
    y = w;
  k = min(k, y.size());
  rep(i, s.size()){
    h = true;
    rep(j, min(u.size(), s.size() - i)){
      if(s[i + j] != u[j] && s[i + j] != '?' && u[j] != '?')
        h = false;
    }
    if(h){
      a = i;
      break;
    }
    else if(i == n - 1)
      a = n;
  }
  w = "";
  x = "";
  if(a + u.size() >= s.size()){
    rep(i, a){
      x = s[i];
      w = w + x;
    }
    rep(i, u.size()){
      x = u[i];
      w = w + x;
    }
  }
  else
    w = s;
  rep(i, w.size()){
    h = true;
    rep(j, min(t.size(), w.size() - i)){
      if(w[i + j] != t[j] && w[i + j] != '?' && t[j] != '?')
        h = false;
    }
    if(h){
      a = i;
      break;
    }
    else if(i == n - 1)
      a = n;
  }
  w = "";
  x = "";
  y = "";
  if(a + t.size() >= w.size()){
    rep(i, a){
      x = w[i];
      y = y + x;
    }
    rep(i, t.size()){
      x = t[i];
      y = y + x;
    }
  }
  else
    y = w;
  k = min(k, y.size()); // 2
  rep(i, t.size()){
    h = true;
    rep(j, min(s.size(), t.size() - i)){
      if(t[i + j] != s[j] && t[i + j] != '?' && s[j] != '?')
        h = false;
    }
    if(h){
      a = i;
      break;
    }
    else if(i == n - 1)
      a = n;
  }
  w = "";
  x = "";
  if(a + s.size() >= t.size()){
    rep(i, a){
      x = t[i];
      w = w + x;
    }
    rep(i, s.size()){
      x = s[i];
      w = w + x;
    }
  }
  else
    w = t;
  rep(i, w.size()){
    h = true;
    rep(j, min(u.size(), w.size() - i)){
      if(w[i + j] != u[j] && w[i + j] != '?' && u[j] != '?')
        h = false;
    }
    if(h){
      a = i;
      break;
    }
    else if(i == n - 1)
      a = n;
  }
  w = "";
  x = "";
  y = "";
  if(a + u.size() >= w.size()){
    rep(i, a){
      x = w[i];
      y = y + x;
    }
    rep(i, u.size()){
      x = u[i];
      y = y + x;
    }
  }
  else
    y = w;
  k = min(k, y.size()); // 3
  rep(i, u.size()){
    h = true;
    rep(j, min(t.size(), u.size() - i)){
      if(u[i + j] != t[j] && u[i + j] != '?' && t[j] != '?')
        h = false;
    }
    if(h){
      a = i;
      break;
    }
    else if(i == n - 1)
      a = n;
  }
  w = "";
  x = "";
  if(a + t.size() >= u.size()){
    rep(i, a){
      x = u[i];
      w = w + x;
    }
    rep(i, t.size()){
      x = t[i];
      w = w + x;
    }
  }
  else
    w = u;
  rep(i, w.size()){
    h = true;
    rep(j, min(s.size(), w.size() - i)){
      if(w[i + j] != s[j] && w[i + j] != '?' && s[j] != '?')
        h = false;
    }
    if(h){
      a = i;
      break;
    }
    else if(i == n - 1)
      a = n;
  }
  w = "";
  x = "";
  y = "";
  if(a + s.size() >= w.size()){
    rep(i, a){
      x = w[i];
      y = y + x;
    }
    rep(i, s.size()){
      x = s[i];
      y = y + x;
    }
  }
  else
    y = w;
  k = min(k, y.size()); // 4
  rep(i, t.size()){
    h = true;
    rep(j, min(u.size(), t.size() - i)){
      if(t[i + j] != u[j] && t[i + j] != '?' && u[j] != '?')
        h = false;
    }
    if(h){
      a = i;
      break;
    }
    else if(i == n - 1)
      a = n;
  }
  w = "";
  x = "";
  if(a + u.size() >= t.size()){
    rep(i, a){
      x = t[i];
      w = w + x;
    }
    rep(i, u.size()){
      x = u[i];
      w = w + x;
    }
  }
  else
    w = t;
  rep(i, w.size()){
    h = true;
    rep(j, min(s.size(), w.size() - i)){
      if(w[i + j] != s[j] && w[i + j] != '?' && s[j] != '?')
        h = false;
    }
    if(h){
      a = i;
      break;
    }
    else if(i == n - 1)
      a = n;
  }
  w = "";
  x = "";
  y = "";
  if(a + s.size() >= w.size()){
    rep(i, a){
      x = w[i];
      y = y + x;
    }
    rep(i, s.size()){
      x = s[i];
      y = y + x;
    }
  }
  else
    y = w;
  k = min(k, y.size()); // 5
  rep(i, u.size()){
    h = true;
    rep(j, min(s.size(), u.size() - i)){
      if(u[i + j] != s[j] && u[i + j] != '?' && s[j] != '?')
        h = false;
    }
    if(h){
      a = i;
      break;
    }
    else if(i == n - 1)
      a = n;
  }
  w = "";
  x = "";
  if(a + s.size() >= u.size()){
    rep(i, a){
      x = u[i];
      w = w + x;
    }
    rep(i, s.size()){
      x = s[i];
      w = w + x;
    }
  }
  else
    w = u;
  rep(i, w.size()){
    h = true;
    rep(j, min(t.size(), w.size() - i)){
      if(w[i + j] != t[j] && w[i + j] != '?' && t[j] != '?')
        h = false;
    }
    if(h){
      a = i;
      break;
    }
    else if(i == n - 1)
      a = n;
  }
  w = "";
  x = "";
  y = "";
  if(a + t.size() >= w.size()){
    rep(i, a){
      x = w[i];
      y = y + x;
    }
    rep(i, t.size()){
      x = t[i];
      y = y + x;
    }
  }
  else
    y = w;
  k = min(k, y.size());
  out(k);
  memi;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:25:15: error: no matching function for call to 'min(std::__cxx11::basic_string<char>::size_type, long long unsigned int)'
   25 |     rep(j, min(t.size(), s.size() - i)){
      |            ~~~^~~~~~~~~~~~~~~~~~~~~~~~
a.cc:4:42: note: in definition of macro 'rep'
    4 | #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:25:15: note:   deduced conflicting types for parameter 'const _Tp' ('long unsigned int' and 'long long unsigned int')
   25 |     rep(j, min(t.size(), s.size() - i)){
      |            ~~~^~~~~~~~~~~~~~~~~~~~~~~~
a.cc:4:42: note: in definition of macro 'rep'
    4 | #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:25:15: note:   mismatched types 'std::initializer_list<_Tp>' and 'long unsigned int'
   25 |     rep(j, min(t.size(), s.size() - i)){
      |            ~~~^~~~~~~~~~~~~~~~~~~~~~~~
a.cc:4:42: note: in definition of macro 'rep'
    4 | #define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
      |                                          ^
a.cc:33:18: error: 'n' was not declared in this scope
   33 |     else if(i == n - 1)
      |                  ^
a.cc:52:15: error: no matching function for call to 'min(std::__cxx11::basic_string<char>::size_type, long long unsigned int)'
   52 |     rep(j, min(u.size(), w.size() - i)){
      |            ~~~^~~~~~~~~~~~~~~~~~~~~~~~
a.cc:4:42: note: in definition of macro 'rep'
    4 | #define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
      |                                          ^
/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:52:15: note:   deduced conflicting types for parameter 'const _Tp' ('long unsigned int' and 'long long unsigned int')
   52 |     rep(j, min(u.size(), w.size() - i)){
      |            ~~~^~~~~~~~~~~~~~~~~~~~~~~~
a.cc:4:42: note: in definition of macro 'rep'
    4 | #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
/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:52:15: note:   mismatched types 'std::initializer_list<_Tp>' and 'long unsigned int'
   52 |     rep(j, min(u.size(), w.size() - i)){
      |            ~~~^~~~~~~~~~~~~~~~~~~~~~~~
a.cc:4:42: note: in definition of macro 'rep'
    4 | #define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
      |                                          ^
a.cc:60:18: error: 'n' was not declared in this scope
   60 |     else if(i == n - 1)
      |                  ^
a.cc:78:10: error: no matching function for call to 'min(ll&, std::__cxx11::basic_string<char>::size_type)'
   78 |   k = min(k, y.size());
      |       ~~~^~~~~~~~~~~~~
/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:78:10: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'})
   78 |   k = min(k, y.size());
      |       ~~~^~~~~~~~~~~~~
/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
/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:78:10: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   78 |   k = min(k, y.size());
      |       ~~~^~~~~~~~~~~~~
a.cc:81:15: error: no matching function for call to 'min(std::__cxx11::basic_string<char>::size_type, long long unsigned int)'
   81 |     rep(j, min(u.size(), s.size() - i)){
      |            ~~~^~~~~~~~~~~~~~~~~~~~~~~~
a.cc:4:42: note: in definition of macro 'rep'
    4 | #define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
      |                                          ^
/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:81:15: note:   deduced conflicting types for parameter 'const _Tp' ('long unsigned int' and 'long long unsigned int')
   81 |     rep(j, min(u.size(), s.size() - i)){
      |            ~~~^~~~~~~~~~~~~~~~~~~~~~~~
a.cc:4:42: note: in definition of macro 'rep'
    4 | #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
/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:81:15: note:   mismatched types 'std::initializer_list<_Tp>' and 'long unsigned int'
   81 |     rep(j, min(u.size(), s.size() - i)){
      |            ~~~^~~~~~~~~~~~~~~~~~~~~~~~
a.cc:4:42: note: in definition of macro 'rep'
    4 | #define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
      |                                          ^
a.cc:89:18: error: 'n' was not declared in this scope
   89 |     else if(i == n - 1)
      |                  ^
a.cc:108:15: error: no matching function for call to 'min(std::__cxx11::basic_string<char>::size_type, long long unsigned int)'
  108 |     rep(j, min(t.size(), w.size() - i)){
      |            ~~~^~~~~~~~~~~~~~~~~~~~~~~~
a.cc:4:42: note: in definition of macro 'rep'
    4 | #define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
      |                                          ^
/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:108:15: note:   deduced conflicting types for parameter 'const _Tp' ('l