Language: C++

#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)

vector<string> func(string a, string b) {
	vector<string> ret;
	ret.push_back(a + b);
	ret.push_back(b + a);
	rep(i, 0, a.size()) {
		if (a[i] == b[0] || a[i] == '?' || b[0] == '?') {
			bool flg = true;
			string tmp = a.substr(0, i);
			rep(j, 0, min(b.size(), a.size() - i)) {
				if (a[i + j] == b[j] || b[j] == '?') {
					tmp += a[i + j];
				}
				else if (a[i + j] == '?') {
					tmp += b[j];
				}
				else {
					flg = false;
					break;
				}
			}
			if (b.size() < a.size() - i) {
				tmp += a.substr(b.size(), a.size() - i - b.size());
			}
			else if (a.size() - i < b.size()) {
				tmp += b.substr(a.size() - i, b.size() + i - a.size());
			}
			if (flg) {
				ret.push_back(tmp);
			}
		}
	}
	swap(a, b);
	rep(i, 1, a.size()) {
		if (a[i] == b[0] || a[i] == '?' || b[0] == '?') {
			bool flg = true;
			string tmp = a.substr(0, i);
			rep(j, 0, min(b.size(), a.size() - i)) {
				if (a[i + j] == b[j] || b[j] == '?') {
					tmp += a[i + j];
				}
				else if (a[i + j] == '?') {
					tmp += b[j];
				}
				else {
					flg = false;
					break;
				}
			}
			if (b.size() < a.size() - i) {
				tmp += a.substr(b.size(), a.size() - i - b.size());
			}
			else if (a.size() - i < b.size()) {
				tmp += b.substr(a.size() - i, b.size() + i - a.size());
			}
			if (flg) {
				ret.push_back(tmp);
			}
		}
	}
	return ret;
}

int main() {
	string a, b, c;
	std::cin >> a >> b >> c;
	ll ans = a.size() + b.size() + c.size();
	vector<string> comb_1, comb_2;
	comb_1 = func(a, b);
	rep(i, 0, comb_1.size()) {
		comb_2 = func(comb_1[i], c);
		rep(j, 0, comb_2.size()) {
			ans = min(ans, (ll)comb_2[j].size());
		}
	}
	comb_1 = func(a, c);
	rep(i, 0, comb_1.size()) {
		comb_2 = func(comb_1[i], b);
		rep(j, 0, comb_2.size()) {
			ans = min(ans, (ll)comb_2[j].size());
		}
	}
	comb_1 = func(b, c);
	rep(i, 0, comb_1.size()) {
		comb_2 = func(comb_1[i], a);
		rep(j, 0, comb_2.size()) {
			ans = min(ans, (ll)comb_2[j].size());
		}
	}

	std::cout << ans << endl;
	return 0;

}


Compiler output:
a.cc: In function 'std::vector<std::__cxx11::basic_string<char> > func(std::string, std::string)':
a.cc:81:38: error: no matching function for call to 'min(std::__cxx11::basic_string<char>::size_type, long long unsigned int)'
   81 |                         rep(j, 0, min(b.size(), a.size() - i)) {
      |                                   ~~~^~~~~~~~~~~~~~~~~~~~~~~~
a.cc:70:33: note: in definition of macro 'rep'
   70 | #define rep(i,s,e) for(ll i=s;i<e;i++)
      |                                 ^
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 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:81:38: note:   deduced conflicting types for parameter 'const _Tp' ('long unsigned int' and 'long long unsigned int')
   81 |                         rep(j, 0, min(b.size(), a.size() - i)) {
      |                                   ~~~^~~~~~~~~~~~~~~~~~~~~~~~
a.cc:70:33: note: in definition of macro 'rep'
   70 | #define rep(i,s,e) for(ll i=s;i<e;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,
                 from a.cc:5:
/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:38: note:   mismatched types 'std::initializer_list<_Tp>' and 'long unsigned int'
   81 |                         rep(j, 0, min(b.size(), a.size() - i)) {
      |                                   ~~~^~~~~~~~~~~~~~~~~~~~~~~~
a.cc:70:33: note: in definition of macro 'rep'
   70 | #define rep(i,s,e) for(ll i=s;i<e;i++)
      |                                 ^
a.cc:109:38: error: no matching function for call to 'min(std::__cxx11::basic_string<char>::size_type, long long unsigned int)'
  109 |                         rep(j, 0, min(b.size(), a.size() - i)) {
      |                                   ~~~^~~~~~~~~~~~~~~~~~~~~~~~
a.cc:70:33: note: in definition of macro 'rep'
   70 | #define rep(i,s,e) for(ll i=s;i<e;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:109:38: note:   deduced conflicting types for parameter 'const _Tp' ('long unsigned int' and 'long long unsigned int')
  109 |                         rep(j, 0, min(b.size(), a.size() - i)) {
      |                                   ~~~^~~~~~~~~~~~~~~~~~~~~~~~
a.cc:70:33: note: in definition of macro 'rep'
   70 | #define rep(i,s,e) for(ll i=s;i<e;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:109:38: note:   mismatched types 'std::initializer_list<_Tp>' and 'long unsigned int'
  109 |                         rep(j, 0, min(b.size(), a.size() - i)) {
      |                                   ~~~^~~~~~~~~~~~~~~~~~~~~~~~
a.cc:70:33: note: in definition of macro 'rep'
   70 | #define rep(i,s,e) for(ll i=s;i<e;i++)
      |                                 ^