ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 1):
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
void solve()
{
    int l,r;
    int a;
    cin>>l>>r;
    int s=l^r;
    if(r-l==2)  cout<<l<<' '<<l+1<<' '<<r<<endl;
    else
    {
        for(int i=30;i>=0;i--)
            if(1<<i & s)
            {
                a=i;
                break;
            }
        int x,y,z;
        x=1<<a;
        y=x-1;
        z=l;
        cout<<x<<' '<<y<<' '<<z<<endl;
    }
}
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}
Problem: 2050C - Uninteresting Number
Language: C++20 (GCC 13-64)


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

using namespace std;

typedef long long ll;

int a[100010];



int main() {

	int _;

	cin >> _;

	while(_--){

		string s;

		cin >> s;

		for(int i=0;i<s.size();i++){

			a[i]=s[i]-'0';

		}

		ll sum=0;

		int num2=0,num3=0;

		for(int i=0;i<s.size();i++){

			sum+=a[i];

			if(a[i]==2){

				num2++;

			}

			else if(a[i]==3){

				num3++;

			}

		}

		if(sum%9==0){

			cout << "YES" << endl;

		}

		else if(sum%9==7&&num2>=1){

			cout << "YES" << endl;

		}

		else if(sum%9==5&&num2>=2){

			cout << "YES" << endl;

		}

		else if(sum%9==3&&(num3>=1||num2>=3)){

			cout << "YES" << endl;

		}

		else if(sum%9==1&&(num2>=4||(num2>=1&&num3>=1))){

			cout << "YES" << endl;

		}

		else if(sum%9==6&&(num3>=2||num2>=6)){

			cout << "YES" << endl;

		}

		else if(sum%9==2&&(num2>=8||(num2>=2&&num3>=2)||(num2>=5&&num3>=1))){

			cout << "YES" << endl;

		}

		else if(sum%9==4&&(num2>=7||(num2>=4&&num3>=1)||(num2>=1&&num3>=2))){

		    cout << "YES" << endl;

		}

		else if(sum%9==8&&(num2>=5||(num2>=2&&num3>=1))){

			cout << "YES" << endl;

		}

		else cout << "NO" << endl;

	}

	return 0;

}
Problem: 2050C - Uninteresting Number
Language: C++20 (GCC 13-64)

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

using namespace std;

typedef long long ll;

int a[100010];



int main() {

	int _;

	cin >> _;

	while(_--){

		string s;

		cin >> s;

		for(int i=0;i<s.size();i++){

			a[i]=s[i]-'0';

		}

		ll sum=0;

		int num2=0,num3=0;

		for(int i=0;i<s.size();i++){

			sum+=a[i];

			if(a[i]==2){

				num2++;

			}

			else if(a[i]==3){

				num3++;

			}

		}

		if(sum%9==0&&sum!=0){

			cout << "YES" << endl;

		}

		else if(sum%9==7&&num2>=1){

			cout << "YES" << endl;

		}

		else if(sum%9==5&&num2>=2){

			cout << "YES" << endl;

		}

		else if(sum%9==3&&(num3>=1||num2>=3)){

			cout << "YES" << endl;

		}

		else if(sum%9==1&&(num2>=4||(num2>=1&&num3>=1))){

			cout << "YES" << endl;

		}

		else if(sum%9==6&&(num3>=2||num2>=6)){

			cout << "YES" << endl;

		}

		else if(sum%9==2&&(num2>=8||(num2>=2&&num3>=2)||(num2>=5&&num3>=1))){

			cout << "YES" << endl;

		}

		else if(sum%9==4&&(num2>=7||(num2>=4&&num3>=1)||(num2>=1&&num3>=2))){

		    cout << "YES" << endl;

		}

		else if(sum%9==8&&(num2>=5||(num2>=2&&num3>=1))){

			cout << "YES" << endl;

		}

		else cout << "NO" << endl;

	}

	return 0;

}

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

using namespace std;

typedef long long ll;

int a[100010];



