ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 3):
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        long long n;
        cin>>n;
        long long temp = n;
        int two = 0, three = 0;
        long long sum = 0;
        while(temp>0)
        {
            int r = temp%10;
            sum += r;
            if(r==2) two++;
            if(r==3) three++;
            temp /= 10;
        }
        if(sum%9==0)
        {
            cout<<"YES"<<endl;
            continue;
        }
        bool flag = true;
        for(int i = 1; i<=min(8, two); i++)
        {
            if((sum+i*2)%9==0)
                {
                    cout<<"YES"<<endl;
                    flag = false;
                    break;
                }
        }
        if(flag==false)
        continue;
        for(int i = 1; i<=min(8, three); i++)
        {
            if((sum+i*6)%9==0)
                {
                    cout<<"YES"<<endl;
                    flag = false;
                    break;
                }
        }
        if(flag==false)
        continue;
        for(int i = 1; i<=min(8, two); i++)
        {
            for(int j = 1; j<=min(8, three); j++)
            {
                if((sum+i*2+j*6)%9==0)
                {
                    cout<<"YES"<<endl;
                    flag = false;
                    break;
                }
            }
        }
        if(flag==true)
        cout<<"NO"<<endl;
    }
    return 0;
}

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

int main() {
    int t;
    cin >> t;
    while (t--) {
        long long n;
        cin >> n;
        long long temp = n;
        int two = 0, three = 0;
        long long sum = 0;

        // Calculate digit sum and count of 2s and 3s
        while (temp > 0) {
            int r = temp % 10;
            sum += r;
            if (r == 2) two++;
            if (r == 3) three++;
            temp /= 10;
        }

        // Check if the current sum is already divisible by 9
        if (sum % 9 == 0) {
            cout << "YES" << endl;
            continue;
        }

        bool possible = false;

        // Iterate over possible combinations of transformations
        for (int x = 0; x <= min(8, two); x++) {
            for (int y = 0; y <= min(8, three); y++) {
                if ((sum + x * 2 + y * 6) % 9 == 0) {
                    possible = true;
                    break;
                }
            }
            if (possible) break; // Exit outer loop early
        }

        // Output result based on findings
        cout << (possible ? "YES" : "NO") << endl;
    }
    return 0;
}
Problem: 2063B - Subsequence Update
Language: PyPy 3-64

Previous submission (verdict: Wrong answer on test 5):
for _ in range(int(input())):

    n,l,r=map(int,input().split())

    l-=1

    r-=1

    a=list(map(int,input().split()))

    sub,subleft,subright,t,res=sorted(a[l:r+1],reverse=True),sorted(a[:l]),sorted(a[r+1:]),sum(a[l:r+1]),9999999

    if l>0:

        change=0

        for i in range(r-l+1):

            if i<len(subleft):

                if subleft[i]<sub[i]:

                    change+=subleft[i]-sub[i]

        res=min(res,t+change)

    if r<n:

        change=0

        for i in range(r-l+1):

            if i<len(subright):

                if subright[i]<sub[i]:

                    change+=subright[i]-sub[i]

        res=min(res,t+change)

    print(res)

Submission (verdict: Wrong answer on test 1):
for _ in range(int(input())):
    n,l,r=map(int,input().split())
    l-=1
    r-=1
    a=list(map(int,input().split()))
    if l==0 and r==n-1:
        print(a[l:r+1])
        continue
    sub,subleft,subright,t,res=sorted(a[l:r+1],reverse=True),sorted(a[:l]),sorted(a[r+1:]),sum(a[l:r+1]),9999999
    if l>0:
        change=0
        for i in range(r-l+1):
            if i<len(subleft):
                if subleft[i]<sub[i]:
                    change+=subleft[i]-sub[i]
            else:
                break
        res=min(res,t+change)
    if r<n:
        change=0
        for i in range(r-l+1):
            if i<len(subright):
                if subright[i]<sub[i]:
                    change+=subright[i]-sub[i]
            else:
                break
        res=min(res,t+change)
    print(res)
Problem: 2063B - Subsequence Update
Language: PyPy 3-64

