ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2060D - Subtract Min Sort
Language: C++20 (GCC 13-64)

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

using namespace std;

void solve(vector<int>& v){

    

    

    if(v.size()==1){

        cout<<"YES"<<endl;

        return;

    }

    if(v[1]<v[0]){

        cout<<"NO"<<endl;

        return;

    }

    v[1]=v[1]-v[0];

    vector<int> tt1(v.begin()+1,v.end());

    solve(tt1);



}

signed main(){

    ios::sync_with_stdio(false);

    cin.tie(nullptr);

    int t;

    cin>>t;

    while(t--){

        int n;

        cin>>n;

        vector<int> v(n);

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

            cin>>v[i];

        }

        solve(v);

    }

    return 0;

}

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

using namespace std;

void solve(){

    int n;

    cin>>n;

    vector<int> v(n);

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

        cin>>v[i];

    }

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

        if(v[i]>v[i+1]){

            cout<<"NO"<<endl;

            return;

        }

        v[i+1]-=v[i];

        v[i]=0;

        

    }



    cout<<"YES"<<endl;



    

    



}

signed main(){

    ios::sync_with_stdio(false);

    cin.tie(nullptr);

    int t;

    cin>>t;

    while(t--){

        solve();

    }

    return 0;

}
Problem: 2049C - MEX Cycle
Language: C++20 (GCC 13-64)

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

using namespace std;

int arr[200005];



void solve(){

	int n,x,y;

	cin>>n>>x>>y;

	if(n&1){

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

			arr[i-1]=0;

			arr[i]=1;

		}

		arr[n]=2;

		if(arr[x]==0&&arr[y]==0){

			if(arr[x]==1&&arr[y]==1){

				if(x==n-1||x==1)swap(arr[x],arr[n]);

				else arr[x]=2;

			}

		}

		if(arr[x]==1&&arr[y]==1){

			if(arr[x]==1&&arr[y]==1){

				if(x==n-1||x==1)swap(arr[x],arr[n]);

				else arr[x]=2;

			}

		}

	}else{

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

			arr[i-1]=0;

			arr[i]=1;

		}

		if(arr[x]==0&&arr[y]==0){

			if(arr[x]==1&&arr[y]==1){

				if(x==n-1||x==1)swap(arr[x],arr[n]);

				else arr[x]=2;

			}

		}

		if(arr[x]==1&&arr[y]==1){

			if(arr[x]==1&&arr[y]==1){

				if(x==n-1||x==1)swap(arr[x],arr[n]);

				else arr[x]=2;

			}

		}

	}

	for(int i = 1; i <= n; i ++) cout << arr[i] << " ";

    cout << "\n";

}



int main(){

	int t;

	cin>>t;

	while(t--)solve();

}

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

using namespace std;

int arr[200005];



void solve(){

	int n,x,y;

	cin>>n>>x>>y;

	if(n&1){

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

			arr[i-1]=0;

			arr[i]=1;

		}

		arr[n]=2;

		if(arr[x]==0&&arr[y]==0){

				if(x==n-1||x==1)swap(arr[x],arr[n]);

				else arr[x]=2;

		}

		if(arr[x]==1&&arr[y]==1){

				if(x==n-1||x==1)swap(arr[x],arr[n]);

				else arr[x]=2;

		}

	}else{

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

			arr[i-1]=0;

			arr[i]=1;

		}

		if(arr[x]==0&&arr[y]==0){

				if(x==n-1||x==1)swap(arr[x],arr[n]);

				else arr[x]=2;

		}

		if(arr[x]==1&&arr[y]==1){

				if(x==n-1||x==1)swap(arr[x],arr[n]);

				else arr[x]=2;

		}

	}

	for(int i = 1; i <= n; i ++) cout << arr[i] << " ";

    cout << "\n";

}



int main(){

	int t;

	cin>>t;

	while(t--)solve();

}
Problem: 2049C - MEX Cycle
Language: C++20 (GCC 13-64)

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

using namespace std;

int arr[200005];



