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;



using ll = long long;

using i128 = __int128;

using pii = pair<int, int>;

using pll = pair<ll, ll>;

constexpr int inf = 0x3f3f3f3f;

constexpr ll linf = 0x3f3f3f3f3f3f3f3f;



#define WA {cout << "NO" << '\n';return ;}

#define AC {cout << "YES" << '\n';return ;}



void solve() {

	// Your code here

	int N;

	cin >> N;

	std::vector<int> v(N);

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

		cin >> v[i];

	}

	if (N == 1) {

		AC;

	}

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

		WA;

	}

	/*

		2   3  4  1

		0   1  4  1

		0   0  3  1

	*/

	vector<int> suf(N);

	suf[N - 1] = v[N - 1];

	for (int i = N - 2; i; i--) {

		suf[i] = min(suf[i + 1], v[i]);

	}



	//5 4

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

		if (v[i] > suf[i + 1]) {

			if (i == 0) {

				WA;

			}

			while (v[i] > suf[i + 1]) {

				int d = min(v[i - 1], v[i]);

				if (d <= 0) {

					WA;

				}

				v[i - 1] -= d, v[i] -= d;

			}

		}

	}



	AC;

}



int main()

{

	ios::sync_with_stdio(false), cin.tie(0);

	int t = 1;

	cin >> t;

	while (t--) {

		solve();

	}

	return 0;

}

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

using namespace std;



using ll = long long;

using i128 = __int128;

using pii = pair<int, int>;

using pll = pair<ll, ll>;

constexpr int inf = 0x3f3f3f3f;

constexpr ll linf = 0x3f3f3f3f3f3f3f3f;



#define WA {cout << "NO" << '\n';return ;}

#define AC {cout << "YES" << '\n';return ;}



void solve() {

	// Your code here

	int N;

	cin >> N;

	std::vector<int> v(N);

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

		cin >> v[i];

	}

	// ???????????

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

		if (v[i] <= v[i + 1]) {

			v[i + 1] -= min(v[i], v[i + 1]);

		} else {

			WA;

		}

	}

	AC;

}



int main()

{

	ios::sync_with_stdio(false), cin.tie(0);

	int t = 1;

	cin >> t;

	while (t--) {

		solve();

	}

	return 0;

}
Problem: 2061D - Kevin and Numbers
Language: C++20 (GCC 13-64)


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

#define int long long

#define pp pair<int,int>

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

#define rall(a) a.rbegin(),a.rend()

using namespace std;

void remove(int val,map <int,int> &mp) {

    mp[val]--;

    if(mp[val]==0)

        mp.erase(val);

}

void form(int val,map <int,int> &mp) {

    if(mp.size()==0)return;

    if(val<mp.begin()->first)return;

    

    if(val&1) {

        int x=(val-1)/2,y=x+1;

        if(mp.find(x)!=mp.end() && mp.find(y)!=mp.end()) {

            remove(x,mp);

            remove(y,mp);

            mp[val]++;

        }

        else if(mp.find(x)!=mp.end()) {

            form(y,mp);

            if(mp.find(y)!=mp.end()) {

                remove(y,mp);

                remove(x,mp);

                mp[val]++;

            }

        }

        else if(mp.find(y)!=mp.end()) {

            form(x,mp);

            if(mp.find(x)!=mp.end()) {

                remove(x,mp);

                remove(y,mp);

                mp[val]++;

            }

        }

        else {

            form(x,mp);

            form(y,mp);

            if(mp.find(x)!=mp.end() && mp.find(y)!=mp.end()) {

                remove(x,mp);

                remove(y,mp);

                mp[val]++;

            }

        }

    }

    else {

        int x=val/2;

        if(mp[x]>=2) {

            remove(x,mp);

            remove(x,mp);

            mp[val]++;

        }

        else if(mp.find(x)!=mp.end()) {

            form(x,mp);

            if(mp[x]>=2) {

                remove(x,mp);

                remove(x,mp);

                mp[val]++;

            }

        }

        else {

            form(x,mp);

            form(x,mp);

            if(mp[x]>=2) {

                remove(x,mp);

                remove(x,mp);

                mp[val]++;

            }

        }

    }   



}

void solve()

