ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2063B - Subsequence Update
Language: PyPy 3-64

Previous submission (verdict: Wrong answer on test 2):
from itertools import accumulate, pairwise

import math

import bisect

import heapq

from collections import Counter, defaultdict

from functools import cache

def solve():

    n, l, r = map(int, input().split())

    arr = [int(x) for x in input().split()]

    # 2 1 2 1 

    if l == 1 or r == n or r - l == 1:

        arr.sort()

        print(sum(arr[: r - l + 1]))

    else:

        # keep one element from arr[l: r] and r - l elements of smallest

        mn = math.inf

        idx = -1

        for i in range(l - 1, r):

            if arr[i] < mn:

                mn = arr[i]

                idx = i

        other = arr[:i] + arr[i + 1:]

        other.sort()

        print(mn + sum(other[: r- l]))

for _ in range(int(input())):

    solve()

Submission (verdict: Wrong answer on test 2):
from itertools import accumulate, pairwise
import math
import bisect
import heapq
from collections import Counter, defaultdict
from functools import cache
def solve():
    n, l, r = map(int, input().split())
    arr = [int(x) for x in input().split()]
    # 1 1 2 1 
    if l == 1 or r == n or r - l == 0:
        arr.sort()
        print(sum(arr[: r - l + 1]))
    else:
        # keep one element from arr[l: r] and r - l elements of smallest
        mn = math.inf
        idx = -1
        for i in range(l - 1, r):
            if arr[i] < mn:
                mn = arr[i]
                idx = i
        other = arr[:i] + arr[i + 1:]
        other.sort()
        print(mn + sum(other[: r - l]))
for _ in range(int(input())):
    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