int main() {

	int _;

	cin >> _;

	while(_--){

		string s;

		cin >> s;

		for(int i=0;i<s.size();i++){

			a[i]=s[i]-'0';

		}

		ll sum=0;

		int num2=0,num3=0;

		for(int i=0;i<s.size();i++){

			sum+=a[i];

			if(a[i]==2){

				num2++;

			}

			else if(a[i]==3){

				num3++;

			}

		}

		if(sum==0){

			cout << "NO" << endl;

		}

		else if(sum%9==0){

			cout << "YES" << endl;

		}

		else if(sum%9==7&&num2>=1){

			cout << "YES" << endl;

		}

		else if(sum%9==5&&num2>=2){

			cout << "YES" << endl;

		}

		else if(sum%9==3&&(num3>=1||num2>=3)){

			cout << "YES" << endl;

		}

		else if(sum%9==1&&(num2>=4||(num2>=1&&num3>=1))){

			cout << "YES" << endl;

		}

		else if(sum%9==6&&(num3>=2||num2>=6)){

			cout << "YES" << endl;

		}

		else if(sum%9==2&&(num2>=8||(num2>=2&&num3>=2)||(num2>=5&&num3>=1))){

			cout << "YES" << endl;

		}

		else if(sum%9==4&&(num2>=7||(num2>=4&&num3>=1)||(num2>=1&&num3>=2))){

		    cout << "YES" << endl;

		}

		else if(sum%9==8&&(num2>=5||(num2>=2&&num3>=1))){

			cout << "YES" << endl;

		}

		else cout << "NO" << endl;

	}

	return 0;

}
Problem: 2050C - Uninteresting Number
Language: C++20 (GCC 13-64)

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

using namespace std;

typedef long long ll;

int a[100010];



int main() {

	int _;

	cin >> _;

	while(_--){

		string s;

		cin >> s;

		for(int i=0;i<s.size();i++){

			a[i]=s[i]-'0';

		}

		ll sum=0;

		int num2=0,num3=0;

		for(int i=0;i<s.size();i++){

			sum+=a[i];

			if(a[i]==2){

				num2++;

			}

			else if(a[i]==3){

				num3++;

			}

		}

		if(sum==0){

			cout << "NO" << endl;

		}

		else if(sum%9==0){

			cout << "YES" << endl;

		}

		else if(sum%9==7&&num2>=1){

			cout << "YES" << endl;

		}

		else if(sum%9==5&&num2>=2){

			cout << "YES" << endl;

		}

		else if(sum%9==3&&(num3>=1||num2>=3)){

			cout << "YES" << endl;

		}

		else if(sum%9==1&&(num2>=4||(num2>=1&&num3>=1))){

			cout << "YES" << endl;

		}

		else if(sum%9==6&&(num3>=2||num2>=6)){

			cout << "YES" << endl;

		}

		else if(sum%9==2&&(num2>=8||(num2>=2&&num3>=2)||(num2>=5&&num3>=1))){

			cout << "YES" << endl;

		}

		else if(sum%9==4&&(num2>=7||(num2>=4&&num3>=1)||(num2>=1&&num3>=2))){

		    cout << "YES" << endl;

		}

		else if(sum%9==8&&(num2>=5||(num2>=2&&num3>=1))){

			cout << "YES" << endl;

		}

		else cout << "NO" << endl;

	}

	return 0;

}

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

using namespace std;

typedef long long ll;

int a[100010];



int main() {

	int _;

	cin >> _;

	while(_--){

		string s;

		cin >> s;

		for(int i=0;i<s.size();i++){

			a[i]=s[i]-'0';

		}

		ll sum=0;

		int num2=0,num3=0;

		for(int i=0;i<s.size();i++){

			sum+=a[i];

			if(a[i]==2){

				num2++;

			}

			else if(a[i]==3){

				num3++;

			}

		}

		

		if(sum%9==0){

			cout << "YES" << endl;

		}

		else if(sum%9==7&&num2>=1){

			cout << "YES" << endl;

		}

		else if(sum%9==5&&num2>=2){

			cout << "YES" << endl;

		}

		else if(sum%9==3&&(num3>=1||num2>=3)){

			cout << "YES" << endl;

		}

		else if(sum%9==1&&(num2>=4||(num2>=1&&num3>=1))){

			cout << "YES" << endl;

		}

		else if(sum%9==6&&(num3>=2||num2>=6||(num3>=1&&num2>=3))){

			cout << "YES" << endl;

		}

		else if(sum%9==2&&(num2>=8||(num2>=2&&num3>=2)||(num2>=5&&num3>=1))){

			cout << "YES" << endl;

		}

		else if(sum%9==4&&(num2>=7||(num2>=4&&num3>=1)||(num2>=1&&num3>=2))){

		    cout << "YES" << endl;

		}

		else if(sum%9==8&&(num2>=5||(num2>=2&&num3>=1))){

			cout << "YES" << endl;

		}

		else cout << "NO" << endl;

	}

	return 0;

}
Problem: 2050C - Uninteresting Number
Language: C++20 (GCC 13-64)

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

