ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2061D - Kevin and Numbers
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Memory limit exceeded on test 6):
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
using namespace std;
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int t; 
    cin >> t;
    while(t--){
        int n, m;
        cin >> n >> m;
        long long sumA = 0, sumB = 0;
        vector<long long> a(n), b(m);
        
        for (int i = 0; i < n; i++){
            cin >> a[i];
            sumA += a[i];
        }
        for (int i = 0; i < m; i++){
            cin >> b[i];
            sumB += b[i];
        }
 
        // The sum invariant must hold.
        if(sumA != sumB){
            cout << "No\n";
            continue;
        }
 
        // Build a frequency map for the original numbers (sequence a).
        unordered_map<long long,int> freq;
        freq.reserve(n * 2);
        for (auto x : a)
            freq[x]++;
 
        // Use a max-heap to simulate splitting the numbers from b.
        priority_queue<long long> pq;
        for (auto x : b)
            pq.push(x);
 
        int matched = 0; // number of elements from a that we have "matched"
        bool possible = true;
 
        while(!pq.empty() && matched < n){
            long long cur = pq.top();
            pq.pop();
            // If cur appears in a then we “take” it.
            if(freq.find(cur) != freq.end() && freq[cur] > 0){
                freq[cur]--;
                matched++;
                continue;
            }
            // If cur is 1 and it is not in a, then we cannot split it further.
            if(cur == 1){
                possible = false;
                break;
            }
            // Otherwise, split cur into the only two valid numbers.
            if(cur % 2 == 0){
                pq.push(cur / 2);
                pq.push(cur / 2);
            } else {
                pq.push(cur / 2);
                pq.push(cur / 2 + 1);
            }
        }
 
        cout << (matched == n && possible ? "Yes" : "No") << "\n";
    }
    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 fastio()                      \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)
#define MOD 1000000007
#define MOD1 998244353
#define INF 1e18
#define PI 3.141592653589793238462
#define int long long
int pri[1000100];

vector<int> getdiv(int n)
{
    vector<int> ans;
    for (int i = 1; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            if (pri[i] == 1)
                ans.push_back(i);
            if (i != n / i && pri[n / i] == 1)
                ans.push_back(n / i);
        }
    }
    sort(ans.begin(), ans.end());
    ans.erase(unique(ans.begin(), ans.end()), ans.end());
    return ans;
}
void sieve()
{
    fill(pri + 2, pri + 1000100, 1);
    for (int i = 2; i * i <= 1e6; i++)
    {
        if (pri[i] == 1)
        {
            for (int j = i * i; j <= 1e6; j += i)
            {
                pri[j] = 0;
            }
        }
    }
}
signed solve()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];
    if (n <= 2)
    {
        if (a[0] > a[1])
        {
            cout << "NO" << endl;
            return 0;
        }
        cout << "YES" << endl;
        return 0;
    }
    for (int i = 1; i < n; i++)
    {
        if (a[i] > a[i + 1] && a[i] < a[i - 1])
        {
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;

    return 0;
}

signed main()
{
    fastio();
    int testcase;
    cin >> testcase;
    while (testcase--)
    {
        solve();
    }
    return 0;
}
Problem: 2049C - MEX Cycle
Language: C++23 (GCC 14-64, msys2)

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

#include <bits/stdc++.h>

#define max(a, b) (a < b ? b : a)

#define min(a, b) ((a > b) ? b : a)

#define SZ(X) ((int)(X).size())

#define ALL(X) (X).begin(), (X).end()

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

typedef long long int ll;

typedef std::vector<int> vi;

typedef std::pair<int, int> pi;

#define clr(arr,value) memset(arr,value,sizeof(arr))

#define F first

#define S second

//#define int long long

#define el '\n'

#define OO 100000000000000

const ll MOD = 1e9 +7;

const int N = 2e5+5;

using namespace std;

typedef unordered_map<int,unordered_set<int>> HASHSET ;









int dx []= {0,0,1,-1,-1,1,-1,1};

int dy []= {1,-1,0,0,-1,1,1,-1};







void PLAY(){

    int n , x, y;

    cin >> n >> x>> y;

    --x;--y;

    vi ans(n);

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

        ans[i] = (i&1?0:1);

    }

    if (n&1)ans[n-1]=2;

    if (!(abs(x-y)==1 || ans[x] != ans[y] || y-x == n-1)){

        x =  (x == 0)?y:x;

        ans[x] = 2;

    }

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

        cout << ans[i] << ' ';

    }

    cout << el;

}





