ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2057C - Trip to the Olympiad
Language: C++23 (GCC 14-64, msys2)

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

int main() {
	int t, l, r;
	cin >> t;
	while (t--) {
		cin >> l >> r;
		int a = 1 << ((int)log2(r));
		int b = (a - 1 >= l ? a - 1 : a + 1);
		int c = (a == r ? l : r);
		cout << a << ' ' << b << ' ' << c << endl;
	}
	return 0;
}

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

int main() {
	int t, l, r;
	cin >> t;
	while (t--) {
		cin >> l >> r;
		int a = 1 << ((int)log2(r));
		if (a == l) {
			a = (1 << ((int)log2(r ^ l))) + l;
		}
		int b = a - 1;
		int c = (a == r ? l : r);
		cout << a << ' ' << b << ' ' << c << endl;
	}
	return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++23 (GCC 14-64, msys2)


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

int main() {
	int t, l, r;
	cin >> t;
	while (t--) {
		cin >> l >> r;
		int a = 1 << ((int)log2(r));
		int b = a - 1;
		int c = (a == r ? l : r);
		cout << a << ' ' << b << ' ' << c << endl;
	}
	return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++23 (GCC 14-64, msys2)

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

int main() {
	int t, l, r;
	cin >> t;
	while (t--) {
		cin >> l >> r;
		int a = 1 << ((int)log2(r));
		int b = a - 1;
		int c = (a == r ? l : r);
		cout << a << ' ' << b << ' ' << c << endl;
	}
	return 0;
}

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

int main() {
	int t, l, r;
	cin >> t;
	while (t--) {
		cin >> l >> r;
		int a = 1 << ((int)log2(r));
		int b = (a - 1 >= l ? a - 1 : a + 1);
		int c = (a == r ? l : r);
		cout << a << ' ' << b << ' ' << c << endl;
	}
	return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++23 (GCC 14-64, msys2)

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

int main() {
	int t, l, r;
	cin >> t;
	while (t--) {
		cin >> l >> r;
		int a = 1 << ((int)log2(r));
		if (a == l) {
			a = (1 << ((int)log2(r ^ l))) + l;
		}
		int b = a - 1;
		int c = (a == r ? l : r);
		cout << a << ' ' << b << ' ' << c << endl;
	}
	return 0;
}

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

int main() {
	int t, l, r;
	cin >> t;
	while (t--) {
		cin >> l >> r;
		int a = l | ((1 << (int)(log2(l ^ r))) - 1);
		int b = a + 1;
		int c = (b == r ? l : r);
		cout << a << ' ' << b << ' ' << c << endl;
	}
	return 0;
}
Problem: 2063C - Remove Exactly Two
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 2):
#include <iostream>
#include <vector>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <cstring>
#include <iomanip>
#include <climits>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <random>
#include <numeric>
  
using namespace std;
  
typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef vector<vector<ll>> vvll;
typedef vector<pair<ll, ll>> vpll;
typedef vector<vector<pair<ll, ll>>> vvpll;
typedef pair<ll, pair<ll, ll>> SuperPair;
  
const ll INF = 1e18;
  
#define _MATH_DEFINES_DEFINED
  
#define MP make_pair
#define pb push_back
#define printl cout << "\n";
#define dprintl cout << endl;
#define loop(x, n) for (ll x = 0; x < n; x++)
#define range(x, l, r) for (ll x = l; x < r; x++)
#define show(a) cout << (a) << "\n";
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define con cout << "NO\n"
#define coy cout << "YES\n";
#define max_el max_element
#define min_el min_element
#define stf shrink_to_fit
  
template<typename T>
void input(vector<T> &mas) {
  loop(i, mas.size()) {
    cin >> mas[i];
  }
}
  
template<typename T>
void output(vector<T> &mas) {
  loop(i, mas.size()) {
    cout << mas[i] << " ";
  }
  printl;
}
  
template<typename T>
void waste_read(ll n) {
  T ignore;
  for (ll i = 0; i < n; i++) cin >> ignore;
}
  
ll to_number(char c) {
  return (ll)c - (ll)'a' + 1;
}
  
char to_char(ll x) {
  return (char)(x + (ll)'a' - 1);
}
  
ll labs(ll n) {
  return (n < 0) ? -n : n;
}
  
ll lmin(ll a, ll b) {
  return (a < b) ? a : b;
}
  
ll lmax(ll a, ll b) {
  return (a > b) ? a : b;
}
  
ll lmod(ll a, ll b) {
  return ((a % b) + b) % b;
}

vvll graph;
vll used;
ll ans;

void dfs(ll node, ll prev_val, bool are_connected) {
  // UPDATE
  if (are_connected == true) {
    ans = lmax(ans, prev_val + graph[node].size() - 2);
  } else {
    ans = lmax(ans, prev_val + graph[node].size() - 1);
  }

  // cout << "new answer : " << graph[node].size() << endl;

  // CALCULATE
  used[node] = true;
  for (ll v : graph[node]) {
    if (!used[v]) {
      bool iscon = false;
      ll pass_value = prev_val;
      if (graph[node].size() < prev_val) {
        iscon = true;
        pass_value = graph[node].size();
      }
      dfs(v, pass_value, iscon);
    }
  }
}

signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  ll t;
  cin >> t;
  while (t--) {
    ll n;
    cin >> n;
    graph.resize(n);
    used.resize(n);
    loop(i, n - 1) {
      ll u, v;
      cin >> u >> v;
      graph[u - 1].push_back(v - 1);
      graph[v - 1].push_back(u - 1);
    }
    ans = -INF;

    used[0] = true;
    for (ll v : graph[0]) {
      dfs(v, graph[0].size(), true);
    }

    show(ans);

    // RELOAD
    graph.clear();
    used.clear();
  }
  return 0;
}
Problem: 2050D - Digital string maximization
Language: C++23 (GCC 14-64, msys2)

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

using namespace std;

long long t;

string s;

void solve(){

    cin>>s;

    string kq;

    int n=s.size();

    for(int i=0; i<n; i++){

        int maxn=s[i];

        for(int j=i+1; j<min(n,i+9); j++){

            maxn=max(maxn,s[j]-(j-i));

        }

        if(maxn==s[i]) continue;

        for(int j=i+1; j<min(n,i+9); j++){

            if(s[j]-(j-i)==maxn){

                s[j]-=(j-i);

                swap(s[j],s[i]);

                if(j!=i+1) swap(s[j],s[j-1]);

                break;

            }

        }

    }

    cout<<s<<'\n';

}

int main(){

    ios_base::sync_with_stdio(0);

    cin.tie(0); cout.tie(0);

    // freopen(".inp", "r", stdin);

    // freopen(".out", "w", stdout);

    cin>>t;

    while(t--){

        solve();

    }

}

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

using namespace std;

long long t;

string s;

void solve(){

    cin>>s;

    string kq;

    int n=s.size();

    for(int i=0; i<n; i++){

        int maxn=s[i];

        for(int j=i+1; j<min(n,i+9); j++){

            maxn=max(maxn,s[j]-(j-i));

        }

        if(maxn==s[i]) continue;

        for(int j=i+1; j<min(n,i+9); j++){

            if(s[j]-(j-i)==maxn){

                for(int k=j-1; k>=i; k--){

                    s[k+1]--;

                    swap(s[k],s[k+1]);

                }

                break;

            }

        }

    }

    cout<<s<<'\n';

}

int main(){

    ios_base::sync_with_stdio(0);

    cin.tie(0); cout.tie(0);

    // freopen(".inp", "r", stdin);

    // freopen(".out", "w", stdout);

    cin>>t;

    while(t--){

        solve();

    }

}
Problem: 2050D - Digital string maximization
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Time limit exceeded on test 6):
#include <bits/stdc++.h>

