ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2060D - Subtract Min Sort
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
#define db long double
#define fi first
#define se second
#define endl "\n"
#define all(v) v.begin(), v.end()
#define vi vector<int>
#define vb vector<bool>
#define vii vector<pair<int, int>>
#define vvi vector<vector<int>>
#define ii pair<int, int>
#define iii pair<int, pair<int, int>>
#define mii map<int, int>
#define mci map<char, int>
#define altgraph vector<set<int>>
#define pqueue priority_queue
const int max_n = 200005;
const int max_ai = 1000000;
const int mod = 998244353;
const int base = 193939;
const db pi = atan(1) * 4;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); //random
int bpowm(int b, int e){if(e == 0) return 1;int ans = bpowm(b, e / 2);if(e % 2 == 1) return (((ans * ans) % mod) * b) % mod;else return ((ans * ans) % mod);}
int bpow(int b, int e){if(e == 0) return 1;int ans = bpow(b, e / 2);if(e % 2 == 1) return (ans * ans * b);else return (ans * ans);}
int moddiv(int x, int y){return (x % mod) * ((bpowm(y, mod - 2))) % mod;}
int modmin(int a, int b){return (a + mod - b) % mod;}
bool prime[max_n];void primeseev(){prime[1]=true;for(int i=2;i<=sqrt(max_n);i++){if(prime[i])continue;for(int j=i*i;j<=max_n;j+=i){prime[j]=true;}}}
int factori[max_n];void factoree(){factori[0] = 1;for(int i = 1; i <= max_n; i++){factori[i] = (factori[i - 1] * i) % mod;}}
int combi(int n, int k){if(k > n){return 0;}return (((factori[n] * bpowm(factori[n - k], mod - 2)) % mod) * bpowm(factori[k], mod - 2)) % mod;}
 
// upperbound: > val
// lowerbound: >= val
// cout << (condition ? "YES" : "NO") << endl;
// cout.flush();
// sum perm: n(n + 1)/2

void solve()
{
    int n;
    cin >> n;

    vi a(n);
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
    }

    
    int p;
    //last editable element
    if(a[n - 2] <= a[n - 1])
    {
        p = n - 2;
        while(p >= 0 && a[p] <= a[p + 1])
        {
            p--;
        }
        if(p == -1)
        {
            cout << "YES" << endl;
            return;
        }
        // cout << p << " 1" << endl;
    }
    else
    {
        p = n - 2;
        // cout << p << " 2" << endl;
    }

    for(int i = 0; i < p; i++)
    {
        if(a[i] > a[i + 1])
        {
            cout << "NO" << endl;
            return;
        }
        a[i + 1] -= a[i];
        a[i] = 0;
    }

    // for(int i = 0; i < n; i++)
    // {
    //     cout << a[i] << " ";
    // }
    // cout << endl;
    
    cout << "YES" << endl;
}
 
signed main()
{
    clock_t tStart = clock();
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
    #ifndef ONLINE_JUDGE
    freopen("INPUT.INP", "r", stdin);
    freopen("OUTPUT.OUT", "w", stdout);
    #endif
 
    // primeseev();
    // factoree();
 
    int t = 1;
    cin >> t;
    while(t--) solve();
 
    fprintf(stderr,"\n>> Runtime: %.10fs\n",(double)(clock()-tStart)/CLOCKS_PER_SEC);
    return 0;
}
/*
pls don't hac me
am friendli
if you hac i eat yur balls
*/
Problem: 2052A - Adrenaline Rush
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 4):
#include <bits/stdc++.h>

using namespace std;

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

