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

Solution 1 (runtime: 62 ms):
#include <bits/stdc++.h>
using namespace std;

#ifndef ONLINE_JUDGE
#define debug(x) cerr << #x << " ";_print(x) ;cerr << endl;
#else
#define debug(x);
#endif

typedef long long ll;

template<class T> void _print(T x) { cerr << x << " "; }


// template<class T> void _print(vector<T> v1);
template<class T> void _print(vector<T> v1){for(T& ele : v1){_print(ele);}}


void stdInput(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
		freopen("error.txt","w",stderr);
	#endif
}


ll solve(vector<ll>& v1,int n)
{
	ll mxSum = LLONG_MIN;

	mxSum = accumulate(v1.begin(),v1.end(),0ll);
	debug(mxSum);
	vector<ll> tmp;

	while(n > 1){
		// debug(mxSum);
		for(int i = 0;i < n-1;++i){
			tmp.push_back(v1[i+1] - v1[i]);
		}
		ll sum = 0;
		for(ll &ele : tmp){
			sum += ele;
		}
		// mxSum = max(mxSum,abs(accumulate(tmp.begin(),tmp.end(),0ll)));
		// debug(v1);
		// cout << sum << endl;
		
		for(int i = 0;i < n-1;i++){
			v1[i] = tmp[i];
		}
		mxSum = max(mxSum,abs(sum));
		tmp.clear();
		n--;
	}
	return mxSum;
	
}
int main()
{
	stdInput();
	int T;
	cin >> T;
	while(T--)
	{
		int n;
		cin >> n;
		vector<ll> v1(n);
		for(ll &i : v1){
			cin >> i;
		}
		cout << solve(v1,n) << endl;
	}
}

Solution 2 (runtime: 46 ms):
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb  push_back
#define mp  make_pair
#define INT_MAX                 INT64_MAX;
#define INT_MIN                 INT64_MIN;
#define IO_FAST                 ios_base::sync_with_stdio(false); cin.tie(NULL);
#define testcase                int t; cin >> t; while(t--)
#define inputvec(v1, n)         for(int i=0; i<n; i++) {int x; cin >> x; v1.pb(x);}
#define inputvecp(v1, n)        for(int i=0; i<n; i++) {int x, y; cin >> x >> y; v1.pb(mp(x,y));}
#define sort(v1)                sort(v1.begin(), v1.end())
#define reverse(v1)             reverse(v1.begin(), v1.end())
#define print(x)                cout << #x << endl;
#define deb(x)                  cout << #x << ' ' <<  '=' << ' ' << x << endl;
#define upperbound(v1, k)       upper_bound(v1.begin(), v1.end(), k)
#define lowerbound(v1, k)       lower_bound(v1.begin(), v1.end(), k)
#define tolower(s1)             transform(s1.begin(), s1.end(), s1.begin(), ::tolower)
#define toupper(s1)             transform(s1.begin(), s1.end(), s1.begin(), ::toupper)
#define auto1(v1)               for(auto &num1:v1) {cout << num1 << ' ';} cout << endl;
#define auto2(vp1)              for(auto &num1:vp1) {cout << num1.first << ' ' <<num1.second << endl;}
#define auto3(vv1)              for(auto &num1:vv1) {for(auto &num2:num1){cout << num2 <<' ';}cout<<endl;}
int gcd(int a,int b)            {if (b==0) return a; return gcd(b, a%b);} // take a=0;
int lcm(int a,int b)            {return a/gcd(a,b)*b;}  // take a = v[0];
const int N = 1e5+10;
const int mod = 1e9+7;
// freopen("in.txt", "r", stdin);
// freopen("out.txt", "w", stdout);
//======================================================================================================//
signed main()
{
    IO_FAST
    testcase
    {
        int n;
        cin >> n;

        vector<int> v1;
        inputvec(v1, n);

        int ans = 0;
        for(int i=0; i<n; i++)
        {
            ans += v1[i];
        } 

        while(v1.size() > 1) 
        {
            vector<int> v2;
            for(int i=1; i<v1.size(); i++) 
            {
                v2.pb(v1[i]-v1[i-1]);
            }

            int num1 = 0;
            for(int i=0; i<v2.size(); i++)
            {
                num1 += v2[i];
            }

            reverse(v1);
            vector<int> v3;
            for(int i=1; i<v1.size(); i++) 
            {
                v3.pb(v1[i]-v1[i-1]);
            }

            int num2 = 0;
            for(int i=0; i<v3.size(); i++)
            {
                num2 += v3[i];
            }

            if(num1>=num2) 
            {
                v1 = v2;
                ans = max(ans, num1);
            } 
            else 
            {
                v1 = v3;
                ans = max(ans, num2);
            }
        }

        cout << ans << endl;      
    }
}