ShaysXIA/CodeInsightBench huggingface dataset:
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;



#ifdef APPLE

#include <competitive/debug>

#else

#define debug(...) void()

#endif



template<typename T> bool chmax(T &a, const T &b) { return (b > a ? a = b, true : false); }

template<typename T> bool chmin(T &a, const T &b) { return (b < a ? a = b, true : false); }



using i64 = int64_t;



int main() {

  ios::sync_with_stdio(false);

  cin.tie(nullptr);



  int tt;

  cin >> tt;

  

  while (tt--) {

    int n, l, r;

    cin >> n >> l >> r;



    vector<int> a(n);

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

      cin >> a[i];

    }



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

    i64 sum = 0;

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

      sum += a[i];

    }



    cout << sum << '\n';

  }

}

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

using namespace std;



#ifdef APPLE

#include <competitive/debug>

#else

#define debug(...) void()

#endif



template<typename T> bool chmax(T &a, const T &b) { return (b > a ? a = b, true : false); }

template<typename T> bool chmin(T &a, const T &b) { return (b < a ? a = b, true : false); }



using i64 = int64_t;



int main() {

  ios::sync_with_stdio(false);

  cin.tie(nullptr);



  int tt;

  cin >> tt;

  

  while (tt--) {

    int n, l, r;

    cin >> n >> l >> r;



    l--; r--;



    vector<int> in, out;

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

      int x;

      cin >> x;

      if (l <= i && i <= r) {

        in.push_back(x);

      }

      else {

        out.push_back(x);

      }

    }



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

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



    for (int i = 0, j = in.size()-1; i < (int)out.size() && j >= 0; i++) {

      if (out[i] < in[j]) {

        swap(out[i], in[j]);

        j--;

      }

    }



    cout << accumulate(in.begin(), in.end(), 0LL) << '\n';

  }

}
Problem: 2063B - Subsequence Update
Language: C++20 (GCC 13-64)


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

using namespace std;



#ifdef APPLE

#include <competitive/debug>

#else

#define debug(...) void()

#endif



template<typename T> bool chmax(T &a, const T &b) { return (b > a ? a = b, true : false); }

template<typename T> bool chmin(T &a, const T &b) { return (b < a ? a = b, true : false); }



using i64 = int64_t;



int main() {

  ios::sync_with_stdio(false);

  cin.tie(nullptr);



  int tt;

  cin >> tt;

  

  while (tt--) {

    int n, l, r;

    cin >> n >> l >> r;



    vector<int> a(n);

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

      cin >> a[i];

    }



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

    i64 sum = 0;

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

      sum += a[i];

    }



    cout << sum << '\n';

  }

}
Problem: 2063B - Subsequence Update
Language: PyPy 3-64

Previous submission (verdict: Wrong answer on test 2):
t=int(input())

for case in range(t):

    s=0

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

    seq=list(map(int,input().split()))

    seg=list(seq[l-1:r])

    exseg=list(seq[:l-1])

    exseg.extend(list(seq[r:]))

    seg.append(0)

    s=sum(seg)

    if len(exseg)!=0:

        while min(exseg)<max(seg):

            a=min(exseg)

            b=max(seg)

            s=s-b+a

            seg.remove(b)

            exseg.remove(a)

            if len(exseg)==0:

                break

    print(s)

Submission (verdict: Compilation error):
t=int(input())

