Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
// LOCKED IN!
#include <bits/stdc++.h>
using namespace std;
#define int long long
// const int MXV = (1LL << 58) - 1;
// const int INF = (1LL << 56);
const int MXQ = (1LL << 32) - 1;
void dbg(vector<int> &v) { for(int k: v) cout << k << " "; }
void dbg(map<int, int> &v) { for(auto [a, b]: v) cout << a << " " << b << '\n'; }
void dbg(set<int> &v) { for(int k: v) cout << k << " "; }

// O(n) ~ O(1)
struct DSU {
  vector<int> par, sz;
  DSU(int n) {
    par.resize(n+1);
    sz.resize(n+1, 1);
    for(int i = 0 ; i <= n ; i++) par[i] = i;
  }

  int pfind(int v) {
    if(v == par[v]) return v;
    else return par[v] = pfind(par[v]);
  }

  void sunion(int a, int b) {
    a = pfind(a);
    b = pfind(b);
    if(a == b) return;
    if(sz[a] > sz[b]) swap(a, b);
    par[b] = a;
    sz[a] += sz[b];
  }
};

const int INF = 1e7;
void solve() {
  int n; cin >> n;
  vector<int> v(n);
  for(int i = 0 ; i < n ; i++) cin >> v[i];
  if(n == 1) {
    cout << v[0] << '\n';
    return;
  }
  
  int r = -INF;
  for(int i = 0 ; i < n-1 ; i++) {
    // yapping fr fr
    int k = 0;
    for(int j: v) k += j;
    if(k < 0) reverse(v.begin(), v.end());
    r = max(r, k);
    k = 0;
    for(int j: v) k += j;
    r = max(r, k);
    vector<int> nv;
    for(int j = 0 ; j < v.size()-1 ; j++) nv.push_back(v[j+1] - v[j]);
    v = nv;
    // for(int j: v) cout << j << " ";
    // cout << endl;
  }

  cout << max(r, abs(v[0])) << '\n';
}

signed main() {
  int t; cin >> t;
  // int t = 1;
  while(t--) solve();
}

// think greedy first, Div2AB usually are some sort of greedy, super simple usually
// C on Div2 or E on Div3/4 require more thinking but still not too hard
// for later problems, think about data structures like segment tree and ordered set
// do smth instead of nothing and stay organized
// WRITE STUFF DOWN
// DON'T GET STUCK ON ONE APPROACH

Submission (verdict: Accepted):
// LOCKED IN!
#include <bits/stdc++.h>
using namespace std;
#define int long long
// const int MXV = (1LL << 58) - 1;
// const int INF = (1LL << 56);
const int MXQ = (1LL << 32) - 1;
void dbg(vector<int> &v) { for(int k: v) cout << k << " "; }
void dbg(map<int, int> &v) { for(auto [a, b]: v) cout << a << " " << b << '\n'; }
void dbg(set<int> &v) { for(int k: v) cout << k << " "; }
 
// O(n) ~ O(1)
struct DSU {
  vector<int> par, sz;
  DSU(int n) {
    par.resize(n+1);
    sz.resize(n+1, 1);
    for(int i = 0 ; i <= n ; i++) par[i] = i;
  }
 
  int pfind(int v) {
    if(v == par[v]) return v;
    else return par[v] = pfind(par[v]);
  }
 
  void sunion(int a, int b) {
    a = pfind(a);
    b = pfind(b);
    if(a == b) return;
    if(sz[a] > sz[b]) swap(a, b);
    par[b] = a;
    sz[a] += sz[b];
  }
};
 
const int INF = 1e7;
void solve() {
  int n; cin >> n;
  vector<int> v(n);
  int r = 0;
  for(int i = 0 ; i < n ; i++) {
    cin >> v[i];
    r += v[i];
  }
  
  if(n == 1) {
    cout << v[0] << '\n';
    return;
  }
  
  for(int i = 0 ; i < n-1 ; i++) {
    int k = 0;  
    vector<int> w;
    for(int j = 0 ; j < v.size()-1 ; j++) {
      w.push_back(v[j+1] - v[j]);
      k += w.back();
    }

    r = max(r, abs(k));
    v = w;
  }
 
  cout << r << '\n';
}
 
signed main() {
  int t; cin >> t;
  // int t = 1;
  while(t--) solve();
}
 
// think greedy first, Div2AB usually are some sort of greedy, super simple usually
// C on Div2 or E on Div3/4 require more thinking but still not too hard
// for later problems, think about data structures like segment tree and ordered set
// do smth instead of nothing and stay organized
// WRITE STUFF DOWN
// DON'T GET STUCK ON ONE APPROACH