ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2060D - Subtract Min Sort
Language: C++20 (GCC 13-64)

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

int main() {
    int tt; 
    cin >> tt;
    
    while (tt--) {
        int n; cin >> n;
        vector<int>nums(n);
        for(int i =0 ; i <n ; i++) cin >> nums[i];
        reverse(nums.begin(),nums.end());
        bool st=true;
        for (int i = 0; i < n-2; i++)
        {
            if(nums[i]<nums[i+1]){
                int x=(min(nums[i+1],nums[i+2]));
                nums[i+1]-=x;
                nums[i+2]-=x;
                 if(nums[i]<nums[i+1]){
                    st=false;
                    break;
                 }
            }
        }
        // for(auto s: nums) cout << s << " ";
        if(nums[n-2]>nums[n-1]) st=false;
        if(!st){
            cout << "YES\n";
            continue;
        }else{
            cout << "NO\n";
        }
        

        


        
        

        
        
        
        

        
        
        
        

        
        

       
    }
}


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

int main() {
    int tt; 
    cin >> tt;
    
    while (tt--) {
        int n; cin >> n;
        vector<int>nums(n);
        for(int i =0 ; i <n ; i++) cin >> nums[i];
        vector<int>temp=nums;
        reverse(nums.begin(),nums.end());
        bool st=true;
        for (int i = 0; i < n-2; i++)
        {
            if(nums[i]<nums[i+1]){
               
                int x=(min(nums[i+1],nums[i+2]));
                nums[i+1]-=x;
                nums[i+2]-=x;
                 if(nums[i]<nums[i+1]){
                    st=false;
                    break;
                 }
            }
        }
        // for(auto s: nums) cout << s << " ";
        if(nums[n-2]<nums[n-1]) st=false;
        if(st){
            cout << "YES\n";
            continue;
        }else{
            st=true;
            nums=temp;
            for(int i=0; i <n-1 ; i++){
                int x=(min(nums[i+1],nums[i]));
                nums[i]-=x;
                nums[i+1]-=x;
                if(nums[i]!=0)st=false;
            }
            if(nums[n-1]!=0)st=false;
            if(st){
                cout << "YES\n";
                continue;
            }
            
            cout << "NO\n";
        }
        

        


        
        

        
        
        
        

        
        
        
        

        
        

       
    }
}
Problem: 2060D - Subtract Min Sort
Language: C++20 (GCC 13-64)

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

int main() {
    int tt; 
    cin >> tt;
    
    while (tt--) {
        int n; cin >> n;
        vector<int>nums(n);
        for(int i =0 ; i <n ; i++) cin >> nums[i];
        vector<int>temp=nums;
        reverse(nums.begin(),nums.end());
        bool st=true;
        for (int i = 0; i < n-2; i++)
        {
            if(nums[i]<nums[i+1]){
               
                int x=(min(nums[i+1],nums[i+2]));
                nums[i+1]-=x;
                nums[i+2]-=x;
                 if(nums[i]<nums[i+1]){
                    st=false;
                    break;
                 }
            }
        }
        // for(auto s: nums) cout << s << " ";
        if(nums[n-2]<nums[n-1]) st=false;
        if(st){
            cout << "YES\n";
            continue;
        }else{
            st=true;
            nums=temp;
            for(int i=0; i <n-1 ; i++){
                int x=(min(nums[i+1],nums[i]));
                nums[i]-=x;
                nums[i+1]-=x;
                if(nums[i]!=0)st=false;
            }
            if(nums[n-1]!=0)st=false;
            if(st){
                cout << "YES\n";
                continue;
            }
            
            cout << "NO\n";
        }
        

        


        
        

        
        
        
        

        
        
        
        

        
        

       
    }
}


Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector <ll>;
using ii = pair <ll, ll>;
using vii = vector <ii>;

void tc () {
    ll n;
    cin >> n;
    vll ve(n);
    for (ll &i : ve) cin >> i;
    ll j = 0;
    for (ll i = 1; i < n; i++) {
        if (ve[i-1] > ve[i]) j = i;
    }
    if (j == 0) { // all done
        cout << "YES\n";
        return;
    }
    auto fop = [&](ll i) {
        ll minN = min(ve[i], ve[i+1]);
        ve[i] -= minN;
        ve[i+1] -= minN;
    };
    for (ll i = 0; i < j; i++) {
        fop(i);
    }
    cout << (is_sorted(ve.begin(), ve.end()) ? "YES" : "NO") << '\n';
}

