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

Previous submission (verdict: Runtime error on test 1):
#include <iostream>
#include <vector>
#include <sstream>
#include <algorithm>
#include <stdio.h>
#include <map>
#include <unordered_map>
using namespace std;
int main(){
    cin.tie(NULL);
    ios_base::sync_with_stdio(false);
    int complects;
    cin>>complects;
   // cout<<complects<<endl;
    vector<int> numbersarr;
    int n;
    int temp;
    int size1;
    int sum;
    int summax;
    for(int j=0;j<complects;j++){
        //cout<<"newcomplect";
        numbersarr.clear();
        cin>>n;
        //cout<<n<<endl;
        summax=0;
        for(int i=0;i<n;i++){
                cout<<"in temp";
            cin>>temp;
            numbersarr.push_back(temp);
            //sum=a[n]-a[1]
        }
        //greedy approach
        size1=numbersarr.size();
        sum=0;
        for(int i=0;i<numbersarr.size();i++){
            sum=sum+numbersarr[i];

        }
        summax=sum;
        while(size1!=1){
            if(numbersarr[size1-1]-numbersarr[0]<numbersarr[0]-numbersarr[size1-1]){
                reverse(numbersarr.begin(),numbersarr.end());

            }
            if (numbersarr[size1-1]-numbersarr[0]>summax){
                summax=numbersarr[size1-1]-numbersarr[0];
            }
            //do a minus
            for(int i=0;i<numbersarr.size()-1;i++){
                numbersarr[i]=numbersarr[i+1]-numbersarr[i];

            }
            numbersarr.erase(numbersarr.end());


        }
        cout<<summax<<"\n";


    }

}


Submission (verdict: Wrong answer on test 2):
#include <iostream>
#include <vector>
#include <sstream>
#include <algorithm>
#include <stdio.h>
#include <map>
#include <unordered_map>
using namespace std;
int main() {
    cin.tie(NULL);
    ios_base::sync_with_stdio(false);
    int complects;
    cin >> complects;
    //cout << complects << endl;
    vector<int> numbersarr;
    int n;
    int temp;
    int size1;
    int sum;
    int summax;
    for (int j = 0; j < complects; j++) {
        //cout << "newcomplect";
        numbersarr.clear();
        cin >> n;
        //cout << n << endl;
        summax = 0;
        for (int i = 0; i < n; i++) {
            //cout << "in temp";
            cin >> temp;
            numbersarr.push_back(temp);
            //sum=a[n]-a[1]
        }
        //greedy approach
       
        sum = 0;
        size1 = numbersarr.size();
        for (int i = 0; i < numbersarr.size(); i++) {
            sum = sum + numbersarr[i];

        }
        summax = sum;
        while (size1 != 1) {
           // cout << "while";
            if (numbersarr[size1 - 1] - numbersarr[0] < numbersarr[0] - numbersarr[size1 - 1]) {
              //  cout << "3";
                reverse(numbersarr.begin(), numbersarr.end());

            }
            if (numbersarr[size1 - 1] - numbersarr[0] > summax) {
              //  cout<<"2";
                summax = numbersarr[size1 - 1] - numbersarr[0];
            }
            //do a minus
            for (int i = 0; i < numbersarr.size() - 1; i++) {
               // cout << "1";
                numbersarr[i] = numbersarr[i + 1] - numbersarr[i];

            }
            numbersarr.erase(numbersarr.end()-1);
            size1 = numbersarr.size();

        }
        cout << summax << "\n";


    }

}