ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2049C - MEX Cycle
Language: C++17 (GCC 7-32)

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

using namespace std;

#define endl '\n'

#define ll long long

#define vi vector<int>

#define vii vector<vi>

#define viii vector<vii>

#define vl vector<long long>

#define vll vector<vl>

#define vlll vector<vll>

#define pii pair<int, int>

#define pll pair<ll, ll>



void solve() {

	int n, x, y; cin >> n >> x >> y;

	

	vi a(n + 1);

	

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

		a[i] = i % 2;

	

	if (n & 1) {

		a[n - 1] = 2;

		a[n] = 0;

	}

	

	if ((y + 1) % n == x || x + 1 == y);

	else if (a[x] == a[y]) {

		a[x] = 2;

		

		if (a[y] == 0 && y == n) {

			a[n - 2] = 0;

			a[n - 1] = 1;

		}

	}

	

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

		cout << a[i] << " \n"[i == n];

}



int main() {

    

    ios::sync_with_stdio(false);

    cout.tie(NULL);

    

	int _ = 1;

	cin >> _;



    while (_--)

        solve();

    

    return 0;

}

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

using namespace std;

#define endl '\n'

#define ll long long

#define vi vector<int>

#define vii vector<vi>

#define viii vector<vii>

#define vl vector<long long>

#define vll vector<vl>

#define vlll vector<vll>

#define pii pair<int, int>

#define pll pair<ll, ll>



void solve() {

	int n, x, y; cin >> n >> x >> y;

	

	vi a(n + 1);

	

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

		a[i] = i % 2;

	

	if (n & 1) {

		a[n - 1] = 2;

		a[n] = 0;

	}

	

	if ((y + 1) % n == x || x + 1 == y);

	else if (a[x] == a[y]) {

		a[x] = 2;

		

		if (n % 2 == 1 && a[y] == 0 && y == n) {

			a[n - 2] = 0;

			a[n - 1] = 1;

		}

	}

	

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

		cout << a[i] << " \n"[i == n];

}



int main() {

    

    ios::sync_with_stdio(false);

    cout.tie(NULL);

    

	int _ = 1;

	cin >> _;



    while (_--)

        solve();

    

    return 0;

}
Problem: 2049C - MEX Cycle
Language: C++17 (GCC 7-32)

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

using namespace std;

#define endl '\n'

#define ll long long

#define vi vector<int>

#define vii vector<vi>

#define viii vector<vii>

#define vl vector<long long>

#define vll vector<vl>

#define vlll vector<vll>

#define pii pair<int, int>

#define pll pair<ll, ll>



void solve() {

	int n, x, y; cin >> n >> x >> y;

	

	vi a(n + 1);

	

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

		a[i] = i % 2;

	

	if (n & 1) {

		a[n - 1] = 2;

		a[n] = 0;

	}

	

	if ((y + 1) % n == x || x + 1 == y);

	else if (a[x] == a[y]) {

		a[x] = 2;

		

		if (n % 2 == 1 && a[y] == 0 && y == n) {

			a[n - 2] = 0;

			a[n - 1] = 1;

		}

	}

	

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

		cout << a[i] << " \n"[i == n];

}



int main() {

    

    ios::sync_with_stdio(false);

    cout.tie(NULL);

    

	int _ = 1;

	cin >> _;



    while (_--)

        solve();

    

    return 0;

}

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

using namespace std;

#define endl '\n'

#define ll long long

#define vi vector<int>

#define vii vector<vi>

#define viii vector<vii>

#define vl vector<long long>

#define vll vector<vl>

#define vlll vector<vll>

#define pii pair<int, int>

#define pll pair<ll, ll>



void solve() {

	int n, x, y; cin >> n >> x >> y;

	

	vi a(n + 1);

	

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

		a[i] = i % 2;

	

	if (n & 1) {

		a[n - 1] = 2;

		a[n] = 0;

	}

	

	if ((y + 1) % n == x || x + 1 == y);

	else if (a[x] == a[y]) {

		a[x] = 2;

		

		if (n % 2 == 1 && x == n - 2 && y == n) {

			a[n - 2] = 0;

			a[n - 1] = 1;

		}

	}

	

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

		cout << a[i] << " \n"[i == n];

}