{

    int n,m;cin>>n>>m;

    vector <int> a(n),b(m);

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

    for(int i=0;i<m;i++)cin>>b[i];

    

    map <int,int> mp;

    for(int i:a)

        mp[i]++;



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

        if(mp.find(b[i])!=mp.end()) {

            remove(b[i],mp);

        }

        else {

            form(b[i],mp);

            if(mp.find(b[i])!=mp.end()) {

                remove(b[i],mp);

            }

            else {

                cout<<"No"<<endl;

                return;

            }

        }

    }

    if(mp.size()==0)

        cout<<"Yes"<<endl;

    else

        cout<<"No"<<endl;

    

}

signed main()

{

    cin.tie()->sync_with_stdio(false);

    int t;cin>>t;

    while(t--)solve();

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

Previous submission (verdict: Wrong answer on test 8):
#include<iostream>

#include<vector>

#include<algorithm>

#include<unordered_map>

#include<utility>

#include<string>

using namespace std;

typedef long long ll;



int t;



bool comp(int a, int b){

    return a > b;

}



void solve(){

    int n, l, r;

    int sum = 0;

    cin>>n>>l>>r;

    vector<int> a(n);

    l--; r--;

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

        cin >> a[i];

        if(i >= l && i <= r) sum += a[i];

    }



    sort(a.begin() + l, a.begin() + r + 1, comp);

    sort(a.begin(), a.begin() + l);

    sort(a.begin() + r + 1, a.end());



    int ptr1 = 0, ptr2 = l, ptr3 = r + 1;

    int sum1 = 0, sum2 = 0, sum3 = 0;

    int ans = sum;



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

        sum1 += a[ptr1];

        sum2 += a[ptr2];

        ans = min(ans, sum - sum2 + sum1);

        ptr1++; ptr2++;

    }



    ptr2 = l;

    sum2 = 0;



    for(int i = 1; i <= min(n - r - 1, r - l + 1); i++){

        sum3 += a[ptr3];

        sum2 += a[ptr2];

        ans = min(ans, sum - sum2 + sum3);

        ptr3++; ptr2++;

    }



    cout<<ans;

    cout<<endl;

}



int main(){

    cin >> t;

    while(t--){

        solve();

    }

}

Submission (verdict: Accepted):
#include<iostream>

#include<vector>

#include<algorithm>

#include<unordered_map>

#include<utility>

#include<string>

using namespace std;

typedef long long ll;



int t;



bool comp(int a, int b){

    return a > b;

}



void solve(){

    int n, l, r;

    ll sum = 0;

    cin>>n>>l>>r;

    vector<int> a(n);

    l--; r--;

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

        cin >> a[i];

        if(i >= l && i <= r) sum += a[i];

    }



    sort(a.begin() + l, a.begin() + r + 1, comp);

    sort(a.begin(), a.begin() + l);

    sort(a.begin() + r + 1, a.end());



    int ptr1 = 0, ptr2 = l, ptr3 = r + 1;

    ll sum1 = 0, sum2 = 0, sum3 = 0;

    ll ans = sum;



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

        sum1 += a[ptr1];

        sum2 += a[ptr2];

        ans = min(ans, sum - sum2 + sum1);

        ptr1++; ptr2++;

    }



    ptr2 = l;

    sum2 = 0;



    for(int i = 1; i <= min(n - r - 1, r - l + 1); i++){

        sum3 += a[ptr3];

        sum2 += a[ptr2];

        ans = min(ans, sum - sum2 + sum3);

        ptr3++; ptr2++;

    }



    cout<<ans;

    cout<<endl;

}