#define endl "\n"
using namespace std;
const int N=2e5+5;
void solve(){
    int l,r,res=0,las;
    bool b=0;
    cin>>l>>r;
    if( (l^r)==(l+r) ){
        cout<<l<<' '<<l<<' '<<r<<endl;
        return;
    }
    for(int i=30;i>=0;i--){
        int x=((l>>i)&1);
        int y=((r>>i)&1);
        if(x==y){
            if(b)res+=((!x)<<i);
            else res+=(x<<i);
        }
        else{
            if(b){
                res+=(las<<i);
            }
            else{
                for(int j=i;j>=0;j--){
                    if( ((l>>j)&1)==((r>>j)&1) ){
                        las=!((l>>j)&1);
                        break;
                    }
                }
                res+=((!las)<<i);
                b=1;
            }
        }
    }
    cout<<l<<' '<<res<<' '<<r<<endl;
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    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
#define endl "\n"
using namespace std;
const int N=2e5+5;
void solve(){
    int l,r,res=0,las;
    bool b=0;
    cin>>l>>r;
    if( (l^r)==(l+r) ){
        cout<<l<<' '<<l+1<<' '<<r<<endl;
        return;
    }
    for(int i=30;i>=0;i--){
        int x=((l>>i)&1);
        int y=((r>>i)&1);
        if(x==y){
            if(b)res+=((!x)<<i);
            else res+=(x<<i);
        }
        else{
            if(b){
                res+=(las<<i);
            }
            else{
                for(int j=i;j>=0;j--){
                    if( ((l>>j)&1)==((r>>j)&1) ){
                        las=!((l>>j)&1);
                        break;
                    }
                }
                res+=((!las)<<i);
                b=1;
            }
        }
    }
    cout<<l<<' '<<res<<' '<<r<<endl;
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    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
#define endl "\n"
using namespace std;
const int N=2e5+5;
void solve(){
    int l,r,res;
    cin>>l>>r;
    for(int i=30;i>=0;i--){
        if((r>>i)&1){
            res=i;
            break;
        }
    }
    int tmp=0;
    for(int i=res;i>=0;i--)
        tmp+=(1ll<<i);
    cout<<0<<' '<<r<<' '<<(tmp^r)<<endl;
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    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
#define endl "\n"
using namespace std;
const int N=2e5+5;
void solve(){
    int l,r,res=0,las;
    bool b=0;
    cin>>l>>r;
    if( (l^r)==(l+r) ){
        cout<<l<<' '<<l<<' '<<r<<endl;
        return;
    }
    for(int i=30;i>=0;i--){
        int x=((l>>i)&1);
        int y=((r>>i)&1);
        if(x==y){
            if(b)res+=((!x)<<i);
            else res+=(x<<i);
        }
        else{
            if(b){
                res+=(las<<i);
            }
            else{
                for(int j=i;j>=0;j--){
                    if( ((l>>j)&1)==((r>>j)&1) ){
                        las=!((l>>j)&1);
                        break;
                    }
                }
                res+=((!las)<<i);
                b=1;
            }
        }
    }
    cout<<l<<' '<<res<<' '<<r<<endl;
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    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
#define endl "\n"
using namespace std;
const int N=2e5+5;
void solve(){
    int l,r,res;
    cin>>l>>r;
    for(int i=30;i>=0;i--){
        if((r>>i)&1){
            res=i;
            break;
        }
    }
    int tmp=0;
    for(int i=res;i>=0;i--)
        tmp+=(1ll<<i);
    cout<<0<<' '<<r<<' '<<(tmp^r)<<endl;
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    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
#define endl "\n"
using namespace std;
const int N=2e5+5;
void solve(){
    int l,r,res=0,las;
    bool b=0;
    cin>>l>>r;
    if( (l^r)==(l+r) ){
        cout<<l<<' '<<l+1<<' '<<r<<endl;
        return;
    }
    for(int i=30;i>=0;i--){
        int x=((l>>i)&1);
        int y=((r>>i)&1);
        if(x==y){
            if(b)res+=((!x)<<i);
            else res+=(x<<i);
        }
        else{
            if(b){
                res+=(las<<i);
            }
            else{
                for(int j=i;j>=0;j--){
                    if( ((l>>j)&1)==((r>>j)&1) ){
                        las=!((l>>j)&1);
                        break;
                    }
                }
                res+=((!las)<<i);
                b=1;
            }
        }
    }
    cout<<l<<' '<<res<<' '<<r<<endl;
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    int T=1;
    cin>>T;
    while(T--){
        solve();
    }
    return 0;
}

Submission (verdict: Accepted):
#include<bits/stdc++.h>
#define int long long
#define endl "\n"
using namespace std;
const int N=2e5+5;
void solve(){
    int l,r,res=0,las;
    bool b=0;
    cin>>l>>r;
    for(int i=30;i>=0;i--){
        int x=((l>>i)&1);
        int y=((r>>i)&1);
        if(x==y){
            if(b)res+=((!x)<<i);
            else res+=(x<<i);
        }
        else{
            if(b){
                res+=(las<<i);
            }
            else{
                for(int j=i;j>=0;j--){
                    if( ((l>>j)&1)==((r>>j)&1) ){
                        las=!((l>>j)&1);
                        break;
                    }
                }
                res+=((!las)<<i);
                b=1;
            }
        }
    }
    cout<<l<<' '<<res<<' '<<r<<endl;
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    int T=1;
    cin>>T;
    while(T--){
        solve();
    }
    return 0;
}
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
#define int long long
#define f(i, n1, n2) for (int i = n1; i < n2; i++)
#define fi(n1, n2) for (int i = n1; i < n2; i++)
#define ri(n1) for (int i = n1 - 1; i >= 0; i--)
#define in(nam) cin >> nam;
#define nin(nam) int nam; cin >> nam;
#define e endl;
#define out(nam) cout << nam << e
#define outar(n) for(auto it:n)cout<<it<<" "; 
#define v(n, i) vector<int> n(i);
#define vi(n) vector<int> n;
#define vin(nam)for(auto &i:nam)cin>>i;
#define map(name) map<int, int> name;
#define yon(ans) cout << ((ans) ? "YES" : "NO") << "\n";
#define all(a) a.begin(), a.end()
#define sorta(a) sort(a.begin(), a.end());
#define sortre(a) sort(a.rbegin(), a.rend());
using namespace std;
const int mod = 1e9 + 7;

void chance() {
    nin(n)
    if(n%9==0){
        yon(1)
        return;
    }

    int sum=0,tem=n,no2=0,no6=0;
    while(tem>0){
        int dig = tem%10;
        sum += dig; 
        if(dig==2)no2++;   
        if(dig==3)no6++;   
        tem/=10;
    }
    no2 = min(no2,9LL);
    no6 = min(no6,9LL);
    fi(0,no2+1) {
        f(j,0,no6+1) {
            int nsum = sum+ i*2+j*6;
            if (nsum%9==0) {
                yon(1) 
                return;
            }
        }
    }
    yon(0)
}

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int t = 1;
    in(t) // when t
    while (t--) {
        chance();
    }
    return 0;
}


Submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
#define int long long
#define f(i, n1, n2) for (int i = n1; i < n2; i++)
#define fi(n1, n2) for (int i = n1; i < n2; i++)
#define ri(n1) for (int i = n1 - 1; i >= 0; i--)
#define in(nam) cin >> nam;
#define nin(nam) int nam; cin >> nam;
#define e endl;
#define out(nam) cout << nam << e
#define outar(n) for(auto it:n)cout<<it<<" "; 
#define v(n, i) vector<int> n(i);
#define vi(n) vector<int> n;
#define vin(nam)for(auto &i:nam)cin>>i;
#define map(name) map<int, int> name;
#define yon(ans) cout << ((ans) ? "YES" : "NO") << "\n";
#define all(a) a.begin(), a.end()
#define sorta(a) sort(a.begin(), a.end());
#define sortre(a) sort(a.rbegin(), a.rend());
using namespace std;
const int mod = 1e9 + 7;

void chance() {
    nin(n)
    if(n%9==0){
        yon(1)
        return;
    }

    int sum=0,tem=n,no2=0,no6=0;
    while(tem>0){
        int dig = tem%10;
        sum += dig; 
        if(dig==2)no2++;   
        if(dig==3)no6++;   
        tem/=10;
    }

    no2 = min(no2,10LL);
    no6 = min(no6,10LL);
    fi(0,no2+1){
        f(j,0,no6+1) {
            int nsum = sum+ i*2+j*6;
            if (nsum%9==0) {
                yon(1) 
                return;
            }
        }
    }
    yon(0)
}

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int t = 1;
    in(t) // when t
    while (t--) {
        chance();
    }
    return 0;
}
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
#define int long long
#define f(i, n1, n2) for (int i = n1; i < n2; i++)
#define fi(n1, n2) for (int i = n1; i < n2; i++)
#define ri(n1) for (int i = n1 - 1; i >= 0; i--)
#define in(nam) cin >> nam;
#define nin(nam) int nam; cin >> nam;
#define e endl;
#define out(nam) cout << nam << e
#define outar(n) for(auto it:n)cout<<it<<" "; 
#define v(n, i) vector<int> n(i);
#define vi(n) vector<int> n;
#define vin(nam)for(auto &i:nam)cin>>i;
#define map(name) map<int, int> name;
#define yon(ans) cout << ((ans) ? "YES" : "NO") << "\n";
#define all(a) a.begin(), a.end()
#define sorta(a) sort(a.begin(), a.end());
#define sortre(a) sort(a.rbegin(), a.rend());
using namespace std;
const int mod = 1e9 + 7;

void chance() {
    nin(n)
    if(n%9==0){
        yon(1)
        return;
    }

    int sum=0,tem=n,no2=0,no6=0;
    while(tem>0){
        int dig = tem%10;
        sum += dig; 
        if(dig==2)no2++;   
        if(dig==3)no6++;   
        tem/=10;
    }

    // no2 = min(no2,10LL);
    // no6 = min(no6,10LL);
    fi(0,no2+1){
        f(j,0,no6+1) {
            int nsum = sum+ i*2+j*6;
            if (nsum%9==0) {
                yon(1) 
                return;
            }
        }
    }
    yon(0)
}

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int t = 1;
    in(t) // when t
    while (t--) {
        chance();
    }
    return 0;
}


Submission (verdict: Accepted):
#include <bits/stdc++.h>
#define int long long
#define f(i, n1, n2) for (int i = n1; i < n2; i++)
#define fi(n1, n2) for (int i = n1; i < n2; i++)
#define ri(n1) for (int i = n1 - 1; i >= 0; i--)
#define in(nam) cin >> nam;
#define nin(nam) int nam; cin >> nam;
#define e endl;
#define out(nam) cout << nam << e
#define outar(n) for(auto it:n)cout<<it<<" "; 
#define v(n, i) vector<int> n(i);
#define vi(n) vector<int> n;
#define vin(nam)for(auto &i:nam)cin>>i;
#define map(name) map<int, int> name;
#define yon(ans) cout << ((ans) ? "YES" : "NO") << "\n";
#define all(a) a.begin(), a.end()
#define sorta(a) sort(a.begin(), a.end());
#define sortre(a) sort(a.rbegin(), a.rend());
using namespace std;
const int mod = 1e9 + 7;

void chance() {
    string s;
    in(s);
    // nin(n)
    // if(n%9==0){
    //     yon(1)
    //     return;
    // }

    int sum=0,no2=0,no6=0;
    // while(tem>0){
    //     int dig = tem%10;
    //     sum += dig; 
    //     if(dig==2)no2++;   
    //     if(dig==3)no6++;   
    //     tem/=10;
    // }
    for(auto c:s){
        int dig = c-'0';
        sum += dig; 
        if(dig==2)no2++;   
        if(dig==3)no6++;   
    }

    fi(0,no2+1){
        f(j,0,no6+1) {
            int nsum = sum+ i*2+j*6;
            if (nsum%9==0) {
                yon(1) 
                return;
            }
        }
    }
    yon(0)
}

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int t = 1;
    in(t) // when t
    while (t--) {
        chance();
    }
    return 0;
}
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
#define int long long
#define f(i, n1, n2) for (int i = n1; i < n2; i++)
#define fi(n1, n2) for (int i = n1; i < n2; i++)
#define ri(n1) for (int i = n1 - 1; i >= 0; i--)
#define in(nam) cin >> nam;
#define nin(nam) int nam; cin >> nam;
#define e endl;
#define out(nam) cout << nam << e
#define outar(n) for(auto it:n)cout<<it<<" "; 
#define v(n, i) vector<int> n(i);
#define vi(n) vector<int> n;
#define vin(nam)for(auto &i:nam)cin>>i;
#define map(name) map<int, int> name;
#define yon(ans) cout << ((ans) ? "YES" : "NO") << "\n";
#define all(a) a.begin(), a.end()
#define sorta(a) sort(a.begin(), a.end());
#define sortre(a) sort(a.rbegin(), a.rend());
using namespace std;
const int mod = 1e9 + 7;

void chance() {
    nin(n)
    if(n%9==0){
        yon(1)
        return;
    }

    int sum=0,tem=n,no2=0,no6=0;
    while(tem>0){
        int dig = tem%10;
        sum += dig; 
        if(dig==2)no2++;   
        if(dig==3)no6++;   
        tem/=10;
    }
    no2 = min(no2,9LL);
    no6 = min(no6,9LL);
    fi(0,no2+1) {
        f(j,0,no6+1) {
            int nsum = sum+ i*2+j*6;
            if (nsum%9==0) {
                yon(1) 
                return;
            }
        }
    }
    yon(0)
}

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int t = 1;
    in(t) // when t
    while (t--) {
        chance();
    }
    return 0;
}
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
#define int long long
#define f(i, n1, n2) for (int i = n1; i < n2; i++)
#define fi(n1, n2) for (int i = n1; i < n2; i++)
#define ri(n1) for (int i = n1 - 1; i >= 0; i--)
#define in(nam) cin >> nam;
#define nin(nam) int nam; cin >> nam;
#define e endl;
#define out(nam) cout << nam << e
#define outar(n) for(auto it:n)cout<<it<<" "; 
#define v(n, i) vector<int> n(i);
#define vi(n) vector<int> n;
#define vin(nam)for(auto &i:nam)cin>>i;
#define map(name) map<int, int> name;
#define yon(ans) cout << ((ans) ? "YES" : "NO") << "\n";
#define all(a) a.begin(), a.end()
#define sorta(a) sort(a.begin(), a.end());
#define sortre(a) sort(a.rbegin(), a.rend());
using namespace std;
const int mod = 1e9 + 7;

