ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> PII;
#define int long long
int read()
{
    int x = 0, f = 1;
    char ch = getchar();
    while (!isdigit(ch))
    {
        if (ch == '-')
            f = -1;
        ch = getchar();
    }
    while (isdigit(ch))
    {
        x = (x << 1) + (x << 3) + ch - '0';
        ch = getchar();
    }
    return x * f;
}

void solve()
{
    int n;
    int l, r;
    cin >> n >> l >> r;
    int len = r - l + 1;
    vector<int> a(n + 1);
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
    }
    int ans = 0;
    for (int i = l; i <= r; i++)
    {
        ans += a[i];
    }
    // [1 r]
    vector<int> b;
    for (int i = 1; i <= r; i++)
    {
        b.push_back(a[i]);
    }
    sort(b.begin(), b.end());
    int t1 = 0;
    for (int i = 0; i < len; i++)
    {
        t1 += b[i];
    }
    // [ l n ]
    vector<int> c;
    for (int i = l; i <= n; i++)
    {
        c.push_back(a[i]);
    }
    sort(c.begin(), c.end());
    int t2 = 0;
    for (int i = 0; i < len; i++)
    {
        t2 += c[i];
    }

    int t=min(t1,t2);
    if (ans>t)
    {
        cout<<t<<"\n";
    }
    else 
    {
        if (len==1)
        {
            int tt=2e9;
            for (int i=1;i<l;i++)
            {
                tt=min(tt,a[i]);
            }
            for (int i=r+1;i<=n;i++)
            {
                tt=min(tt,a[i]);
            }
           
           cout<<tt<<"\n";
        }
        else 
        {
            cout<<ans<<"\n";
        }
    }
}
signed main()
{
    std::cin.tie(nullptr)->sync_with_stdio(false);
    int t = 1;
    cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}


Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> PII;
#define int long long
int read()
{
    int x = 0, f = 1;
    char ch = getchar();
    while (!isdigit(ch))
    {
        if (ch == '-')
            f = -1;
        ch = getchar();
    }
    while (isdigit(ch))
    {
        x = (x << 1) + (x << 3) + ch - '0';
        ch = getchar();
    }
    return x * f;
}