int main() {



    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

//    freopen("input.txt","r",stdin);

//    freopen("output.txt", "w", stdout);

    int T = 1 ;

    cin >> T;



    while (T--){

        PLAY();

    }



    return 0;



}

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

#include <bits/stdc++.h>

#define max(a, b) (a < b ? b : a)

#define min(a, b) ((a > b) ? b : a)

#define SZ(X) ((int)(X).size())

#define ALL(X) (X).begin(), (X).end()

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

typedef long long int ll;

typedef std::vector<int> vi;

typedef std::pair<int, int> pi;

#define clr(arr,value) memset(arr,value,sizeof(arr))

#define F first

#define S second

//#define int long long

#define el '\n'

#define OO 100000000000000

const ll MOD = 1e9 +7;

const int N = 2e5+5;

using namespace std;

typedef unordered_map<int,unordered_set<int>> HASHSET ;









int dx []= {0,0,1,-1,-1,1,-1,1};

int dy []= {1,-1,0,0,-1,1,1,-1};







void PLAY(){

    int n , x, y;

    cin >> n >> x>> y;

    --x;--y;

    vi ans(n);

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

        ans[i] = (i&1?1:0);

    }

    if (n&1)ans[n-1]=2;

    if (!(abs(x-y)==1 || ans[x] != ans[y] || y-x == n-1)){

        x =  (x == 0)?y:x;

        ans[x] = 2;

    }

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

        cout << ans[i] << ' ';

    }

    cout << el;

}





int main() {



    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

//    freopen("input.txt","r",stdin);

//    freopen("output.txt", "w", stdout);

    int T = 1 ;

    cin >> T;



    while (T--){

        PLAY();

    }



    return 0;



}
Problem: 2049C - MEX Cycle
Language: C++23 (GCC 14-64, msys2)

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

#include <bits/stdc++.h>

#define max(a, b) (a < b ? b : a)

#define min(a, b) ((a > b) ? b : a)

#define SZ(X) ((int)(X).size())

#define ALL(X) (X).begin(), (X).end()

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

typedef long long int ll;

typedef std::vector<int> vi;

typedef std::pair<int, int> pi;

#define clr(arr,value) memset(arr,value,sizeof(arr))

#define F first

#define S second

//#define int long long

#define el '\n'

#define OO 100000000000000

const ll MOD = 1e9 +7;

const int N = 2e5+5;

using namespace std;

typedef unordered_map<int,unordered_set<int>> HASHSET ;









int dx []= {0,0,1,-1,-1,1,-1,1};

int dy []= {1,-1,0,0,-1,1,1,-1};







void PLAY(){

    int n , x, y;

    cin >> n >> x>> y;

    --x;--y;

    vi ans(n);

    bool f = x&1?0:1;

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

        ans[i] = (i&1?f:!f);

    }

    if (n&1)ans[n-1]=2;

    if (!(abs(x-y)==1 || ans[x] != ans[y] || y-x == n-1)){

        x =  (x == 0)?y:x;

        ans[x] = 2;

    }

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

        cout << ans[i] << ' ';

    }

    cout << el;

}





int main() {



    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

//    freopen("input.txt","r",stdin);

//    freopen("output.txt", "w", stdout);

    int T = 1 ;

    cin >> T;



    while (T--){

        PLAY();

    }



    return 0;



}

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

#include <bits/stdc++.h>

#define max(a, b) (a < b ? b : a)

#define min(a, b) ((a > b) ? b : a)

#define SZ(X) ((int)(X).size())

#define ALL(X) (X).begin(), (X).end()

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

typedef long long int ll;

typedef std::vector<int> vi;

typedef std::pair<int, int> pi;

#define clr(arr,value) memset(arr,value,sizeof(arr))

#define F first

#define S second

//#define int long long

#define el '\n'

#define OO 100000000000000

const ll MOD = 1e9 +7;

const int N = 2e5+5;

using namespace std;

typedef unordered_map<int,unordered_set<int>> HASHSET ;









int dx []= {0,0,1,-1,-1,1,-1,1};

int dy []= {1,-1,0,0,-1,1,1,-1};







void PLAY(){

    int n , x, y;

    cin >> n >> x>> y;

    --x;--y;

    vi ans(n);

    bool f = x&1?1:0;

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

        ans[i] = (i&1?f:!f);

    }

    if (n&1)ans[n-1]=2;

    if (!(abs(x-y)==1 || ans[x] != ans[y] || y-x == n-1)){

        x =  (x == 0)?y:x;

        ans[x] = 2;

    }

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

        cout << ans[i] << ' ';

    }

    cout << el;

}