using namespace std;

long long t;

string s;

void solve(){

    cin>>s;

    string kq;

    for(int i=0; i<s.size(); i++){

        int maxn=s[i];

        for(int j=i+1; j<s.size(); j++){

            maxn=max(maxn,s[j]-(j-i));

        }

        if(maxn==s[i]) continue;

        for(int j=i+1; j<s.size(); j++){

            if(s[j]-(j-i)==maxn){

                for(int k=j-1; k>=i; k--){

                    s[k+1]--;

                    swap(s[k],s[k+1]);

                }

                break;

            }

        }

    }

    cout<<s<<'\n';

}

int main(){

    ios_base::sync_with_stdio(0);

    cin.tie(0); cout.tie(0);

    // freopen(".inp", "r", stdin);

    // freopen(".out", "w", stdout);

    cin>>t;

    while(t--){

        solve();

    }

}

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

using namespace std;

long long t;

string s;

void solve(){

    cin>>s;

    string kq;

    int n=s.size();

    for(int i=0; i<n; i++){

        int maxn=s[i];

        for(int j=i+1; j<min(n,i+9); j++){

            maxn=max(maxn,s[j]-(j-i));

        }

        if(maxn==s[i]) continue;

        for(int j=i+1; j<min(n,i+9); j++){

            if(s[j]-(j-i)==maxn){

                s[j]-=(j-i);

                swap(s[j],s[i]);

                if(j!=i+1) swap(s[j],s[j-1]);

                break;

            }

        }

    }

    cout<<s<<'\n';

}

