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

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

void setIO(string name = "") {
    cin.tie(0)->sync_with_stdio(0);
    if (!name.empty()) {
        freopen((name + ".in").c_str(), "r", stdin);
        freopen((name + ".out").c_str(), "w", stdout);
    }
}

vector<long long> dif(vector<long long> v) {
    vector<long long> ret(v.size() - 1);
    for (int i = 1; i < v.size(); i++) {
        ret[i - 1] = v[i] - v[i - 1];
    }
    return ret;
}


int main() {
    setIO();
    int t; cin >> t;
    for (int a = 0; a < t; a++) {
        int n; cin >> n;
        vector<long long> v(n);
        for (int i = 0; i < n; i++) {
            cin >> v[i];
        }
        long long sum = accumulate(v.begin(), v.end(), 0LL);
        
        while (v.size() > 1) {
            if (v[v.size() - 1] < v[0]) {
                reverse(v.begin(), v.end());
            }
            v = dif(v);
            long long temp = accumulate(v.begin(), v.end(), 0LL);
            if (temp > sum) {
                sum = temp;
            }

        }

        cout << sum << "\n";


    }

    return 0;
}


Solution 2 (runtime: 46 ms):
#pragma GCC optimize("O3,unroll-loops")

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace chrono;
using namespace __gnu_pbds; 

#define int long long
#define all(i,n) for(int i=0;i<(int)n;i++)
#define srt(v) sort(v.begin(), v.end())
#define pb push_back
#define vi vector<int> 
#define vvi vector<vector<int>>

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update > pbds; 

int md = 1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int getRandomNumber(int l, int r) { return uniform_int_distribution<int>(l,r)(rng); }
int expo(int a, int b, int mod) { int res = 1; a%=mod; b%=mod; while(b > 0){ if(b&1) res = (res * a)%mod; a = (a * a)%mod; b >>= 1; } return res%mod; }
int ModInvPrime(int a , int b) { return expo(a , b-2 , b)%b; }
int power(int a, int b){ int res = 1; while(b){ if(b&1) res*=a; a*=a; b>>=1; } return res; }
bool isPrime(int n) { if (n <= 1) return false; for (int i = 2; i * i <= n; i++) if (n % i == 0) return false; return true; }
int GCD(int a,int b) { if(b==0)return a; a%=b; return GCD(b,a); }

void solve() {
    int n;
    cin >> n;
    vector<int> v(n), t ; 
    for(int i=0; i<n; i++){
        cin >> v[i];
    }
    int ans = -1e9;
    int sum = accumulate(v.begin(), v.end(), 0LL);
    ans = max(ans, sum);
    while( v.size() > 1){
        t.clear();
        for(int i=0; i<v.size()-1; i++){
            t.push_back(v[i+1] - v[i]);
        }
        sum = accumulate(t.begin(), t.end(), 0LL);
        if(v.size() > 1)
            ans = max(ans, abs(sum));
        else
            ans = max(ans, sum);
        v.clear();
        v = t;
    }

    cout << ans <<endl;

}
signed main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(nullptr);
    int t = 1;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;                                                                                                                       
}