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;
#define ll long long
#define vll vector<ll>
#define fi(n) for(int i=0;i<n;i++)
#define f(i,n) for(int i=0;i<n;i++)
#define loop(i,x,n) for(int i=x;i<n;i++)
#define pb push_back
#define lld long double
#define sqrt sqrtl
#define ull unsigned long long
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define pll pair<ll,ll>
#define getSet(x) __builtin_popcountll(x)
#define mp make_pair
#define vbl vector<bool>
#define IOS ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
ll mod1=1e9+7;
ll mod=998244353;
const ll N=1e5;
vector<ll> fact;
vector<ll> infact;

/********************************************************************************************************************************************************************/

ll power(ll a, ll n){ll ans = 1;while (n){if (n & 1) ans = (ans * a) % mod;a = (a * a) % mod;n >>= 1;}return ans;}
ll gcd(ll a, ll b) {if (b > a) {return gcd(b, a);} if (b == 0) {return a;} return gcd(b, a % b);}
ll inverse(ll a){return power(a,mod-2);}
void factorial(ll a){fact.resize(a+1);infact.resize(a+1);fact[0]=1;infact[0]=1;for(int i=1; i<=a; i++){fact[i]=(fact[i-1]*i)%mod;infact[i]=inverse(fact[i]);}}
ll nCr(int n,int r) {if(n>=r){ll inv=infact[n-r]*infact[r]%mod;return (fact[n]*inv)%mod;}return 0;}
ll setbits(ll r){ll count=0;while(r>0){count++;r=(r&(r-1));}return(count);}
auto fsort = [] (const std::pair<int,int>& a, const std::pair<int,int>& b) {if (a.first != b.first) return a.first < b.first;return a.second > b.second;};

//********************************************************************************************************************************************************************/
#ifndef ONLINE_JUDGE
#define debug(x) cerr << #x <<" "; _print(x); cerr << endl;
#else
#define debug(x)
#endif

void _print(ll t) {cerr << t;}
void _print(int t) {cerr << t;}
void _print(string t) {cerr << t;}
void _print(char t) {cerr << t;}
void _print(lld t) {cerr << t;}
void _print(double t) {cerr << t;}
void _print(ull t) {cerr << t;}