using namespace std;

typedef long long ll;

int a[100010];



int main() {

	int _;

	cin >> _;

	while(_--){

		string s;

		cin >> s;

		for(int i=0;i<s.size();i++){

			a[i]=s[i]-'0';

		}

		ll sum=0;

		int num2=0,num3=0;

		for(int i=0;i<s.size();i++){

			sum+=a[i];

			if(a[i]==2){

				num2++;

			}

			else if(a[i]==3){

				num3++;

			}

		}

		if(sum%9==0){

			cout << "YES" << endl;

		}

		else if(sum%9==7&&num2>=1){

			cout << "YES" << endl;

		}

		else if(sum%9==5&&num2>=2){

			cout << "YES" << endl;

		}

		else if(sum%9==3&&(num3>=1||num2>=3)){

			cout << "YES" << endl;

		}

		else if(sum%9==1&&(num2>=4||(num2>=1&&num3>=1))){

			cout << "YES" << endl;

		}

		else if(sum%9==6&&(num3>=2||num2>=6)){

			cout << "YES" << endl;

		}

		else if(sum%9==2&&(num2>=8||(num2>=2&&num3>=2)||(num2>=5&&num3>=1))){

			cout << "YES" << endl;

		}

		else if(sum%9==4&&(num2>=7||(num2>=4&&num3>=1)||(num2>=1&&num3>=2))){

		    cout << "YES" << endl;

		}

		else if(sum%9==8&&(num2>=5||(num2>=2&&num3>=1))){

			cout << "YES" << endl;

		}

		else cout << "NO" << endl;

	}

	return 0;

}

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

using namespace std;

typedef long long ll;

int a[100010];



int main() {

	int _;

	cin >> _;

	while(_--){

		string s;

		cin >> s;

		for(int i=0;i<s.size();i++){

			a[i]=s[i]-'0';

		}

		ll sum=0;

		int num2=0,num3=0;

		for(int i=0;i<s.size();i++){

			sum+=a[i];

			if(a[i]==2){

				num2++;

			}

			else if(a[i]==3){

				num3++;

			}

		}

		if(sum%9==0&&sum!=0){

			cout << "YES" << endl;

		}

		else if(sum%9==7&&num2>=1){

			cout << "YES" << endl;

		}

		else if(sum%9==5&&num2>=2){

			cout << "YES" << endl;

		}

		else if(sum%9==3&&(num3>=1||num2>=3)){

			cout << "YES" << endl;

		}

		else if(sum%9==1&&(num2>=4||(num2>=1&&num3>=1))){

			cout << "YES" << endl;

		}

		else if(sum%9==6&&(num3>=2||num2>=6)){

			cout << "YES" << endl;

		}

		else if(sum%9==2&&(num2>=8||(num2>=2&&num3>=2)||(num2>=5&&num3>=1))){

			cout << "YES" << endl;

		}

		else if(sum%9==4&&(num2>=7||(num2>=4&&num3>=1)||(num2>=1&&num3>=2))){

		    cout << "YES" << endl;

		}

		else if(sum%9==8&&(num2>=5||(num2>=2&&num3>=1))){

			cout << "YES" << endl;

		}

		else cout << "NO" << endl;

	}

	return 0;

}
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include<iostream>

#include<vector>

#include<algorithm>

#include<cmath>

using namespace std;

using ll=long long;

void solve(){

    int n,l,r;

    cin>>n>>l>>r;

    vector<int>a(n+1);

    for(int i=1;i<=n;i++)cin>>a[i];

    sort(a.begin(),a.end());

    int ans=r-l+1;

    int sum=0;

    for(int i=0;i<=ans;i++){

        sum+=a[i];

    }

    cout<<sum<<'\n';

    return ;

}