int main () {
    cin.tie(nullptr) -> sync_with_stdio(false);
    ll T; cin >> T; while (T--) { tc(); }
    return 0;
}
Problem: 2062C - Cirno and Operations
Language: Java 21


Submission (verdict: Wrong answer on test 2):
import java.util.*;
import java.io.*;
import java.math.*;

public class sub {

	// can i get expert by summer please

	static int mod = 998244353;

	public static void main(String args[]) throws IOException {
		int t = sc.nextInt();
		while (t-- > 0) {
			int n = sc.nextInt();
			ArrayList<Long> a = new ArrayList();
			if (n == 1) {
				out.println(sc.nextInt());
			} else {
				for (int i = 0; i < n; i++) {
					a.add(sc.nextLong());
				}
				long ans = 0;
				for (int i = 0; i < n; i++) {
					ArrayList<Long> copy = new ArrayList();
					long sum = 0;
					for (int j = 0; j < a.size(); j++) {
						sum += a.get(j);
					}
					if(sum<0) {
						Collections.reverse(a);
					}
					for(int j = 0;j<a.size()-1;j++) {
						copy.add(a.get(j) - a.get(j + 1));
					}
					a = copy;
					ans=Math.max(ans,sum);
				}
				out.println(ans);
			}
		}
		out.close();
	}

//	static long bincoef(int n, int k) {
//	    if (n < k) return 0L;
//	    return (p[n] * pow((p[n - k] * p[k]) % mod, mod - 2, mod)) % mod;
//	}

	static long pow(long a, long b, long mod) {
		if (b == 0) {
			return 1L;
		}
		long val = pow(a, b / 2, mod);
		if (b % 2 == 0) {
			return val * val % mod;
		}
		return val * val % mod * a % mod;
	}

	static long gcd(long a, long b) {
		if (b == 0) {
			return a;
		}
		return gcd(b, a % b);
	}

	static long lcm(long a, long b) {
		return a * b / gcd(a, b);
	}

	static Kattio sc = new Kattio();
	static PrintWriter out = new PrintWriter(System.out);

	static class Kattio {

		static BufferedReader r;
		static StringTokenizer st;

		public Kattio() {
			r = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() {
			try {
				while (st == null || !st.hasMoreTokens()) {
					st = new StringTokenizer(r.readLine());
				}
				return st.nextToken();
			} catch (Exception e) {
				return null;
			}
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}
	}
}
Problem: 2063C - Remove Exactly Two
Language: Java 21


Submission (verdict: Time limit exceeded on test 6):
import java.util.*;
import java.io.*;
import java.math.*;

public class sub {

	static int mod = 998244353;

	public static void main(String args[]) throws IOException {
		int t = sc.nextInt();
		while(t-->0) {
			int n = sc.nextInt();
			ArrayList<ArrayList<Integer>> adj = new ArrayList();
			for(int i = 0;i<n;i++)adj.add(new ArrayList());
			int deg[] = new int[n];
			for(int i = 0;i<n-1;i++) {
				int u = sc.nextInt()-1;
				int v = sc.nextInt()-1;
				adj.get(u).add(v);
				adj.get(v).add(u);
				deg[u]++;
				deg[v]++;
			}
			PriorityQueue<Integer> pq = new PriorityQueue(Collections.reverseOrder());
			for(int i = 0;i<deg.length;i++) {
				pq.add(deg[i]);
			}
			int ans = 0;
			for(int i = 0;i<n;i++) {
				for(int j : adj.get(i)) {
					ans = Math.max(ans, deg[j]+deg[i]-2);
					pq.remove(deg[j]);
				}
				pq.remove(deg[i]);
				//out.println(pq);
				ans=Math.max(deg[i]+(pq.peek()==null?0:pq.peek())-1, ans);
				for(int j : adj.get(i)) {
					pq.add(deg[j]);
				}
				pq.add(deg[i]);
			}
			out.println(ans);
		}
		out.close();
	}

//	static long bincoef(int n, int k) {
//	    if (n < k) return 0L;
//	    return (p[n] * pow((p[n - k] * p[k]) % mod, mod - 2, mod)) % mod;
//	}
	