void solve() {
    int n;
    cin >> n;
    vector<int> arr(n);
    for (int i = 0; i < n; i++) {
        cin >> arr[i];
    }
    vector<pair<int, int>> ans;
    for (int i = 1; i <= n; i++) {
        for (int j = i + 1; j <= n; j++) {
            ans.push_back(make_pair(j, i));
        }
    }
    vector<int> p(n);
    map<int, int> mpp;
    for (int i = 0; i < n; i++) {
        p[i] = n - i;
        mpp[p[i]] = i;
    }
    for (int i = 0; i < n; i++) {
        for (int j = mpp[arr[i]]; j > i; j--) {
            ans.push_back(make_pair(p[j], p[j - 1]));
            swap(arr[j], arr[j - 1]);
            swap(mpp[arr[j]], mpp[arr[j - 1]]);
        }
    }
    cout << ans.size() << endl;
    for (auto [x, y] : ans) {
        cout << x << " " << y << endl;
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}

Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>

using namespace std;

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

void solve() {
    int n;
    cin >> n;
    vector<int> arr(n);
    for (int i = 0; i < n; i++) {
        cin >> arr[i];
    }
    vector<pair<int, int>> ans;
    for (int i = 1; i <= n; i++) {
        for (int j = i + 1; j <= n; j++) {
            ans.push_back(make_pair(j, i));
        }
    }
    vector<int> p(n);
    map<int, int> mpp;
    for (int i = 0; i < n; i++) {
        p[i] = n - i;
        mpp[p[i]] = i;
    }
    for (int i = 0; i < n; i++) {
        for (int j = mpp[arr[i]]; j > i; j--) {
            ans.push_back(make_pair(arr[j], arr[j - 1]));
            swap(arr[j], arr[j - 1]);
            swap(mpp[arr[j]], mpp[arr[j - 1]]);
        }
    }
    cout << ans.size() << endl;
    for (auto [x, y] : ans) {
        cout << x << " " << y << endl;
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 4):
#include <bits/stdc++.h>

using namespace std;

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

void solve() {
    int n;
    cin >> n;
    vector<int> arr(n);
    for (int i = 0; i < n; i++) {
        cin >> arr[i];
    }
    vector<pair<int, int>> ans;
    for (int i = 1; i <= n; i++) {
        for (int j = i + 1; j <= n; j++) {
            ans.push_back(make_pair(j, i));
        }
    }
    vector<int> p(n);
    map<int, int> mpp;
    for (int i = 0; i < n; i++) {
        p[i] = n - i;
        mpp[p[i]] = i;
    }
    for (int i = 0; i < n; i++) {
        for (int j = mpp[arr[i]]; j > i; j--) {
            ans.push_back(make_pair(p[j], p[j - 1]));
            swap(arr[j], arr[j - 1]);
            swap(mpp[arr[j]], mpp[arr[j - 1]]);
        }
    }
    cout << ans.size() << endl;
    for (auto [x, y] : ans) {
        cout << x << " " << y << endl;
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>

using namespace std;

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

void solve() {
    int n;
    cin >> n;
    vector<int> arr(n);
    for (int i = 0; i < n; i++) {
        cin >> arr[i];
    }
    vector<pair<int, int>> ans;
    for (int i = 1; i <= n; i++) {
        for (int j = i + 1; j <= n; j++) {
            ans.push_back(make_pair(j, i));
        }
    }
    vector<int> p(n);
    map<int, int> mpp;
    for (int i = 0; i < n; i++) {
        p[i] = n - i;
        mpp[p[i]] = i;
    }
    for (int i = 0; i < n; i++) {
        for (int j = mpp[arr[i]]; j > i; j--) {
            ans.push_back(make_pair(arr[j], arr[j - 1]));
            swap(arr[j], arr[j - 1]);
            swap(mpp[arr[j]], mpp[arr[j - 1]]);
        }
    }
    cout << ans.size() << endl;
    for (auto [x, y] : ans) {
        cout << x << " " << y << endl;
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}

Submission (verdict: Accepted):
#include <bits/stdc++.h>

using namespace std;

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

void solve() {
    int n;
    cin >> n;
    vector<int> arr(n);
    for (int i = 0; i < n; i++) {
        cin >> arr[i];
    }
    vector<pair<int, int>> ans;
    for (int i = 1; i <= n; i++) {
        for (int j = i + 1; j <= n; j++) {
            ans.push_back(make_pair(j, i));
        }
    }
    vector<int> p(n);
    map<int, int> mpp;
    for (int i = 0; i < n; i++) {
        p[i] = n - i;
        mpp[p[i]] = i;
    }
    for (int i = 0; i < n; i++) {
        for (int j = mpp[arr[i]]; j > i; j--) {
            ans.push_back(make_pair(p[j], p[j - 1]));
            swap(p[j], p[j - 1]);
            swap(mpp[p[j]], mpp[p[j - 1]]);
        }
    }
    cout << ans.size() << endl;
    for (auto [x, y] : ans) {
        cout << x << " " << y << endl;
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}
Problem: 2063C - Remove Exactly Two
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 2):
// Problem: C. Remove Exactly Two
// Contest: Codeforces - Codeforces Round 1000 (Div. 2)
// URL: https://codeforces.com/problemset/problem/2063/C
// Memory Limit: 256 MB
// Time Limit: 2000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

#include<bits/stdc++.h>

#define NoTLE ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ld long double
#define ll long long
#define F first
#define S second
#define pb push_back
#define all(x) x.begin(),x.end()
#define nl '\n'
#define YES cout << "YES"
#define NO cout << "NO"
#define fx(i) fixed<<setprecision(i)

using namespace std;

const int MOD = 1e9+7 ;
const int MOD2 = 998244353 ;
const ld eps = 1e-10;
const ld pi = acos(-1) ;

void noBrainer () 
{

}

void new_test( )
{

}


void solve()
{
	int n ; cin >> n ;
	map < int , vector < int > > tree ;
	vector < int > dig ( n + 1 ) ;
	int cur = 0 ;
	int ma = 0 ;
	for ( int i = 0 ; i < n - 1 ; i++ )
	{
		int a , b ; cin >> a >> b ;
		tree[a].pb(b) ;
		tree[b].pb(a) ;
		dig[a]++ ;
		dig[b]++ ;
		if ( ma < dig[a] )
		{
			ma = dig[a] ;
			cur = a ;
		}
		if ( ma < dig[b] )
		{
			ma = dig[b] ;
			cur = b ;
		}
	}
	int ans = ma - 1 ;
	for ( auto el : tree[cur] )
	{
		dig[el]-- ;
	}
	int mn = 0 ;
	for ( int i = 1 ; i <= n ; i++ )
	{
		if ( i != cur )
		mn = max ( mn , dig[i] ) ;
	}
	ans += mn ;
	cout << ans ;
}	

signed main()
{
    NoTLE
    //freopen( "input.txt" , "r" , stdin );
    //freopen( "output.txt" , "w" , stdout );
    int T = 1;
    cin >> T ;
    //int X = T;
    while( T-- )
    {
    	// int ctest = X-T ;
        //noBrainer() ;
        solve();
        cout << nl ;
    }
    return 0;
}
Problem: 2063C - Remove Exactly Two
Language: C# 10


Submission (verdict: Runtime error on test 2):
﻿new ProblemSolver().Solve();

class ProblemSolver
{
    private int n;
    private bool[] visited;
    private int[] inEdges, outEdges;
    private List<int>[] graph;

    public void Solve()
    {
        var testCases = Convert.ToInt32(Console.ReadLine().Trim());

        for (var i = 0; i < testCases; i++)
        {
            RunTestCase();
        }
    }

    void RunTestCase()
    {
        n = Convert.ToInt32(Console.ReadLine().Trim());

        graph = new List<int>[n];

        for (var i = 0; i < n; i++)
        {
            graph[i] = new List<int>();
        }

        for (var i = 0; i < n - 1; i++)
        {
            var row = Console.ReadLine()
                             .Trim()
                             .Split()
                             .Select(item => Convert.ToInt32(item))
                             .ToArray();

            var u = row[0] - 1;
            var v = row[1] - 1;

            graph[u].Add(v);
            graph[v].Add(u);
        }

        ExecuteRemoveOperation();
        ExecuteRemoveOperation();

        Console.WriteLine(CountConnectedComponents());
    }

    void ExecuteRemoveOperation()
    {
        inEdges = new int[n];
        outEdges = new int[n];
        visited = new bool[n];

        for (var i = 0; i < n; i++)
            if (!visited[i]) DFS(i);
       
        RemoveNodeWithMaxEdges();
    }

    void DFS(int node)
    {
        visited[node] = true;

        foreach (var child in graph[node])
        {
            if (!visited[child])
            {
                outEdges[node]++;
                inEdges[child]++;
                DFS(child);
            }
        }
    }

    void RemoveNodeWithMaxEdges()
    {
        var nodeToRemove = (-1, -1);

        for (int i = 0; i < n; i++)
        {
            if (inEdges[i] + outEdges[i] > nodeToRemove.Item1)
            {
                nodeToRemove = (inEdges[i] + outEdges[i], i);
            }
        }

        int node = nodeToRemove.Item2;

        for (int i = node; i < n - 1; i++)
        {
            graph[i] = graph[i + 1];
        }

        for (int i = 0; i < n; i++)
        {
            graph[i].Remove(node);
        }

        n--;
    }

    int CountConnectedComponents()
    {
        visited = visited.Select(item => false).ToArray();
        
        var components = 0;

        for (int i = 0; i < n; i++)
        {
            if (visited[i])
            {
                continue;
            }

            components++;
            DFS(i);
        }

        return components;
    }
}
Problem: 2060D - Subtract Min Sort
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;

#define For(a, b, c) for (int a = b; a <= c; a++)
#define Fod(a, b, c) for (int a = b; a >= c; a--)
#define ll long long
#define ft first
#define sc second
#define ii pair<ll, ll>
#define iii pair<int, ii>
#define pb push_back
#define mp(a, b, c) {For(i, b, c) cout << a[i] << endl}

int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        int n;
        cin >> n;
        int a[n];
        For(i, 0, n - 1) cin >> a[i];
        bool val = true;
        if (a[0] < a[1])
        {
            For(i, 1, n - 2)
            {
                a[i] -= a[i - 1];
                a[i - 1] = 0;
                if (a[i] < a[i - 1] + a[i + 1])
                    continue;
                else
                {
                    val = false;
                    break;
                }
            }
        }
        else
            val = false;
        if (val && a[n - 1] >= a[n - 2])
            cout << "YES" << endl;
        else
            cout << "NO" << endl;
    }
    return 0;
}
Problem: 2060D - Subtract Min Sort
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;

#define For(a, b, c) for (int a = b; a <= c; a++)
#define Fod(a, b, c) for (int a = b; a >= c; a--)
#define ll long long
#define ft first
#define sc second
#define ii pair<ll, ll>
#define iii pair<int, ii>
#define pb push_back
#define mp(a, b, c) {For(i, b, c) cout << a[i] << endl}

int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        int n;
        cin >> n;
        int a[n];
        For(i, 0, n - 1) cin >> a[i];
        bool val = true;
        if (a[0] < a[1])
        {
            For(i, 1, n - 2)
            {
                a[i] -= a[i - 1];
                a[i - 1] = 0;
                if (a[i] < a[i - 1] + a[i + 1])
                    continue;
                else
                {
                    val = false;
                    break;
                }
            }
        }
        else
            val = false;
        if (val && a[n - 1] >= a[n - 2])
            cout << "YES" << endl;
        else
            cout << "NO" << endl;
    }
    return 0;
}

Submission (verdict: Wrong answer on test 10):
#include <bits/stdc++.h>
using namespace std;

#define For(a, b, c) for (int a = b; a <= c; a++)
#define Fod(a, b, c) for (int a = b; a >= c; a--)
#define ll long long
#define ft first
#define sc second
#define ii pair<ll, ll>
#define iii pair<int, ii>
#define pb push_back
#define mp(a, b, c) {For(i, b, c) cout << a[i] << endl}

int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        int n;
        cin >> n;
        int a[n];
        For(i, 0, n - 1) cin >> a[i];
        bool val = true;
        if (a[0] < a[1])
        {
            For(i, 1, n - 2)
            {
                a[i] -= a[i - 1];
                a[i - 1] = 0;
                if (a[i] <= a[i - 1] + a[i + 1])
                    continue;
                else
                {
                    val = false;
                    break;
                }
            }
        }
        else
            val = false;
        if (val && a[n - 1] >= a[n - 2])
            cout << "YES" << endl;
        else
            cout << "NO" << endl;
    }
    return 0;
}
Problem: 2060D - Subtract Min Sort
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 10):
#include <bits/stdc++.h>
using namespace std;