int main(){

    ios_base::sync_with_stdio(0);

    cin.tie(0); cout.tie(0);

    // freopen(".inp", "r", stdin);

    // freopen(".out", "w", stdout);

    cin>>t;

    while(t--){

        solve();

    }

}
Problem: 2050D - Digital string maximization
Language: C++23 (GCC 14-64, msys2)


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

using namespace std;

long long t;

string s;

void solve(){

    cin>>s;

    string kq;

    for(int i=0; i<s.size(); i++){

        int maxn=s[i];

        for(int j=i+1; j<s.size(); j++){

            maxn=max(maxn,s[j]-(j-i));

        }

        for(int j=i+1; j<s.size(); j++){

            if(s[j]-(j-i)==maxn){

                for(int k=j-1; k>=i; k--){

                    s[k+1]--;

                    swap(s[k],s[k+1]);

                }

                break;

            }

        }

    }

    cout<<s<<'\n';

}

int main(){

    ios_base::sync_with_stdio(0);

    cin.tie(0); cout.tie(0);

    // freopen(".inp", "r", stdin);

    // freopen(".out", "w", stdout);

    cin>>t;

    while(t--){

        solve();

    }

}
Problem: 2050D - Digital string maximization
Language: C++23 (GCC 14-64, msys2)

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

using namespace std;

long long t;

string s;

void solve(){

    cin>>s;

    string kq;

    for(int i=0; i<s.size(); i++){

        int maxn=s[i];

        for(int j=i+1; j<s.size(); j++){

            maxn=max(maxn,s[j]-(j-i));

        }

        for(int j=i+1; j<s.size(); j++){

            if(s[j]-(j-i)==maxn){

                for(int k=j-1; k>=i; k--){

                    s[k+1]--;

                    swap(s[k],s[k+1]);

                }

                break;

            }

        }

    }

    cout<<s<<'\n';

}

int main(){

    ios_base::sync_with_stdio(0);

    cin.tie(0); cout.tie(0);

    // freopen(".inp", "r", stdin);

    // freopen(".out", "w", stdout);

    cin>>t;

    while(t--){

        solve();

    }

}

Submission (verdict: Time limit exceeded on test 6):
#include <bits/stdc++.h>

using namespace std;

long long t;

string s;

