Language: C++

#include <bits/stdc++.h>
#define endl '\n'

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s[3];
	for (auto& ss: s) {
		cin >> ss;
	}
	bool can[3][3][2001] = {};
	for (int i = 0; i < 3; ++i) {
		for (int j = 0; j < 3; ++j) {
			for (int shift = 0; shift <= 2000; ++shift) {
				can[i][j][shift] = true;
				for (int k = 0; k < s[j].size() && k + shift < s[i].size(); ++k) {
					if (s[i][k + shift] != '?' && s[j][k] != '?' && s[i][k + shift] != s[j][k]) {
						can[i][j][shift] = false;
						break;
					}
				}
			}
		}
	}
	int p[] = {0, 1, 2};
	unsigned int ans = 1e9;
	do {
		for (int sh1 = 0; sh1 <= 2000; ++sh1) {
			for (int sh2 = 0; sh2 <= 2000; ++sh2) {
				int sh3 = sh1 + sh2;
				if (can[p[0]][p[1]][sh1] && can[p[1]][p[2]][sh2] && (sh3 > 2000 || can[p[0]][p[2]][sh3])) {
					ans = min(ans, max(s[p[0]].size(), max(sh1 + s[p[1]].size(), sh3 + s[p[2]].size())));
				}
			}
		}
	} while (next_permutation(p, p + 3));
	cout << ans << endl;
}

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