ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2061D - Kevin and Numbers
Language: C++23 (GCC 14-64, msys2)

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

using namespace std;

using i64 = long long;

using u64 = unsigned long long;

using pii = pair<int,int>;

using pll = pair<long long,long long>;



mt19937_64 rnd(time(nullptr));

const int maxn = 2e5+100;

const int mod = 998'244'353;

//const int mod = 1e+9+7;

//const i64 inf = 1e18;

//const int inf = 1e9;



int n,m;



void Main(){

    cin>>n>>m;

    multiset<int> a,b;

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

        int x; cin>>x;

        a.insert(x);

    }

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

        int x; cin>>x;

        auto it = a.find(x);

        if(it!=a.end()) a.erase(it);

        else b.insert(x);

    }

    while(!b.empty()){

        int cur = *b.begin(); b.erase(b.begin());

        while(a.size()>=2 && *a.begin() < cur){

            int x=*a.begin(); a.erase(a.begin());

            int y=*a.begin();a.erase(a.begin());

            if(abs(x-y)>1) break;

            a.insert(x+y);

        }

        if(a.empty() || *a.begin() != cur) return cout <<"NO\n",void();

        a.erase(a.begin());

    }

    cout << (a.empty() ? "YES" : "NO") << '\n';

}

int main(){

    ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

    int T = 1;

    cin >> T;

    while(T--) Main();

}

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

using namespace std;

using i64 = long long;

using u64 = unsigned long long;

using pii = pair<int,int>;

using pll = pair<long long,long long>;



mt19937_64 rnd(time(nullptr));

const int maxn = 2e5+100;

const int mod = 998'244'353;

//const int mod = 1e+9+7;

//const i64 inf = 1e18;

//const int inf = 1e9;



int n,m;



bool solve(int x,multiset<int> & mst){

    if(mst.empty() || *mst.begin() > x) return false;

//    printf("solve %d\n",mst.find(x)==mst.end());

    if(mst.find(x) != mst.end()){

        mst.erase(mst.find(x));

        return true;

    }

    int mid = x>>1;

    return solve(mid,mst) && solve(mid+(x&1),mst);

}

void Main(){

    cin>>n>>m;

    multiset<int> a,b;

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

        int x; cin>>x;

        a.insert(x);

    }

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

        int x; cin>>x;

        if(!solve(x,a)) return cout<<"NO\n",void();

    }

    cout << (a.empty() ? "YES" : "NO" ) << '\n';

}

int main(){

    ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

    int T = 1;

    cin >> T;

    while(T--) Main();

}
Problem: 2061D - Kevin and Numbers
Language: C++20 (GCC 13-64)

Previous submission (verdict: Runtime error on test 9):
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
#define int long long
#define fr(i,a,b) for(int i=a;i<b;i++)

