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 <bits/stdc++.h>
#include <queue>
#include <unordered_set>
#include <set>
#include <map>
#include <chrono>
 
using namespace std;
 
#define se second
#define fi first
#define pb push_back
 
#define all(v) v.begin(),v.end()
#define loop(n) for(int i = 0; i < n; i++)
#define forn(i,st, n) for (int i = st; i < int(n); i++)
#define ll long long 
#define ld long double
#define ull unsigned long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define umii unordered_map<int,int,custom_hash>
#define umll unordered_map<ll,ll,custom_hash>
#define vpii vector<pii>
#define vvi vector<vector<int>>
#define vvc vector<vector<char>>
#define mem(a,b) memset(a, b, sizeof(a))
 
#define lz(x) __builtin_clz(x) // gives no. of leading zeros
#define tz(x) __builtin_ctz(x)
#define popc(x) __builtin_popcount(x)
#define setbits(x) __builtin_popcountll(x)
#define msb(x) 63 - __builtin_clzll(x)
#define lsb(x) __builtin_ctzll(x)
#define parity(x) __builtin_parity(x) // return 1 if odd no. of setbits else 0
 
#define input(v) for(auto &it:v)cin>>it 
#define output(v) for(auto &it:v)cout<<it<<" "
#define fast ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
 
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
 
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
 
//-------------------------------------- Start_Here ------------------------------------------------------------------------------------------------
 
 
void solve(){
    ll l, r;
    cin >> l >> r;

    ll a, b,c;

    ll m = 31 - lz(l ^ r);

    int k = 0;
    while ((1LL << k) <= r) k++;
    k--;

    if((1LL << k) < l ){
        a = l;
    }
    else{
        a = (1LL << k);
    }

    c = r;

    b = l | (1LL<<m) - 1;


    
  cout<<a<<" " <<b<<" "<<c<<endl;
}
 
int main() {
    fast;
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)


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

int mod=1e9+7;

int32_t main(){
	int t;
	cin>>t;

	while(t--){
		int l,r;
        cin>>l>>r;
        int x,z;

        for(int i=r; i>=l; i--){
            if((i & i-1)==0){
                x=i;
                break;
            } 
        }

        for(int i=r; i>=l; i--){
            if(i!=x || i!=x-1){
                z=i;
                break;
            } 
        }

        cout<<x<<" "<<x-1<<" "<<z<<endl;
	}
	
	return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)

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

int mod=1e9+7;

int32_t main(){
	int t;
	cin>>t;

	while(t--){
		int l,r;
        cin>>l>>r;
        int x,z;

        for(int i=r; i>=l; i--){
            if((i & i-1)==0){
                x=i;
                break;
            } 
        }

        for(int i=r; i>=l; i--){
            if(i!=x && i!=x-1){
                z=i;
                break;
            } 
        }

        cout<<x<<" "<<x-1<<" "<<z<<endl;
	}
	
	return 0;
}

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

int mod=1e9+7;

int32_t main(){
	int t;
	cin>>t;

	while(t--){
		int l,r;
        cin>>l>>r;
        int x,z, ans=0;

        for(int i=30; i>=0; i--){
            int b1=0, b2=0;

            if(l & (1LL<<i)) b1=1; 
            if(r & (1LL<<i)) b2=1; 

            if(b1==b2){
                ans+=b1 * (1LL<<i);
            }

            else{
                x=ans+ (1LL<<i);
                break;
            }
        }

        for(int i=r; i>=l; i--){
            if(i!=x && i!=x-1){
                z=i;
                break;
            } 
        }

        cout<<x<<" "<<x-1<<" "<<z<<endl;
	}
	
	return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)

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

int mod=1e9+7;

int32_t main(){
	int t;
	cin>>t;

	while(t--){
		int l,r;
        cin>>l>>r;
        int x,z;

        for(int i=r; i>=l; i--){
            if((i & i-1)==0){
                x=i;
                break;
            } 
        }

        for(int i=r; i>=l; i--){
            if(i!=x || i!=x-1){
                z=i;
                break;
            } 
        }

        cout<<x<<" "<<x-1<<" "<<z<<endl;
	}
	
	return 0;
}

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

int mod=1e9+7;

