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 INF (int)1e18
#define f first
#define s second
#define eb emplace
#define pb push_back
#define endl '\n'
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define mod (int)998244353
#define p(v) for(auto x: v) cout << x << " "; cout << endl;
#define debug(x) cout << #x << ": " << x << endl;
#define input(a,n); for(int i = 0;i<n;i++) cin>>a[i];


int gcd(int a, int b) {
    if (b == 0) {
        return a;
    } else {
        return gcd(b, a % b);
    }
}

bool isPrime(int n) {
    if (n <= 1) return false;
    if (n <= 3) return true;
    if (n % 2 == 0 || n % 3 == 0) return false;
    for (int i = 5; i <= sqrt(n); i += 6) {
        if (n % i == 0 || n % (i + 2) == 0)
            return false;
    }
    return true;
}

vector<int> findDivisors(int n) {
    vector<int> divisors;
    for (int i = 1; i <= sqrt(n); ++i) {
        if (n % i == 0) {
            divisors.push_back(i);
            if (i != n / i) divisors.push_back(n / i);
        }
    }
    return divisors;
}

int binpow(int a, int b) {
    int res = 1;
    while (b > 0) {
        if (b & 1) {
            res = (res * a );
        }
        a = (a * a);
        b >>= 1;
    }
    return res;
}


void Solve() {
   int n;
   cin >> n;
   vector<int> v;
   int sum=0;
   for(int i=0;i<n;i++){
      int x;
      cin>>x;
      v.push_back(x);
      sum+=x;
   }

   while(n > 1) {
      int sumx = 0, sumy = 0;
      for(int i = 0; i < n; i++) {
         if(i % 2 == 0) {
            sumx += v[i];
            sumy -= v[i];
         } else { 
            sumx -= v[i];
            sumy += v[i];
         }
      }
      
      vector<int> v2(n - 1);
      if(sumy > sumx) {
        for(int i = 0; i < n - 1; i++) {
            v2[i] = v[i + 1] - v[i];
        }
      } else {
        for(int i = 0; i < n - 1; i++) {
           v2[i] = v[n - 2 - i] - v[n - 1 - i]; 
        }
      }
      v = v2;
      n--;
      sum=max(sum,max(sumy,sumx));
   }
   cout << sum << endl;
}

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int t;
    cin>>t;
    while(t--)
         Solve();
    return 0;
}


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define INF (int)1e18
#define f first
#define s second
#define eb emplace
#define pb push_back
#define endl '\n'
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define mod (int)998244353
#define p(v) for(auto x: v) cout << x << " "; cout << endl;
#define debug(x) cout << #x << ": " << x << endl;
#define input(a,n); for(int i = 0;i<n;i++) cin>>a[i];


int gcd(int a, int b) {
    if (b == 0) {
        return a;
    } else {
        return gcd(b, a % b);
    }
}

bool isPrime(int n) {
    if (n <= 1) return false;
    if (n <= 3) return true;
    if (n % 2 == 0 || n % 3 == 0) return false;
    for (int i = 5; i <= sqrt(n); i += 6) {
        if (n % i == 0 || n % (i + 2) == 0)
            return false;
    }
    return true;
}

vector<int> findDivisors(int n) {
    vector<int> divisors;
    for (int i = 1; i <= sqrt(n); ++i) {
        if (n % i == 0) {
            divisors.push_back(i);
            if (i != n / i) divisors.push_back(n / i);
        }
    }
    return divisors;
}

int binpow(int a, int b) {
    int res = 1;
    while (b > 0) {
        if (b & 1) {
            res = (res * a );
        }
        a = (a * a);
        b >>= 1;
    }
    return res;
}


void Solve() {
   int n;
   cin >> n;
   vector<int> v;
   int sum=0;
   for(int i=0;i<n;i++){
      int x;
      cin>>x;
      v.push_back(x);
      sum+=x;
   }

   while(n > 1) {
      int sumx = 0, sumy = 0,tsum=0;
      for(int i = 0; i < n; i++) {
        tsum+=v[i];
         if(i % 2 == 0) {
            sumx += v[i];
            sumy -= v[i];
         } else { 
            sumx -= v[i];
            sumy += v[i];
         }
      }
      
      vector<int> v2(n - 1);
      if(sumy > sumx) {
        for(int i = 0; i < n - 1; i++) {
            v2[i] = v[i + 1] - v[i];
        }
      } else {
        for(int i = 0; i < n - 1; i++) {
           v2[i] = v[n - 2 - i] - v[n - 1 - i]; 
        }
      }
      v = v2;
      n--;
      sum=max(sum,max(sumy,sumx));
      sum=max(sum,tsum);
   }
   cout << sum << endl;
}

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int t;
    cin>>t;
    while(t--)
         Solve();
    return 0;
}