ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2063B - Subsequence Update
Language: C++20 (GCC 13-64)

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

using namespace std;

typedef long long ll;

#define pp make_pair

#define endl "\n"

#define f first

#define s second

#define TxtIO   freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);

#define int long long



signed main()

{

    ios_base::sync_with_stdio(false);

    cin.tie(0);

    int t ;cin>>t;

    while (t--)

    {

        int n,l,r ; cin>>n>>l>>r;

        l--;r--;

        vector<int> v(n); 

        for (int i = 0 ; i<n ; i++) cin>>v[i];



        vector<int> v1;

        vector<int> v2;

        

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

        v1.push_back(v[i]);

        v2.push_back(v[i]);

        }



        for (int i = 0 ;i<l;i++) v1.push_back(v[i]);

        for (int i = r+1 ;i<n;i++) v2.push_back(v[i]);



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

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

        int k= r-l+1;

        int ans=INT_MAX;

        int sum=0;

      //  cout<<v1.size()<<" "<<v2.size();

    //    return 0;

        for (int i = 0 ;i<k;i++) sum+=v1[i];

        ans=min(ans,sum); sum=0;

        for (int i = 0 ; i<k;i++) sum+=v2[i];

        ans=min(ans,sum);

        

        cout<<ans<<endl;



    }

}

// store the indexes

// 3  6  6  4  3 2

// 8 11 11  10 - -

