Language: C++

#include<bits/stdc++.h>

using namespace std;
typedef long long int lld;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define trav(a,v) for(auto a:v)

int calc(string a, string b){
  //cout<<a<<" "<<b<<endl;
  rep(i,0,(int)a.size()+1){
    bool B=true;
    for(int j=0;j<(int)b.size() && i+j<(int)a.size();j++){
      if(!(b[j]==a[i+j] || b[j]=='?' || a[i+j]=='?')){
	B=false;
      }
    }
    if(B){
      //cout<<i<<endl;
      return i;
    }
  }
  return a.size();
}
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string a[3];
  cin>>a[0]>>a[1]>>a[2];
  if(a[0].size()<a[1].size())swap(a[0],a[1]);
  if(a[1].size()<a[2].size())swap(a[1],a[2]);
  if(a[0].size()<a[1].size())swap(a[0],a[1]);
  lld dist[3][3];
  bool cmp[3][3];
  rep(i,0,3){
    rep(j,0,3){
      dist[i][j]=calc(a[i],a[j]);
      cmp[i][j]=false;
      if(dist[i][j]+a[j].size()<=a[i].size())cmp[i][j]=true;
    }
  }
  if(cmp[0][2] || cmp[1][2]){
    if(cmp[0][1]){
      cout<<a[0].size()<<endl;
      return 0;
    }
    //cout<<"A"<<" "<<dist[0][1]<<" "<<dist[1][0]<<endl;
    cout<<min(dist[0][1]+a[1].size(),dist[1][0]+a[0].size())<<endl;
    return 0;
  }
  int per[3];
  rep(i,0,3)per[i]=i;
  lld ans=1000000000;
  do{
    ans=min(ans,(lld)dist[per[0]][per[1]]+dist[per[1]][per[2]]+a[per[2]].size());
  }while(next_permutation(per,per+3));
  cout<<ans<<endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:54:12: error: no matching function for call to 'min(lld&, long long unsigned int)'
   54 |     ans=min(ans,(lld)dist[per[0]][per[1]]+dist[per[1]][per[2]]+a[per[2]].size());
      |         ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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:54:12: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'long long unsigned int')
   54 |     ans=min(ans,(lld)dist[per[0]][per[1]]+dist[per[1]][per[2]]+a[per[2]].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
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:54:12: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   54 |     ans=min(ans,(lld)dist[per[0]][per[1]]+dist[per[1]][per[2]]+a[per[2]].size());
      |         ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~