Problem: 2062C - Cirno and Operations
Language: C++23 (GCC 14-64, msys2)

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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

#define debug(i) cout << #i << ' '<<i<<endl;
#define int long long
#define yy cout << "YES\n";
#define nn cout << "NO\n";
#define ff first
#define ss second
#define pb push_back
#define endl "\n"
#define f(i, x, n) for (int i = x; i < n; i++)
#define rf(i, x, n) for (int i = x; i >= n; i--)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
const int inf = LLONG_MAX;
const int mod = 1e9 + 7;
const int mod2 = 998244353;

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

    vector<int> v,v1(n);
    int sum=0;
    f(i,0,n){
        int x;
        cin>>x;
        v.pb(x);
        sum+=v[i];
        v1[i]=v[i];
    }

    int mx=sum;
    f(i,0,n){
        sum=0;
        if(v.size()==1) break;
        reverse(all(v));
        vector<int> a;
        f(j,1,v.size()){
            a.pb(v[j]-v[j-1]);
            sum+=(v[j]-v[j-1]);
        }
        mx=max(mx,sum);
        v.clear();
        f(j,0,a.size()){
            v.pb(a[j]);
        }
    }

    f(i,0,n){
        sum=0;
        if(v.size()==1) break;
        vector<int> a;
        f(j,1,v.size()){
            a.pb(v[j]-v[j-1]);
            sum+=(v[j]-v[j-1]);
        }
        mx=max(mx,sum);
        v.clear();
        f(j,0,a.size()){
            v.pb(a[j]);
        }
        reverse(all(v));
    }

    cout<<mx<<endl;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int T=1;
    cin >> T;

    while (T--) {
        solve();
    }
    return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

#define debug(i) cout << #i << ' '<<i<<endl;
#define int long long
#define yy cout << "YES\n";
#define nn cout << "NO\n";
#define ff first
#define ss second
#define pb push_back
#define endl "\n"
#define f(i, x, n) for (int i = x; i < n; i++)
#define rf(i, x, n) for (int i = x; i >= n; i--)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
const int inf = LLONG_MAX;
const int mod = 1e9 + 7;
const int mod2 = 998244353;

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

    vector<int> v,v1(n);
    int sum=0;
    f(i,0,n){
        int x;
        cin>>x;
        v.pb(x);
        sum+=v[i];
        v1[i]=v[i];
    }

    int mx=sum;
    f(i,0,n){
        sum=0;
        if(v.size()==1) break;
        reverse(all(v));
        vector<int> a;
        f(j,1,v.size()){
            a.pb(v[j]-v[j-1]);
            sum+=(v[j]-v[j-1]);
        }
        mx=max(mx,sum);
        v.clear();
        f(j,0,a.size()){
            v.pb(a[j]);
        }
    }

    f(i,0,n){
        sum=0;
        if(v1.size()==1) break;
        vector<int> a;
        f(j,1,v1.size()){
            a.pb(v1[j]-v1[j-1]);
            sum+=(v1[j]-v1[j-1]);
        }
        mx=max(mx,sum); 
        v1.clear();
        f(j,0,a.size()){
            v.pb(a[j]);
        }
        reverse(all(v1));
    }

    cout<<mx<<endl;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int T=1;
    cin >> T;

    while (T--) {
        solve();
    }
    return 0;
}