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

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define yes cout << "YES" << endl;
#define no cout << "NO" << endl;
#define nl cout << '\n';
#define pb push_back
#define F first
#define S second
#define mp make_pair
#define mod 1000000007
#define make(n) ll n; cin >> n;
#define makech(ch) char ch; cin >> ch;
#define makestr(s) string s; cin >> s;
#define show(n) cout << n << endl;
#define makearr(a, n) vector<ll> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; }
#define make2d(a, n, m) vvi a(n, vector<ll>(m)); for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { cin >> a[i][j]; } }
#define all(v) v.begin(), v.end()
#define showme(a) for(auto it:a){cout<<it<<" ";} cout<<'\n';
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
#define forl(n) for(int i=0; i<n; i++)

vector<ll> generatePascalsTriangleLine(int n) {
    vector<ll> line(n + 1, 1);
    for (int i = 1; i < n; i++) {
        line[i] = line[i - 1] * (n - i + 1) / i;
    }
    return line;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    make(t);
    while (t--) {
        make(n);
        makearr(arr, n)

        ll sum = 0, ans = 0;
        for(int i=0; i<arr.size(); i++){
            sum+=arr[i];
        }
        ans=sum;

        while(n>1){
            vector<ll>diff;
            for(int i=0; i<arr.size()-1; i++){
                diff.pb(arr[i+1]-arr[i]);
            }

            sum=accumulate(all(diff), 0);
            ans=max({ans, sum, -sum});

            arr.clear();
            for(int i=0; i<diff.size(); i++){
                arr.pb(diff[i]);
            }
            diff.clear();
            n--;
        }
        show(ans)
    }
    return 0;
}


Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define yes cout << "YES" << endl;
#define no cout << "NO" << endl;
#define nl cout << '\n';
#define pb push_back
#define F first
#define S second
#define mp make_pair
#define mod 1000000007
#define make(n) ll n; cin >> n;
#define makech(ch) char ch; cin >> ch;
#define makestr(s) string s; cin >> s;
#define show(n) cout << n << endl;
#define makearr(a, n) vector<ll> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; }
#define make2d(a, n, m) vvi a(n, vector<ll>(m)); for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { cin >> a[i][j]; } }
#define all(v) v.begin(), v.end()
#define showme(a) for(auto it:a){cout<<it<<" ";} cout<<'\n';
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
#define forl(n) for(int i=0; i<n; i++)

vector<ll> generatePascalsTriangleLine(int n) {
    vector<ll> line(n + 1, 1);
    for (int i = 1; i < n; i++) {
        line[i] = line[i - 1] * (n - i + 1) / i;
    }
    return line;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    make(t);
    while (t--) {
        make(n);
        makearr(arr, n)

        ll sum = 0, ans = 0;
        for(int i=0; i<arr.size(); i++){
            sum+=arr[i];
        }
        ans=sum;
        
        vector<ll>curr=arr;
        while(curr.size()>1){
            vector<ll>diff;
            for(int i=0; i<curr.size()-1; i++){
                diff.pb(curr[i+1]-curr[i]);
            }

            sum=accumulate(all(diff), 0LL);
            ans=max(ans, abs(sum));

            curr.clear();
            for(int i=0; i<diff.size(); i++){
                curr.pb(diff[i]);
            }
            diff.clear();
        }
        show(ans)
    }
    return 0;
}