int main() {

    

    ios::sync_with_stdio(false);

    cout.tie(NULL);

    

	int _ = 1;

	cin >> _;



    while (_--)

        solve();

    

    return 0;

}
Problem: 2049C - MEX Cycle
Language: C++17 (GCC 7-32)


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

using namespace std;

#define endl '\n'

#define ll long long

#define vi vector<int>

#define vii vector<vi>

#define viii vector<vii>

#define vl vector<long long>

#define vll vector<vl>

#define vlll vector<vll>

#define pii pair<int, int>

#define pll pair<ll, ll>



void solve() {

	int n, x, y; cin >> n >> x >> y;

	

	vi a(n + 1);

	

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

		a[i] = i % 2;

	

	if (n & 1) {

		a[n - 1] = 2;

		a[n] = 0;

	}

	

	if ((y + 1) % n == x || x + 1 == y);

	else if (a[x] == a[y]) {

		a[x] = 2;

		

		if (a[y] == 0 && y == n) {

			a[n - 2] = 0;

			a[n - 1] = 1;

		}

	}

	

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

		cout << a[i] << " \n"[i == n];

}



int main() {

    

    ios::sync_with_stdio(false);

    cout.tie(NULL);

    

	int _ = 1;

	cin >> _;



    while (_--)

        solve();

    

    return 0;

}
Problem: 2049C - MEX Cycle
Language: C++17 (GCC 7-32)

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

using namespace std;

#define endl '\n'

#define ll long long

#define vi vector<int>

#define vii vector<vi>

#define viii vector<vii>

#define vl vector<long long>

#define vll vector<vl>

#define vlll vector<vll>

#define pii pair<int, int>

#define pll pair<ll, ll>



void solve() {

	int n, x, y; cin >> n >> x >> y;

	

	vi a(n + 1);

	

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

		a[i] = i % 2;

	

	if (n & 1) {

		a[n - 1] = 2;

		a[n] = 0;

	}

	

	if ((y + 1) % n == x || x + 1 == y);

	else if (a[x] == a[y]) {

		a[x] = 2;

		

		if (n % 2 == 1 && x == n - 2 && y == n) {

			a[n - 2] = 0;

			a[n - 1] = 1;

		}

	}

	

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

		cout << a[i] << " \n"[i == n];

}



int main() {

    

    ios::sync_with_stdio(false);

    cout.tie(NULL);

    

	int _ = 1;

	cin >> _;



    while (_--)

        solve();

    

    return 0;

}

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

using namespace std;

#define endl '\n'

#define ll long long

#define vi vector<int>

#define vii vector<vi>

#define viii vector<vii>

#define vl vector<long long>

#define vll vector<vl>

#define vlll vector<vll>

#define pii pair<int, int>

#define pll pair<ll, ll>



void solve() {

	int n, x, y; cin >> n >> x >> y;

	

	vi a(n + 1);

	

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

		a[i] = i % 2;

	

	if (n & 1) {

		a[n - 1] = 2;

		a[n] = 0;

	}

	

	if ((y + 1) % n == x || x + 1 == y);

	else if (a[x] == a[y]) {

		a[x] = 2;

		

		if (n % 2 == 1 && x == n - 3 && y == n) {

			a[n - 2] = 0;

			a[n - 1] = 1;

		}

	}

	

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

		cout << a[i] << " \n"[i == n];

}



int main() {

    

    ios::sync_with_stdio(false);

    cout.tie(NULL);

    

	int _ = 1;

	cin >> _;



    while (_--)

        solve();

    

    return 0;

}
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)

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