#define For(a, b, c) for (int a = b; a <= c; a++)
#define Fod(a, b, c) for (int a = b; a >= c; a--)
#define ll long long
#define ft first
#define sc second
#define ii pair<ll, ll>
#define iii pair<int, ii>
#define pb push_back
#define mp(a, b, c) {For(i, b, c) cout << a[i] << endl}

int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        int n;
        cin >> n;
        int a[n];
        For(i, 0, n - 1) cin >> a[i];
        bool val = true;
        if (a[0] < a[1])
        {
            For(i, 1, n - 2)
            {
                a[i] -= a[i - 1];
                a[i - 1] = 0;
                if (a[i] <= a[i - 1] + a[i + 1])
                    continue;
                else
                {
                    val = false;
                    break;
                }
            }
        }
        else
            val = false;
        if (val && a[n - 1] >= a[n - 2])
            cout << "YES" << endl;
        else
            cout << "NO" << endl;
    }
    return 0;
}

Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;

#define For(a, b, c) for (int a = b; a <= c; a++)
#define Fod(a, b, c) for (int a = b; a >= c; a--)
#define ll long long
#define ft first
#define sc second
#define ii pair<ll, ll>
#define iii pair<int, ii>
#define pb push_back
#define mp(a, b, c) {For(i, b, c) cout << a[i] << endl}

