ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2061D - Kevin and Numbers
Language: C++17 (GCC 7-32)


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

#define fastIO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);cout.precision(numeric_limits<double>::max_digits10);
#define int long long
#define ll long long
#define endl '\n'

// STL Input Outputs
#define vdef(v,n) vector<int> v((n)); for(int i=0;i<(n);i++) cin>>v[i]
#define vvdef(v,n,m) vector<vector<int>> v(n, vector<int>(m)); for(int i=0; i<n; i++) for(int j=0; j<m; j++) cin >> v[i][j];
#define vout(v) for(auto& el:v) cout<<el<<" "; cout << endl
#define vvout(vec) for(auto& v: vec){for(auto& ele: v){cout << ele <<" ";}cout << endl;}
#define mpdef(mp) map<int, int> mp
#define mpout(mp) for(auto& el: mp) { cout << el.first << " " << el.second << endl; }
#define strin(s) string s; cin >> s

// Pairs
#define pr pair<int, int>
#define ff first
#define ss second

// STL Functions Related
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()

// Inputs and Outputs
#define rd1(x) int x; cin >> x
#define rd2(x, y) int x, y; cin >> x >> y
#define rd3(x, y, z) int x, y, z; cin >> x >> y >> z
#define rd4(x, y, z, w) int x, y, z, w; cin >> x >> y >> z >> w
#define ha cout << "YES" << endl
#define na cout << "NO" << endl
#define nl cout << endl
#define aout(ans) cout << ans << endl

const int MOD = 1000000007;
const int MOD2 = 998244353;

void solve() {
    rd2(n,m);
    multiset<int> s1, s2;
    for(int i=0; i<n; i++){
        rd1(x);
        s1.insert(x);
    } 
    for(int i=0; i<m; i++){
        rd1(x);
        s2.insert(x);
    }
    int sm1 = accumulate(all(s1), 0ll), sm2 = accumulate(all(s2), 0ll);
    if(sm1 != sm2){
        na;
        return;
    }
    while(!s1.empty() && !s2.empty()){
        int mx1 = *s1.rbegin(), mx2 = *s2.rbegin();
        if(mx1 > mx2){
            na;
            return;
        }else if(mx1 == mx2){
            s1.erase(s1.find(mx1));
            s2.erase(s2.find(mx2));
        }else{
            int v1 = (mx2+1)/2, v2 = mx2/2; 
            if(s1.count(v1)>0 && s1.count(v2)>0){
                s1.erase(s1.find(v1));
                s1.erase(s1.find(v2));
                s2.erase(s2.find(mx2));
            }else{
                s2.erase(s2.find(mx2));
                s2.insert(v1);
                s2.insert(v2);
            }
        }
    }
    if(s1.empty() && s2.empty()){
        ha;
    }else{
        na;
    }
}

signed main() {
    fastIO;
    int t = 1;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}
Problem: 2049C - MEX Cycle
Language: C++17 (GCC 7-32)


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

using namespace std;



int main() {

    int t ;cin>>t; // You can modify t for multiple test cases

    while (t--) {

        int n, x, y;

        cin >> n >> x >> y;



        vector<int> a(n, 0); // Initialize with 0



        if (x == n || y == n) {

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

                a[i] = (i % 2 == 0) ? 0 : 1;

            }

            if (n % 2) {

                a[0] = 2;

            }

            if (a[x - 1] == a[y - 1]) {

                if (a[x - 1] == 0) {

                    a[x - 1] = 2;

                    if (x == 3) {

                        a[x - 2] = 0;

                    }

                } else if (a[x - 1] == 1) {

                    a[y - 1] = 2;

                }

            }

        } else {

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

                a[i] = (i % 2 == 0) ? 0 : 1;

            }

            if (n % 2) {

                a[n - 1] = 2;

            }

            if (a[x - 1] == a[y - 1]) {

                if (a[x - 1] == 0) {

                    a[y - 1] = 2;

                    if (y + 1 < n && a[y + 1] == 2) { // Avoid out-of-bounds access

                        a[y] = 0;

                    }

                } else if (a[x - 1] == 1) {

                    a[x - 1] = 2;

                }

            }

        }



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

            cout << a[i] << " ";

        }

        cout << endl;

    }



    return 0;

}
Problem: 2052A - Adrenaline Rush
Language: C++23 (GCC 14-64, msys2)

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