int power(int a, int b) {
    int result = 1;
    while (b) {
        if (b & 1) 
            result = result * a;
        a = a * a;
        b >>= 1;
    }
    return result;
}
int log_a_base_b(int a , int b){
    int cnt=0;
    while(a!=0){
        a/=b;
        cnt++;
    }
    return cnt;
}
void solve(){
    int n,m;
    cin >> n >> m ;
    multiset<int> s1, s2;
    fr(i,0,n){
        int x; cin>>x;
        s1.insert(x);
    }
    fr(i,0,m){
        int x; cin>>x;
        s2.insert(x);
    }
    int ct=0;
    while(ct<n-m){
        if(s1.size()>0 && s2.size()>0){
            auto it1= --s1.end();
            auto it2= --s2.end();
            if((*it2) > (*it1)){
                s2.erase(it2);
                int x=(*it2)/2;
                int y=((*it2)+1)/2;
                s2.insert(x);
                s2.insert(y);
                ct++;
            }
            else if((*it2)==(*it1)){
                s1.erase(it1);
                s2.erase(it2);
            }
            else{
                cout<<"No"<<endl;
                return;
            }
        }
        else{
            cout<<"No"<<endl;
            return;
        }
    }
    if(s1==s2){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t; cin >> t;
    while(t--){
        solve();
    }
}

Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
#define int long long
#define fr(i,a,b) for(int i=a;i<b;i++)

int power(int a, int b) {
    int result = 1;
    while (b) {
        if (b & 1) 
            result = result * a;
        a = a * a;
        b >>= 1;
    }
    return result;
}
int log_a_base_b(int a , int b){
    int cnt=0;
    while(a!=0){
        a/=b;
        cnt++;
    }
    return cnt;
}
void solve(){
    int n,m;
    cin >> n >> m ;
    multiset<int> s1, s2;
    fr(i,0,n){
        int x; cin>>x;
        s1.insert(x);
    }
    fr(i,0,m){
        int x; cin>>x;
        s2.insert(x);
    }
    int ct=0;
    while(ct<n-m){
        if(s1.size()>0 && s2.size()>0){
            auto it1= --s1.end();
            auto it2= --s2.end();
            if((*it2) > (*it1)){
                int x=(*it2)/2;
                int y=((*it2)+1)/2;
                s2.erase(it2);
                s2.insert(x);
                s2.insert(y);
                ct++;
            }
            else if((*it2)==(*it1)){
                s1.erase(it1);
                s2.erase(it2);
            }
            else{
                cout<<"No"<<endl;
                return;
            }
        }
        else{
            cout<<"No"<<endl;
            return;
        }
    }
    if(s1==s2){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t; cin >> t;
    while(t--){
        solve();
    }
}
Problem: 2061D - Kevin and Numbers
Language: C++20 (GCC 13-64)


Submission (verdict: Runtime error on test 1):
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
#define int long long
#define fr(i,a,b) for(int i=a;i<b;i++)

int power(int a, int b) {
    int result = 1;
    while (b) {
        if (b & 1) 
            result = result * a;
        a = a * a;
        b >>= 1;
    }
    return result;
}
int log_a_base_b(int a , int b){
    int cnt=0;
    while(a!=0){
        a/=b;
        cnt++;
    }
    return cnt;
}
void solve(){
    int n,m;
    cin >> n >> m ;
    multiset<int> s1, s2;
    fr(i,0,n){
        int x; cin>>x;
        s1.insert(x);
    }
    fr(i,0,m){
        int x; cin>>x;
        s2.insert(x);
    }
    int ct=0;
    while(ct<n-m){
        auto it1= --s1.end();
        auto it2= --s2.end();
        if(s1.size()>0 && s2.size()>0){
            if((*it2) > (*it1)){
                s2.erase(it2);
                int x=(*it2)/2;
                int y=((*it2)+1)/2;
                s2.insert(x);
                s2.insert(y);
                ct--;
            }
            else if((*it2)==(*it1)){
                s1.erase(it1);
                s2.erase(it2);
            }
            else{
                cout<<"No"<<endl;
                return;
            }
        }
        else{
            cout<<"No"<<endl;
            return;
        }
    }
    if(s1==s2){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t; cin >> t;
    while(t--){
        solve();
    }
}
Problem: 2060D - Subtract Min Sort
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
#define int long long
#define _MAX 1e9
#define _MIN -1e18
#define HierenCE_ signed main()

using namespace std;

int n, s, l, r, m;
int q;
int t;
int a[200005];
HierenCE_ {
	cin >> t;
	while(t--) {
		cin >> n;
		for(int i = 0; i < n; i++) {
			cin >> a[i];
		}
		if(n == 2) {
			if(a[0] <= a[1]) {
				cout << "YES\n";
			} else cout << "NO\n";
			continue;
		}
		int ok = 1;
		for(int i = 1; i < n - 1; i++) {
			if(a[i] - a[i - 1] > a[i + 1]) {
				ok = 0;
				break;
			} else {
				a[i] = a[i] - a[i - 1];
			}
		}
		if(ok) {
			cout << "YES\n";
		} else cout << "NO\n";
	}
}
Problem: 2060D - Subtract Min Sort
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
#define int long long
#define _MAX 1e9
#define _MIN -1e18
#define HierenCE_ signed main()

using namespace std;

int n, s, l, r, m;
int q;
int t;
int a[200005];
HierenCE_ {
	cin >> t;
	while(t--) {
		cin >> n;
		for(int i = 0; i < n; i++) {
			cin >> a[i];
		}
		if(n == 2) {
			if(a[0] <= a[1]) {
				cout << "YES\n";
			} else cout << "NO\n";
			continue;
		}
		int ok = 1;
		for(int i = 1; i < n - 1; i++) {
			if(a[i] - a[i - 1] > a[i + 1]) {
				ok = 0;
				break;
			} else {
				a[i] = a[i] - a[i - 1];
			}
		}
		if(ok) {
			cout << "YES\n";
		} else cout << "NO\n";
	}
}

Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
#define int long long
#define _MAX 1e9
#define _MIN -1e18
#define HierenCE_ signed main()

using namespace std;

int n, s, l, r, m;
int q;
int t;
int a[200005];
HierenCE_ {
	cin >> t;
	while(t--) {
		cin >> n;
		for(int i = 1; i <= n; i++) {
			cin >> a[i];
		}
		if(n == 2) {
			if(a[0] <= a[1]) {
				cout << "YES\n";
			} else cout << "NO\n";
			continue;
		}
		int ok = 1;
		for(int i = 1; i < n; i++) {
			if(a[i] - a[i - 1] > a[i + 1]) {
				ok = 0;
				break;
			} else {
				a[i] = a[i] - a[i - 1];
			}
		}
		if(ok) {
			cout << "YES\n";
		} else cout << "NO\n";
	}
}
Problem: 2060D - Subtract Min Sort
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
#define int long long
#define _MAX 1e9
#define _MIN -1e18
#define HierenCE_ signed main()

using namespace std;

int n, s, l, r, m;
int q;
int t;
int a[200005];
HierenCE_ {
	cin >> t;
	while(t--) {
		cin >> n;
		for(int i = 1; i <= n; i++) {
			cin >> a[i];
		}
		if(n == 2) {
			if(a[0] <= a[1]) {
				cout << "YES\n";
			} else cout << "NO\n";
			continue;
		}
		int ok = 1;
		for(int i = 1; i < n; i++) {
			if(a[i] - a[i - 1] > a[i + 1]) {
				ok = 0;
				break;
			} else {
				a[i] = a[i] - a[i - 1];
			}
		}
		if(ok) {
			cout << "YES\n";
		} else cout << "NO\n";
	}
}

Submission (verdict: Accepted):
#include <bits/stdc++.h>
#define int long long
#define _MAX 1e9
#define _MIN -1e18
#define HierenCE_ signed main()

using namespace std;

int n, s, l, r, m;
int q;
int t;
int a[200005];
HierenCE_ {
	cin >> t;
	while(t--) {
		cin >> n;
		for(int i = 1; i <= n; i++) {
			cin >> a[i];
		}
		if(n == 2) {
			if(a[1] <= a[2]) {
				cout << "YES\n";
			} else cout << "NO\n";
			continue;
		}
		int ok = 1;
		for(int i = 1; i < n; i++) {
			if(a[i] - a[i - 1] > a[i + 1]) {
				ok = 0;
				break;
			} else {
				a[i] = a[i] - a[i - 1];
			}
		}
		if(ok) {
			cout << "YES\n";
		} else cout << "NO\n";
	}
}
Problem: 2062C - Cirno and Operations
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 2):
    //#define MYDEBUG
    #ifndef oUwUo
    	#include <bits/stdc++.h>
     
    	using namespace std;
     
    	#define endl << "\n"
    	#define FOR(x, n) for (int x=0; x < n; x++)
    	#define ll long long
    	#define vi vector<int>
    	#define vpi vector<pair<int,int>>
    	#define vvi vector<vector<i>>
    	#define vll vector<ll>
    	#define vpll vector<pair<ll,ll>>
    	#define vvll vector<vector<ll,ll>>
    	#define mp make_pair
    	#define SMIN(x,y) x=min(x,y)
    	#define SMAX(x,y) x=max(x,y)
    	#define RNG(j,l,r) for(int j=l;j<r;j++)
    	#define REVRNG(j,l,r) for(int j=r-1;j>=l;j--)
     
    	#ifdef MYDEBUG
    	#define D(x) {cerr << #x << " = " << x endl;}
    	#define D2(x, y) {cerr << #x << " = " << x << "/t" << #y << " = " << y endl;}
    	#define DT(t,x) {cerr<<t<<"\t"<<#x<<" = "<<x endl;}
    	#define DIT(cont) {cerr<<"container: " <<#cont endl<<"\t"; for(auto x: cont){cerr<<x<<" ";} cerr endl;}
    	#define DITlmd(cont,lmd) {cerr<<"container: " <<#cont endl<<"\t"; for(auto x: cont){cerr<<lmd(x)<<" ";} cerr endl;}
    	#define DARR(arr,n) {cerr<<"array :"<<#arr endl <<"\t" ; FOR(i,n){cerr<<arr[i]<<" ";} cerr endl;}
    	#define DARRlmd(arr,n,lmd) {cerr<<"array :"<<#arr endl <<"\t" ; FOR(i,n){cerr<<lmd(arr[i])<<" ";} cerr endl;}
    	#define TT(tex) cerr<<tex endl;
    	#else
    	#define D(x)
    	#define D2(x, y)
    	#define DT(t,x)
    	#define DIT(cont)
    	#define DITlmd(cont,lmd)
    	#define DARR(arr,n)
    	#define DARRlmd(arr,n,lmd)
    	#define TT(tex)
    	#endif
    #endif

	
     
    void solve()
    {
    	// code
		int n; cin>>n;
		
		ll res=0;

		vi a(n),b(n-1);

		FOR(i,n) cin>>a[i];

		for(int el:a) res+=el;


		while(a.size()>1){
			int s=a.size();
			b.resize(s-1);
			ll value=0;
		

			FOR(i,s-1){
				b[i]=a[i]-a[i+1];
			}
			for(int el :b) value+=el;
			res=max(res,abs(value));

			swap(a,b);


		}

		cout<<res endl;

		


    
    	return;
    }
     
    int main()
    {
        cin.tie(0);
        cout.sync_with_stdio(0);
    	int _;
    	cin >> _;
    	for (int t = 1; t <= _; t++)
    	{
    		#ifdef MYDEBUG
    			cerr << "______________________ testcsase = " << t endl;
    		#endif
    		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>
#include<map>
#define endl '\n'
#define int long long 
#define x first
#define y second
using namespace std;
typedef pair<int,int> PII;
//typedef vector<int> VI;
//typedef vector<vector<int> > VVI;

//struct Edge
//{
//	int to,nxt,val;
//}e[100003];
//int cnt,head[100003];
//void add(int u,int v)
//{
//	e[++cnt].to=v;
//	e[cnt].nxt=head[u];
//	head[u]=cnt;
//}

int n,k;
int a[53];
map<int,int> m;
void solve()
{   
    cin>>n;
    if(n==1)
    {
        int t;
        cin>>t;
        cout<<t<<endl;
        return ;
    }
    for(int i=1;i<=n;i++)
        cin>>a[i];
    int ans=0;
    int t=n;
    for(int i=1;i<=t;i++)
    {
        int sum=0;
        for(int j=1;j<=n;j++)
            sum+=a[j];
        ans=max(ans,abs(sum));
        // cout<<"No"<<n<<" "<<ans<<endl;
        // for(int j=1;j<=n;j++)
        //     cout<<a[j]<<" ";
        // cout<<endl;
        for(int j=1;j<n;j++)
            a[j]=a[j+1]-a[j];
        n--;
    }
    cout<<ans<<endl;
	return ;
}
signed main()
{
	ios::sync_with_stdio(0);
	int 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>
#include<map>
#define endl '\n'
#define int long long 
#define x first
#define y second
using namespace std;
typedef pair<int,int> PII;
//typedef vector<int> VI;
//typedef vector<vector<int> > VVI;

//struct Edge
//{
//	int to,nxt,val;
//}e[100003];
//int cnt,head[100003];
//void add(int u,int v)
//{
//	e[++cnt].to=v;
//	e[cnt].nxt=head[u];
//	head[u]=cnt;
//}

int n,k;
int a[53];
map<int,int> m;
void solve()
{   
    cin>>n;
    if(n==1)
    {
        int t;
        cin>>t;
        cout<<t<<endl;
        return ;
    }
    for(int i=1;i<=n;i++)
        cin>>a[i];
    int ans=0;
    int t=n;
    for(int i=1;i<=n;i++)
    {
        int sum=0;
        for(int j=1;j<=t;j++)
            sum+=a[j];
        ans=max(ans,abs(sum));
        // cout<<"No"<<n<<" "<<ans<<endl;
        // for(int j=1;j<=n;j++)
        //     cout<<a[j]<<" ";
        // cout<<endl;
        for(int j=1;j<t;j++)
            a[j]=a[j+1]-a[j];
        t--;
    }
    cout<<ans<<endl;
	return ;
}
signed main()
{
	ios::sync_with_stdio(0);
	int T=1;
	cin>>T;
	while(T--)
	{
		solve();
	}
	return 0;
}

Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
#include<map>
#define endl '\n'
#define int long long 
#define x first
#define y second
using namespace std;
typedef pair<int,int> PII;
//typedef vector<int> VI;
//typedef vector<vector<int> > VVI;

//struct Edge
//{
//	int to,nxt,val;
//}e[100003];
//int cnt,head[100003];
//void add(int u,int v)
//{
//	e[++cnt].to=v;
//	e[cnt].nxt=head[u];
//	head[u]=cnt;
//}

int n,k;
int a[53];
map<int,int> m;
void solve()
{   
    cin>>n;
    if(n==1)
    {
        int t;
        cin>>t;
        cout<<t<<endl;
        return ;
    }
    for(int i=1;i<=n;i++)
        cin>>a[i];
    int ans=0;
    int t=n;
    for(int i=1;i<=n;i++)
    {
        int sum=0;
        for(int j=1;j<=t;j++)
            sum+=a[j];
        if(ans!=1)
            ans=max(ans,abs(sum));
        else  
            ans=max(ans,sum);
        // cout<<"No"<<n<<" "<<ans<<endl;
        // for(int j=1;j<=n;j++)
        //     cout<<a[j]<<" ";
        // cout<<endl;
        for(int j=1;j<t;j++)
            a[j]=a[j+1]-a[j];
        t--;
    }
    cout<<ans<<endl;
	return ;
}
signed main()
{
	ios::sync_with_stdio(0);
	int 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>
#include<map>
#define endl '\n'
#define int long long 
#define x first
#define y second
using namespace std;
typedef pair<int,int> PII;
//typedef vector<int> VI;
//typedef vector<vector<int> > VVI;

//struct Edge
//{
//	int to,nxt,val;
//}e[100003];
//int cnt,head[100003];
//void add(int u,int v)
//{
//	e[++cnt].to=v;
//	e[cnt].nxt=head[u];
//	head[u]=cnt;
//}

int n,k;
int a[53];
map<int,int> m;
void solve()
{   
    cin>>n;
    if(n==1)
    {
        int t;
        cin>>t;
        cout<<t<<endl;
        return ;
    }
    for(int i=1;i<=n;i++)
        cin>>a[i];
    int ans=0;
    int t=n;
    for(int i=1;i<=n;i++)
    {
        int sum=0;
        for(int j=1;j<=t;j++)
            sum+=a[j];
        if(ans!=1)
            ans=max(ans,abs(sum));
        else  
            ans=max(ans,sum);
        // cout<<"No"<<n<<" "<<ans<<endl;
        // for(int j=1;j<=n;j++)
        //     cout<<a[j]<<" ";
        // cout<<endl;
        for(int j=1;j<t;j++)
            a[j]=a[j+1]-a[j];
        t--;
    }
    cout<<ans<<endl;
	return ;
}
signed main()
{
	ios::sync_with_stdio(0);
	int T=1;
	cin>>T;
	while(T--)
	{
		solve();
	}
	return 0;
}

Submission (verdict: Accepted):
#include<bits/stdc++.h>
#include<map>
#define endl '\n'
#define int long long 
#define x first
#define y second
using namespace std;
typedef pair<int,int> PII;
//typedef vector<int> VI;
//typedef vector<vector<int> > VVI;

//struct Edge
//{
//	int to,nxt,val;
//}e[100003];
//int cnt,head[100003];
//void add(int u,int v)
//{
//	e[++cnt].to=v;
//	e[cnt].nxt=head[u];
//	head[u]=cnt;
//}

int n,k;
int a[53];
map<int,int> m;
void solve()
{   
    cin>>n;
    if(n==1)
    {
        int t;
        cin>>t;
        cout<<t<<endl;
        return ;
    }
    for(int i=1;i<=n;i++)
        cin>>a[i];
    int ans=-1e18;
    int t=n;
    for(int i=1;i<=n;i++)
    {
        int sum=0;
        for(int j=1;j<=t;j++)
            sum+=a[j];
        if(i!=1)
            ans=max(ans,abs(sum));
        else  
            ans=max(ans,sum);
        // cout<<"No"<<n<<" "<<ans<<endl;
        // for(int j=1;j<=n;j++)
        //     cout<<a[j]<<" ";
        // cout<<endl;
        for(int j=1;j<t;j++)
            a[j]=a[j+1]-a[j];
        t--;
    }
    cout<<ans<<endl;
	return ;
}
signed main()
{
	ios::sync_with_stdio(0);
	int 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>
#include<map>
#define endl '\n'
#define int long long 
#define x first
#define y second
using namespace std;
typedef pair<int,int> PII;
//typedef vector<int> VI;
//typedef vector<vector<int> > VVI;

//struct Edge
//{
//	int to,nxt,val;
//}e[100003];
//int cnt,head[100003];
//void add(int u,int v)
//{
//	e[++cnt].to=v;
//	e[cnt].nxt=head[u];
//	head[u]=cnt;
//}

int n,k;
int a[53];
map<int,int> m;
void solve()
{   
    cin>>n;
    if(n==1)
    {
        int t;
        cin>>t;
        cout<<t<<endl;
        return ;
    }
    for(int i=1;i<=n;i++)
        cin>>a[i];
    int ans=0;
    int t=n;
    for(int i=1;i<=t;i++)
    {
        int sum=0;
        for(int j=1;j<=n;j++)
            sum+=a[j];
        ans=max(ans,abs(sum));
        // cout<<"No"<<n<<" "<<ans<<endl;
        // for(int j=1;j<=n;j++)
        //     cout<<a[j]<<" ";
        // cout<<endl;
        for(int j=1;j<n;j++)
            a[j]=a[j+1]-a[j];
        n--;
    }
    cout<<ans<<endl;
	return ;
}
signed main()
{
	ios::sync_with_stdio(0);
	int T=1;
	cin>>T;
	while(T--)
	{
		solve();
	}
	return 0;
}


Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
#include<map>
#define endl '\n'
#define int long long 
#define x first
#define y second
using namespace std;
typedef pair<int,int> PII;
//typedef vector<int> VI;
//typedef vector<vector<int> > VVI;

//struct Edge
//{
//	int to,nxt,val;
//}e[100003];
//int cnt,head[100003];
//void add(int u,int v)
//{
//	e[++cnt].to=v;
//	e[cnt].nxt=head[u];
//	head[u]=cnt;
//}

int n,k;
int a[53];
map<int,int> m;
void solve()
{   
    cin>>n;
    if(n==1)
    {
        int t;
        cin>>t;
        cout<<t<<endl;
        return ;
    }
    for(int i=1;i<=n;i++)
        cin>>a[i];
    int ans=0;
    int t=n;
    for(int i=1;i<=n;i++)
    {
        int sum=0;
        for(int j=1;j<=t;j++)
            sum+=a[j];
        ans=max(ans,abs(sum));
        // cout<<"No"<<n<<" "<<ans<<endl;
        // for(int j=1;j<=n;j++)
        //     cout<<a[j]<<" ";
        // cout<<endl;
        for(int j=1;j<t;j++)
            a[j]=a[j+1]-a[j];
        t--;
    }
    cout<<ans<<endl;
	return ;
}
signed main()
{
	ios::sync_with_stdio(0);
	int T=1;
	cin>>T;
	while(T--)
	{
		solve();
	}
	return 0;
}