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

Solution 1 (runtime: 46 ms):
//==================== contributed by kanshuman ====================

//========================= input module ===============================

#pragma GCC optimod_intze("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 kanshuman6484 ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

#define flp(a,b,c) for (int(a) = b; (a) < (c); (a)++)
#define rep(a,b,c) for (int(a) = b; (a) >= (c); (a)--)

using ll = long long;
const int M = 1e9 + 7;
#define pb push_back
#define pob pop_back
#define nl '\n'
#define X first
#define Y second
#define PI 3.141592653589793238462
#define YES cout<<"YES"<<nl
#define NO cout<<"NO"<<nl
#define all(x) x.begin(),x.end()
#define sz(x) ((int)(x).size())
#define vi vector<int>
#define vl vector<ll>
#define pll pair<ll,ll>
#define dbg debug

#define srt(v)  sort(v.begin(),v.end())
#define rev(v)  reverse(v.begin(),v.end())
#define mxe(v)  *max_element(v.begin(),v.end())
#define mne(v)  *min_element(v.begin(),v.end())
#define unq(v)  v.resize(distance(v.begin(), unique(v.begin(), v.end())));

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

void _print(int x){cerr<<x;}
void _print(ll t) {cerr << t;}
void _print(char x){cerr<<x;}
void _print(string x){cerr<<x;}

template<class T,class V> void _print(pair<T,V> p) {cerr<<"{"; _print(p.first);cerr<<","; _print(p.second);cerr<<"}";}
template<class T>void _print(vector<T> v) {cerr<<" [ "; for (T i:v){_print(i);cerr<<" ";}cerr<<"]";}
template<class T>void _print(set<T> v) {cerr<<" [ "; for (T i:v){_print(i); cerr<<" ";}cerr<<"]";}
template<class T>void _print(multiset<T> v) {cerr<< " [ "; for (T i:v){_print(i);cerr<<" ";}cerr<<"]";}
template<class T,class V>void _print(map<T, V> v) {cerr<<" [ "; for(auto i:v) {_print(i);cerr<<" ";} cerr<<"]";}

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
//find_by_order(index) -> returns iterator , order_of_key(key) -> returns cnt of values < key
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset;
typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_pset;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// ===============================================================================================

ll gcd(ll a, ll b){if (b > a)return gcd(b, a);if (b == 0)return a;return gcd(b, a % b);}
ll expo(ll a, ll b, ll mod){ll res = 1;while (b > 0){if (b & 1)res = (res * a) % mod;a = (a * a) % mod;b = b >> 1;}return res;}
vector<ll> sieve(int n){int *arr = new int[n + 1]();vector<ll> vect;for (int i = 2; i <= n; i++)if (arr[i] == 0){vect.push_back(i);for (int j = 2 * i; j <= n; j += i)arr[j] = 1;}return vect;}
ll mod_add(ll a, ll b, ll m){a = a % m;b = b % m;return (((a + b) % m) + m) % m;}
ll mod_mul(ll a, ll b, ll m){a = a % m;b = b % m;return (((a * b) % m) + m) % m;}
//void meta(int t) {cout << "Case #" << t << ": ";}
ll phin(ll n){ll number = n;if (n % 2 == 0){number /= 2;while (n % 2 == 0)n /= 2;}for (ll i = 3; i <= sqrt(n); i += 2){if (n % i == 0){while (n % i == 0)n /= i;number = (number / i * (i - 1));}}if (n > 1)number = (number / n * (n - 1));return number;} // O(sqrt(N))
ll getRandomNumber(ll l, ll r) { return uniform_int_distribution<ll>(l, r)(rng); }

// ============================ take ip/op like vector,pairs directly! ============================

template<typename typC,typename typD> istream &operator>>(istream &cin,pair<typC,typD> &a) { return cin>>a.first>>a.second; }
template<typename typC> istream &operator>>(istream &cin,vector<typC> &a) { for (auto &x:a) cin>>x; return cin; }
template<typename typC,typename typD> ostream &operator<<(ostream &cout,const pair<typC,typD> &a) { return cout<<a.first<<' '<<a.second; }
template<typename typC,typename typD> ostream &operator<<(ostream &cout,const vector<pair<typC,typD>> &a) { for (auto &x:a) cout<<x<<' '; return cout; }
template<typename typC> ostream &operator<<(ostream &cout,const vector<typC> &a) { int n=a.size(); if (!n) return cout; cout<<a[0]; for (int i=1; i<n; i++) cout<<' '<<a[i]; return cout; }

//===================== END of the input module ========================

void solve()
{
    int n; cin >> n;
    vl a(n + 1);
    flp(i, 1, n + 1) cin >> a[i];
    int k = n;
    ll ans = -1e18;
    flp(i, 1, n + 1) {
        ll sum = 0;
        flp(i, 1, k + 1) sum += a[i];
        if (i == 1) ans = max(ans, sum);
        else ans = max(ans, max(sum, (-sum)));
        flp(i, 1, k) a[i] = a[i + 1] - a[i];
        k--;
    }
    cout << ans << nl;
    return;
}

int main()
{
    kanshuman6484
#ifdef ONLINE_JUDGE
    freopen("error.txt", "w", stderr);
#endif
    auto start1 = high_resolution_clock::now();
    int t = 1;
    cin >> t;
    flp(i, 1, t + 1) {
        //meta(i);
        solve();
    }
    auto stop1 = high_resolution_clock::now();
    auto duration = duration_cast<microseconds>(stop1 - start1);
#ifndef ONLINE_JUDGE
    cerr << "Time: " << duration.count() / 1000 << " ms" << endl;
#endif

    return 0;
}

Solution 2 (runtime: 46 ms):
﻿#include <iostream>
#include <ctime>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <map>
#include <bitset>
#include <set>
using namespace std;

using ll = long long;


using namespace std;

long long a[1010];

int main() {
	int t;
	cin >> t;
	while (t--) {
		int n;
		cin >> n;
		for (int i = 1; i <= n; i++) 
			cin >> a[i];
		int now = n;
		long long ans = -1e18;
		for (int i = 1; i <= n; i++) {
			long long sum = 0;
			for (int i = 1; i <= now; i++)
				sum = (sum + a[i]);
			if (i == 1)
				ans = max(ans, sum);
			else 
				ans = max(ans, max(sum, (-sum)));
			for (int i = 1; i < now; i++) 
				a[i] = (a[i + 1] - a[i]);
			now--;
		}
		cout << ans << endl;
	}
	return 0;
}