void solve()
{
    int n;
    int l, r;
    cin >> n >> l >> r;
    int len = r - l + 1;
    vector<int> a(n + 1);
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
    }
    int ans = 0;
    for (int i = l; i <= r; i++)
    {
        ans += a[i];
    }
    // [1 r]
    vector<int> b;
    for (int i = 1; i <= r; i++)
    {
        b.push_back(a[i]);
    }
    sort(b.begin(), b.end());
    int t1 = 0;
    for (int i = 0; i < len; i++)
    {
        t1 += b[i];
    }
    // [ l n ]
    vector<int> c;
    for (int i = l; i <= n; i++)
    {
        c.push_back(a[i]);
    }
    sort(c.begin(), c.end());
    int t2 = 0;
    for (int i = 0; i < len; i++)
    {
        t2 += c[i];
    }
    int t = min(t1, t2);
    cout << t << "\n";
}
signed main()
{
    std::cin.tie(nullptr)->sync_with_stdio(false);
    int t = 1;
    cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> PII;
#define int long long 
int read()
{
    int x = 0, f = 1;
    char ch = getchar();
    while (!isdigit(ch))
    {
        if (ch == '-')
            f = -1;
        ch = getchar();
    }
    while (isdigit(ch))
    {
        x = (x << 1) + (x << 3) + ch - '0';
        ch = getchar();
    }
    return x * f;
}



void solve()
{
   int n;int l,r;cin>>n>>l>>r;
   int len=r-l+1;
   vector<int>a(n);
   for (int i=0;i<n;i++)
   {
    cin>>a[i];
   }
   sort(a.begin(),a.end());
   int ans=0;
   for (int i=0;i<len;i++)
   {
    ans+=a[i];
   }
   cout<<ans<<"\n";

}
signed main()
{
    std::cin.tie(nullptr)->sync_with_stdio(false);
    int t = 1;
     cin>>t;
    while (t--)
    {
        solve();
    }
    return 0;
}
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> PII;
#define int long long 
int read()
{
    int x = 0, f = 1;
    char ch = getchar();
    while (!isdigit(ch))
    {
        if (ch == '-')
            f = -1;
        ch = getchar();
    }
    while (isdigit(ch))
    {
        x = (x << 1) + (x << 3) + ch - '0';
        ch = getchar();
    }
    return x * f;
}



void solve()
{
   int n;int l,r;cin>>n>>l>>r;
   int len=r-l+1;
   vector<int>a(n);
   for (int i=0;i<n;i++)
   {
    cin>>a[i];
   }
   sort(a.begin(),a.end());
   int ans=0;
   for (int i=0;i<len;i++)
   {
    ans+=a[i];
   }
   cout<<ans<<"\n";

}
signed main()
{
    std::cin.tie(nullptr)->sync_with_stdio(false);
    int t = 1;
     cin>>t;
    while (t--)
    {
        solve();
    }
    return 0;
}


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> PII;
#define int long long
int read()
{
    int x = 0, f = 1;
    char ch = getchar();
    while (!isdigit(ch))
    {
        if (ch == '-')
            f = -1;
        ch = getchar();
    }
    while (isdigit(ch))
    {
        x = (x << 1) + (x << 3) + ch - '0';
        ch = getchar();
    }
    return x * f;
}

void solve()
{
    int n;
    int l, r;
    cin >> n >> l >> r;
    int len = r - l + 1;
    vector<int> a(n + 1);
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
    }
    int ans = 0;
    for (int i = l; i <= r; i++)
    {
        ans += a[i];
    }
    // [1 r]
    vector<int> b;
    for (int i = 1; i <= r; i++)
    {
        b.push_back(a[i]);
    }
    sort(b.begin(), b.end());
    int t1 = 0;
    for (int i = 0; i < len; i++)
    {
        t1 += b[i];
    }
    // [ l n ]
    vector<int> c;
    for (int i = l; i <= n; i++)
    {
        c.push_back(a[i]);
    }
    sort(c.begin(), c.end());
    int t2 = 0;
    for (int i = 0; i < len; i++)
    {
        t2 += c[i];
    }

    int t=min(t1,t2);
    if (ans>t)
    {
        cout<<t<<"\n";
    }
    else 
    {
        if (len==1)
        {
            int tt=2e9;
            for (int i=1;i<l;i++)
            {
                tt=min(tt,a[i]);
            }
            for (int i=r+1;i<=n;i++)
            {
                tt=min(tt,a[i]);
            }
           
           cout<<tt<<"\n";
        }
        else 
        {
            cout<<ans<<"\n";
        }
    }
}
signed main()
{
    std::cin.tie(nullptr)->sync_with_stdio(false);
    int t = 1;
    cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}
Problem: 2050E - Three Strings
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 16):
#include<iostream>
#include<cstring>
using namespace std;