void solve() {
    int n;
    cin >> n;
    vector <int> a(n), b(n);
    stack <int> s;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = n-1; i >= 0; i--) {
        while (!s.empty() && s.top() >= a[i]) {
            s.pop();
        }
        if (s.empty()) b[i] = 0;
        else b[a[i]-1] = s.top();
        s.push(a[i]);
    }
    for (int i = 0; i < n; i++) {
        a[i] = i+1;
    }
    // cout << '\n';
    vector <pair<int, int>> ans;
    a.push_back(0);
    int p = n;
    while(n--) {
        int i = 0;
        while (a[i+1]!=b[a[i]-1]) {
            ans.push_back({a[i], a[i+1]});
            swap(a[i], a[i+1]);
            i++;
        }
    }
    cout << ans.size() << '\n';
    for (int i = 0; i < ans.size(); i++) {
        cout << ans[i].second << ' ' << ans[i].first << '\n';
    }

}

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

Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;
#define ll long long

void solve() {
    int n;
    cin >> n;
    vector <int> a(n), b(n);
    stack <int> s;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = n-1; i >= 0; i--) {
        while (!s.empty() && s.top() >= a[i]) {
            s.pop();
        }
        if (s.empty()) b[a[i]-1] = 0;
        else b[a[i]-1] = s.top();
        s.push(a[i]);
    }
    for (int i = 0; i < n; i++) {
        a[i] = i+1;
    }

    // for (int i = 0; i < n; i++) {
    //     cout << b[i] << ' ';
    // }
    // cout << '\n';
    vector <pair<int, int>> ans;
    a.push_back(0);
    int p = n;
    while(n--) {
        int i = 0;
        int val = b[a[0]-1];
        while (a[i+1]!=val) {
            ans.push_back({a[i], a[i+1]});
            swap(a[i], a[i+1]);
            i++;
        }
    }
    cout << ans.size() << '\n';
    for (int i = 0; i < ans.size(); i++) {
        cout << ans[i].second << ' ' << ans[i].first << '\n';
    }

}

int main () {
    int t = 1;
    // cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++23 (GCC 14-64, msys2)

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

void solve() {
    int n;
    cin >> n;
    vector <int> a(n), b(n);
    stack <int> s;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = n-1; i >= 0; i--) {
        while (!s.empty() && s.top() >= a[i]) {
            s.pop();
        }
        if (s.empty()) b[i] = 0;
        else b[a[i]-1] = s.top();
        s.push(a[i]);
    }
    for (int i = 0; i < n; i++) {
        a[i] = i+1;
    }
    // cout << '\n';
    vector <pair<int, int>> ans;
    a.push_back(0);
    int p = n;
    while(n--) {
        int i = 0;
        while (a[i+1]!=b[a[i]-1]) {
            ans.push_back({a[i], a[i+1]});
            swap(a[i], a[i+1]);
            i++;
        }
    }
    cout << ans.size() << '\n';
    for (int i = 0; i < ans.size(); i++) {
        cout << ans[i].first << ' ' << ans[i].second << '\n';
    }

}

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

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

void solve() {
    int n;
    cin >> n;
    vector <int> a(n), b(n);
    stack <int> s;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = n-1; i >= 0; i--) {
        while (!s.empty() && s.top() >= a[i]) {
            s.pop();
        }
        if (s.empty()) b[i] = 0;
        else b[a[i]-1] = s.top();
        s.push(a[i]);
    }
    for (int i = 0; i < n; i++) {
        a[i] = i+1;
    }
    // cout << '\n';
    vector <pair<int, int>> ans;
    a.push_back(0);
    int p = n;
    while(n--) {
        int i = 0;
        while (a[i+1]!=b[a[i]-1]) {
            ans.push_back({a[i], a[i+1]});
            swap(a[i], a[i+1]);
            i++;
        }
    }
    cout << ans.size() << '\n';
    for (int i = 0; i < ans.size(); i++) {
        cout << ans[i].second << ' ' << ans[i].first << '\n';
    }

}

int main () {
    int t = 1;
    // cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}
Problem: 2052A - Adrenaline Rush
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

void solve() {
    int n;
    cin >> n;
    vector <int> a(n), b(n);
    stack <int> s;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = n-1; i >= 0; i--) {
        while (!s.empty() && s.top() >= a[i]) {
            s.pop();
        }
        if (s.empty()) b[i] = 0;
        else b[a[i]-1] = s.top();
        s.push(a[i]);
    }
    for (int i = 0; i < n; i++) {
        a[i] = i+1;
    }
    // cout << '\n';
    vector <pair<int, int>> ans;
    a.push_back(0);
    int p = n;
    while(n--) {
        int i = 0;
        while (a[i+1]!=b[a[i]-1]) {
            ans.push_back({a[i], a[i+1]});
            swap(a[i], a[i+1]);
            i++;
        }
    }
    cout << ans.size() << '\n';
    for (int i = 0; i < ans.size(); i++) {
        cout << ans[i].first << ' ' << ans[i].second << '\n';
    }

}

