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

Previous submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
#define IOS1 std::ios::sync_with_stdio(false)
#define IOS2 std::cin.tie(nullptr)
#define mode1 1
#define mode2 1

using i32 = int;
using ui32 = unsigned int;
using i64 = long long;
using ui64 = unsigned long long;
using pii = std::pair<int, int>;
using ll = long long;
// using i128 = __int128;

constexpr i64 INF = 0x3f3f3f3f3f3f3f3f;
constexpr i64 INFINF = 0X7fffffffffffffff;
constexpr int inf = 1e9;
constexpr int mod = 998244353;

template <class T1, class T2>
std::istream& operator>>(std::istream& cin, std::pair<T1, T2>& a) { return cin >> a.first >> a.second; };
template <class T1, class T2>
std::ostream& operator<<(std::ostream& cout, std::pair<T1, T2>& a) { return cout << a.first << ' ' << a.second; };
template <class T>
std::ostream& operator<<(std::ostream& cout, std::vector<T>& a)
{
    for (int i = 0; i < a.size(); ++i)
        cout << a[i] << " \n"[i == a.size() - 1];
    return cout;
}

template<class T>
inline T read()
{
    T x = 0, f = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9')
    {
        if (ch == '-')
            f = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9')
        x = x * 10 + ch - '0', ch = getchar();
    return x * f;
}

template<class T>
inline void write(T x)
{
    if (x < 0)
        putchar('-'), x = -x;
    if (x > 9)
        write(x / 10);
    putchar(x % 10 + '0');
    return;
}

class Solution
{
public:
    void solve()
    {
        int n;
        std::cin >> n;
        std::vector<int> a(n), b;
        int tmp = -inf;
        for (int i = 0; i < n; ++i) std::cin >> a[i];
        std::function<void(std::vector<int> t)>dfs = [&](std::vector<int> t) -> void
        {
            tmp = std::max(tmp, std::accumulate(t.begin(), t.end(), 0));
            if (t.size() == 1) return;
            std::vector<int> x, y;
            for (int i = 1; i < t.size(); ++i)
            {
                x.emplace_back(t[i] - t[i - 1]);
            }
            dfs(x);
            // std::reverse(t.begin(), t.end());
            // for (int i = 1; i < t.size(); ++i)
            // {
            //     y.emplace_back(t[i] - t[i - 1]);
            // }
            // dfs(y);
        };
        dfs(a);
        std::cout << tmp << "\n";
    }
};

int main()
{
    IOS1;
    IOS2;

#if mode1
    int t;
    std::cin >> t;
    while (t--)
    {
        Solution().solve();
    }
#elif mode2
    Solution().solve();
#endif

    return 0;
}

Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
#define IOS1 std::ios::sync_with_stdio(false)
#define IOS2 std::cin.tie(nullptr)
#define mode1 1
#define mode2 1

using i32 = int;
using ui32 = unsigned int;
using i64 = long long;
using ui64 = unsigned long long;
using pii = std::pair<int, int>;
using ll = long long;
// using i128 = __int128;

constexpr i64 INF = 0x3f3f3f3f3f3f3f3f;
constexpr i64 INFINF = 0X7fffffffffffffff;
constexpr int inf = 1e9;
constexpr int mod = 998244353;

template <class T1, class T2>
std::istream& operator>>(std::istream& cin, std::pair<T1, T2>& a) { return cin >> a.first >> a.second; };
template <class T1, class T2>
std::ostream& operator<<(std::ostream& cout, std::pair<T1, T2>& a) { return cout << a.first << ' ' << a.second; };
template <class T>
std::ostream& operator<<(std::ostream& cout, std::vector<T>& a)
{
    for (int i = 0; i < a.size(); ++i)
        cout << a[i] << " \n"[i == a.size() - 1];
    return cout;
}

template<class T>
inline T read()
{
    T x = 0, f = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9')
    {
        if (ch == '-')
            f = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9')
        x = x * 10 + ch - '0', ch = getchar();
    return x * f;
}

template<class T>
inline void write(T x)
{
    if (x < 0)
        putchar('-'), x = -x;
    if (x > 9)
        write(x / 10);
    putchar(x % 10 + '0');
    return;
}

class Solution
{
public:
    void solve()
    {
        int n;
        std::cin >> n;
        std::vector<i64> a(n), b;
        i64 tmp = -INFINF;
        for (int i = 0; i < n; ++i) std::cin >> a[i];
        std::function<void(std::vector<i64> t)>dfs1 = [&](std::vector<i64> t) -> void
        {
            tmp = std::max(tmp, std::accumulate(t.begin(), t.end(), 0LL));
            if (t.size() == 1) return;
            std::vector<i64> x, y;
            for (int i = 1; i < t.size(); ++i)
            {
                x.emplace_back(t[i] - t[i - 1]);
            }
            dfs1(x);
            // std::reverse(t.begin(), t.end());
            // for (int i = 1; i < t.size(); ++i)
            // {
            //     y.emplace_back(t[i] - t[i - 1]);
            // }
            // dfs1(y);
        };
        std::function<void(std::vector<i64> t)>dfs2 = [&](std::vector<i64> t) -> void
        {
            tmp = std::max(tmp, std::accumulate(t.begin(), t.end(), 0LL));
            if (t.size() == 1) return;
            std::vector<i64> x, y;
            // for (int i = 1; i < t.size(); ++i)
            // {
            //     x.emplace_back(t[i] - t[i - 1]);
            // }
            // dfs1(x);
            std::reverse(t.begin(), t.end());
            for (int i = 1; i < t.size(); ++i)
            {
                y.emplace_back(t[i] - t[i - 1]);
            }
            dfs2(y);
        };
        dfs1(a);
        dfs2(a);
        std::cout << tmp << "\n";
    }
};

int main()
{
    IOS1;
    IOS2;

#if mode1
    int t;
    std::cin >> t;
    while (t--)
    {
        Solution().solve();
    }
#elif mode2
    Solution().solve();
#endif

    return 0;
}