void solve() {
    char* a = new char[1005];
    char* b = new char[1005];
    char* c = new char[1005];
    cin.getline(a, 1000, '\n');
    cin.getline(b, 1000, '\n');
    cin.getline(c, 1000, '\n');
    int** dp = new int*[strlen(a) + 1];
    for (int i = 0; i <= strlen(a);i++) {
        dp[i] = new int[strlen(b) + 1];
    }
    for (int i = 0; i <= strlen(a);i++) {
        for (int j = 0; j <= strlen(b);j++) {
            dp[i][j] = 1e7;
        }
    }
    dp[0][0] = 0;
    for (int i = 0; i <= strlen(a);i++) {
        for (int j = 0; j <= strlen(b);j++) {
            if (i == 0 && j == 0) {
                dp[i][j] = 0;
            }
            else {
                if (i == 0) {
                    dp[i][j] = min(dp[i][j], dp[i][j - 1] + (b[j - 1] != c[j - 1]));
                }
                else if (j == 0) {
                    dp[i][j] = min(dp[i][j], dp[i - 1][j] + (c[i - 1] != a[i - 1]));
                }
                else {
                    dp[i][j] = min(dp[i][j], min(dp[i - 1][j] + (c[i + j - 1] != a[i - 1]), dp[i][j - 1] + (c[i + j - 1] != b[j - 1])));
                }
            }
        }
    }
    cout << dp[strlen(a)][strlen(b)] << '\n';
    for (int i = 0; i <= strlen(a);i++) {
        delete[] dp[i];
        dp[i] = NULL;
    }
    delete[] dp;
    dp = NULL;
    delete[] a;
    a = NULL;
    delete[] b;
    b = NULL;
    delete[] c;
    c = NULL;
}
int main() {
    int te;
    cin >> te;
    cin.ignore();
    while (te--) {
        solve();
    }
}
Problem: 2050E - Three Strings
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 16):
#include<iostream>
#include<cstring>
using namespace std;




void solve() {
    char* a = new char[2005];
    char* b = new char[2005];
    char* c = new char[2005];
    cin.getline(a, 2000, '\n');
    cin.getline(b, 2000, '\n');
    cin.getline(c, 2000, '\n');
    int** dp = new int*[strlen(a) + 1];
    for (int i = 0; i <= strlen(a);i++) {
        dp[i] = new int[strlen(b) + 1];
    }
    for (int i = 0; i <= strlen(a);i++) {
        for (int j = 0; j <= strlen(b);j++) {
            dp[i][j] = 1e7;
        }
    }
    dp[0][0] = 0;
    for (int i = 0; i <= strlen(a);i++) {
        for (int j = 0; j <= strlen(b);j++) {
            if (i == 0 && j == 0) {
                dp[i][j] = 0;
            }
            else {
                if (i == 0) {
                    dp[i][j] = min(dp[i][j], dp[i][j - 1] + (b[j - 1] != c[j - 1]));
                }
                else if (j == 0) {
                    dp[i][j] = min(dp[i][j], dp[i - 1][j] + (c[i - 1] != a[i - 1]));
                }
                else {
                    dp[i][j] = min(dp[i][j], min(dp[i - 1][j] + (c[i + j - 1] != a[i - 1]), dp[i][j - 1] + (c[i + j - 1] != b[j - 1])));
                }
            }
        }
    }
    cout << dp[strlen(a)][strlen(b)] << '\n';
    for (int i = 0; i <= strlen(a);i++) {
        delete[] dp[i];
        dp[i] = NULL;
    }
    delete[] dp;
    dp = NULL;
    delete[] a;
    a = NULL;
    delete[] b;
    b = NULL;
    delete[] c;
    c = NULL;
}
int main() {
    int te;
    cin >> te;
    cin.ignore();
    while (te--) {
        solve();
    }
}

Submission (verdict: Accepted):
#include<iostream>
#include<cstring>
#include<vector>
using namespace std;




void solve() {
    string a, b, c;
    cin >> a >> b >> c;    
    int na = a.size();
    int nb = b.size();
    vector<vector<int>> dp(na + 1, vector<int>(nb + 1, na + nb + 1));
    for (int i = 0; i <= a.size();i++) {
        for (int j = 0; j <= b.size();j++) {
            dp[i][j] = 1e7;
        }
    }
    dp[0][0] = 0;
    for (int i = 0; i <= a.size();i++) {
        for (int j = 0; j <= b.size();j++) {
            if (i == 0 && j == 0) {
                dp[i][j] = 0;
            }
            else {
                if (i == 0) {
                    dp[i][j] = min(dp[i][j], dp[i][j - 1] + (b[j - 1] != c[j - 1]));
                }
                else if (j == 0) {
                    dp[i][j] = min(dp[i][j], dp[i - 1][j] + (c[i - 1] != a[i - 1]));
                }
                else {
                    dp[i][j] = min(dp[i][j], min(dp[i - 1][j] + (c[i + j - 1] != a[i - 1]), dp[i][j - 1] + (c[i + j - 1] != b[j - 1])));
                }
            }
        }
    }
    cout << dp[a.size()][b.size()] << '\n';
}
int main() {
    int te;
    cin >> te;
    while (te--) {
        solve();
    }
}
Problem: 2063C - Remove Exactly Two
Language: C# 10