int main() {
	// your code goes here
	
	int t ; 
	cin>>t;
	while(t--){
	    string s  ;
	     cin>>s ;
	     if(s.size()==1){
	         cout<<s<<endl ;
	         continue ;
	     }
	     for(int i = 0; i <s.size() ;i++){
	         char ans = s[i] ; int index = i ; 
	         for(int j =i ; j < s.size() ; j++ ){
	             if(s[j]-j+i > ans && s[j]>'0'){
	                 ans = s[j]-j+i;
	                 index = j ; 
	             }
	         }
	           s.erase(s.begin()+index);
	         s.insert(s.begin()+i,ans);
	     }
	     cout<<s<<endl;
	}

}

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

int main() {
	// your code goes here
	 ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
	
	int t ; 
	cin>>t;
	while(t--){
	    string s  ;
	     cin>>s ;
	     if(s.size()==1){
	         cout<<s<<endl ;
	         continue ;
	     }
	     for(int i = 0; i <s.size() ;i++){
	         char ans = s[i] ; int index = i ; 
	         for(int j =i ; j < s.size() ; j++ ){
	             if(s[j]-j+i > ans && s[j]>'0'){
	                 ans = s[j]-j+i;
	                 index = j ; 
	             }
	         }
	           s.erase(s.begin()+index);
	         s.insert(s.begin()+i,ans);
	     }
	     cout<<s<<endl;
	}

}
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)


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

int main() {
	// your code goes here
	
	int t ; 
	cin>>t;
	while(t--){
	    string s  ;
	     cin>>s ;
	     if(s.size()==1){
	         cout<<s<<endl ;
	         continue ;
	     }
	     for(int i = 0; i <s.size() ;i++){
	         char ans = s[i] ; int index = i ; 
	         for(int j =i ; j < s.size() ; j++ ){
	             if(s[j]-j+i > ans && s[j]>'0'){
	                 ans = s[j]-j+i;
	                 index = j ; 
	             }
	         }
	           s.erase(s.begin()+index);
	         s.insert(s.begin()+i,ans);
	     }
	     cout<<s<<endl;
	}

}
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)

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

int main() {
	// your code goes here
	 ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
	
	int t ; 
	cin>>t;
	while(t--){
	    string s  ;
	     cin>>s ;
	     if(s.size()==1){
	         cout<<s<<endl ;
	         continue ;
	     }
	     for(int i = 0; i <s.size() ;i++){
	         char ans = s[i] ; int index = i ; 
	         for(int j =i ; j < s.size() ; j++ ){
	             if(s[j]-j+i > ans && s[j]>'0'){
	                 ans = s[j]-j+i;
	                 index = j ; 
	             }
	         }
	           s.erase(s.begin()+index);
	         s.insert(s.begin()+i,ans);
	     }
	     cout<<s<<endl;
	}

}

Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	// your code goes here
	 ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
	
	int t ; 
	cin>>t;
	while(t--){
	    string s  ;
	     cin>>s ;
	     if(s.size()==1){
	         cout<<s<<endl ;
	         continue ;
	     }
	     for(int i = 0; i <s.size() ;i++){
	         char ans = s[i] ; int index = i ; 
	         for(int j =i ; j <=i+9&&j<=s.size() ; j++ ){
	             if(s[j]-j+i > ans && s[j]>'0'){
	                 ans = s[j]-j+i;
	                 index = j ; 
	             }
	         }
	           s.erase(s.begin()+index);
	         s.insert(s.begin()+i,ans);
	     }
	     cout<<s<<endl;
	}
 
}
Problem: 2050E - Three Strings
Language: C++17 (GCC 7-32)


Submission (verdict: Time limit exceeded on test 16):

#include<bits/stdc++.h>
using namespace std;
#define int long long
 
int mod = 1e9+7;