int main () {
    int t = 1;
    // cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)

Previous submission (verdict: Time limit exceeded on test 7):
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pll pair<ll,ll>
#define vl vector<ll> 
#define pb push_back
#define loop(n,i) for(ll i = 0; i < n; i++)
#define fa(i,v) for(auto &i:v)
#define YES cout << "YES\n"
#define NO cout << "NO\n"
#define print(x) cout << x << "\n";
#define cl(v) v.clear()
#define all(v) v.begin(),v.end()
#define inf (ll)1e18
#define mod (ll)(1e9+7)
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

template <typename T> T input(int n = 1){T tmp;cin >> tmp;return tmp;  }
template <typename T> vector<T> inputn(int n){vector<T> tmp;loop(n,i){
        T _;cin >> _;tmp.pb(_);}return tmp;}

string op(string s, ll n){
    char tmp1;
    tmp1 = s[n];
    s[n] = s[n-1];
    s[n-1] = (char)(tmp1-1);
    return s;
}

int main() {
	fastio
	int T = input<int>();
	loop(T,_){
        string s = input<string>();
        int p = 0;
        fa(x,s){
            int i = 1;
            ll best = s[p],pn = 0;
            while(i < 10 and p+i < s.length()){
                if(s[p+i]-i > best) {
                    best = s[p+i]-i;
                    pn = i;
                }
                i++;
            }
            loop(pn,j){
                s = op(s,p+(pn-j));
            }
            p++;
        }
        cout << s << "\n";
	}
	return 0;
}

Submission (verdict: Time limit exceeded on test 7):
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pll pair<ll,ll>
#define vl vector<ll> 
#define pb push_back
#define loop(n,i) for(ll i = 0; i < n; i++)
#define fa(i,v) for(auto &i:v)
#define YES cout << "YES\n"
#define NO cout << "NO\n"
#define print(x) cout << x << "\n";
#define cl(v) v.clear()
#define all(v) v.begin(),v.end()
#define inf (ll)1e18
#define mod (ll)(1e9+7)
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

template <typename T> T input(int n = 1){T tmp;cin >> tmp;return tmp;  }
template <typename T> vector<T> inputn(int n){vector<T> tmp;loop(n,i){
        T _;cin >> _;tmp.pb(_);}return tmp;}

// class node{
//     public:
//     ll value;
//     node * next;
//     node(ll n, node * prev){
//         value = n;
//         prev->next = this;
//     }
// };

string op(string s, ll n){
    char tmp1;
    tmp1 = s[n];
    s[n] = s[n-1];
    s[n-1] = (char)(tmp1-1);
    return s;
}

int main() {
	fastio
	int T = input<int>();
	loop(T,_){
        string s = input<string>();
        int p = 0;
        // node str(s[0]-'0',NULL);
        // node prev = str;
        fa(x,s){
            int i = 1;
            ll best = s[p],pn = 0;
            while(i < 10 -(s[p]-'0') and p+i < s.length()){
                if(s[p+i]-i > best) {
                    best = s[p+i]-i;
                    pn = i;
                }
                i++;
            }
            loop(pn,j){
                s = op(s,p+(pn-j));
            }
            p++;
        }
        cout << s << "\n";
	}
	return 0;
}
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)

Previous submission (verdict: Time limit exceeded on test 7):
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pll pair<ll,ll>
#define vl vector<ll> 
#define pb push_back
#define loop(n,i) for(ll i = 0; i < n; i++)
#define fa(i,v) for(auto &i:v)
#define YES cout << "YES\n"
#define NO cout << "NO\n"
#define print(x) cout << x << "\n";
#define cl(v) v.clear()
#define all(v) v.begin(),v.end()
#define inf (ll)1e18
#define mod (ll)(1e9+7)
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

template <typename T> T input(int n = 1){T tmp;cin >> tmp;return tmp;  }
template <typename T> vector<T> inputn(int n){vector<T> tmp;loop(n,i){
        T _;cin >> _;tmp.pb(_);}return tmp;}

