ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 1):
/*Les do some thikr:
سُبْحَانَ ٱللَّٰهِ
ٱلْحَمْدُ لِلَّٰهِ
 الله أكبر
أَسْتَغْفِرُ ٱللَّٰهَ
سُبْحَانَ اللَّهِ وَبِحَمْدِهِ، سُبْحَانَ اللَّهِ العَظِيم
 لَا حَوْلَ وَلَا قُوَّةَ إِلَّا بِٱللَّٰهِ ٱلْعَلِيِّ ٱلْعَظِيمِ
لا إله إلا الله
and durood
اللَّهُمَّ بَارِكْ عَلَى مُحَمَّدٍ، وَعَلَى آلِ مُحَمَّدٍ، كَمَا بَارَكْتَ عَلَى إِبْرَاهِيمَ، وَعَلَى آلِ إِبْرَاهِيمَ، إِنَّكَ حَمِيدٌ مَجِيدٌ
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long

//bitset<100001>a;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int t=1;
cin>>t;

    while(t--)
    {
      ll n,i,x,f=0,sum=0,mx;
      cin>>n;
     vector<ll>v,v1;
      for(i=0; i<n; i++)
      {
          cin>>x;
         v.push_back(x);
         
         sum+=x;
      }
     mx=max(sum,-sum);
      while(n--)
      { sum=0,f=0;
        
          for(i=1; i<v.size(); i++)
          { x=v[i]-v[i-1];
         
          sum+=x;
              v1.push_back(x);
              f=1;
          }
          
          v=v1;
          v1.clear();
          if(f)
         mx=max({mx,sum,-sum});
      }
     // cout<<v[0]<<" ";
   
     
   cout<<mx<<"\n";
    }
    
 
 
return 0;
}

Submission (verdict: Wrong answer on test 2):
/*Les do some thikr:
سُبْحَانَ ٱللَّٰهِ
ٱلْحَمْدُ لِلَّٰهِ
 الله أكبر
أَسْتَغْفِرُ ٱللَّٰهَ
سُبْحَانَ اللَّهِ وَبِحَمْدِهِ، سُبْحَانَ اللَّهِ العَظِيم
 لَا حَوْلَ وَلَا قُوَّةَ إِلَّا بِٱللَّٰهِ ٱلْعَلِيِّ ٱلْعَظِيمِ
لا إله إلا الله
and durood
اللَّهُمَّ بَارِكْ عَلَى مُحَمَّدٍ، وَعَلَى آلِ مُحَمَّدٍ، كَمَا بَارَكْتَ عَلَى إِبْرَاهِيمَ، وَعَلَى آلِ إِبْرَاهِيمَ، إِنَّكَ حَمِيدٌ مَجِيدٌ
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long

//bitset<100001>a;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int t=1;
cin>>t;

    while(t--)
    {
      ll n,i,x,f=0,sum=0,mx;
      cin>>n;
     vector<ll>v,v1;
      for(i=0; i<n; i++)
      {
          cin>>x;
         v.push_back(x);
         
         sum+=x;
      }
      if(n==1)
     mx=sum;
     else
     mx=max(sum,-sum);
      while(n--)
      { sum=0,f=0;
        
          for(i=1; i<v.size(); i++)
          { x=v[i]-v[i-1];
         
          sum+=x;
              v1.push_back(x);
              f=1;
          }
          
          v=v1;
          v1.clear();
          if(f)
         mx=max({mx,sum,-sum});
      }
     // cout<<v[0]<<" ";
   
     
   cout<<mx<<"\n";
    }
    
 
 
return 0;
}
Problem: 2063C - Remove Exactly Two
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
void solve(){
    int n;cin>>n;
    vector<int> e[n+1];
    for(int i=1;i<n;i++){
        int u,v;cin>>u>>v;
        e[u].push_back(v);
        e[v].push_back(u);
    }
    int root,maxn=0;
    for(int i=1;i<=n;i++) maxn=max(maxn,(int)e[i].size());
    for(int i=1;i<=n;i++) if(e[i].size()==maxn) {root=i;break;}
    vector<int> vis(n+1),deg(n+1);
    function<void(int,int)> dfs=[&](int u,int fa){
        vis[u]=1;
        for(auto v:e[u]){
            if(v==fa || vis[v]) continue;
            deg[u]++;
            dfs(v,u);
        }
    };
    // cout<<root<<endl;
    vis[root]=1;
    for(auto i:e[root]){
        dfs(i,root);
    }
    int ans=0;
    for(int i=1;i<=n;i++) ans=max(ans,deg[i]);
    if(!ans) ans=maxn-1;
    else ans+=maxn;
    cout<<ans<<endl;
}
signed main(){
    cin.tie(0)->sync_with_stdio(0);
    int t=1;cin>>t;
    while(t--) solve();
    return 0;
}
Problem: 2063C - Remove Exactly Two
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
void solve(){
    int n;cin>>n;
    vector<int> e[n+1];
    for(int i=1;i<n;i++){
        int u,v;cin>>u>>v;
        e[u].push_back(v);
        e[v].push_back(u);
    }
    int root,maxn=0;
    for(int i=1;i<=n;i++) maxn=max(maxn,(int)e[i].size());
    for(int i=1;i<=n;i++) if(e[i].size()==maxn) {root=i;break;}
    vector<int> vis(n+1),deg(n+1);
    function<void(int,int)> dfs=[&](int u,int fa){
        vis[u]=1;
        for(auto v:e[u]){
            if(v==fa || vis[v]) continue;
            deg[u]++;
            deg[v]++;
            dfs(v,u);
        }
    };
    // cout<<root<<endl;
    vis[root]=1;
    for(auto i:e[root]){
        dfs(i,root);
    }
    int ans=0;
    for(int i=1;i<=n;i++) ans=max(ans,deg[i]);
    // cout<<maxn<<' '<<ans<<endl;
    // if(!ans) ans=maxn-1;
    // else if(ans==1)ans=maxn;
    // else ans+=maxn;
    ans+=maxn-1;
    cout<<ans<<endl;
}
signed main(){
    cin.tie(0)->sync_with_stdio(0);
    int t=1;cin>>t;
    while(t--) solve();
    return 0;
}

Submission (verdict: Accepted):
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
void solve(){
    int n;cin>>n;
    vector<int> e[n+1];
    vector dp(n+1,vector<vector<int>>(3,vector<int>(2,-1e18)));
    vector<int> deg(n+1);
    for(int i=1;i<n;i++){
        int u,v;cin>>u>>v;
        e[u].push_back(v);
        e[v].push_back(u);
        deg[u]++;deg[v]++;
    }
    // for(int i=1;i<=n;i++) dp[i][1][0]=-1e18;
    function<void(int,int)> dfs=[&](int u,int fa){
        dp[u][1][1]=e[u].size()-1;
        int max1=-1e18,max2=-1e18;
        for(auto v:e[u]){
            if(v==fa) continue;
            dfs(v,u);
            dp[u][1][0]=max({dp[u][1][0],dp[v][1][0],dp[v][1][1]});
            dp[u][2][1]=max({dp[u][2][1],dp[v][1][0]+deg[u]-1,dp[v][1][1]+deg[u]-2});
            dp[u][2][0]=max({dp[u][2][0],dp[v][2][1],dp[v][2][0]});
            if(max(dp[v][1][0],dp[v][1][1])>=max1){
                max2=max1;
                max1=max(dp[v][1][0],dp[v][1][1]);
            }
            else if(max(dp[v][1][0],dp[v][1][1])>max2){
                max2=max(dp[v][1][0],dp[v][1][1]);
            }
        }
        dp[u][2][0]=max(dp[u][2][0],max1+max2);
    };
    dfs(1,0);
    // cout<<dp[2][1][1]<<endl;
    cout<<max(dp[1][2][0],dp[1][2][1])+1<<endl;
}
signed main(){
    cin.tie(0)->sync_with_stdio(0);
    int t=1;cin>>t;
    while(t--) solve();
    return 0;
}
Problem: 2063C - Remove Exactly Two
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
void solve(){
    int n;cin>>n;
    vector<int> e[n+1];
    for(int i=1;i<n;i++){
        int u,v;cin>>u>>v;
        e[u].push_back(v);
        e[v].push_back(u);
    }
    int root,maxn=0;
    for(int i=1;i<=n;i++) maxn=max(maxn,(int)e[i].size());
    for(int i=1;i<=n;i++) if(e[i].size()==maxn) {root=i;break;}
    vector<int> vis(n+1),deg(n+1);
    function<void(int,int)> dfs=[&](int u,int fa){
        vis[u]=1;
        for(auto v:e[u]){
            if(v==fa || vis[v]) continue;
            deg[u]++;
            dfs(v,u);
        }
    };
    // cout<<root<<endl;
    vis[root]=1;
    for(auto i:e[root]){
        dfs(i,root);
    }
    int ans=0;
    for(int i=1;i<=n;i++) ans=max(ans,deg[i]);
    if(!ans) ans=maxn-1;
    else ans+=maxn;
    cout<<ans<<endl;
}
signed main(){
    cin.tie(0)->sync_with_stdio(0);
    int t=1;cin>>t;
    while(t--) solve();
    return 0;
}

Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
void solve(){
    int n;cin>>n;
    vector<int> e[n+1];
    for(int i=1;i<n;i++){
        int u,v;cin>>u>>v;
        e[u].push_back(v);
        e[v].push_back(u);
    }
    int root,maxn=0;
    for(int i=1;i<=n;i++) maxn=max(maxn,(int)e[i].size());
    for(int i=1;i<=n;i++) if(e[i].size()==maxn) {root=i;break;}
    vector<int> vis(n+1),deg(n+1);
    function<void(int,int)> dfs=[&](int u,int fa){
        vis[u]=1;
        for(auto v:e[u]){
            if(v==fa || vis[v]) continue;
            deg[u]++;
            dfs(v,u);
        }
    };
    // cout<<root<<endl;
    vis[root]=1;
    for(auto i:e[root]){
        dfs(i,root);
    }
    int ans=0;
    for(int i=1;i<=n;i++) ans=max(ans,deg[i]);
    if(!ans) ans=maxn-1;
    else if(ans==1)ans=maxn;
    else ans+=maxn;
    cout<<ans<<endl;
}
signed main(){
    cin.tie(0)->sync_with_stdio(0);
    int t=1;cin>>t;
    while(t--) solve();
    return 0;
}
Problem: 2063C - Remove Exactly Two
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
void solve(){
    int n;cin>>n;
    vector<int> e[n+1];
    for(int i=1;i<n;i++){
        int u,v;cin>>u>>v;
        e[u].push_back(v);
        e[v].push_back(u);
    }
    int root,maxn=0;
    for(int i=1;i<=n;i++) maxn=max(maxn,(int)e[i].size());
    for(int i=1;i<=n;i++) if(e[i].size()==maxn) {root=i;break;}
    vector<int> vis(n+1),deg(n+1);
    function<void(int,int)> dfs=[&](int u,int fa){
        vis[u]=1;
        for(auto v:e[u]){
            if(v==fa || vis[v]) continue;
            deg[u]++;
            dfs(v,u);
        }
    };
    // cout<<root<<endl;
    vis[root]=1;
    for(auto i:e[root]){
        dfs(i,root);
    }
    int ans=0;
    for(int i=1;i<=n;i++) ans=max(ans,deg[i]);
    if(!ans) ans=maxn-1;
    else if(ans==1)ans=maxn;
    else ans+=maxn;
    cout<<ans<<endl;
}
signed main(){
    cin.tie(0)->sync_with_stdio(0);
    int t=1;cin>>t;
    while(t--) solve();
    return 0;
}

Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
void solve(){
    int n;cin>>n;
    vector<int> e[n+1];
    for(int i=1;i<n;i++){
        int u,v;cin>>u>>v;
        e[u].push_back(v);
        e[v].push_back(u);
    }
    int root,maxn=0;
    for(int i=1;i<=n;i++) maxn=max(maxn,(int)e[i].size());
    for(int i=1;i<=n;i++) if(e[i].size()==maxn) {root=i;break;}
    vector<int> vis(n+1),deg(n+1);
    function<void(int,int)> dfs=[&](int u,int fa){
        vis[u]=1;
        for(auto v:e[u]){
            if(v==fa || vis[v]) continue;
            deg[u]++;
            deg[v]++;
            dfs(v,u);
        }
    };
    // cout<<root<<endl;
    vis[root]=1;
    for(auto i:e[root]){
        dfs(i,root);
    }
    int ans=0;
    for(int i=1;i<=n;i++) ans=max(ans,deg[i]);
    // cout<<maxn<<' '<<ans<<endl;
    // if(!ans) ans=maxn-1;
    // else if(ans==1)ans=maxn;
    // else ans+=maxn;
    ans+=maxn-1;
    cout<<ans<<endl;
}
signed main(){
    cin.tie(0)->sync_with_stdio(0);
    int t=1;cin>>t;
    while(t--) solve();
    return 0;
}
Problem: 2050E - Three Strings
Language: C++20 (GCC 13-64)


Submission (verdict: Memory limit exceeded on test 1):
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define x first
#define y second
#define pb push_back
#define ssize(x) (int)(x.size())

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
const int N = 1e5 + 10, inf = 0x3f3f3f3f;
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};

string a, b, c;
int dp[N][N];

void slove()
{
	// --L.Cat
	cin >> a >> b >> c;
	int n = ssize(a), m = ssize(b);
	for (int i = 0; i <= ssize(a); i++)
	{
		for (int j = 0; j <= ssize(b); j++)
		{
			dp[i][j] = inf;
		}
	}
	dp[0][0] = 0;
	for (int i = 0; i < ssize(a); i++)
	{
		dp[i + 1][0] = dp[i][0] + (a[i] != c[i]);
	}

	for (int i = 0; i < ssize(b); i++)
	{
		dp[0][i + 1] = dp[0][i + 1] + (b[i] != c[i]);
	}

	for (int i = 1; i <= ssize(a); i++)
	{
		for (int j = 1; j <= ssize(b); 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] << endl;
}

int main()
{
	IOS;
	int T = 1;
	cin >> T;
	while (T--)
	{
		slove();
	}
	return 0;
}
Problem: 2050E - Three Strings
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define x first
#define y second
#define pb push_back
#define ssize(x) (int)(x.size())

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
const int N = 1e3 + 10, inf = 0x3f3f3f3f;
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};

string a, b, c;
int dp[N][N];

void slove()
{
	// --L.Cat
	cin >> a >> b >> c;
	int n = ssize(a), m = ssize(b);
	for (int i = 0; i <= ssize(a); i++)
	{
		for (int j = 0; j <= ssize(b); j++)
		{
			dp[i][j] = inf;
		}
	}
	dp[0][0] = 0;
	for (int i = 0; i < ssize(a); i++)
	{
		dp[i + 1][0] = dp[i][0] + (a[i] != c[i]);
	}

	for (int i = 0; i < ssize(b); i++)
	{
		dp[0][i + 1] = dp[0][i + 1] + (b[i] != c[i]);
	}

	for (int i = 1; i <= ssize(a); i++)
	{
		for (int j = 1; j <= ssize(b); 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] << endl;
}

int main()
{
	IOS;
	int T = 1;
	cin >> T;
	while (T--)
	{
		slove();
	}
	return 0;
}

Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define x first
#define y second
#define pb push_back
#define ssize(x) (int)(x.size())

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
const int N = 1e3 + 10, inf = 0x3f3f3f3f;
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};

string a, b, c;
int dp[N][N];

void slove()
{
	// --L.Cat
	cin >> a >> b >> c;
	int n = ssize(a), m = ssize(b);
	for (int i = 0; i <= ssize(a) + 1; i++)
	{
		for (int j = 0; j <= ssize(b) + 1; j++)
		{
			dp[i][j] = inf;
		}
	}
	dp[0][0] = 0;
	for (int i = 0; i < ssize(a); i++)
	{
		dp[i + 1][0] = dp[i][0] + (a[i] != c[i]);
	}

	for (int i = 0; i < ssize(b); i++)
	{
		dp[0][i + 1] = dp[0][i + 1] + (b[i] != c[i]);
	}

	for (int i = 1; i <= ssize(a); i++)
	{
		for (int j = 1; j <= ssize(b); 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] << endl;
}

int main()
{
	IOS;
	int T = 1;
	cin >> T;
	while (T--)
	{
		slove();
	}
	return 0;
}
Problem: 2050E - Three Strings
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define x first
#define y second
#define pb push_back
#define ssize(x) (int)(x.size())

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
const int N = 1e3 + 10, inf = 0x3f3f3f3f;
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};

string a, b, c;
int dp[N][N];

void slove()
{
	// --L.Cat
	cin >> a >> b >> c;
	int n = ssize(a), m = ssize(b);
	for (int i = 0; i <= ssize(a) + 1; i++)
	{
		for (int j = 0; j <= ssize(b) + 1; j++)
		{
			dp[i][j] = inf;
		}
	}
	dp[0][0] = 0;
	for (int i = 0; i < ssize(a); i++)
	{
		dp[i + 1][0] = dp[i][0] + (a[i] != c[i]);
	}

	for (int i = 0; i < ssize(b); i++)
	{
		dp[0][i + 1] = dp[0][i + 1] + (b[i] != c[i]);
	}

	for (int i = 1; i <= ssize(a); i++)
	{
		for (int j = 1; j <= ssize(b); 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] << endl;
}

int main()
{
	IOS;
	int T = 1;
	cin >> T;
	while (T--)
	{
		slove();
	}
	return 0;
}

Submission (verdict: Accepted):
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define x first
#define y second
#define pb push_back
#define ssize(x) (int)(x.size())

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
const int N = 1e3 + 10, inf = 0x3f3f3f3f;
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};

string a, b, c;
int dp[N][N];

void slove()
{
	// --L.Cat
	cin >> a >> b >> c;
	int n = ssize(a), m = ssize(b);
	for (int i = 0; i <= ssize(a) + 1; i++)
	{
		for (int j = 0; j <= ssize(b) + 1; j++)
		{
			dp[i][j] = inf;
		}
	}
	dp[0][0] = 0;
	for (int i = 0; i < ssize(a); i++)
	{
		dp[i + 1][0] = dp[i][0] + (a[i] != c[i]);
	}

	for (int i = 0; i < ssize(b); i++)
	{
		dp[0][i + 1] = dp[0][i] + (b[i] != c[i]);
	}

	for (int i = 1; i <= ssize(a); i++)
	{
		for (int j = 1; j <= ssize(b); 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] << endl;
}

int main()
{
	IOS;
	int T = 1;
	cin >> T;
	while (T--)
	{
		slove();
	}
	return 0;
}
Problem: 2050E - Three Strings
Language: C++20 (GCC 13-64)

Previous submission (verdict: Memory limit exceeded on test 1):
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define x first
#define y second
#define pb push_back
#define ssize(x) (int)(x.size())

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
const int N = 1e5 + 10, inf = 0x3f3f3f3f;
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};

string a, b, c;
int dp[N][N];

void slove()
{
	// --L.Cat
	cin >> a >> b >> c;
	int n = ssize(a), m = ssize(b);
	for (int i = 0; i <= ssize(a); i++)
	{
		for (int j = 0; j <= ssize(b); j++)
		{
			dp[i][j] = inf;
		}
	}
	dp[0][0] = 0;
	for (int i = 0; i < ssize(a); i++)
	{
		dp[i + 1][0] = dp[i][0] + (a[i] != c[i]);
	}

	for (int i = 0; i < ssize(b); i++)
	{
		dp[0][i + 1] = dp[0][i + 1] + (b[i] != c[i]);
	}

	for (int i = 1; i <= ssize(a); i++)
	{
		for (int j = 1; j <= ssize(b); 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] << endl;
}

int main()
{
	IOS;
	int T = 1;
	cin >> T;
	while (T--)
	{
		slove();
	}
	return 0;
}

Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define x first
#define y second
#define pb push_back
#define ssize(x) (int)(x.size())

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
const int N = 1e3 + 10, inf = 0x3f3f3f3f;
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};

string a, b, c;
int dp[N][N];

void slove()
{
	// --L.Cat
	cin >> a >> b >> c;
	int n = ssize(a), m = ssize(b);
	for (int i = 0; i <= ssize(a); i++)
	{
		for (int j = 0; j <= ssize(b); j++)
		{
			dp[i][j] = inf;
		}
	}
	dp[0][0] = 0;
	for (int i = 0; i < ssize(a); i++)
	{
		dp[i + 1][0] = dp[i][0] + (a[i] != c[i]);
	}

	for (int i = 0; i < ssize(b); i++)
	{
		dp[0][i + 1] = dp[0][i + 1] + (b[i] != c[i]);
	}

	for (int i = 1; i <= ssize(a); i++)
	{
		for (int j = 1; j <= ssize(b); 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] << endl;
}

int main()
{
	IOS;
	int T = 1;
	cin >> T;
	while (T--)
	{
		slove();
	}
	return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(), (x).end()
#define allr(x) (x).rbegin(), (x).rend()
#define endl '\n'
#define KeepGoing ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define Yes cout << "Yes"
#define No cout << "No"
#define YES cout << "YES"
#define NO cout << "NO"
#define endl '\n'
#define nl cout << "\n";
#define print(x) for(auto &y : x)cout << y << ' ';
#define debug(...) cerr << "(" << #__VA_ARGS__ << ") = ", dbg(__VA_ARGS__)
void dbg() { cerr << endl; }
template <typename T, typename... Args>
void dbg(T first, Args... rest) {
    cerr << first << " ";
    dbg(rest...);
}
#define debugArr(arr) cerr << #arr << " = "; for (auto x : arr) cerr << x << " "; cerr << endl;
#define trace() cerr << __FUNCTION__ << " called at line " << __LINE__ << endl;
#define NDEBUG  // Disable assertions
bool valid(int i, int j, int nx, int ny){
    return (nx >= 0 && nx < i && ny >= 0 && ny < j);
}
void solve() {
int n;
cin >> n;
vector<int> v(n);
int ans = 0;
for(auto &x: v) {
    cin >> x;
    ans += x;
}
while(v.size() > 1){
    vector<int> t2, t3;
    int sum1 = 0, sum2 = 0;
    for(int i = 1; i < v.size(); ++i){
        t2.push_back(v[i] - v[i - 1]);
        sum1 += (v[i] - v[i - 1]);
    }
    reverse(all(v));
    for(int i = 1; i < v.size(); ++i){
        t3.push_back(v[i] - v[i - 1]);
        sum2 += (v[i] - v[i - 1]);
    }
    if(sum1 >= sum2){
        v = t2;
    }
    else{
        v = t3;
    }
    ans = max({ans, sum1, sum2});
}
cout << ans;
}
int main() {
        
    KeepGoing
    int t = 1; 
    cin >> t;    
    while (t--) {
        solve();
        cout << "\n";
        }
        return 0;
    }


    /*

            .  .
            |\_|\
            | a_a\
            | | "]
        ____| '-\___
        /.----.___.-'\
        //        _    \
    //   .-. (~B~) /|
    |'|  /\:  .--  / \
    // |-/  \_/____/\/~|
    |/  \ |  []_|_|_] \ |
    | \  | \ |___   _\ ]_}
    | |  '-' /   '.'  |
    | |     /    /|:  | 
    | |     |   / |:  /\
    | |     /  /  |  /  \
    | |    |  /  /  |    \
    \ |    |/\/  |/|/\    \
    \|\ |\|  |  | / /\/\__\
    \ \| | /   | |__
        / |   |____)
        |_/



    */
