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

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>
using namespace std;
using namespace __gnu_pbds;
// #define int long long
#define ld long double
#define pb push_back
#define endl '\n'           // remove for interactive problem
#define pii pair<int,int>
#define fi first
#define se second
#define vi vector<int>
#define vvi vector<vi>
#define vpii vector<pii>
#define all(vec) vec.begin(),vec.end()
#define fsort(vec) sort(all(vec))
#define rsort(vec) sort(vec.rbegin(),vec.rend())
#define rev(vec) reverse(all(vec))
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define setbits(x)  __builtin_popcountll(x)
#define clz(x) __builtin_clzll(x)
#define ctz(x) __builtin_ctzll(x)
#define gcd(a,b) __gcd(a,b)
#define max_ele(vec) *(max_element(all(vec)))
#define min_ele(vec) *(min_element(all(vec)))
#define sz(vec) (int)vec.size()
typedef tree<int,null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const ld pi = 3.1415926535897932;
const ld eps = 1e-12;
const int inf = 1e18;
const int mod = 1e9+7;
// const int mod = 998244353;
// const int N = (int)2e6+1;
// int fac[N];

int lcm(int a,int b){return ((a*b)/gcd(a,b));}
void accept_2d(vector<vi>& vec){
    for(auto &i:vec){for(auto &j:i)cin>>j;}}
void display_2d(vector<vector<int>>& vec){
    for(auto i:vec){for(auto j:i)cout<<j<<" ";cout<<endl;}}
void accept(vi &vec){
    for(auto &i:vec)cin>>i;}
void display(vi &vec){
    for(auto i:vec)cout<<i<<" ";cout<<endl;}
void accept_pair_vector(vpii &vec){
    for(auto &i:vec)cin>>i.fi>>i.se;}
void disp_pair_vector(vpii &vec){
    for(auto i:vec)cout<<i.fi<<" "<<i.se<<endl;}
void disp_str(string s){cout<<s<<endl;}
void yes_no(bool f){
    if(f)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}
void disp_set(multiset<int>& st){
    for(auto it:st)cout<<it<<" ";cout<<endl;}
// void disp_multiset(multiset<int>& st){
//     for(auto it:st)cout<<it<<" ";cout<<endl;}
// void disp_map(map<int,int>& mp){
//     for(auto it:mp){cout<<(it).fi<<" "<<it.se<<endl;}cout<<endl;}
int binaryexp_mod(int x,int n){
    if(n==0)return 1;
    if(n&1) return (x*binaryexp_mod((x*x)%mod, (n-1)/2)%mod)%mod;
    return binaryexp_mod((x*x)%mod,n/2)%mod;
}
// int binaryexp(int x, int n){
//     if(n==0)return 1;
//     if(n&1) return x*binaryexp(x*x,(n-1)/2);
//     return binaryexp((x*x),n/2);
// }
int inverse(int n){int inv = binaryexp_mod(n,mod-2); return inv;}        // CAN BE USED only when mod is prime or it is coprime with the number
// void nextPer(vi &arr){                      
//     next_permutation(all(arr));             // IT directly return lexicographically next greater permutation in O(N)
// }
// void sieve(){
//     vi vec((int)1e7+1,1);  // 1->indicates prime, 0 indicates not prime
//     vec[0] = 0, vec[1] = 0;
//     for(int i=2;i*i<=1e7;i++){
//         if(vec[i]){
//             for(int j=i*i;j<=1e7;j+=i) vec[j] = 0;
//         }
//     }
// }
// void spf(){
//     int spf[(int)1e6 + 1];
//     for(int i=0;i<=1e6;i++)spf[i] = i;
//     for(int i=2;i<= 1e6; i++){
//         if(spf[i] == i){
//             for(int j=2*i;j <= 1e6; j+=i){
//                 if(spf[j] == j)
//                 spf[j] = i;
//             }
//         }
//     }
// }
// bool isVowel(char c){
//     if(c == 'A' || (c == 'E') || (c=='I') || (c=='O') || (c=='U'))
//     return true;
//     return false;
// }
int32_t main(){
    fast;
    // fac[0] = 1;
    // for(int i=1;i<N;i++){
    // fac[i] = (fac[i-1]*i)%mod;
    // }
    int tt = 1;cin>>tt;
    while(tt--){
        int n;cin>>n;
        vi vec(n);accept(vec);
        int sum = accumulate(all(vec),0ll);
        int ans = sum;
        while(sz(vec)>1){
            vi temp;
            for(int i=0;i<(sz(vec)-1);i++){
                temp.pb(vec[i+1]-vec[i]);
            }
            vec.clear();
            vec = temp;
            sum = accumulate(all(temp),0ll);
            ans = max(ans,max(sum,(-1)*sum));
        }
        cout<<ans<<endl;
    }
    return 0;
}