for case in range(t):

    s=0

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

    seq=list(map(int,input().split()))

    seg=list(seq[l-1:r])

    exseg=list(seq[:l-1])

    exseg.extend(list(seq[r:]))

    seg.append(0)

    s=sum(seg)

    if len(exseg)!=0:

        while min(exseg)<max(seg):

            a=min(exseg)

            b=max(seg)

            s=s-b+a

            seg.remove(b)

            exseg.remove(a)

            if len(exseg)==0:

                break

    print(s
Problem: 2063B - Subsequence Update
Language: PyPy 3-64


Submission (verdict: Wrong answer on test 2):
t=int(input())

for case in range(t):

    s=0

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

    seq=list(map(int,input().split()))

    seg=list(seq[l-1:r])

    exseg=list(seq[:l-1])

    exseg.extend(list(seq[r:]))

    seg.append(0)

    s=sum(seg)

    if len(exseg)!=0:

        while min(exseg)<max(seg):

            a=min(exseg)

            b=max(seg)

            s=s-b+a

            seg.remove(b)

            exseg.remove(a)

            if len(exseg)==0:

                break

    print(s)
Problem: 2063B - Subsequence Update
Language: PyPy 3-64

Previous submission (verdict: Compilation error):
t=int(input())

for case in range(t):

    s=0

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

    seq=list(map(int,input().split()))

    seg=list(seq[l-1:r])

    exseg=list(seq[:l-1])

    exseg.extend(list(seq[r:]))

    seg.append(0)

    s=sum(seg)

    if len(exseg)!=0:

        while min(exseg)<max(seg):

            a=min(exseg)

            b=max(seg)

            s=s-b+a

            seg.remove(b)

            exseg.remove(a)

            if len(exseg)==0:

                break

    print(s

Submission (verdict: Accepted):
t=int(input())

for case in range(t):

    s=0

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

    seq=list(map(int,input().split()))

    a=seq[:l-1]+sorted(seq[l-1:])

    b=sorted(seq[:r])[::-1]+seq[r:]

    print(min(sum(a[l-1:r]),sum(b[l-1:r])))
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 unsigned long long

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

	vector<bool> bitsl, bitsr;

	
	for(Int temp=l;temp!=0; temp /=2)
		bitsl.push_back(temp%2);
	
	for(Int temp=r;temp!=0; temp /=2)
		bitsr.push_back(temp%2);
	
	int firstdiff;
	Int prefix=0;
	for(int i=max(bitsl.size(), bitsr.size()); i>=0; i--){
		if(i>bitsl.size()-1 || i>bitsr.size()-1){
			firstdiff = i;
			break;
		}
		else if(bitsl[i]!=bitsr[i]){
			firstdiff = i;
			break;
		}
		else
			prefix = 2*prefix+bitsl[i];
	}
	
	Int x=prefix+(Int)pow(2, firstdiff);
	Int y=x-1;

	Int z;
	if(l!=y) z=l;
	else if(l) z=l+2;

	cout << x << " "<<y << " "<<z<<endl;
	// cout << (x^y)+(y^z)+(z^x) << " "<<2*((Int)pow(2,firstdiff+1)-1)<<endl;
	// cout << endl;
}

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

	for(int i=0; i<t; i++){
		solve();
	}
}


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

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

	vector<bool> bitsl, bitsr;

	
	for(Int temp=l;temp!=0; temp /=2)
		bitsl.push_back(temp%2);
	
	for(Int temp=r;temp!=0; temp /=2)
		bitsr.push_back(temp%2);
	
	int firstdiff;
	Int prefix=0;
	for(int i=max(bitsl.size(), bitsr.size()); i>=0; i--){
		if(i>bitsl.size()-1 || i>bitsr.size()-1){
			firstdiff = i;
			break;
		}
		else if(bitsl[i]!=bitsr[i]){
			firstdiff = i;
			break;
		}
		else
			prefix = 2*prefix+bitsl[i];
	}
	
	Int x=prefix+(Int)pow(2, firstdiff-1);
	Int y=x-1;

	Int z;
	if(l!=y) z=l;
	else if(l) z=l+2;

	cout << x << " "<<y << " "<<z<<endl;
	cout << (x^y)+(y^z)+(z^x) << " "<<2*((Int)pow(2,firstdiff)-1)<<endl;
	cout << endl;
}

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

	for(int i=0; i<t; i++){
		solve();
	}
}
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 unsigned long long

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

	vector<bool> bitsl, bitsr;

	
	for(Int temp=l;temp!=0; temp /=2)
		bitsl.push_back(temp%2);
	
	for(Int temp=r;temp!=0; temp /=2)
		bitsr.push_back(temp%2);
	
	int firstdiff;
	Int prefix=0;
	for(int i=max(bitsl.size(), bitsr.size()); i>=0; i--){
		if(i>bitsl.size()-1 || i>bitsr.size()-1){
			firstdiff = i;
			break;
		}
		else if(bitsl[i]!=bitsr[i]){
			firstdiff = i;
			break;
		}
		else
			prefix = 2*prefix+bitsl[i];
	}
	
	Int x=prefix+(Int)pow(2, firstdiff-1);
	Int y=x-1;

	Int z;
	if(l!=y) z=l;
	else if(l) z=l+2;

	cout << x << " "<<y << " "<<z<<endl;
	cout << (x^y)+(y^z)+(z^x) << " "<<2*((Int)pow(2,firstdiff)-1)<<endl;
	cout << endl;
}

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

	for(int i=0; i<t; i++){
		solve();
	}
}


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

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

	vector<bool> bitsl, bitsr;

	
	for(Int temp=l;temp!=0; temp /=2)
		bitsl.push_back(temp%2);
	
	for(Int temp=r;temp!=0; temp /=2)
		bitsr.push_back(temp%2);
	
	int firstdiff;
	Int prefix=0;
	for(int i=max(bitsl.size(), bitsr.size()); i>=0; i--){
		if(i>bitsl.size()-1 || i>bitsr.size()-1){
			firstdiff = i;
			break;
		}
		else if(bitsl[i]!=bitsr[i]){
			firstdiff = i;
			break;
		}
		else
			prefix = 2*prefix+bitsl[i];
	}
	
	Int x=prefix+(Int)pow(2, firstdiff-1);
	Int y=x-1;

	Int z;
	if(l!=y) z=l;
	else if(l) z=l+2;

	cout << x << " "<<y << " "<<z<<endl;
	// cout << (x^y)+(y^z)+(z^x) << " "<<2*((Int)pow(2,firstdiff)-1)<<endl;
	// cout << endl;
}

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

	for(int i=0; i<t; i++){
		solve();
	}
}
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 unsigned long long

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

	vector<bool> bitsl, bitsr;

	
	for(Int temp=l;temp!=0; temp /=2)
		bitsl.push_back(temp%2);
	
	for(Int temp=r;temp!=0; temp /=2)
		bitsr.push_back(temp%2);
	
	int firstdiff;
	Int prefix=0;
	for(int i=max(bitsl.size(), bitsr.size()); i>=0; i--){
		if(i>bitsl.size()-1 || i>bitsr.size()-1){
			firstdiff = i;
			break;
		}
		else if(bitsl[i]!=bitsr[i]){
			firstdiff = i;
			break;
		}
		else
			prefix = 2*prefix+bitsl[i];
	}
	
	Int x=prefix+(Int)pow(2, firstdiff);
	Int y=x-1;

	Int z;
	if(l!=y) z=l;
	else if(l) z=l+2;

	cout << x << " "<<y << " "<<z<<endl;
	// cout << (x^y)+(y^z)+(z^x) << " "<<2*((Int)pow(2,firstdiff+1)-1)<<endl;
	// cout << endl;
}

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

	for(int i=0; i<t; i++){
		solve();
	}
}
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 unsigned long long

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

	vector<bool> bitsl, bitsr;

	
	for(Int temp=l;temp!=0; temp /=2)
		bitsl.push_back(temp%2);
	
	for(Int temp=r;temp!=0; temp /=2)
		bitsr.push_back(temp%2);
	
	int firstdiff;
	Int prefix=0;
	for(int i=max(bitsl.size(), bitsr.size()); i>=0; i--){
		if(i>bitsl.size()-1 || i>bitsr.size()-1){
			firstdiff = i;
			break;
		}
		else if(bitsl[i]!=bitsr[i]){
			firstdiff = i;
			break;
		}
		else
			prefix = 2*prefix+bitsl[i];
	}
	
	Int x=prefix+(Int)pow(2, firstdiff-1);
	Int y=x-1;

	Int z;
	if(l!=y) z=l;
	else if(l) z=l+2;

	cout << x << " "<<y << " "<<z<<endl;
	// cout << (x^y)+(y^z)+(z^x) << " "<<2*((Int)pow(2,firstdiff)-1)<<endl;
	// cout << endl;
}

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

	for(int i=0; i<t; i++){
		solve();
	}
}


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

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

	vector<bool> bitsl, bitsr;

	
	for(Int temp=l;temp!=0; temp /=2)
		bitsl.push_back(temp%2);
	
	for(Int temp=r;temp!=0; temp /=2)
		bitsr.push_back(temp%2);

	// for(int i=0; i<bitsl.size(); i++)
	// 	cout << bitsl[i] << " ";
	// cout << endl;
	// for(int i=0; i<bitsr.size(); i++)
	// 	cout << bitsr[i] << " ";
	// cout << endl;

	int firstdiff;
	Int x=0;

	for(int i=max(bitsl.size(), bitsr.size())-1; i>=0; i--){
		if((i>=bitsl.size()) || (i>=bitsr.size())){
			firstdiff = i;
			x = (2*x+1)*(Int)pow(2,i);
			break;
		}
		else if((bitsl[i]!=bitsr[i])){
			firstdiff = i;
			x = (2*x+1)*(Int)pow(2,i);
			break;
		}
		else{
			x = 2*x+bitsl[i];
		}
	}
	
	Int y=x-1;
	Int z;
	if(l!=y) z=l;
	else if(l) z=l+2;

	cout << x << " "<<y << " "<<z<<endl;
}

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

	for(int i=0; i<t; i++){
		solve();
	}
}
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)