void solve(){

    cin>>s;

    string kq;

    for(int i=0; i<s.size(); i++){

        int maxn=s[i];

        for(int j=i+1; j<s.size(); j++){

            maxn=max(maxn,s[j]-(j-i));

        }

        if(maxn==s[i]) continue;

        for(int j=i+1; j<s.size(); j++){

            if(s[j]-(j-i)==maxn){

                for(int k=j-1; k>=i; k--){

                    s[k+1]--;

                    swap(s[k],s[k+1]);

                }

                break;

            }

        }

    }

    cout<<s<<'\n';

}

int main(){

    ios_base::sync_with_stdio(0);

    cin.tie(0); cout.tie(0);

    // freopen(".inp", "r", stdin);

    // freopen(".out", "w", stdout);

    cin>>t;

    while(t--){

        solve();

    }

}
Problem: 2060D - Subtract Min Sort
Language: Python 3

Previous submission (verdict: Wrong answer on test 1):
def solve():
    import sys
    input_data = sys.stdin.read().strip().split()
    
    t = int(input_data[0])
    idx = 1
    answers = []
    
    for _ in range(t):
        n = int(input_data[idx]); idx += 1
        a = list(map(int, input_data[idx: idx+n]))
        idx += n
        
        # Single pass from left to right
        for i in range(n-1):
            if a[i] <= a[i+1]:
                # Subtract a[i] from a[i+1], set a[i] to 0
                a[i+1] -= a[i]
                a[i] = 0
        
        # Check if final array is non-decreasing
        possible = all(a[i] <= a[i+1] for i in range(n-1))
        answers.append("YES" if possible else "NO")
    
    print("\n".join(answers))


Submission (verdict: Wrong answer on test 1):
def solve():
    import sys
    
    t = int(input().strip())           # Number of test cases
    for _ in range(t):
        n = int(input().strip())       # Size of array
        a = list(map(int, input().split()))
        
        # -- Apply the left-to-right "subtract min" strategy --
        for i in range(n - 1):
            if a[i] <= a[i + 1]:
                # Subtract a[i] from a[i+1] and set a[i] to 0
                a[i+1] -= a[i]
                a[i] = 0
        
        # -- Check if non-decreasing --
        if all(a[i] <= a[i+1] for i in range(n - 1)):
            print("YES")
        else:
            print("NO")
Problem: 2060D - Subtract Min Sort
Language: Python 3


Submission (verdict: Wrong answer on test 1):
def solve():
    import sys
    input_data = sys.stdin.read().strip().split()
    
    t = int(input_data[0])
    idx = 1
    answers = []
    
    for _ in range(t):
        n = int(input_data[idx]); idx += 1
        a = list(map(int, input_data[idx: idx+n]))
        idx += n
        
        # Single pass from left to right
        for i in range(n-1):
            if a[i] <= a[i+1]:
                # Subtract a[i] from a[i+1], set a[i] to 0
                a[i+1] -= a[i]
                a[i] = 0
        
        # Check if final array is non-decreasing
        possible = all(a[i] <= a[i+1] for i in range(n-1))
        answers.append("YES" if possible else "NO")
    
    print("\n".join(answers))
Problem: 2060D - Subtract Min Sort
Language: Python 3

Previous submission (verdict: Wrong answer on test 1):
def solve():
    import sys
    
    t = int(input().strip())           # Number of test cases
    for _ in range(t):
        n = int(input().strip())       # Size of array
        a = list(map(int, input().split()))
        
        # -- Apply the left-to-right "subtract min" strategy --
        for i in range(n - 1):
            if a[i] <= a[i + 1]:
                # Subtract a[i] from a[i+1] and set a[i] to 0
                a[i+1] -= a[i]
                a[i] = 0
        
        # -- Check if non-decreasing --
        if all(a[i] <= a[i+1] for i in range(n - 1)):
            print("YES")
        else:
            print("NO")