int main(){

    int _;

    cin>>_;

    while(_--)solve();

    return 0;

}

Submission (verdict: Wrong answer on test 8):
#include<iostream>

#include<vector>

#include<algorithm>

#include<cmath>

using namespace std;

using ll=long long;

void solve(){

    int l,r,n;

    cin>>n>>l>>r;

    vector<int>a(n+1);

    for(int i=1;i<=n;i++)cin>>a[i];

    //由于整个进行反转的话，前面和后面不相等的元素就影响不到当前的点

    //所以要想可以影响大的话，就需要从1开始，所以现在的需要计算的是

    //[1,r][l,n]的最小值

    vector<int>val1,val2;

    for(int i=1;i<=r;i++){

        val1.push_back(a[i]);

    }

    for(int i=l;i<=n;i++){

        val2.push_back(a[i]);

    }

    sort(val1.begin(),val1.end());

    sort(val2.begin(),val2.end());

    int _val1=0,_val2=0;

    for(int i=0;i<r-l+1;i++){

        _val1+=val1[i];

        _val2+=val2[i];

    }

    cout<<min(_val1,_val2)<<'\n';

    return ;

}

int main(){

    int _;

    cin>>_;

    while(_--)solve();

    return 0;

}
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 2):
#include<iostream>

#include<vector>

#include<algorithm>

#include<cmath>

using namespace std;

using ll=long long;

void solve(){

    int n,l,r;

    cin>>n>>l>>r;

    vector<int>a(n+1);

    for(int i=1;i<=n;i++)cin>>a[i];

    sort(a.begin(),a.end());

    int ans=r-l+1;

    int sum=0;

    for(int i=0;i<=ans;i++){

        sum+=a[i];

    }

    cout<<sum<<'\n';

    return ;

}

int main(){

    int _;

    cin>>_;

    while(_--)solve();

    return 0;

}
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 8):
#include<iostream>

#include<vector>

#include<algorithm>

#include<cmath>

using namespace std;

using ll=long long;

void solve(){

    int l,r,n;

    cin>>n>>l>>r;

    vector<int>a(n+1);

    for(int i=1;i<=n;i++)cin>>a[i];

    //由于整个进行反转的话，前面和后面不相等的元素就影响不到当前的点

    //所以要想可以影响大的话，就需要从1开始，所以现在的需要计算的是

    //[1,r][l,n]的最小值

    vector<int>val1,val2;

    for(int i=1;i<=r;i++){

        val1.push_back(a[i]);

    }

    for(int i=l;i<=n;i++){

        val2.push_back(a[i]);

    }

    sort(val1.begin(),val1.end());

    sort(val2.begin(),val2.end());

    int _val1=0,_val2=0;

    for(int i=0;i<r-l+1;i++){

        _val1+=val1[i];

        _val2+=val2[i];

    }

    cout<<min(_val1,_val2)<<'\n';

    return ;

}

int main(){

    int _;

    cin>>_;

    while(_--)solve();

    return 0;

}

Submission (verdict: Accepted):
#include<iostream>

#include<vector>

#include<algorithm>

#include<cmath>

using namespace std;

using ll=long long;

void solve(){

    int l,r,n;

    cin>>n>>l>>r;

    vector<ll>a(n+1);

    for(int i=1;i<=n;i++)cin>>a[i];

    //由于整个进行反转的话，前面和后面不相等的元素就影响不到当前的点

    //所以要想可以影响大的话，就需要从1开始，所以现在的需要计算的是

    //[1,r][l,n]的最小值

    vector<ll>val1,val2;

    for(int i=1;i<=r;i++){

        val1.push_back(a[i]);

    }

    for(int i=l;i<=n;i++){

        val2.push_back(a[i]);

    }

    sort(val1.begin(),val1.end());

    sort(val2.begin(),val2.end());

    ll _val1=0,_val2=0;

    for(int i=0;i<r-l+1;i++){

        _val1+=val1[i];

        _val2+=val2[i];

    }

    cout<<min(_val1,_val2)<<'\n';

    return ;

}

