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

Previous submission (verdict: Wrong answer on test 6):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pb push_back
#define loop0(i, n) for(long long i = 0; i < n; i++)
#define loop1(i, n) for(long long i = 1; i < n; i++)
#define allin(a, i, n) for(long long i=0; i<n; i++)cin>>a[i];
#define allout(a, i, n) for(long long i=0; i<n; i++)cout<<a[i]<<" ";
#define vll vector<long long>
#define pll pair<long long, long long>
#define mll unordered_map<long long, long long>
#define vpll vector<pll>
#define allr(v) v.rbegin(), v.rend()
#define all(v) v.begin(), v.end()
#define vs vector<string>
#define sum_a(a, n) accumulate(a, a+n, 0ll)
#define sum_v(v) accumulate(all(v), 0ll)

void solve(){
    ll n;
    cin>>n;
    ll a[n];
    allin(a, i, n);
    ll ans;
    if(n==1){
        cout<<a[0]<<endl;
        return;
    }
    if(n==2){
        ans = max(a[0]+a[1], max(a[0]-a[1], a[1]-a[0]));
        cout<<ans<<endl;
        return;
    }
    
    ans = abs(sum_a(a, n));
    vll curr, diff;
    for(auto x: a){
        curr.pb(x);
    }
    for(int i = 1; i < n; i++){
        diff.pb(curr[i]-curr[i-1]);
    }
    ans = max(abs(sum_v(diff)), ans);
    // allout(curr, i, n); cout<<endl;
    // allout(diff, i, n-1); cout<<endl;
    // cout<<ans<<endl;
    
    
    curr.clear();
    while(diff.size()>2){
        for(auto x: diff){
        curr.pb(x);
        }
        diff.clear();
        for(int i = 1; i < curr.size(); i++){
        diff.pb(curr[i]-curr[i-1]);
        }
        ans = max(abs(sum_v(diff)), ans);
        // allout(curr, i, curr.size()); cout<<endl;
        // allout(diff, i, diff.size()); cout<<endl;
        // cout<<ans<<endl;
        curr.clear();
    }
        ans = max(ans, max(diff[0]+diff[1], max(diff[0]-diff[1], diff[1]-diff[0])));
        cout<<ans<<endl;
}

int main() {
	int t;
	cin>>t;
	while(t--) solve();

}


Submission (verdict: Wrong answer on test 6):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pb push_back
#define loop0(i, n) for(long long i = 0; i < n; i++)
#define loop1(i, n) for(long long i = 1; i < n; i++)
#define allin(a, i, n) for(long long i=0; i<n; i++)cin>>a[i];
#define allout(a, i, n) for(long long i=0; i<n; i++)cout<<a[i]<<" ";
#define vll vector<long long>
#define pll pair<long long, long long>
#define mll unordered_map<long long, long long>
#define vpll vector<pll>
#define allr(v) v.rbegin(), v.rend()
#define all(v) v.begin(), v.end()
#define vs vector<string>
#define sum_a(a, n) accumulate(a, a+n, 0ll)
#define sum_v(v) accumulate(all(v), 0ll)

void solve(){
    ll n;
    cin>>n;
    ll a[n];
    allin(a, i, n);
    ll ans;
    if(n==1){
        cout<<a[0]<<endl;
        return;
    }
    if(n==2){
        ans = max(a[0]+a[1], max(a[0]-a[1], a[1]-a[0]));
        cout<<ans<<endl;
        return;
    }
    vll curr, diff;
    for(auto x: a){
        curr.pb(x);
    }
    for(int i = 1; i < n; i++){
        diff.pb(curr[i]-curr[i-1]);
    }
    ans = abs(sum_v(diff));
    // allout(curr, i, n); cout<<endl;
    // allout(diff, i, n-1); cout<<endl;
    // cout<<ans<<endl;
    
    
    curr.clear();
    while(diff.size()>2){
        for(auto x: diff){
        curr.pb(x);
        }
        diff.clear();
        for(int i = 1; i < curr.size(); i++){
        diff.pb(curr[i]-curr[i-1]);
        }
        ans = max(abs(sum_v(diff)), ans);
        // allout(curr, i, curr.size()); cout<<endl;
        // allout(diff, i, diff.size()); cout<<endl;
        // cout<<ans<<endl;
        curr.clear();
    }
        ans = max(ans, max(diff[0]+diff[1], max(diff[0]-diff[1], diff[1]-diff[0])));
        cout<<ans<<endl;
}

int main() {
	int t;
	cin>>t;
	while(t--) solve();

}