Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(int)(n); ++i)

const int MX = 2000;
bool ab[20000], ac[20000], bc[20000]; // where not match

bool match(char c1, char c2) {
  return (c1 == '?' || c2 == '?' || c1 == c2);
}

int main () {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  
  string a, b, c;
  cin >> a >> b >> c;
  int la = a.length();
  int lb = b.length();
  int lc = c.length();
  
  rep(i, a) rep(j, b) if(!match(a[i], b[j])) ab[10000-j+i] = true;
  rep(i, a) rep(j, c) if(!match(a[i], c[j])) ac[10000-j+i] = true;
  rep(i, b) rep(j, c) if(!match(b[i], c[j])) bc[10000-j+i] = true;
  
  int ans = 3*MX;
  for (int i=-2*MX; i<=2*MX; ++i) {
    for (int j=-2*MX; j<=2*MX; ++j) {
      if (!ab[i+10000] && !ac[j+10000] && !bc[10000-i+j])) {
        int L = min(0, min(i, j));
        int R = max(A, max(B+i, C+j));
        ans = min(ans, R-L);
      }
    }
  }
  cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:3:34: error: invalid cast from type 'std::string' {aka 'std::__cxx11::basic_string<char>'} to type 'int'
    3 | #define rep(i, n) for(int i=0; i<(int)(n); ++i)
      |                                  ^~~~~~~~
a.cc:22:3: note: in expansion of macro 'rep'
   22 |   rep(i, a) rep(j, b) if(!match(a[i], b[j])) ab[10000-j+i] = true;
      |   ^~~
a.cc:3:34: error: invalid cast from type 'std::string' {aka 'std::__cxx11::basic_string<char>'} to type 'int'
    3 | #define rep(i, n) for(int i=0; i<(int)(n); ++i)
      |                                  ^~~~~~~~
a.cc:22:13: note: in expansion of macro 'rep'
   22 |   rep(i, a) rep(j, b) if(!match(a[i], b[j])) ab[10000-j+i] = true;
      |             ^~~
a.cc:3:34: error: invalid cast from type 'std::string' {aka 'std::__cxx11::basic_string<char>'} to type 'int'
    3 | #define rep(i, n) for(int i=0; i<(int)(n); ++i)
      |                                  ^~~~~~~~
a.cc:23:3: note: in expansion of macro 'rep'
   23 |   rep(i, a) rep(j, c) if(!match(a[i], c[j])) ac[10000-j+i] = true;
      |   ^~~
a.cc:3:34: error: invalid cast from type 'std::string' {aka 'std::__cxx11::basic_string<char>'} to type 'int'
    3 | #define rep(i, n) for(int i=0; i<(int)(n); ++i)
      |                                  ^~~~~~~~
a.cc:23:13: note: in expansion of macro 'rep'
   23 |   rep(i, a) rep(j, c) if(!match(a[i], c[j])) ac[10000-j+i] = true;
      |             ^~~
a.cc:3:34: error: invalid cast from type 'std::string' {aka 'std::__cxx11::basic_string<char>'} to type 'int'
    3 | #define rep(i, n) for(int i=0; i<(int)(n); ++i)
      |                                  ^~~~~~~~
a.cc:24:3: note: in expansion of macro 'rep'
   24 |   rep(i, b) rep(j, c) if(!match(b[i], c[j])) bc[10000-j+i] = true;
      |   ^~~
a.cc:3:34: error: invalid cast from type 'std::string' {aka 'std::__cxx11::basic_string<char>'} to type 'int'
    3 | #define rep(i, n) for(int i=0; i<(int)(n); ++i)
      |                                  ^~~~~~~~
a.cc:24:13: note: in expansion of macro 'rep'
   24 |   rep(i, b) rep(j, c) if(!match(b[i], c[j])) bc[10000-j+i] = true;
      |             ^~~
a.cc:29:58: error: expected primary-expression before ')' token
   29 |       if (!ab[i+10000] && !ac[j+10000] && !bc[10000-i+j])) {
      |                                                          ^