Previous submission (verdict: Compilation error):
#include <bits/stdc++.h>
using namespace std;
#define ll long long







/*
input n, k
genrate an array with n numbers 
so to find those min numbers?
we get n/2 min numbers
arrange these as 

if k == 1 print the 1 ........ n elemets  

if k > 1 

put n/2 element in the end of the kth position of the array 



*/









void pv(vector<vector<ll>> &subset){
    for (int i = 0; i<subset.size(); i++){
        for(int j = 0; j<subset[i].size(); j++)
            cout<<subset[i][j]<<" ";
        cout<<endl;
    }
    cout<<endl;
}

void print(vector<ll> &temp){
   for(int i = 0; i<temp.size(); i++)
        cout<<temp[i];

   cout<<endl;
}


void solve(){
    //  create a queue and push the element in sequence 
    // for each inserting element 

    unsigned int n;
    cin>>n;
    vector<ll> v(n);
    
    for(unsigned int i = 0; i<n; i++){
        cin >> v[i];
    }

    for(unsigned int i = 1; i<n; i++){
        if(v[i-1] > v[i]){
            c = true;
            break;
        }
        else{
            v[i] -= v[i-1];
            v[i-1] = 0;
        }
    }
    (c)?cout<<"NO\n":cout<<"YES\n";
}


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