int32_t main(){
	int t;
	cin>>t;

	while(t--){
		int l,r;
        cin>>l>>r;
        int x,z;

        for(int i=r; i>=l; i--){
            if((i & i-1)==0){
                x=i;
                break;
            } 
        }

        for(int i=r; i>=l; i--){
            if(i!=x && i!=x-1){
                z=i;
                break;
            } 
        }

        cout<<x<<" "<<x-1<<" "<<z<<endl;
	}
	
	return 0;
}
Problem: 2063C - Remove Exactly Two
Language: PyPy 3-64


Submission (verdict: Time limit exceeded on test 23):
"""
For God so loved the world that he gave his one and only Son, 
that whoever believes in him shall not perish but have eternal life.
JOHN 3:16 
"""
import random
from math import *
from functools import lru_cache
from itertools import accumulate
from fractions import Fraction
from bisect import bisect_left as bl
from bisect import bisect_right as br
from operator import itemgetter
from collections import Counter,deque,defaultdict
from heapq import heappop as hpop, heappush as hpush
# constants
p = 10**9 + 7 
ANS = ['NO','YES']
import sys
input = sys.stdin.readline
output = sys.stdout.write
#sys.setrecursionlimit(110000)
# #For large input
# input = sys.stdin.read
# data = input().split()
# Shortcut for input()
def I(): return int(input())
def S(): return input().strip()
def F(): return float(input())
def MI(): return map(int, input().split())
def MS(): return map(str, input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int, input().split()))
def LS(): return list(map(str, input().split()))
def LF(): return list(map(float , input().split()))
# Shortcut for output()
res = []
def OI(res): output("\n".join(res))
def OL(res): output("\n".join(" ".join(i) for i in res))






t = I()
while t:
    n = I()
    deg = [0]*n
    g = defaultdict(set)
    for _ in range(n-1):
        u,v = MI()
        g[u-1].add(v-1)
        g[v-1].add(u-1)
        deg[u-1]+=1
        deg[v-1]+=1
    ans = 0
    #when nodes are adjacent
    for node in g:
        for child in g[node]:
            ans = max(ans,deg[node] + deg[child]-2)
    #when two nodes are not adjacent
    s = sorted([(deg[i],i) for i in range(n)],reverse = 1)
    for _,node1 in s:
        for _,node2 in s:
            if node1 == node2 or node1 in g[node2]: continue
            ans = max(ans, deg[node1] + deg[node2] - 1)
            break
    print(ans)
    t-=1
Problem: 2049B - pspspsps
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 2):
// **************** MBRAHUL *************** 

#include<bits/stdc++.h>

#define ll long long

#define pn cout<<"NO"<<endl

#define py cout<<"YES"<<endl

#define vll vector<long long>

#define vi vector<int>

#define vb vector<bool>

#define u_map unordered_map

#define pll pair<long long,long long>

#define pii pair<int,int>

#define inf INT_MAX

#define pb push_back

#define mod 998244353

#define MOD 1000000007

#define ld long double

#define ff first

#define ss second

#define all(v) v.begin(),v.end()

#define min3(a, b, c) min(c, min(a, b))

#define min4(a, b, c, d) min(d, min(c, min(a, b)))

#define loop(i,n) for(int i=0;i<n;i++)

#define rloop(i, n) for(int i=n-1;i>=0;i--)

using namespace std;



void input(vector<ll>&arr,ll n){

for(ll i =0;i<n;i++)cin>>arr[i];

}



void printArr(vector<ll>&arr, ll i,ll j){

for(ll k = i;k<=j;k++)cout<<arr[k]<<" ";

cout<<endl; 

}



void find(){

  int n;

  string str;

  cin>>n>>str;

  set<char>s;

  for(auto c:str)s.insert(c);

  if(s.size()==1){

    py;

    return;

  }

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

    if(str[i]=='s' || str[i]=='.')continue;

    else{

      pn;

      return;

    }

  }

  py;

}



int main(){

ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);

ll test=1;

cin>>test;

while(test--){

find();

}

return 0;

}
Problem: 2049B - pspspsps
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
// **************** MBRAHUL *************** 

#include<bits/stdc++.h>

#define ll long long

#define pn cout<<"NO"<<endl

#define py cout<<"YES"<<endl

#define vll vector<long long>

#define vi vector<int>

#define vb vector<bool>

#define u_map unordered_map

#define pll pair<long long,long long>

#define pii pair<int,int>

#define inf INT_MAX