Previous submission (verdict: Wrong answer on test 2):
for _ in range(int(input())):

    n,l,r=map(int,input().split())

    l-=1

    r-=1

    a=list(map(int,input().split()))

    if l==0 and r==n-1:

        print(sum(a[l:r+1]))

        continue

    if l==r:

        print(min(a))

        continue

    sub,subleft,subright,t,res=sorted(a[l:r+1],reverse=True),sorted(a[:l]),sorted(a[r+1:]),sum(a[l:r+1]),9999999

    combined=[]

    for i in subleft:

        combined.append(i)

    for i in subright:

        combined.append(i)

    combined.sort()

    change=0

    for i in range(r-l+1):

        if i<len(combined):

            if combined[i]<sub[i]:

                change+=combined[i]-sub[i]

        else:

            break

    res=min(res,t+change)

    print(res)

    

Submission (verdict: Accepted):
for _ in range(int(input())):
    n,l,r=map(int,input().split())
    l-=1
    r-=1
    a=list(map(int,input().split()))
    if l==0 and r==n-1:
        print(sum(a[l:r+1]))
        continue
    if l==r:
        print(min(a))
        continue
    sub,subleft,subright,t,res=sorted(a[l:r+1],reverse=True),sorted(a[:l]),sorted(a[r+1:]),sum(a[l:r+1]),float('inf')
    if l>0:
        change=0
        for i in range(r-l+1):
            if i<len(subleft):
                if subleft[i]<sub[i]:
                    change+=subleft[i]-sub[i]
            else:
                break
        res=min(res,t+change)
    if r<n:
        change=0
        for i in range(r-l+1):
            if i<len(subright):
                if subright[i]<sub[i]:
                    change+=subright[i]-sub[i]
            else:
                break
        res=min(res,t+change)
    print(res)
Problem: 2063B - Subsequence Update
Language: PyPy 3-64

Previous submission (verdict: Wrong answer on test 1):
for _ in range(int(input())):
    n,l,r=map(int,input().split())
    l-=1
    r-=1
    a=list(map(int,input().split()))
    if l==0 and r==n-1:
        print(a[l:r+1])
        continue
    sub,subleft,subright,t,res=sorted(a[l:r+1],reverse=True),sorted(a[:l]),sorted(a[r+1:]),sum(a[l:r+1]),9999999
    if l>0:
        change=0
        for i in range(r-l+1):
            if i<len(subleft):
                if subleft[i]<sub[i]:
                    change+=subleft[i]-sub[i]
            else:
                break
        res=min(res,t+change)
    if r<n:
        change=0
        for i in range(r-l+1):
            if i<len(subright):
                if subright[i]<sub[i]:
                    change+=subright[i]-sub[i]
            else:
                break
        res=min(res,t+change)
    print(res)

Submission (verdict: Wrong answer on test 5):
for _ in range(int(input())):

    n,l,r=map(int,input().split())

    l-=1

    r-=1

    a=list(map(int,input().split()))

    if l==0 and r==n-1:

        print(sum(a[l:r+1]))

        continue

    sub,subleft,subright,t,res=sorted(a[l:r+1],reverse=True),sorted(a[:l]),sorted(a[r+1:]),sum(a[l:r+1]),9999999

    if l>0:

        change=0

        for i in range(r-l+1):

            if i<len(subleft):

                if subleft[i]<sub[i]:

                    change+=subleft[i]-sub[i]

            else:

                break

        res=min(res,t+change)

    if r<n:

        change=0

        for i in range(r-l+1):

            if i<len(subright):

                if subright[i]<sub[i]:

                    change+=subright[i]-sub[i]

            else:

                break

        res=min(res,t+change)

    print(res)
Problem: 2063B - Subsequence Update
Language: PyPy 3-64