void solve(){

	int n,x,y;

	cin>>n>>x>>y;

	if(n&1){

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

			arr[i-1]=0;

			arr[i]=1;

		}

		arr[n]=2;

		if(arr[x]==0&&arr[y]==0){

				if(x==n-1||x==1)swap(arr[x],arr[n]);

				else arr[x]=2;

		}

		if(arr[x]==1&&arr[y]==1){

				if(x==n-1||x==1)swap(arr[x],arr[n]);

				else arr[x]=2;

		}

	}else{

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

			arr[i-1]=0;

			arr[i]=1;

		}

		if(arr[x]==0&&arr[y]==0){

				if(x==n-1||x==1)swap(arr[x],arr[n]);

				else arr[x]=2;

		}

		if(arr[x]==1&&arr[y]==1){

				if(x==n-1||x==1)swap(arr[x],arr[n]);

				else arr[x]=2;

		}

	}

	for(int i = 1; i <= n; i ++) cout << arr[i] << " ";

    cout << "\n";

}



int main(){

	int t;

	cin>>t;

	while(t--)solve();

}

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

using namespace std;

int arr[200005];



void solve(){

	int n,x,y;

	cin>>n>>x>>y;

	if(n&1){

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

			arr[i-1]=0;

			arr[i]=1;

		}

		arr[n]=2;

		if(arr[x]==0&&arr[y]==0){

				if(x==n-1||x==1)swap(arr[x],arr[n]);

				else arr[x]=2;

		}

		if(arr[x]==1&&arr[y]==1){

				if(x==n-1||x==1)swap(arr[x],arr[n]);

				else arr[x]=2;

		}

	}else{

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

			arr[i-1]=0;

			arr[i]=1;

		}

		if(arr[x]==0&&arr[y]==0){

				if(x==n-1||x==1)swap(arr[x],arr[n]);

				else arr[x]=2;

		}

		if(arr[x]==1&&arr[y]==1){

				if(x==n-1||x==1)swap(arr[x],arr[n]);

				else arr[x]=2;

		}

	}

	for(int i = 1; i <= n; i ++) cout << arr[i] << " ";

    cout << "\n";

}



int main(){

	int t;

	cin>>t;

	while(t--)solve();

}
Problem: 2049C - MEX Cycle
Language: C++20 (GCC 13-64)


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

using namespace std;

int arr[200005];



void solve(){

	int n,x,y;

	cin>>n>>x>>y;

	if(n&1){

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

			arr[i-1]=0;

			arr[i]=1;

		}

		arr[n]=2;

		if(arr[x]==0&&arr[y]==0){

			if(arr[x]==1&&arr[y]==1){

				if(x==n-1||x==1)swap(arr[x],arr[n]);

				else arr[x]=2;

			}

		}

		if(arr[x]==1&&arr[y]==1){

			if(arr[x]==1&&arr[y]==1){

				if(x==n-1||x==1)swap(arr[x],arr[n]);

				else arr[x]=2;

			}

		}

	}else{

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

			arr[i-1]=0;

			arr[i]=1;

		}

		if(arr[x]==0&&arr[y]==0){

			if(arr[x]==1&&arr[y]==1){

				if(x==n-1||x==1)swap(arr[x],arr[n]);

				else arr[x]=2;

			}

		}

		if(arr[x]==1&&arr[y]==1){

			if(arr[x]==1&&arr[y]==1){

				if(x==n-1||x==1)swap(arr[x],arr[n]);

				else arr[x]=2;

			}

		}

	}

	for(int i = 1; i <= n; i ++) cout << arr[i] << " ";

    cout << "\n";

}



int main(){

	int t;

	cin>>t;

	while(t--)solve();

}
Problem: 2049C - MEX Cycle
Language: C++20 (GCC 13-64)

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

using namespace std;

int arr[200005];



