Problem: 2062C - Cirno and Operations
Language: c++17 

Solution 1 (runtime: 61 ms):
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define in(initial,final,name) for(int i=initial;i<final;i++){cin>>name[i];}
#define f(i,initial,final) for(int i=initial;i<final;i++)
#define out(initial,final,name) for(int i=initial;i<final;i++){cout<<name[i]<<" ";}
#define p_b(x) push_back(x) 

const ll M=1e18+7;

//generate all primes up to n and returns vector of prime upto n.
vector<int>primes;
vector<int> sieve(int n){
    
    vector<int>v(n+7,1);
     v[1]=0;
    for(int i=2;i*i<=n;i++){
        if(v[i]){
            primes.p_b(i);
            for(int j=i*i;j<=n;j+=i){
                v[j]=0;
            }
        }
    }
    return primes;
}


// Returns a vector of its prime factors.
vector<int> primefactorization(ll n){
    vector<int>v;
    int i=1;
    for(i=2;i*i<=n;i++){
        if(n%i==0){
            while(n%i==0){
                v.p_b(i);
                n=n/i;
            }
        }
    }
    if(n>1){
        v.p_b(n);
    }
    return v;

}


// for calculation of nCr in combinatrics generates vector of factorails and inverse factorials upto n.

const int c=1e6+7;
ll fac[c];
ll invfac[c];
ll modinv(ll a,ll m);
void precomp_fac(ll n,ll m){
    fac[0]=1;
    for(int i=1;i<=n;i++){
        fac[i]=((fac[i-1]%m)*(i%m))%m;
    }
    invfac[n]=modinv(fac[n],m);
    invfac[0]=1;
    for(int i=n-1;i<=1;i++){
        invfac[i]=((invfac[i+1]%m)*((i+1)%m))%m;
    }
}

//Modular exponentiation of large numbers. calculates a^b mod m. 
ll binexpoIte(ll a,ll b,ll mod){
    ll ans=1;
    a%=mod;
    while(b){
        if(b&1){
            ans=(ans*a)%mod;
        }
        a=(a*a)%mod;
        b=b>>1;
    }
    return ans%mod;
}

//Modular multiplication for large numbers. calculates (a*b mod m)
ll binmul(ll a,ll b,ll mod){
    ll ans=0;
    while(b){
        if(b&1){
            ans=(ans+a)%mod;
        }
        a=(a+a)%mod;
        b=b>>1;
    }
    return (ans%mod);
}


// Modular Inverse of any number where m is a prime number.
ll modinv(ll a,ll m){
        ll ans = binexpoIte(a,m-2,m);
        return ans%m;
}

// return the log of any number in integer.
int logn(ll n,ll k){
    int i=0;
    while(n!=0){
        n=n/k;
        i++;
    }
    return --i;
}

// comparator function for pair.
bool cmp(pair<int,int>a,pair<int,int>b){
    if(a.first==b.first){
        return a.second<b.second;
    }
    return a.first<b.first;
}

// information about ques:

// Choose any subsequence∗ of the sequence a, and reverse it. Note that the subsequence does not have to be contiguous.
/////////////////////////////////////////////////////////////////////////////
// code required temporary functions



int main(){
    int t;cin>>t;
    while(t--){
        int n;cin>>n;
        vector<vector<ll>>v(n);
        ll sum=0;
        for(int i=0;i<n;i++){
            ll x;cin>>x;
            v[0].push_back(x);
            sum+=x;
        }

        ll mx=sum;
        for(int i=1;i<n;i++){
            for(int j=0;j<n-i;j++){
                v[i].push_back(v[i-1][j+1]-v[i-1][j]);
            }
            ll con;
            if(v[i].size()>1)
             con=abs(v[i-1].front()-v[i-1].back());
            else con=abs(v[i][0]);
            mx=max(mx,con);
        }

        cout<<mx<<endl;
    }

    return 0;
}

Solution 2 (runtime: 62 ms):
#include <iostream>
#include <vector>
using namespace std;

int main(){
    int t ;
    cin>>t;
    for(int i=0;i<t;i++){
        int n;
        cin>>n;
        vector<long long> a(n);
        for(int j=0;j<n;j++){
            cin>>a[j];
        }
        // 1,2  <->  2,取反      
        //2,1   <-> 和是2的反     x个1  +2  + y个1  （x>=0,y>=0)  结果与   1个2的结果绝对值相同
        // 1,1  <-> 没有操作
        // 所以只用看2的个数  ，最多n-1个2
        
        if(n==1){
            cout<<a[0]<<endl;
            continue;
        }
        long long max_sum=0;
        for(int j=0;j<n;j++){
            max_sum+= a[j];
        }
        int num_of_2=0;
        for(num_of_2=1;num_of_2<=n-1;num_of_2++){
            int num=n-num_of_2;
            long long sum=a[num]-a[0];//2后相加的结果 
            if(sum<0){
                sum=-sum;
            }
            if(sum>max_sum){
                max_sum=sum;
            }
            for(int k=0;k<num;k++){
                a[k]=a[k+1]-a[k];
            }
            
        }
        cout<<max_sum<<endl;
    }
}