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

Solution 1 (runtime: 46 ms):
#include <bits/stdc++.h>
#define fl(i, k, n) for (int i = k; i < n; i++)
#define dfl(i, n) for (int i = n - 1; i >= 0; i--)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;

template <typename T>

inline void print(T a)
{
    cout << a << "\n";
}

template <typename T>
inline void printV(const vector<T> &a)
{
    for (const T &b : a)
        cout << b << " ";
    cout << "\n";
}

template <typename T>
inline void printVV(const vector<vector<T>> &a)
{
    for (const vector<T> &row : a)
    {
        for (const T &elem : row)
            cout << elem << " ";
        cout << "\n";
    }
}

// Function to input a vector
template <typename T>
inline void inputV(vector<T> &a)
{
    for (T &elem : a)
        cin >> elem;
}

// Function to input a 2D vector
template <typename T>
inline void inputVV(vector<vector<T>> &a, int rows, int cols)
{
    a.resize(rows, vector<T>(cols));
    for (int i = 0; i < rows; i++)
        for (int j = 0; j < cols; j++)
            cin >> a[i][j];
}

// Modular arithmetic utilities
const int MOD = 1e9 + 7;
inline ll addMod(ll a, ll b)
{
    return (a + b) % MOD;
}
inline ll subMod(ll a, ll b)
{
    return (a - b + MOD) % MOD;
}
inline ll mulMod(ll a, ll b)
{
    return (a * b) % MOD;
}
// Debugging utilities
#ifdef DEBUG
#define debug(x) cerr << #x << " = " << (x) << endl;
#else
#define debug(x)
#endif
ll power(ll a, ll b)
{
    ll ans = 1;
    while (b > 0)
    {
        if (b & 1)
        {
            ans = (ans * a) % 1000000007;
        }
        a = (a * a) % 1000000007;
        b >>= 1;
    }
    return ans;
}

int findMin(vector<int> &arr)
{
    int low = 0, high = arr.size() - 1;
    while (low <= high)
    {
        if (arr[low] <= arr[high])
        {
            return low;
        }
        int mid = (low + high) / 2;
        if (arr[mid] > arr[high])
        {
            low = mid + 1;
        }
        else
        {
            high = mid;
        }
    }
    return low;
}
bool prime(int n)
{
    int cnt = 0;
    for (int i = 2; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            cnt++;
        }
    }
    return (cnt <= 0);
}
int lcs(string &S1, string &S2)
{
    int m = S1.size();
    int n = S2.size();
    vector<vector<int>> dp(m + 1, vector<int>(n + 1, 0));
    for (int i = 1; i <= m; ++i)
    {
        for (int j = 1; j <= n; ++j)
        {
            if (S1[i - 1] == S2[j - 1])
                dp[i][j] = dp[i - 1][j - 1] + 1;
            else
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
        }
    }

    return dp[m][n];
}
bool isPower(ll x, ll y)
{
    float res1 = log(y) / log(x);
    return res1 == floor(res1);
}
ll hcf(ll n1, ll n2)
{
    if (n2 != 0)
        return hcf(n2, n1 % n2);
    else
        return n1;
}
unsigned int onesComplement(unsigned int n)
{
    int number_of_bits = floor(log2(n)) + 1;
    return ((1 << number_of_bits) - 1) ^ n;
}
/*auto compare = [&](string a, string b){
    if(mp[a]==mp[b]){
        return a.length()>b.length();
    }
    return mp[a]>mp[b];
};*/
struct comp {
    template <typename T>
 
    // Comparator function
    bool operator()(const T& l, const T& r) const
    {
        if (l.second != r.second) {
            return l.second < r.second;
        }
        return l.first < r.first;
    }
};
void solve(){
    int n;
    cin>>n;
    vector<ll>arr;
    for(int i=0;i<n;i++){
        ll x;
        cin>>x;
        arr.push_back(x);
    }  
    if(n==1){
        cout<<arr[0]<<endl;
        return;
    }
    ll sum=0;
    for(int i=0;i<n;i++){
        sum+=arr[i];
    }
    while(n>1){
        ll sum1=0;
        for(int j=0;j<n-1;j++){
            sum1+=(arr[j+1]-arr[j]);
            arr[j]=arr[j+1]-arr[j];
        }
        sum=max(abs(sum1),sum);
        n--;
    }
    cout<<(abs(arr[0]),sum)<<endl;
}

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


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

int main() {
    int t;
    cin >> t; // Number of test cases

    while (t--) {
        int n;
        cin >> n;

        vector<long long> arr(n);
        for (int i = 0; i < n; i++) {
            cin >> arr[i]; // Input array
        }

        vector<long long> brr(n); 
        
        if(n==1){
            cout<<arr[0]<<endl;
        }else{
        for (int i = 0; i < n; i++) { // Process at most n-1 times
            long long sum = 0;
            for (int j = 0; j < n - i; j++) {
                sum += arr[j]; // Compute sum of first (n-i) elements
            }
            if(i==0){
                brr.push_back(sum);
            }else{

                brr.push_back(abs(sum));
            }

            // Compute new difference array, ensuring no out-of-bounds
            for (int j = 0; j < n - i - 1; j++) {
                arr[j] = arr[j + 1] - arr[j]; // Safe transformation
            }
        }

        if (!brr.empty()) {
            long long max_value = *max_element(brr.begin(), brr.end());
            cout << max_value << endl;
        }
    }
    }

    return 0;
}