ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2052A - Adrenaline Rush
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
#include<string>
#include<algorithm>
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define big 998244353
#define pb push_back
#define mp make_pair
#define forn for(int i=0;i<n;i++)
using namespace std;

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

    int b[n];
    forn cin>>b[i];

    int a[n];
    forn a[i]=i+1;

    int ans = 0;

    int effective_size = n;
    for(int i=n-1;i>=0;i--)
    {
        int ele = b[i];

        auto it = lower_bound(a, a+n, ele);

        int loc = it-a;

        for(int j=loc-1;j>=0;j--)
        {
            // cout<<ele<<" "<<a[j]<<endl;
            // a[j+1] = a[j];
            // a[j] = ele;
            ++ans;
        }

        for(int j=0;j<i;j++)
        {
            // cout<<a[j+1]<<" "<<a[j]<<endl;
            // swap(a[j],a[j+1]);
            ans++;
        }

    }

    cout<<ans<<endl;

    for(int i=n-1;i>=0;i--)
    {
        int ele = b[i];

        auto it = lower_bound(a, a+n, ele);

        int loc = it-a;

        for(int j=loc-1;j>=0;j--)
        {
            cout<<ele<<" "<<a[j]<<endl;
            a[j+1] = a[j];
            a[j] = ele;
            
        }

        for(int j=0;j<i;j++)
        {
            cout<<a[j+1]<<" "<<a[j]<<endl;
            swap(a[j],a[j+1]);
            
        }

    }
}

int32_t main() {
    // fast io
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    // int t;
    // cin >> t;

    // while (t--) 
        solve();
}

Submission (verdict: Wrong answer on test 5):
#include<string>
#include<algorithm>
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define big 998244353
#define pb push_back
#define mp make_pair
#define forn for(int i=0;i<n;i++)
using namespace std;

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

    int b[n];
    forn cin>>b[i];

    int a[n];
    forn a[i]=i+1;

    int ans = 0;

    int effective_size = n;

    vector<pair <int,int>> answers;
    
    for(int i=n-1;i>=0;i--)
    {
        int ele = b[i];

        auto it = lower_bound(a, a+n, ele);

        int loc = it-a;

        for(int j=loc-1;j>=0;j--)
        {
            // cout<<ele<<" "<<a[j]<<endl;
            answers.pb(mp(ele,a[j]));
            a[j+1] = a[j];
            a[j] = ele;
            ++ans;
        }

        for(int j=0;j<i;j++)
        {
            // cout<<a[j+1]<<" "<<a[j]<<endl;
            answers.pb(mp(a[j+1],a[j]));
            swap(a[j],a[j+1]);
            ans++;
        }

    }

    cout<<ans<<endl;
    for(int i=0;i<answers.size();i++){
        cout<<answers[i].first<<" "<<answers[i].second<<endl;
    }
}

int32_t main() {
    // fast io
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    // int t;
    // cin >> t;

    // while (t--) 
        solve();
}
Problem: 2052A - Adrenaline Rush
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 5):
#include<string>
#include<algorithm>
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define big 998244353
#define pb push_back
#define mp make_pair
#define forn for(int i=0;i<n;i++)
using namespace std;

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

    int b[n];
    forn cin>>b[i];

    int a[n];
    forn a[i]=i+1;

    int ans = 0;

    int effective_size = n;

    vector<pair <int,int>> answers;
    
    for(int i=n-1;i>=0;i--)
    {
        int ele = b[i];

        auto it = lower_bound(a, a+n, ele);

        int loc = it-a;

        for(int j=loc-1;j>=0;j--)
        {
            // cout<<ele<<" "<<a[j]<<endl;
            answers.pb(mp(ele,a[j]));
            a[j+1] = a[j];
            a[j] = ele;
            ++ans;
        }

        for(int j=0;j<i;j++)
        {
            // cout<<a[j+1]<<" "<<a[j]<<endl;
            answers.pb(mp(a[j+1],a[j]));
            swap(a[j],a[j+1]);
            ans++;
        }

    }

    cout<<ans<<endl;
    for(int i=0;i<answers.size();i++){
        cout<<answers[i].first<<" "<<answers[i].second<<endl;
    }
}

int32_t main() {
    // fast io
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    // int t;
    // cin >> t;

    // while (t--) 
        solve();
}