Submission (verdict: Wrong answer on test 2):
using System;
using System.Collections.Generic;
using System.Linq;

namespace task2063c;

class Node
{
    readonly List<Node> _neighbours = new();

    //public int Count => _children.Count;
    public int Connections => _neighbours.Count;

    public void AddNeighbour(Node n) => _neighbours.Add(n);

    public void Cut() => _neighbours.ForEach(n => n.RemoveNeighbour(this));

    private void RemoveNeighbour(Node node) => _neighbours.Remove(node);
}

class Tree
{
    readonly Dictionary<int, Node> _nodes = new();
    readonly int _count;
    public int Parts { get; private set; }


    public Tree(int vertices)
    {
        _count = vertices;
        Parts = 1;
    }

    public void ReadFromInput()
    {
        for(var i=0; i<_count-1; ++i)
        {
            var str = Console.ReadLine();
            var numbers = str.Split(' ', StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
            if(numbers.Length != 2)
                throw new InvalidOperationException($"invalid format for node: {str}");

            var n1 = numbers[0];
            var n2 = numbers[1];

            if(!_nodes.TryGetValue(n1, out var node1))
                _nodes[n1] = node1 = new Node();

            if(!_nodes.TryGetValue(n2, out var node2))
                _nodes[n2] = node2 = new Node();

            node1.AddNeighbour(node2);
            node2.AddNeighbour(node1);
        }
    }

    void CutNode(KeyValuePair<int, Node> kv)
    {
        Parts += (kv.Value.Connections - 1);
        kv.Value.Cut();
        _nodes.Remove(kv.Key);
    }

    public void CutMax()
    {
        if(!_nodes.Any())
            return;

        var maxNodeKv = _nodes.Max(Comparer<KeyValuePair<int, Node>>.Create((kv1, kv2) => kv1.Value.Connections.CompareTo(kv2.Value.Connections)));
        CutNode(maxNodeKv);
    }
}

class Program
{
    public static void Main(string[] args)
    {
        var numTestsw = int.Parse(Console.ReadLine());
        var results = new List<int>();

        for(var i=0; i<numTestsw; ++i)
        {
            var tree = new Tree(int.Parse(Console.ReadLine()));
            tree.ReadFromInput();

            tree.CutMax();
            tree.CutMax();

            results.Add(tree.Parts);
        }

        foreach(var n in results)
            Console.WriteLine(n);
    }
}
Problem: 2050D - Digital string maximization
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);cerr.rdbuf(cout.rdbuf());
#define f(i,a,b) for (ll (i)=(a); (i)<(b); (i)++)
#define rf(i,a,b) for (ll (i)=(a); (i)>=(b); (i)--)
#define vll vector<ll>
#define vvll vector<vll>
#define in(n) ll n; cin>>n;
#define sin(s) string (s); cin>>(s);
#define vin(v,n) vll (v)(n); f(i,0,n)cin>>(v)[i];
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sort(v) sort(all(v));
#define rsort(v) sort(v) reverse(all(v));
#define pYES cout<<"YES\n";
#define pNO cout<<"NO\n";
const ll mod = 1000000007;

#ifndef ONLINE_JUDGE
#define debug(x) cerr << #x << " = "; _print(x); cerr << endl;
#else
#define debug(x)
#endif