Submission (verdict: Accepted):
def solve():
    import sys
    
    input_data = sys.stdin.read().strip().split()
    t = int(input_data[0])
    index = 1
    
    results = []
    for _ in range(t):
        n = int(input_data[index])
        index += 1
        
        # Read the array of integers
        a = list(map(int, input_data[index:index+n]))
        index += n
        
        # Perform the "subtract min" operation in a single left-to-right pass
        for i in range(n - 1):
            if a[i] <= a[i + 1]:
                # Subtract a[i] from a[i+1], and make a[i] zero
                a[i+1] -= a[i]
                a[i] = 0
        
        # Check if the final array is non-decreasing
        if all(a[i] <= a[i+1] for i in range(n-1)):
            results.append("YES")
        else:
            results.append("NO")
    
    # Output one result per test case
    print("\n".join(results))
    
solve()
Problem: 2052A - Adrenaline Rush
Language: C++23 (GCC 14-64, msys2)


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

using namespace std;



typedef long long ll;

typedef long double ld;



#define MULTI 0

#define dbg(x) cout << #x << " = " << x << "\n"

#define cin_vector(vec, n, T) vector<T> vec(n); for(ll i = 0; i < n; i++) cin >> vec[i];



template <typename T> void print(vector<T> &v){ for (auto &a : v) cout << a << " "; cout << "\n";}



void solve() {

    int n;

    cin>>n;

    cin_vector(a,n,int);

    vector<int>b;

    for(int i=1; i<=n; i++){

        b.push_back(i);

    }

    int total =0;

    vector<pair<int,int>> c;

    for(int i=0; i<n-1; i++){

        auto it = find(b.begin(),b.end(),a[i]);

        int f_ov = b.end()-1-it;

        total+=f_ov;

        total+=n-1-i;

        // dbg(f_ov);

        b.erase(it);

        for(int j = 1; j<=f_ov; j++ ){

            // dbg(*(it+j));

            c.push_back({*(it+j),a[i]});

        }

        for(int j=0; j<n-i-1; j++){

            c.push_back({a[i],*(b.begin()+j)});

            // cout<<a[i]<<" "<<<<endl;

            // dbg(*(b.begin()+j));

            

        }

        

    }

    cout<<total<<endl;

    // dbg(total);

    for(auto cc: c){

        cout<<cc.first<<" "<<cc.second<<endl;

    }

    // cout<<endl;

}



int32_t main() {

    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cout.precision(15); cout.setf(ios::fixed);

    ll t=1; if(MULTI) cin>>t;

    for (ll it = 1; it <= t; it++) {

        cout << "Case #" << it << ": ";

        solve();

    }

    return 0;

}
Problem: 2050E - Three Strings
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Time limit exceeded on test 13):
// Problem: E. Three Strings

// Contest: Codeforces - Codeforces Round 991 (Div. 3)

// URL: https://codeforces.com/contest/2050/problem/E

// Memory Limit: 256 MB

// Time Limit: 2500 ms

// 

// Powered by CP Editor (https://cpeditor.org)



#include <bits/stdc++.h>

#define ll long long

#define i64 long long

#define read(a) {char c;while((c=getchar())>47) a=a*10+(c^48);}

#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)

#define ull unsigned long long int

#define ui unsigned int

using namespace std;

const int N = 1e2 + 5;

const int P = 1e9 + 7;

const ll inf = 5e6;



int dp[N][N];



void zoumkfl()

{

	string a,b,c;cin >> a >> b >> c;

	int n = a.size();

	int m = b.size();

	//memset(dp,0x3f,sizeof dp);

	fill(&dp[0][0],&dp[0][0] + (n + 1) * (m + 1),inf);

	dp[0][0] = 0;

	for(int i = 0;i < n;i++)

	{

		dp[i + 1][0] = dp[i][0] + (a[i] != c[i]);

	}

	for(int j = 0;j < m;j++)

	{

		dp[0][j + 1] = dp[0][j] + (b[j] != c[j]);

	}

	for(int i = 1;i <= n;i++)

	{

		for(int j = 1;j <= m;j++)

		{

			dp[i][j] = min(dp[i - 1][j] + (a[i - 1] != c[i + j - 1])

			,dp[i][j - 1] + (b[j - 1] != c[i + j - 1]));

		}

	}

	cout << dp[n][m] << '\n';

}