Submission (verdict: Accepted):
#include<string>
#include<algorithm>
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define big 998244353
#define pb push_back
#define mp make_pair
#define forn for(int i=0;i<n;i++)
using namespace std;

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

    int b[n];
    forn cin>>b[i];

    int a[n];
    forn a[i]=i+1;

    int ans = 0;

    int effective_size = n;

    vector<pair <int,int>> answers;
    
    for(int i=n-1;i>=0;i--)
    {
        int ele = b[i];
        int loc;
        for(int j=0;j<n;j++)
        {
            if(a[j]==ele)
            {
                loc = j;
                break;
            }
        }

        // cout<<ele<<" is at "<<loc<<endl;

        for(int j=loc-1;j>=0;j--)
        {
            // cout<<ele<<" "<<a[j]<<endl;
            answers.pb(mp(a[j+1],a[j]));
            swap(a[j+1],a[j]);
            // cout<<"potato";
            ++ans;
        }

        for(int j=0;j<i;j++)
        {
            // cout<<a[j+1]<<" "<<a[j]<<endl;
            answers.pb(mp(a[j+1],a[j]));
            swap(a[j],a[j+1]);
            ans++;
        }

        // for(int j=0;j<n;j++)
        // cout<<a[j]<<" ";
        // cout<<endl;

    }

    cout<<ans<<endl;
    for(int i=0;i<answers.size();i++){
        cout<<answers[i].first<<" "<<answers[i].second<<endl;
    }
}

int32_t main() {
    // fast io
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    // int t;
    // cin >> t;

    // while (t--) 
        solve();
}
Problem: 2052A - Adrenaline Rush
Language: C++20 (GCC 13-64)


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

