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

Previous submission (verdict: Wrong answer on test 2):
 #include <bits/stdc++.h>
 #define F first
 #define S second
 #define ll long long
 #define all(v) v.begin() , v.end()
 #define allr(v) v.rbegin() , v.rend()
 #define pb push_back
 using namespace std;
 #define endl "\n"
 #include <ext/pb_ds/assoc_container.hpp>
 #include <ext/pb_ds/tree_policy.hpp>
 using namespace __gnu_pbds;
 int mod = 998244353;
 typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> orderedS;
 //order_of_key, __builtin_popcountll(n)
 void fast() {
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
}
vector <ll> calc (vector <ll> v){
    vector <ll> cp;
    int n = v.size();
    for (int i = 1; i < n; i++){
        cp.pb (v[i] - v[i - 1]);
    }
    return cp;
}

void solve (){
    int n; cin >> n;
    vector <ll>v (n);
    ll mx = 0;
    for (int i = 0; i < n; i++){
        cin >> v[i];
        mx += v[i];
    }
    if (n == 1){
        cout << v[0] << endl;
        return;
    }

    // (9 -7 8) -> -16 , 15
    // (8 -7 9) -> -15 , 16
    //v[n - 1] - v[n - 2] > v[1] - v[0]

    while (n > 2){
        ll f = v[1] - v[0];
        ll b = v[n - 1] - v[n - 2];
        if (b < f){
            reverse(all(v));
        }
        v = calc(v);
        n--;
        ll sm = 0;
        for (int i = 0; i < n; i++){
            sm += v[i];
        }
        mx = max (mx , sm);
    }
    mx = max (mx , max (v[0] - v[1] , v[1] - v[0]));
    cout << mx << endl;

}
 int main() {
     fast();
     int t = 1;
     cin >> t;
     while (t--) {
         solve();
     }
     return 0;
 }


Submission (verdict: Wrong answer on test 6):
 #include <bits/stdc++.h>
 #define F first
 #define S second
 #define ll long long
 #define all(v) v.begin() , v.end()
 #define allr(v) v.rbegin() , v.rend()
 #define pb push_back
 using namespace std;
 #define endl "\n"
 #include <ext/pb_ds/assoc_container.hpp>
 #include <ext/pb_ds/tree_policy.hpp>
 using namespace __gnu_pbds;
 int mod = 998244353;
 typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> orderedS;
 //order_of_key, __builtin_popcountll(n)
 void fast() {
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
}
vector <ll> calc (vector <ll> v){
    vector <ll> cp;
    int n = v.size();
    for (int i = 1; i < n; i++){
        cp.pb (v[i] - v[i - 1]);
    }
    return cp;
}

void solve (){
    int n; cin >> n;
    vector <ll>v (n);
    ll mx = 0;
    for (int i = 0; i < n; i++){
        cin >> v[i];
        mx += v[i];
    }
    if (n == 1){
        cout << v[0] << endl;
        return;
    }

    // (9 -7 8) -> -16 , 15
    // (8 -7 9) -> -15 , 16
    //v[n - 1] - v[n - 2] > v[1] - v[0]

    while (n > 2){
        v = calc(v);
        n--;
        if (v[n - 1] < v[0]){
            reverse(all(v));
        }
        ll sm = 0;
        for (int i = 0; i < n; i++){
            sm += v[i];
        }
        mx = max (mx , sm);
    }
    mx = max (mx , max (v[0] - v[1] , v[1] - v[0]));
    cout << mx << endl;

}
 int main() {
     fast();
     int t = 1;
     cin >> t;
     while (t--) {
         solve();
     }
     return 0;
 }