int main() {

    IOS;

    int _ = 1;

    cin >> _;

    while(_--)

    {

        zoumkfl();

    }

    return 0;

}

Submission (verdict: Accepted):
// Problem: E. Three Strings

// Contest: Codeforces - Codeforces Round 991 (Div. 3)

// URL: https://codeforces.com/contest/2050/problem/E

// Memory Limit: 256 MB

// Time Limit: 2500 ms

// 

// Powered by CP Editor (https://cpeditor.org)



#include <bits/stdc++.h>

#define ll long long

#define i64 long long

#define read(a) {char c;while((c=getchar())>47) a=a*10+(c^48);}

#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)

#define ull unsigned long long int

#define ui unsigned int

using namespace std;

const int N = 1e2 + 5;

const int P = 1e9 + 7;

const ll inf = 5e6;





void zoumkfl()

{

	string a,b,c;cin >> a >> b >> c;

	int n = a.size();

	int m = b.size();

	int dp[n + 1][m + 1];

	//memset(dp,0x3f,sizeof dp);

	fill(&dp[0][0],&dp[0][0] + (n + 1) * (m + 1),inf);

	dp[0][0] = 0;

	for(int i = 0;i < n;i++)

	{

		dp[i + 1][0] = dp[i][0] + (a[i] != c[i]);

	}

	for(int j = 0;j < m;j++)

	{

		dp[0][j + 1] = dp[0][j] + (b[j] != c[j]);

	}

	for(int i = 1;i <= n;i++)

	{

		for(int j = 1;j <= m;j++)

		{

			dp[i][j] = min(dp[i - 1][j] + (a[i - 1] != c[i + j - 1])

			,dp[i][j - 1] + (b[j - 1] != c[i + j - 1]));

		}

	}

	cout << dp[n][m] << '\n';

}



int main() {

    IOS;

    int _ = 1;

    cin >> _;

    while(_--)

    {

        zoumkfl();

    }

    return 0;

}
Problem: 2050E - Three Strings
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Time limit exceeded on test 13):
// Problem: E. Three Strings

// Contest: Codeforces - Codeforces Round 991 (Div. 3)

// URL: https://codeforces.com/contest/2050/problem/E

// Memory Limit: 256 MB

// Time Limit: 2500 ms

// 

// Powered by CP Editor (https://cpeditor.org)



#include <bits/stdc++.h>

#define ll long long

#define i64 long long

#define read(a) {char c;while((c=getchar())>47) a=a*10+(c^48);}

#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)

#define ull unsigned long long int

#define ui unsigned int

using namespace std;

const int N = 1e2 + 5;

const int P = 1e9 + 7;

const ll inf = 4e18;



ll dp[N][N];



void zoumkfl()

{

	string a,b,c;cin >> a >> b >> c;

	int n = a.size();

	int m = b.size();

	//memset(dp,0x3f,sizeof dp);

	fill(&dp[0][0],&dp[0][0] + (n + 1) * (m + 1),inf);

	dp[0][0] = 0;

	for(int i = 0;i < n;i++)

	{

		dp[i + 1][0] = dp[i][0] + (a[i] != c[i]);

	}

	for(int j = 0;j < m;j++)

	{

		dp[0][j + 1] = dp[0][j] + (b[j] != c[j]);

	}

	for(int i = 1;i <= n;i++)

	{

		for(int j = 1;j <= m;j++)

		{

			dp[i][j] = min(dp[i - 1][j] + (a[i - 1] != c[i + j - 1])

			,dp[i][j - 1] + (b[j - 1] != c[i + j - 1]));

		}

	}

	cout << dp[n][m] << '\n';

}



