Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)

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

#define ll long long
#define pb push_back
#define rep(i,j,k) for(int i=(j);i<(k);i++)
#define NO cout<<"NO\n"
#define YES cout<<"YES\n"
#define YN(f)   cout<<((f) ? "YES":"NO")<<"\n"


ll const mod = 1e9+7;
int N = 5e5+5;
vector<ll> fac,inv;
ll power(ll a,ll b){
    if(b==0)    return 1;
    ll tmp = power(a,b/2);
    if(b%2==0)  return (tmp*tmp)%mod;
    else    return (((tmp*tmp)%mod)*a)%mod;
}
ll ncr(ll n,ll r){
    if(r>n) return 0;
    return (((fac[n]*inv[r])%mod)*inv[n-r])%mod;
}
void init_facts(){
    fac.resize(N);
    inv.resize(N);
    fac[0] = 1;
    for(int i=1;i<N;i++)    fac[i] = (fac[i-1]*i)%mod;
    for(int i=0;i<N;i++)    inv[i] = power(fac[i],mod-2)%mod;
}
ll gcd(ll a,ll b){return b==0 ? a:gcd(b,a%b);}
ll lcm(ll a,ll b){return (a/gcd(a,b))*b;}
/*----------------------------------------------------------------------------------------------------------------------------------*/

void solve(int T){
    int n;
    cin>>n;
    vector<long> a(n);
    for(auto &x:a)  cin>>x;
    long ans = accumulate(a.begin(),a.end(),0);
    for(int i=0;i<n-1;i++){
        long temp = 0;
        for(int j=0;j<a.size()-1;j++){
            a[j] = a[j+1]-a[j];
            temp += a[j];
        }
        a.pop_back();
        ans = max(ans,abs(temp));
    }
    cout<<ans<<"\n";
}

/*----------------------------------------------------------------------------------------------------------------------------------*/
int main()                                                                                
{  
    ios_base::sync_with_stdio(false);                         
    cin.tie(NULL);cout.tie(NULL);
    int t = 1;
    cin>>t;
    for(int _=1;_<=t;_++){
        solve(_);
    }
    #ifndef ONLINE_JUDGE
        cout << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif
    return 0;
}

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

#define ll long long
#define pb push_back
#define rep(i,j,k) for(int i=(j);i<(k);i++)
#define NO cout<<"NO\n"
#define YES cout<<"YES\n"
#define YN(f)   cout<<((f) ? "YES":"NO")<<"\n"


ll const mod = 1e9+7;
int N = 5e5+5;
vector<ll> fac,inv;
ll power(ll a,ll b){
    if(b==0)    return 1;
    ll tmp = power(a,b/2);
    if(b%2==0)  return (tmp*tmp)%mod;
    else    return (((tmp*tmp)%mod)*a)%mod;
}
ll ncr(ll n,ll r){
    if(r>n) return 0;
    return (((fac[n]*inv[r])%mod)*inv[n-r])%mod;
}
void init_facts(){
    fac.resize(N);
    inv.resize(N);
    fac[0] = 1;
    for(int i=1;i<N;i++)    fac[i] = (fac[i-1]*i)%mod;
    for(int i=0;i<N;i++)    inv[i] = power(fac[i],mod-2)%mod;
}
ll gcd(ll a,ll b){return b==0 ? a:gcd(b,a%b);}
ll lcm(ll a,ll b){return (a/gcd(a,b))*b;}
/*----------------------------------------------------------------------------------------------------------------------------------*/

void solve(int T){
    int n;
    cin>>n;
    vector<ll> a(n);
    for(auto &x:a)  cin>>x;
    ll ans = accumulate(a.begin(),a.end(),0);
    for(int i=0;i<n-1;i++){
        ll temp = 0;
        for(int j=0;j<a.size()-1;j++){
            a[j] = a[j+1]-a[j];
            temp += a[j];
        }
        a.pop_back();
        ans = max(ans,abs(temp));
    }
    cout<<ans<<"\n";
}

/*----------------------------------------------------------------------------------------------------------------------------------*/
int main()                                                                                
{  
    ios_base::sync_with_stdio(false);                         
    cin.tie(NULL);cout.tie(NULL);
    int t = 1;
    cin>>t;
    for(int _=1;_<=t;_++){
        solve(_);
    }
    #ifndef ONLINE_JUDGE
        cout << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif
    return 0;
}