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;
#define ll long long
#define vi(v,n) vector<int>(v)((n)); for(int i=0;i<(n);i++){cin>>(v)[i];}
#define vl(v,n) vector<long long>(v)((n)); for(int i=0;i<(n);i++){cin>>(v)[i];}
#define srt(v) sort((v).begin(),(v).end())
#define srtr(v) sort((v).begin(),(v).end(),greater<>())
#define pb push_back
#define nl "\n"
#define yes cout<<"YES\n";
#define no cout<<"NO\n";
#define setbits(x) __builtin_popcountll(x)
#define For(i,b) for(int (i)=0;(i)<(b);(i)++)
#define ff first
#define ss second
#define test ll x86; cin>>x86; while(x86--)
#define all(x) x.begin(),x.end()
#define speed ios_base::sync_with_stdio(false); cin.tie(0), cout.tie(0);
#define pvec(v) for(auto it:(v)){cout<<it<<" ";}cout<<nl
#define mii(a) map<int,int>(a)
#define miir(a) map<int,int,greater<>>(a)  
#define mll(a) map<ll,ll>(a)
#define mllr(a) map<ll,ll,greater<>>(a)
#define pmap(m) for(auto it:(m)){cout<<it.ff<<" "<<it.ss<<nl;}cout<<nl
#define ppvec(v) for(auto it:(v)){cout<<it.ff<<" "<<it.ss<<nl;}cout<<nl
 
const int INF = 1e9+5;
const int mod=1e9+7;


void solve() {
    int n;
    cin>>n;
    vi(a, n);
    ll ans=0;
    if(n==1){
        cout<<a[0]<<endl;
        return;
    }
    for(int i=0; i<n-1; i++){
        ll sum1=0;
        ll sum=0;
        ll rev=0;
        vector<int> v=a;
        for(int j=0; j<a.size(); j++){
            sum1+=a[j];
        }
        for(int j=1; j<a.size(); j++){
            sum+=(a[j]-a[j-1]);
            a[j-1]=a[j]-a[j-1];
        }
        reverse(v.begin(), v.end());
        for(int j=1; j<a.size(); j++){
            rev+=(v[j]-v[j-1]);
            v[j-1]=v[j]-v[j-1];
        }
        vector<int> b(a.size()-1);
        ans=max({sum1, sum, rev});
        if(rev>sum){
            b.assign(v.begin(), v.end() - 1);
        }
        else{
            b.assign(a.begin(), a.end() - 1);
        }
        a=b;
    }
    cout<<ans<<endl;
}
  
int main() {
    test
    solve();
    return 0;
}

Submission (verdict: Wrong answer on test 6):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vi(v,n) vector<int>(v)((n)); for(int i=0;i<(n);i++){cin>>(v)[i];}
#define vl(v,n) vector<long long>(v)((n)); for(int i=0;i<(n);i++){cin>>(v)[i];}
#define srt(v) sort((v).begin(),(v).end())
#define srtr(v) sort((v).begin(),(v).end(),greater<>())
#define pb push_back
#define nl "\n"
#define yes cout<<"YES\n";
#define no cout<<"NO\n";
#define setbits(x) __builtin_popcountll(x)
#define For(i,b) for(int (i)=0;(i)<(b);(i)++)
#define ff first
#define ss second
#define test ll x86; cin>>x86; while(x86--)
#define all(x) x.begin(),x.end()
#define speed ios_base::sync_with_stdio(false); cin.tie(0), cout.tie(0);
#define pvec(v) for(auto it:(v)){cout<<it<<" ";}cout<<nl
#define mii(a) map<int,int>(a)
#define miir(a) map<int,int,greater<>>(a)  
#define mll(a) map<ll,ll>(a)
#define mllr(a) map<ll,ll,greater<>>(a)
#define pmap(m) for(auto it:(m)){cout<<it.ff<<" "<<it.ss<<nl;}cout<<nl
#define ppvec(v) for(auto it:(v)){cout<<it.ff<<" "<<it.ss<<nl;}cout<<nl
 
const int INF = 1e9+5;
const int mod=1e9+7;


void solve() {
    int n;
    cin>>n;
    vl(a, n);
    ll ans=0;
    if(n==1){
        cout<<a[0]<<endl;
        return;
    }
    for(int i=0; i<n-1; i++){
        ll sum1=0;
        ll sum=0;
        ll rev=0;
        vector<ll> v=a;
        for(int j=0; j<a.size(); j++){
            sum1+=a[j];
        }
        for(int j=1; j<a.size(); j++){
            sum+=(a[j]-a[j-1]);
            a[j-1]=a[j]-a[j-1];
        }
        reverse(v.begin(), v.end());
        for(int j=1; j<a.size(); j++){
            rev+=(v[j]-v[j-1]);
            v[j-1]=v[j]-v[j-1];
        }
        vector<ll> b(a.size()-1);
        ans=max({sum1, sum, rev});
        if(rev>sum){
            b.assign(v.begin(), v.end() - 1);
        }
        else{
            b.assign(a.begin(), a.end() - 1);
        }
        a=b;
    }
    cout<<ans<<endl;
}
  
int main() {
    test
    solve();
    return 0;
}