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

Code 1:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
template<class T> using ordered_set = __gnu_pbds::tree<T, __gnu_pbds::null_type, std::less<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;

#define dbg(x) cerr << #x << " = " << x << endl;
#define int long long
#define double long double
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(),a.rend()
#define endl "\n"
const int mod = 1e9+ 7;
const int dx[] = { 1, 0, -1, 0 };                                                            
const int dy[] = { 0, 1, 0, -1 };     

int lcm(int a,int b){
    return a/__gcd(a,b)*b;
}

const int maxN = 1e3 + 5, inf = 1e18;

int sum(vector<int>&a){
    int res =0 ;
    for(int x:a)res += x;
    return res;
}
void solve(){
    // so importa o primeiro e o ultimo

    int n, ans = 0;
    cin >> n;

    vector<int>a(n);
    for(int &i:a){
        cin >> i;
        ans += i;
    }

    while(a.size() > 1){
        int x = a.back() - a.front();

        ans = max(ans, x);
        // cout << "sz: " << a.size() << endl;
        if(x < 0){
            reverse(all(a));
        }

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

        a = b;
    }
    ans = max(ans, a[0]);
    cout << ans << endl;
}



signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    cin >> t;

    while (t--) {
        solve();
    }

  
    return 0;
}





Code 2:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
template<class T> using ordered_set = __gnu_pbds::tree<T, __gnu_pbds::null_type, std::less<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;

#define dbg(x) cerr << #x << " = " << x << endl;
#define int long long
#define double long double
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(),a.rend()
#define endl "\n"
const int mod = 1e9+ 7;
const int dx[] = { 1, 0, -1, 0 };                                                            
const int dy[] = { 0, 1, 0, -1 };     

int lcm(int a,int b){
    return a/__gcd(a,b)*b;
}

const int maxN = 1e3 + 5, inf = 1e18;

int sum(vector<int>&a){
    int res =0 ;
    for(int x:a)res += x;
    return res;
}
void solve(){
    // so importa o primeiro e o ultimo

    int n, ans = 0;
    cin >> n;

    vector<int>a(n);
    for(int &i:a){
        cin >> i;
        ans += i;
    }

    while(a.size() > 1){
        // for(int x:a)cout << x << " ";
        // cout << endl;
        int x = a.back() - a.front();

        ans = max(ans, sum(a));
        // cout << "sz: " << a.size() << " x: " << x << " ans: " << ans << endl;
        if(x < 0){
            reverse(all(a));
        }

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

        a = b;
    }
    ans = max(ans, a[0]);
    cout << ans << endl;
}



signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    cin >> t;

    while (t--) {
        solve();
    }

  
    return 0;
}





Answer: 2