//  after sorting  2 3 3 4 6 6

Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pp make_pair
#define endl "\n"
#define f first
#define s second
#define TxtIO   freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
#define int long long

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t ;cin>>t;
    while (t--)
    {
        int n,l,r ; cin>>n>>l>>r;
        l--;r--;
        vector<int> v(n); 
        for (int i = 0 ; i<n ; i++) cin>>v[i];

        vector<int> v1;
        vector<int> v2;
        
        for (int i = l; i<=r;i++) {
        v1.push_back(v[i]);
        v2.push_back(v[i]);
        }

        for (int i = 0 ;i<l;i++) v1.push_back(v[i]);
        for (int i = r+1 ;i<n;i++) v2.push_back(v[i]);

        sort(v1.begin(),v1.end());
        sort(v2.begin(),v2.end());
        int k= r-l+1;
        int sum1=0;
      //  cout<<v1.size()<<" "<<v2.size();
    //    return 0;
        for (int i = 0 ;i<k;i++) sum1+=v1[i];
        
        int sum2 = 0 ;
        for (int i = 0 ; i<k;i++) sum2+=v2[i];
        
        cout<<min(sum1,sum2)<<endl;

    }
}
// store the indexes
// 3  6  6  4  3 2
// 8 11 11  10 - -
//  after sorting  2 3 3 4 6 6
Problem: 2063B - Subsequence Update
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;
#define pp make_pair
#define endl "\n"
#define f first
#define s second
#define TxtIO   freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
#define int long long
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t ;cin>>t;
    while (t--)
    {
        int n,l,r ; cin>>n>>l>>r;
        l--;r--;
        vector<int> v(n);
        for (int i = 0 ; i<n ; i++) cin>>v[i];
        sort(v.begin(),v.end());
        int idx=0; int ans=0;
        for (int i = l;i<r+1;i++) ans+=v[idx++];
        cout<<ans<<endl;
    }
}
// store the indexes
// 3  6  6  4  3 2
// 8 11 11  10 - -
//  after sorting  2 3 3 4 6 6


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pp make_pair
#define endl "\n"
#define f first
#define s second
#define TxtIO   freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
#define int long long
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t ;cin>>t;
    while (t--)
    {
        int n,l,r ; cin>>n>>l>>r;
        l--;r--;
        vector<int> v(n);
        for (int i = 0 ; i<n ; i++) cin>>v[i];
        sort(v.begin(),v.end());
         int ans=0;
        for (int i = 0;i<r-l+1;i++) ans+=v[i];
        cout<<ans<<endl;
    }
}
// store the indexes
// 3  6  6  4  3 2
// 8 11 11  10 - -
//  after sorting  2 3 3 4 6 6
Problem: 2063B - Subsequence Update
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pp make_pair
#define endl "\n"
#define f first
#define s second
#define TxtIO   freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
#define int long long
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t ;cin>>t;
    while (t--)
    {
        int n,l,r ; cin>>n>>l>>r;
        l--;r--;
        vector<int> v(n);
        for (int i = 0 ; i<n ; i++) cin>>v[i];
        sort(v.begin(),v.end());
        int idx=0; int ans=0;
        for (int i = l;i<r+1;i++) ans+=v[idx++];
        cout<<ans<<endl;
    }
}
// store the indexes
// 3  6  6  4  3 2
// 8 11 11  10 - -
//  after sorting  2 3 3 4 6 6
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define ld long double
#define all(x) x.begin(), x.end()
#define endl '\n'
#define T  ll t ; cin >> t; while(t--)
int main() {
    fast
    T{
        string s;
        cin>>s;
        int sum=0,c2=0,c3=0;
        for(int i=0;i<s.size();i++){
            sum+=(s[i]-'0');
            if(s[i]=='2'){
                c2++;
            }else if(s[i]=='3'){
                c3++;
            }
        }
        while(sum%9&&(c3||c2)){
            if(sum%9==7&&c2){
                sum+=2;
                c2--;
            }
            if(sum%9==3&&c3){
                sum+=6;
                c3--;
            }
            if(sum%9&&c3){
                sum+=6;
                c3--;
            }else if(sum%9&&c2){
                sum+=2;
                c2--;
            }

        }
        if(sum%9){
            cout<<"NO\n";
        }else{
            cout<<"YES\n";
        }
    }



}
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define ld long double
#define all(x) x.begin(), x.end()
#define endl '\n'
#define T  ll t ; cin >> t; while(t--)
int main() {
    fast
    T{
        string s;
        cin>>s;
        int sum=0,c2=0,c3=0;
        for(int i=0;i<s.size();i++){
            sum+=(s[i]-'0');
            if(s[i]=='2'){
                c2++;
            }else if(s[i]=='3'){
                c3++;
            }
        }
        while(sum%9&&(c3||c2)){
            if(sum%9==7&&c2){
                sum+=2;
                c2--;
            }
            if(sum%9==3&&c3){
                sum+=6;
                c3--;
            }
            if(sum%9&&c3){
                sum+=6;
                c3--;
            }else if(sum%9&&c2){
                sum+=2;
                c2--;
            }

        }
        if(sum%9){
            cout<<"NO\n";
        }else{
            cout<<"YES\n";
        }
    }



}



Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define ld long double
#define all(x) x.begin(), x.end()
#define endl '\n'
#define T  ll t ; cin >> t; while(t--)
int main() {
    fast
    T{
        string s;
        cin>>s;
        int sum=0,c2=0,c3=0;
        for(int i=0;i<s.size();i++){
            sum+=(s[i]-'0');
            if(s[i]=='2'){
                c2++;
            }else if(s[i]=='3'){
                c3++;
            }
        }
        while(sum%9&&(c3||c2)){
            if(sum%9==7&&c2){
                sum+=2;
            }
            if(sum%9==5&&c2>=2){
                sum+=4;
            }
            if(sum%9==3&&c3){
                sum+=6;
            }
            if(sum%9==3&&c2>=3){
                sum+=6;
            }
            if(sum%9==1&&(c2&&c3)||(c2>=4)){
                sum+=8;
            }

            if(sum%9&&c3){
                sum+=6;
                c3--;
            }else if(sum%9&&c2){
                sum+=2;
                c2--;
            }

        }
        if(sum%9){
            cout<<"NO\n";
        }else{
            cout<<"YES\n";
        }
    }



}
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define ld long double
#define all(x) x.begin(), x.end()
#define endl '\n'
#define T  ll t ; cin >> t; while(t--)
int main() {
    fast
    T{
        string s;
        cin>>s;
        int sum=0,c2=0,c3=0;
        for(int i=0;i<s.size();i++){
            sum+=(s[i]-'0');
            if(s[i]=='2'){
                c2++;
            }else if(s[i]=='3'){
                c3++;
            }
        }
        while(sum%9&&(c3||c2)){
            if(sum%9==7&&c2){
                sum+=2;
            }
            if(sum%9==5&&c2>=2){
                sum+=4;
            }
            if(sum%9==3&&c3){
                sum+=6;
            }
            if(sum%9==3&&c2>=3){
                sum+=6;
            }
            if(sum%9==1&&(c2&&c3)||(c2>=4)){
                sum+=8;
            }

            if(sum%9&&c3){
                sum+=6;
                c3--;
            }else if(sum%9&&c2){
                sum+=2;
                c2--;
            }

        }
        if(sum%9){
            cout<<"NO\n";
        }else{
            cout<<"YES\n";
        }
    }



}