void chance() {
    nin(n)
    if(n%9==0){
        yon(1)
        return;
    }

    int sum=0,tem=n,no2=0,no6=0;
    while(tem>0){
        int dig = tem%10;
        sum += dig; 
        if(dig==2)no2++;   
        if(dig==3)no6++;   
        tem/=10;
    }

    no2 = min(no2,10LL);
    no6 = min(no6,10LL);
    fi(0,no2+1){
        f(j,0,no6+1) {
            int nsum = sum+ i*2+j*6;
            if (nsum%9==0) {
                yon(1) 
                return;
            }
        }
    }
    yon(0)
}

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int t = 1;
    in(t) // when t
    while (t--) {
        chance();
    }
    return 0;
}


Submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
#define int long long
#define f(i, n1, n2) for (int i = n1; i < n2; i++)
#define fi(n1, n2) for (int i = n1; i < n2; i++)
#define ri(n1) for (int i = n1 - 1; i >= 0; i--)
#define in(nam) cin >> nam;
#define nin(nam) int nam; cin >> nam;
#define e endl;
#define out(nam) cout << nam << e
#define outar(n) for(auto it:n)cout<<it<<" "; 
#define v(n, i) vector<int> n(i);
#define vi(n) vector<int> n;
#define vin(nam)for(auto &i:nam)cin>>i;
#define map(name) map<int, int> name;
#define yon(ans) cout << ((ans) ? "YES" : "NO") << "\n";
#define all(a) a.begin(), a.end()
#define sorta(a) sort(a.begin(), a.end());
#define sortre(a) sort(a.rbegin(), a.rend());
using namespace std;
const int mod = 1e9 + 7;

