ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2050C - Uninteresting Number
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 3):
#include<bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin>>t;
    while(t--){
        long long int n;
        cin>>n;
        if(n % 9 == 0){
            cout<<"YES"<<endl;
            continue;
        }
        long long int sum = 0;
        long long int a = n;
        long long int two = 0, three = 0;
        while(a > 0){
            long long int digit = a%10;
            sum += digit;
            if(digit == 2) two++;
            else if(digit == 3) three++;
            a/=10;
        }
        if(two == 0 && three == 0){
            cout<<"NO"<<endl;
            continue;
        }
        int f = 0;
        if(two > 8) two = 8;
        if(three > 8) three = 8;
        for(int i = 0; i<=two; i++){
            for(int j = 0; j<=three; j++){
                if((sum + i*2 + j*6)% 9 == 0){
                    f = 1;
                    break;
                }
            }
        }
        if(f) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
}

Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;

void solve() {
    string input;
    cin >> input;

    int sm = 0, twos = 0, threes = 0;

    // Calculate sum of digits, count of 2s and 3s
    for (char c : input) {
        int digit = c - '0';
        sm += digit;
        if (digit == 2) twos++;
        if (digit == 3) threes++;
    }
    // Check possible combinations of added 2s and 3s
    for (int i = 0; i <= twos; i++) {
        for (int j = 0; j <= threes; j++) {
            if ((sm + i * 2 + j * 6) % 9 == 0) {
                cout << "YES" << endl;
                return;
            }
        }
    }

    cout << "NO" << endl;
}

int main() {
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}
Problem: 2050C - Uninteresting Number
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin>>t;
    while(t--){
        long long int n;
        cin>>n;
        if(n % 9 == 0){
            cout<<"YES"<<endl;
            continue;
        }
        long long int sum = 0;
        long long int a = n;
        long long int two = 0, three = 0;
        while(a > 0){
            long long int digit = a%10;
            sum += digit;
            if(digit == 2) two++;
            else if(digit == 3) three++;
            a/=10;
        }
        if(two == 0 && three == 0){
            cout<<"NO"<<endl;
            continue;
        }
        int f = 0;
        n = n % 9;
        int k = 1;
        while(two > 0 || three > 0){
            int number = (9 * k);
            if((number - n) % 2 == 0 && (number - n)/2 <= two){
                f = 1;
                break;
            }
            if((number - n) % 6 == 0 && (number - n)/6 <= three){
                f = 1;
                break;
            }
            if((number - n) % 8 == 0 && two > 0 && three > 0){
                f = 1;
                break;
            }
            else if(two > 0 && three > 0){
                n += 8;
                two--;
                three--;
            }
            while(n < number && three > 0){
                n += 6;
                three--;
            }
            while(n < number && two > 0){
                n += 2;
                two--;
            }
            k++;
        }
        if(f) cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
}
Problem: 2050D - Digital string maximization
Language: Python 3

Previous submission (verdict: Wrong answer on test 1):
def solve():

s = list(input())

n = len(s)

while True:

changed = False

for i in range(1, n):

if s[i] != '0' and int(s[i]) - 1 > int(s[i-1]):

s[i] = str(int(s[i]) - 1)

s[i-1] = str(int(s[i-1]) + 1)

changed = True

if not changed:

break

print("".join(s))



t = int(input())

for _ in range(t):

solve()

Submission (verdict: Wrong answer on test 1):
def solve():

s = list(input())

n = len(s)

while True:

changed = False

for i in range(1, n):

if s[i] != '0' and int(s[i]) - 1 > int(s[i-1]):

s[i] = str(int(s[i-1]))

s[i-1] = str(int(s[i]) - 1)

changed = True

if not changed:

break

print("".join(s))



t = int(input())

for _ in range(t):

solve()
Problem: 2050D - Digital string maximization
Language: Python 3

Previous submission (verdict: Runtime error on test 1):
for _ in range(int(input())):

s = input()

n = len(s)

prev = int(s)

prev2 =0

while(prev>prev2):

for i in range(1,n):

if s[i]!="0" and int(s[i])-1>int(s[i-1]):

s[i-1],s[i]= s[i]-1,s[i-1]

prev2 = prev

prev = max(prev,int(s))

print(prev)





Submission (verdict: Wrong answer on test 1):
def solve():

s = list(input())

n = len(s)

while True:

changed = False

for i in range(1, n):

if s[i] != '0' and int(s[i]) - 1 > int(s[i-1]):