int main() {

    IOS;

    int _ = 1;

    cin >> _;

    while(_--)

    {

        zoumkfl();

    }

    return 0;

}

Submission (verdict: Time limit exceeded on test 13):
// Problem: E. Three Strings

// Contest: Codeforces - Codeforces Round 991 (Div. 3)

// URL: https://codeforces.com/contest/2050/problem/E

// Memory Limit: 256 MB

// Time Limit: 2500 ms

// 

// Powered by CP Editor (https://cpeditor.org)



#include <bits/stdc++.h>

#define ll long long

#define i64 long long

#define read(a) {char c;while((c=getchar())>47) a=a*10+(c^48);}

#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)

#define ull unsigned long long int

#define ui unsigned int

using namespace std;

const int N = 1e2 + 5;

const int P = 1e9 + 7;

const ll inf = 5e6;



int dp[N][N];



void zoumkfl()

{

	string a,b,c;cin >> a >> b >> c;

	int n = a.size();

	int m = b.size();

	//memset(dp,0x3f,sizeof dp);

	fill(&dp[0][0],&dp[0][0] + (n + 1) * (m + 1),inf);

	dp[0][0] = 0;

	for(int i = 0;i < n;i++)

	{

		dp[i + 1][0] = dp[i][0] + (a[i] != c[i]);

	}

	for(int j = 0;j < m;j++)

	{

		dp[0][j + 1] = dp[0][j] + (b[j] != c[j]);

	}

	for(int i = 1;i <= n;i++)

	{

		for(int j = 1;j <= m;j++)

		{

			dp[i][j] = min(dp[i - 1][j] + (a[i - 1] != c[i + j - 1])

			,dp[i][j - 1] + (b[j - 1] != c[i + j - 1]));

		}

	}

	cout << dp[n][m] << '\n';

}



int main() {

    IOS;

    int _ = 1;

    cin >> _;

    while(_--)

    {

        zoumkfl();

    }

    return 0;

}
Problem: 2050E - Three Strings
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Time limit exceeded on test 13):
// Problem: E. Three Strings

// Contest: Codeforces - Codeforces Round 991 (Div. 3)

// URL: https://codeforces.com/contest/2050/problem/E

// Memory Limit: 256 MB

// Time Limit: 2500 ms

// 

// Powered by CP Editor (https://cpeditor.org)



#include <bits/stdc++.h>

#define ll long long

#define i64 long long

#define read(a) {char c;while((c=getchar())>47) a=a*10+(c^48);}

#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)

#define ull unsigned long long int

#define ui unsigned int

using namespace std;

const int N = 1e2 + 5;

const int P = 1e9 + 7;

const ll inf = 4e18;



ll dp[N][N];



void zoumkfl()

{

	string a,b,c;cin >> a >> b >> c;

	int n = a.size();

	int m = b.size();

	//memset(dp,0x3f,sizeof dp);

	fill(&dp[0][0],&dp[0][0] + (n + 1) * (m + 1),inf);

	dp[0][0] = 0;

	for(int i = 0;i < n;i++)

	{

		dp[i + 1][0] = dp[i][0] + (a[i] != c[i]);

	}

	for(int j = 0;j < m;j++)

	{

		dp[0][j + 1] = dp[0][j] + (b[j] != c[j]);

	}

	for(int i = 1;i <= n;i++)

	{

		for(int j = 1;j <= m;j++)

		{

			dp[i][j] = min(dp[i - 1][j] + (a[i - 1] != c[i + j - 1])

			,dp[i][j - 1] + (b[j - 1] != c[i + j - 1]));

		}

	}

	cout << dp[n][m] << '\n';

}



int main() {

    IOS;

    int _ = 1;

    cin >> _;

    while(_--)

    {

        zoumkfl();

    }

    return 0;

}