int main(){

    cin >> t;

    while(t--){

        solve();

    }

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


Submission (verdict: Wrong answer on test 2):
#include<iostream>

#include<vector>

#include<algorithm>

#include<unordered_map>

#include<utility>

#include<string>

using namespace std;

typedef long long ll;



int t;



bool comp(int a, int b){

    return a > b;

}



void solve(){

    int n, l, r;

    int sum = 0;

    cin>>n>>l>>r;

    vector<int> a(n);

    l--; r--;

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

        cin >> a[i];

        if(i >= l && i <= r) sum += a[i];

    }



    sort(a.begin() + l, a.begin() + r + 1, comp);

    sort(a.begin(), a.begin() + l + 1);

    sort(a.begin() + r + 1, a.end());



    int ptr1 = 0, ptr2 = l, ptr3 = r + 1;

    int sum1 = 0, sum2 = 0, sum3 = 0;

    int ans = sum;



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

        sum1 += a[ptr1];

        sum2 += a[ptr2];

        ans = min(ans, sum - sum2 + sum1);

        ptr1++; ptr2++;

    }



    ptr2 = l;

    sum2 = 0;



    for(int i = 1; i <= min(n - r - 1, r - l + 1); i++){

        sum3 += a[ptr3];

        sum2 += a[ptr2];

        ans = min(ans, sum - sum2 + sum3);

        ptr3++; ptr2++;

    }



    cout<<ans;

    cout<<endl;

}



int main(){

    cin >> t;

    while(t--){

        solve();

    }

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

Previous submission (verdict: Wrong answer on test 2):
#include<iostream>

#include<vector>

#include<algorithm>

#include<unordered_map>

#include<utility>

#include<string>

using namespace std;

typedef long long ll;



int t;



bool comp(int a, int b){

    return a > b;

}



void solve(){

    int n, l, r;

    int sum = 0;

    cin>>n>>l>>r;

    vector<int> a(n);

    l--; r--;

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

        cin >> a[i];

        if(i >= l && i <= r) sum += a[i];

    }



    sort(a.begin() + l, a.begin() + r + 1, comp);

    sort(a.begin(), a.begin() + l + 1);

    sort(a.begin() + r + 1, a.end());



    int ptr1 = 0, ptr2 = l, ptr3 = r + 1;

    int sum1 = 0, sum2 = 0, sum3 = 0;

    int ans = sum;



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

        sum1 += a[ptr1];

        sum2 += a[ptr2];

        ans = min(ans, sum - sum2 + sum1);

        ptr1++; ptr2++;

    }



    ptr2 = l;

    sum2 = 0;



    for(int i = 1; i <= min(n - r - 1, r - l + 1); i++){

        sum3 += a[ptr3];

        sum2 += a[ptr2];

        ans = min(ans, sum - sum2 + sum3);

        ptr3++; ptr2++;

    }



    cout<<ans;

    cout<<endl;

}



int main(){

    cin >> t;

    while(t--){

        solve();

    }

}

Submission (verdict: Wrong answer on test 8):
#include<iostream>

#include<vector>

#include<algorithm>

#include<unordered_map>

#include<utility>

#include<string>

using namespace std;

typedef long long ll;



int t;



bool comp(int a, int b){

    return a > b;

}



void solve(){

    int n, l, r;

    int sum = 0;

    cin>>n>>l>>r;

    vector<int> a(n);

    l--; r--;

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

        cin >> a[i];

        if(i >= l && i <= r) sum += a[i];

    }



    sort(a.begin() + l, a.begin() + r + 1, comp);

    sort(a.begin(), a.begin() + l);

    sort(a.begin() + r + 1, a.end());



    int ptr1 = 0, ptr2 = l, ptr3 = r + 1;

    int sum1 = 0, sum2 = 0, sum3 = 0;

    int ans = sum;



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

        sum1 += a[ptr1];

        sum2 += a[ptr2];

        ans = min(ans, sum - sum2 + sum1);

        ptr1++; ptr2++;

    }



    ptr2 = l;

    sum2 = 0;



    for(int i = 1; i <= min(n - r - 1, r - l + 1); i++){

        sum3 += a[ptr3];

        sum2 += a[ptr2];

        ans = min(ans, sum - sum2 + sum3);

        ptr3++; ptr2++;

    }



    cout<<ans;

    cout<<endl;

}



int main(){

    cin >> t;

    while(t--){

        solve();

    }

}
Problem: 2050D - Digital string maximization
Language: C++20 (GCC 13-64)


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



using namespace std;



#define endl '\n'



#define MAX_INT ((int64_t)1E18 + 1000)

#define makefn(fn) [](auto... args) { return fn(args...); }

using ll = long long;

#define int ll