int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        int n;
        cin >> n;
        int a[n];
        For(i, 0, n - 1) cin >> a[i];
        bool val = true;
        if (a[0] <= a[1])
        {
            For(i, 1, n - 2)
            {
                a[i] -= a[i - 1];
                a[i - 1] = 0;
                if (a[i] <= a[i - 1] + a[i + 1])
                    continue;
                else
                {
                    val = false;
                    break;
                }
            }
        }
        else
            val = false;
        if (val && a[n - 1] >= a[n - 2])
            cout << "YES" << endl;
        else
            cout << "NO" << endl;
    }
    return 0;
}
Problem: 2061D - Kevin and Numbers
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

void solve(){
    int n, m;
    cin >> n >> m;
    multiset<int> a;
    vi b(m);
    for(int i = 0; i < n; i++) {
        int x; cin >> x;
        a.insert(x);
    }
    for(int i = 0; i < m; i++) {
        cin >> b[i];
    }
    sort(b.begin(), b.end());
    
    int ib = 0;
    auto ia = a.begin();

    while(ia != a.end()) {
        
        if(*ia == b[ib]) {
            ia++;
            ib++;
        }
        else {
            int ea = *(ia++);
            if(ia == a.end()) {
                cout << "No\n";
                return;
            }
            int na = *ia;
            if(abs(na - ea) <= 1) {
                a.insert(na + ea);
                ia++;
                // a.erase(ea);
                // a.erase(na);
            }else {
                cout << "No\n";
                return;
            }
        }
    }

    cout << "Yes\n";
    return;
}