#define pb push_back

#define mod 998244353

#define MOD 1000000007

#define ld long double

#define ff first

#define ss second

#define all(v) v.begin(),v.end()

#define min3(a, b, c) min(c, min(a, b))

#define min4(a, b, c, d) min(d, min(c, min(a, b)))

#define loop(i,n) for(int i=0;i<n;i++)

#define rloop(i, n) for(int i=n-1;i>=0;i--)

using namespace std;



void input(vector<ll>&arr,ll n){

for(ll i =0;i<n;i++)cin>>arr[i];

}



void printArr(vector<ll>&arr, ll i,ll j){

for(ll k = i;k<=j;k++)cout<<arr[k]<<" ";

cout<<endl; 

}



void find(){

  int n;

  string str;

  cin>>n>>str;

  set<char>st;

  for(auto c:str)if(c!='.')st.insert(c);

  if(st.size()<=1){

    py;

    return;

  }

  int s=0,p=0;

  for(auto c:str){

    if(c=='s')s++;

    else if(c=='p')p++;

  }

  if(s==1 || p==1){

    if(s==1){

      if(str[0]=='s')py;

      else pn;

    }

    else{

      if(str.back()=='p')py;

      else pn;

    }

  }

  else pn;

}



int main(){

ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);

ll test=1;

cin>>test;

while(test--){

find();

}

return 0;

}

Submission (verdict: Accepted):
// **************** MBRAHUL *************** 

#include<bits/stdc++.h>

#define ll long long

#define pn cout<<"NO"<<endl

#define py cout<<"YES"<<endl

#define vll vector<long long>

#define vi vector<int>

#define vb vector<bool>

#define u_map unordered_map

#define pll pair<long long,long long>

#define pii pair<int,int>

#define inf INT_MAX

#define pb push_back

#define mod 998244353

#define MOD 1000000007

#define ld long double

#define ff first

#define ss second

#define all(v) v.begin(),v.end()

#define min3(a, b, c) min(c, min(a, b))

#define min4(a, b, c, d) min(d, min(c, min(a, b)))

#define loop(i,n) for(int i=0;i<n;i++)

#define rloop(i, n) for(int i=n-1;i>=0;i--)

using namespace std;



void input(vector<ll>&arr,ll n){

for(ll i =0;i<n;i++)cin>>arr[i];

}



void printArr(vector<ll>&arr, ll i,ll j){

for(ll k = i;k<=j;k++)cout<<arr[k]<<" ";

cout<<endl; 

}



void find(){

  int n;

  string str;

  cin>>n>>str;

  set<char>st;

  for(auto c:str)if(c!='.')st.insert(c);

  if(st.size()<=1){

    py;

    return;

  }

  int s=0,p=0;

  for(auto c:str){

    if(c=='s')s++;

    else if(c=='p')p++;

  }

  if(s==1 || p==1){

    if(s==1 && p==1){

      if(str.back()=='p' || str[0]=='s')py;

      else pn;

    }

    else if(s==1){

      if(str[0]=='s')py;

      else pn;

    }

    else{

      if(str.back()=='p')py;

      else pn;

    }

  }

  else pn;

}



int main(){

ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);

ll test=1;

cin>>test;

while(test--){

find();

}

return 0;

}
Problem: 2049B - pspspsps
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
// **************** MBRAHUL *************** 

#include<bits/stdc++.h>

#define ll long long

#define pn cout<<"NO"<<endl

#define py cout<<"YES"<<endl

#define vll vector<long long>

#define vi vector<int>

#define vb vector<bool>

#define u_map unordered_map

#define pll pair<long long,long long>

#define pii pair<int,int>

#define inf INT_MAX

#define pb push_back

#define mod 998244353

#define MOD 1000000007

#define ld long double

#define ff first

#define ss second

#define all(v) v.begin(),v.end()

#define min3(a, b, c) min(c, min(a, b))

#define min4(a, b, c, d) min(d, min(c, min(a, b)))

#define loop(i,n) for(int i=0;i<n;i++)

#define rloop(i, n) for(int i=n-1;i>=0;i--)

using namespace std;



void input(vector<ll>&arr,ll n){

for(ll i =0;i<n;i++)cin>>arr[i];

}



void printArr(vector<ll>&arr, ll i,ll j){

for(ll k = i;k<=j;k++)cout<<arr[k]<<" ";

cout<<endl; 

}