void solve(){

	int n,x,y;

	cin>>n>>x>>y;

	if(n&1){

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

			arr[i-1]=0;

			arr[i]=1;

		}

		arr[n]=2;

		if(arr[x]==0&&arr[y]==0){

				if(x==n-1||x==1)swap(arr[x],arr[n]);

				else arr[x]=2;

		}

		if(arr[x]==1&&arr[y]==1){

				if(x==n-1||x==1)swap(arr[x],arr[n]);

				else arr[x]=2;

		}

	}else{

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

			arr[i-1]=0;

			arr[i]=1;

		}

		if(arr[x]==0&&arr[y]==0){

				if(x==n-1||x==1)swap(arr[x],arr[n]);

				else arr[x]=2;

		}

		if(arr[x]==1&&arr[y]==1){

				if(x==n-1||x==1)swap(arr[x],arr[n]);

				else arr[x]=2;

		}

	}

	for(int i = 1; i <= n; i ++) cout << arr[i] << " ";

    cout << "\n";

}



int main(){

	int t;

	cin>>t;

	while(t--)solve();

}

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

using namespace std;

int arr[200005];



void solve(){

	int n,x,y;

	cin>>n>>x>>y;

	if(n&1){

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

			arr[i-1]=0;

			arr[i]=1;

		}

		arr[n]=2;

		if(arr[x]==0&&arr[y]==0){

				if(x==n-1||x==1)swap(arr[x],arr[n]);

				else arr[x]=2;

		}

		if(arr[x]==1&&arr[y]==1){

				if(x==n-1||x==1)swap(arr[x],arr[n]);

				else arr[x]=2;

		}

	}else{

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

			arr[i-1]=0;

			arr[i]=1;

		}

		if(arr[x]==0&&arr[y]==0){

			arr[x]=2;

		}

		if(arr[x]==1&&arr[y]==1){

			arr[x]=2;

		}

	}

	for(int i = 1; i <= n; i ++) cout << arr[i] << " ";

    cout << "\n";

}



int main(){

	int t;

	cin>>t;

	while(t--)solve();

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


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

void solve() {
	string a, b, c; cin >> a >> b >> c;
	int n = a.size(); int m = b.size();

	vector<vector<int>> dp(n+1, vector<int>(m+1, 1e9));
	dp[0][0] = 0;
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j <= m; j++) {
			bool changeA = !(a[i-1] == c[i+j-1]);
			bool changeB = !(b[j-1] == c[i+j-1]);

			dp[i][j] = min(dp[i-1][j] + changeA, dp[i][j-1] + changeB);
		}
	}

	cout << dp[n][m] << endl;
}

int main() {
	int t; cin >> t;

	while (t--) {
		solve();
	}
}
Problem: 2050E - Three Strings
Language: C++17 (GCC 7-32)

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

void solve() {
	string a, b, c; cin >> a >> b >> c;
	int n = a.size(); int m = b.size();

	vector<vector<int>> dp(n+1, vector<int>(m+1, 1e9));
	dp[0][0] = 0;
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j <= m; j++) {
			bool changeA = !(a[i-1] == c[i+j-1]);
			bool changeB = !(b[j-1] == c[i+j-1]);

			dp[i][j] = min(dp[i-1][j] + changeA, dp[i][j-1] + changeB);
		}
	}

	cout << dp[n][m] << endl;
}

int main() {
	int t; cin >> t;

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


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

#define int long long

void solve() {
	string a, b, c; cin >> a >> b >> c;
	int n = a.size(); int m = b.size();

	vector<vector<int>> dp(n+1, vector<int>(m+1, 1e9));
	dp[0][0] = 0;
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j <= m; j++) {
			bool changeA = !(a[i-1] == c[i+j-1]);
			bool changeB = !(b[j-1] == c[i+j-1]);

			dp[i][j] = min(dp[i-1][j] + changeA, dp[i][j-1] + changeB);
		}
	}

	cout << dp[n][m] << endl;
}

signed main() {
	int t; cin >> t;

	while (t--) {
		solve();
	}
}
Problem: 2050E - Three Strings
Language: C++17 (GCC 7-32)

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

#define int long long