s[i] = str(int(s[i]) - 1)

s[i-1] = str(int(s[i-1]) + 1)

changed = True

if not changed:

break

print("".join(s))



t = int(input())

for _ in range(t):

solve()
Problem: 2050D - Digital string maximization
Language: Python 3


Submission (verdict: Runtime error on test 1):
for _ in range(int(input())):

s = input()

n = len(s)

prev = int(s)

prev2 =0

while(prev>prev2):

for i in range(1,n):

if s[i]!="0" and int(s[i])-1>int(s[i-1]):

s[i-1],s[i]= s[i]-1,s[i-1]

prev2 = prev

prev = max(prev,int(s))

print(prev)
Problem: 2050D - Digital string maximization
Language: Python 3

Previous submission (verdict: Wrong answer on test 1):
def solve():

s = list(input())

n = len(s)

while True:

changed = False

for i in range(1, n):

if s[i] != '0' and int(s[i]) - 1 > int(s[i-1]):

s[i] = str(int(s[i-1]))

s[i-1] = str(int(s[i]) - 1)

changed = True

if not changed:

break

print("".join(s))



t = int(input())

for _ in range(t):

solve()

Submission (verdict: Accepted):
def solve():

s = list(input())

n = len(s)

while True:

changed = False

for i in range(1, n):

if s[i] != '0' and int(s[i]) - 1 > int(s[i-1]):

num = int(s[i])

s[i] = str(int(s[i-1]))

s[i-1] = str(num - 1)

changed = True

if not changed:

break

print("".join(s))



t = int(input())

for _ in range(t):

solve()
Problem: 2057B - Gorilla and the Exam
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>

using namespace std;

int main() {
	int t;
	cin>>t;
	while(t>0) {
		int n,k;
		cin>>n>>k;
		vector<int> v;
		set<int> st;
		for(int i=0;i<n;i++) {
			 int x;cin>>x;
			 v.push_back(x);
			 st.insert(x);
		}
		if(k==0) {
			cout<<st.size()<<endl;
		}
		else if(k==n) {
			cout<<1<<endl;
		}
		else {
			sort(v.begin(),v.end());
			int k1=k;
			set<int> uqp;
			int unqp=0;
			if(v[k1-1]==v[k1]) {unqp--;}
			while(k1>0) {
				uqp.insert(v[k1-1]); k1--;
			}	
			unqp+=uqp.size();
			k1=n-k;
			set<int> uqs;
			int unqs=0;
			if(v[k1+1]==v[k1]) {unqs--;}
			while(k1<n) {
				uqs.insert(v[k1]); k1++;
			}
			unqs+=uqs.size();
			cout<<st.size()-(max(unqp,unqs))<<endl;
		}
		t--;
	}
}
Problem: 2057B - Gorilla and the Exam
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
 #include <bits/stdc++.h>

using namespace std;

int main() {
	int t;
	cin>>t;
	while(t>0) {
		int n,k;
		cin>>n>>k;
		vector<int> v;
		map<int,int> st;
		for(int i=0;i<n;i++) {
			 int x;cin>>x;
			 v.push_back(x);
			 st[x]++;
		}
		if(k==0) {
			cout<<st.size()<<endl;
		}
		else if(k==n) {
			cout<<1<<endl;
		}
		else {
			int ans= st.size();
			vector<int> v;
			for(auto it:st) {
				v.push_back(it.second);
			}
			sort(v.begin(),v.end());
			int i=0;
			while(k>0 && i<n) {
				if(v[i]<=k) {k-=v[i]; ans--;}
				i++;
			}
			cout<<ans<<endl;
		}
		t--;
	}
}

Submission (verdict: Accepted):
 #include <bits/stdc++.h>

using namespace std;

int main() {
	int t;
	cin>>t;
	while(t>0) {
		int n,k;
		cin>>n>>k;
		vector<int> v;
		map<int,int> st;
		for(int i=0;i<n;i++) {
			 int x;cin>>x;
			 v.push_back(x);
			 st[x]++;
		}
		if(k==0) {
			cout<<st.size()<<endl;
		}
		else if(k==n) {
			cout<<1<<endl;
		}
		else {
			int ans= st.size();
			vector<int> v;
			for(auto it:st) {
				v.push_back(it.second);
			}
			sort(v.begin(),v.end());
			int i=0;
			int m= v.size();
			while(k>0 && i<m) {
				if(v[i]<=k) {k-=v[i]; ans--;}
				i++;
			}
			cout<<ans<<endl;
		}
		t--;
	}
}
Problem: 2057B - Gorilla and the Exam
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>

