ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)

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

using namespace std;



#define int 			long long int

#define double			long double

#define F			first

#define S 			second

#define pb 			push_back

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

#define vi 			vector<int>

#define pii			pair<int, int>

#define rep(i, a, b) 		for(int i = a; i < b; i++)

#define CODE_START 		ios_base::sync_with_stdio();cin.tie(0);cout.tie(0);



void solve() {

	int n, l, r;

	cin >> n >> l >> r;

	vi a(n);

	rep(i, 0, n) cin >> a[i];



	int curr_sum = 0, sum = 0, len = 0, d = r-l+1;

	rep(i, l-1, r) curr_sum += a[i];

	int mn = curr_sum;



	vi prefix(d+1);

	rep(i, 1, d+1) prefix[i] = prefix[i-1] + a[l+i-2];



	rep(i, 0, r-1) {

		if(sum + a[i] < curr_sum) {

			sum += a[i];

			len++;

		}

		else {

			sum = a[i];

			len = 1;

		}

		mn = min(mn, curr_sum - prefix[len] + sum);

		if(len == d) {

			sum -= a[i-r+l];

			len--;

		}

	}

	

	vi suffix(d+1);

	for(int i = d-1; i >= 0; i--) suffix[i] = suffix[i+1] + a[r-d+i];

	

	sum = 0;

	len = 0;



	for(int i = n-1; i >= l; i--) {

		if(sum + a[i] < curr_sum) {

			sum += a[i];

			len++;

		}

		else {

			sum = a[i];

			len = 1;

		}

		mn = min(mn, curr_sum - suffix[d-len] + sum);

		if(len == d) {

			sum -= a[i+r-l];

			len--;

		}

	}

	

	cout << mn << "\n";

}



int32_t main() {

	#ifdef CODE_START

		CODE_START;

	#endif



	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 double			long double
#define F			first
#define S 			second
#define pb 			push_back
#define all(x) 			x.begin(), x.end()
#define vi 			vector<int>
#define pii			pair<int, int>
#define rep(i, a, b) 		for(int i = a; i < b; i++)
#define CODE_START 		ios_base::sync_with_stdio();cin.tie(0);cout.tie(0);

void solve() {
	int n, l, r;
	cin >> n >> l >> r;
	vi a(n);
	rep(i, 0, n) cin >> a[i];
	vi b;
	rep(i, l-1, r) b.pb(a[i]);
	sort(b.rbegin(), b.rend());
	int d = r-l+1;
	vi prefix(d+1);
	rep(i, 0, d) prefix[i+1] = prefix[i] + b[i];
	
	vi c;
	rep(i, 0, l-1) c.pb(a[i]);
	sort(all(c));

	int sum = 0, mn = prefix[d];
	rep(i, 0, (int)min(d, l-1)) {
		if(sum + c[i] < prefix[i+1]) {
			sum += c[i];
			mn = min(mn, prefix[d] - prefix[i+1] + sum);
		}
	}

	vi e;
	for(int i = n-1; i >= r; i--) e.pb(a[i]);
	sort(all(e));

	sum = 0;
	rep(i, 0, (int)min(d, n-r)) {
		if(sum + e[i] < prefix[i+1]) {
			sum += e[i];
			mn = min(mn, prefix[d] - prefix[i+1] + sum);
		}
	}

	cout << mn << "\n";
}

int32_t main() {
	#ifdef CODE_START
		CODE_START;
	#endif

	int t;	
	cin >> t;
	while(t--) {
		solve();
	}
	return 0;
}
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)

Previous submission (verdict: Time limit exceeded on test 8):
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(ll i = a; i < b; ++i)
#define tr(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define w(a) while(a--)
#define cint(n) ll n; cin >> n;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<string> vs;

