Language: C++

#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
//#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N = 210000;
const int K = 100000;
const int mod = 1e9 + 7;
int p[3];
int ok1[N], ok2[N], ok3[N];
int solve(string a, string b, string c){
    for (int i = 0; i < K; i++){
        ok1[i] = ok2[i] = ok3[i] = 1;
    }
    for (int i = 0; i < a.length(); i++){
        for (int j = 0; j < b.length(); j++){
            if (i + j >= a.length()) break;
            if (a[i + j] != b[j] && a[i + j] != '?' && b[j] != '?') ok1[i] = 0;
        }
    }
    for (int i = 0; i < b.length(); i++){
        for (int j = 0; j < c.length(); j++){
            if (i + j >= b.length()) break;
            if (b[i + j] != c[j] && b[i + j] != '?' && c[j] != '?') ok2[i] = 0;
        }
    }
    for (int i = 0; i < a.length(); i++){
        for (int j = 0; j < c.length(); j++){
            if (i + j >= b.length()) break;
            if (a[i + j] != c[j] && a[i + j] != '?' && c[j] != '?') ok3[i] = 0;
        }
    }
    int res = 1e9;
    for (int i = 0; i <= a.length(); i++){
        for (int j = i; j <= a.length() + b.length(); j++){
            if (ok1[i] && ok3[j] && ok2[j - i]){
                res = min(res, max(max((int)a.length(), b.length() + i), c.length() + j));
            }
        }
    }
    return res;
}
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    string s[3];
    cin >> s[0];
    cin >> s[1];
    cin >> s[2];
    int ans = 1e9;
    for (int i = 0; i < 3; i++) p[i] = i;
    for (int i = 0; i < 6; i++){
        next_permutation(p, p + 3);
        ans = min(ans, solve(s[p[0]], s[p[1]], s[p[2]]));
    }
    cout << ans;
}


Compiler output:
a.cc: In function 'long long int solve(std::string, std::string, std::string)':
a.cc:48:39: error: no matching function for call to 'max(long long int, long long unsigned int)'
   48 |                 res = min(res, max(max((int)a.length(), b.length() + i), c.length() + j));
      |                                    ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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:2:
/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:48:39: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'long long unsigned int')
   48 |                 res = min(res, max(max((int)a.length(), b.length() + i), c.length() + j));
      |                                    ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:
/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:48:39: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   48 |                 res = min(res, max(max((int)a.length(), b.length() + i), c.length() + j));
      |                                    ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc: At global scope:
a.cc:54:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   54 | main(){
      | ^~~~