void solution() {

  string s;

  cin >> s;

  for(int i = 0; i < s.size(); i++) {

    int best = s[i] - '0';

    int max_pos =i;

    for(int j = i+1; j < s.size() && j < i+10;j++) {

      if(best< s[j] - '0'){

        max_pos = j;

        best = s[j] - '0';

      }

      while(max_pos > i) {

        swap(s[max_pos], s[max_pos-1]);

        max_pos --;

      }

    }

    s[i] = (char) best  + '0';

  }

  cout << s << endl;







}



int32_t main() {

  ios_base::sync_with_stdio(false);

  cin.tie(nullptr), cout.tie(nullptr);

  int t;

  cin >> t;

  while (t--)

    solution();



  return 0;

}
Problem: 2050D - Digital string maximization
Language: C++20 (GCC 13-64)

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



using namespace std;



#define endl '\n'



#define MAX_INT ((int64_t)1E18 + 1000)

#define makefn(fn) [](auto... args) { return fn(args...); }

using ll = long long;

#define int ll



void solution() {

  string s;

  cin >> s;

  for (int i = 0; i < s.size(); i++) {

    int best = s[i] - '0';

    int max_pos = i;

    for (int j = i + 1; j < s.size() && j < i + 10; j++) {

      if (best < s[j] - '0' - (j - i)) {

        max_pos = j;

        best = s[j] - '0' - (j - i);

      }

    }

    while (max_pos > i) {

      swap(s[max_pos], s[max_pos - 1]);

      max_pos--;

    }

    s[i] = (char)best + '0';

  }

  cout << s << endl;

}



int32_t main() {

  ios_base::sync_with_stdio(false);

  cin.tie(nullptr), cout.tie(nullptr);

  int t;

  cin >> t;

  while (t--)

    solution();



  return 0;

}



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

using namespace std;



void testcase()

{

    string s; cin >> s;

    int n = s.length();

    

    vector<int> a(n);

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

    {

        a[i] = s[i] - '0';

    }

    

    int x; int ind;

    

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

    {

        x = a[i];

        for(int j = 1; j < 9 and i + j < n; j++)

        {

            if (x < a[i+j] - j)

            {

                x = a[i+j] - j;

                ind = i+j;

            }

        }

        

        if (x != a[i])

        {

            for(int j = ind; j >= i+1; j--)

            {

                a[j] = a[j-1];

            }

            

            a[i] = x;

        }

    }

    

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

    {

        cout << a[i];

    }

    

    cout << endl;

}



int main()

{

    int t; cin >> t;

    while(t--) testcase();

    return 0;

}
Problem: 2050D - Digital string maximization
Language: C++20 (GCC 13-64)

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



using namespace std;



#define endl '\n'



#define MAX_INT ((int64_t)1E18 + 1000)

#define makefn(fn) [](auto... args) { return fn(args...); }

using ll = long long;

#define int ll



void solution() {

  string s;

  cin >> s;

  for(int i = 0; i < s.size(); i++) {

    int best = s[i] - '0';

    int max_pos =i;

    for(int j = i+1; j < s.size() && j < i+10;j++) {

      if(best< s[j] - '0'){

        max_pos = j;

        best = s[j] - '0';

      }

      while(max_pos > i) {

        swap(s[max_pos], s[max_pos-1]);

        max_pos --;

      }

    }

    s[i] = (char) best  + '0';

  }

  cout << s << endl;







}



int32_t main() {

  ios_base::sync_with_stdio(false);

  cin.tie(nullptr), cout.tie(nullptr);

  int t;

  cin >> t;

  while (t--)

    solution();



  return 0;

}



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



using namespace std;



#define endl '\n'



#define MAX_INT ((int64_t)1E18 + 1000)

#define makefn(fn) [](auto... args) { return fn(args...); }

using ll = long long;

#define int ll



void solution() {

  string s;

  cin >> s;

  for (int i = 0; i < s.size(); i++) {

    int best = s[i] - '0';

    int max_pos = i;

    for (int j = i + 1; j < s.size() && j < i + 10; j++) {

      if (best < s[j] - '0' - (j - i)) {

        max_pos = j;

        best = s[j] - '0' - (j - i);

      }

    }

    while (max_pos > i) {

      swap(s[max_pos], s[max_pos - 1]);

      max_pos--;

    }

    s[i] = (char)best + '0';

  }

  cout << s << endl;

}