int main() {
    cint(t);
    w(t) {
        string a;
        cin >> a;
        vl bb(sz(a));
        bool con = false;
        while(!con) {
            rep(i, 0, sz(a)) {
                bb[i] = a[i] - '0' - i;
            }
            bool flag = true;
            rep(i, 0, sz(a) - 1) {
                if (bb[i] < bb[i+1]) {
                    swap(a[i], a[i+1]);
                    a[i] -= 1;
                    flag = false;
                }
            }
            if (flag) con = true;
        }       
        rep (i, 0, sz(a)) {
            cout << a[i];
        } 
        cout << endl;
    }
}

Submission (verdict: Time limit exceeded on test 8):
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(ll i = a; i < b; ++i)
#define tr(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define w(a) while(a--)
#define cint(n) ll n; cin >> n;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<string> vs;

int main() {
    ios::sync_with_stdio(false); 
    cin.tie(nullptr); cout.tie(nullptr);
    cint(t);
    w(t) {
        string a;
        cin >> a;
        vl bb(sz(a));
        bool con = false;
        while(!con) {
            rep(i, 0, sz(a)) {
                bb[i] = a[i] - '0' - i;
            }
            bool flag = true;
            rep(i, 0, sz(a) - 1) {
                if (bb[i] < bb[i+1]) {
                    swap(a[i], a[i+1]);
                    a[i] -= 1;
                    flag = false;
                }
            }
            if (flag) con = true;
        }       
        rep (i, 0, sz(a)) {
            cout << a[i];
        } 
        cout << endl;
    }
}
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)

Previous submission (verdict: Time limit exceeded on test 8):
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(ll i = a; i < b; ++i)
#define tr(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define w(a) while(a--)
#define cint(n) ll n; cin >> n;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<string> vs;

int main() {
    ios::sync_with_stdio(false); 
    cin.tie(nullptr); cout.tie(nullptr);
    cint(t);
    w(t) {
        string a;
        cin >> a;
        vl bb(sz(a));
        bool con = false;
        while(!con) {
            rep(i, 0, sz(a)) {
                bb[i] = a[i] - '0' - i;
            }
            bool flag = true;
            rep(i, 0, sz(a) - 1) {
                if (bb[i] < bb[i+1]) {
                    swap(a[i], a[i+1]);
                    a[i] -= 1;
                    flag = false;
                }
            }
            if (flag) con = true;
        }       
        rep (i, 0, sz(a)) {
            cout << a[i];
        } 
        cout << endl;
    }
}

Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(ll i = a; i < b; ++i)
#define tr(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define w(a) while(a--)
#define cint(n) ll n; cin >> n;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<string> vs;

int main() {
    cint(t);
    w(t) {
        string a;
        cin >> a;
        rep(i, 0, sz(a)) {
            rep(j, 1, 10) {
                if (i - j >= 0 && a[i - j] < a[i - j + 1] - 1) {
                    swap(a[i-j], a[i-j+1]);
                    a[i-j]--;
                }
            }
        }
        cout << a << endl;
    }
}
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)


Submission (verdict: Time limit exceeded on test 8):
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(ll i = a; i < b; ++i)
#define tr(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define w(a) while(a--)
#define cint(n) ll n; cin >> n;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<string> vs;

int main() {
    cint(t);
    w(t) {
        string a;
        cin >> a;
        vl bb(sz(a));
        bool con = false;
        while(!con) {
            rep(i, 0, sz(a)) {
                bb[i] = a[i] - '0' - i;
            }
            bool flag = true;
            rep(i, 0, sz(a) - 1) {
                if (bb[i] < bb[i+1]) {
                    swap(a[i], a[i+1]);
                    a[i] -= 1;
                    flag = false;
                }
            }
            if (flag) con = true;
        }       
        rep (i, 0, sz(a)) {
            cout << a[i];
        } 
        cout << endl;
    }
}
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;
using i64=long long;
#define endl "\n"

void dfs(vector<int> a,int &maxSum,int len){
  //先求出当前数组差分之后的和
  maxSum=max(maxSum,abs(a.back()-a.front()));
  if(len==1){
    return;
  }
  //对原数组进行差分
  vector<int> b=a;
  a.clear();
  for(int i=1;i<len;i++){
    a.push_back(b[i]-b[i-1]);
  }
  dfs(a,maxSum,len-1);
}