using namespace std;

int main() {
	int t;
	cin>>t;
	while(t>0) {
		int n,k;
		cin>>n>>k;
		vector<int> v;
		set<int> st;
		for(int i=0;i<n;i++) {
			 int x;cin>>x;
			 v.push_back(x);
			 st.insert(x);
		}
		if(k==0) {
			cout<<st.size()<<endl;
		}
		else if(k==n) {
			cout<<1<<endl;
		}
		else {
			sort(v.begin(),v.end());
			int k1=k;
			set<int> uqp;
			int unqp=0;
			if(v[k1-1]==v[k1]) {unqp--;}
			while(k1>0) {
				uqp.insert(v[k1-1]); k1--;
			}	
			unqp+=uqp.size();
			k1=n-k;
			set<int> uqs;
			int unqs=0;
			if(v[k1+1]==v[k1]) {unqs--;}
			while(k1<n) {
				uqs.insert(v[k1]); k1++;
			}
			unqs+=uqs.size();
			cout<<st.size()-(max(unqp,unqs))<<endl;
		}
		t--;
	}
}

Submission (verdict: Wrong answer on test 2):
 #include <bits/stdc++.h>

using namespace std;

int main() {
	int t;
	cin>>t;
	while(t>0) {
		int n,k;
		cin>>n>>k;
		vector<int> v;
		set<int> st;
		for(int i=0;i<n;i++) {
			 int x;cin>>x;
			 v.push_back(x);
			 st.insert(x);
		}
		if(k==0) {
			cout<<st.size()<<endl;
		}
		else if(k==n) {
			cout<<1<<endl;
		}
		else {
			sort(v.begin(),v.end());
			int k1=k;
			set<int> uqp;
			int unqp=0;
			if(v[k1-1]==v[k1]) {unqp--;}
			while(k1>0) {
				uqp.insert(v[k1-1]); k1--;
			}	
			unqp+=uqp.size();
			// cout<<"unqp "<<unqp<<endl;
			k1=n-k;
			set<int> uqs;
			int unqs=0;
			if(v[k1-1]==v[k1]) {unqs--;}
			while(k1<n) {
				uqs.insert(v[k1]); k1++;
			}
			unqs+=uqs.size();
			// cout<<"unqs "<<unqs<<endl;
			cout<<st.size()-(max(unqp,unqs))<<endl;
		}
		t--;
	}
}
Problem: 2057B - Gorilla and the Exam
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
 #include <bits/stdc++.h>

using namespace std;

int main() {
	int t;
	cin>>t;
	while(t>0) {
		int n,k;
		cin>>n>>k;
		vector<int> v;
		set<int> st;
		for(int i=0;i<n;i++) {
			 int x;cin>>x;
			 v.push_back(x);
			 st.insert(x);
		}
		if(k==0) {
			cout<<st.size()<<endl;
		}
		else if(k==n) {
			cout<<1<<endl;
		}
		else {
			sort(v.begin(),v.end());
			int k1=k;
			set<int> uqp;
			int unqp=0;
			if(v[k1-1]==v[k1]) {unqp--;}
			while(k1>0) {
				uqp.insert(v[k1-1]); k1--;
			}	
			unqp+=uqp.size();
			// cout<<"unqp "<<unqp<<endl;
			k1=n-k;
			set<int> uqs;
			int unqs=0;
			if(v[k1-1]==v[k1]) {unqs--;}
			while(k1<n) {
				uqs.insert(v[k1]); k1++;
			}
			unqs+=uqs.size();
			// cout<<"unqs "<<unqs<<endl;
			cout<<st.size()-(max(unqp,unqs))<<endl;
		}
		t--;
	}
}

Submission (verdict: Wrong answer on test 2):
 #include <bits/stdc++.h>

using namespace std;

int main() {
	int t;
	cin>>t;
	while(t>0) {
		int n,k;
		cin>>n>>k;
		vector<int> v;
		map<int,int> st;
		for(int i=0;i<n;i++) {
			 int x;cin>>x;
			 v.push_back(x);
			 st[x]++;
		}
		if(k==0) {
			cout<<st.size()<<endl;
		}
		else if(k==n) {
			cout<<1<<endl;
		}
		else {
			int ans= st.size();
			vector<int> v;
			for(auto it:st) {
				v.push_back(it.second);
			}
			sort(v.begin(),v.end());
			int i=0;
			while(k>0 && i<n) {
				if(v[i]<=k) {k-=v[i]; ans--;}
				i++;
			}
			cout<<ans<<endl;
		}
		t--;
	}
}
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
#include <iostream>
using namespace std;