	static class Node implements Comparable<Node> {
        long cost;
        int u, v;
        Node(long cost, int u, int v) {
            this.cost = cost;
            this.u = u;
            this.v = v;
        }
        public int compareTo(Node o) {
            return Long.compare(this.cost, o.cost);
        }
    }

	static long pow(long a, long b, long mod) {
		if (b == 0) {
			return 1L;
		}
		long val = pow(a, b / 2, mod);
		if (b % 2 == 0) {
			return val * val % mod;
		}
		return val * val % mod * a % mod;
	}

	static long gcd(long a, long b) {
		if (b == 0) {
			return a;
		}
		return gcd(b, a % b);
	}

	static long lcm(long a, long b) {
		return a * b / gcd(a, b);
	}

	static Kattio sc = new Kattio();
	static PrintWriter out = new PrintWriter(System.out);

	static class Kattio {

		static BufferedReader r;
		static StringTokenizer st;

		public Kattio() {
			r = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() {
			try {
				while (st == null || !st.hasMoreTokens()) {
					st = new StringTokenizer(r.readLine());
				}
				return st.nextToken();
			} catch (Exception e) {
				return null;
			}
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}
	}
}
Problem: 2060D - Subtract Min Sort
Language: C++23 (GCC 14-64, msys2)

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

using namespace std;

#define int long long int

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

#define print(v,n) for(int i = 0 ; i  < n ; i++){ cout << v[i] << " ";} cout << endl;

#define input(v,n) for(int i = 0 ; i  < n ; i++){ cin >> v[i];}

#define YES cout << "YES" << endl;

#define NO cout << "NO" << endl;

#define modadd(a,b) (a+b)%mod

#define modsub(a,b) (a-b+mod)%mod

#define modmul(a,b) ((a%mod)*(b%mod))%mod

const int mod = 1e9 + 7;



int binpow(int a,int n){

a%=mod;

int res = 1;

while(n){

if(n%2){

res = (res*a)%mod;

}

a = (a*a)%mod;

n = n/2;

}

return res%mod;

}



void solve()

{

int n;

cin >> n;

vector<int> a(n);

input(a,n);

if(a[0] > a[1] || a[n-2] > a[n-1]){

NO;

return;

}



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

int val = min(a[i],a[i+1]);

a[i] = a[i] - val;

a[i+1] = a[i+1] - val;

if(a[i] > a[i+1]){

NO;

return;

}

}



YES;

return;

}







signed main()

{



ios_base::sync_with_stdio(false);

cin.tie(NULL);

cout.tie(NULL);



int t;

cin >> t;

while(t--)

{

solve();

}

return 0;

}

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

using namespace std;

#define int long long int

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

#define print(v,n) for(int i = 0 ; i  < n ; i++){ cout << v[i] << " ";} cout << endl;

#define input(v,n) for(int i = 0 ; i  < n ; i++){ cin >> v[i];}

#define YES cout << "YES" << endl;

#define NO cout << "NO" << endl;

#define modadd(a,b) (a+b)%mod

#define modsub(a,b) (a-b+mod)%mod

#define modmul(a,b) ((a%mod)*(b%mod))%mod

const int mod = 1e9 + 7;



int binpow(int a,int n){

a%=mod;

int res = 1;

while(n){

if(n%2){

res = (res*a)%mod;

}

a = (a*a)%mod;

n = n/2;

}

return res%mod;

}



void solve()

{

int n;

cin >> n;

vector<int> a(n);

input(a,n);

if(a[0] > a[1] || a[n-2] > a[n-1]){

NO;

return;

}



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

int val = min(a[i],a[i+1]);

a[i] = a[i] - val;

a[i+1] = a[i+1] - val;

bool flag = false;;

if(i!=0){

if(a[i] < a[i-1]){

flag = true;

}

}

if(a[i] > a[i+1] || flag){

a[i] += val;

a[i+1] += val;

}

}



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

if(a[i] > a[i+1]){

NO;

return;

}

}



YES;

return;

}







signed main()

{



ios_base::sync_with_stdio(false);

cin.tie(NULL);

cout.tie(NULL);



int t;

cin >> t;

while(t--)

{

solve();

}

return 0;

}
Problem: 2060D - Subtract Min Sort
Language: C++23 (GCC 14-64, msys2)

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

using namespace std;

#define int long long int

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

#define print(v,n) for(int i = 0 ; i  < n ; i++){ cout << v[i] << " ";} cout << endl;

#define input(v,n) for(int i = 0 ; i  < n ; i++){ cin >> v[i];}

