Language: C++

using namespace std;

#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()
int M=2000;
bool ab[100000],ac[100000],bc[100000];

bool match(char a,char b){
    return (a == '?' || b == '?' || a == b);
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    string a,b,c; cin >> a >> b >> c;
    rep(i,0,a.length())rep(j,0,b.length()) if(!match(a[i],b[j])) ab[i-j+50000] =true;
    rep(i,0,a.length())rep(j,0,c.length()) if(!match(a[i],c[j])) ac[i-j+50000] =true;
    rep(i,0,b.length())rep(j,0,c.length()) if(!match(b[i],c[j])) bc[i-j+50000] =true;

    int ans = 3 * M;
    rep(i,-2*M,2*M+1)rep(j,-2*M,2*M+1)if((!ab[i+50000]) && (!ac[j+50000]) && (!bc[j-i+50000])){
        int l = min(0,min(i,j));
        int r = max(a.length(),max(b.length()+i,c.length()+j));
        ans = min(ans,r-l);
    }
    cout << ans << endl;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:15:5: error: 'cin' was not declared in this scope
   15 |     cin.tie(nullptr);
      |     ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | using namespace std;
a.cc:16:5: error: 'ios' has not been declared
   16 |     ios::sync_with_stdio(false);
      |     ^~~
a.cc:17:5: error: 'cout' was not declared in this scope
   17 |     cout << fixed << setprecision(15);
      |     ^~~~
a.cc:17:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:17:13: error: 'fixed' was not declared in this scope
   17 |     cout << fixed << setprecision(15);
      |             ^~~~~
a.cc:1:1: note: 'std::fixed' is defined in header '<ios>'; this is probably fixable by adding '#include <ios>'
  +++ |+#include <ios>
    1 | using namespace std;
a.cc:17:22: error: 'setprecision' was not declared in this scope
   17 |     cout << fixed << setprecision(15);
      |                      ^~~~~~~~~~~~
a.cc:1:1: note: 'std::setprecision' is defined in header '<iomanip>'; this is probably fixable by adding '#include <iomanip>'
  +++ |+#include <iomanip>
    1 | using namespace std;
a.cc:18:5: error: 'string' was not declared in this scope
   18 |     string a,b,c; cin >> a >> b >> c;
      |     ^~~~~~
a.cc:1:1: note: 'std::string' is defined in header '<string>'; this is probably fixable by adding '#include <string>'
  +++ |+#include <string>
    1 | using namespace std;
a.cc:18:26: error: 'a' was not declared in this scope; did you mean 'ac'?
   18 |     string a,b,c; cin >> a >> b >> c;
      |                          ^
      |                          ac
a.cc:18:31: error: 'b' was not declared in this scope; did you mean 'bc'?
   18 |     string a,b,c; cin >> a >> b >> c;
      |                               ^
      |                               bc
a.cc:18:36: error: 'c' was not declared in this scope; did you mean 'bc'?
   18 |     string a,b,c; cin >> a >> b >> c;
      |                                    ^
      |                                    bc
a.cc:25:23: error: 'min' was not declared in this scope; did you mean 'main'?
   25 |         int l = min(0,min(i,j));
      |                       ^~~
      |                       main
a.cc:25:17: error: 'min' was not declared in this scope; did you mean 'main'?
   25 |         int l = min(0,min(i,j));
      |                 ^~~
      |                 main
a.cc:26:32: error: 'max' was not declared in this scope
   26 |         int r = max(a.length(),max(b.length()+i,c.length()+j));
      |                                ^~~
a.cc:26:17: error: 'max' was not declared in this scope
   26 |         int r = max(a.length(),max(b.length()+i,c.length()+j));
      |                 ^~~
a.cc:29:20: error: 'endl' was not declared in this scope
   29 |     cout << ans << endl;
      |                    ^~~~
a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
  +++ |+#include <ostream>
    1 | using namespace std;