template <typename T>
void _print(T x) { cerr << x; }
template <typename T, typename V>
void _print(pair<T, V> p) { cerr << "{"; _print(p.first); cerr << ", "; _print(p.second); cerr << "}"; }
template <typename T>
void _print(vector<T> v) { cerr << "[ "; for (T i : v) { _print(i); cerr << " "; } cerr << "]"; }
template <typename T>
void _print(set<T> s) { cerr << "{ "; for (T i : s) { _print(i); cerr << " "; } cerr << "}"; }
template <typename T, typename V>
void _print(map<T, V> m) { cerr << "{ "; for (auto i : m) { _print(i); cerr << " "; } cerr << "}"; }
/* *********************Template ends here************** */


void solve() {
    sin(s)
    ll n=s.length();
    // rf(k,n-1,1){
        rf(i,n-1,1){
            ll l=i-1;
            ll r=i;
            while(l>=0 && s[r]-s[l]>1){
                s[r]--;
                swap(s[l],s[r]);
                l--; r--;
            }
        }
    // }
    cout<<s<<endl;
}

int main() {
    fast;
    int t = 1;
    cin >> t;
    while(t--) solve();
}
Problem: 2061D - Kevin and Numbers
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Runtime error on test 1):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);cerr.rdbuf(cout.rdbuf());
#define f(i,a,b) for (ll (i)=(a); (i)<(b); (i)++)
#define rf(i,a,b) for (ll (i)=(a); (i)>=(b); (i)--)
#define vll vector<ll>
#define vvll vector<vll>
#define in(n) ll n; cin>>n;
#define sin(s) string (s); cin>>(s);
#define vin(v,n) vll (v)(n); f(i,0,n)cin>>(v)[i];
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sort(v) sort(all(v));
#define rsort(v) sort(v) reverse(all(v));
#define pYES cout<<"YES\n";
#define pNO cout<<"NO\n";
const ll mod = 1000000007;

#ifndef ONLINE_JUDGE
#define debug(x) cerr << #x << " = "; _print(x); cerr << endl;
#else
#define debug(x)
#endif

template <typename T>
void _print(T x) { cerr << x; }
template <typename T, typename V>
void _print(pair<T, V> p) { cerr << "{"; _print(p.first); cerr << ", "; _print(p.second); cerr << "}"; }
template <typename T>
void _print(vector<T> v) { cerr << "[ "; for (T i : v) { _print(i); cerr << " "; } cerr << "]"; }
template <typename T>
void _print(set<T> s) { cerr << "{ "; for (T i : s) { _print(i); cerr << " "; } cerr << "}"; }
template <typename T, typename V>
void _print(map<T, V> m) { cerr << "{ "; for (auto i : m) { _print(i); cerr << " "; } cerr << "}"; }
/* *********************Template ends here************** */


void solve() {
    in(n) in(m)
    vin(a,n)
    vin(b,m)
    multiset<ll> p(all(a)),q(all(b));
    ll diff=n-m;
    for(auto itt=q.begin();itt!=q.end(); itt++){
        auto it=p.find(*itt);
        if (it!=p.end()){
            p.erase(it);
            q.erase(itt);
        }else{
            if (diff==0 || *itt==1){
                pNO
                return;
            }else{
                ll x=*itt;
                q.erase(itt);
                ll xx=x/2, yy=x/2+x%2;
                if (xx!=0) q.insert(xx);
                if (yy!=0) q.insert(yy);
                if (q.size()>0) itt=q.begin();
                else break;
            }
        }
    }
    if (p.size()==0 && q.size()==0) pYES
    else pNO
}

int main() {
    fast;
    int t = 1;
    cin >> t;
    while(t--) solve();
}
Problem: 2063C - Remove Exactly Two
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
#define FastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pii pair<int,int>
#define ll long long int
#define SIZE 200005
#define all(v) v.begin(), v.end()
#define pb push_back
#define MOD 1000000007
#define INF 1000000007
using namespace std;

int n , ma[SIZE] , val[SIZE] , ans;
vector<int> g[SIZE] , child[SIZE];

void init() {
    ans=0;
    for (int i = 1; i <= n; i++) {
        g[i].clear();
        child[i].clear();
        ma[i] = 0;
    }
}