Submission (verdict: Accepted):
#include<bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define ld long double
#define all(x) x.begin(), x.end()
#define endl '\n'
#define T  ll t ; cin >> t; while(t--)
int main() {
    fast
    T{
        string s;
        cin>>s;
        int sum=0,c2=0,c3=0;
        for(int i=0;i<s.size();i++){
            sum+=(s[i]-'0');
            if(s[i]=='2'){
                c2++;
            }else if(s[i]=='3'){
                c3++;
            }
        }
        while(sum%9&&(c3||c2)){
            if(c2&&!c3){
                sum+=2;
                c2--;
            }else if(!c2&&c3){
                sum+=6;
                c3--;
            }else{
                if((sum+2)%9==0){
                    sum+=2;
                }else if((sum+4)%9==0&&c2>=2){
                    sum+=4;
                }else{
                    sum+=6;
                    c3--;
                }
            }

        }
        if(sum%9){
            cout<<"NO\n";
        }else{
            cout<<"YES\n";
        }
    }



}
Problem: 2061D - Kevin and Numbers
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
#include <iomanip>
#include <cmath>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type, less<>, rb_tree_tag, tree_order_statistics_node_update>
#define ordered_multiset tree <int, null_type, less_equal <int>, rb_tree_tag, tree_order_statistics_node_update>
using namespace std;
#define pb push_back
#define F first
#define S second
#define all(a)  a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(x) ((int)(x).size())
#define int long long
#define popcoutn(x) __builtin_popcountll(x)
//__builtin_clzll()->leading zeros in binary
#define inf 1e18
#define el "\n"
#define Bassmala ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
vector<int> take(int n){
    vector<int>v(n);
    for(int i=0;i<n;i++)cin>>v[i];
    return v;
}
//--------------------------------global variables----------------------------------//
//---------------------------------functions----------------------------------------//
//-----------------------------------code-------------------------------------------//
void pewpew(){
    multiset<int>st;
    int n,m;cin>>n>>m;
    for(int i=0;i<n;i++){
        int a;cin>>a;
        st.insert(a);
    }
    map<int,int>mp;
    for(int i=0;i<m;i++){
        int a;cin>>a;
        mp[a]++;
    }
    while(sz(st)){
        int cur=*st.begin();
        st.erase(st.begin());
        if(mp.count(cur) and mp[cur]){
            mp[cur]--;
            continue;
        }else if(st.empty()){
            cout<<"NO"<<el;
            return;
        }
        if(sz(st) and abs(cur-*st.begin())<=1){
            cur+=*st.begin();
            st.erase(st.begin());
            st.insert(cur);

        }else break;
    }
    for(auto it:mp)if(it.S or sz(st)){
        cout<<"NO"<<el;
        return;
    }
    cout<<"YES"<<el;
// Yes
// No
// Yes
// Yes
// No
// Yes
// No
// No
// No

}
//----------------------------------------------------------------------------------//
signed main()
{
    /* ☯︎☯︎☯︎ */    Bassmala;    /* ☯︎☯︎☯︎ */
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt","w",stdout);
    int x_x = 1;
    cin >> x_x;
    while (x_x--) {
        pewpew();
    }
    return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int t, l, r;
    cin >> t;
    while (t--) {
        cin >> l >> r;
        int k = 31 - __builtin_clz(l ^ r), a = l | (1 << k) - 1, b = a + 1, c = a == l ? r : l;
        cout << a << " " << b << " " << c << "\n";
    }
    return 0;
}


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