int main(){

    int _;

    cin>>_;

    while(_--)solve();

    return 0;

}
Problem: 2063C - Remove Exactly Two
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
#define all(a) a.begin(),a.end()
#define mod 998244353
#define PII pair<int,int>
#define PLL pair<long long,long long>
#define PCC pair<char,char>
const int N = 200005;
using namespace std;
typedef long long ll;
typedef long double ld;
const int dirs_4[4][2] = { {0,1},{0,-1},{1,0},{-1,0} };
const int dirs_8[8][2] = { {0,1},{0,-1},{1,0},{-1,0},{1,1},{1,-1},{-1,1},{-1,-1} };
ll quick_pow(ll a, ll b) {
    ll s = 0;
    while (b) {
        if (b & 1)s^=a;
        b >>= 1;
        a = (1&a)^(1&a);
    }
    return s;
}
ll gcd(ll x, ll y) {
    return y == 0 ? x : gcd(y, x % y);
}
ll lcm(ll x, ll y) {
    return x * y / gcd(x, y);
}
ll lowbit(ll x) {
    return x & -x;
}
ll get_dist(int x1,int y1,int x2,int y2){
    return pow(x1-x2,2)+pow(y1-y2,2);
}
int u[N],v[N],f[N],g[N];
int Find1(int x){
    return x==f[x]?x:f[x]=Find1(f[x]);
}
int Find2(int x){
    return x==g[x]?x:g[x]=Find2(g[x]);
}
void solve()
{
    int n;
    cin>>n;
    vector<vector<int>>g(n+1);
    vector<int>deg(n+1);
    for(int i=0;i<n-1;i++){
        int u,v;
        cin>>u>>v;
        deg[u]++,deg[v]++;
        g[u].emplace_back(v);
        g[v].emplace_back(u);
    }
    if(n==2){
        cout<<0<<endl;
        return ;
    }
    int mx=0;
    for(int i=1;i<=n;i++){
        if(deg[i]>deg[mx]){
            mx=i;
        }
    }
    int ans=deg[mx];
    for(auto&j:g[mx]){
        deg[j]--;
    }
    int remove=mx;
    mx=0;
    for(int i=1;i<=n;i++){
        if(i!=remove&&deg[i]>deg[mx]){
            mx=i;
        }
    } 
    ans+=deg[mx]-1;
    cout<<ans<<endl;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    int t;
    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 ll                       long long int
#define pb                       push_back
#define mp                       make_pair
#define pp                       pop_back
#define mod                      1000000007
#define inf                      1e18
#define vi                       vector<ll>
#define vvi                      vector<vi>
#define pii                      pair<ll, ll>
#define vpii                     vector<pii>
#define pi                       acos(-1)
#define all(v)                   v.begin(), v.end()
#define rall(v)                  v.rbegin(), v.rend()
#define yes                      cout << "YES" << endl;
#define no                       cout << "NO" << endl;
#define ff                       first
#define ss                       second
#define endl                     '\n'
#define FIO                      ios_base :: sync_with_stdio(false); cin.tie(NULL);
#define debug(arg)               cout << #arg << " = " << arg << endl;


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

    vi v(n);
    for (auto &it : v) cin >> it;

    ll sum = accumulate(all(v), 0LL);
    while (v.size() > 1) {
        for (ll i = 0; i < v.size() - 1; ++i) 
            v[i] = v[i + 1] - v[i];
        v.pp();
        ll temp = 0;
        for (ll i = 0; i < v.size(); ++i) 
            temp += abs(v[i]);
        sum = max(sum, temp);
    }
    cout << sum << endl;
}

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

Previous submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
#define ll                       long long int
#define pb                       push_back
#define mp                       make_pair
#define pp                       pop_back
#define mod                      1000000007
#define inf                      1e18
#define vi                       vector<ll>
#define vvi                      vector<vi>
#define pii                      pair<ll, ll>
#define vpii                     vector<pii>
#define pi                       acos(-1)
#define all(v)                   v.begin(), v.end()
#define rall(v)                  v.rbegin(), v.rend()
#define yes                      cout << "YES" << endl;
#define no                       cout << "NO" << endl;
#define ff                       first
#define ss                       second
#define endl                     '\n'
#define FIO                      ios_base :: sync_with_stdio(false); cin.tie(NULL);
#define debug(arg)               cout << #arg << " = " << arg << endl;


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

    vi v(n);
    for (auto &it : v) cin >> it;

    ll sum = accumulate(all(v), 0LL);
    while (v.size() > 1) {
        for (ll i = 0; i < v.size() - 1; ++i) 
            v[i] = v[i + 1] - v[i];
        v.pp();
        ll temp = accumulate(all(v), 0LL);
        sum = max(sum, temp);
    }
    cout << sum << endl;
}

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