string op(string s, ll n){
    char tmp1;
    tmp1 = s[n];
    s[n] = s[n-1];
    s[n-1] = (char)(tmp1-1);
    return s;
}

int main() {
	fastio
	int T = input<int>();
	loop(T,_){
        string s = input<string>();
        int p = 0;
        fa(x,s){
            int i = 1;
            ll best = s[p],pn = 0;
            while(i < 10 and p+i < s.length()){
                if(s[p+i]-i > best) {
                    best = s[p+i]-i;
                    pn = i;
                }
                i++;
            }
            if(T == 1) cout << s.length() << " " << pn << "\n";
            loop(pn,j){
                s = op(s,p+(pn-j));
            }
            p++;
        }
        cout << s << "\n";
	}
	return 0;
}

Submission (verdict: Wrong answer on test 7):
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pll pair<ll,ll>
#define vl vector<ll> 
#define pb push_back
#define loop(n,i) for(ll i = 0; i < n; i++)
#define fa(i,v) for(auto &i:v)
#define YES cout << "YES\n"
#define NO cout << "NO\n"
#define print(x) cout << x << "\n";
#define cl(v) v.clear()
#define all(v) v.begin(),v.end()
#define inf (ll)1e18
#define mod (ll)(1e9+7)
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

template <typename T> T input(int n = 1){T tmp;cin >> tmp;return tmp;  }

string op(string s, ll n){
    
    return s;
}

int main() {
	fastio
	int T = input<int>();
	loop(T,_){
        string s = input<string>();
        int p = 0;
        fa(x,s){
            int i = 1;
            ll best = s[p],pn = 0;
            while(i < 10 and p+i < s.length()){
                if(s[p+i]-i > best) {
                    best = s[p+i]-i;
                    pn = i;
                }
                i++;
            }
            if(T == 1) cout << s.length() << " " << pn << "\n";
            loop(pn,j){
                int N=p+(pn-j);
                char tmp1;
                tmp1 = s[N];
                s[N] = s[N-1];
                s[N-1] = (char)(tmp1-1);
            }
            p++;
        }
        cout << s << "\n";
	}
	return 0;
}
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)


Submission (verdict: Time limit exceeded on test 7):
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pll pair<ll,ll>
#define vl vector<ll> 
#define pb push_back
#define loop(n,i) for(ll i = 0; i < n; i++)
#define fa(i,v) for(auto &i:v)
#define YES cout << "YES\n"
#define NO cout << "NO\n"
#define print(x) cout << x << "\n";
#define cl(v) v.clear()
#define all(v) v.begin(),v.end()
#define inf (ll)1e18
#define mod (ll)(1e9+7)
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

template <typename T> T input(int n = 1){T tmp;cin >> tmp;return tmp;  }
template <typename T> vector<T> inputn(int n){vector<T> tmp;loop(n,i){
        T _;cin >> _;tmp.pb(_);}return tmp;}

string op(string s, ll n){
    char tmp1;
    tmp1 = s[n];
    s[n] = s[n-1];
    s[n-1] = (char)(tmp1-1);
    return s;
}

int main() {
	fastio
	int T = input<int>();
	loop(T,_){
        string s = input<string>();
        int p = 0;
        fa(x,s){
            int i = 1;
            ll best = s[p],pn = 0;
            while(i < 10 and p+i < s.length()){
                if(s[p+i]-i > best) {
                    best = s[p+i]-i;
                    pn = i;
                }
                i++;
            }
            loop(pn,j){
                s = op(s,p+(pn-j));
            }
            p++;
        }
        cout << s << "\n";
	}
	return 0;
}
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 7):
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pll pair<ll,ll>
#define vl vector<ll> 
#define pb push_back
#define loop(n,i) for(ll i = 0; i < n; i++)
#define fa(i,v) for(auto &i:v)
#define YES cout << "YES\n"
#define NO cout << "NO\n"
#define print(x) cout << x << "\n";
#define cl(v) v.clear()
#define all(v) v.begin(),v.end()
#define inf (ll)1e18
#define mod (ll)(1e9+7)
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

template <typename T> T input(int n = 1){T tmp;cin >> tmp;return tmp;  }

string op(string s, ll n){
    
    return s;
}