int main() {
    int t;
    cin >> t;
    while (t--) {
        long long l, r;
        cin >> l >> r;
        if (r - l >= 2) {
            if (l % 2 == 0)
                cout << l << " " << l + 1 << " " << l + 2 << "\n";
            else
                cout << l + 1 << " " << l + 2 << " " << l + 3 << "\n";
        } else {
            cout << -1 << "\n";
        }
    }
    return 0;
}


Submission (verdict: Wrong answer on test 1):
#include <iostream>
using namespace std;

int main() {
    int t;
    cin >> t;
    while (t--) {
        long long l, r;
        cin >> l >> r;
        if (r - l >= 2) {
            if ((r ^ (r - 1)) + ((r - 1) ^ (r - 2)) + (r ^ (r - 2)) > 
                (l ^ (l + 1)) + ((l + 1) ^ (l + 2)) + (l ^ (l + 2))) {
                cout << r - 2 << " " << r - 1 << " " << r << "\n";
            } else {
                cout << l << " " << l + 1 << " " << l + 2 << "\n";
            }
        } else {
            cout << -1 << "\n";
        }
    }
    return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
#include <iostream>
using namespace std;

int main() {
    int t;
    cin >> t;
    while (t--) {
        long long l, r;
        cin >> l >> r;
        if (r - l >= 2) {
            if ((r ^ (r - 1)) + ((r - 1) ^ (r - 2)) + (r ^ (r - 2)) > 
                (l ^ (l + 1)) + ((l + 1) ^ (l + 2)) + (l ^ (l + 2))) {
                cout << r - 2 << " " << r - 1 << " " << r << "\n";
            } else {
                cout << l << " " << l + 1 << " " << l + 2 << "\n";
            }
        } else {
            cout << -1 << "\n";
        }
    }
    return 0;
}


Submission (verdict: Accepted):
#include<bits/stdc++.h>
using namespace std;
int t,l,r,ans;
int main(){
	cin>>t;
	while(t--){
		scanf("%d%d",&l,&r);
		for(int i=29;i>=0;i--){
			if((l&(1<<i))^(r&(1<<i))){
				ans=r&((1<<30)-(1<<i));
				break;
			}
		}
		printf("%d %d %d\n",ans,ans-1,ans==r?l:r);
	}
	return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 1):
#include <iostream>
using namespace std;

int main() {
    int t;
    cin >> t;
    while (t--) {
        long long l, r;
        cin >> l >> r;
        if (r - l >= 2) {
            if (l % 2 == 0)
                cout << l << " " << l + 1 << " " << l + 2 << "\n";
            else
                cout << l + 1 << " " << l + 2 << " " << l + 3 << "\n";
        } else {
            cout << -1 << "\n";
        }
    }
    return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>

using namespace std;

#define int int64_t
#define ar array

void solve() {
    int l,r; cin >> l >> r;
    int k = -1;
    for (int i = 0; i <= 30; i++) {
        if ((l^r)>>i & 1) k = i;
    }
    int x = r & (1 << 31 - 1 << k);
    if (r = x) cout << l << ' ' << x << ' ' << x-1 << '\n';
    else if (l == x) cout << r << ' ' << x << ' ' << x-1 << '\n';
}

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int t = 1; cin >> t;
    while (t--) {
        solve();
    }
}

Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>

using namespace std;

#define int int64_t
#define ar array

void solve() {
    int l,r; cin >> l >> r;
    int k = 0;
    for (int i = 1; i <= 30; i++) {
        if (((l^r)>>i) & 1) k = i-1;
    }
    int x = r & ((1 << 31) - (1 << k));
    if (r == x) cout << l << ' ' << x << ' ' << x-1 << '\n';
    else cout << r << ' ' << x << ' ' << x-1 << '\n';
}

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int t = 1; cin >> t;
    while (t--) {
        solve();
    }
}
Problem: 2057C - Trip to the Olympiad
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>

using namespace std;

#define int int64_t
#define ar array

void solve() {
    int l,r; cin >> l >> r;
    int k = 0;
    for (int i = 1; i <= 30; i++) {
        if (((l^r)>>i) & 1) k = i-1;
    }
    int x = r & ((1 << 31) - (1 << k));
    if (r == x) cout << l << ' ' << x << ' ' << x-1 << '\n';
    else cout << r << ' ' << x << ' ' << x-1 << '\n';
}

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int t = 1; cin >> t;
    while (t--) {
        solve();
    }
}