Submission (verdict: Accepted):
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define ld long double
#define pb push_back
#define endl '\n'           // remove for interactive problem
#define pii pair<int,int>
#define fi first
#define se second
#define vi vector<int>
#define vvi vector<vi>
#define vpii vector<pii>
#define all(vec) vec.begin(),vec.end()
#define fsort(vec) sort(all(vec))
#define rsort(vec) sort(vec.rbegin(),vec.rend())
#define rev(vec) reverse(all(vec))
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define setbits(x)  __builtin_popcountll(x)
#define clz(x) __builtin_clzll(x)
#define ctz(x) __builtin_ctzll(x)
#define gcd(a,b) __gcd(a,b)
#define max_ele(vec) *(max_element(all(vec)))
#define min_ele(vec) *(min_element(all(vec)))
#define sz(vec) (int)vec.size()
typedef tree<int,null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const ld pi = 3.1415926535897932;
const ld eps = 1e-12;
const int inf = 1e18;
const int mod = 1e9+7;
// const int mod = 998244353;
// const int N = (int)2e6+1;
// int fac[N];

int lcm(int a,int b){return ((a*b)/gcd(a,b));}
void accept_2d(vector<vi>& vec){
    for(auto &i:vec){for(auto &j:i)cin>>j;}}
void display_2d(vector<vector<int>>& vec){
    for(auto i:vec){for(auto j:i)cout<<j<<" ";cout<<endl;}}
void accept(vi &vec){
    for(auto &i:vec)cin>>i;}
void display(vi &vec){
    for(auto i:vec)cout<<i<<" ";cout<<endl;}
void accept_pair_vector(vpii &vec){
    for(auto &i:vec)cin>>i.fi>>i.se;}
void disp_pair_vector(vpii &vec){
    for(auto i:vec)cout<<i.fi<<" "<<i.se<<endl;}
void disp_str(string s){cout<<s<<endl;}
void yes_no(bool f){
    if(f)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}
void disp_set(multiset<int>& st){
    for(auto it:st)cout<<it<<" ";cout<<endl;}
// void disp_multiset(multiset<int>& st){
//     for(auto it:st)cout<<it<<" ";cout<<endl;}
// void disp_map(map<int,int>& mp){
//     for(auto it:mp){cout<<(it).fi<<" "<<it.se<<endl;}cout<<endl;}
int binaryexp_mod(int x,int n){
    if(n==0)return 1;
    if(n&1) return (x*binaryexp_mod((x*x)%mod, (n-1)/2)%mod)%mod;
    return binaryexp_mod((x*x)%mod,n/2)%mod;
}
// int binaryexp(int x, int n){
//     if(n==0)return 1;
//     if(n&1) return x*binaryexp(x*x,(n-1)/2);
//     return binaryexp((x*x),n/2);
// }
int inverse(int n){int inv = binaryexp_mod(n,mod-2); return inv;}        // CAN BE USED only when mod is prime or it is coprime with the number
// void nextPer(vi &arr){                      
//     next_permutation(all(arr));             // IT directly return lexicographically next greater permutation in O(N)
// }
// void sieve(){
//     vi vec((int)1e7+1,1);  // 1->indicates prime, 0 indicates not prime
//     vec[0] = 0, vec[1] = 0;
//     for(int i=2;i*i<=1e7;i++){
//         if(vec[i]){
//             for(int j=i*i;j<=1e7;j+=i) vec[j] = 0;
//         }
//     }
// }
// void spf(){
//     int spf[(int)1e6 + 1];
//     for(int i=0;i<=1e6;i++)spf[i] = i;
//     for(int i=2;i<= 1e6; i++){
//         if(spf[i] == i){
//             for(int j=2*i;j <= 1e6; j+=i){
//                 if(spf[j] == j)
//                 spf[j] = i;
//             }
//         }
//     }
// }
// bool isVowel(char c){
//     if(c == 'A' || (c == 'E') || (c=='I') || (c=='O') || (c=='U'))
//     return true;
//     return false;
// }
int32_t main(){
    fast;
    // fac[0] = 1;
    // for(int i=1;i<N;i++){
    // fac[i] = (fac[i-1]*i)%mod;
    // }
    int tt = 1;cin>>tt;
    while(tt--){
        int n;cin>>n;
        vi vec(n);accept(vec);
        int sum = accumulate(all(vec),0ll);
        int ans = sum;
        while(sz(vec)>1){
            vi temp;
            for(int i=0;i<(sz(vec)-1);i++){
                temp.pb(vec[i+1]-vec[i]);
            }
            vec.clear();
            vec.resize(n);
            vec = temp;
            sum = accumulate(all(temp),0ll);
            ans = max(ans,abs(sum));
            n--;
        }
        cout<<ans<<endl;
    }
    return 0;
}