void solve(){
  int n;
  cin>>n;
  vector<int> a(n+5);
  int maxSum=0;

  for(int i=0;i<n;i++){
    cin>>a[i];
    maxSum+=a[i];
  }
  if(n==1){
    cout<<maxSum<<endl;
    return;
  }
  else if(n==2){
    cout<<max(maxSum,abs(a[1]-a[0]))<<endl;
    return;
  }
  dfs(a,maxSum,n);
  cout<<maxSum<<endl;
}


int main(){
  ios::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>
using namespace std;
using i64=long long;
#define endl "\n"

void dfs(vector<int> a,i64 &maxSum,int len){
  //先求出当前数组差分之后的和
  maxSum=max(maxSum,(i64)abs(a.back()-a.front()));
  if(len==2){
    return;
  }
  //对原数组进行差分
  vector<int> b=a;
  a.clear();
  for(int i=1;i<len;i++){
    a.push_back(b[i]-b[i-1]);
  }
  dfs(a,maxSum,len-1);
}

void solve(){
  int n;
  cin>>n;
  vector<int> a(n+5);
  i64 maxSum=0;

  for(int i=0;i<n;i++){
    cin>>a[i];
    maxSum+=a[i];
  }
  if(n==1){
    cout<<maxSum<<endl;
    return;
  }
  else if(n==2){
    cout<<max(maxSum,(i64)abs(a[1]-a[0]))<<endl;
    return;
  }
  dfs(a,maxSum,n);
  cout<<maxSum<<endl;
}

int main(){
  ios::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++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 6):
#include<bits/stdc++.h>
using namespace std;
using i64=long long;
#define endl "\n"

void dfs(vector<i64> a,i64 &maxSum,i64 len){
  //先求出当前数组差分之后的和
  maxSum=max(maxSum,(i64)abs(a.back()-a.front()));
  if(len==2){
    return;
  }
  //对原数组进行差分
  vector<i64> b=a;
  a.clear();
  for(i64 i=1;i<len;i++){
    a.push_back(b[i]-b[i-1]);
  }
  dfs(a,maxSum,len-1);
}

void solve(){
  i64 n;
  cin>>n;
  vector<i64> a(n+5);
  i64 maxSum=0;

  for(i64 i=0;i<n;i++){
    cin>>a[i];
    maxSum+=a[i];
  }
  if(n==1){
    cout<<maxSum<<endl;
    return;
  }
  else if(n==2){
    cout<<max(maxSum,(i64)abs(a[1]-a[0]))<<endl;
    return;
  }
  dfs(a,maxSum,n);
  cout<<maxSum<<endl;
}

int main(){
  ios::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 8):
#include<bits/stdc++.h>
using namespace std;
using i64=long long;
#define endl "\n"

void dfs(vector<i64> a,i64 &maxSum,i64 len){
  //先求出当前数组差分之后的和
  maxSum=max(maxSum,(i64)abs(a.back()-a.front()));
  if(len==2){
    return;
  }
  //对原数组进行差分
  vector<i64> b=a;
  a.clear();
  for(i64 i=1;i<len;i++){
    a.push_back(b[i]-b[i-1]);
  }
  dfs(a,maxSum,len-1);
}

void solve(){
  i64 n;
  cin>>n;
  vector<i64> a(n+5);
  i64 maxSum=0;

  for(i64 i=0;i<n;i++){
    cin>>a[i];
    maxSum+=a[i];
  }
  if(n==1){
    cout<<maxSum<<endl;
    return;
  }
  else if(n==2){
    cout<<max(maxSum,(i64)abs(a[1]-a[0]))<<endl;
    return;
  }
  else if(n==3){
    cout<<max({maxSum,(i64)abs(a[2]-a[0]),(i64)abs(a[2]-2*a[1]+a[0])})<<endl;
    return;
  }
  dfs(a,maxSum,n);
  cout<<maxSum<<endl;
}

int main(){
  ios::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++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 8):
#include<bits/stdc++.h>
using namespace std;
using i64=long long;
#define endl "\n"

void dfs(vector<i64> a,i64 &maxSum,i64 len){
  //先求出当前数组差分之后的和
  maxSum=max(maxSum,(i64)abs(a.back()-a.front()));
  if(len==2){
    return;
  }
  //对原数组进行差分
  vector<i64> b=a;
  a.clear();
  for(i64 i=1;i<len;i++){
    a.push_back(b[i]-b[i-1]);
  }
  dfs(a,maxSum,len-1);
}

void solve(){
  i64 n;
  cin>>n;
  vector<i64> a(n+5);
  i64 maxSum=0;

  for(i64 i=0;i<n;i++){
    cin>>a[i];
    maxSum+=a[i];
  }
  if(n==1){
    cout<<maxSum<<endl;
    return;
  }
  else if(n==2){
    cout<<max(maxSum,(i64)abs(a[1]-a[0]))<<endl;
    return;
  }
  else if(n==3){
    cout<<max({maxSum,(i64)abs(a[2]-a[0]),(i64)abs(a[2]-2*a[1]+a[0])})<<endl;
    return;
  }
  dfs(a,maxSum,n);
  cout<<maxSum<<endl;
}

int main(){
  ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);

  int T;
  cin>>T;
  while(T--){
    solve();
  }
  return 0;
}

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

