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

Previous submission (verdict: Wrong answer on test 6):
#include <iostream>
#include <fstream>
#include <istream>
#include <cmath>
#include <stack>
#include <climits>
#include <string.h>
#include <algorithm>
#include <numeric>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iomanip>
#include <assert.h>
using namespace std;

typedef long long int ll;
#define nl << "\n"
#define IOS                  \
    ios::sync_with_stdio(0); \
    cin.tie(0);
#define all(a) a.begin(), a.end()
#define cnl cout nl
#define YES cout << "YES" nl
#define NO cout << "NO" nl
template <typename... T>
void see(T &...args) {
    ((cin >> args), ...);
}
template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
    for (auto &i : v)
        is >> i;
    return is;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> v) {
    for (auto &i : v)
        os << i << ' ';
    return os;
}

void solve() {
    ll n; cin >> n;
    vector<ll> v(n); cin >> v;
    if(v.size() == 1) return void(cout << v.front() nl);
    ll best_sum = accumulate(all(v), 0);


    while(v.size() != 1) {
        for(ll i = 0; i < n - 1; i++) {
            v[i] = v[i + 1] - v[i];
        }
        v.pop_back();
        if(v.back() - v.front() < 0) 
            reverse(all(v));
        best_sum = max(best_sum, abs(v.back() - v.front()));
    }
    assert(v.size() == 1);
    cout << max(best_sum, abs(v.front())) nl;
}

int main() {
    IOS
    // ifstream in("in");
    // cin.rdbuf(in.rdbuf()); 
    
    #ifdef LOCAL
    ifstream in("in");
    cin.rdbuf(in.rdbuf());
    #endif

    int t = 1;
    see(t);

    while (t--) {
        solve();
    }
    return 0;
}

Submission (verdict: Accepted):
#include <iostream>
#include <fstream>
#include <istream>
#include <cmath>
#include <stack>
#include <climits>
#include <string.h>
#include <algorithm>
#include <numeric>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iomanip>
#include <assert.h>
using namespace std;

typedef long long int ll;
#define nl << "\n"
#define IOS                  \
    ios::sync_with_stdio(0); \
    cin.tie(0);
#define all(a) a.begin(), a.end()
#define cnl cout nl
#define YES cout << "YES" nl
#define NO cout << "NO" nl
template <typename... T>
void see(T &...args) {
    ((cin >> args), ...);
}
template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
    for (auto &i : v)
        is >> i;
    return is;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> v) {
    for (auto &i : v)
        os << i << ' ';
    return os;
}

void solve() {
    ll n; cin >> n;
    vector<ll> v(n); cin >> v;
    if(v.size() == 1) return void(cout << v.front() nl);
    ll best_sum = accumulate(all(v), 0LL);

    while(v.size() != 1) {
        for(int i = 0; i < n - 1; i++) {
            v[i] = v[i + 1] - v[i];
        }
        v.pop_back();
        best_sum = max(best_sum, abs(accumulate(all(v), 0LL)));
    }
    cout << best_sum nl;
}

int main() {
    IOS
    // ifstream in("in");
    // cin.rdbuf(in.rdbuf()); 
    
    #ifdef LOCAL
    ifstream in("in");
    cin.rdbuf(in.rdbuf());
    #endif

    int t = 1;
    see(t);

    while (t--) {
        solve();
    }
    return 0;
}