void chance() {
    nin(n)
    if(n%9==0){
        yon(1)
        return;
    }

    int sum=0,tem=n,no2=0,no6=0;
    while(tem>0){
        int dig = tem%10;
        sum += dig; 
        if(dig==2)no2++;   
        if(dig==3)no6++;   
        tem/=10;
    }

    // no2 = min(no2,10LL);
    // no6 = min(no6,10LL);
    fi(0,no2+1){
        f(j,0,no6+1) {
            int nsum = sum+ i*2+j*6;
            if (nsum%9==0) {
                yon(1) 
                return;
            }
        }
    }
    yon(0)
}

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int t = 1;
    in(t) // when t
    while (t--) {
        chance();
    }
    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
#define ll long long
#define pi pair<int, int>
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define pb push_back
#define inf 1e9
using namespace std;

const int dim = 2e5+1, mod = 1e9+7;
int n, st, a[dim], aux[dim], i;

//void op1(int a[], int& st)
//{
//    reverse(a+st, a+n+1);
//}

void op2(int a[], int& st)
{
    int i;
    if (n-st+1 <= 1)
        return;
    st++;
    for (i = n; i >= st; i--)
        a[i] = a[i]-a[i-1];
//    cout << "a: ";
//    for (i = st; i <= n; i++)
//        cout << a[i] << ' ';
//    cout << endl;
}