int main() {



    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

//    freopen("input.txt","r",stdin);

//    freopen("output.txt", "w", stdout);

    int T = 1 ;

    cin >> T;



    while (T--){

        PLAY();

    }



    return 0;



}
Problem: 2049C - MEX Cycle
Language: C++23 (GCC 14-64, msys2)


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

#include <bits/stdc++.h>

#define max(a, b) (a < b ? b : a)

#define min(a, b) ((a > b) ? b : a)

#define SZ(X) ((int)(X).size())

#define ALL(X) (X).begin(), (X).end()

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

typedef long long int ll;

typedef std::vector<int> vi;

typedef std::pair<int, int> pi;

#define clr(arr,value) memset(arr,value,sizeof(arr))

#define F first

#define S second

//#define int long long

#define el '\n'

#define OO 100000000000000

const ll MOD = 1e9 +7;

const int N = 2e5+5;

using namespace std;

typedef unordered_map<int,unordered_set<int>> HASHSET ;









int dx []= {0,0,1,-1,-1,1,-1,1};

int dy []= {1,-1,0,0,-1,1,1,-1};







void PLAY(){

    int n , x, y;

    cin >> n >> x>> y;

    --x;--y;

    vi ans(n);

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

        ans[i] = (i&1?0:1);

    }

    if (n&1)ans[n-1]=2;

    if (!(abs(x-y)==1 || ans[x] != ans[y] || y-x == n-1)){

        x =  (x == 0)?y:x;

        ans[x] = 2;

    }

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

        cout << ans[i] << ' ';

    }

    cout << el;

}





int main() {



    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

//    freopen("input.txt","r",stdin);

//    freopen("output.txt", "w", stdout);

    int T = 1 ;

    cin >> T;



    while (T--){

        PLAY();

    }



    return 0;



}
Problem: 2049C - MEX Cycle
Language: C++23 (GCC 14-64, msys2)

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

#include <bits/stdc++.h>

#define max(a, b) (a < b ? b : a)

#define min(a, b) ((a > b) ? b : a)

#define SZ(X) ((int)(X).size())

#define ALL(X) (X).begin(), (X).end()

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

typedef long long int ll;

typedef std::vector<int> vi;

typedef std::pair<int, int> pi;

#define clr(arr,value) memset(arr,value,sizeof(arr))

#define F first

#define S second

//#define int long long

#define el '\n'

#define OO 100000000000000

const ll MOD = 1e9 +7;

const int N = 2e5+5;

using namespace std;

typedef unordered_map<int,unordered_set<int>> HASHSET ;









int dx []= {0,0,1,-1,-1,1,-1,1};

int dy []= {1,-1,0,0,-1,1,1,-1};







void PLAY(){

    int n , x, y;

    cin >> n >> x>> y;

    --x;--y;

    vi ans(n);

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

        ans[i] = (i&1?1:0);

    }

    if (n&1)ans[n-1]=2;

    if (!(abs(x-y)==1 || ans[x] != ans[y] || y-x == n-1)){

        x =  (x == 0)?y:x;

        ans[x] = 2;

    }

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

        cout << ans[i] << ' ';

    }

    cout << el;

}





int main() {



    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

//    freopen("input.txt","r",stdin);

//    freopen("output.txt", "w", stdout);

    int T = 1 ;

    cin >> T;



    while (T--){

        PLAY();

    }



    return 0;



}

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

#include <bits/stdc++.h>

#define max(a, b) (a < b ? b : a)

#define min(a, b) ((a > b) ? b : a)

#define SZ(X) ((int)(X).size())

#define ALL(X) (X).begin(), (X).end()

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

typedef long long int ll;

typedef std::vector<int> vi;

typedef std::pair<int, int> pi;

#define clr(arr,value) memset(arr,value,sizeof(arr))

#define F first

#define S second

//#define int long long

#define el '\n'

#define OO 100000000000000

const ll MOD = 1e9 +7;

const int N = 2e5+5;

using namespace std;

typedef unordered_map<int,unordered_set<int>> HASHSET ;









int dx []= {0,0,1,-1,-1,1,-1,1};

int dy []= {1,-1,0,0,-1,1,1,-1};