Previous submission (verdict: Wrong answer on test 5):
for _ in range(int(input())):

    n,l,r=map(int,input().split())

    l-=1

    r-=1

    a=list(map(int,input().split()))

    if l==0 and r==n-1:

        print(sum(a[l:r+1]))

        continue

    sub,subleft,subright,t,res=sorted(a[l:r+1],reverse=True),sorted(a[:l]),sorted(a[r+1:]),sum(a[l:r+1]),9999999

    if l>0:

        change=0

        for i in range(r-l+1):

            if i<len(subleft):

                if subleft[i]<sub[i]:

                    change+=subleft[i]-sub[i]

            else:

                break

        res=min(res,t+change)

    if r<n:

        change=0

        for i in range(r-l+1):

            if i<len(subright):

                if subright[i]<sub[i]:

                    change+=subright[i]-sub[i]

            else:

                break

        res=min(res,t+change)

    print(res)

Submission (verdict: Wrong answer on test 2):
for _ in range(int(input())):

    n,l,r=map(int,input().split())

    l-=1

    r-=1

    a=list(map(int,input().split()))

    if l==0 and r==n-1:

        print(sum(a[l:r+1]))

        continue

    if l==r:

        print(min(a))

        continue

    sub,subleft,subright,t,res=sorted(a[l:r+1],reverse=True),sorted(a[:l]),sorted(a[r+1:]),sum(a[l:r+1]),9999999

    combined=[]

    for i in subleft:

        combined.append(i)

    for i in subright:

        combined.append(i)

    combined.sort()

    change=0

    for i in range(r-l+1):

        if i<len(combined):

            if combined[i]<sub[i]:

                change+=combined[i]-sub[i]

        else:

            break

    res=min(res,t+change)

    print(res)
Problem: 2063B - Subsequence Update
Language: PyPy 3-64


Submission (verdict: Wrong answer on test 5):
for _ in range(int(input())):

    n,l,r=map(int,input().split())

    l-=1

    r-=1

    a=list(map(int,input().split()))

    sub,subleft,subright,t,res=sorted(a[l:r+1],reverse=True),sorted(a[:l]),sorted(a[r+1:]),sum(a[l:r+1]),9999999

    if l>0:

        change=0

        for i in range(r-l+1):

            if i<len(subleft):

                if subleft[i]<sub[i]:

                    change+=subleft[i]-sub[i]

        res=min(res,t+change)

    if r<n:

        change=0

        for i in range(r-l+1):

            if i<len(subright):

                if subright[i]<sub[i]:

                    change+=subright[i]-sub[i]

        res=min(res,t+change)

    print(res)
Problem: 2061D - Kevin and Numbers
Language: C++17 (GCC 7-32)

Previous submission (verdict: Time limit exceeded on test 28):
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>

using namespace std;
typedef vector<int> vi;

bool helper(int x, unordered_map<int, int> &bank)
{
    if (bank[x] > 0)
    {
        bank[x]--;
        return true;
    }
    if (x == 1)
        return false;
    if (x % 2)
    {
        int sx = x / 2, sy = x - sx;
        return helper(sx, bank) && helper(sy, bank);
    }
    else
        return helper(x / 2, bank) && helper(x / 2, bank);
}

void solve(int n, int m, vi &a, vi &b)
{
    unordered_map<int, int> mp;
    for (int e : a)
        mp[e]++;

    for (int e : b)
    {
        if (!helper(e, mp))
        {
            // cout << e << " can't be made\n";
            cout << "NO\n";
            return;
        }
    }

    int loc = 0;
    for (auto [k, v] : mp)
        loc += v;
    if (!loc)
        cout << "YES\n";
    else
        cout << "NO\n";
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    cin >> t;
    while (t--)
    {
        int n, m;
        cin >> n >> m;
        vi a(n), b(m);
        for (int i = 0; i < n; i++)
            cin >> a[i];
        for (int i = 0; i < m; i++)
            cin >> b[i];
        solve(n, m, a, b);
    }
}

Submission (verdict: Time limit exceeded on test 28):
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>

using namespace std;
typedef vector<int> vi;

bool helper(int x, unordered_map<int, int> &bank, int &eu)
{
    if (bank[x] > 0)
    {
        bank[x]--;
        eu++;
        return true;
    }
    if (x == 1)
        return false;
    if (x % 2)
    {
        int sx = x / 2, sy = x - sx;
        return helper(sx, bank, eu) && helper(sy, bank, eu);
    }
    else
        return helper(x / 2, bank, eu) && helper(x / 2, bank, eu);
}