void solve() {
	string a, b, c; cin >> a >> b >> c;
	int n = a.size(); int m = b.size();

	vector<vector<int>> dp(n+1, vector<int>(m+1, 1e9));
	dp[0][0] = 0;
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j <= m; j++) {
			bool changeA = !(a[i-1] == c[i+j-1]);
			bool changeB = !(b[j-1] == c[i+j-1]);

			dp[i][j] = min(dp[i-1][j] + changeA, dp[i][j-1] + changeB);
		}
	}

	cout << dp[n][m] << endl;
}

signed main() {
	int t; cin >> t;

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


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

#define int long long

void solve() {
	string a, b, c; cin >> a >> b >> c;
	int n = a.size(); int m = b.size();

	vector<vector<int>> dp(n+1, vector<int>(m+1, 1e9));
	dp[0][0] = 0;
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= m; j++) {
			if (i < n) {
				int changeA = (a[i] != c[i+j]);
				dp[i+1][j] = min(dp[i+1][j], dp[i][j] + changeA);
			} 

			if (j < m) {
				int changeB = (b[j] != c[i+j]);
				dp[i][j+1] = min(dp[i][j+1], dp[i][j] + changeB);
			}
		}
	}

	cout << dp[n][m] << endl;
}

signed main() {
	int t; cin >> t;

	while (t--) {
		solve();
	}
}
Problem: 2050B - Transfusion
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 3):
#include <iostream>

#include <fstream>

using namespace std;

int x,n,a,s,s1,s2;

int main()

{

    //ifstream cin ("input.txt");

    //ofstream cout ("output.txt");

    cin>>x;

    for(int j=0;j<x;j++){

        cin>>n;

        s=0;

        s1=0;

        s2=0;

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

            cin>>a;

            s+=a;

            if(i%2==0){

                s1+=a;

            }else{

                s2+=a;

            }

        }

        if(s%n!=0){

            cout<<"no"<<'\n';

        }else{

            if(n%2==0){

                if(s1==s2){

                    cout<<"yes"<<'\n';

                }else{

                    cout<<"no"<<'\n';

                }

            }else{

                if(s1==s2+s/n){

                    cout<<"yes"<<'\n';

                }else{

                    cout<<"no"<<'\n';

                }

            }

        }

    }

    return 0;

}
Problem: 2050B - Transfusion
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 3):
#include <iostream>

#include <fstream>

using namespace std;

int x,n,a,s,s1,s2;

int main()

{

    //ifstream cin ("input.txt");

    //ofstream cout ("output.txt");

    cin>>x;

    for(int j=0;j<x;j++){

        cin>>n;

        s=0;

        s1=0;

        s2=0;

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

            cin>>a;

            s+=a;

            if(i%2==0){

                s1+=a;

            }else{

                s2+=a;

            }

        }

        if(s%n!=0){

            cout<<"no"<<'\n';

        }else{

            if(n%2==0){

                if(s1==s2){

                    cout<<"yes"<<'\n';

                }else{

                    cout<<"no"<<'\n';

                }

            }else{

                if(s1==s2+s/n){

                    cout<<"yes"<<'\n';

                }else{

                    cout<<"no"<<'\n';

                }

            }

        }

    }

    return 0;

}



Submission (verdict: Wrong answer on test 3):
#include <iostream>

#include <fstream>

using namespace std;

int x,n,a,s,s1,s2;

int main()

{

    //ifstream cin ("input.txt");

    //ofstream cout ("output.txt");

    cin>>x;

    for(int j=0;j<x;j++){

        cin>>n;

        s=0;

        s1=0;

        s2=0;

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

            cin>>a;

            s+=a;

            if(i%2==0){

                s1+=a;

            }else{

                s2+=a;

            }

        }

        if(s%n!=0){

            cout<<"NO"<<'\n';

        }else{

            if(n%2==0){

                if(s1==s2){

                    cout<<"YES"<<'\n';

                }else{

                    cout<<"NO"<<'\n';

                }

            }else{

                if(s1==s2+s/n){

                    cout<<"YES"<<'\n';

                }else{

                    cout<<"NO"<<'\n';

                }

            }

        }

    }

    return 0;

}
Problem: 2050B - Transfusion
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 3):
#include <iostream>