int solve(int ind1, int ind2, string a, string b, string c, int n, int m, vector<vector<int>> &dp){
    if(ind1==n && ind2==m)
        return 0;

    if(ind1==n){
        if(c[ind1+ind2]!=b[ind2])
            return dp[ind1][ind2] = 1+solve(ind1,ind2+1,a,b,c,n,m,dp);
        else
            return dp[ind1][ind2] = solve(ind1,ind2+1,a,b,c,n,m,dp);
    }

    if(ind2==m){
        if(c[ind1+ind2]!=a[ind1])
            return dp[ind1][ind2] = 1+solve(ind1+1,ind2,a,b,c,n,m,dp);
        else
            return dp[ind1][ind2] = solve(ind1+1,ind2,a,b,c,n,m,dp);
    }

    if(dp[ind1][ind2]!=1e9)
        return dp[ind1][ind2];
    
    if(c[ind1+ind2]==a[ind1] && c[ind1+ind2]!=b[ind2])
        return dp[ind1][ind2] = min(solve(ind1+1,ind2,a,b,c,n,m,dp),1+solve(ind1,ind2+1,a,b,c,n,m,dp));
    
    if(c[ind1+ind2]!=a[ind1] && c[ind1+ind2]==b[ind2])
        return dp[ind1][ind2] = min(1+solve(ind1+1,ind2,a,b,c,n,m,dp),solve(ind1,ind2+1,a,b,c,n,m,dp));

    if(c[ind1+ind2]==a[ind1] && c[ind1+ind2]==b[ind2])
        return dp[ind1][ind2] = min(solve(ind1+1,ind2,a,b,c,n,m,dp),solve(ind1,ind2+1,a,b,c,n,m,dp));

    if(c[ind1+ind2]!=a[ind1] && c[ind1+ind2]!=b[ind2])
        return dp[ind1][ind2] = 1+min(solve(ind1+1,ind2,a,b,c,n,m,dp),solve(ind1,ind2+1,a,b,c,n,m,dp));
}

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t=1;
    cin>>t;
 
    while(t--){
        string a,b,c;
        cin>>a;
        cin>>b;
        cin>>c;
        int n = a.size();
        int m = b.size();
        vector<vector<int>> dp(n+1, vector<int>(m+1,1e9));

        int ans = solve(0,0,a,b,c,n,m,dp);
        cout<<ans<<endl;
    }
    return 0;
}
Problem: 2050E - Three Strings
Language: C++17 (GCC 7-32)

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

int solve(string& s1, string& s2, string& s3, int i, int j, int k, vector<vector<vector<int>>>& dp){
    if(k<0 && j<0 && i<0){
        return 0;
    }
    if(k<0){
        return 1e8;
    }
    if(i>=0 && j>=0 && dp[i+1][j+1][k+1] != -1){
        return dp[i+1][j+1][k+1];
    }
    // cout<<i<<j<<k<<endl;
    int ans = 1e8;
    if(s3[k]!=s1[i] && s3[k]!=s2[j]){
        if(i>=0 &&j>=0)
        return dp[i+1][j+1][k+1] = 1+min(solve(s1, s2, s3, i-1, j, k-1, dp), solve(s1, s2, s3, i, j-1, k-1, dp));
        if(i>=0)
        return dp[i+1][j+1][k+1] = 1+solve(s1, s2, s3, i-1, j, k-1, dp);
        if(j>=0)
        return dp[i+1][j+1][k+1] = 1+solve(s1, s2, s3, i, j-1, k-1, dp);

    }
    if(i>=0 && s3[k]==s1[i]){
        ans=min(ans, solve(s1, s2, s3, i-1, j, k-1, dp));
    }
    else if(i>=0){
        ans = min(ans, 1+solve(s1, s2, s3, i-1, j, k-1,dp));
    }
    if(j>=0 && s3[k]==s2[j]){
        ans=min(ans, solve(s1, s2, s3, i, j-1, k-1, dp));
    }
    else if(j>=0){
        ans = min(ans, 1+solve(s1, s2, s3, i, j-1, k-1, dp));
    }
    return dp[i+1][j+1][k+1] = ans;
}


int main(){
    int testcases=1;

    cin>>testcases;
    while(testcases--){
        string s1, s2, s3;
        cin>>s1>>s2>>s3;
        vector<vector<vector<int>>> dp(s3.size()+10, vector<vector<int>>(s3.size()+10, vector<int>(s3.size()+10, -1)));
        cout << solve(s1, s2, s3, s1.size()-1, s2.size()-1, s3.size()-1, dp)<<endl;

    }
}



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