/*
6
1 1 3 5
1 3 2 1
8 10 28 100
100 1 100 1
1 100 1 100
100 100 0 100 100
0 0 6 5
*
*/

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







/*
input n, k
genrate an array with n numbers 
so to find those min numbers?
we get n/2 min numbers
arrange these as 

if k == 1 print the 1 ........ n elemets  

if k > 1 

put n/2 element in the end of the kth position of the array 



*/









void pv(vector<vector<ll>> &subset){
    for (int i = 0; i<subset.size(); i++){
        for(int j = 0; j<subset[i].size(); j++)
            cout<<subset[i][j]<<" ";
        cout<<endl;
    }
    cout<<endl;
}

void print(vector<ll> &temp){
   for(int i = 0; i<temp.size(); i++)
        cout<<temp[i];

   cout<<endl;
}


void solve(){
    //  create a queue and push the element in sequence 
    // for each inserting element 

    unsigned int n;
    cin>>n;
    vector<ll> v(n);
    
    for(unsigned int i = 0; i<n; i++){
        cin >> v[i];
    }
    bool c = false;
    for(unsigned int i = 1; i<n; i++){
        if(v[i-1] > v[i]){
            c = true;
            break;
        }
        else{
            v[i] -= v[i-1];
            v[i-1] = 0;
        }
    }
    (c)?cout<<"NO\n":cout<<"YES\n";
}


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

/*
6
1 1 3 5
1 3 2 1
8 10 28 100
100 1 100 1
1 100 1 100
100 100 0 100 100
0 0 6 5
*
*/
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)

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







