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

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

using namespace std;
using namespace __gnu_pbds;


#define intll long long

#define inf LLONG_MAX
#define all(x) x.begin(),x.end()
#define out(a) for(int i = 0; i<a.size(); i++) {cout<<a[i]<<" ";}cout<<endl;
#define set_bits(x) __builtin_popcountll(x)
#define sz(x) ((int)(x).size())
#define endl "\n"
#define fastio ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
typedef tree<pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update > pbds; // find_by_order, order_of_key

/*
    Two important operations that we can perform in these data structures:

    order_of_key: The number of items in a set that are strictly smaller than k 
    find_by_order: It returns an iterator to the ith largest element

*/


int gcd(int a, int b) {if (b > a) {return gcd(b, a);} if (b == 0) {return a;} return gcd(b, a % b);}
int expo(int a, int b, int mod) {int res = 1; while (b > 0) {if (b & 1)res = (res * a) % mod; a = (a * a) % mod; b = b >> 1;} return res;}
void extendgcd(int a, int b,int*v) {if (b == 0) {v[0] = 1; v[1] = 0; v[2] = a; return ;} extendgcd(b, a % b, v); int x = v[1]; v[1] = v[0] - v[1] * (a / b); v[0] = x; return;}
int mminv(int a, int b) {int arr[3]; extendgcd(a, b, arr); return arr[0];}
int mminvprime(int a, int b) {return expo(a, b - 2, b);}
bool revsort(int a, int b) {return a > b;}
void swap(int &x, int &y) {int temp = x; x = y; y = temp;}
int combination(int n, int r, int m, int *fact, int *ifact) {int val1 = fact[n]; int val2 = ifact[n - r]; int val3 = ifact[r]; return (((val1 * val2) % m) * val3) % m;}
void google(int t) {cout << "Case #" << t << ": ";}
int mod_add(int a, int b, int m) {a = a % m; b = b % m; return (((a + b) % m) + m) % m;}
int mod_mul(int a, int b, int m) {a = a % m; b = b % m; return (((a * b) % m) + m) % m;}
int mod_sub(int a, int b, int m) {a = a % m; b = b % m; return (((a - b) % m) + m) % m;}
int mod_div(int a, int b, int m) {a = a % m; b = b % m; return (mod_mul(a, mminvprime(b, m), m) + m) % m;} 
int phin(int n) {int number = n; if (n % 2 == 0) {number /= 2; while (n % 2 == 0)n /= 2;} for (int i = 3; i <= sqrt(n); i += 2) {if (n % i == 0) {while (n % i == 0)n /= i; number = (number / i * (i - 1));}} if (n > 1)number = (number / n * (n - 1)) ; return number;} //O(sqrt(N))

 #ifndef ONLINE_JUDGE
    #include "template.cpp"
    #else
    #define debug(...)
    #define debugArr(...)
#endif

int32_t main(){
    fastio;
    int t;
    cin>>t;
    while(t--){
        int n;
        cin>>n;
        vector<int> a(n);
        for(int i = 0 ; i < n ; ++i){
            cin>>a[i];
        }
        int sum = -1e9;
        vector<int> b = a;
        while((int)a.size() != 1){
            sum = max(sum , accumulate(a.begin() , a.end() ,0));
            vector<int> temp;
            for(int i = 1 ; i < (int)a.size() ; ++i){
                temp.push_back(a[i] - a[i - 1]);
            }
            vector<int> revtemp;
            reverse(a.begin() , a.end());
            for(int i = 1 ; i < (int)a.size() ; ++i){
                revtemp.push_back(a[i] - a[i - 1]);
            }

            if(accumulate(temp.begin() , temp.end() , 0) >= accumulate(revtemp.begin() , revtemp.end() , 0)){
                a = temp;
            }
            else{
                a = revtemp;
            }
        }
        while((int)b.size() != 1){
            sum = max(sum , accumulate(b.begin() , b.end() ,0));
            vector<int> temp;
            for(int i = 1 ; i < (int)b.size() ; ++i){
                temp.push_back(b[i] - b[i - 1]);
            }
            vector<int> revtemp;
            reverse(b.begin() , b.end());
            for(int i = 1 ; i < (int)b.size() ; ++i){
                revtemp.push_back(b[i] - b[i - 1]);
            }

            if(accumulate(temp.begin() , temp.end() , 0) > accumulate(revtemp.begin() , revtemp.end() , 0)){
                b = temp;
            }
            else{
                b = revtemp;
            }
        }
        cout << max({a[0] , sum , b[0]}) << endl;
    }
}