void find(){

  int n;

  string str;

  cin>>n>>str;

  set<char>s;

  for(auto c:str)if(c!='.')s.insert(c);

  if(s.size()<=1){

    py;

    return;

  }

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

    if(str[i]=='s' || str[i]=='.')continue;

    else{

      pn;

      return;

    }

  }

  py;

}



int main(){

ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);

ll test=1;

cin>>test;

while(test--){

find();

}

return 0;

}

Submission (verdict: Wrong answer on test 2):
// **************** MBRAHUL *************** 

#include<bits/stdc++.h>

#define ll long long

#define pn cout<<"NO"<<endl

#define py cout<<"YES"<<endl

#define vll vector<long long>

#define vi vector<int>

#define vb vector<bool>

#define u_map unordered_map

#define pll pair<long long,long long>

#define pii pair<int,int>

#define inf INT_MAX

#define pb push_back

#define mod 998244353

#define MOD 1000000007

#define ld long double

#define ff first

#define ss second

#define all(v) v.begin(),v.end()

#define min3(a, b, c) min(c, min(a, b))

#define min4(a, b, c, d) min(d, min(c, min(a, b)))

#define loop(i,n) for(int i=0;i<n;i++)

#define rloop(i, n) for(int i=n-1;i>=0;i--)

using namespace std;



void input(vector<ll>&arr,ll n){

for(ll i =0;i<n;i++)cin>>arr[i];

}



void printArr(vector<ll>&arr, ll i,ll j){

for(ll k = i;k<=j;k++)cout<<arr[k]<<" ";

cout<<endl; 

}



void find(){

  int n;

  string str;

  cin>>n>>str;

  set<char>st;

  for(auto c:str)if(c!='.')st.insert(c);

  if(st.size()<=1){

    py;

    return;

  }

  int s=0,p=0;

  for(auto c:str){

    if(c=='s')s++;

    else if(c=='p')p++;

  }

  if(s==1 || p==1){

    if(s==1){

      if(str[0]=='s')py;

      else pn;

    }

    else{

      if(str.back()=='p')py;

      else pn;

    }

  }

  else pn;

}



int main(){

ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);

ll test=1;

cin>>test;

while(test--){

find();

}

return 0;

}
Problem: 2049B - pspspsps
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
// **************** MBRAHUL *************** 

#include<bits/stdc++.h>

#define ll long long

#define pn cout<<"NO"<<endl

#define py cout<<"YES"<<endl

#define vll vector<long long>

#define vi vector<int>

#define vb vector<bool>

#define u_map unordered_map

#define pll pair<long long,long long>

#define pii pair<int,int>

#define inf INT_MAX

#define pb push_back

#define mod 998244353

#define MOD 1000000007

#define ld long double

#define ff first

#define ss second

#define all(v) v.begin(),v.end()

#define min3(a, b, c) min(c, min(a, b))

#define min4(a, b, c, d) min(d, min(c, min(a, b)))

#define loop(i,n) for(int i=0;i<n;i++)

#define rloop(i, n) for(int i=n-1;i>=0;i--)

using namespace std;



void input(vector<ll>&arr,ll n){

for(ll i =0;i<n;i++)cin>>arr[i];

}



void printArr(vector<ll>&arr, ll i,ll j){

for(ll k = i;k<=j;k++)cout<<arr[k]<<" ";

cout<<endl; 

}



void find(){

  int n;

  string str;

  cin>>n>>str;

  set<char>s;

  for(auto c:str)s.insert(c);

  if(s.size()==1){

    py;

    return;

  }

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

    if(str[i]=='s' || str[i]=='.')continue;

    else{

      pn;

      return;

    }

  }

  py;

}



int main(){

ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);

ll test=1;

cin>>test;

while(test--){

find();

}

return 0;

}

Submission (verdict: Wrong answer on test 2):
// **************** MBRAHUL *************** 

#include<bits/stdc++.h>

#define ll long long

#define pn cout<<"NO"<<endl

#define py cout<<"YES"<<endl

#define vll vector<long long>

#define vi vector<int>

#define vb vector<bool>

#define u_map unordered_map

#define pll pair<long long,long long>

#define pii pair<int,int>

#define inf INT_MAX

#define pb push_back

#define mod 998244353

#define MOD 1000000007

#define ld long double