#define YES cout << "YES" << endl;

#define NO cout << "NO" << endl;

#define modadd(a,b) (a+b)%mod

#define modsub(a,b) (a-b+mod)%mod

#define modmul(a,b) ((a%mod)*(b%mod))%mod

const int mod = 1e9 + 7;



int binpow(int a,int n){

a%=mod;

int res = 1;

while(n){

if(n%2){

res = (res*a)%mod;

}

a = (a*a)%mod;

n = n/2;

}

return res%mod;

}



void solve()

{

int n;

cin >> n;

vector<int> a(n);

input(a,n);

if(a[0] > a[1] || a[n-2] > a[n-1]){

NO;

return;

}



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

int val = min(a[i],a[i+1]);

a[i] = a[i] - val;

a[i+1] = a[i+1] - val;

bool flag = false;;

if(i!=0){

if(a[i] < a[i-1]){

flag = true;

}

}

if(a[i] > a[i+1] || flag){

a[i] += val;

a[i+1] += val;

}

}



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

if(a[i] > a[i+1]){

NO;

return;

}

}



YES;

return;

}







signed main()

{



ios_base::sync_with_stdio(false);

cin.tie(NULL);

cout.tie(NULL);



int t;

cin >> t;

while(t--)

{

solve();

}

return 0;

}

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

using namespace std;

#define int long long int

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

#define print(v,n) for(int i = 0 ; i  < n ; i++){ cout << v[i] << " ";} cout << endl;

#define input(v,n) for(int i = 0 ; i  < n ; i++){ cin >> v[i];}

#define YES cout << "YES" << endl;

#define NO cout << "NO" << endl;

#define modadd(a,b) (a+b)%mod

#define modsub(a,b) (a-b+mod)%mod

#define modmul(a,b) ((a%mod)*(b%mod))%mod

const int mod = 1e9 + 7;



int binpow(int a,int n){

a%=mod;

int res = 1;

while(n){

if(n%2){

res = (res*a)%mod;

}

a = (a*a)%mod;

n = n/2;

}

return res%mod;

}



int check(int n,vector<int> a,bool f){

if(a[0] > a[1]){

// NO;

return 0;

}



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

int val = min(a[i],a[i+1]);

a[i] = a[i] - val;

a[i+1] = a[i+1] - val;

bool flag = false;;

if(i!=0){

if(f){

if(a[i] < a[i-1]){

flag = true;

}

}else{

if(a[i] > a[i-1]){

flag = true;

}

}

}

if(flag){

a[i] += val;

a[i+1] += val;

}

}



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

if(f){

if(a[i] > a[i+1]){

// NO;

return 0;

}

}else{

if(a[i] < a[i+1]){

return 0;

}

}

}



// YES;

return 1;

}



void solve()

{

int n;

cin >> n;

vector<int> a(n);

input(a,n);

bool ans = false;

if(check(n,a,1)){

ans = true;

}

reverse(all(a));

if(check(n,a,0)){

ans = true;

}

if(ans){

YES;

}else{

NO;

}

return;

}







signed main()

{



ios_base::sync_with_stdio(false);

cin.tie(NULL);

cout.tie(NULL);



int t;

cin >> t;

while(t--)

{

solve();

}

return 0;

}
Problem: 2060D - Subtract Min Sort
Language: C++23 (GCC 14-64, msys2)


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

using namespace std;

#define int long long int

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

#define print(v,n) for(int i = 0 ; i  < n ; i++){ cout << v[i] << " ";} cout << endl;

#define input(v,n) for(int i = 0 ; i  < n ; i++){ cin >> v[i];}

#define YES cout << "YES" << endl;

#define NO cout << "NO" << endl;

#define modadd(a,b) (a+b)%mod

#define modsub(a,b) (a-b+mod)%mod

#define modmul(a,b) ((a%mod)*(b%mod))%mod

const int mod = 1e9 + 7;



int binpow(int a,int n){

a%=mod;

int res = 1;

while(n){

if(n%2){

res = (res*a)%mod;

}

a = (a*a)%mod;

n = n/2;

}

return res%mod;

}



void solve()

{

int n;

cin >> n;

vector<int> a(n);

input(a,n);

if(a[0] > a[1] || a[n-2] > a[n-1]){

NO;

return;

}



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

int val = min(a[i],a[i+1]);

a[i] = a[i] - val;

a[i+1] = a[i+1] - val;

if(a[i] > a[i+1]){

NO;

return;

}

}