int solve(string& s1, string& s2, string& s3, int i, int j, int k, vector<vector<vector<int>>>& dp){
    if(k<0 && j<0 && i<0){
        return 0;
    }
    if(k<0){
        return 1e8;
    }
    if(i>=0 && j>=0 && dp[i+1][j+1] != -1){
        return dp[i+1][j+1];
    }
    // cout<<i<<j<<k<<endl;
    int ans = 1e8;
    if(s3[k]!=s1[i] && s3[k]!=s2[j]){
        if(i>=0 &&j>=0)
        return dp[i+1][j+1] = 1+min(solve(s1, s2, s3, i-1, j, k-1, dp), solve(s1, s2, s3, i, j-1, k-1, dp));
        if(i>=0)
        return dp[i+1][j+1] = 1+solve(s1, s2, s3, i-1, j, k-1, dp);
        if(j>=0)
        return dp[i+1][j+1] = 1+solve(s1, s2, s3, i, j-1, k-1, dp);

    }
    if(i>=0 && s3[k]==s1[i]){
        ans=min(ans, solve(s1, s2, s3, i-1, j, k-1, dp));
    }
    else if(i>=0){
        ans = min(ans, 1+solve(s1, s2, s3, i-1, j, k-1,dp));
    }
    if(j>=0 && s3[k]==s2[j]){
        ans=min(ans, solve(s1, s2, s3, i, j-1, k-1, dp));
    }
    else if(j>=0){
        ans = min(ans, 1+solve(s1, s2, s3, i, j-1, k-1, dp));
    }
    return dp[i+1][j+1] = ans;
}


int main(){
    int testcases=1;

    cin>>testcases;
    while(testcases--){
        string s1, s2, s3;
        cin>>s1>>s2>>s3;
        vector<vector<int>> dp(s3.size()+10, vector<int>(s3.size()+10, -1));
        cout << solve(s1, s2, s3, s1.size()-1, s2.size()-1, s3.size()-1, dp)<<endl;

    }
}
Problem: 2050E - Three Strings
Language: C++17 (GCC 7-32)

Previous submission (verdict: Compilation error):
#include<bits/stdc++.h>
using namespace std;

int solve(string& s1, string& s2, string& s3, int i, int j, int k, vector<vector<vector<int>>>& dp){
    if(k<0 && j<0 && i<0){
        return 0;
    }
    if(k<0){
        return 1e8;
    }
    if(i>=0 && j>=0 && dp[i+1][j+1] != -1){
        return dp[i+1][j+1];
    }
    // cout<<i<<j<<k<<endl;
    int ans = 1e8;
    if(s3[k]!=s1[i] && s3[k]!=s2[j]){
        if(i>=0 &&j>=0)
        return dp[i+1][j+1] = 1+min(solve(s1, s2, s3, i-1, j, k-1, dp), solve(s1, s2, s3, i, j-1, k-1, dp));
        if(i>=0)
        return dp[i+1][j+1] = 1+solve(s1, s2, s3, i-1, j, k-1, dp);
        if(j>=0)
        return dp[i+1][j+1] = 1+solve(s1, s2, s3, i, j-1, k-1, dp);

    }
    if(i>=0 && s3[k]==s1[i]){
        ans=min(ans, solve(s1, s2, s3, i-1, j, k-1, dp));
    }
    else if(i>=0){
        ans = min(ans, 1+solve(s1, s2, s3, i-1, j, k-1,dp));
    }
    if(j>=0 && s3[k]==s2[j]){
        ans=min(ans, solve(s1, s2, s3, i, j-1, k-1, dp));
    }
    else if(j>=0){
        ans = min(ans, 1+solve(s1, s2, s3, i, j-1, k-1, dp));
    }
    return dp[i+1][j+1] = ans;
}