int main(){
    int tt = 1; 
    cin >> tt;
    while(tt--) {
        solve();    
    }
    return 0;
}


Submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

void solve(){
    int n, m;
    cin >> n >> m;
    multiset<int> a;
    vi b(m);
    for(int i = 0; i < n; i++) {
        int x; cin >> x;
        a.insert(x);
    }
    for(int i = 0; i < m; i++) {
        cin >> b[i];
    }
    sort(b.begin(), b.end());
    
    int ib = 0;
    auto ia = a.begin();

    while(ia != a.end()) {
        
        if(*ia == b[ib]) {
            ia++;
            ib++;
        }
        else {
            int ea = *(ia++);
            if(ia == a.end()) {
                cout << "No\n";
                return;
            }
            int na = *ia;
            if(abs(na - ea) <= 1) {
                a.insert(na + ea);
                ia++;
                // a.erase(ea);
                // a.erase(na);
            }else {
                cout << "No\n";
                return;
            }
        }
    }

    if(ib == m) {
        cout << "Yes\n";
    }
    else {
        cout << "No\n";
    }
    return;
}

int main(){
    int tt = 1; 
    cin >> tt;
    while(tt--) {
        solve();    
    }
    return 0;
}
// 500000000 500000000
// 1000000000 1000000000
Problem: 2061D - Kevin and Numbers
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

