criyle/codenet-compile-errors huggingface dataset:
Language: C++

#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++) 
#define M 2000
bool ab[100000],bc[100000],ac[100000] ;
bool match(char c1 , char c2) {
   return(c1=='?' || c2=='?' || c1==c2);
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string a,b,c ;
    cin >> a >> b >> c ;
    int i,j;
   int A=a.length();
   int B=b.length();
   int C=c.length();
   REP(i,A) REP(j,B) if(!match(a[i],b[j]) ab[i-j+50000] = true ;
   REP(i,A) REP(j,B) if(!match(b[i],c[j]) bc[i-j+50000] = true ;
   REP(i,A) REP(j,B) if(!match(a[i],c[j]) ac[i-j+50000] = true ;
   int ans = 3*M ;
   for(i=-2*M;i<=2*M;i++) for(j=-2*M;j<=2*M;j++) if(!ab[i+50000] && !ac[j+50000] &&
   !bc[j-i+50000]){
   int l = min(0, min(i, j));
   int r = max(A, max(B + i, C + j));
   ans=min(ans, r-l);
   cout<<ans<<endl ;                    
   return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:19:42: error: expected ';' before 'ab'
   19 |    REP(i,A) REP(j,B) if(!match(a[i],b[j]) ab[i-j+50000] = true ;
      |                                          ^~~
      |                                          ;
a.cc:4:18: error: expected primary-expression before 'for'
    4 | #define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
      |                  ^~~
a.cc:20:4: note: in expansion of macro 'REP'
   20 |    REP(i,A) REP(j,B) if(!match(b[i],c[j]) bc[i-j+50000] = true ;
      |    ^~~
a.cc:19:65: error: expected ')' before 'for'
   19 |    REP(i,A) REP(j,B) if(!match(a[i],b[j]) ab[i-j+50000] = true ;
      |                        ~                                        ^
      |                                                                 )
a.cc:4:46: error: expected ';' before ')' token
    4 | #define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
      |                                              ^
a.cc:20:4: note: in expansion of macro 'REP'
   20 |    REP(i,A) REP(j,B) if(!match(b[i],c[j]) bc[i-j+50000] = true ;
      |    ^~~
a.cc:4:46: error: expected ';' before ')' token
    4 | #define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
      |                                              ^
a.cc:20:13: note: in expansion of macro 'REP'
   20 |    REP(i,A) REP(j,B) if(!match(b[i],c[j]) bc[i-j+50000] = true ;
      |             ^~~
a.cc:21:42: error: expected ';' before 'ac'
   21 |    REP(i,A) REP(j,B) if(!match(a[i],c[j]) ac[i-j+50000] = true ;
      |                                          ^~~
      |                                          ;
a.cc:22:18: error: expected ')' before ';' token
   22 |    int ans = 3*M ;
      |                  ^
a.cc:21:24: note: to match this '('
   21 |    REP(i,A) REP(j,B) if(!match(a[i],c[j]) ac[i-j+50000] = true ;
      |                        ^
a.cc:27:4: error: 'ans' was not declared in this scope; did you mean 'abs'?
   27 |    ans=min(ans, r-l);
      |    ^~~
      |    abs
a.cc:30:2: error: expected '}' at end of input
   30 | }
      |  ^
a.cc:10:12: note: to match this '{'
   10 | int main() {
      |            ^
Language: C++

#include"bits/stdc++.h"
using namespace std;
#define REP(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define rep(i,n) REP((i),0,(n))
using ll = long long;

string join(string base, string s) {
    const ll M = s.size();
    rep(l, base.size()) {
        ll r = min((ll)base.size(), l + M);
        REP(i, l, r) {
            if (base[i] != '?' && s[i - l] != '?' && base[i] != s[i - l])goto end;
        }
        ll siz = max((ll)base.size(), l + M);
        base.resize(siz, '*');
        REP(i, l, siz) {
            base[i] =
                base[i] == '*' ? s[i - l] :
                s[i - l] == '?' ? base[i] : s[i - l];
        }
        return base;
end:;
    }
    return base + s;
}

int main()
{
    vector<string> ss;
    rep(i, 3) {
        string s;
        cin >> s;
        ss.push_back(s);
    }
    sort(ss.begin(), ss.end());

    ll res = 1e7;
    do {
        string base = ss[0];
        REP(i, 1, 3)base = join(base, ss[i]);
        res = min(res, (ll)base.size());
    } while (next_permutation(ss.begin(), ss.end()));
    cout << res << endl;
    return 0;
}


Compiler output:
a.cc: In function 'std::string join(std::string, std::string)':
a.cc:22:1: error: jump to label 'end'
   22 | end:;
      | ^~~
a.cc:12:79: note:   from here
   12 |             if (base[i] != '?' && s[i - l] != '?' && base[i] != s[i - l])goto end;
      |                                                                               ^~~
a.cc:14:12: note:   crosses initialization of 'll siz'
   14 |         ll siz = max((ll)base.size(), l + M);
      |            ^~~
Language: C++

#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/















//---------------------------------------------------------------------------------------------------
vector<bool> matching(string x, string y) {
	int nx = x.size();
	int ny = y.size();

	vector<bool> res(6010);
	rep(st, 0, nx) {
		for (int i = 0; st + i < nx && i < ny; i++) {
			if (x[st + i] == '?') continue;
			if (y[i] == '?') continue;
			if (x[st + i] != y[i]) res[a] = false;
		}
	}

	return res;
}
//---------------------------------------------------------------------------------------------------
int solve(string A, string B, string C) {
	int na = A.size();
	int nb = B.size();
	int nc = C.size();

	auto ab = matching(A, B);
	auto bc = matching(B, C);
	auto ac = matching(A, C);

	int ans = inf;
	rep(a, 0,  2020) rep(b, 0, 4040) if (ab[a] && bc[b] && ac[a + b]) {
		chmin(ans, max({ na, a + nb, a + b + nc }));
	}
	return ans;
}
//---------------------------------------------------------------------------------------------------
void _main() {
	vector<string> v;
	rep(i, 0, 3) {
		string s; cin >> s;
		v.push_back(s);
	}
	sort(all(v));

	int ans = inf;
	do {
		chmin(ans, solve(v[0], v[1], v[2]));
	} while (next_permutation(all(v)));
	cout << ans << endl;
}







Compiler output:
a.cc: In function 'std::vector<bool> matching(std::string, std::string)':
a.cc:46:52: error: 'a' was not declared in this scope
   46 |                         if (x[st + i] != y[i]) res[a] = false;
      |                                                    ^
Language: C++

import sys
from itertools import permutations

a, b, c = sys.stdin.read().split()

def merge(s, t):
    n = len(s)
    m = len(t)
    cand = []
    for i in range(n):
        for j in range(min(m, n-i)):
            if s[i+j] != t[j]:
                if s[i+j] != '?' and t[j] != '?':
                    break
        else:
            if m >= n - i:
                cand.append(s[:i] + t)
            else:
                cand.append(s)
                break
    return cand

def main():
    ans = 10000
    for p in permutations((a, b, c)):
        s, t, u = p
        cand = merge(s, t)
        for w in cand:
            res = merge(w, u)
            for r in res:
                ans = min(ans, len(r))
    return ans

if __name__ == "__main__":
    ans = main()
    print(ans)

Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import sys
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 6e3 + 7;
const ll mod = 1e9+7;

int n,m;

char c1[maxn], c2[maxn], c3[maxn];
int k1, k2, k3;

getfail(char *p,int *nex)//kmp找nex节点
{
    int k=strlen(p);
    nex[0]=0;
    nex[1]=0;
    for(int i=1;i<k;i++){
        int j=nex[i];
        while(j && p[j]!=p[i] && p[i] != '?' && p[j] != '?')j=nex[j];
        nex[i+1] = (p[i]==p[j] || p[i] == '?' || p[j] == '?') ? j+1 : 0;
    }
}//kmp

char ch[maxn];
int nex[maxn];
int solve(char *c1, char *c2, char *c3){
    k1 = strlen(c1);
    k2 = strlen(c2);
    k3 = strlen(c3);
    getfail(c2, nex);
    int j = 0, last = -1, all = -1;
    for(int i=0; i < k1; i++){
        while(j > 0 && c1[i] != c2[j] && c1[i] != '?' && c2[j] != '?') j = nex[j];
        if(c1[i] ==  c2[j] || c1[i] == '?' || c2[j] == '?'){
            last = j;
            j++;
            if(j == k2){
                all = i;
                break;
            }
        }
    }
    if(all != -1){
        for(int i = 0; i <= k1; i++)ch[i] = c1[i];
    }
    else{
        for(int i = 0; i < k1; i++)ch[i] = c1[i];
        for(int j = last + 1; j <= k2; j++)ch[j - last - 1 + k1] = c2[j];
        //cout << "ch = " << ch << "\n";
        for(int i = 0; i <= last; i++){
            int t1 = k1 - 1 - (last - i), t2 = i, t3 = t1;
            if(c1[t1] == '?')ch[t3] = c2[t2];
            else if(c2[t2] == '?')ch[t3] = c1[t1];
        }
        ch[k1 + k2 - last - 1] = '\0';
    }
    //cout << "k1, k2, k3 = " << k1 << " " << k2 << " " << k3 << "\n";
    //cout << "all, last = " << all << " " << last << "\n";
    int k = strlen(ch);

    getfail(c3, nex);
    j = 0, last = -1, all = -1;
    for(int i=0; i < k; i++){
        while(j > 0 && ch[i] != c3[j] && ch[i] != '?' && c3[j] != '?') j = nex[j];
        if(ch[i] ==  c3[j] || ch[i] == '?' || c3[j] == '?'){
            last = j;
            j++;
            if(j == k3){
                all = i;
                break;
            }
        }
    }
    /*
    cout << "all, last = " << all << " " << last << "\n";
    cout << c1 << "\n";
    cout << c2 << "\n";
    cout << c3 << "\n";
    cout << ch << "\n";
    */
    int ans = k1 + k2 + k3;
    if(all != -1)ans = k;
    else ans = k + k3 - last - 1;
    //cout << ans << "\n\n";
    return ans;
}
int main()
{
    scanf("%s", c1);
    scanf("%s", c2);
    scanf("%s", c3);
    int ans = solve(c1, c2, c3);
    ans = min(ans, solve(c1, c3, c2));
    ans = min(ans, solve(c2, c1, c3));
    ans = min(ans, solve(c2, c3, c1));
    ans = min(ans, solve(c3, c1, c2));
    ans = min(ans, solve(c3, c2, c1));
    printf("%d\n", ans);


    return 0;
}


Compiler output:
a.cc:12:1: error: ISO C++ forbids declaration of 'getfail' with no type [-fpermissive]
   12 | getfail(char *p,int *nex)//kmp找nex节点
      | ^~~~~~~
a.cc: In function 'int getfail(char*, int*)':
a.cc:22:1: warning: no return statement in function returning non-void [-Wreturn-type]
   22 | }//kmp
      | ^
Language: C++

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int INF = 1000000000;
const int mod = 1e9+7;
const int maxn = 2e5+5;
int juge(string a,string b,string c){
	int i,j,l;
	int len1 =a.length(),len2 = b.length(),len3 = c.length();
	int cnt1 =0,cnt2 = 0; 
	for(i=0;i<len1;i++){
		for(j=0;i+j<len1;j++){
		//	cout<<33333<<endl;
			if(a[i+j]==b[j]||a[i+j]=='?'||b[j]=='?'){
				continue;
			}
			else {
				break;
			}
		}
		if((i+j)==len1&&j<=len2){
			cnt1 = j;
			for(int k=len1-j;k<len1;k++){
				if((a[i]=='?'&&b[i]!='?')||(b[i]=='?'&&a[i]!='?')){
					if(a[i]=='?') a[i] = b[i];
				}
			}
			break;
		}
	}
	for(int k=cnt1;k<len2;k++)
		a.push_back(b[k]);
	b = a;
	
	len2 = b.length();
//	cout<<cnt1<<" "<<len2<<endl;;
//	cout<<b<<endl;
	for(j=0;j<len2;j++){
		for(l=0;l+j<len2;l++){
		//	cout<<444444<<endl;
			if(b[l+j]==c[l]||b[l+j]=='?'||c[l]=='?'){
				continue;
			}
			else {
				break;
			}
		}
		if((j+l)==len2&&l<=len3){
			cnt2 = l;
			break;
		}
	}wo 
	//cout<<1111<<endl; 
	int ans = len2+len3-cnt2;
	return ans;
}
int main() {
	int minn = 1000000;
	string s[4];
	cin>>s[1]>>s[2]>>s[3];
	for(int i=1;i<=3;i++)
		for(int j=1;j<=3;j++)
			for(int l=1;l<=3;l++){
				if(i!=j&&i!=l&&j!=l){
					minn = min(minn,juge(s[i],s[j],s[l]));
				//	cout<<22222<<endl;
				}
			}
	cout<<minn<<endl;
    return 0;
}



Compiler output:
a.cc: In function 'int juge(std::string, std::string, std::string)':
a.cc:68:10: error: 'wo' was not declared in this scope
   68 |         }wo
      |          ^~
a.cc:71:16: error: 'ans' was not declared in this scope; did you mean 'abs'?
   71 |         return ans;
      |                ^~~
      |                abs
Language: C++

#include <iostream>
#include <vector>
#include <string>
using namespace std;

bool g(string a, string b)
{
    for (int i = 0; i < min(a.length(), b.length()); i++)
    {
        if (a[i] != '?' && b[i] != '?' && a[i] != b[i])
        {
            return false;
        }
    }
    return true;
}

int f(string a, string b, string c)
{
    int r = 6000;
    for (int i = 0; i < a.length(); i++)
    {
        for (int j = 0; j < b.length(); j++)
        {
            int s = max({ i + j + c.length(), i + b.length(), a.length() });
            string aa = i >= a.length() ? "" : a.substr(i);
            string bb = j >= b.length() ? "" : b.substr(j);
            string cc = i+j >= a.length() ? "" : a.substr(i+j);
            if (s < r && g(aa, b) && g(bb, c) && g(cc, c))
            {
                r = s;
            }
        }
    }
    return r;
}

int main()
{
    string a,b,c;
    cin >> a >> b >> c;
    int r;
    r = min(6000,f(a,b,c));
    r = min(r,f(a,c,b));
    r = min(r,f(b,a,c));
    r = min(r,f(b,c,a));
    r = min(r,f(c,a,b));
    r = min(r,f(c,b,a));
    cout << r << endl;
}

Compiler output:
a.cc: In function 'int f(std::string, std::string, std::string)':
a.cc:25:24: error: no matching function for call to 'max(<brace-enclosed initializer list>)'
   25 |             int s = max({ i + j + c.length(), i + b.length(), a.length() });
      |                     ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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:   candidate expects 2 arguments, 1 provided
/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, 1 provided
Language: C++

#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ll long long
#define lson l,mid,p<<1
#define rson mid+1,r,p<<1|1
#define pii pair<int,int>
using namespace std;
const int inf=1e9+10;
const int mod=1e9+7;
const int maxn=2e3+10;
int dp[maxn][maxn][maxn];
char a[maxn],b[maxn],c[maxn];
int main(){
	//ios::sync_with_stdio(false);
	//freopen("in","r",stdin);
	cin>>a+1>>b+1>>c+1;
	int n=strlen(a+1),m=strlen(b+1),k=strlen(c+1);
	for(int i=0;i<=n;i++) for(int j=0;j<=m;j++) for(int l=0;l<=k;l++) dp[i][j][l]=inf;
	dp[0][0][0]=0;
	for(int i=0;i<=n;i++){
		for(int j=0;j<=m;j++){
			for(int l=0;l<=k;l++){
				if(i==0&&j==0&&l==0) continue;
				if(i>0) dp[i][j][l]=min(dp[i][j][l],dp[i-1][j][l]+1);
				if(j>0) dp[i][j][l]=min(dp[i][j][l],dp[i][j-1][l]+1);
				if(l>0) dp[i][j][l]=min(dp[i][j][l],dp[i][j][l-1]+1);
				if(i>0&&j>0&&(a[i]==b[j]||a[i]=='?'||b[j]=='?')) dp[i][j][l]=min(dp[i][j][l],dp[i-1][j-1][l]+1);
				if(i>0&&l>0&&(a[i]==c[l]||a[i]=='?'||c[l]=='?')) dp[i][j][l]=min(dp[i][j][l],dp[i-1][j][l-1]+1);
				if(l>0&&j>0&&(c[l]==b[j]||c[l]=='?'||b[j]=='?')) dp[i][j][l]=min(dp[i][j][l],dp[i][j-1][l-1]+1);
				if(i>0&&j>0&&l>0){
					char x=a[i],y=b[j],z=c[l];
					if((x==y||x=='?'||y=='?')&&(x==z||x=='?'||z=='?')&&(y==z||y=='?'||z=='?'))
						dp[i][j][l]=min(dp[i][j][l],dp[i-1][j-1][l-1]+1);
				}
			}
		}
	}
	cout<<dp[n][m][k]<<endl;
	return 0;
}


Compiler output:
/tmp/ccJVJsdc.o: in function `main':
a.cc:(.text+0xb): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccJVJsdc.o
a.cc:(.text+0x27): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/ccJVJsdc.o
a.cc:(.text+0x3c): relocation truncated to fit: R_X86_64_PC32 against symbol `c' defined in .bss section in /tmp/ccJVJsdc.o
a.cc:(.text+0x4e): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccJVJsdc.o
a.cc:(.text+0x60): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/ccJVJsdc.o
a.cc:(.text+0x72): relocation truncated to fit: R_X86_64_PC32 against symbol `c' defined in .bss section in /tmp/ccJVJsdc.o
a.cc:(.text+0x3b9): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccJVJsdc.o
a.cc:(.text+0x3c9): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/ccJVJsdc.o
a.cc:(.text+0x3dd): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccJVJsdc.o
a.cc:(.text+0x3f1): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/ccJVJsdc.o
a.cc:(.text+0x4e0): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
Language: C++


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

bool isMatch(char a,char b){
    if(a == '?' || b == '?'){
        return true;
    }else if(a == b){
        return true;
    }else{
        return false;
    }
}
int main() {
    string a,b,c;
    cin >> a >> b >> c;
    
    int a_size = a.size();
    int b_size = b.size();
    int c_size = c.size();

    int max_n = a_size+b_size+c_size;
    string oringin_a = a;
    rep(i,max_n-a_size){
        a += "?";
    }
    
    rep(i,max_n){
        rep(j,b_size){
            if(j == b_size-1){
                //match
                rep(jkr,b_size){
                    a[i+jkr] = (a[i+jkr] == '?')?a[i+jkr]:b[jkr];
                    goto asdhuih;
                }
            }
            if(isMatch(b[j],a[j+i])){
                continue;
            }else{
                break;
            }
        }
    }
    
asdhuih:
    b = c;
    b_size = c_size;
    
    rep(i,max_n){
        rep(j,b_size){
            if(j == b_size-1){
                //match
                rep(jkr,b_size){
                    a[i+jkr] = (a[i+jkr] == '?')?a[i+jkr]:"!";
                    goto qweoiu;
                }
            }
            if(isMatch(b[j],a[j+i])){
                continue;
            }else{
                break;
            }
        }
    }
    
qweoiu:
    int cnt = 0;
    rep(i,max_n){
        if(a[max_n-i-1]=='?'){
            cnt++;
        }
    }
    
    cout << max_n-cnt << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:56:49: error: operands to '?:' have different types '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type' {aka 'char'} and 'const char*'
   56 |                     a[i+jkr] = (a[i+jkr] == '?')?a[i+jkr]:"!";
      |                                ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
Language: C++

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

bool can(string s1, string s2, int pos){
	for(int j = pos; j < pos + s2.size() && j < s1.size(); j++){
		if(s1[j] != '?' && s2[j-pos] != '?' && s1[j] != s2[j-pos]){
			return 0;
		}
	}
	return 1;
}
bool ok[3][3][2020];
string s[3];

int get_it(int a, int b, int c){
	int ans = s[a].size() + s[b].size() + s[c].size();
	for(int pos1 = 0; pos1 <= s[a].size(); pos1++){
		for(int pos2 = 0; pos2 <= s[b].size(); pos2++){
			if(ok[a][b][pos1] && ok[b][c][pos2] && (pos1 + pos2 >= s[a].size() || ok[a][c][pos1 + pos2])){
				ans = min(ans, max({pos1 + pos2 + (int)s[c].size(), pos1 + (int)s[b].size(), (int)s[a].size());
			}
		}
	}
	return ans;
}

int main(){
	cin >> s[0] >> s[1] >> s[2];
	rep(i, 3){
		rep(j, 3){
			rep(pos, s[j].size()){
				ok[j][i][pos] = can(s[j], s[i], pos);
			}
			ok[j][i][s[j].size()] = 1;
		}
	}
	cout << min({get_it(0, 1, 2), get_it(0, 2, 1), get_it(1, 0, 2), 
				 get_it(1, 2, 0), get_it(2, 0, 1), get_it(2, 1, 0)}) << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int get_it(int, int, int)':
a.cc:21:126: error: expected '}' before ')' token
   21 |                                 ans = min(ans, max({pos1 + pos2 + (int)s[c].size(), pos1 + (int)s[b].size(), (int)s[a].size());
      |                                                    ~                                                                         ^
a.cc:21:127: error: expected ')' before ';' token
   21 |                                 ans = min(ans, max({pos1 + pos2 + (int)s[c].size(), pos1 + (int)s[b].size(), (int)s[a].size());
      |                                          ~                                                                                    ^
      |                                                                                                                               )
Language: C++


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

bool isMatch(char a,char b){
    if(a == '?' || b == '?'){
        return true;
    }else if(a == b){
        return true;
    }else{
        return false;
    }
}
int main() {
    string a,b,c;
    cin >> a >> b >> c;
    
    int a_size = a.size();
    int b_size = b.size();
    int c_size = c.size();

    int max_n = a_size+b_size+c_size;
    string oringin_a = a;
    rep(i,max_n-a_size){
        a += "?";
    }
    
    rep(i,max_n){
        rep(j,b_size){
            if(j == b_size-1){
                //match
                rep(jkr,b_size){
                    a[i+jkr] = (a[i+jkr] == '?')?a[i+jkr]:b[jkr];
                    goto asdhuih;
                }
            }
            if(isMatch(b[j],a[j+i])){
                continue
            }else{
                break;
            }
        }
    }
    
asdhuih:
    b = c;
    b_size = c_size;
    
    rep(i,max_n){
        rep(j,b_size){
            if(j == b_size-1){
                //match
                rep(jkr,b_size){
                    a[i+jkr] = (a[i+jkr] == '?')?a[i+jkr]:"!";
                    goto qweoiu;
                }
            }
            if(isMatch(b[j],a[j+i])){
                continue
            }else{
                break;
            }
        }
    }
    
qweoiu:
    int cnt = 0;
    rep(i,max_n){
        if(a[max_n-i-1]=='?'){
            cnt++;
        }
    }
    
    cout << max_n-cnt << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:40:25: error: expected ';' before '}' token
   40 |                 continue
      |                         ^
      |                         ;
   41 |             }else{
      |             ~            
a.cc:56:49: error: operands to '?:' have different types '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type' {aka 'char'} and 'const char*'
   56 |                     a[i+jkr] = (a[i+jkr] == '?')?a[i+jkr]:"!";
      |                                ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
a.cc:61:25: error: expected ';' before '}' token
   61 |                 continue
      |                         ^
      |                         ;
   62 |             }else{
      |             ~
Language: C++

#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007


#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007

ll d[3][3][2020];

int main(){
  clr(d,0);
  string s[3];
  cin>>s[0];
  cin>>s[1];
  cin>>s[2];
  rep(i,0,3){
    rep(j,0,3){
      if(i==j)continue;
      string s1 =s[i];
      string s2 = s[j];
      ll mn = s1.sz;
      rep(k,0,s1.sz){
        ll flag = 1;
        rep(l,0,s2.sz){
          if(k+l==s1.sz)break;
          if(s1[k+l]=='?')continue;
          if(s2[l]=='?')continue;
          if(s1[k+l]!=s2[l])flag = 0;
        }
        if(flag==1){
          d[i][j][k]=1;
        }
      }
    }
  }
  vector<ll> v;
  rep(i,0,3){
    v.pb(i);
  }
  ll mn = s[0].sz+s[1].sz+s[2].sz;
  do{
    ll a1 = v[0];
    ll a2 = v[1];
    ll a3 = v[2];
    rep(i,0,s[a1].sz){
      if(d[a1][a2][i]==1){
        rep(j,0,s[a1].sz){
          if(d[a1][a3][j]==1){
            if((i-j>=0&&i-j<s[a3].sz&&d[a3][a2][i-j]==1)||(i-j<0)){
              mn = min(mn,max(i+(ll)s[a2].sz,j+(ll)s[a3].sz));
            }
          }
        }
        rep(j,0,s[a2].sz){
          if(d[a2][a3][j]==1){
            if(i+j<s[a1].szd[a1][a3][i+j]==1){
              mn = min(mn,max(i+(ll)s[a2].sz,i+j+(ll)s[a3].sz));
            }
          }
        }
      }
    }
  }while(next_permutation(all(v)));
  cout << mn << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:126:26: error: 'std::string' {aka 'class std::__cxx11::basic_string<char>'} has no member named 'szd'
  126 |             if(i+j<s[a1].szd[a1][a3][i+j]==1){
      |                          ^~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
char p2(char c, char d){
  if (c == '?' && d == '?'){
    return '?';
  } else if (c == '?'){
    return d;
  } else if (d == '?'){
    return c;
  } else if (c == d){
    return c;
  } else {
    return '#';
  }
}
char p3(char &c, char &d, char &e){
  return p2(c, p2(d, e));
}
bool f2(string s, string t, int d){
  int L = max(s.size(), d + t.size());
  for (int i = 0; i < L; i++){
    char S = '?';
    char T = '?';
    if (i < s.size()) S = s[i];
    if (d <= i && i < d + t.size()) T = t[i - d];
    if (p2(S, T) == '#'){
      return false;
    }
  }
  return true;
}
int f3(string &s, string &t, string &r){
  int res = 10000;
  int A = s.size();
  int B = t.size();
  int C = r.size();
  set<int> Msr;
  for (int i = 0; i <= A + C; i++){ //t
    bool b = f2(s, t, i);
    if (!b) continue;
//    int L1 = max(s.size(), (int) t.size() + i);
    bool flg2 = true;
    for (int j = 0; j <= A + B; j++){ //r
      if (Msr.count(j)) continue;
      int L = max(A, max(B + i, C + j));
      if (L >= res) continue;
      if (i > A && j > B) continue;
      bool flg = true;
      string res2;
      for (int k = 0; k < L; k++){
        char S = '?';
        char T = '?';
        char R = '?';
        if (k < A) S = s[k];
        if (i <= k && k < B + i) T = t[k - i];
        if (j <= k && k < C + j) R = r[k - j];
        if (p3(S, T, R) == '#'){
          flg = false;
          if (p2(S, R) == '#'){
            Msr.insert(j);
          break;
        }
      }
      if (flg){
        res = L;
        break;
      }
    }
  }
  return res;
}
int main(){
  string a, b, c;
  cin >> a >> b >> c;
  int A = f3(a, b, c);
  int B = f3(b, c, a);
  int C = f3(c, a, b);
  cout << min(A, min(B, C));
}

Compiler output:
a.cc: In function 'int f3(std::string&, std::string&, std::string&)':
a.cc:72:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   72 | int main(){
      |         ^~
a.cc:72:9: note: remove parentheses to default-initialize a variable
   72 | int main(){
      |         ^~
      |         --
a.cc:72:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:72:11: error: a function-definition is not allowed here before '{' token
   72 | int main(){
      |           ^
a.cc:79:2: error: expected '}' at end of input
   79 | }
      |  ^
a.cc:32:40: note: to match this '{'
   32 | int f3(string &s, string &t, string &r){
      |                                        ^
a.cc:79:2: warning: control reaches end of non-void function [-Wreturn-type]
   79 | }
      |  ^
Language: C++

#include <bits/stdc++.h>

using namespace std;

#define DIM 300009
#define INF ((long long)1e18+9ll)
#define pairll pair<long long,long long>
#define fi first
#define se second
#define ld long double
#define amen exit(0)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define endl '\n'
#define MODULO 1000000007

long long i,j,k,l,n,m;

string a[4];

long long dp[4][4];

bool check(char a,char b){
    if(a=='?' || b=='?')return 1;
    return a==b;
}

vector<long long>aa;

bool fnd(string a,string b){
    long long flag=0;
    if(a.length()<b.length())return false;
    for(int i=0;i<a.length()-b.length()+1;i++){
        flag=0;
        for(j=0;j<b.length();j++){
            if(!check(a[i+j],b[j]))flag=1;
        }
        if(flag==0)return true;
    }
    return false;
}

int main()
{   
    fast;

    cin>>a[1]>>a[2]>>a[3];

    for(i=1;i<=3;i++){
        for(j=1;j<=3;j++){
            if(i==j)continue;
            for(int len=min(a[i].length(),a[j].length());len>0;len--){
                long long flag=0;
                for(k=0;k<len;k++){
                    if(!check(a[i][a[i].length()-len+k],a[j][k]))flag=1;
                }
                if(!flag){
                    dp[i][j]=len;
                    break;
                }
            }
        }
    }

    aa={1,2,3};

    long long res=a[1].length()+a[2].length()+a[3].length();

    do{
        if(fnd(a[aa[0]],a[aa[1]]) && fnd(a[aa[0]],a[aa[2]]))res=a[aa[0]].length();

        if(fnd(a[aa[0]],a[aa[1]]) || fnd(a[aa[2]],a[aa[1]])){
       //     cout<<aa[0]<<' '<<aa[1]<<' '<<aa[2]<<' '<<dp[aa[0]][aa[2]]<<' '<<res<<endl;
            res=min((unsigned long long)res,a[aa[0]].length()+a[aa[2]].length()-dp[aa[0]][aa[2]]);
        }

      //      cout<<aa[0]<<' '<<aa[1]<<' '<<aa[2]<<' '<<a[aa[0]].length()+a[aa[1]].length()+a[aa[2]].length()-dp[aa[0]][aa[1]]-dp[aa[1]][aa[2]]<<endl;

        if(dp[aa[0]][aa[1]]!=min(a[aa[1]].length(),a[aa[0]].length()) && dp[aa[1]][aa[2]]!=min(a[aa[2].length()],a[aa[1]].length()))res=min((unsigned long long)res,a[aa[0]].length()+a[aa[1]].length()+a[aa[2]].length()-dp[aa[0]][aa[1]]-dp[aa[1]][aa[2]]);
    }while(next_permutation(aa.begin(),aa.end()));

    cout<<res<<endl;

    amen;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:78:104: error: request for member 'length' in 'aa.std::vector<long long int>::operator[](2)', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'}
   78 |         if(dp[aa[0]][aa[1]]!=min(a[aa[1]].length(),a[aa[0]].length()) && dp[aa[1]][aa[2]]!=min(a[aa[2].length()],a[aa[1]].length()))res=min((unsigned long long)res,a[aa[0]].length()+a[aa[1]].length()+a[aa[2]].length()-dp[aa[0]][aa[1]]-dp[aa[1]][aa[2]]);
      |                                                                                                        ^~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9+7;
//const long long MOD = ;
const long long INF_LL = 1e18+3; const int INF_int = 1e9+3;
#define ll long long
#define rep(i,n) for(int i = 0;i<n;i++)
#define lrep(i,n) for(long long i = 0;i<n;i++)
#define All(a) a.begin(),a.end()
#define Debug_Output_ALL(a) for(auto itr = a.begin();itr!=a.end();itr++) cout << *itr << " ";cout << endl;
int solve(string a,string b,string c){
    rep(i,a.size()){
        bool fl = true;
        rep(j,min(b.size(),a.size()-i)){
            if(a[i+j]!=b[j] && a[i+j]!='?' && b[j]!='?'){
                fl = false;
                break;
            }
        }
        if(fl){
            if(i+b.size()>a.size()){
                b = a.substr(0,i) + b;
            else b = a;
            for(int k = i;k<a.size();k++){
                if(b[k]=='?' && a[k]!='?') b[k]=a[k];
            }
            break;
        }
        if(i==a.size()-1) b = a+b;
    }
    //cout << b << " ";
    rep(i,b.size()){
        bool fl = true;
        rep(j,min(c.size(),b.size()-i)){
            if(b[i+j]!=c[j] && b[i+j]!='?' && c[j]!='?'){
                fl = false;
                break;
            }
        }
        if(fl){
            if(i+c.size()>b.size()) c = b.substr(0,i) + c;
            else c = b;
            break;
        }
        if(i==b.size()-1) c = b+c;
    }
    //cout << c << endl;
    return c.size();
}
int main(){
    string a,b,c;
    cin >> a >> b >> c;
    int ans = solve(a,b,c);
    ans = min(ans,solve(a,c,b));
    ans = min(ans,solve(b,a,c));
    ans = min(ans,solve(b,c,a));
    ans = min(ans,solve(c,a,b));
    ans = min(ans,solve(c,b,a));
    cout << ans << endl;
}


Compiler output:
a.cc: In function 'int solve(std::string, std::string, std::string)':
a.cc:23:13: error: expected '}' before 'else'
   23 |             else b = a;
      |             ^~~~
a.cc:21:36: note: to match this '{'
   21 |             if(i+b.size()>a.size()){
      |                                    ^
Language: C++

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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;


int main()
{
  string a,b,c,aori;
  cin >> a >> b >> c;
  
  aori = a;
  a += b + c;
  
  unsigned count[26];
  int sum=0,count_x=0;
  
  rep(i,26)
    count[i] = 0 ;
  
  rep(i,a.size()){
    if ( a.at(i) >= 'a' && a.at(i) <= 'z' )
      count[a.at(i)-'a']=1;
    else if(a.at(i)=='?')
      count_x++;
  }

  rep(i,26)
    sum += count[i];
  
  rep(i,aori.size){
    if(aori[i]==b[i] || b[i]==c[i] || aori[i]==c[i]){
      count_x =0;
      break;
    }
  }
  
  
  cout << sum + count_x<< endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:36:14: error: invalid use of member function 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size() const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]' (did you forget the '()' ?)
   36 |   rep(i,aori.size){
      |              ^
a.cc:4:45: note: in definition of macro 'rep'
    4 | #define rep(i, n) for (int i = 0; i < (int)(n); i++)
      |                                             ^
Language: C++

//QWsin
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define rep(i,x,y) for(int i=x;i<=y;++i)
#define out(i,u) for(int i=first[u];i!=-1;i=nxt[i])
#define repvc(i,vc) for(int i=0,Sz=vc.size();i<Sz;++i)
using namespace std;
inline int read()
{
	char ch=getchar();int ret=0,f=1;
	while(ch<'0' || ch>'9') {if(ch=='-')f=-1;ch=getchar();}
	for(;ch>='0' && ch<='9';ch=getchar()) ret=ret*10+ch-'0';
	return ret*f;
}

typedef long long ll;
const int INF=1<<30;

const int maxn=2000+10;

string res;

bool check(int pos,char *s)
{
	vector<int>tmp;
	for(int i=pos;i<(int)res.length();++i)
	{
		if(res[i]=='?') {res[i]=s[i-pos];tmp.push_back(i);}
		else if(s[i-pos]!='?' && res[i]!=s[i-pos]) {
			for(auto x: tmp) res[x]='?';
			return 0;	
		}
	}
	return 1;
}

void fill(int pos,char *s)
{
	int l=strlen(s);
	int resl=res.length();
	for(int i=resl;i<pos+l;++i)
		res+=s[i-pos];
}

int solve(char *a,char *b,char *c)
{
	int la=strlen(a);
	int lc=strlen(c);
	res.clear();
	res=string(a);
//	cout<<res<<endl;
	int pos1;
	rep(i,0,la){
		if(check(i,b)) {
			pos1=i;fill(i,b);break;
		}
	}
//	cout<<res<<endl;
	rep(i,pos1,(int)res.length()){
		if(check(i,c)) {
//			fill(i,c);
//			cout<<res<<endl;
//			puts("");
			return i+lc;
		}
	}
	
	return INF;
}

char s[3][maxn];
int id[5];


int main()
{
	rep(i,0,2) scanf("%s",s[i]);
	int ans=INF;
	rep(i,1,3) id[i]=i;
	do{
		char *t[5];
		rep(i,1,3) t[i]=s[id[i]-1];
		ans=min(ans,solve(t[1],t[2],t[3]));
	}while(next_permutation(id+1,id+3+1));
	cout<<ans<<endl;
	return 0;
}


Compiler output:
a.cc: In function 'bool check(int, char*)':
a.cc:27:9: error: 'vector' was not declared in this scope
   27 |         vector<int>tmp;
      |         ^~~~~~
a.cc:6:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    5 | #include<algorithm>
  +++ |+#include <vector>
    6 | #define rep(i,x,y) for(int i=x;i<=y;++i)
a.cc:27:16: error: expected primary-expression before 'int'
   27 |         vector<int>tmp;
      |                ^~~
a.cc:30:50: error: 'tmp' was not declared in this scope; did you mean 'tm'?
   30 |                 if(res[i]=='?') {res[i]=s[i-pos];tmp.push_back(i);}
      |                                                  ^~~
      |                                                  tm
a.cc:32:37: error: 'tmp' was not declared in this scope; did you mean 'tm'?
   32 |                         for(auto x: tmp) res[x]='?';
      |                                     ^~~
      |                                     tm
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)

#define int long long
//using ll = long long;
using P = pair<int,int>;

ostream &operator<<(ostream &os,const P &p){ return os << "(" << p.first << "," << p.second << ")"; }
template<class T>
ostream &operator<<(ostream &os,const vector<T> &v){
	for(int i = 0;i < v.size();i++) os << (i ? "," : "[") << v[i];
	os << "]";
	return os;
}

template<class T> T &chmin(T &a,const T &b){ return a = min(a,b); }
template<class T> T &chmax(T &a,const T &b){ return a = max(a,b); }

const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

signed main(){
	bool ok[3][3][2010] = {};
	string s[3];
	for(int i = 0;i < 3;i++) cin >> s[i];
	for(int i = 0;i < 3;i++){
		for(int j = 0;j < 3;j++){
			if(i == j) continue;
			for(int k = 0;k <= s[i].length();k++){
				ok[i][j][k] = true;
				for(int l = 0;k + l < s[i].length() && l < s[j].length();l++){
					if(s[i][k + l] != '?' && s[j][l] != '?' && s[i][k + l] != s[j][l]) ok[i][j][k] = false;
				}
			}
		}
	}
	int ans = INF;
	vector<int> vec = {0,1,2};
	do{
		for(int i = 0;i <= s[vec[0]].length();i++){
			for(int j = 0;j <= s[vec[1]].length();j++){
				if(ok[vec[0]][vec[1]][i] && ok[vec[1]][vec[2]][j] && (i + j <= s[vec[0]].length() ? ok[vec[0]][vec[2]][i + j] : true)){
					chmin(ans,i + j + s[vec[2]].length());
				}
			}
		}
	}while(next_permutation(all(vec)));
	cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:54:46: error: no matching function for call to 'chmin(long long int&, long long unsigned int)'
   54 |                                         chmin(ans,i + j + s[vec[2]].length());
      |                                         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:24:22: note: candidate: 'template<class T> T& chmin(T&, const T&)'
   24 | template<class T> T &chmin(T &a,const T &b){ return a = min(a,b); }
      |                      ^~~~~
a.cc:24:22: note:   template argument deduction/substitution failed:
a.cc:54:46: note:   deduced conflicting types for parameter 'const T' ('long long int' and 'long long unsigned int')
   54 |                                         chmin(ans,i + j + s[vec[2]].length());
      |                                         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int q;
    cin >> q;
    vector<ll> p(31, 1);
    for (int i = 0; i < 30; i++) {
        p[i + 1] = p[i] * 3;
    }
    while (q--) {
        ll a, b, c, d;
        cin >> a >> b >> c >> d;
        a--, b--, c--, d--;
        if (abs(b - d) < abs(a - c)) {
            swap(a, b);
            swap(c, d);
        }
        ll ans = abs(a - c) + abs(b - d);
        for (int i = 29; i >= 0; i--) {
            a %= p[i + 1];
            c %= p[i + 1];
            if (p[i] < abs(a - c) + 1 || abs(b - d) - 1 < p[i]) {
                continue;
            }
            if (min(a, c) < p[i] || p[i] * 2 <= max(a, c)) {
                continue;
            }
            int s = calc(i + 1, a, 0), t = calc(i + 1, c, p[i + 1] - 1);
            if (!eval(i, b, d)) {
                t = -1;
            }
            if (s == 1 && t == 7) {
                ll ls = p[i] - 1, rs = p[i] * 2;
                ans += min(abs(ls - a), abs(rs - c)) * 2;
                break;
            }
        }
        cout << ans << '\n';
    }
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:37:21: error: 'calc' was not declared in this scope
   37 |             int s = calc(i + 1, a, 0), t = calc(i + 1, c, p[i + 1] - 1);
      |                     ^~~~
a.cc:38:18: error: 'eval' was not declared in this scope
   38 |             if (!eval(i, b, d)) {
      |                  ^~~~
a.cc:39:17: error: 't' was not declared in this scope
   39 |                 t = -1;
      |                 ^
a.cc:41:27: error: 't' was not declared in this scope
   41 |             if (s == 1 && t == 7) {
      |                           ^
Language: C++

#include<iostream>
#include<cstdint>
#include<algorithm>

int64_t calc(int64_t a1, int64_t a2, int64_t b1, int64_t b2, int lv, int64_t L) {
  //if(lv == 0) return 0;
  if(lv == 1) return return std::abs(a1-b1)+std::abs(a2-b2);
  int64_t Lb = L/3;
  int64_t bi_a1 = a1/Lb;
  int64_t bi_a2 = a2/Lb;
  int64_t bi_b1 = b1/Lb;
  int64_t bi_b2 = b2/Lb;
  if(bi_a1 == bi_b1 && bi_a2 == bi_b2) {
    return calc(a1%Lb, a2%Lb, b1%Lb, b2%Lb, lv-1, Lb); // same block
  }
  if(bi_a2 == bi_b2) { std::swap(a1, a2); std::swap(b1, b2); }
  // bi_a2 != bi_b2
  while(Lb > 0) {
    bi_a1 = a1/Lb;
    bi_b1 = b1/Lb;
    if(bi_a1 != bi_b1) return std::abs(a1-b1) + std::abs(a2-b2);
    if(bi_a1 == 1 && std::abs(a2/Lb - b2/Lb) > 1) {
      int64_t r1 = a1 - (Lb-1) + b1 - (Lb-1);
      int64_t r2 = Lb*2 - a1 + Lb*2 - b1;
      return std::abs(a2-b2) + std::min(r1, r2); 
    }
    a1 %= Lb;
    b1 %= Lb;
    Lb /= 3;
  }
  return std::abs(a2 - b2);
}

int main() {
  int64_t L = 1;
  for(int i = 0; i < 30; ++i) L *= 3;
  int Q; std::cin >> Q;
  for(int i = 0; i < Q; ++i) {
    int64_t a, b, c, d; std::cin >> a >> b >> c >> d;
    std::cout << calc(a-1, b-1, c-1, d-1, 30, L) << std::endl;
  }
  return 0;
}


Compiler output:
a.cc: In function 'int64_t calc(int64_t, int64_t, int64_t, int64_t, int, int64_t)':
a.cc:7:22: error: expected primary-expression before 'return'
    7 |   if(lv == 1) return return std::abs(a1-b1)+std::abs(a2-b2);
      |                      ^~~~~~
a.cc:7:21: error: expected ';' before 'return'
    7 |   if(lv == 1) return return std::abs(a1-b1)+std::abs(a2-b2);
      |                     ^~~~~~~
      |                     ;
Language: C++

#include<iostream>
#include<cstdint>
#include<algorithm>

int64_t calc(int64_t a1, int64_t a2, int64_t b1, int64_t b2, int lv, int64_t L) {
  if(lv == 0) return 0;
  int64_t Lb = L/3;
  int64_t bi_a1 = a1/Lb;
  int64_t bi_a2 = a2/Lb;
  int64_t bi_b1 = b1/Lb;
  int64_t bi_b2 = b2/Lb;
  if(bi_a1 == bi_b1 && bi_a2 == bi_b2) {
    return calc(a1%Lb, a2%Lb, b1%Lb, b2%Lb, lv-1, Lb); // same block
  }
  if(bi_a2 == bi_b2) { std::swap(a1, a2); std::swap(b1, b2); }
  // bi_a2 != bi_b2
  while(Lb > 0) {
    bi_a1 = a1/Lb;
    bi_b1 = b1/Lb;
    if(bi_a1 != bi_b1) return std::abs(a1-b1) + std::abs(a2-b2);
    if(bi_a1 == 1 && std::abs(a2/Lb - b2/Lb) > 1) {
      //a1 %= Lb;
      //b1 %= Lb;
      //return std::abs(a2 - b2) + std::min(a1+b1+2, Lb*2-a1-b1);
      int64_t r1 = a1 - (Lb-1) + b1 - (Lb-1);
      int64_t r2 = Lb*2 - a1 + Lb*2 - b1;
      return std::abs( + std::min(r1, r2); 
    }
    a1 %= Lb;
    b1 %= Lb;
    Lb /= 3;
  }
  return std::abs(a2 - b2);
}

int main() {
  int64_t L = 1;
  for(int i = 0; i < 30; ++i) L *= 3;
  int Q; std::cin >> Q;
  for(int i = 0; i < Q; ++i) {
    int64_t a, b, c, d; std::cin >> a >> b >> c >> d;
    std::cout << calc(a-1, b-1, c-1, d-1, 30, L) << std::endl;
  }
  return 0;
}


Compiler output:
a.cc: In function 'int64_t calc(int64_t, int64_t, int64_t, int64_t, int, int64_t)':
a.cc:27:42: error: expected ')' before ';' token
   27 |       return std::abs( + std::min(r1, r2);
      |                      ~                   ^
      |                                          )
Language: C++


#include <cstdio>
#include <algorithm>
#define LL long long
using namespace std;
LL width[35];
LL cal(LL x1,LL y1,LL x2,LL y2,int level){
	LL w;
	if(level==0)return abs(y1-y2);
	w=width[level-1];
	if(x1/w!=x2/w)return abs(x1-x2)+abs(y1-y2);
	if(x1/w==1&&abs(y1/w-y2/w)>=2)
		return abs(y1-y2)+min(x1%w+1+x2%w+1,(w-x1%w)+(w-x2%w));
	return cal(x1%w,y1,x2%w,y2,level-1);
}
int main(){
	int i,q;
	width[0]=1;
	for(i=1;i<=29;i++)width[i]=width[i-1]*3;
	LL x1,y1,x2,y2;
  if( scanf( "%d", &q ) != 2 ) 
{
  
  // fprintf( stderr, "Expected at least two numbers as input\n");
   exit(1);
}

	scanf("%d",&q);
	while(q--){
		if(scanf("%lld%lld%lld%lld",&x1,&y1,&x2,&y2);!=2) { exit(1);}
		x1--,y1--,x2--,y2--;
		if(abs(x1-x2)>abs(y1-y2))swap(x1,y1),swap(x2,y2);
		printf("%lld\n",cal(x1,y1,x2,y2,30));
	}
	return 0;
}
 

Compiler output:
a.cc:37:1: error: extended character   is not valid in an identifier
   37 |  
      | ^
a.cc: In function 'int main()':
a.cc:30:62: error: expected primary-expression before '!=' token
   30 |                 if(scanf("%lld%lld%lld%lld",&x1,&y1,&x2,&y2);!=2) { exit(1);}
      |                                                              ^~
a.cc: At global scope:
a.cc:37:1: error: '\U000000a0' does not name a type
   37 |  
      | ^
Language: C++


#include <cstdio>
#include <algorithm>
#define LL long long
using namespace std;
LL width[35];
LL cal(LL x1,LL y1,LL x2,LL y2,int level){
	LL w;
	if(level==0)return abs(y1-y2);
	w=width[level-1];
	if(x1/w!=x2/w)return abs(x1-x2)+abs(y1-y2);
	if(x1/w==1&&abs(y1/w-y2/w)>=2)
		return abs(y1-y2)+min(x1%w+1+x2%w+1,(w-x1%w)+(w-x2%w));
	return cal(x1%w,y1,x2%w,y2,level-1);
}
int main(){
	int i,q;
	width[0]=1;
	for(i=1;i<=29;i++)width[i]=width[i-1]*3;
	LL x1,y1,x2,y2;
	scanf("%d",&q);
	while(q--){
		scanf("%lld%lld%lld%lld",&x1,&y1,&x2,&y2);
		x1--,y1--,x2--,y2--;
		if(abs(x1-x2)>abs(y1-y2))swap(x1,y1),swap(x2,y2);
		printf("%lld\n",cal(x1,y1,x2,y2,30));
	}
	return 0;
}
 

Compiler output:
a.cc:30:1: error: extended character   is not valid in an identifier
   30 |  
      | ^
a.cc:30:1: error: '\U000000a0' does not name a type
   30 |  
      | ^