void solve()
{
    int l, r, i;
    cin >> l >> r;
    if(r - l == 2)
    {
        cout << r << ' ' << r - 1 << ' ' << l << '\n';
        return;
    }
    int a = 1LL<<(63 - __builtin_clzll(r));
    int b = a - 1;
    int c = b - 1;
    cout << a << ' ' << b << ' ' << c << '\n';

}

int32_t main()
{
    int t; cin >> t;
    while (t--) solve();
    
}
Problem: 2057C - Trip to the Olympiad
Language: C++23 (GCC 14-64, msys2)

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

void solve()
{
    int l, r, i;
    cin >> l >> r;
    if(r - l == 2)
    {
        cout << r << ' ' << r - 1 << ' ' << l << '\n';
        return;
    }
    int a = 1LL<<(63 - __builtin_clzll(r));
    int b = a - 1;
    int c = b - 1;
    cout << a << ' ' << b << ' ' << c << '\n';

}

int32_t main()
{
    int t; cin >> t;
    while (t--) solve();
    
}



Submission (verdict: Wrong answer on test 1):
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int test = sc.nextInt();
		for (int z = 0; z < test; z++) {

			long l = sc.nextInt();
			long r = sc.nextInt();
			long one = l;
			long two;
			long three;
			long i =1;
			if((r-l+1)==3) {
				two=l+1;
				three=l+2;
			} else {
				while (i<=r) {
					i=i*2;
				}
				if(i/2<l){
				    if((r-l+1) >=6 ){
				        two= l+2;
				        three=two+3;
				        
				    }else{
				        two= r-1;
				        three= r;
				        one = r-2;
				    }
				    
				}else if(i/2==l){
				    if((r-l+1) >=6 ){
				        three = r;
				        two = r-2;
				        one = r-5;
				    }else{
				        two= r-1;
				        three= r;
				        one = r-2;
				    }
				    
				    
				}
				else{
				    three=i/2;
				    two=three-1;
				}
				
			}
			
			System.out.println(two+" "+three+" "+one);



		}
	}
}
Problem: 2057C - Trip to the Olympiad
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void solve()
{
    int l,r;
    cin >> l >> r;
    int lg = log(l ^ r) / log(2);
    int num = (1 << lg);
    int a = r / num * num;
    int b = a - 1;;
    int c;
    for (int i = l;i <= r;i++) 
    {
        if (i != a && i != b) 
        {
            c = i;
            break;
        }
    }
    cout << a << ' ' << b << ' ' << c << '\n';
} 
int main() 
{
    //ios_base::sync_with_stdio(false);
    //cin.tie(0);
	int t;
	cin >> t;
	while(t--) solve();
	return 0;
}




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

#define ll long long
#define F first
#define S second
#define pb push_back
#define endl "\n"
#define all(x) (x).begin(), (x).end()

using namespace std;

