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

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

void solve_1() {
    int n;
    cin >> n;
    vector<string> g(n);

    for (int i = 0; i < n; ++i) {
        cin >> g[i];
    }

    vector<int> p(n, LONG_LONG_MAX);
    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n; ++j) {
            if (g[i][j] == '0') {
                p[j] = i;
            } else {
                if (p[i] > j) {
                    p[i] = j;
                }
            }
        }
        cout << "p: "; for (int b : p) cout << b << ' '; cout << '\n';
    }

    int mex = 0;
    vector<bool> f(n + 1);
    for (int i = 0; i < n; ++i) {
        if (p[i] < n) {
            f[p[i]] = true;
        }
    }

    for (int i = 0; i <= n; ++i) {
        if (!f[i]) {
            mex = i;
            break;
        }
    }

    cout << "f: "; for (bool b : f) cout << b << ' '; cout << '\n';
    cout << "p: "; for (int b : p) cout << b << ' '; cout << '\n';

    int t = mex;
    while (t != LONG_LONG_MAX) {
        cout << t << ' ';
        t = p[t];
    }
    cout << '\n';
}

void printIntVec(vector<int> &v, string name) {
    cout << name << ": ";
    for (int i : v) cout << i << ' ';
    cout << '\n';
}

void inIntVec(vector<int> &v) {
    for (int i = 0; i < v.size(); ++i) {
        cin >> v[i];
    }
}

void solve() {
    int n;
    cin >> n;
    vector<int> a(n);
    inIntVec(a);
    int mx = accumulate(a.begin(), a.end(), 0ll);
    if (a.size() == 1) {
        cout << mx << '\n';
        return;
    }
    while (a.size() > 1) {
        vector<int> tmp;
        for (int i = 1; i < a.size(); ++i) {
            tmp.push_back(a[i] - a[i - 1]);
        }
        a = tmp;
        int sm = accumulate(a.begin(), a.end(), 0ll);
        mx = max(mx, abs(sm));
    }
    cout << max(mx, abs(a[0])) << '\n';
}

int32_t main() {
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}

Solution 2 (runtime: 61 ms):
#include <iostream>
#include <vector>
#include <list>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>

using namespace std;

#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define vll vector<ll>
#define vull vector<ull>
#define pi pair<int, int>
#define pll pair<ll, ll>
#define pull pair<ull, ull>
#define uset unordered_set
#define umap unordered_map

#define all(c) (c).begin(), (c).end()

#define debugp(p) cout << "f=" << p.first << ",s=" << p.second << "\n"
#define debugiter(c) for (const auto& v : c) std::cout << v << " "
#define initvec(v) for (auto& vn : v) cin >> vn

void solve() {
    int N; cin >> N;
    vll nums(N); initvec(nums);

    ll bestSum = accumulate(all(nums), 0LL);
    for (int d = 0; d < N - 1; d++) {
        // do difference operation
        for (int i = 0; i < nums.size() - 1; i++)
            nums[i] = nums[i + 1] - nums[i];
        nums.pop_back();

        // debugiter(nums); cout << "\n";

        ll sum = accumulate(all(nums), 0LL);
        bestSum = max(bestSum, max(sum, -sum));
    }

    cout << bestSum << "\n";
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int T; cin >> T;
    while (T--) {
        solve();
    }
}