int main(){
    int testcases=1;

    cin>>testcases;
    while(testcases--){
        string s1, s2, s3;
        cin>>s1>>s2>>s3;
        vector<vector<int>> dp(s3.size()+10, vector<int>(s3.size()+10, -1));
        cout << solve(s1, s2, s3, s1.size()-1, s2.size()-1, s3.size()-1, dp)<<endl;

    }
}



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

int solve(string& s1, string& s2, string& s3, int i, int j, int k, vector<vector<int>>& dp){
    if(k<0 && j<0 && i<0){
        return 0;
    }
    if(k<0){
        return 1e8;
    }
    if(i>=0 && j>=0 && dp[i+1][j+1] != -1){
        return dp[i+1][j+1];
    }
    // cout<<i<<j<<k<<endl;
    int ans = 1e8;
    if(s3[k]!=s1[i] && s3[k]!=s2[j]){
        if(i>=0 &&j>=0)
        return dp[i+1][j+1] = 1+min(solve(s1, s2, s3, i-1, j, k-1, dp), solve(s1, s2, s3, i, j-1, k-1, dp));
        if(i>=0)
        return dp[i+1][j+1] = 1+solve(s1, s2, s3, i-1, j, k-1, dp);
        if(j>=0)
        return dp[i+1][j+1] = 1+solve(s1, s2, s3, i, j-1, k-1, dp);

    }
    if(i>=0 && s3[k]==s1[i]){
        ans=min(ans, solve(s1, s2, s3, i-1, j, k-1, dp));
    }
    else if(i>=0){
        ans = min(ans, 1+solve(s1, s2, s3, i-1, j, k-1,dp));
    }
    if(j>=0 && s3[k]==s2[j]){
        ans=min(ans, solve(s1, s2, s3, i, j-1, k-1, dp));
    }
    else if(j>=0){
        ans = min(ans, 1+solve(s1, s2, s3, i, j-1, k-1, dp));
    }
    return dp[i+1][j+1] = ans;
}


int main(){
    int testcases=1;

    cin>>testcases;
    while(testcases--){
        string s1, s2, s3;
        cin>>s1>>s2>>s3;
        vector<vector<int>> dp(s3.size()+10, vector<int>(s3.size()+10, -1));
        cout << solve(s1, s2, s3, s1.size()-1, s2.size()-1, s3.size()-1, dp)<<endl;

    }
}
Problem: 2050E - Three Strings
Language: C++17 (GCC 7-32)


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

int solve(string& s1, string& s2, string& s3, int i, int j, int k, vector<vector<vector<int>>>& dp){
    if(k<0 && j<0 && i<0){
        return 0;
    }
    if(k<0){
        return 1e8;
    }
    if(i>=0 && j>=0 && dp[i+1][j+1][k+1] != -1){
        return dp[i+1][j+1][k+1];
    }
    // cout<<i<<j<<k<<endl;
    int ans = 1e8;
    if(s3[k]!=s1[i] && s3[k]!=s2[j]){
        if(i>=0 &&j>=0)
        return dp[i+1][j+1][k+1] = 1+min(solve(s1, s2, s3, i-1, j, k-1, dp), solve(s1, s2, s3, i, j-1, k-1, dp));
        if(i>=0)
        return dp[i+1][j+1][k+1] = 1+solve(s1, s2, s3, i-1, j, k-1, dp);
        if(j>=0)
        return dp[i+1][j+1][k+1] = 1+solve(s1, s2, s3, i, j-1, k-1, dp);

    }
    if(i>=0 && s3[k]==s1[i]){
        ans=min(ans, solve(s1, s2, s3, i-1, j, k-1, dp));
    }
    else if(i>=0){
        ans = min(ans, 1+solve(s1, s2, s3, i-1, j, k-1,dp));
    }
    if(j>=0 && s3[k]==s2[j]){
        ans=min(ans, solve(s1, s2, s3, i, j-1, k-1, dp));
    }
    else if(j>=0){
        ans = min(ans, 1+solve(s1, s2, s3, i, j-1, k-1, dp));
    }
    return dp[i+1][j+1][k+1] = ans;
}