Submission (verdict: Accepted):
#include<bits/stdc++.h>
using namespace std;
#define ll                       long long int
#define pb                       push_back
#define mp                       make_pair
#define pp                       pop_back
#define mod                      1000000007
#define inf                      1e18
#define vi                       vector<ll>
#define vvi                      vector<vi>
#define pii                      pair<ll, ll>
#define vpii                     vector<pii>
#define pi                       acos(-1)
#define all(v)                   v.begin(), v.end()
#define rall(v)                  v.rbegin(), v.rend()
#define yes                      cout << "YES" << endl;
#define no                       cout << "NO" << endl;
#define ff                       first
#define ss                       second
#define endl                     '\n'
#define FIO                      ios_base :: sync_with_stdio(false); cin.tie(NULL);
#define debug(arg)               cout << #arg << " = " << arg << endl;


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

    vi v(n);
    for (auto &it : v) cin >> it;

    ll sum = accumulate(all(v), 0LL);
    while (v.size() > 1) {
        for (ll i = 0; i < v.size() - 1; ++i) 
            v[i] = v[i + 1] - v[i];
        v.pp();
        ll temp = accumulate(all(v), 0LL);
        sum = max(sum, abs(temp));
    }
    cout << sum << endl;
}

int main()
{
    FIO;
    ll t = 1; cin >> t;
    while (t--) 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 ll                       long long int
#define pb                       push_back
#define mp                       make_pair
#define pp                       pop_back
#define mod                      1000000007
#define inf                      1e18
#define vi                       vector<ll>
#define vvi                      vector<vi>
#define pii                      pair<ll, ll>
#define vpii                     vector<pii>
#define pi                       acos(-1)
#define all(v)                   v.begin(), v.end()
#define rall(v)                  v.rbegin(), v.rend()
#define yes                      cout << "YES" << endl;
#define no                       cout << "NO" << endl;
#define ff                       first
#define ss                       second
#define endl                     '\n'
#define FIO                      ios_base :: sync_with_stdio(false); cin.tie(NULL);
#define debug(arg)               cout << #arg << " = " << arg << endl;


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

    vi v(n);
    for (auto &it : v) cin >> it;

    ll sum = accumulate(all(v), 0LL);
    while (v.size() > 1) {
        for (ll i = 0; i < v.size() - 1; ++i) 
            v[i] = v[i + 1] - v[i];
        v.pp();
        ll temp = 0;
        for (ll i = 0; i < v.size(); ++i) 
            temp += abs(v[i]);
        sum = max(sum, temp);
    }
    cout << sum << endl;
}

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


Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
#define ll                       long long int
#define pb                       push_back
#define mp                       make_pair
#define pp                       pop_back
#define mod                      1000000007
#define inf                      1e18
#define vi                       vector<ll>
#define vvi                      vector<vi>
#define pii                      pair<ll, ll>
#define vpii                     vector<pii>
#define pi                       acos(-1)
#define all(v)                   v.begin(), v.end()
#define rall(v)                  v.rbegin(), v.rend()
#define yes                      cout << "YES" << endl;
#define no                       cout << "NO" << endl;
#define ff                       first
#define ss                       second
#define endl                     '\n'
#define FIO                      ios_base :: sync_with_stdio(false); cin.tie(NULL);
#define debug(arg)               cout << #arg << " = " << arg << endl;


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

    vi v(n);
    for (auto &it : v) cin >> it;

    ll sum = accumulate(all(v), 0LL);
    while (v.size() > 1) {
        for (ll i = 0; i < v.size() - 1; ++i) 
            v[i] = v[i + 1] - v[i];
        v.pp();
        ll temp = accumulate(all(v), 0LL);
        sum = max(sum, temp);
    }
    cout << sum << endl;
}

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