int  main()
{
     long long int  n,t=1,i,j,m,k;
    //cin >> t ;
    while(t--)
    {
    //string s;
    cin >> n ;
    long long int ans=0,a[n],b[n+1]={};
    char op;
    //pair<long long int,long long int>a[n];
    for(i=0;i<n;i++)
    {
      cin >> a[i] ;
      ans+=max(i-i,n-a[i]-i)+n-i-1;
    }
    cout << ans << "\n" ;
    for(i=0;i<n;i++)
    {
      //b[a[i]]++;
      for(j=a[i]+1;j<=n;j++)
      {
        if(b[j]==0)
        cout << j << " " << a[i] << "\n" ;
      }
      for(j=n;j>0;j--)
      {
        if(b[j]==0&&j!=a[i])
        cout << a[i] << " " << j << "\n" ;
      }
      b[a[i]]++;
    }
  }
  return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++20 (GCC 13-64)

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

int  main()
{
     long long int  n,t=1,i,j,m,k;
    //cin >> t ;
    while(t--)
    {
    //string s;
    cin >> n ;
    long long int ans=0,a[n],b[n+1]={};
    char op;
    //pair<long long int,long long int>a[n];
    for(i=0;i<n;i++)
    {
      cin >> a[i] ;
      ans+=max(i-i,n-a[i])+n-i-1;
    }
    cout << ans << "\n" ;
    for(i=0;i<n;i++)
    {
      //b[a[i]]++;
      for(j=a[i]+1;j<=n;j++)
      {
        if(b[j]==0)
        cout << j << " " << a[i] << "\n" ;
      }
      for(j=n;j>0;j--)
      {
        if(b[j]==0&&j!=a[i])
        cout << a[i] << " " << j << "\n" ;
      }
      b[a[i]]++;
    }
  }
  return 0;
}

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

int  main()
{
     long long int  n,t=1,i,j,m,k;
    //cin >> t ;
    while(t--)
    {
    //string s;
    cin >> n ;
    long long int ans=0,a[n],b[n+1]={},x;
    vector<long long int>c;
    char op;
    //pair<long long int,long long int>a[n];
    for(i=0;i<n;i++)
    {
      cin >> a[i] ;
      x=n-a[i];
      for(j=0;j<c.size()&&x;j++)
      {
        if(c[j]>a[i])
        x--;
      }
      ans+=x+n-i-1;
      c.push_back(a[i]);
    }
    cout << ans << "\n" ;
    for(i=0;i<n;i++)
    {
      //b[a[i]]++;
      for(j=a[i]+1;j<=n;j++)
      {
        if(b[j]==0)
        cout << j << " " << a[i] << "\n" ;
      }
      for(j=n;j>0;j--)
      {
        if(b[j]==0&&j!=a[i])
        cout << a[i] << " " << j << "\n" ;
      }
      b[a[i]]++;
    }
  }
  return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++20 (GCC 13-64)

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

int  main()
{
     long long int  n,t=1,i,j,m,k;
    //cin >> t ;
    while(t--)
    {
    //string s;
    cin >> n ;
    long long int ans=0,a[n],b[n+1]={};
    char op;
    //pair<long long int,long long int>a[n];
    for(i=0;i<n;i++)
    {
      cin >> a[i] ;
      ans+=max(i-i,n-a[i]-i)+n-i-1;
    }
    cout << ans << "\n" ;
    for(i=0;i<n;i++)
    {
      //b[a[i]]++;
      for(j=a[i]+1;j<=n;j++)
      {
        if(b[j]==0)
        cout << j << " " << a[i] << "\n" ;
      }
      for(j=n;j>0;j--)
      {
        if(b[j]==0&&j!=a[i])
        cout << a[i] << " " << j << "\n" ;
      }
      b[a[i]]++;
    }
  }
  return 0;
}

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

int  main()
{
     long long int  n,t=1,i,j,m,k;
    //cin >> t ;
    while(t--)
    {
    //string s;
    cin >> n ;
    long long int ans=0,a[n],b[n+1]={};
    char op;
    //pair<long long int,long long int>a[n];
    for(i=0;i<n;i++)
    {
      cin >> a[i] ;
      ans+=max(i-i,n-a[i])+n-i-1;
    }
    cout << ans << "\n" ;
    for(i=0;i<n;i++)
    {
      //b[a[i]]++;
      for(j=a[i]+1;j<=n;j++)
      {
        if(b[j]==0)
        cout << j << " " << a[i] << "\n" ;
      }
      for(j=n;j>0;j--)
      {
        if(b[j]==0&&j!=a[i])
        cout << a[i] << " " << j << "\n" ;
      }
      b[a[i]]++;
    }
  }
  return 0;
}
Problem: 2061D - Kevin and Numbers
Language: C++20 (GCC 13-64)


Submission (verdict: Memory limit exceeded on test 27):
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define lll _int128_t
#define vi vector<int>
#define vvi vector<vector<int>>
#define pb push_back
#define nl '\n'
template< typename typC> istream &operator>>(istream &cin,vector<typC> &a) {for (auto &x:a)cin>>x; return cin;}
template< typename typC> ostream &operator<<(ostream &cout,vector<typC> &a) {for (auto it:a)cout<<it<<" "; return cout;}
#define loop1(n) for(int i=0;i<n;i++)
#define loop2(a,b,i) for(int i=a;i<b;i++)
#define fast 	ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
void solve() {
    int n, m;
    cin >> n >> m;
    
    multiset<ll> a;
    vector<ll> b(m);

    ll sumA = 0;
    for (int i = 0; i < n; i++) {
        ll x;
        cin >> x;
        a.insert(x);
        sumA += x;
    }

    for (int i = 0; i < m; i++) {
        cin >> b[i];
    }

    sort(b.rbegin(), b.rend());

    for (ll bi : b) {
        if (bi > sumA) { 
            cout << "No\n"; 
            return;
        }

        priority_queue<ll> pq;
        pq.push(bi);
        bool possible = true;

        while (!pq.empty() && !a.empty()) {
            ll num = pq.top();
            pq.pop();

            auto it = a.find(num);
            if (it != a.end()) {
                a.erase(it); 
                sumA -= num;
                continue;
            }

            if (num == 1 || num < *a.begin()) { 
                possible = false;
                break;
            }
            ll left = num / 2;
            ll right = num - left;

            pq.push(left);
            pq.push(right);
        }

        if (!possible) {
            cout << "No\n";
            return;
        }
    }
      if(!a.empty()){
         cout << "No\n";
            return;
    }
    cout << "Yes\n";
}

int main(){
    fast;
    int t=1;
    cin>>t;
    while (t--){
        solve();
    }
}
Problem: 2057C - Trip to the Olympiad
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 2e5 + 9;
mt19937 rnd(time(0));
typedef long long ll;
typedef pair<int,int> pii;
const int mod = 1e9 + 7;
const int P = rnd() % mod;
void solve() {
    int l, r;
    cin >> l >> r;
    int k = 63 - __builtin_clz(l ^ r);
    int a = l | ((1 << k) - 1), b = a + 1, c = (a == l ? r : l);
    cout << a << " " << b << " " << c << "\n";
}
signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    cin >> t;
    while(t--) solve();
    return 0;
}

Submission (verdict: Accepted):
#include <bits/stdc++.h>
// #define int long long
using namespace std;
const int N = 2e5 + 9;
mt19937 rnd(time(0));
typedef long long ll;
typedef pair<int,int> pii;
const int mod = 1e9 + 7;
const int P = rnd() % mod;
void solve() {
    int l, r;
    cin >> l >> r;
    int k = 31 - __builtin_clz(l ^ r);
    int a = l | ((1 << k) - 1), b = a + 1, c = (a == l ? r : l);
    cout << a << " " << b << " " << c << "\n";
}
signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    cin >> t;
    while(t--) solve();
    return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 2e5 + 9;
mt19937 rnd(time(0));
typedef long long ll;
typedef pair<int,int> pii;
const int mod = 1e9 + 7;
const int P = rnd() % mod;
void solve() {
    int l , r; cin >> l >> r;
    int x = 0,ans = 0;
    for(int i = 32;i >= 0;i--) {
        if((1ll << i) & l == (1ll << i) & r) {
            x += ((1ll << i) & l) ^ (1ll << i);
        }
        else {
            if(x + (1ll << i) < r) x += (1ll << i);
        }
    }
    cout << l << " " << x << " " << r << "\n";
}
signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    cin >> t;
    while(t--) solve();
    return 0;
}

Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 2e5 + 9;
mt19937 rnd(time(0));
typedef long long ll;
typedef pair<int,int> pii;
const int mod = 1e9 + 7;
const int P = rnd() % mod;
void solve() {
    int l, r;
    cin >> l >> r;
    int k = 63 - __builtin_clz(l ^ r);
    int a = l | ((1 << k) - 1), b = a + 1, c = (a == l ? r : l);
    cout << a << " " << b << " " << c << "\n";
}
signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    cin >> t;
    while(t--) solve();
    return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 2e5 + 9;