int32_t main() {

  ios_base::sync_with_stdio(false);

  cin.tie(nullptr), cout.tie(nullptr);

  int t;

  cin >> t;

  while (t--)

    solution();



  return 0;

}
Problem: 2057B - Gorilla and the Exam
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
#include <cmath>
#include <cstddef>
#define Mahmoud ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define ull unsigned long long
#define f(i,x,n) for(int i=x;i<n;i++)
#define Ef(i,x,n) for(int i=x;i<=n;i++)
#define If(i,x,n,inc) for(int i=x;i<n;i+=inc)
#define Rf(i,n,a) for(int i=n;i>=a;i--)
#define pb push_back
#define pf push_front
#define b_e(v) v.begin(),v.end()
#define rb_e(v) v.rbegin(),v.rend()
#define xD 0
using namespace std;
void setIO(string s) {
    freopen((s + ".in").c_str(), "r", stdin);
    freopen((s + ".out").c_str(), "w", stdout);
}
const ll MAX=1e5+5;

int main() {
    Mahmoud
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t;
    cin>>t;
    while(t--){
        int n,k,a[MAX];
        cin>>n>>k;
        unordered_map<int,int>mp;
        for(int i=0;i<n;i++){
            cin>>a[i];
            mp[a[i]]++;
        }
        vector<int>cnt;
        cnt.reserve(mp.size());
        for(auto &p:mp)cnt.pb(p.second);
        sort(b_e(cnt),greater<int>());
        if(n-cnt[0]<=k)cout<<1<<endl;
        int d=0,sm=0;
        for(int x:cnt){
            sm+=x;
            d++;
            if(n-sm<=k)break;
        }
        cout<<d<<endl;

    }
    return xD;
}
Problem: 2057B - Gorilla and the Exam
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
#include <cmath>
#include <cstddef>
#define Mahmoud ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define ull unsigned long long
#define f(i,x,n) for(int i=x;i<n;i++)
#define Ef(i,x,n) for(int i=x;i<=n;i++)
#define If(i,x,n,inc) for(int i=x;i<n;i+=inc)
#define Rf(i,n,a) for(int i=n;i>=a;i--)
#define pb push_back
#define pf push_front
#define b_e(v) v.begin(),v.end()
#define rb_e(v) v.rbegin(),v.rend()
#define xD 0
using namespace std;
void setIO(string s) {
    freopen((s + ".in").c_str(), "r", stdin);
    freopen((s + ".out").c_str(), "w", stdout);
}
const ll MAX=1e5+5;

int main() {
    Mahmoud
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t;
    cin>>t;
    while(t--){
        int n,k,a[MAX];
        cin>>n>>k;
        unordered_map<int,int>mp;
        for(int i=0;i<n;i++){
            cin>>a[i];
            mp[a[i]]++;
        }
        vector<int>cnt;
        cnt.reserve(mp.size());
        for(auto &p:mp)cnt.pb(p.second);
        sort(b_e(cnt),greater<int>());
        if(n-cnt[0]<=k)cout<<1<<endl;
        int d=0,sm=0;
        for(int x:cnt){
            sm+=x;
            d++;
            if(n-sm<=k)break;
        }
        cout<<d<<endl;

    }
    return xD;
}

Submission (verdict: Time limit exceeded on test 11):
#include <bits/stdc++.h>
#include <cmath>
#include <cstddef>
#define Mahmoud ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define ull unsigned long long
#define f(i,x,n) for(int i=x;i<n;i++)
#define Ef(i,x,n) for(int i=x;i<=n;i++)
#define If(i,x,n,inc) for(int i=x;i<n;i+=inc)
#define Rf(i,n,a) for(int i=n;i>=a;i--)
#define pb push_back
#define pf push_front
#define b_e(v) v.begin(),v.end()
#define rb_e(v) v.rbegin(),v.rend()
#define xD 0
using namespace std;
void setIO(string s) {
    freopen((s + ".in").c_str(), "r", stdin);
    freopen((s + ".out").c_str(), "w", stdout);
}
const ll MAX=1e5+5;