void PLAY(){

    int n , x, y;

    cin >> n >> x>> y;

    --x;--y;

    vi ans(n);

    bool f = x&1?0:1;

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

        ans[i] = (i&1?f:!f);

    }

    if (n&1)ans[n-1]=2;

    if (!(abs(x-y)==1 || ans[x] != ans[y] || y-x == n-1)){

        x =  (x == 0)?y:x;

        ans[x] = 2;

    }

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

        cout << ans[i] << ' ';

    }

    cout << el;

}





int main() {



    ios_base::sync_with_stdio(false);

    cin.tie(NULL);

//    freopen("input.txt","r",stdin);

//    freopen("output.txt", "w", stdout);

    int T = 1 ;

    cin >> T;



    while (T--){

        PLAY();

    }



    return 0;



}
Problem: 2050D - Digital string maximization
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 1):
#include <bits/stdc++.h>
#include <string>
#include <vector>
using namespace std;
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")

#define endl "\n"

template<class T, class T2> inline bool chkmax(T &x, const T2 &y) { return x < y ? x = y, 1 : 0; }
template<class T, class T2> inline bool chkmin(T &x, const T2 &y) { return x > y ? x = y, 1 : 0; }

#ifndef LOCAL
#define cerr if(false) cerr
#endif
#define out( x ) #x << " = " << x << "  "

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {
	return os << "(" << p.first << ", " << p.second << ")";
}

template<typename T, typename B = decay<decltype(*begin(declval<T>()))>, typename enable_if<!is_same<T, string>::value>::type* = nullptr>
ostream& operator <<(ostream &os, const T &c) {
	bool f = false;
	os << "(";
	for(const auto &x : c) {
		if(f) {
			os << ", ";
		}
		f = true;
		os << x;
	}return os << ")";
}

typedef long long ll;
const ll mod = 1e9 + 7;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//

const int MAX_N = 1e6 + 10;

int ind[16];
std::vector< int > pos[16];

void solve() {

	std::string s;
	std::cin >> s;

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

		int curr = s[i] - '0';
		pos[curr].push_back( i );
	}


	std::vector< int > nas;
	for( int i=0 ; i < n ; i++ ){
		int currMx = -1;
		int indMx = -1;

		for( int j=0 ; j < 10 ; j++ ){

			if( ind[j] < (int)pos[j].size() ){
				int curr;
				if( pos[j][ ind[j] ] > i ) curr = j - ( pos[j][ind[j]] - i );
				else curr = j;

				cerr << out( j ) << out( curr ) << endl;

				if( chkmax( currMx, curr ) ) indMx = j;
			}
		}
		nas.push_back( currMx );
		ind[ indMx ]++;
	}

	cerr << out( nas ) << endl;

	for( auto j : nas ) std::cout << j;
	std::cout << endl;

	for( int i = 0 ; i < 10 ; i++ ){
		pos[i].clear();
		ind[i] = 0;
	}

}

signed main() {
#ifndef LOCAL
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#endif

	int t = 1;
	cin >> t;
	while(t --) {
		solve();
	}

	return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin>>t;
    for(int i=1;i<=t;i++)
    {
        int n;
        cin>>n;
        vector<int>arr(n,0);
        for(int i=0;i<n;i++)
        cin>>arr[i];
        vector<int>temp=arr;
        int maxi=LLONG_MIN;
        while(true)
        {
            int sum=0ll;
            for(int i=0;i<temp.size();i++)
            {
                sum+=temp[i];
            }
            maxi=max(maxi,sum);
            reverse(temp.begin(),temp.end());
            if(temp.size()==1)
            break;
            vector<int>v;
            for(int i=1;i<temp.size();i++)
            {
                v.push_back(temp[i]-temp[i-1]);
            }
            temp=v;
            if(temp.size()==1)
            {maxi=max(maxi,temp[0]);break;}
        }
        cout<<maxi<<endl;
    }
}