Submission (verdict: Accepted):
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;


#define int long long

#define inf LLONG_MAX
#define all(x) x.begin(),x.end()
#define out(a) for(int i = 0; i<a.size(); i++) {cout<<a[i]<<" ";}cout<<endl;
#define set_bits(x) __builtin_popcountll(x)
#define sz(x) ((int)(x).size())
#define endl "\n"
#define fastio ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
typedef tree<pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update > pbds; // find_by_order, order_of_key

/*
    Two important operations that we can perform in these data structures:

    order_of_key: The number of items in a set that are strictly smaller than k 
    find_by_order: It returns an iterator to the ith largest element

*/


int gcd(int a, int b) {if (b > a) {return gcd(b, a);} if (b == 0) {return a;} return gcd(b, a % b);}
int expo(int a, int b, int mod) {int res = 1; while (b > 0) {if (b & 1)res = (res * a) % mod; a = (a * a) % mod; b = b >> 1;} return res;}
void extendgcd(int a, int b,int*v) {if (b == 0) {v[0] = 1; v[1] = 0; v[2] = a; return ;} extendgcd(b, a % b, v); int x = v[1]; v[1] = v[0] - v[1] * (a / b); v[0] = x; return;}
int mminv(int a, int b) {int arr[3]; extendgcd(a, b, arr); return arr[0];}
int mminvprime(int a, int b) {return expo(a, b - 2, b);}
bool revsort(int a, int b) {return a > b;}
void swap(int &x, int &y) {int temp = x; x = y; y = temp;}
int combination(int n, int r, int m, int *fact, int *ifact) {int val1 = fact[n]; int val2 = ifact[n - r]; int val3 = ifact[r]; return (((val1 * val2) % m) * val3) % m;}
void google(int t) {cout << "Case #" << t << ": ";}
int mod_add(int a, int b, int m) {a = a % m; b = b % m; return (((a + b) % m) + m) % m;}
int mod_mul(int a, int b, int m) {a = a % m; b = b % m; return (((a * b) % m) + m) % m;}
int mod_sub(int a, int b, int m) {a = a % m; b = b % m; return (((a - b) % m) + m) % m;}
int mod_div(int a, int b, int m) {a = a % m; b = b % m; return (mod_mul(a, mminvprime(b, m), m) + m) % m;} 
int phin(int n) {int number = n; if (n % 2 == 0) {number /= 2; while (n % 2 == 0)n /= 2;} for (int i = 3; i <= sqrt(n); i += 2) {if (n % i == 0) {while (n % i == 0)n /= i; number = (number / i * (i - 1));}} if (n > 1)number = (number / n * (n - 1)) ; return number;} //O(sqrt(N))

//  #ifndef ONLINE_JUDGE
//     #include "template.cpp"
//     #else
//     #define debug(...)
//     #define debugArr(...)
// #endif

int32_t main(){
    fastio;
    int t;
    cin>>t;
    while(t--){
        int n;
        cin>>n;
        vector<int> a(n);
        for(int i = 0 ; i < n ; ++i){
            cin>>a[i];
        }
        int sum = -1e18;
        vector<int> b = a;
        while((int)a.size() != 1){
            sum = max(sum , accumulate(a.begin() , a.end() ,0LL));
            vector<int> temp;
            for(int i = 1 ; i < (int)a.size() ; ++i){
                temp.push_back(a[i] - a[i - 1]);
            }
            vector<int> revtemp;
            reverse(a.begin() , a.end());
            for(int i = 1 ; i < (int)a.size() ; ++i){
                revtemp.push_back(a[i] - a[i - 1]);
            }

            if(accumulate(temp.begin() , temp.end() , 0LL) >= accumulate(revtemp.begin() , revtemp.end() , 0LL)){
                a = temp;
            }
            else{
                a = revtemp;
            }
        }
        while((int)b.size() != 1){
            sum = max(sum , accumulate(b.begin() , b.end() ,0LL));
            vector<int> temp;
            for(int i = 1 ; i < (int)b.size() ; ++i){
                temp.push_back(b[i] - b[i - 1]);
            }
            vector<int> revtemp;
            reverse(b.begin() , b.end());
            for(int i = 1 ; i < (int)b.size() ; ++i){
                revtemp.push_back(b[i] - b[i - 1]);
            }

            if(accumulate(temp.begin() , temp.end() , 0LL) > accumulate(revtemp.begin() , revtemp.end() , 0LL)){
                b = temp;
            }
            else{
                b = revtemp;
            }
        }
        cout << max({a[0] , sum , b[0]}) << endl;
    }
}