Problem: 2052A - Adrenaline Rush
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 5):
#include<bits/stdc++.h>
using namespace std;
#define ll unsigned long long
#define I inline
#define reg register
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define fi first
#define se second
#define i128 __int128
#define uint unsigned int
constexpr int N=1100;
int n,c[N],p[N],vis[N][N];
stack<pii>st;
int main(){
  cin>>n;
  for(int i=1;i<=n;i++)cin>>c[i];
  for(int i=1;i<=n;i++)p[c[i]]=i;
  for(int i=n;i;i--)
    for(int j=p[i]+1;j<=i;j++)
      vis[c[j-1]][c[j]]=1,vis[c[j]][c[j-1]]=1,
      st.push(mp(c[j-1],c[j])),swap(c[j-1],c[j]);
  for(int i=n;i;i--){
    int j=0;
    for(j=i-1;j&&!vis[c[j]][c[j+1]];j--)
      st.push(mp(c[j],c[j+1])),swap(c[j],c[j+1]);
    for(j=j+1;j<i;j++)
      st.push(mp(c[j],c[j+1])),swap(c[j],c[j+1]);
  }
  cout<<st.size()<<'\n';
  while(!st.empty()){
    pii u=st.top();
    cout<<u.fi<<' '<<u.se<<'\n';
    st.pop();
  }
  return 0;
}