int main(){
    int testcases=1;

    cin>>testcases;
    while(testcases--){
        string s1, s2, s3;
        cin>>s1>>s2>>s3;
        vector<vector<vector<int>>> dp(s3.size()+10, vector<vector<int>>(s3.size()+10, vector<int>(s3.size()+10, -1)));
        cout << solve(s1, s2, s3, s1.size()-1, s2.size()-1, s3.size()-1, dp)<<endl;

    }
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 2):
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
using namespace std;
typedef long long ll;


int main() {
    int t; cin >> t;
    while(t--){
        int n; cin >> n;
        int a[n];
        int sum = 0;
        for(int i = 0; i < n; i++){
            cin >> a[i];
            sum += a[i];
        }
        vector<int>v;
        while(n > 1){
            int add = 0;
            for(int i = 0; i < n-1; i++){
                v.push_back(a[i+1] - a[i]);
            }
            for(int i = 0; i < n-1; i++){
                add += v[i];
            }
            sum = max(sum, abs(add));
            n--;
            for(int i = 0; i < n; i++){
                a[i] = v[i];
            }
            v.clear();
        }
        cout << sum << endl;


    }

    return 0;
}



/*
ll gcd(int a, int b){
    if(b == 0) return a;
    return gcd(b, a%b);
}

ll lcm(int a, int b){
    return a*b / gcd(a,b);
}
*/
/*
int knapSack(int W, const vector<int>& weights, const vector<int>& values, int n) {

    vector<vector<int>> dp(n + 1, vector<int>(W + 1, 0));

    // Build the DP table
    for (int i = 1; i <= n; i++) {
        for (int w = 0; w <= W; w++) {
            if (weights[i - 1] <= w) {
                // Include the item or exclude it
                dp[i][w] = max(dp[i - 1][w], dp[i - 1][w - weights[i - 1]] + values[i - 1]);
            } else {
                // Exclude the item
                dp[i][w] = dp[i - 1][w];
            }
        }
    }

    // The last cell of the DP table contains the maximum value
    return dp[n][W];
}
*/
Problem: 2063C - Remove Exactly Two
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 2):
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
typedef long long ll;


int main() {
    int t; cin >> t;
    while(t--){
        int n; cin >> n;
        int u, v;
        vector<pair<int, int>>v1;
        map<int, int>m1;
        for(int i = 0; i < n-1; i++){
            cin >> u >> v;
            v1.push_back({u, v});
            m1[u]++;
            m1[v]++;
        }
        vector<pair<int, int>> vec(m1.begin(), m1.end());

        sort(vec.begin(), vec.end(), [](const pair<int, int>& a, const pair<int, int>& b) {
            return a.second > b.second;
        });

        int max1 = vec[0].first;
        int max2 = vec[1].first;

        int counter = 0;
        for(int i = 0; i < n-1; i++){
            if(v1[i].first != max1 && v1[i].second != max1 && v1[i].first != max2 && v1[i].second != max2){
                counter++;
            }
        }
        cout << counter + (n - 2 - (2*counter)) << endl;
    }

    return 0;
}



/*
ll gcd(int a, int b){
    if(b == 0) return a;
    return gcd(b, a%b);
}

ll lcm(int a, int b){
    return a*b / gcd(a,b);
}
*/
/*
int knapSack(int W, const vector<int>& weights, const vector<int>& values, int n) {

    vector<vector<int>> dp(n + 1, vector<int>(W + 1, 0));

    // Build the DP table
    for (int i = 1; i <= n; i++) {
        for (int w = 0; w <= W; w++) {
            if (weights[i - 1] <= w) {
                // Include the item or exclude it
                dp[i][w] = max(dp[i - 1][w], dp[i - 1][w - weights[i - 1]] + values[i - 1]);
            } else {
                // Exclude the item
                dp[i][w] = dp[i - 1][w];
            }
        }
    }

    // The last cell of the DP table contains the maximum value
    return dp[n][W];
}
*/