void solve(int n, int m, vi &a, vi &b)
{
    unordered_map<int, int> mp;
    for (int e : a)
        mp[e]++;

    for (int e : b)
    {
        if (n < m)
        {
            cout << "NO\n";
            return;
        }
        int eu = 0;
        if (!helper(e, mp, eu))
        {
            cout << "NO\n";
            return;
        }
        n -= eu - 1;
    }

    int loc = 0;
    for (auto [k, v] : mp)
        loc += v;
    if (!loc)
        cout << "YES\n";
    else
        cout << "NO\n";
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    cin >> t;
    while (t--)
    {
        int n, m;
        cin >> n >> m;
        vi a(n), b(m);
        for (int i = 0; i < n; i++)
            cin >> a[i];
        for (int i = 0; i < m; i++)
            cin >> b[i];
        solve(n, m, a, b);
    }
}
Problem: 2061D - Kevin and Numbers
Language: C++17 (GCC 7-32)


Submission (verdict: Time limit exceeded on test 28):
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>

using namespace std;
typedef vector<int> vi;

bool helper(int x, unordered_map<int, int> &bank)
{
    if (bank[x] > 0)
    {
        bank[x]--;
        return true;
    }
    if (x == 1)
        return false;
    if (x % 2)
    {
        int sx = x / 2, sy = x - sx;
        return helper(sx, bank) && helper(sy, bank);
    }
    else
        return helper(x / 2, bank) && helper(x / 2, bank);
}

void solve(int n, int m, vi &a, vi &b)
{
    unordered_map<int, int> mp;
    for (int e : a)
        mp[e]++;

    for (int e : b)
    {
        if (!helper(e, mp))
        {
            // cout << e << " can't be made\n";
            cout << "NO\n";
            return;
        }
    }

    int loc = 0;
    for (auto [k, v] : mp)
        loc += v;
    if (!loc)
        cout << "YES\n";
    else
        cout << "NO\n";
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    cin >> t;
    while (t--)
    {
        int n, m;
        cin >> n >> m;
        vi a(n), b(m);
        for (int i = 0; i < n; i++)
            cin >> a[i];
        for (int i = 0; i < m; i++)
            cin >> b[i];
        solve(n, m, a, b);
    }
}
Problem: 2061D - Kevin and Numbers
Language: C++17 (GCC 7-32)

Previous submission (verdict: Time limit exceeded on test 28):
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>

using namespace std;
typedef vector<int> vi;

bool helper(int x, unordered_map<int, int> &bank, int &n, int &m)
{
    if (bank[x] > 0)
    {
        bank[x]--;
        if (--n + 1 < m)
            return false;
        return true;
    }
    if (x == 1)
        return false;
    if (x % 2)
    {
        int sx = x / 2, sy = x - sx;
        return helper(sx, bank, n, m) && helper(sy, bank, n, m);
    }
    else
        return helper(x / 2, bank, n, m) && helper(x / 2, bank, n, m);
}

void solve(int n, int m, vi &a, vi &b)
{
    unordered_map<int, int> mp;
    for (int e : a)
        mp[e]++;

    for (int e : b)
    {
        if (!helper(e, mp, n, m))
        {
            cout << "NO\n";
            return;
        }
        m--;
    }

    if (!n)
        cout << "YES\n";
    else
        cout << "NO\n";
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    cin >> t;
    while (t--)
    {
        int n, m;
        cin >> n >> m;
        vi a(n), b(m);
        for (int i = 0; i < n; i++)
            cin >> a[i];
        for (int i = 0; i < m; i++)
            cin >> b[i];
        solve(n, m, a, b);
    }
}

Submission (verdict: Accepted):
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;
typedef vector<int> vi;

bool helper(int x, map<int, int> &bank, int &n, int &m)
{
    if (x < bank.begin()->first)
        return false;
    if (bank[x] > 0)
    {
        if (--bank[x] == 0)
            bank.erase(x);
        if (--n + 1 < m)
            return false;
        return true;
    }
    if (x == 1)
        return false;
    if (x % 2)
    {
        int sx = x / 2, sy = x - sx;
        return helper(sx, bank, n, m) && helper(sy, bank, n, m);
    }
    else
        return helper(x / 2, bank, n, m) && helper(x / 2, bank, n, m);
}