/*
input n, k
genrate an array with n numbers 
so to find those min numbers?
we get n/2 min numbers
arrange these as 

if k == 1 print the 1 ........ n elemets  

if k > 1 

put n/2 element in the end of the kth position of the array 



*/









void pv(vector<vector<ll>> &subset){
    for (int i = 0; i<subset.size(); i++){
        for(int j = 0; j<subset[i].size(); j++)
            cout<<subset[i][j]<<" ";
        cout<<endl;
    }
    cout<<endl;
}

void print(vector<ll> &temp){
   for(int i = 0; i<temp.size(); i++)
        cout<<temp[i];

   cout<<endl;
}


void solve(){
    //  create a queue and push the element in sequence 
    // for each inserting element 

    unsigned int n;
    cin>>n;
    
    ll x, diff = 0;
    
    for(unsigned int i = 0; i<n; i++){
        cin>>x;
        diff = x - diff;
        if(diff < 0){
            cout<< "NO\n";
            return ;
        }
    }
    cout << "YES\n";

}


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

/*
6
1 1 3 5
1 3 2 1
8 10 28 100
100 1 100 1
1 100 1 100
100 100 0 100 100
0 0 6 5
*
*/

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







/*
input n, k
genrate an array with n numbers 
so to find those min numbers?
we get n/2 min numbers
arrange these as 

if k == 1 print the 1 ........ n elemets  

if k > 1 

put n/2 element in the end of the kth position of the array 



*/









void pv(vector<vector<ll>> &subset){
    for (int i = 0; i<subset.size(); i++){
        for(int j = 0; j<subset[i].size(); j++)
            cout<<subset[i][j]<<" ";
        cout<<endl;
    }
    cout<<endl;
}

void print(vector<ll> &temp){
   for(int i = 0; i<temp.size(); i++)
        cout<<temp[i];

   cout<<endl;
}


void solve(){
    //  create a queue and push the element in sequence 
    // for each inserting element 

    unsigned int n;
    cin>>n;
    vector<ll> v(n);
    
    for(unsigned int i = 0; i<n; i++){
        cin >> v[i];
    }

    for(unsigned int i = 1; i<n; i++){
        if(v[i-1] > v[i]){
            c = true;
            break;
        }
        else{
            v[i] -= v[i-1];
            v[i-1] = 0;
        }
    }
    (c)?cout<<"NO\n":cout<<"YES\n";
}


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

/*
6
1 1 3 5
1 3 2 1
8 10 28 100
100 1 100 1
1 100 1 100
100 100 0 100 100
0 0 6 5
*
*/
Problem: 2060D - Subtract Min Sort
Language: C++17 (GCC 7-32)


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







/*
input n, k
genrate an array with n numbers 
so to find those min numbers?
we get n/2 min numbers
arrange these as 

if k == 1 print the 1 ........ n elemets  

if k > 1 

put n/2 element in the end of the kth position of the array 



*/









void pv(vector<vector<ll>> &subset){
    for (int i = 0; i<subset.size(); i++){
        for(int j = 0; j<subset[i].size(); j++)
            cout<<subset[i][j]<<" ";
        cout<<endl;
    }
    cout<<endl;
}

void print(vector<ll> &temp){
   for(int i = 0; i<temp.size(); i++)
        cout<<temp[i];

   cout<<endl;
}


void solve(){
    //  create a queue and push the element in sequence 
    // for each inserting element 

    unsigned int n;
    cin>>n;
    
    ll x, diff = 0;
    
    for(unsigned int i = 0; i<n; i++){
        cin>>x;
        diff = x - diff;
        if(diff < 0){
            cout<< "NO\n";
            return ;
        }
    }
    cout << "YES\n";

}


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

/*
6
1 1 3 5
1 3 2 1
8 10 28 100
100 1 100 1
1 100 1 100
100 100 0 100 100
0 0 6 5
*
*/
Problem: 2062C - Cirno and Operations
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
#define fio() ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define endl "\n"