void dfs(vector<i64> a,i64 &maxSum,i64 len){
  //先求出当前数组差分之后的和
  //i64 now=abs(a.back()-a.front()); //不要随便用a.back()因为数组一般会开的比较大，那这个时候back就全是0了
  i64 now=abs(a[len-1]-a.front());
  maxSum=max(maxSum,now);
  if(len==2){
    return;
  }
  //对原数组进行差分
  vector<i64> b;
  for(i64 i=1;i<len;++i){
    b.push_back(a[i]-a[i-1]);
  }
  dfs(b,maxSum,len-1);
}

void solve(){
  i64 n;
  cin>>n;
  vector<i64> a(n+5);
  i64 maxSum=0;

  for(i64 i=0;i<n;++i){
    cin>>a[i];
    maxSum+=a[i];
  }
  if(n==1){
    cout<<maxSum<<"\n";
    return;
  }
  else if(n==2){
    cout<<max(maxSum,(i64)abs(a[1]-a[0]))<<"\n";
    return;
  }

  dfs(a,maxSum,n);
  cout<<maxSum<<"\n";
}

int main(){
  ios::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++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
using i64=long long;
#define endl "\n"

void dfs(vector<int> a,int &maxSum,int len){
  //先求出当前数组差分之后的和
  maxSum=max(maxSum,abs(a.back()-a.front()));
  if(len==1){
    return;
  }
  //对原数组进行差分
  vector<int> b=a;
  a.clear();
  for(int i=1;i<len;i++){
    a.push_back(b[i]-b[i-1]);
  }
  dfs(a,maxSum,len-1);
}


void solve(){
  int n;
  cin>>n;
  vector<int> a(n+5);
  int maxSum=0;

  for(int i=0;i<n;i++){
    cin>>a[i];
    maxSum+=a[i];
  }
  if(n==1){
    cout<<maxSum<<endl;
    return;
  }
  else if(n==2){
    cout<<max(maxSum,abs(a[1]-a[0]))<<endl;
    return;
  }
  dfs(a,maxSum,n);
  cout<<maxSum<<endl;
}


int main(){
  ios::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++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
using i64=long long;
#define endl "\n"

void dfs(vector<int> a,i64 &maxSum,int len){
  //先求出当前数组差分之后的和
  maxSum=max(maxSum,(i64)abs(a.back()-a.front()));
  if(len==2){
    return;
  }
  //对原数组进行差分
  vector<int> b=a;
  a.clear();
  for(int i=1;i<len;i++){
    a.push_back(b[i]-b[i-1]);
  }
  dfs(a,maxSum,len-1);
}

void solve(){
  int n;
  cin>>n;
  vector<int> a(n+5);
  i64 maxSum=0;

  for(int i=0;i<n;i++){
    cin>>a[i];
    maxSum+=a[i];
  }
  if(n==1){
    cout<<maxSum<<endl;
    return;
  }
  else if(n==2){
    cout<<max(maxSum,(i64)abs(a[1]-a[0]))<<endl;
    return;
  }
  dfs(a,maxSum,n);
  cout<<maxSum<<endl;
}

int main(){
  ios::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 6):
#include<bits/stdc++.h>
using namespace std;
using i64=long long;
#define endl "\n"

void dfs(vector<i64> a,i64 &maxSum,i64 len){
  //先求出当前数组差分之后的和
  maxSum=max(maxSum,(i64)abs(a.back()-a.front()));
  if(len==2){
    return;
  }
  //对原数组进行差分
  vector<i64> b=a;
  a.clear();
  for(i64 i=1;i<len;i++){
    a.push_back(b[i]-b[i-1]);
  }
  dfs(a,maxSum,len-1);
}

void solve(){
  i64 n;
  cin>>n;
  vector<i64> a(n+5);
  i64 maxSum=0;

  for(i64 i=0;i<n;i++){
    cin>>a[i];
    maxSum+=a[i];
  }
  if(n==1){
    cout<<maxSum<<endl;
    return;
  }
  else if(n==2){
    cout<<max(maxSum,(i64)abs(a[1]-a[0]))<<endl;
    return;
  }
  dfs(a,maxSum,n);
  cout<<maxSum<<endl;
}

int main(){
  ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);

  int T;
  cin>>T;
  while(T--){
    solve();
  }
  return 0;
}
Problem: 2061D - Kevin and Numbers
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 3):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) begin(x), end(x)
const int M = 1e9 + 7;