template <class T, class V> void _print(pair <T, V> p);
template <class T> void _print(vector <T> v);
template <class T> void _print(set <T> v);
template <class T, class V> void _print(map <T, V> v);
template <class T> void _print(multiset <T> v);
template <class T, class V> void _print(pair <T, V> p) {cerr << "{"; _print(p.ff); cerr << ","; _print(p.ss); cerr << "}";}
template <class T> void _print(vector <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T> void _print(set <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T> void _print(multiset <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T, class V> void _print(map <T, V> v) {cerr << "[ "; for (auto i : v) {_print(i); cerr << " ";} cerr << "]";};

//// MODULAR ARITHMETIC
ll mminvprime(ll a, ll b) { return power(a, b - 2); }
ll mod_add(ll a, ll b, ll m=mod){a = a % m;b = b % m;return (((a + b) % m) + m) % m;}
ll mod_mul(ll a, ll b, ll m=mod){a = a % m;b = b % m;return (((a * b) % m) + m) % m;}
ll mod_sub(ll a, ll b, ll m=mod){a = a % m;b = b % m;return (((a - b) % m) + m) % m;}
ll mod_div(ll a, ll b, ll m=mod){a = a % m;b = b % m;return (mod_mul(a, mminvprime(b, m), m) + m) % m;}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bool cmp1(pair<ll,ll>&a,pair<ll,ll>&b){return a.ff<b.ff;}
bool cmp2(pair<ll,ll>&a,pair<ll,ll>&b){return a.ss<b.ss;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
vll perform1(vll a){
    vll b;
    fi(a.size()-1){
        b.pb(a[i+1]-a[i]);
    }
    return b;
}
void solve() {
    ll n;
    cin>>n;
    vll a(n);
    fi(n)cin>>a[i];
    auto b = a;
    ll maxi = accumulate(all(a),0ll);
    while(a.size()!=1){
        maxi = max(maxi , accumulate(all(b),0ll));
        a = perform1(a);
        reverse(all(a));
        maxi = max(maxi , accumulate(all(a),0ll));
    } 
    while(b.size()!=1){
        maxi = max(maxi , accumulate(all(b),0ll));
        reverse(all(b));
        b = perform1(b);
        maxi = max(maxi , accumulate(all(b),0ll));
    }
    // cout<<max(a[0],b[0])<<endl;
    cout<<maxi<<endl;

}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
int main(){
    IOS;
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("Error.txt","w",stderr);
    auto start_time = chrono::steady_clock::now();
    #endif
    int tt=1;
    cin>>tt;
    while(tt--){
        solve();
    }
    #ifndef ONLINE_JUDGE
    auto end_time = chrono::steady_clock::now();
    auto diff_time = end_time - start_time;
    cout << "Execution time : " << fixed << setprecision(5) <<  chrono::duration <double, milli> (diff_time).count() << " ms" << endl;
    #endif
    return 0;
}

Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vll vector<ll>
#define fi(n) for(int i=0;i<n;i++)
#define f(i,n) for(int i=0;i<n;i++)
#define loop(i,x,n) for(int i=x;i<n;i++)
#define pb push_back
#define lld long double
#define sqrt sqrtl
#define ull unsigned long long
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define pll pair<ll,ll>
#define getSet(x) __builtin_popcountll(x)
#define mp make_pair
#define vbl vector<bool>
#define IOS ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
ll mod1=1e18+7;
ll mod=998244353;
const ll N=1e5;
vector<ll> fact;
vector<ll> infact;

/********************************************************************************************************************************************************************/

ll power(ll a, ll n){ll ans = 1;while (n){if (n & 1) ans = (ans * a) % mod;a = (a * a) % mod;n >>= 1;}return ans;}
ll gcd(ll a, ll b) {if (b > a) {return gcd(b, a);} if (b == 0) {return a;} return gcd(b, a % b);}
ll inverse(ll a){return power(a,mod-2);}
void factorial(ll a){fact.resize(a+1);infact.resize(a+1);fact[0]=1;infact[0]=1;for(int i=1; i<=a; i++){fact[i]=(fact[i-1]*i)%mod;infact[i]=inverse(fact[i]);}}
ll nCr(int n,int r) {if(n>=r){ll inv=infact[n-r]*infact[r]%mod;return (fact[n]*inv)%mod;}return 0;}
ll setbits(ll r){ll count=0;while(r>0){count++;r=(r&(r-1));}return(count);}
auto fsort = [] (const std::pair<int,int>& a, const std::pair<int,int>& b) {if (a.first != b.first) return a.first < b.first;return a.second > b.second;};

//********************************************************************************************************************************************************************/
#ifndef ONLINE_JUDGE
#define debug(x) cerr << #x <<" "; _print(x); cerr << endl;
#else
#define debug(x)
#endif

void _print(ll t) {cerr << t;}
void _print(int t) {cerr << t;}
void _print(string t) {cerr << t;}
void _print(char t) {cerr << t;}
void _print(lld t) {cerr << t;}
void _print(double t) {cerr << t;}
void _print(ull t) {cerr << t;}

template <class T, class V> void _print(pair <T, V> p);
template <class T> void _print(vector <T> v);
template <class T> void _print(set <T> v);
template <class T, class V> void _print(map <T, V> v);
template <class T> void _print(multiset <T> v);
template <class T, class V> void _print(pair <T, V> p) {cerr << "{"; _print(p.ff); cerr << ","; _print(p.ss); cerr << "}";}
template <class T> void _print(vector <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T> void _print(set <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T> void _print(multiset <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T, class V> void _print(map <T, V> v) {cerr << "[ "; for (auto i : v) {_print(i); cerr << " ";} cerr << "]";};

//// MODULAR ARITHMETIC
ll mminvprime(ll a, ll b) { return power(a, b - 2); }
ll mod_add(ll a, ll b, ll m=mod){a = a % m;b = b % m;return (((a + b) % m) + m) % m;}
ll mod_mul(ll a, ll b, ll m=mod){a = a % m;b = b % m;return (((a * b) % m) + m) % m;}
ll mod_sub(ll a, ll b, ll m=mod){a = a % m;b = b % m;return (((a - b) % m) + m) % m;}
ll mod_div(ll a, ll b, ll m=mod){a = a % m;b = b % m;return (mod_mul(a, mminvprime(b, m), m) + m) % m;}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bool cmp1(pair<ll,ll>&a,pair<ll,ll>&b){return a.ff<b.ff;}
bool cmp2(pair<ll,ll>&a,pair<ll,ll>&b){return a.ss<b.ss;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
vll perform1(vll a){
    vll b;
    fi(a.size()-1){
        b.pb(a[i+1]-a[i]);
    }
    return b;
}
ll sum(vll &a){
    ll su = 0;
    fi(a.size())su = (su%mod1 + a[i]%mod1)%mod1;
    return su;
}
void solve() {
    ll n;
    cin>>n;
    vll a(n);
    fi(n)cin>>a[i];
    auto b = a;
    ll maxi = accumulate(all(a),0ll);
    while(a.size()!=1){
        maxi = max(maxi , sum(a));
        a = perform1(a);
        reverse(all(a));
        maxi = max(maxi , sum(a));
    } 
    while(b.size()!=1){
        maxi = max(maxi , sum(b));
        reverse(all(b));
        b = perform1(b);
        maxi = max(maxi , sum(b));
    }
    cout<<maxi<<endl;

}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
int main(){
    IOS;
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("Error.txt","w",stderr);
    auto start_time = chrono::steady_clock::now();
    #endif
    int tt=1;
    cin>>tt;
    while(tt--){
        solve();
    }
    #ifndef ONLINE_JUDGE
    auto end_time = chrono::steady_clock::now();
    auto diff_time = end_time - start_time;
    cout << "Execution time : " << fixed << setprecision(5) <<  chrono::duration <double, milli> (diff_time).count() << " ms" << endl;
    #endif
    return 0;
}