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

Solution 1 (runtime: 46 ms):
#include "bits/stdc++.h"
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vb vector<bool>
#define vll vector<ll>
#define vd vector<double>
#define vpii vector<pii>
#define vvi vector<vector<int>>
#define vvll vector<vll>
#define vvpii vector<vpii>
#define pb push_back
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define forn(i, n) for (int i = 0; i < (n); ++i)
constexpr ll N = 2e5 + 7;
constexpr ll M = 5e5 + 1;
constexpr ll mod = 1e9 + 7;
using namespace std;

template <class T>
std::ostream &operator<<(std::ostream &out, const vector<T> &vec) {
  for (auto &val : vec) {
    out << val << ' ';
  }
  out << '\n';
  return out;
}

#ifndef DEBUG_TEMPLATE_CPP
#define DEBUG_TEMPLATE_CPP
#include <bits/stdc++.h>
// #define cerr cout
namespace __DEBUG_UTIL__ {
using namespace std;
/* Primitive Datatypes Print */
void print(const char *x) { cerr << x; }
void print(bool x) { cerr << (x ? "T" : "F"); }
void print(char x) { cerr << '\'' << x << '\''; }
void print(signed short int x) { cerr << x; }
void print(unsigned short int x) { cerr << x; }
void print(signed int x) { cerr << x; }
void print(unsigned int x) { cerr << x; }
void print(signed long int x) { cerr << x; }
void print(unsigned long int x) { cerr << x; }
void print(signed long long int x) { cerr << x; }
void print(unsigned long long int x) { cerr << x; }
void print(float x) { cerr << x; }
void print(double x) { cerr << x; }
void print(long double x) { cerr << x; }
void print(string x) { cerr << '\"' << x << '\"'; }
template <size_t N> void print(bitset<N> x) { cerr << x; }
void print(vector<bool> v) { /* Overloaded this because stl optimizes
                                vector<bool> by using _Bit_reference instead of
                                bool to conserve space. */
  int f = 0;
  cerr << '{';
  for (auto &&i : v)
    cerr << (f++ ? "," : "") << (i ? "T" : "F");
  cerr << "}";
}
/* Templates Declarations to support nested datatypes */
template <typename T> void print(T &&x);
template <typename T> void print(vector<vector<T>> mat);
template <typename T, size_t N, size_t M> void print(T (&mat)[N][M]);
template <typename F, typename S> void print(pair<F, S> x);
template <typename T, size_t N> struct Tuple;
template <typename T> struct Tuple<T, 1>;
template <typename... Args> void print(tuple<Args...> t);
template <typename... T> void print(priority_queue<T...> pq);
template <typename T> void print(stack<T> st);
template <typename T> void print(queue<T> q);
/* Template Datatypes Definitions */
template <typename T> void print(T &&x) {
  /*  This works for every container that supports range-based loop
      i.e. vector, set, map, oset, omap, dequeue */
  int f = 0;
  cerr << '{';
  for (auto &&i : x)
    cerr << (f++ ? "," : ""), print(i);
  cerr << "}";
}
template <typename T> void print(vector<vector<T>> mat) {
  int f = 0;
  cerr << "\n~~~~~\n";
  for (auto &&i : mat) {
    cerr << setw(2) << left << f++, print(i), cerr << "\n";
  }
  cerr << "~~~~~\n";
}
template <typename T, size_t N, size_t M> void print(T (&mat)[N][M]) {
  int f = 0;
  cerr << "\n~~~~~\n";
  for (auto &&i : mat) {
    cerr << setw(2) << left << f++, print(i), cerr << "\n";
  }
  cerr << "~~~~~\n";
}
template <typename F, typename S> void print(pair<F, S> x) {
  cerr << '(';
  print(x.first);
  cerr << ',';
  print(x.second);
  cerr << ')';
}
template <typename T, size_t N> struct Tuple {
  static void printTuple(T t) {
    Tuple<T, N - 1>::printTuple(t);
    cerr << ",", print(get<N - 1>(t));
  }
};
template <typename T> struct Tuple<T, 1> {
  static void printTuple(T t) { print(get<0>(t)); }
};
template <typename... Args> void print(tuple<Args...> t) {
  cerr << "(";
  Tuple<decltype(t), sizeof...(Args)>::printTuple(t);
  cerr << ")";
}
template <typename... T> void print(priority_queue<T...> pq) {
  int f = 0;
  cerr << '{';
  while (!pq.empty())
    cerr << (f++ ? "," : ""), print(pq.top()), pq.pop();
  cerr << "}";
}
template <typename T> void print(stack<T> st) {
  int f = 0;
  cerr << '{';
  while (!st.empty())
    cerr << (f++ ? "," : ""), print(st.top()), st.pop();
  cerr << "}";
}
template <typename T> void print(queue<T> q) {
  int f = 0;
  cerr << '{';
  while (!q.empty())
    cerr << (f++ ? "," : ""), print(q.front()), q.pop();
  cerr << "}";
}
/* Printer functions */
void printer(const char *) {} /* Base Recursive */
template <typename T, typename... V>
void printer(const char *names, T &&head, V &&...tail) {
  /* Using && to capture both lvalues and rvalues */
  int i = 0;
  for (size_t bracket = 0;
       names[i] != '\0' and (names[i] != ',' or bracket != 0); i++)
    if (names[i] == '(' or names[i] == '<' or names[i] == '{')
      bracket++;
    else if (names[i] == ')' or names[i] == '>' or names[i] == '}')
      bracket--;
  cerr.write(names, i) << " = ";
  print(head);
  if (sizeof...(tail))
    cerr << " ||", printer(names + i + 1, tail...);
  else
    cerr << "]\n";
}
/* PrinterArr */
void printerArr(const char *) {} /* Base Recursive */
template <typename T, typename... V>
void printerArr(const char *names, T arr[], size_t N, V... tail) {
  size_t ind = 0;
  for (; names[ind] and names[ind] != ','; ind++)
    cerr << names[ind];
  for (ind++; names[ind] and names[ind] != ','; ind++)
    ;
  cerr << " = {";
  for (size_t i = 0; i < N; i++)
    cerr << (i ? "," : ""), print(arr[i]);
  cerr << "}";
  if (sizeof...(tail))
    cerr << " ||", printerArr(names + ind + 1, tail...);
  else
    cerr << "]\n";
}
} // namespace __DEBUG_UTIL__
#ifndef ONLINE_JUDGE
#define debug(...)                                                             \
  std::cerr << __LINE__ << ": [",                                              \
      __DEBUG_UTIL__::printer(#__VA_ARGS__, __VA_ARGS__)
#define debugArr(...)                                                          \
  std::cerr << __LINE__ << ": [",                                              \
      __DEBUG_UTIL__::printerArr(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...)
#define debugArr(...)
#endif
#endif

struct custom_hash {
  static uint64_t splitmix64(uint64_t x) {
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }

  size_t operator()(uint64_t x) const {
    static const uint64_t FIXED_RANDOM =
        chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
  }
};

ll binpow(ll a, ll b, ll modulo = mod) {
  ll res = 1;
  while (b) {
    if (b & 1) {
      res *= a;
      res %= modulo;
    }
    a *= a;
    a %= modulo;
    b >>= 1;
  }
  return res;
}

void solve() {
  int n;
  cin >> n;
  vll a(n);
  forn(i, n) cin >> a[i];
  ll res = -1e16;
  for (int start = 0; start < n; ++start) {
    ll sum = 0;
    for (int i = start; i < n; ++i) {
      sum += a[i];
    }
    // debug(a, sum);
    if (start > 0) {
      sum = abs(sum);
    }
    res = max(res, sum);
    for (int i = n - 1; i >= start + 1; --i) {
      a[i] -= a[i - 1];
    }
  }
  cout << res << '\n';
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);

  int t;
  cin >> t;
  while (t--) {
    solve();
  }
}

Solution 2 (runtime: 46 ms):
#include <iostream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

vector<long long> performDifferenceOperation(vector<long long>& v) {
    vector<long long> result;
    if (v.size() <= 1) {
        return result;
    }
    for (int i = 1; i < v.size(); ++i) {
        result.push_back(v[i] - v[i - 1]);
    }
    return result;
}

void solve() {
    int n; cin >> n;
    vector<long long> v(n);
    long long sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> v[i];
        sum += v[i];
    }
    while (v.size() != 1) {
        v = performDifferenceOperation(v);
        long long r = 0;
        for (long long i : v) r += i;
        sum = max(sum, r);
        sum = max(sum, -r);
    }
    cout << sum << "\n";
}

int main() {
    cin.tie(0) -> sync_with_stdio(0);
    int t;
    cin >> t;
    while (t--) solve();
}