Language: C++

#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 998244353;//1e9 + 7;
typedef long long LL;
typedef long double LD;
typedef pair<LL, LL> PLL;
typedef pair<LD, LL> PDL;
typedef pair<LD, LD> PDD;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
//typedef boost::multiprecision::cpp_int bigint;

template<class T>
void in(T& x) {
	cin >> x;
}

template<class T1, class T2>
void in(pair<T1, T2>& p) {
	in(p.first);
	in(p.second);
}

template<class T>
void in(vector<T>& v, LL st = -1, LL en = -1) {
	if (st == -1) {
		st = 0;
		en = v.size() - 1;
	}
	for (LL n = st; n <= en; n++) {
		in(v[n]);
	}
}

LL calc(string& A, string& B, string& C) {
	//AとB
	//A何文字目がB0文字目になる?
	LL sa;
	for (sa = 0; sa < A.size(); sa++) {
		bool flag = true;
		for (LL l = 0; l < min((LL)A.size()-sa, (LL)B.size()); l++) {
			if (A[sa+l] != '?' && B[l] != '?' && A[sa+l] != B[l]) {
				flag = false;
				break;
			}
		}
		if (!flag)continue;
		else break;
	}
	//sa文字目からマッチ可能
	string AA;
	AA.resize(max((LL)A.size(), B.size() + sa));
	for (LL n = 0; n < sa; n++) {
		AA[n] = A[n];
	}
	for (LL n = sa; n < min((LL)A.size()-1,B.size()-1+sa); n++) {
		if (A[n] == '?')AA[n] = B[n];
		else AA[n] = A[n];
	}
	if (A.size() < B.size() + sa) {
		for (LL n = A.size(); n < B.size() + sa; n++) {
			AA[n] = B[n-sa];
		}
	}
	else {
		for (LL n = B.size() + sa; n < A.size(); n++) {
			AA[n] = A[n];
		}
	}
	//sa文字目から
	LL sb = sa;
	for (; sb < AA.size(); sb++) {
		bool flag = true;
		for (LL n = 0; n < min(AA.size() - sb, (LL)C.size()); n++) {
			if (AA[sb + n] != '?' && C[n] != '?' && AA[sb + n] != C[n]) {
				flag = false;
				break;
			}
		}
		if (!flag)continue;
		else break;
	}
	return max((LL)AA.size(), C.size() + sb);
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	string A, B, C;
	cin >> A >> B >> C;
	LL ans = calc(A, B, C);
	ans = min(ans, calc(A,C,B));
	ans = min(ans, calc(B,A,C));
	ans = min(ans, calc(B,C,A));
	ans = min(ans, calc(C,A,B));
	ans = min(ans, calc(C,B,A));
	cout << ans << "\n";
	return 0;
}


Compiler output:
a.cc: In function 'LL calc(std::string&, std::string&, std::string&)':
a.cc:77:22: error: no matching function for call to 'max(LL, long long unsigned int)'
   77 |         AA.resize(max((LL)A.size(), B.size() + sa));
      |                   ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:77:22: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'long long unsigned int')
   77 |         AA.resize(max((LL)A.size(), B.size() + sa));
      |                   ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:4:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:77:22: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   77 |         AA.resize(max((LL)A.size(), B.size() + sa));
      |                   ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:81:32: error: no matching function for call to 'min(LL, long long unsigned int)'
   81 |         for (LL n = sa; n < min((LL)A.size()-1,B.size()-1+sa); n++) {
      |                             ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:32: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'long long unsigned int')
   81 |         for (LL n = sa; n < min((LL)A.size()-1,B.size()-1+sa); n++) {
      |                             ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:32: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   81 |         for (LL n = sa; n < min((LL)A.size()-1,B.size()-1+sa); n++) {
      |                             ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:99:39: error: no matching function for call to 'min(long long unsigned int, LL)'
   99 |                 for (LL n = 0; n < min(AA.size() - sb, (LL)C.size()); n++) {
      |                                    ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:99:39: note:   deduced conflicting types for parameter 'const _Tp' ('long long unsigned int' and 'LL' {aka 'long long int'})
   99 |                 for (LL n = 0; n < min(AA.size() - sb, (LL)C.size()); n++) {
      |                                    ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:99:39: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long unsigned int'
   99 |                 for (LL n = 0; n < min(AA.size() - sb, (LL)C.size()); n++) {
      |                                    ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:108:19: error: no matching function for call to 'max(LL, long long unsigned int)'
  108 |         return max((LL)AA.size(), C.size() + sb);
      |                ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:108:19: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'long long unsigned int')
  108 |         return max((LL)AA.size(), C.size() + sb);
      |                ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:108:19: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
  108 |         return max((LL)AA.size(), C.size() + sb);
      |                ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~