Submission (verdict: Accepted):
#include <bits/stdc++.h>

using namespace std;

#define int int64_t
#define ar array

void solve() {
    int l,r; cin >> l >> r;
    int k = 0;
    for (int i = 0; i <= 30; i++) {
        if (((l^r)>>i) & 1) k = i;
    }
    int x = r & ((1 << 31) - (1 << k));
    if (r == x) cout << l << ' ' << x << ' ' << x-1 << '\n';
    else cout << r << ' ' << x << ' ' << x-1 << '\n';
}

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int t = 1; cin >> t;
    while (t--) {
        solve();
    }
}
Problem: 2057C - Trip to the Olympiad
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>

using namespace std;

#define int int64_t
#define ar array

void solve() {
    int l,r; cin >> l >> r;
    int k = -1;
    for (int i = 0; i <= 30; i++) {
        if ((l^r)>>i & 1) k = i;
    }
    int x = r & (1 << 31 - 1 << k);
    if (r = x) cout << l << ' ' << x << ' ' << x-1 << '\n';
    else if (l == x) cout << r << ' ' << x << ' ' << x-1 << '\n';
}

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int t = 1; cin >> t;
    while (t--) {
        solve();
    }
}
Problem: 2057C - Trip to the Olympiad
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 1):

#include "bits/stdc++.h"
#define int long long
#define uint unsigned long long
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define fr(i,n) for(int i=0; i<(n); i++)
#define fr1(i,n) for(int i=1;i<=n;i++)
#define rep(i,a,n) for(int i=(a); i<=(n); i++)
#define nl cout<<"\n"
#define dbg(var) cout<<#var<<"="<<var<<" "
#define all(v) v.begin(),v.end()
#define sz(v) (int)(v.size())
#define srt(v)  sort(v.begin(),v.end())
#define mxe(v)  *max_element(v.begin(),v.end())
#define mne(v)  *min_element(v.begin(),v.end())
#define unq(v)  v.resize(distance(v.begin(), unique(v.begin(), v.end())));
// make sure to sort before applying unique // else only consecutive duplicates would be removed
#define bin(x,y)  bitset<y>(x)
using namespace std;
int MOD=1e9+7;      // Hardcoded, directly change from here for functions!
const int mod2=998244353;
void modadd(int &a , int b) {a=((a%MOD)+(b%MOD))%MOD;}
void modsub(int &a , int b) {a=((a%MOD)-(b%MOD)+MOD)%MOD;}
void modmul(int &a , int b) {a=((a%MOD)*(b%MOD))%MOD;}
// ================================== take ip/op lik1000

template<typename typC,typename typD> istream &operator>>(istream &cin,pair<typC,typD> &a) { return cin>>a.first>>a.second; }
template<typename typC> istream &operator>>(istream &cin,vector<typC> &a) { for (auto &x:a) cin>>x; return cin; }
template<typename typC,typename typD> ostream &operator<<(ostream &cout,const pair<typC,typD> &a) { return cout<<a.first<<' '<<a.second; }
template<typename typC,typename typD> ostream &operator<<(ostream &cout,const vector<pair<typC,typD>> &a) { for (auto &x:a) cout<<x<<'\n'; return cout; }
template<typename typC> ostream &operator<<(ostream &cout,const vector<typC> &a) { int n=a.size(); if (!n) return cout; cout<<a[0]; for (int i=1; i<n; i++) cout<<' '<<a[i]; return cout; }
// ===================================END Of the input module ==========================================

void solve()
{
   int l,r;cin>>l>>r;
   int len=r-l+1;
   if(len==3)
   {
       cout<<l<<" "<<l+1<<" "<<r<<endl;
       return;
   }
   int a=r;
   int b=r-1;
   int c=l;
   cout<<a<<" "<<b<<" "<<c<<endl;
}
  
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   
    int t;cin>>t;
    while(t--)
    {
      solve();
    }
     
    
     
    
   
    return 0;
}
Problem: 2050E - Three Strings
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;

typedef long long int lli;
const int modd = 1e9 + 7;