void dfs(int here ,int pa) {
    val[here] = 1;
    for (auto t : g[here]) {
        if (t == pa) continue;
        val[here]++;
        child[here].pb(t);
        dfs(t , here);
    }
}

void solve(int here) {
    for (auto t : child[here]) solve(t);
    vector<int> tmp;
    for (auto t : child[here]) tmp.pb(ma[t]);
    sort(all(tmp));
    reverse(all(tmp));
    if (tmp.size() >= 2) ans = max(ans , tmp[0]+tmp[1]-1);
    for (auto t : child[here]) {
        if (child[t].size() > 0) ans = max(ans , ma[t]+val[here]-1-(here==1));
    }
    ma[here] = max(val[here] , (tmp.size() > 0 ? tmp[0] : -1));
}

void solve() {
    cin >> n;
    for (int i = 1; i <= n-1; i++) {
        int u , v; cin >> u >> v;
        g[u].pb(v); g[v].pb(u);
    }

    if (n == 2) {
        cout << "0\n";
        return;
    }

    dfs(1 , -1);
    val[1]--;
    //for (int i = 1; i <= n; i++) printf("%d " , val[i]);
    //printf("\n");
    solve(1);

    cout << ans << "\n";
}

int main() {
    FastIO;

    int t; cin >> t;
    while(t--) {
        init();
        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 fir first
#define sec second
#define endl "\n"   

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
const int N = 1e5, M = N * 2, mod = 1e9 + 7, inf = 0x3f3f3f3f, P = 131;

void solve()
{
    int n;
    cin >> n;
    vector<int>a(n + 1);
    int ans = 0;
    for(int i = 1;i <= n;i ++){
        cin >> a[i];
        ans += a[i];
    }
    if(n == 1){
        cout << a[1] << endl;
        return;
    }
    // int ans = -inf;
    for(int i = n - 1;i >= 1;i --){
        int sum = 0;
        for(int j = 1; j <= i ;j ++){
            a[j] = a[j + 1] - a[j];
            sum += a[j];
        }
        ans = max(ans,abs(sum));
    }
    cout << ans << endl;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int t = 1;
    cin >> t;
    while(t --)
        solve();

    return 0;
}

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

#define fir first
#define sec second
#define endl "\n"   

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
const int N = 1e5, M = N * 2, mod = 1e9 + 7, inf = 0x3f3f3f3f, P = 131;

void solve()
{
    int n;
    cin >> n;
    vector<int>a(n + 1);
    ll ans = 0;
    for(int i = 1;i <= n;i ++){
        cin >> a[i];
        ans += a[i];
    }
    if(n == 1){
        cout << a[1] << endl;
        return;
    }
    // int ans = -inf;
    for(int i = n - 1;i >= 1;i --){
        ll sum = 0;
        for(int j = 1; j <= i ;j ++){
            a[j] = a[j + 1] - a[j];
        }
        for(int j = 1;j <= i;j ++)
            sum += a[j];
        ans = max(ans,abs(sum));
    }
    cout << ans << endl;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int t = 1;
    cin >> t;
    while(t --)
        solve();

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


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

#define fir first
#define sec second
#define endl "\n"   

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
const int N = 1e5, M = N * 2, mod = 1e9 + 7, inf = 0x3f3f3f3f, P = 131;

void solve()
{
    int n;
    cin >> n;
    vector<int>a(n + 1);
    int ans = 0;
    for(int i = 1;i <= n;i ++){
        cin >> a[i];
        ans += a[i];
    }
    if(n == 1){
        cout << a[1] << endl;
        return;
    }
    // int ans = -inf;
    for(int i = n - 1;i >= 1;i --){
        int sum = 0;
        for(int j = 1; j <= i ;j ++){
            a[j] = a[j + 1] - a[j];
            sum += a[j];
        }
        ans = max(ans,abs(sum));
    }
    cout << ans << endl;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int t = 1;
    cin >> t;
    while(t --)
        solve();

    return 0;
}