Submission (verdict: Accepted):
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin>>t;
    for(int i=1;i<=t;i++)
    {
        int n;
        cin>>n;
        vector<int>arr(n,0);
        for(int i=0;i<n;i++)
        cin>>arr[i];
        vector<int>temp=arr;
        int maxi=LLONG_MIN;
        while(true)
        {
            int sum=0ll;
            for(int i=0;i<temp.size();i++)
            {
                sum+=temp[i];
            }
            maxi=max(maxi,sum);
            reverse(temp.begin(),temp.end());
            if(temp.size()==1)
            break;
            vector<int>v;
            for(int i=1;i<temp.size();i++)
            {
                v.push_back(temp[i]-temp[i-1]);
            }
            sum=0;
            for(int i=0;i<v.size();i++)
            sum+=v[i];
            maxi=max(maxi,sum);
            int neg=(-1ll)*sum;
            maxi=max(maxi,neg);
            temp=v;
            if(temp.size()==1)
            {maxi=max(maxi,temp[0]);break;}
        }
        cout<<maxi<<endl;
    }
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin>>t;
    for(int i=1;i<=t;i++)
    {
        int n;
        cin>>n;
        vector<int>arr(n,0);
        for(int i=0;i<n;i++)
        cin>>arr[i];
        vector<int>temp=arr;
        int maxi=LLONG_MIN;
        while(true)
        {
            int sum=0;
            for(int i=0;i<temp.size();i++)
            {
                sum+=temp[i];
            }
            maxi=max(maxi,sum);
            reverse(temp.begin(),temp.end());
            if(temp.size()==1)
            break;
            vector<int>v;
            for(int i=1;i<temp.size();i++)
            {
                v.push_back(temp[i]-temp[i-1]);
            }
            temp=v;
            if(temp.size()==1)
            {maxi=max(maxi,temp[0]);break;}
        }
        cout<<maxi<<endl;
    }
}

Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin>>t;
    for(int i=1;i<=t;i++)
    {
        int n;
        cin>>n;
        vector<int>arr(n,0);
        for(int i=0;i<n;i++)
        cin>>arr[i];
        vector<int>temp=arr;
        int maxi=LLONG_MIN;
        while(true)
        {
            int sum=0ll;
            for(int i=0;i<temp.size();i++)
            {
                sum+=temp[i];
            }
            maxi=max(maxi,sum);
            reverse(temp.begin(),temp.end());
            if(temp.size()==1)
            break;
            vector<int>v;
            for(int i=1;i<temp.size();i++)
            {
                v.push_back(temp[i]-temp[i-1]);
            }
            temp=v;
            if(temp.size()==1)
            {maxi=max(maxi,temp[0]);break;}
        }
        cout<<maxi<<endl;
    }
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin>>t;
    for(int i=1;i<=t;i++)
    {
        int n;
        cin>>n;
        vector<int>arr(n,0);
        for(int i=0;i<n;i++)
        cin>>arr[i];
        vector<int>temp=arr;
        int maxi=INT_MIN;
        while(true)
        {
            int sum=0;
            for(int i=0;i<temp.size();i++)
            {
                sum+=temp[i];
            }
            maxi=max(maxi,sum);
            reverse(temp.begin(),temp.end());
            if(temp.size()==1)
            break;
            vector<int>v;
            for(int i=1;i<temp.size();i++)
            {
                v.push_back(temp[i]-temp[i-1]);
            }
            temp=v;
            if(temp.size()==1)
            {maxi=max(maxi,temp[0]);break;}
        }
        cout<<maxi<<endl;
    }
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin>>t;
    for(int i=1;i<=t;i++)
    {
        int n;
        cin>>n;
        vector<int>arr(n,0);
        for(int i=0;i<n;i++)
        cin>>arr[i];
        vector<int>temp=arr;
        int maxi=INT_MIN;
        while(true)
        {
            int sum=0;
            for(int i=0;i<temp.size();i++)
            {
                sum+=temp[i];
            }
            maxi=max(maxi,sum);
            reverse(temp.begin(),temp.end());
            if(temp.size()==1)
            break;
            vector<int>v;
            for(int i=1;i<temp.size();i++)
            {
                v.push_back(temp[i]-temp[i-1]);
            }
            temp=v;
            if(temp.size()==1)
            {maxi=max(maxi,temp[0]);break;}
        }
        cout<<maxi<<endl;
    }
}

Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin>>t;
    for(int i=1;i<=t;i++)
    {
        int n;
        cin>>n;
        vector<int>arr(n,0);
        for(int i=0;i<n;i++)
        cin>>arr[i];
        vector<int>temp=arr;
        int maxi=LLONG_MIN;
        while(true)
        {
            int sum=0;
            for(int i=0;i<temp.size();i++)
            {
                sum+=temp[i];
            }
            maxi=max(maxi,sum);
            reverse(temp.begin(),temp.end());
            if(temp.size()==1)
            break;
            vector<int>v;
            for(int i=1;i<temp.size();i++)
            {
                v.push_back(temp[i]-temp[i-1]);
            }
            temp=v;
            if(temp.size()==1)
            {maxi=max(maxi,temp[0]);break;}
        }
        cout<<maxi<<endl;
    }
}