Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)

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>
#ifndef ONLINE_JUDGE
#include "dbg/dbg.h"
#else
#define debug(...) 1
#endif
using namespace std;
using namespace __gnu_pbds;

using ll = long long;
using ld = long double;
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int dr[] = { -1, 0, +1, 0};
const int dc[] = {0, +1, 0, -1};
template <class T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template <class T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


void solve() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (auto &it : a) {
        cin >> it;
    }

    if (n == 1) {
        cout << a[0] << '\n';
        return;
    }

    int ans = accumulate(all(a), 0);
    while (a.size() > 1) {
        vector<int> diffa, revDiffa;

        for(int i = 0; i < (int)a.size() - 1; i++) 
            diffa.push_back(a[i + 1] - a[i]);

        reverse(all(a));

        for(int i = 0; i < (int)a.size() - 1; i++)
            revDiffa.push_back(a[i + 1] - a[i]);

        int sum = accumulate(all(diffa), 0);
        int revSum = accumulate(all(revDiffa), 0);

        ans = max({ans, sum, revSum});

        if(sum >= revSum) a = diffa;
        else a = revDiffa;
    }

    cout << ans << '\n';
}

int main() {
// #ifndef ONLINE_JUDGE
//     freopen("error.txt", "w", stderr);
// #endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int tt = 1;
    cin >> tt;

    while (tt--) {
        solve();
    }

    return 0;
}



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>
#ifndef ONLINE_JUDGE
#include "dbg/dbg.h"
#else
#define debug(...) 1
#endif
using namespace std;
using namespace __gnu_pbds;

using ll = long long;
using ld = long double;
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int dr[] = { -1, 0, +1, 0};
const int dc[] = {0, +1, 0, -1};
template <class T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template <class T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


void solve() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (auto &it : a) {
        cin >> it;
    }

    if (n == 1) {
        cout << a[0] << '\n';
        return;
    }

    int ans = accumulate(all(a), 0);
    while (a.size() > 1) {
        vector<int> diffa;

        for(int i = 0; i < (int)a.size() - 1; i++) 
            diffa.push_back(a[i + 1] - a[i]);

        int sum = accumulate(all(diffa), 0);

        ans = max({ans, sum, -sum});

        a = diffa;    
    }

    cout << ans << '\n';
}

int main() {
// #ifndef ONLINE_JUDGE
//     freopen("error.txt", "w", stderr);
// #endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int tt = 1;
    cin >> tt;

    while (tt--) {
        solve();
    }

    return 0;
}