Submission (verdict: Wrong answer on test 7):
#include<bits/stdc++.h>
using namespace std;
#define ll unsigned long long
#define I inline
#define reg register
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define fi first
#define se second
#define i128 __int128
#define uint unsigned int
constexpr int N=1100;
int n,c[N],p[N],vis[N][N];
stack<pii>st;
int main(){
  cin>>n;
  for(int i=1;i<=n;i++)cin>>c[i];
  for(int i=1;i<=n;i++)p[c[i]]=i;
  for(int i=n;i;i--)
    for(int j=p[i]+1;j<=i;j++)
      vis[c[j-1]][c[j]]=1,vis[c[j]][c[j-1]]=1,p[c[j]]=j-1,
      st.push(mp(c[j-1],c[j])),swap(c[j-1],c[j]);
  for(int i=n;i;i--){
    int j=0;
    for(j=i-1;j&&!vis[c[j]][c[j+1]];j--)
      st.push(mp(c[j],c[j+1])),swap(c[j],c[j+1]);
    for(j+=1;j<i;j++)
      st.push(mp(c[j],c[j+1])),swap(c[j],c[j+1]);
  }
  cout<<st.size()<<'\n';
  while(!st.empty()){
    pii u=st.top();
    cout<<u.fi<<' '<<u.se<<'\n';
    st.pop();
  }
  return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
#define ll unsigned long long
#define I inline
#define reg register
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define fi first
#define se second
#define i128 __int128
#define uint unsigned int
constexpr int N=1100;
int n,c[N],p[N],vis[N][N];
stack<pii>st;
int main(){
  cin>>n;
  for(int i=1;i<=n;i++)cin>>c[i];
  for(int i=1;i<=n;i++)p[c[i]]=i;
  for(int i=n;i;i--)
    for(int j=p[i]+1;j<=i;j++)
      vis[c[j-1]][c[j]]=1,vis[c[j]][c[j-1]]=1,
      st.push(mp(c[j-1],c[j])),swap(c[j-1],c[j]);
  for(int i=n;i;i--){
    int j=0;
    for(j=i-1;j&&!vis[c[j]][c[j+1]];j--)
      st.push(mp(c[j],c[j+1])),swap(c[j],c[j+1]);
    for(j=j+1;j<i;j++)
      st.push(mp(c[j],c[j+1])),swap(c[j],c[j+1]);
  }
  cout<<st.size()<<'\n';
  while(!st.empty()){
    pii u=st.top();
    cout<<u.se<<' '<<u.fi<<'\n';
    st.pop();
  }
  return 0;
}