Language: C++

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

typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector <ll> vi;
typedef vector <pi> vpi;
#define f first
#define s second
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0)
#define INF 1e9
#define int ll
string A[4];


int mn[5][5];

int32_t main(){
	fast;
	
	FOR(i,0,2) cin>>A[i];
	
	
	FOR(i,0,2){
		FOR(j,0,2){
			if (i == j) continue;
			mn[i][j] = 0;
			FOR(k,1,min(A[i].size(),A[j].size())){
				string s1 = A[i].substr(A[i].size() - k,k);
				string s2 = A[j].substr(0,k);
				
				//reverse(all(s2));
				
				bool yes = 1;
				FOR(a,0,k-1){
					if (s1[a] == '?' || s2[a] == '?') continue;
					if (s1[a] != s2[a]) yes = 0;
				}
				
				if (yes) mn[i][j] = k;
			}
			
			//cout<<i<<' '<<j<<' '<<mn[i][j]<<'\n';
			
		}
	}
	
	int sm = A[0].size() + A[1].size() + A[2].size();
	
	vi p = {0,1,2};
	
	ll ans = INF;
	
	if (mn[p[0]][p[1]] != A[p[1]].size() && mn[p[1]][p[2]] != A[p[1]].size()) ans = min(ans,sm - mn[p[0]][p[1]] - mn[p[1]][p[2]]);
	else if (mn[p[0]][p[1]] == A[p[1]].size() && mn[p[1]][p[2]] == A[p[2]].size()) ans = min(ans,A[p[0]].size());
	else ans = min(ans,(ll)sm - mn[p[0]][p[2]] - (ll)A[p[1]].size());
	
	
	while (next_permutation(all(p))){
		if (mn[p[0]][p[1]] != A[p[1]].size() && mn[p[1]][p[2]] != A[p[1]].size()) ans = min(ans,sm - mn[p[0]][p[1]] - mn[p[1]][p[2]]);
		else if (mn[p[0]][p[1]] == A[p[1]].size() && mn[p[1]][p[2]] == A[p[2]].size()) ans = min(ans,A[p[0]].size());
		else ans = min(ans,(ll)sm - mn[p[0]][p[2]] - (ll)A[p[1]].size());
	}
	
	cout<<ans;
				
				
	
}



Compiler output:
a.cc: In function 'int32_t main()':
a.cc:63:97: error: no matching function for call to 'min(ll&, std::__cxx11::basic_string<char>::size_type)'
   63 |         else if (mn[p[0]][p[1]] == A[p[1]].size() && mn[p[1]][p[2]] == A[p[2]].size()) ans = min(ans,A[p[0]].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:63:97: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'})
   63 |         else if (mn[p[0]][p[1]] == A[p[1]].size() && mn[p[1]][p[2]] == A[p[2]].size()) ans = min(ans,A[p[0]].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:63:97: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   63 |         else if (mn[p[0]][p[1]] == A[p[1]].size() && mn[p[1]][p[2]] == A[p[2]].size()) ans = min(ans,A[p[0]].size());
      |                                                                                              ~~~^~~~~~~~~~~~~~~~~~~~
a.cc:69:105: error: no matching function for call to 'min(ll&, std::__cxx11::basic_string<char>::size_type)'
   69 |                 else if (mn[p[0]][p[1]] == A[p[1]].size() && mn[p[1]][p[2]] == A[p[2]].size()) ans = min(ans,A[p[0]].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:69:105: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'})
   69 |                 else if (mn[p[0]][p[1]] == A[p[1]].size() && mn[p[1]][p[2]] == A[p[2]].size()) ans = min(ans,A[p[0]].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:69:105: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   69 |                 else if (mn[p[0]][p[1]] == A[p[1]].size() && mn[p[1]][p[2]] == A[p[2]].size()) ans = min(ans,A[p[0]].size());
      |                                                                                                      ~~~^~~~~~~~~~~~~~~~~~~~