#define ff first

#define ss second

#define all(v) v.begin(),v.end()

#define min3(a, b, c) min(c, min(a, b))

#define min4(a, b, c, d) min(d, min(c, min(a, b)))

#define loop(i,n) for(int i=0;i<n;i++)

#define rloop(i, n) for(int i=n-1;i>=0;i--)

using namespace std;



void input(vector<ll>&arr,ll n){

for(ll i =0;i<n;i++)cin>>arr[i];

}



void printArr(vector<ll>&arr, ll i,ll j){

for(ll k = i;k<=j;k++)cout<<arr[k]<<" ";

cout<<endl; 

}



void find(){

  int n;

  string str;

  cin>>n>>str;

  set<char>s;

  for(auto c:str)if(c!='.')s.insert(c);

  if(s.size()<=1){

    py;

    return;

  }

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

    if(str[i]=='s' || str[i]=='.')continue;

    else{

      pn;

      return;

    }

  }

  py;

}



int main(){

ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);

ll test=1;

cin>>test;

while(test--){

find();

}

return 0;

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


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

#define max(a, b) ((a > b) ? a : b)

using namespace std;

long long a[59];
int tmp[59];

int t;
int n;

long long res = 0;
long long sum;

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

    cin >> t;

    while (t--)
    {
        cin >> n;

        res = LONG_LONG_MIN;

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

        int k = n;

        while (k--)
        {
            sum = 0;

            for (int i = 0; i < n; i++) sum += a[i];

            res = max(res, sum);
            if (k > 1) res = max(res, -sum);
            n--;

            for (int i = 0; i < n; i++) a[i] = a[i + 1] - a[i];
        }

        cout << res << '\n';
    }

    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>

#define max(a, b) ((a > b) ? a : b)

using namespace std;

long long a[59];
int tmp[59];

int t;
int n;

long long res = 0;
long long sum;

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

    cin >> t;

    while (t--)
    {
        cin >> n;

        res = LONG_LONG_MIN;

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

        int k = n;

        for (int j = 0; j < k; j++)
        {
            sum = 0;

            for (int i = 0; i < n; i++) sum += a[i];

            res = max(res, sum);
            if (k > 1) res = max(res, -sum);
            n--;

            for (int i = 0; i < n; i++) a[i] = a[i + 1] - a[i];
        }

        cout << res << '\n';
    }

    return 0;
}

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

#define max(a, b) ((a > b) ? a : b)

using namespace std;

long long a[59];
int tmp[59];

int t;
int n;

long long res = 0;
long long sum;

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

    cin >> t;

    while (t--)
    {
        cin >> n;

        res = LONG_LONG_MIN;

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

        int k = n;

        for (int j = 0; j < k; j++)
        {
            sum = 0;

            for (int i = 0; i < n; i++) sum += a[i];

            res = max(res, sum);
            if (j > 0) res = max(res, -sum);
            n--;

            for (int i = 0; i < n; i++) a[i] = a[i + 1] - a[i];
        }

        cout << res << '\n';
    }

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

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

#define max(a, b) ((a > b) ? a : b)

using namespace std;

long long a[59];
int tmp[59];

int t;
int n;

long long res = 0;
long long sum;

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

    cin >> t;

    while (t--)
    {
        cin >> n;

        res = LONG_LONG_MIN;

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

        int k = n;

        while (k--)
        {
            sum = 0;

            for (int i = 0; i < n; i++) sum += a[i];

            res = max(res, sum);
            if (k > 1) res = max(res, -sum);
            n--;

            for (int i = 0; i < n; i++) a[i] = a[i + 1] - a[i];
        }

        cout << res << '\n';
    }

    return 0;
}

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

#define max(a, b) ((a > b) ? a : b)

using namespace std;

long long a[59];
int tmp[59];

int t;
int n;

long long res = 0;
long long sum;

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

    cin >> t;

    while (t--)
    {
        cin >> n;

        res = LONG_LONG_MIN;

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

        int k = n;

        for (int j = 0; j < k; j++)
        {
            sum = 0;

            for (int i = 0; i < n; i++) sum += a[i];

            res = max(res, sum);
            if (k > 1) res = max(res, -sum);
            n--;

            for (int i = 0; i < n; i++) a[i] = a[i + 1] - a[i];
        }

        cout << res << '\n';
    }

    return 0;
}