void solve(){
    int n, m;
    cin >> n >> m;
    multiset<int> a;
    vi b(m);
    for(int i = 0; i < n; i++) {
        int x; cin >> x;
        a.insert(x);
    }
    for(int i = 0; i < m; i++) {
        cin >> b[i];
    }
    sort(b.begin(), b.end());
    
    int ib = 0;
    auto ia = a.begin();

    while(ia != a.end()) {
        
        if(*ia == b[ib]) {
            ia++;
            ib++;
        }
        else {
            int ea = *(ia++);
            if(ia == a.end()) {
                cout << "No\n";
                return;
            }
            int na = *ia;
            if(abs(na - ea) <= 1) {
                a.insert(na + ea);
                ia++;
                // a.erase(ea);
                // a.erase(na);
            }else {
                cout << "No\n";
                return;
            }
        }
    }

    cout << "Yes\n";
    return;
}

int main(){
    int tt = 1; 
    cin >> tt;
    while(tt--) {
        solve();    
    }
    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
#define int long long
int32_t main() {
    int32_t tc;
    cin >> tc;
    while(tc--){
        int n;
        cin >> n;
        vector<int> a(n);
        for(int i = 0; i < n; i++) cin >> a[i];
        int ans = 0;
        for(int i = 0; i < n; i++) ans += a[i];
        while(a.size() > 2){
            reverse(a.begin(),a.end());
            for(int i = 0; i < n-1; i++) a[i] = a[i+1]-a[i];
            a.pop_back();
            ans = max(ans,a.back()-a[0]);
        }
        if(a.size() == 2) ans = max(ans,a[0]-a[1]);
        cout << ans << endl;
    }
}


Submission (verdict: Wrong answer on test 6):
#include <bits/stdc++.h>
using namespace std;
#define int long long
int32_t main() {
    int32_t tc;
    cin >> tc;
    while(tc--){
        int n;
        cin >> n;
        vector<int> a(n);
        for(int i = 0; i < n; i++) cin >> a[i];
        int ans = 0;
        for(int i = 0; i < n; i++) ans += a[i];
        while(a.size() > 2){
            reverse(a.begin(),a.end());
            for(int i = 0; i < n-1; i++) a[i] = a[i+1]-a[i];
            a.pop_back();
            ans = max(ans,a.back()-a[0]);
            ans = max(ans, a[0]-a.back());
        }
        if(a.size() == 2) {
            ans = max(ans,a[0]-a[1]);
            ans = max(ans,a[1]-a[0]);
        }
        cout << ans << endl;
    }
}