#define int long long
#define F first
#define S second
#define pb push_back
#define ppb pop_back
#define all(x) begin(x), end(x)
#define allr(x) rbegin(x), rend(x)
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define bac(i, a, b) for (int i = a; i >= b; i--)
#define yes "YES"
#define no "NO"
#define nl " \n"
#define ak(x) cout << x << "\n";
#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
template <class T>using max_heap = priority_queue<T>;
template <class T>using min_heap = priority_queue<T, vector<T>, greater<T>>;


void solve(){
	
}


int32_t main(){
	fastio();
#ifndef ONLINE_JUDGE
  // for getting input from input.txt
  freopen("input.txt", "r", stdin);
  // for writing output to output.txt
  freopen("output.txt", "w", stdout);
#endif

	int t = 1;
	cin >> t;

	while (t--){
		solve();
	}
}

Submission (verdict: Memory limit exceeded on test 14):
#include <bits/stdc++.h>
using namespace std;

typedef long long int lli;
const int modd = 1e9 + 7;

#define int long long
#define F first
#define S second
#define pb push_back
#define ppb pop_back
#define all(x) begin(x), end(x)
#define allr(x) rbegin(x), rend(x)
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define bac(i, a, b) for (int i = a; i >= b; i--)
#define yes "YES"
#define no "NO"
#define nl " \n"
#define ak(x) cout << x << "\n";
#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
template <class T>using max_heap = priority_queue<T>;
template <class T>using min_heap = priority_queue<T, vector<T>, greater<T>>;


int solve(int l,int m,int n,string &a,string &b,string &c,vector<vector<vector<int>>>&dp){
	if(n==0) return 0;
	if(l == 0){
		// cout<<"AK:"<<"M:"<<m<<" N:"<<n<<nl;
		int cnt=0;
		for(int i=0;i<n;i++){
			if(b[i] != c[i]) cnt++;
		}
		return cnt;
	}
	if(m == 0){
		// cout<<"AK:"<<"L:"<<l<<" N:"<<n<<nl;
		int cnt=0;
		for(int i=0;i<n;i++){
			if(a[i] != c[i]) cnt++;
		}
		return cnt;
	}

	if(dp[l][m][n] != -1) return dp[l][m][n];

	if(a[l-1] == c[n-1] && b[m-1] == c[n-1]){
		return dp[l][m][n] = min(solve(l-1,m,n-1,a,b,c,dp),solve(l,m-1,n-1,a,b,c,dp));
	}
	if(a[l-1] == c[n-1]){
		return dp[l][m][n] = min(solve(l-1,m,n-1,a,b,c,dp),1+solve(l,m-1,n-1,a,b,c,dp));
	}
	if(b[m-1] == c[n-1]){
		return dp[l][m][n] = min(solve(l,m-1,n-1,a,b,c,dp),1+solve(l-1,m,n-1,a,b,c,dp));
	}
	else {
		// not matches with anyone then skip it
		return dp[l][m][n] = 1 + min(solve(l-1,m,n-1,a,b,c,dp),solve(l,m-1,n-1,a,b,c,dp));
	}
}

void solve(){
	string a,b,c; cin>>a>>b>>c;

	int l=a.size();
	int m=b.size();
	int n=c.size();
	vector<vector<vector<int>>>dp(l+1,vector<vector<int>>(m+1,vector<int>(n+1,-1)));
	cout<<solve(l,m,n,a,b,c,dp)<<nl;
}


int32_t main(){
	fastio();
#ifndef ONLINE_JUDGE
  // for getting input from input.txt
  freopen("input.txt", "r", stdin);
  // for writing output to output.txt
  freopen("output.txt", "w", stdout);
#endif

	int t = 1;
	cin >> t;

	while (t--){
		solve();
	}
}
Problem: 2050E - Three Strings
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;

typedef long long int lli;
const int modd = 1e9 + 7;

#define int long long
#define F first
#define S second
#define pb push_back
#define ppb pop_back
#define all(x) begin(x), end(x)
#define allr(x) rbegin(x), rend(x)
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define bac(i, a, b) for (int i = a; i >= b; i--)
#define yes "YES"
#define no "NO"
#define nl " \n"
#define ak(x) cout << x << "\n";
#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
template <class T>using max_heap = priority_queue<T>;
template <class T>using min_heap = priority_queue<T, vector<T>, greater<T>>;


void solve(){
	
}


int32_t main(){
	fastio();
#ifndef ONLINE_JUDGE
  // for getting input from input.txt
  freopen("input.txt", "r", stdin);
  // for writing output to output.txt
  freopen("output.txt", "w", stdout);
#endif

	int t = 1;
	cin >> t;

	while (t--){
		solve();
	}
}