mt19937 rnd(time(0));
typedef long long ll;
typedef pair<int,int> pii;
const int mod = 1e9 + 7;
const int P = rnd() % mod;
void solve() {
    int l , r; cin >> l >> r;
    int x = 0,ans = 0;
    for(int i = 32;i >= 0;i--) {
        if((1ll << i) & l == (1ll << i) & r) {
            x += ((1ll << i) & l) ^ (1ll << i);
        }
        else {
            if(x + (1ll << i) < r) x += (1ll << i);
        }
    }
    cout << l << " " << x << " " << r << "\n";
}
signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    cin >> t;
    while(t--) solve();
    return 0;
}
Problem: 2050C - Uninteresting Number
Language: C++23 (GCC 14-64, msys2)


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


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t;
    cin>>t;
    while(t--){
        string s;
        cin>>s;
        int tw=0,th=0,ss=0;
        bool f =true;
        for(int i=0;i<s.size();i++){
            ss+=int(s[i]-'0');
            if(s[i]=='2') tw++;
            if(s[i]=='3') th++;
        }
        int x=ss%9;
        if(x==0){
            cout<<"YES"<<endl;
            f=false;
        }
        else{
            for(int i=0;i<=min(tw,8);i++){
                for(int j=0;j<=min(th,8);j++){
                    int m;
                    m=x+(i)*2+(j)*6;
                    if(m%9==0){
                        cout<<"YES"<<endl;
                        f=false;
                        break;
                    }
                    m=0;
                }
            }

        }
        if(f==true) cout<<"NO"<<endl;

    }


    return 0;
}
Problem: 2050C - Uninteresting Number
Language: C++23 (GCC 14-64, msys2)

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


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t;
    cin>>t;
    while(t--){
        string s;
        cin>>s;
        int tw=0,th=0,ss=0;
        bool f =true;
        for(int i=0;i<s.size();i++){
            ss+=int(s[i]-'0');
            if(s[i]=='2') tw++;
            if(s[i]=='3') th++;
        }
        int x=ss%9;
        if(x==0){
            cout<<"YES"<<endl;
            f=false;
        }
        else{
            for(int i=0;i<=min(tw,8);i++){
                for(int j=0;j<=min(th,8);j++){
                    int m;
                    m=ss+(i)*2+(j)*6;
                    if(m%9==0){
                        cout<<"YES"<<endl;
                        f=false;
                        break;
                    }
                    m=0;
                }
            }

        }
        if(f==true) cout<<"NO"<<endl;

    }


    return 0;
}


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

using namespace std;

void solve() {
    string input;
    cin >> input;
    vector<int> s;

    for (char x : input) {
        s.push_back(x - '0');
    }

    int sm = 0;
    for (int num : s) {
        sm += num;
    }

    int twos = count(s.begin(), s.end(), 2);
    int threes = count(s.begin(), s.end(), 3);

    for (int i = 0; i <= min(9, twos); i++) {
        for (int j = 0; j <= min(9, threes); j++) {
            if ((sm + i * 2 + j * 6) % 9 == 0) {
                cout << "YES" << endl;
                return;
            }
        }
    }
    cout << "NO" << endl;
}