void solve(int n, int m, vi &a, vi &b)
{
    map<int, int> mp;
    for (int e : a)
        mp[e]++;

    for (int e : b)
    {
        if (!helper(e, mp, n, m))
        {
            cout << "NO\n";
            return;
        }
        m--;
    }

    if (!n)
        cout << "YES\n";
    else
        cout << "NO\n";
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    cin >> t;
    while (t--)
    {
        int n, m;
        cin >> n >> m;
        vi a(n), b(m);
        for (int i = 0; i < n; i++)
            cin >> a[i];
        for (int i = 0; i < m; i++)
            cin >> b[i];
        solve(n, m, a, b);
    }
}
Problem: 2061D - Kevin and Numbers
Language: C++17 (GCC 7-32)

Previous submission (verdict: Time limit exceeded on test 28):
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>

using namespace std;
typedef vector<int> vi;

bool helper(int x, unordered_map<int, int> &bank, int &eu)
{
    if (bank[x] > 0)
    {
        bank[x]--;
        eu++;
        return true;
    }
    if (x == 1)
        return false;
    if (x % 2)
    {
        int sx = x / 2, sy = x - sx;
        return helper(sx, bank, eu) && helper(sy, bank, eu);
    }
    else
        return helper(x / 2, bank, eu) && helper(x / 2, bank, eu);
}

void solve(int n, int m, vi &a, vi &b)
{
    unordered_map<int, int> mp;
    for (int e : a)
        mp[e]++;

    for (int e : b)
    {
        if (n < m)
        {
            cout << "NO\n";
            return;
        }
        int eu = 0;
        if (!helper(e, mp, eu))
        {
            cout << "NO\n";
            return;
        }
        n -= eu - 1;
    }

    int loc = 0;
    for (auto [k, v] : mp)
        loc += v;
    if (!loc)
        cout << "YES\n";
    else
        cout << "NO\n";
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    cin >> t;
    while (t--)
    {
        int n, m;
        cin >> n >> m;
        vi a(n), b(m);
        for (int i = 0; i < n; i++)
            cin >> a[i];
        for (int i = 0; i < m; i++)
            cin >> b[i];
        solve(n, m, a, b);
    }
}

Submission (verdict: Time limit exceeded on test 28):
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>

using namespace std;
typedef vector<int> vi;

bool helper(int x, unordered_map<int, int> &bank, int &n, int &m)
{
    if (bank[x] > 0)
    {
        bank[x]--;
        if (--n + 1 < m)
            return false;
        return true;
    }
    if (x == 1)
        return false;
    if (x % 2)
    {
        int sx = x / 2, sy = x - sx;
        return helper(sx, bank, n, m) && helper(sy, bank, n, m);
    }
    else
        return helper(x / 2, bank, n, m) && helper(x / 2, bank, n, m);
}

void solve(int n, int m, vi &a, vi &b)
{
    unordered_map<int, int> mp;
    for (int e : a)
        mp[e]++;

    for (int e : b)
    {
        if (!helper(e, mp, n, m))
        {
            cout << "NO\n";
            return;
        }
        m--;
    }

    if (!n)
        cout << "YES\n";
    else
        cout << "NO\n";
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    cin >> t;
    while (t--)
    {
        int n, m;
        cin >> n >> m;
        vi a(n), b(m);
        for (int i = 0; i < n; i++)
            cin >> a[i];
        for (int i = 0; i < m; i++)
            cin >> b[i];
        solve(n, m, a, b);
    }
}
Problem: 2052A - Adrenaline Rush
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)