ll sum(int a[], int& st)
{
    ll rez = 0;
    for (int i = st; i <= n; i++)
        rez += a[i];
    return rez;
}

void solve()
{
    cin >> n;
    st = 1;
    for (i = 1; i <= n; i++)
        cin >> a[i];//, aux[i] = a[i];
    ll rez = sum(a, st);
    for (i = 1; i < n; i++)
    {
        op2(a, st);
        rez = max(rez, abs(sum(a, st)));
    }
    cout << rez << '\n';
}

int main()
{
    ios_base::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++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
#define ll long long
#define pi pair<int, int>
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define pb push_back
#define inf 1e9
using namespace std;

const int dim = 2e5+1, mod = 1e9+7;
int n, st, a[dim], aux[dim], i;

//void op1(int a[], int& st)
//{
//    reverse(a+st, a+n+1);
//}

void op2(int a[], int& st)
{
    int i;
    if (n-st+1 <= 1)
        return;
    st++;
    for (i = n; i >= st; i--)
        a[i] = a[i]-a[i-1];
//    cout << "a: ";
//    for (i = st; i <= n; i++)
//        cout << a[i] << ' ';
//    cout << endl;
}

ll sum(int a[], int& st)
{
    ll rez = 0;
    for (int i = st; i <= n; i++)
        rez += a[i];
    return rez;
}

void solve()
{
    cin >> n;
    st = 1;
    for (i = 1; i <= n; i++)
        cin >> a[i];//, aux[i] = a[i];
    ll rez = sum(a, st);
    for (i = 1; i < n; i++)
    {
        op2(a, st);
        rez = max(rez, abs(sum(a, st)));
    }
    cout << rez << '\n';
}

int main()
{
    ios_base::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>
#define ll long long
#define pi pair<int, int>
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define pb push_back
#define inf 1e9
using namespace std;

const int dim = 2e5+1, mod = 1e9+7;
int n, st, a[dim], aux[dim], i;

//void op1(int a[], int& st)
//{
//    reverse(a+st, a+n+1);
//}

void op2(int a[], int& st)
{
    int i;
    if (n-st+1 <= 1)
        return;
    st++;
    for (i = n; i >= st; i--)
        a[i] = a[i]-a[i-1];
//    cout << "a: ";
//    for (i = st; i <= n; i++)
//        cout << a[i] << ' ';
//    cout << endl;
}

ll sum(int a[], int& st)
{
    ll rez = 0;
    for (int i = st; i <= n; i++)
        rez += a[i];
    if (n > 1)
        return abs(rez);
    return rez;
}

void solve()
{
    cin >> n;
    st = 1;
    for (i = 1; i <= n; i++)
        cin >> a[i];//, aux[i] = a[i];
    ll rez = sum(a, st);
    while (n-st+1 > 1)
    {
        op2(a, st);
        rez = max(rez, sum(a, st));
    }
    cout << rez << '\n';
}

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