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

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb  push_back
#define mp  make_pair
#define INT_MAX                 INT64_MAX;
#define INT_MIN                 INT64_MIN;
#define IO_FAST                 ios_base::sync_with_stdio(false); cin.tie(NULL);
#define testcase                int t; cin >> t; while(t--)
#define inputvec(v1, n)         for(int i=0; i<n; i++) {int x; cin >> x; v1.pb(x);}
#define inputvecp(v1, n)        for(int i=0; i<n; i++) {int x, y; cin >> x >> y; v1.pb(mp(x,y));}
#define sort(v1)                sort(v1.begin(), v1.end())
#define reverse(v1)             reverse(v1.begin(), v1.end())
#define print(x)                cout << #x << endl;
#define deb(x)                  cout << #x << ' ' <<  '=' << ' ' << x << endl;
#define upperbound(v1, k)       upper_bound(v1.begin(), v1.end(), k)
#define lowerbound(v1, k)       lower_bound(v1.begin(), v1.end(), k)
#define tolower(s1)             transform(s1.begin(), s1.end(), s1.begin(), ::tolower)
#define toupper(s1)             transform(s1.begin(), s1.end(), s1.begin(), ::toupper)
#define auto1(v1)               for(auto &num1:v1) {cout << num1 << ' ';} cout << endl;
#define auto2(vp1)              for(auto &num1:vp1) {cout << num1.first << ' ' <<num1.second << endl;}
#define auto3(vv1)              for(auto &num1:vv1) {for(auto &num2:num1){cout << num2 <<' ';}cout<<endl;}
int gcd(int a,int b)            {if (b==0) return a; return gcd(b, a%b);} // take a=0;
int lcm(int a,int b)            {return a/gcd(a,b)*b;}  // take a = v[0];
const int N = 1e5+10;
const int mod = 1e9+7;
// freopen("in.txt", "r", stdin);
// freopen("out.txt", "w", stdout);
//======================================================================================================//
signed main()
{
    IO_FAST
    testcase
    {
        int n;
        cin >> n;

        vector<int> v1;
        inputvec(v1, n);

        int sum=0;
        for(auto &value : v1)
        {
            sum += value;
        }   
             
        while(v1.size()>1)
        {
            int sum1=0;
            for(int i=1; i<v1.size(); i++)
            {
                sum1 = v1[i]-v1[i-1];
            }

            vector<int> v2=v1;
            reverse(v2);
            
            int sum2=0;
            for(int i=1; i<v2.size(); i++)
            {
                sum2 += v2[i] - v2[i-1];
            }

            if(sum1>=sum2)
            {
                vector<int> v;
                for(int i=1; i<v1.size(); i++)
                {
                    v.pb(v1[i]-v1[i-1]);
                }
                v1 = v;
            }
            else
            {
                vector<int> v;
                for(int i=1; i<v2.size(); i++)
                {
                    v.pb(v2[i]-v2[i-1]);
                }
                v1 = v;
            }
        }

        cout << max(sum, v1[0]) << endl;
    }
}

Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb  push_back
#define mp  make_pair
#define INT_MAX                 INT64_MAX;
#define INT_MIN                 INT64_MIN;
#define IO_FAST                 ios_base::sync_with_stdio(false); cin.tie(NULL);
#define testcase                int t; cin >> t; while(t--)
#define inputvec(v1, n)         for(int i=0; i<n; i++) {int x; cin >> x; v1.pb(x);}
#define inputvecp(v1, n)        for(int i=0; i<n; i++) {int x, y; cin >> x >> y; v1.pb(mp(x,y));}
#define sort(v1)                sort(v1.begin(), v1.end())
#define reverse(v1)             reverse(v1.begin(), v1.end())
#define print(x)                cout << #x << endl;
#define deb(x)                  cout << #x << ' ' <<  '=' << ' ' << x << endl;
#define upperbound(v1, k)       upper_bound(v1.begin(), v1.end(), k)
#define lowerbound(v1, k)       lower_bound(v1.begin(), v1.end(), k)
#define tolower(s1)             transform(s1.begin(), s1.end(), s1.begin(), ::tolower)
#define toupper(s1)             transform(s1.begin(), s1.end(), s1.begin(), ::toupper)
#define auto1(v1)               for(auto &num1:v1) {cout << num1 << ' ';} cout << endl;
#define auto2(vp1)              for(auto &num1:vp1) {cout << num1.first << ' ' <<num1.second << endl;}
#define auto3(vv1)              for(auto &num1:vv1) {for(auto &num2:num1){cout << num2 <<' ';}cout<<endl;}
int gcd(int a,int b)            {if (b==0) return a; return gcd(b, a%b);} // take a=0;
int lcm(int a,int b)            {return a/gcd(a,b)*b;}  // take a = v[0];
const int N = 1e5+10;
const int mod = 1e9+7;
// freopen("in.txt", "r", stdin);
// freopen("out.txt", "w", stdout);
//======================================================================================================//
signed main()
{
    IO_FAST
    testcase
    {
        int n;
        cin >> n;

        vector<int> v1;
        inputvec(v1, n);

        int sum=0;
        for(auto &value : v1)
        {
            sum += value;
        }   

        while(v1.size()>1)
        {
            int sum1=0;
            for(int i=1; i<v1.size(); i++)
            {
                sum1 += v1[i]-v1[i-1];
            }

            vector<int> v2=v1;
            reverse(v2);
            
            int sum2=0;
            for(int i=1; i<v2.size(); i++)
            {
                sum2 += v2[i] - v2[i-1];
            }

            if(sum1>=sum2)
            {
                vector<int> v;
                for(int i=1; i<v1.size(); i++)
                {
                    v.pb(v1[i]-v1[i-1]);
                }
                v1 = v;
            }
            else
            {
                vector<int> v;
                for(int i=1; i<v2.size(); i++)
                {
                    v.pb(v2[i]-v2[i-1]);
                }
                v1 = v;
            }
        }

        cout << max(sum, v1[0]) << endl;
    }
}