YES;

return;

}







signed main()

{



ios_base::sync_with_stdio(false);

cin.tie(NULL);

cout.tie(NULL);



int t;

cin >> t;

while(t--)

{

solve();

}

return 0;

}
Problem: 2057B - Gorilla and the Exam
Language: C++17 (GCC 7-32)

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

int main (){
   int t;
   cin>>t;
   while(t--){
    int n,k;
    cin>>n>>k;
    vector<int>arr(n,0);
    for(int i=0;i<n;i++) cin>>arr[i];
    unordered_map<int,int>mp;
    for(int i=0;i<n;i++) mp[arr[i]]++;
    vector<int>arr1;
    for(auto it:mp){
        arr1.push_back(it.second);
    }
    // sort(arr1.begin(),arr1.end());
    int ele = 0;
    for(int i=0;i<arr1.size();i++){
        if(arr1[i]<=k) ele++;
        k = k - arr1[i];
    }
    if(arr1.size()==ele) cout<<1<<endl;
    else cout<<(arr1.size()-ele)<<endl;
    

   }

   
    return 0;
}

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

int main (){
   int t;
   cin>>t;
   while(t--){
    int n,k;
    cin>>n>>k;
    vector<int>arr(n,0);
    for(int i=0;i<n;i++) cin>>arr[i];
    map<int,int>mp;
    for(int i=0;i<n;i++) mp[arr[i]]++;
    vector<int>arr1;
    for(auto it:mp){
        arr1.push_back(it.second);
    }
    sort(arr1.begin(),arr1.end());
    int ele = 0;
    for(int i=0;i<arr1.size();i++){
        if(arr1[i]<=k) ele++;
        k = k - arr1[i];
    }
    if(arr1.size()==ele) cout<<1<<endl;
    else cout<<(arr1.size()-ele)<<endl;
    

   }

   
    return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++17 (GCC 7-32)

Previous submission (verdict: Time limit exceeded on test 14):
// #include<iostream>
// #include<vector>
// #include <algorithm>
#include<bits/stdc++.h>
using namespace std;

int main (){
   int t;
   cin>>t;
   while(t--){
    int n,k;
    cin>>n>>k;
    vector<int>arr(n,0);
    for(int i=0;i<n;i++) cin>>arr[i];
    unordered_map<int,int>mp;
    for(int i=0;i<n;i++) mp[arr[i]]++;
    vector<int>arr1;
    for(auto it:mp){
        arr1.push_back(it.second);
    }
    sort(arr1.begin(),arr1.end());
    int ele = 0;
    for(int i=0;i<arr1.size();i++){
        if(arr1[i]<=k) ele++;
        k = k - arr1[i];
    }
    if(arr1.size()==ele) cout<<1<<endl;
    else cout<<(arr1.size()-ele)<<endl;
    

   }

   
    return 0;
}

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

int main (){
   int t;
   cin>>t;
   while(t--){
    int n,k;
    cin>>n>>k;
    vector<int>arr(n,0);
    for(int i=0;i<n;i++) cin>>arr[i];
    unordered_map<int,int>mp;
    for(int i=0;i<n;i++) mp[arr[i]]++;
    vector<int>arr1;
    for(auto it:mp){
        arr1.push_back(it.second);
    }
    // sort(arr1.begin(),arr1.end());
    int ele = 0;
    for(int i=0;i<arr1.size();i++){
        if(arr1[i]<=k) ele++;
        k = k - arr1[i];
    }
    if(arr1.size()==ele) cout<<1<<endl;
    else cout<<(arr1.size()-ele)<<endl;
    

   }

   
    return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++17 (GCC 7-32)


Submission (verdict: Time limit exceeded on test 14):
// #include<iostream>
// #include<vector>
// #include <algorithm>
#include<bits/stdc++.h>
using namespace std;

int main (){
   int t;
   cin>>t;
   while(t--){
    int n,k;
    cin>>n>>k;
    vector<int>arr(n,0);
    for(int i=0;i<n;i++) cin>>arr[i];
    unordered_map<int,int>mp;
    for(int i=0;i<n;i++) mp[arr[i]]++;
    vector<int>arr1;
    for(auto it:mp){
        arr1.push_back(it.second);
    }
    sort(arr1.begin(),arr1.end());
    int ele = 0;
    for(int i=0;i<arr1.size();i++){
        if(arr1[i]<=k) ele++;
        k = k - arr1[i];
    }
    if(arr1.size()==ele) cout<<1<<endl;
    else cout<<(arr1.size()-ele)<<endl;
    

   }

   
    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)

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

void solve(){
	int n; cin >> n; 
	vector<int> a(n); for(int& i : a ) cin >> i ;
	if(n == 1){
		cout << a[0] << '\n';
		return;
	}
	int64_t sum = accumulate(a.begin(),a.end(),0ll);
	sum = max(sum,-sum);
	while( n > 1){
		for(int i = 0; i < n-1; i++){
			a[i] = a[i+1] - a[i];
		}
		a[n-1] = 0;
		int64_t x = accumulate(a.begin(),a.end(),0ll);
		n--;
		if(n != 1) x = max(x,-x);
		sum = max(x,sum);
	}
	cout << sum << '\n';
			
	
}

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


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

void solve(){
	int n; cin >> n; 
	vector<int64_t> a(n); for(int64_t& i : a ) cin >> i ;
	if(n == 1){
		cout << a[0] << '\n';
		return;
	}
	int64_t sum = accumulate(a.begin(),a.end(),0ll);
	sum = max(sum,-sum);
	while( n > 1){
		for(int i = 0; i < n-1; i++){
			a[i] = a[i+1] - a[i];
		}
		a[n-1] = 0;
		int64_t x = accumulate(a.begin(),a.end(),0ll);
		n--;
		x = max(x,-x);
		sum = max(x,sum);
	}
	cout << sum << '\n';
			
	
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int tc; cin >> tc;
	while(tc--){
		solve();
	}
	return 0 ;
}
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)

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

void solve(){
	int n; cin >> n; 
	vector<int> a(n); for(int& i : a ) cin >> i ;
	if(n == 1){
		cout << a[0] << '\n';
		return;
	}
	int64_t sum = accumulate(a.begin(),a.end(),0ll);
	sum = max(sum,-sum);
	while( n > 1){
		for(int i = 0; i < n-1; i++){
			a[i] = a[i+1] - a[i];
		}
		a[n-1] = 0;
		int64_t x = accumulate(a.begin(),a.end(),0ll);
		n--;
		x = max(x,-x);
		sum = max(x,sum);
	}
	cout << sum << '\n';
			
	
}

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


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

void solve(){
	int n; cin >> n; 
	vector<int> a(n); for(int& i : a ) cin >> i ;
	if(n == 1){
		cout << a[0] << '\n';
		return;
	}
	int64_t sum = accumulate(a.begin(),a.end(),0ll);
	sum = max(sum,-sum);
	while( n > 1){
		for(int i = 0; i < n-1; i++){
			a[i] = a[i+1] - a[i];
		}
		a[n-1] = 0;
		int64_t x = accumulate(a.begin(),a.end(),0ll);
		n--;
		if(n != 1) x = max(x,-x);
		sum = max(x,sum);
	}
	cout << sum << '\n';
			
	
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int tc; cin >> tc;
	while(tc--){
		solve();
	}
	return 0 ;
}
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)

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

void solve(){
	int n; cin >> n; 
	vector<int> a(n); for(int& i : a ) cin >> i ;
	int64_t sum = accumulate(a.begin(),a.end(),0ll);
	sum = max(sum,-sum);
	while( n > 1){
		for(int i = 0; i < n-1; i++){
			a[i] = a[i+1] - a[i];
		}
		a[n-1] = 0;
		int64_t x = accumulate(a.begin(),a.end(),0ll);
		n--;
		x = max(x,-x);
		sum = max(x,sum);
	}
	cout << sum << '\n';
			
	
}

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


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

void solve(){
	int n; cin >> n; 
	vector<int> a(n); for(int& i : a ) cin >> i ;
	if(n == 1){
		cout << a[0] << '\n';
		return;
	}
	int64_t sum = accumulate(a.begin(),a.end(),0ll);
	sum = max(sum,-sum);
	while( n > 1){
		for(int i = 0; i < n-1; i++){
			a[i] = a[i+1] - a[i];
		}
		a[n-1] = 0;
		int64_t x = accumulate(a.begin(),a.end(),0ll);
		n--;
		x = max(x,-x);
		sum = max(x,sum);
	}
	cout << sum << '\n';
			
	
}

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