#include <fstream>

using namespace std;

int x,n,a,s,s1,s2;

int main()

{

    //ifstream cin ("input.txt");

    //ofstream cout ("output.txt");

    cin>>x;

    for(int j=0;j<x;j++){

        cin>>n;

        s=0;

        s1=0;

        s2=0;

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

            cin>>a;

            s+=a;

            if(i%2==0){

                s1+=a;

            }else{

                s2+=a;

            }

        }

        if(s%n!=0){

            cout<<"NO"<<'\n';

        }else{

            if(n%2==0){

                if(s1==s2){

                    cout<<"YES"<<'\n';

                }else{

                    cout<<"NO"<<'\n';

                }

            }else{

                if(s1==s2+s/n){

                    cout<<"YES"<<'\n';

                }else{

                    cout<<"NO"<<'\n';

                }

            }

        }

    }

    return 0;

}



Submission (verdict: Accepted):
#include <iostream>

#include <fstream>

using namespace std;

long long x,n,a,s,s1,s2;

int main()

{

    //ifstream cin ("input.txt");

    //ofstream cout ("output.txt");

    cin>>x;

    for(int j=0;j<x;j++){

        cin>>n;

        s=0;

        s1=0;

        s2=0;

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

            cin>>a;

            s+=a;

            if(i%2==0){

                s1+=a;

            }else{

                s2+=a;

            }

        }

        if(s%n!=0){

            cout<<"NO"<<'\n';

        }else{

            if(n%2==0){

                if(s1==s2){

                    cout<<"YES"<<'\n';

                }else{

                    cout<<"NO"<<'\n';

                }

            }else{

                if(s1==s2+s/n){

                    cout<<"YES"<<'\n';

                }else{

                    cout<<"NO"<<'\n';

                }

            }

        }

    }

    return 0;

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


Submission (verdict: Time limit exceeded on test 14):
//Hara Hara Mahadev
#include<bits/stdc++.h>
using namespace std;
 
#define int 	long long
#define pi      3.1415926535897932384626433832795028841971693993751058
#define YES     cout<<"YES"<<"\n"
#define NO      cout<<"NO"<<"\n"
#define m1      cout<<-1<<"\n"
#define ssort(S)  sort((S).begin(),(S).end())
#define srev(S)   reverse((S).begin(),(S).end())
#define ll      long long
#define pb      push_back
#define vi      vector<int>
#define vvi 	vector<vector<int>>
#define vll      vector<long long>
#define vc      vector<char>
#define pii     pair<int,int>
#define vpii    vector<pair<int,int>>
#define vs	 vector<string>
#define all(arr)  (arr).begin(), (arr).end()
#define for0(i, n) for (int i = 0; i < n; i++)
#define inp(v) for (auto & a : (v)) cin >> a;
#define endl "\n"
#define speed (ios_base:: sync_with_stdio(false),cin.tie(NULL))
#define mod 1000000007
 
int gcd(int a,int b) { if (a == 0) return b; return gcd(b%a, a);}
int max(int a,int b){if(a>b) return a; else return b;}
int min(int a,int b){if(a<b) return a; else return b;}  

int ceil_div(int a, int b) {
   return a / b + ((a ^ b) > 0 && a % b != 0);
}

void solve()
{
   int n,k;
   cin >> n >> k;

   unordered_map<int,int> mpp;
   for0(i, n) {
        int x; cin >> x; mpp[x]++;
   }

   priority_queue<pii, vpii, greater<pii>> pq;
   for(auto [ele, f]: mpp)
        pq.push({f, ele});

    while(!pq.empty() && k>0) {
        auto it = pq.top();
        pq.pop();
        int f = it.first;
        if(f>k) {
            pq.push(it);
            break;
        }
        else {
            k -= f;
        }
    }

    cout << max(1,pq.size()) << endl;
}

