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);
    vector<int> diffa, revDiffa;
    int sum = 0;
    for(int i = 0; i < n - 1; i++) {
        diffa.push_back(a[i + 1] - a[i]);
        revDiffa.push_back(-a[i + 1] + a[i]);
        sum += diffa.back();
    }

    reverse(all(revDiffa));
    ans = max({ans, sum, -sum});
    n--;

    while (n > 1) {
        vector<int> temp1, temp2;
        for(int i = 0; i < n - 1; i++)
            temp1.push_back(diffa[i + 1]-diffa[i]);
        for(int i = 0; i < n - 1; i++)
            temp2.push_back(revDiffa[i + 1]-revDiffa[i]);

        int sum1 = accumulate(all(temp1), 0);
        int sum2 = accumulate(all(temp2), 0);

        ans = max({ans, sum1, -sum1, sum2, -sum2});
        n--;
        diffa = temp1;
        revDiffa = temp2;
    }

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

int main() {
    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>;

#define int long long
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);
    vector<int> diffa, revDiffa;
    int sum = 0;
    for(int i = 0; i < n - 1; i++) {
        diffa.push_back(a[i + 1] - a[i]);
        revDiffa.push_back(-a[i + 1] + a[i]);
        sum += diffa.back();
    }

    reverse(all(revDiffa));
    ans = max({ans, sum, -sum});
    n--;

    while (n > 1) {
        vector<int> temp1, temp2;
        for(int i = 0; i < n - 1; i++)
            temp1.push_back(diffa[i + 1]-diffa[i]);
        for(int i = 0; i < n - 1; i++)
            temp2.push_back(revDiffa[i + 1]-revDiffa[i]);

        int sum1 = accumulate(all(temp1), 0);
        int sum2 = accumulate(all(temp2), 0);

        ans = max({ans, sum1, -sum1, sum2, -sum2});
        n--;
        diffa = temp1;
        revDiffa = temp2;
    }

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

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int tt = 1;
    cin >> tt;

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

    return 0;
}