Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int MOD = 1e9 + 7;
const int INF = 1e9;
const int N_max = 2e5 + 1;

int eea(int a, int b, int &x, int &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    int x1, y1;
    int d = eea(b, a % b, x1, y1);
    x = y1;
    y = x1 - y1 * (a / b);
    return d;
}

// for prime m
ll inv_prime(ll a, ll m) {
  return a <= 1 ? a : m - (ll) (m/a) * inv_prime(m % a, m) % m;
}

ll bipower(ll a, ll n) {
    ll res = 1;
    while (n) {
        if (n & 1) res = (res * a) % MOD;
        a = (a * a) % MOD;
        n >>= 1;
    } 
    return res;
}

class min_queue {
    deque<int> elems;
    deque<int> mins;
    deque<int> idxs;
    int cnt;
public:
    min_queue() {cnt = 0;}
    ~min_queue() {}

    void push(int elem) {
        elems.push_back(elem);
        while (!mins.empty() && mins.back() >= elem) {
            mins.pop_back();
            idxs.pop_back();
        }

        mins.push_back(elem);
        idxs.push_back(cnt++);        
    }

    int pop() {
        if (!elems.empty()) {
            if (!idxs.empty() && idxs.front() == cnt - elems.size()) {
                mins.pop_front();
                idxs.pop_front();
            }

            int el = elems.front();
            elems.pop_front();
            return el;
        }
        return -1;
    }

    int get_min() {
        if (!mins.empty())
            return mins.front();
        return -1;
    }

    size_t size() {
        return elems.size();
    }

    bool empty() {
        return size() == 0;
    }
};

void dfs(vector<vi>& g, vi& subtrees, vi& parents, vector<bool>& vis, int current, int depth, ll& total) {
    vis[current] = true;
    total += depth;
    subtrees[current] = 1;
    for (auto &e : g[current]) {
        if (!vis[e]) {
            parents[e] = current;
            dfs(g, subtrees, parents, vis, e, depth + 1, total);
            subtrees[current] += subtrees[e];
        }
    }
}

void solve() {
    int n;
    cin >> n;
    vll a(n);
    for (auto &e : a)
        cin >> e;
    if (n == 1) {
        cout << a[0] << "\n";
        return;
    }

    ll res = 0;
    for (int i = 0; i < n; i++)
        res += a[i];
    res = abs(res);

    ll tmp = 0;
    while (a.size() > 1) {
        tmp = 0;

        for (int i = 0; i < a.size() - 1; i++)
            a[i] = a[i + 1] - a[i];

        a.pop_back();

        for (int i = 0; i < a.size(); i++)
            tmp += a[i];
        
        res = max(res, abs(tmp));
    }

    cout << res << "\n";
}
 
 
int main(){
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    int T = 1;
    cin >> T;
    while(T--)
        solve();
    return 0;
}

Submission (verdict: Accepted):
#include <bits/stdc++.h>
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int MOD = 1e9 + 7;
const int INF = 1e9;
const int N_max = 2e5 + 1;

int eea(int a, int b, int &x, int &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    int x1, y1;
    int d = eea(b, a % b, x1, y1);
    x = y1;
    y = x1 - y1 * (a / b);
    return d;
}

// for prime m
ll inv_prime(ll a, ll m) {
  return a <= 1 ? a : m - (ll) (m/a) * inv_prime(m % a, m) % m;
}

ll bipower(ll a, ll n) {
    ll res = 1;
    while (n) {
        if (n & 1) res = (res * a) % MOD;
        a = (a * a) % MOD;
        n >>= 1;
    } 
    return res;
}

class min_queue {
    deque<int> elems;
    deque<int> mins;
    deque<int> idxs;
    int cnt;
public:
    min_queue() {cnt = 0;}
    ~min_queue() {}

    void push(int elem) {
        elems.push_back(elem);
        while (!mins.empty() && mins.back() >= elem) {
            mins.pop_back();
            idxs.pop_back();
        }

        mins.push_back(elem);
        idxs.push_back(cnt++);        
    }

    int pop() {
        if (!elems.empty()) {
            if (!idxs.empty() && idxs.front() == cnt - elems.size()) {
                mins.pop_front();
                idxs.pop_front();
            }

            int el = elems.front();
            elems.pop_front();
            return el;
        }
        return -1;
    }

    int get_min() {
        if (!mins.empty())
            return mins.front();
        return -1;
    }

    size_t size() {
        return elems.size();
    }

    bool empty() {
        return size() == 0;
    }
};

void dfs(vector<vi>& g, vi& subtrees, vi& parents, vector<bool>& vis, int current, int depth, ll& total) {
    vis[current] = true;
    total += depth;
    subtrees[current] = 1;
    for (auto &e : g[current]) {
        if (!vis[e]) {
            parents[e] = current;
            dfs(g, subtrees, parents, vis, e, depth + 1, total);
            subtrees[current] += subtrees[e];
        }
    }
}

void solve() {
    int n;
    cin >> n;
    vll a(n);
    for (auto &e : a)
        cin >> e;
    if (n == 1) {
        cout << a[0] << "\n";
        return;
    }

    ll res = 0;
    for (int i = 0; i < n; i++)
        res += a[i];

    ll tmp = 0;
    while (a.size() > 1) {
        tmp = 0;

        for (int i = 0; i < a.size() - 1; i++)
            a[i] = a[i + 1] - a[i];

        a.pop_back();

        for (int i = 0; i < a.size(); i++)
            tmp += a[i];
        
        res = max(res, abs(tmp));
    }

    cout << res << "\n";
}
 
 
int main(){
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    int T = 1;
    cin >> T;
    while(T--)
        solve();
    return 0;
}