template <typename T>
istream &operator>>(istream &istream, vector<T> &v) {
    for (auto &it : v)
        cin >> it;
    return istream;
}

template <typename T>
ostream &operator<<(ostream &ostream, const vector<T> &c) {
    for (auto &it : c)
        cout << it << " ";
    return ostream;
}

void solve() {
    ll n,m;
    cin>>n>>m;
    vector<ll>a(n);
    cin>>a;
    vector<ll>b(m);
    cin>>b;
    multiset<ll>st;
    multiset<ll>st2;
    for (auto &c:a){
        st.insert(c);
    }
    vector<ll>remove;
    for (auto &c:b){
        st2.insert(c);
        if (st.find(c)!=st.end()){
            st.erase(st.find(c));
            remove.push_back(c);
        }
    }
    for (auto &c:remove){
        st2.erase(st2.find(c));
    }
    while(st.size()>0 && st2.size()>0){
        ll curr=*st.begin();
        ll tar=*st2.begin();
        // cout << curr << " " << tar << endl;
        if (curr>tar){
            cout << "No" << endl;return;
        }
        if (curr==tar){
            st.erase(st.begin());
            st2.erase(st2.begin());
        }
        else{
            st2.erase(st2.begin());
            if (tar%2==0){
                st2.insert(tar/2);
                st2.insert(tar/2);
            }
            else{
                st2.insert(tar/2);
                st2.insert((tar+1)/2);
            }
        }
    }
    if (st.size()==0 && st2.size()==0){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
 
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
#define _GLIBCXX_FILESYSTEM
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int maxn = 1e9 + 10;
const int INF = 1e9 + 100;
const int mod = 998244353;

void solve() {
    int n;
    cin >> n;
    vector<int> a(n + 1);
    for (int i = 1; i <= n; i++) cin >> a[i];
    int ans = -INF, now = n;
    for (int i = 1; i <= n; i++) {
        int sum = accumulate(a.begin(), a.begin() + now + 1, 0);
        if (i == 1) ans = max(ans, sum);
        else ans = max(ans, abs(sum));
        for (int j = 1; j < now; j++)
            a[j] = a[j + 1] - a[j];
        now--;
    }
    cout << ans << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int T = 1;
    cin >> T;
    while (T--)
        solve();

    return 0;
}
/*

1
4
1 1 1 1
1 1 1 1
1 1 1 2
1 1 1 2


*/

Submission (verdict: Wrong answer on test 2):
#define _GLIBCXX_FILESYSTEM
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int maxn = 1e9 + 10;
const int INF = 1e9 + 100;
const int mod = 998244353;

void solve() {
    int n;
    cin >> n;
    vector<ll> a(n + 1);
    for (int i = 1; i <= n; i++) cin >> a[i];
    ll ans = -INF, now = n;
    for (int i = 1; i <= n; i++) {
        ll sum = accumulate(a.begin(), a.begin() + now + 1, 0);
        if (i == 1) ans = max(ans, sum);
        else ans = max(ans, abs(sum));
        for (int j = 1; j < now; j++)
            a[j] = a[j + 1] - a[j];
        now--;
    }
    cout << ans << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int T = 1;
    cin >> T;
    while (T--)
        solve();

    return 0;
}
/*

1
4
1 1 1 1
1 1 1 1
1 1 1 2
1 1 1 2


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


Submission (verdict: Wrong answer on test 2):
#define _GLIBCXX_FILESYSTEM
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int maxn = 1e9 + 10;
const int INF = 1e9 + 100;
const int mod = 998244353;

void solve() {
    int n;
    cin >> n;
    vector<int> a(n + 1);
    for (int i = 1; i <= n; i++) cin >> a[i];
    int ans = -INF, now = n;
    for (int i = 1; i <= n; i++) {
        int sum = accumulate(a.begin(), a.begin() + now + 1, 0);
        if (i == 1) ans = max(ans, sum);
        else ans = max(ans, abs(sum));
        for (int j = 1; j < now; j++)
            a[j] = a[j + 1] - a[j];
        now--;
    }
    cout << ans << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int T = 1;
    cin >> T;
    while (T--)
        solve();

    return 0;
}
/*

1
4
1 1 1 1
1 1 1 1
1 1 1 2
1 1 1 2


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

Previous submission (verdict: Wrong answer on test 2):
#define _GLIBCXX_FILESYSTEM
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int maxn = 1e9 + 10;
const int INF = 1e9 + 100;
const int mod = 998244353;

void solve() {
    int n;
    cin >> n;
    vector<ll> a(n + 1);
    for (int i = 1; i <= n; i++) cin >> a[i];
    ll ans = -INF, now = n;
    for (int i = 1; i <= n; i++) {
        ll sum = accumulate(a.begin(), a.begin() + now + 1, 0);
        if (i == 1) ans = max(ans, sum);
        else ans = max(ans, abs(sum));
        for (int j = 1; j < now; j++)
            a[j] = a[j + 1] - a[j];
        now--;
    }
    cout << ans << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int T = 1;
    cin >> T;
    while (T--)
        solve();

    return 0;
}
/*

1
4
1 1 1 1
1 1 1 1
1 1 1 2
1 1 1 2


*/

Submission (verdict: Accepted):
#define _GLIBCXX_FILESYSTEM
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int maxn = 1e9 + 10;
const ll INF = 1e18 + 100;
const int mod = 998244353;

void solve() {
    int n;
    cin >> n;
    vector<ll> a(n + 1);
    for (int i = 1; i <= n; i++) cin >> a[i];
    ll ans = -INF;
    int now = n;
    for (int i = 1; i <= n; i++) {
        ll sum = 0;
        for (int i = 1; i <= now; i++) sum += a[i];
        if (i == 1) ans = max(ans, sum);
        else ans = max(ans, abs(sum));
        for (int j = 1; j < now; j++)
            a[j] = a[j + 1] - a[j];
        now--;
    }
    cout << ans << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int T = 1;
    cin >> T;
    while (T--)
        solve();

    return 0;
}
/*

1
4
1 1 1 1
1 1 1 1
1 1 1 2
1 1 1 2


*/