int main() {
	fastio
	int T = input<int>();
	loop(T,_){
        string s = input<string>();
        int p = 0;
        fa(x,s){
            int i = 1;
            ll best = s[p],pn = 0;
            while(i < 10 and p+i < s.length()){
                if(s[p+i]-i > best) {
                    best = s[p+i]-i;
                    pn = i;
                }
                i++;
            }
            if(T == 1) cout << s.length() << " " << pn << "\n";
            loop(pn,j){
                int N=p+(pn-j);
                char tmp1;
                tmp1 = s[N];
                s[N] = s[N-1];
                s[N-1] = (char)(tmp1-1);
            }
            p++;
        }
        cout << s << "\n";
	}
	return 0;
}

Submission (verdict: Accepted):
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pll pair<ll,ll>
#define vl vector<ll> 
#define pb push_back
#define loop(n,i) for(ll i = 0; i < n; i++)
#define fa(i,v) for(auto &i:v)
#define YES cout << "YES\n"
#define NO cout << "NO\n"
#define print(x) cout << x << "\n";
#define cl(v) v.clear()
#define all(v) v.begin(),v.end()
#define inf (ll)1e18
#define mod (ll)(1e9+7)
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

template <typename T> T input(int n = 1){T tmp;cin >> tmp;return tmp;  }

string op(string s, ll n){
    
    return s;
}

int main() {
	fastio
	int T = input<int>();
	loop(T,_){
        string s = input<string>();
        int p = 0;
        fa(x,s){
            int i = 1;
            ll best = s[p],pn = 0;
            while(i < 10 and p+i < s.length()){
                if(s[p+i]-i > best) {
                    best = s[p+i]-i;
                    pn = i;
                }
                i++;
            }
            //if(T == 1) cout << s.length() << " " << pn << "\n";
            loop(pn,j){
                int N=p+(pn-j);
                char tmp1;
                tmp1 = s[N];
                s[N] = s[N-1];
                s[N-1] = (char)(tmp1-1);
            }
            p++;
        }
        cout << s << "\n";
	}
	return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 2):
/*
██████╗░███████╗██╗░░░░░██╗░░░░░░█████╗░  ░█████╗░██╗░█████╗░░█████╗░██╗
██╔══██╗██╔════╝██║░░░░░██║░░░░░██╔══██╗  ██╔══██╗██║██╔══██╗██╔══██╗██║
██████╦╝█████╗░░██║░░░░░██║░░░░░███████║  ██║░░╚═╝██║███████║██║░░██║██║
██╔══██╗██╔══╝░░██║░░░░░██║░░░░░██╔══██║  ██║░░██╗██║██╔══██║██║░░██║╚═╝
██████╦╝███████╗███████╗███████╗██║░░██║  ╚█████╔╝██║██║░░██║╚█████╔╝██╗
╚═════╝░╚══════╝╚══════╝╚══════╝╚═╝░░╚═╝  ░╚════╝░╚═╝╚═╝░░╚═╝░╚════╝░╚═╝
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef std::vector<ll> vll;
typedef std::vector<ld> vld;
typedef std::vector<std::vector<ll>> vvll;
typedef std::vector<std::vector<ld>> vvld;
typedef std::vector<string> vstr;
typedef std::vector<bool> vbl;
typedef std::vector<std::pair<ll,ll>> vpll;
typedef std::pair<ll,ll> pll;
#define f(i, x, n) for (ll i = x; i < n; ++i)
#define rf(i, x, n) for (ll i = x; i >= n; --i)
#define in(n) long long int n; cin >> n
#define instr(s) string s; cin >> s
#define inarr(n, arr) vector<ll> arr(n); f(i,0,n) cin >> arr[i]
#define input(vec,a,b) for(ll i_itr = a; i_itr < b; ++i_itr) cin >> vec[i_itr]
#define print(vec,a,b) for(ll i_itr = a; i_itr < b; ++i_itr) cout << vec[i_itr] << " "; cout << "\n"
#define ha cout << "YES" << endl
#define na cout << "NO" << endl
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
const ll mod = 1000000007;
const ll MOD = 998244353;
const long double pi = 3.14159265358979323846264338327950288419716939937510582097494459230;

void solve()
{
    in(n);
    inarr(n,v);
    ll ans=accumulate(all(v),0);
    while(v.size()>1)
    {
        vll temp(v.size()-1);
        f(i,0,v.size()-1)
        {
            temp[i]=v[i+1]-v[i];
        }
        swap(v,temp);
        ans=max(ans,abs((ll)accumulate(all(v),0)));
    }
    cout<<ans<<endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // cout << fixed << setprecision(15); ///activate it if the answers are in decimal.
    ll T = 1;
    cin >> T;
    while (T--)
    {
        solve();
    }
    return 0;
}