int t = 1;
int32_t main() {
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0),cin>>t;
    //cin >> t;
    while(t--){solve();}
    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
    cin >> t;
    while(t--)
    {
        int n;
        cin >> n;
        vector<int> a(n);
        int sum = 0;
        for(int i = 0; i < n; i++)
        {
            cin >> a[i];
            sum+=a[i];
        }
        vector<int> c = a;
        reverse(a.begin(), a.end());
        while(a.size()!=1)
        {
            vector<int> b, d;
            for(int i = 0; i < a.size()-1; i++)
            {
                b.push_back(a[i+1]-a[i]);
                d.push_back(c[i+1]-c[i]);
            }
            a=b;
            c=d;
            reverse(a.begin(), a.end());
            int sum1 = 0, sum2 = 0;
            for(int i = 0; i < a.size(); i++)
            {
                sum1+=a[i];
                sum2+=c[i];
            }
            sum=max(sum, max(sum1, sum2));
        }
        cout << sum << endl;
    }
}

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
    cin >> t;
    while(t--)
    {
        long long n;
        cin >> n;
        vector<long long> a(n);
        long long sum = 0;
        for(long long i = 0; i < n; i++)
        {
            cin >> a[i];
            sum+=a[i];
        }
        vector<long long> c = a;
        reverse(a.begin(), a.end());
        while(a.size()!=1)
        {
            vector<long long> b, d;
            for(long long i = 0; i < a.size()-1; i++)
            {
                b.push_back(a[i+1]-a[i]);
                d.push_back(c[i+1]-c[i]);
            }
            a=b;
            c=d;
            reverse(a.begin(), a.end());
            long long sum1 = 0, sum2 = 0;
            for(int i = 0; i < a.size(); i++)
            {
                sum1+=a[i];
                sum2+=c[i];
            }
            sum=max(sum, max(sum1, sum2));
        }
        cout << sum << endl;
    }
}
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)


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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
    cin >> t;
    while(t--)
    {
        int n;
        cin >> n;
        vector<int> a(n);
        int sum = 0;
        for(int i = 0; i < n; i++)
        {
            cin >> a[i];
            sum+=a[i];
        }
        vector<int> c = a;
        reverse(a.begin(), a.end());
        while(a.size()!=1)
        {
            vector<int> b, d;
            for(int i = 0; i < a.size()-1; i++)
            {
                b.push_back(a[i+1]-a[i]);
                d.push_back(c[i+1]-c[i]);
            }
            a=b;
            c=d;
            reverse(a.begin(), a.end());
            int sum1 = 0, sum2 = 0;
            for(int i = 0; i < a.size(); i++)
            {
                sum1+=a[i];
                sum2+=c[i];
            }
            sum=max(sum, max(sum1, sum2));
        }
        cout << sum << endl;
    }
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    cin >> t;
    while (t--)
    {
        int n;
        cin >> n;
        int a[n];
        for (int i = 0; i < n; i++)
            cin >> a[i];
        // n=n+1;
        int p = n, maxi = 0;
        if (n == 1)
        {
            cout << a[0] << endl;
            continue;
        }
        while (n--)
        {
            int s = 0;
            for (int i = 0; i < p; i++)
                s += a[i];
            if (s < 0)
                maxi = max(maxi, -s);
            else
                maxi = max(maxi, s);
            for (int i = 0; i < p - 1; i++)
            {
                a[i] = a[i + 1] - a[i];
            }
            p--;
        }
        cout << maxi << endl;
    }
    return 0;
}

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    cin >> t;
    while (t--)
    {
        ll n;
        cin >> n;
        ll a[n];
        for (ll i = 0; i < n; i++)
            cin >> a[i];
        // n=n+1;
        ll p = n, maxi = 0;
        if (n == 1)
        {
            cout << a[0] << endl;
            continue;
        }
        while (n--)
        {
            ll s = 0;
            for (int i = 0; i < p; i++)
                s += a[i];
            if (s < 0)
                maxi = max(maxi, -s);
            else
                maxi = max(maxi, s);
            for (int i = 0; i < p - 1; i++)
            {
                a[i] = a[i + 1] - a[i];
            }
            p--;
        }
        cout << maxi << endl;
    }
    return 0;
}