int main() {
    Mahmoud
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t;
    cin>>t;
    while(t--){
        int n,k,a[MAX];
        cin>>n>>k;
        unordered_map<int,int>mp;
        for(int i=0;i<n;i++){
            cin>>a[i];
            mp[a[i]]++;
        }
        vector<int>cnt;
        cnt.reserve(mp.size());
        for(auto &p:mp)cnt.pb(p.second);
        sort(b_e(cnt),greater<int>());

        if(n-cnt[0]<=k){
            cout<<1<<endl;
            continue;
        }
        int d=0,sm=0;
        for(int x:cnt){
            sm+=x;
            d++;
            if(n-sm<=k)break;
        }
        cout<<d<<endl;

    }
    return xD;
}
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;
#define int long long
typedef pair<int,int> pe;
void solve()
{
   int n;
   cin>>n;
  vector<int>v(n);
  int sum=0;
  for(int i=0;i<n;i++)
  {
      int vla;
      cin>>vla;
      v[i]=vla;
      sum+=v[i];
  }
 while(v.size()!=1)
 {
     reverse(v.begin(),v.end());
     int ans=0;
     for(int i=0;i<n-1;i++)
     {
         v[i]=v[i+1]-v[i];
         
     }
     v.pop_back();
 }
 sum=max(sum,v[0]);
 cout<<sum<<"\n";
   
    
}
signed main()
{
    int t;
    cin>>t;
    while(t--)
    {
        solve();
    }
}
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;
#define int long long 
typedef pair<int,int> pe;
void solve()
{
   int n;
   cin>>n;
  vector<double>v(n);
  double sum=0;
  for(int i=0;i<n;i++)
  {
      int vla;
      cin>>vla;
      v[i]=vla;
      sum+=v[i];
  }
 while(v.size()!=1)
 {
     reverse(v.begin(),v.end());
     int ans=0;
     for(int i=0;i<n-1;i++)
     {
         v[i]=v[i+1]-v[i];
         
     }
     v.pop_back();
 }
 sum=max(sum,v[0]);
 cout<<sum<<"\n";
   
    
}
signed main()
{
    int t;
    cin>>t;
    while(t--)
    {
        solve();
    }
}


Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;
#define int long long 
typedef pair<int,int> pe;

void solve()
{
  
		int n;
		cin >> n;
		vector<int>a(n+1);
		for (int i = 1; i <= n; i++) cin >> a[i];
		int now = n;
		long long ans = -1e18;
		for (int i = 1; i <= n; i++){
			long long sum = 0;
			for (int i = 1; i <= now; i++) sum = (sum + a[i]) ;
			if (i == 1) ans = max(ans, sum);
			else ans = max(ans, max(sum, ( - sum) ));
			for (int i = 1; i < now; i++) a[i] = (a[i + 1] - a[i]) ;
			now--;
		}
		cout << ans << endl; 

	
   
    
}
signed main()
{
    int t;
    cin>>t;
    while(t--)
    {
        solve();
    }
}
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;
#define int long long
typedef pair<int,int> pe;
void solve()
{
   int n;
   cin>>n;
  vector<int>v(n);
  int sum=0;
  for(int i=0;i<n;i++)
  {
      int vla;
      cin>>vla;
      v[i]=vla;
      sum+=v[i];
  }
 while(v.size()!=1)
 {
     reverse(v.begin(),v.end());
     int ans=0;
     for(int i=0;i<n-1;i++)
     {
         v[i]=v[i+1]-v[i];
         
     }
     v.pop_back();
 }
 sum=max(sum,v[0]);
 cout<<sum<<"\n";
   
    
}
signed main()
{
    int t;
    cin>>t;
    while(t--)
    {
        solve();
    }
}


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
#define int long long 
typedef pair<int,int> pe;
void solve()
{
   int n;
   cin>>n;
  vector<double>v(n);
  double sum=0;
  for(int i=0;i<n;i++)
  {
      int vla;
      cin>>vla;
      v[i]=vla;
      sum+=v[i];
  }
 while(v.size()!=1)
 {
     reverse(v.begin(),v.end());
     int ans=0;
     for(int i=0;i<n-1;i++)
     {
         v[i]=v[i+1]-v[i];
         
     }
     v.pop_back();
 }
 sum=max(sum,v[0]);
 cout<<sum<<"\n";
   
    
}
signed main()
{
    int t;
    cin>>t;
    while(t--)
    {
        solve();
    }
}