#define rep(i,a,b) for(ll i=(a); i<(b); ++i)
#define repc(i,a,b,c) for(ll i=(a); i<(b); i+=c)
#define repn(i,a,b) for(ll i=(a); i>(b); --i)
#define trav(a,x) for(auto& a: x)
#define travm(a,x) for(const auto& [a, v]: x)
#define all(x) begin(x),end(x)
#define sz(x) (int)size(x)
#define tmod(a) ((a%MOD)+MOD)%MOD
#define tmod2(a) ((a%MOD2)+MOD2)%MOD2
#define tmodc(a,b) ((a%b)+b)%b
#define madd(a,b) (tmod(a)+tmod(b))%MOD
#define madd2(a,b) (tmod2(a)+tmod2(b))%MOD2
#define maddc(a,b,c) (tmodc(a,c)+tmodc(b,c))%c
#define pb push_back
#define mp make_pair
#define cauto const auto
using ll = long long;
int iINF = numeric_limits<int>::max();
int MOD = 1e9+7;
int MOD2 = 1e9+22;
#define int ll
using ld = long double;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vd = vector<double>;
using vll = vector<ll>;
using vpii = vector<pii>;

ll lINF = numeric_limits<ll>::max();
ll negINF = lINF+1;
double EPS = .00001;
cauto maxn = 200001;

/*
4 3
4 2
4 1
3 2
3 1
2 1

1 2
1 3
1 4
2 3
2 4
3 4
*/
void solve()
{
  int n;
  cin >> n;
  vi a(n+1);
  rep(i,1,n+1) cin >> a[i];
  vpii groups;
  int st = a[1];
  int sz = 1;
  rep(i,2,n+1)
  {
    if(a[i]==st+sz) sz++;
    else groups.pb({st,sz}), st = a[i], sz = 1;
  }
  groups.pb({st,sz});
  vpii moves;
  rep(i,1,n+1)
  {
    int in = 1;
    while(a[in]!=i) in++;
    while(in!=i) moves.pb({i,a[in-1]}), swap(a[in],a[in-1]), in--;
  }
  trav(group,groups)
  {
    if(group.second==1) continue;
    repn(i,group.first+group.second-1,group.first) repn(j,i-1,group.first-1) moves.pb({i,j});
    rep(i,group.first,group.first+group.second-1) rep(j,i+1,group.first+group.second) moves.pb({i,j});
  }
  cout << sz(moves) << "\n";
  trav(move,moves) cout << move.first << " " << move.second << "\n";
}
void pre()
{
  
}
int32_t main() 
{
  ios::sync_with_stdio(false);
  pre();
  int t=1; //cin >> t;
  while(t--) solve();
}
/*
When flooring double that has been divided, add .00000000001
Careful mixing subtracting and mod!
*/
Problem: 2062C - Cirno and Operations
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Time limit exceeded on test 2):
#include <bits/stdc++.h>
using namespace std;
#define int long long
int ans = -50001;
int solve(vector<int> arr, int count, int size){
    int temp = 0;
    for (int i = 0; i < size; i++){
        temp += arr[i];
    }
    ans = max(temp, ans);
    if (size == 1){
        return temp;
    }
    vector <int> arr1(size - 1);
    vector <int> arr2(size - 1);
    for (int i = 0; i < size - 1; i++){
        arr1[i] = arr[i + 1] - arr[i];
    }
    for (int i = size - 1; i > 0; i--){
        arr2[size - 1 - i] = arr[i - 1] - arr[i];
    }
    return max(solve(arr1, temp, arr1.size()), solve(arr2, temp, arr2.size()));
}
int32_t main(){
    int t;
    cin >> t;
    while(t--){
        int n;
        cin >> n;
        vector<int> a(n);
        for (int i = 0; i < n; i++){
            cin >> a[i];
        }
        ans = max(ans, solve(a, 0, a.size()));
        cout << ans << endl;
    }
}

Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;
#define int long long
int32_t main(){
    int t;
    cin >> t;
    while(t--){
        int n;
        cin >> n;
        vector<int> a(n);
        int ans = 0;
        for (int i = 0; i < n; i++){
            cin >> a[i];
            ans += a[i];
        }
        while(n > 1){
            for (int i = 0; i < n; i++){
                a[i] = a[i + 1] - a[i];
            }
            n--;
            int temp = 0;
            for (int i = 0; i < n; i++){
                temp += a[i];
            }
            ans = max(ans, abs(temp));
        }
        cout << ans << endl;
    }
}