int main() {
    int t;
    cin >> t;
    for (int i = 0; i < t; i++) {
        solve();
    }
    return 0;
}
Problem: 2050C - Uninteresting Number
Language: C++23 (GCC 14-64, msys2)

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


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t;
    cin>>t;
    while(t--){
        string s;
        cin>>s;
        int tw=0,th=0,ss=0;
        bool f =true;
        for(int i=0;i<s.size();i++){
            ss+=int(s[i]-'0');
            if(s[i]=='2') tw++;
            if(s[i]=='3') th++;
        }
        int x=ss%9;
        if(x==0){
            cout<<"YES"<<endl;
            f=false;
        }
        else{
            for(int i=0;i<=min(tw,8);i++){
                for(int j=0;j<=min(th,8);j++){
                    int m;
                    m=x+(i)*2+(j)*6;
                    if(m%9==0){
                        cout<<"YES"<<endl;
                        f=false;
                        break;
                    }
                    m=0;
                }
            }

        }
        if(f==true) cout<<"NO"<<endl;

    }


    return 0;
}


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


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t;
    cin>>t;
    while(t--){
        string s;
        cin>>s;
        int tw=0,th=0,ss=0;
        bool f =true;
        for(int i=0;i<s.size();i++){
            ss+=int(s[i]-'0');
            if(s[i]=='2') tw++;
            if(s[i]=='3') th++;
        }
        int x=ss%9;
        if(x==0){
            cout<<"YES"<<endl;
            f=false;
        }
        else{
            for(int i=0;i<=min(tw,8);i++){
                for(int j=0;j<=min(th,8);j++){
                    int m;
                    m=ss+(i)*2+(j)*6;
                    if(m%9==0){
                        cout<<"YES"<<endl;
                        f=false;
                        break;
                    }
                    m=0;
                }
            }

        }
        if(f==true) cout<<"NO"<<endl;

    }


    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#define ll long long int
#define fr(i,j,n) for(i=j;i<n;i++)
#define srt(a) sort(a.begin(),a.end())
#define srtr(a) sort(a.begin(),a.end(),greater<ll>())
#define rvr(a) reverse(a.begin(),a.end())
#define rdp(a) a.resize(unique(a.begin(),a.end())-a.begin())
#define mxel(a) *max_element(a.begin(),a.end())
#define mnel(a) *min_element(a.begin(),a.end())
#define ve vector<ll>
#define vep vector<pair<ll,ll>>
#define vee vector<vector<ll>>
using namespace std;
template <typename T>
istream &operator>>(istream &is, vector<T> &v)
{
    for (auto &i : v)
        is >> i;
    return is;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> v)
{
    for (auto &i : v)
        os << i << ' ';
    return os;
}
const ll M=998244353;
const ll N=4e5+2;
void solve()
{
    ll n;cin >> n;ve a(n);cin >> a;ll i,ans,an=-N;if(n==1) {cout << a[0] << endl;return;}
    while(n){
        ans=0;fr(i,0,n) ans+=a[i];an=max(an,ans);
        fr(i,0,n)a[i]=a[i+1]-a[i];
        if(n==1) if(ans<0) an=max(an,-ans);
        n--;
    }
    cout << an << endl;
}
int main()
{
    ll testcase=1;
    cin >> testcase;
    while(testcase--) solve();
    return 0;
}


Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#define ll long long int
#define fr(i,j,n) for(i=j;i<n;i++)
#define srt(a) sort(a.begin(),a.end())
#define srtr(a) sort(a.begin(),a.end(),greater<ll>())
#define rvr(a) reverse(a.begin(),a.end())
#define rdp(a) a.resize(unique(a.begin(),a.end())-a.begin())
#define mxel(a) *max_element(a.begin(),a.end())
#define mnel(a) *min_element(a.begin(),a.end())
#define ve vector<ll>
#define vep vector<pair<ll,ll>>
#define vee vector<vector<ll>>
using namespace std;
template <typename T>
istream &operator>>(istream &is, vector<T> &v)
{
    for (auto &i : v)
        is >> i;
    return is;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> v)
{
    for (auto &i : v)
        os << i << ' ';
    return os;
}
const ll M=998244353;
const ll N=4e5+2;
void solve()
{
    ll n;cin >> n;ve a(n);cin >> a;ll i,ans,an=-N;if(n==1) {cout << a[0] << endl;return;}
    while(n){
        ans=0;fr(i,0,n) ans+=a[i];
        if(n==1)an=max(an,ans);
        else an=max(an,max(ans,(-ans)));
        fr(i,0,n)a[i]=(a[i+1]-a[i]);
        //if(n==1) if(ans<0) an=max(an,-ans);
        n--;
    }
    cout << an << endl;
}
int main()
{
    ll testcase=1;
    cin >> testcase;
    while(testcase--) solve();
    return 0;
}