int main(){
    fio();
    int t; cin>>t;
    while(t--){
        int n; cin>>n;
        vector<int> a(n);
        int ans=0;
        for(int i=0; i<n; i++){
            cin>>a[i];
            ans+=a[i];
        }
        while(n>1){
            n--;
            vector<int> temp(n);
            for(int i=0; i<n; i++) temp[i]=a[i+1]-a[i];
            a=temp;
            ans=max(ans, accumulate(a.begin(), a.end(), 0));
        }
        cout<<ans<<endl;
    }
    return 0;
}

Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
#define fio() ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define endl "\n"

int main(){
    fio();
    int t; cin>>t;
    while(t--){
        int n; cin>>n;
        vector<int> a(n);
        int ans=0;
        for(int i=0; i<n; i++){
            cin>>a[i];
            ans+=a[i];
        }
        while(n>1){
            n--;
            reverse(a.begin(), a.end());
            vector<int> temp(n);
            for(int i=0; i<n; i++) temp[i]=a[i+1]-a[i];
            a=temp;
            ans=max(ans, abs(accumulate(a.begin(), a.end(), 0)));
        }
        cout<<ans<<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>
using namespace std;
#define fio() ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define endl "\n"

int main(){
    fio();
    int t; cin>>t;
    while(t--){
        int n; cin>>n;
        vector<int> a(n);
        int ans=0;
        for(int i=0; i<n; i++){
            cin>>a[i];
            ans+=a[i];
        }
        while(n>1){
            n--;
            reverse(a.begin(), a.end());
            vector<int> temp(n);
            for(int i=0; i<n; i++) temp[i]=a[i+1]-a[i];
            a=temp;
            ans=max(ans, abs(accumulate(a.begin(), a.end(), 0)));
        }
        cout<<ans<<endl;
    }
    return 0;
}

Submission (verdict: Accepted):
#include<bits/stdc++.h>
using namespace std;
#define fio() ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define endl "\n"
#define ll long long

int main(){
    fio();
    int t; cin>>t;
    while(t--){
        int n; cin>>n;
        vector<ll> a(n);
        ll ans=0;
        for(int i=0; i<n; i++){
            cin>>a[i];
            ans+=a[i];
        }
        while(n>1){
            n--;
            vector<ll> temp(n);
            for(int i=0; i<n; i++) temp[i]=a[i+1]-a[i];
            a=temp;
            ans=max(ans, abs(accumulate(a.begin(), a.end(), 0LL)));
        }
        cout<<ans<<endl;
    }
    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>
using namespace std;
#define fio() ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define endl "\n"

int main(){
    fio();
    int t; cin>>t;
    while(t--){
        int n; cin>>n;
        vector<int> a(n);
        int ans=0;
        for(int i=0; i<n; i++){
            cin>>a[i];
            ans+=a[i];
        }
        while(n>1){
            n--;
            vector<int> temp(n);
            for(int i=0; i<n; i++) temp[i]=a[i+1]-a[i];
            a=temp;
            ans=max(ans, abs(accumulate(a.begin(), a.end(), 0)));
        }
        cout<<ans<<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>
using namespace std;
#define fio() ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define endl "\n"

int main(){
    fio();
    int t; cin>>t;
    while(t--){
        int n; cin>>n;
        vector<int> a(n);
        int ans=0;
        for(int i=0; i<n; i++){
            cin>>a[i];
            ans+=a[i];
        }
        while(n>1){
            n--;
            vector<int> temp(n);
            for(int i=0; i<n; i++) temp[i]=a[i+1]-a[i];
            a=temp;
            ans=max(ans, abs(accumulate(a.begin(), a.end(), 0)));
        }
        cout<<ans<<endl;
    }
    return 0;
}

Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
#define fio() ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define endl "\n"
#define ll long long

int main(){
    fio();
    int t; cin>>t;
    while(t--){
        int n; cin>>n;
        vector<ll> a(n);
        ll ans=0;
        for(int i=0; i<n; i++){
            cin>>a[i];
            ans+=a[i];
        }
        while(n>1){
            n--;
            vector<ll> temp(n);
            for(int i=0; i<n; i++) temp[i]=a[i+1]-a[i];
            a=temp;
            ll m=abs(accumulate(a.begin(), a.end(), 0));
            ans=max(ans, m);
        }
        cout<<ans<<endl;
    }
    return 0;
}