void solve() {
    int l, r;
    cin >> l >> r;

    if(r - l == 2) {
        cout << r << " " << r + 1 << " " << l << endl;
    }

    int m_bit = 0;
    for(int i = 31; i >= 0; i--) {
        if((1 << i) & r) {
            m_bit = i;
            break;
        }
    }

    bool all = true;;

    for(int i = l; i <= r; i++) {
        if(!((1 << m_bit) & i)) {
            all = false;
        }
    }

    int a, b, c;

    if(!all) {
        a = 1 << m_bit, b = a - 1, c = b - 1;
    } else {
        m_bit--;
        a = 1 << m_bit, b = a - 1, c = b - 1;
    }

    cout << a << " " << " " << b << " " << c << endl;
}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

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

    return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 1):
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int test = sc.nextInt();
		for (int z = 0; z < test; z++) {

			long l = sc.nextInt();
			long r = sc.nextInt();
			long one = l;
			long two;
			long three;
			long i =1;
			if((r-l+1)==3) {
				two=l+1;
				three=l+2;
			} else {
				while (i<=r) {
					i=i*2;
				}
				if(i/2<l){
				    if((r-l+1) >=6 ){
				        two= l+2;
				        three=two+3;
				        
				    }else{
				        two= r-1;
				        three= r;
				        one = r-2;
				    }
				    
				}else if(i/2==l){
				    if((r-l+1) >=6 ){
				        three = r;
				        two = r-2;
				        one = r-5;
				    }else{
				        two= r-1;
				        three= r;
				        one = r-2;
				    }
				    
				    
				}
				else{
				    three=i/2;
				    two=three-1;
				}
				
			}
			
			System.out.println(two+" "+three+" "+one);



		}
	}
}

Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void solve()
{
    int l,r;
    cin >> l >> r;
    int lg = log(l ^ r) / log(2);
    int num = (1 << lg);
    int a = r / num * num;
    int b = a - 1;;
    int c;
    for (int i = l;i <= r;i++) 
    {
        if (i != a && i != b) 
        {
            c = i;
            break;
        }
    }
    cout << a << ' ' << b << ' ' << c << '\n';
} 
int main() 
{
    //ios_base::sync_with_stdio(false);
    //cin.tie(0);
	int t;
	cin >> t;
	while(t--) solve();
	return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int t, l, r;
    cin >> t;
    while (t--) {
        cin >> l >> r;
        int k = 31 - __builtin_clz(l ^ r), a = l | (1 << k) - 1, b = a + 1, c = a == l ? r : l;
        cout << a << " " << b << " " << c << "\n";
    }
    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;
typedef long long ll;
const ll MOD = 1000000007;
typedef pair<ll, ll> pil;
typedef pair<int, int> pii;
typedef vector<ll>  vll;
typedef vector<int> vi;
#define f(i,c,n) for(int i=c;i<n;i++)
#define all(x) x.begin(),x.end()
#define pb push_back

void solve(){
    int n;cin>>n;
    vector<int> vec(n);
    f(i,0,n) {cin>>vec[i];}

        int temp=n;
        int64_t res = INT_MIN;
        for(int i = 0;i < n; i++){
            int64_t sum = 0;
            f(i,0,temp) sum+=vec[i];
            if(i==0) res = max (res,sum);
            else res = max(res,max(sum,(-sum)));
            f(i,0,temp-1){
                vec[i] = vec[i+1] - vec[i];
            }
            temp--;
        }
        cout << res << endl;

}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int t;
    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;
typedef long long ll;
const ll MOD = 1000000007;
typedef pair<ll, ll> pil;
typedef pair<int, int> pii;
typedef vector<ll>  vll;
typedef vector<int> vi;
#define f(i,c,n) for(int i=c;i<n;i++)
#define all(x) x.begin(),x.end()
#define pb push_back
int a[1010] ;

void solve(){
    int n;
		cin >> n;
		for (int i = 1; i <= n; i++) cin >> a[i];
		int now = n;
		long long ans = -1e18;
		for (int i = 1; i <= n; i++){
			long long sum = 0;
			for (int i = 1; i <= now; i++) sum = (sum + a[i]) ;
			if (i == 1) ans = max(ans, sum);
			else ans = max(ans, max(sum, ( - sum) ));
			for (int i = 1; i < now; i++) a[i] = (a[i + 1] - a[i]) ;
			now--;
		}
		cout << ans << endl; 

}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
typedef pair<ll, ll> pil;
typedef pair<int, int> pii;
typedef vector<ll>  vll;
typedef vector<int> vi;
#define f(i,c,n) for(int i=c;i<n;i++)
#define all(x) x.begin(),x.end()
#define pb push_back
int a[1010] ;

void solve(){
    int n;
		cin >> n;
		for (int i = 1; i <= n; i++) cin >> a[i];
		int now = n;
		long long ans = -1e18 * 1LL;
		for (int i = 1; i <= n; i++){
			long long sum = 0 * 1LL;
			for (int i = 1; i <= now; i++) sum = (sum + a[i]) ;
			if (i == 1) ans = max(ans, sum);
			else ans = max(ans, max(sum, ( - sum) ));
			for (int i = 1; i < now; i++) a[i] = (a[i + 1] - a[i]) ;
			now--;
		}
		cout << ans * 1LL << endl; 

}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}