ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2061D - Kevin and Numbers
Language: C++17 (GCC 7-32)

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

#define ll long long
#define vl vector<ll>
#define uli unordered_map<ll, int>
#define pq priority_queue<ll>

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

  int t = 0;
  cin >> t;
  while (t--) {
    int n = 0;
    int m = 0;
    cin >> n >> m;
    vl a(n);
    vl b(m);
    ll suma = 0;
    ll sumb = 0;
    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];
    }

    if (suma != sumb) {
      cout << "No\n";
      continue;
    }

    uli freq;
    for (ll x : a) {
      freq[x]++;
    }

    pq prio;
    for (ll x : b) {
      prio.push(x);
    }

    bool p = true;
    while (!prio.empty()) {
      ll x = prio.top();
      prio.pop();

      if (freq[x] > 0) {
        freq[x]--;
        continue;
      }

      if (x == 1) {
        p = true;
        break;
      }

      ll l = x / 2;
      ll r = x - l;
      prio.push(l);
      prio.push(r);
    }
    cout << (p ? "Yes" : "No") << '\n';
  }
  return 0;
}


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

#define ll long long
#define vl vector<ll>
#define uli unordered_map<ll, int>
#define prio priority_queue<ll>

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

  int t = 0;
  cin >> t;
  while (t--) {
    int n = 0;
    int m = 0;
    cin >> n >> m;
    vl a(n), b(m);
    ll suma = 0;
    ll sumb = 0;
    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];
    }
    if (suma != sumb) {
      cout << "No\n";
      continue;
    }
    uli freq;
    for (ll x : a) {
      freq[x]++;
    }
    prio pq;
    for (ll x : b) {
      pq.push(x);
    }
    int mt = 0;
    bool p = true;
    while (!pq.empty() && mt < n) {
      ll x = pq.top();
      pq.pop();
      if (freq[x] > 0) {
        freq[x]--;
        mt++;
        continue;
      }
      if (x == 1) {
        p = false;
        break;
      }
      ll l = x / 2;
      ll r = x - l;
      pq.push(l);
      pq.push(r);
    }
    if (mt != n) {
      p = false;
    }
    cout << (p ? "Yes" : "No") << "\n";
  }
  return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++23 (GCC 14-64, msys2)


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

#define ll long long int
#define MOD 1000000007

ll binarySearch(const vector<ll>& arr, ll target) {
    ll left = 0;
    ll right = arr.size() - 1;

    while (left <= right) {
        ll mid = left + (right - left) / 2; 

        if (arr[mid] == target) {
            return mid; 
        }
        if (arr[mid] < target) {
            left = mid + 1; 
        } else {
            right = mid - 1; 
        }
    }

    return -1; 
}

void solve() {
    ll n;
    cin >> n;
    vector<ll> arr(n);
    for (ll i = 0; i < n; i++) {
        cin >> arr[i];
    }
    vector<ll>k;
    ll q=0;
    vector<vector<ll>>ans;
    for(ll i=n-1; i>=0; i--){
        ll x=arr[i]-1;
        for(ll j=max(x,q); j>=1; j--){
            if(arr[i]!=j && binarySearch(k, j)==-1){
                ans.push_back({arr[i],j});
            }
        }
        for(ll j=1; j<=n; j++){
            if(arr[i]!=j && binarySearch(k, j)==-1){
                ans.push_back({j,arr[i]});
            }
        }
        k.push_back(arr[i]);
    }
    cout<<ans.size()<<endl;
    for(ll i=0; i<ans.size(); i++){
        cout<<ans[i][0]<<" "<<ans[i][1]<<endl;
    }
    if(ans.size()>=1)cout<<endl;
}

int main() {
    int t=1;
    //cin >> t;
    while (t--) {
        solve();
    }
}
Problem: 2052A - Adrenaline Rush
Language: C++23 (GCC 14-64, msys2)

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

#define ll long long int
#define MOD 1000000007

ll binarySearch(const vector<ll>& arr, ll target) {
    ll left = 0;
    ll right = arr.size() - 1;

    while (left <= right) {
        ll mid = left + (right - left) / 2; 

        if (arr[mid] == target) {
            return mid; 
        }
        if (arr[mid] < target) {
            left = mid + 1; 
        } else {
            right = mid - 1; 
        }
    }

    return -1; 
}

void solve() {
    ll n;
    cin >> n;
    vector<ll> arr(n);
    for (ll i = 0; i < n; i++) {
        cin >> arr[i];
    }
    vector<ll>k;
    ll q=0;
    vector<vector<ll>>ans;
    for(ll i=n-1; i>=0; i--){
        ll x=arr[i]-1;
        for(ll j=max(x,q); j>=1; j--){
            if(arr[i]!=j && binarySearch(k, j)==-1){
                ans.push_back({arr[i],j});
            }
        }
        for(ll j=1; j<=n; j++){
            if(arr[i]!=j && binarySearch(k, j)==-1){
                ans.push_back({j,arr[i]});
            }
        }
        k.push_back(arr[i]);
    }
    cout<<ans.size()<<endl;
    for(ll i=0; i<ans.size(); i++){
        cout<<ans[i][0]<<" "<<ans[i][1]<<endl;
    }
    if(ans.size()>=1)cout<<endl;
}

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


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

#define ll long long int
#define MOD 1000000007

ll binarySearch(const vector<ll>& arr, ll target) {
    ll left = 0;
    ll right = arr.size() - 1;

    while (left <= right) {
        ll mid = left + (right - left) / 2; 

        if (arr[mid] == target) {
            return mid; 
        }
        if (arr[mid] < target) {
            left = mid + 1; 
        } else {
            right = mid - 1; 
        }
    }

    return -1; 
}

void solve() {
    ll n;
    cin >> n;
    vector<ll> arr(n);
    for (ll i = 0; i < n; i++) {
        cin >> arr[i];
    }
    vector<ll>k;
    ll q=0;
    vector<vector<ll>>ans;
    for(ll i=n-1; i>=1; i--){
        ll x=arr[i]-1;
        for(ll j=max(x,q); j>=1; j--){
            if(arr[i]!=j && binarySearch(k, j)==-1){
                ans.push_back({arr[i],j});
            }
        }
        for(ll j=1; j<=n; j++){
            if(arr[i]!=j && binarySearch(k, j)==-1){
                ans.push_back({j,arr[i]});
            }
        }
        k.push_back(arr[i]);
    }
    cout<<ans.size()<<endl;
    for(ll i=0; i<ans.size(); i++){
        cout<<ans[i][0]<<" "<<ans[i][1]<<endl;
    }
    
}

int main() {
    int t=1;
    //cin >> t;
    while (t--) {
        solve();
    }
}
Problem: 2052A - Adrenaline Rush
Language: C++23 (GCC 14-64, msys2)

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

#define ll long long int
#define MOD 1000000007

ll binarySearch(const vector<ll>& arr, ll target) {
    ll left = 0;
    ll right = arr.size() - 1;

    while (left <= right) {
        ll mid = left + (right - left) / 2; 

        if (arr[mid] == target) {
            return mid; 
        }
        if (arr[mid] < target) {
            left = mid + 1; 
        } else {
            right = mid - 1; 
        }
    }

    return -1; 
}

void solve() {
    ll n;
    cin >> n;
    vector<ll> arr(n);
    for (ll i = 0; i < n; i++) {
        cin >> arr[i];
    }
    vector<ll>k;
    ll q=0;
    vector<vector<ll>>ans;
    for(ll i=n-1; i>=1; i--){
        ll x=arr[i]-1;
        for(ll j=max(x,q); j>=1; j--){
            if(arr[i]!=j && binarySearch(k, j)==-1){
                ans.push_back({arr[i],j});
            }
        }
        for(ll j=1; j<=n; j++){
            if(arr[i]!=j && binarySearch(k, j)==-1){
                ans.push_back({j,arr[i]});
            }
        }
        k.push_back(arr[i]);
    }
    cout<<ans.size()<<endl;
    for(ll i=0; i<ans.size(); i++){
        cout<<ans[i][0]<<" "<<ans[i][1]<<endl;
    }
    
}

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


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

#define ll long long int
#define MOD 1000000007

ll binarySearch(const vector<ll>& arr, ll target) {
    ll left = 0;
    ll right = arr.size() - 1;

    while (left <= right) {
        ll mid = left + (right - left) / 2; 

        if (arr[mid] == target) {
            return mid; 
        }
        if (arr[mid] < target) {
            left = mid + 1; 
        } else {
            right = mid - 1; 
        }
    }

    return -1; 
}

void solve() {
    ll n;
    cin >> n;
    vector<ll> arr(n);
    for (ll i = 0; i < n; i++) {
        cin >> arr[i];
    }
    vector<ll>k;
    vector<vector<ll>>ans;
    ll q=0;
    for(ll i=n-1; i>=1; i--){
        //cout<<i<<endl;
        ll x=arr[i]-1;
        for(ll j=max(x,q); j>=1; j--){
            if(arr[i]!=j && binarySearch(k, j)==-1){
                ans.push_back({arr[i],j});
               // cout<<arr[i]<<" "<<j<<endl;
            }
        }
        for(ll j=1; j<=n; j++){
            if(arr[i]!=j && binarySearch(k, j)==-1){
                ans.push_back({j,arr[i]});
                //cout<<j<<" "<<arr[i]<<endl;
            }
        }
        k.push_back(arr[i]);
        sort(k.begin(),k.end());
        /*for(ll i=0; i<k.size(); i++){
            cout<<k[i]<<endl;
        }*/
    }
    cout<<ans.size()<<endl;
    for(ll i=0; i<ans.size(); i++){
        cout<<ans[i][0]<<" "<<ans[i][1]<<endl;
    }
    
}

int main() {
    int t=1;
    //cin >> t;
    while (t--) {
        solve();
    }
}
Problem: 2057B - Gorilla and the Exam
Language: C++17 (GCC 7-32)


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

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

    int t;
    cin>>t;
    while(t--){
        int n, k;
        cin>>n>>k;
        vector<int> v(n);
        set<int> s;
        int mini = INT_MAX, cm = INT_MAX;
        int p = 0;
        for(int i = 0; i < n; i++){
            int a;
            cin>>a;
            v[i] = a;
            if(k == 0){
                s.insert(a);
            }
            else if(k == 1){
                mini = min(mini, a);
                s.insert(mini);
            }
        }
        if(k > 1){
            for(int i = 0; i < n; i+=k){
                cm = v[i];
                for(int j = 1; j < k; j++){
                    if(j+i > n) break;
                    cm = min(cm, v[(j+i)]);
                }
                s.insert(cm);
            }
        }
        cout<<s.size()<<"\n";
    }
}
Problem: 2057B - Gorilla and the Exam
Language: C++17 (GCC 7-32)

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

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

    int t;
    cin>>t;
    while(t--){
        int n, k;
        cin>>n>>k;
        vector<int> v(n);
        set<int> s;
        int mini = INT_MAX, cm = INT_MAX;
        int p = 0;
        for(int i = 0; i < n; i++){
            int a;
            cin>>a;
            v[i] = a;
            if(k == 0){
                s.insert(a);
            }
            else if(k == 1){
                mini = min(mini, a);
                s.insert(mini);
            }
        }
        if(k > 1){
            for(int i = 0; i < n; i+=k){
                cm = v[i];
                for(int j = 1; j < k; j++){
                    if(j+i > n) break;
                    cm = min(cm, v[(j+i)]);
                }
                s.insert(cm);
            }
        }
        cout<<s.size()<<"\n";
    }
}

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

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

    int t;
    cin>>t;
    while(t--){
        int n, k;
        cin>>n>>k;
        vector<int> v(n);
        set<int> s;
        int mini = INT_MAX, cm = INT_MAX;
        int p = 0;
        for(int i = 0; i < n; i++){
            int a;
            cin>>a;
            v[i] = a;
            if(k == 0){
                s.insert(a);
            }
            else if(k == 1){
                mini = min(mini, a);
                s.insert(mini);
            }
        }
        if(k > 1){
            for(int i = 0; i < n; i+=k){
                cm = v[i];
                for(int j = 1; j < k; j++){
                    if(j+i >= n) break;
                    cm = min(cm, v[(j+i)]);
                }
                s.insert(cm);
            }
        }
        cout<<s.size()<<"\n";
    }
}
Problem: 2057B - Gorilla and the Exam
Language: C++17 (GCC 7-32)

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

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

    int t;
    cin>>t;
    while(t--){
        int n, k;
        cin>>n>>k;
        vector<int> v(n);
        set<int> s, s2;
        int mini = INT_MAX, cm = INT_MAX;
        int p = 0;
        for(int i = 0; i < n; i++){
            int a;
            cin>>a;
            v[i] = a;
            if(k == 0){
                s.insert(a);
            }
            else if(k == 1){
                mini = min(mini, a);
                s.insert(mini);
            }
        }
        if(k > 1){
            for(int i = 0; i < n; i+=k){
                cm = v[i];
                for(int j = 1; j < k; j++){
                    if(j+i >= n) break;
                    cm = min(cm, v[(j+i)]);
                }
                s.insert(cm);
            }
            for(int i = n-1; i >= 0; i-=k){
                cm = v[i];
                for(int j = k-1; j > 0; j--){
                    if(j+i > n || i-j < 0) break;
                    cm = min(cm, v[(i-j)]);
                }
                s2.insert(cm);
            }
        }
        cout<<(s2.size() > 0? min(s.size(), s2.size()): s.size())<<"\n";
    }
}

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

void solve(){
    int n, k;
    cin>>n>>k;
    vector<int> v(n), f;
    map<int, int> m;
    for(int i = 0; i < n; i++){
        cin>>v[i];
        m[v[i]]++;
    }
    if(k >= n){
        cout<<1<<endl;
        return;
    }
    int ct = 0;
    for(auto it: m){
        if(it.second > k) ct++;
        else f.push_back(it.second);
    }
    sort(f.begin(), f.end());
    for(int j = 0; j < f.size(); j++){
        if(k >= f[j]) {
            k -= f[j];
        }
        else ct++;
    }
    cout<<ct<<"\n";
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    cin>>t;
    while(t--) solve();
}
Problem: 2057B - Gorilla and the Exam
Language: C++17 (GCC 7-32)

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

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

    int t;
    cin>>t;
    while(t--){
        int n, k;
        cin>>n>>k;
        vector<int> v(n);
        set<int> s;
        int mini = INT_MAX, cm = INT_MAX;
        int p = 0;
        for(int i = 0; i < n; i++){
            int a;
            cin>>a;
            v[i] = a;
            if(k == 0){
                s.insert(a);
            }
            else if(k == 1){
                mini = min(mini, a);
                s.insert(mini);
            }
        }
        if(k > 1){
            for(int i = 0; i < n; i+=k){
                cm = v[i];
                for(int j = 1; j < k; j++){
                    if(j+i >= n) break;
                    cm = min(cm, v[(j+i)]);
                }
                s.insert(cm);
            }
        }
        cout<<s.size()<<"\n";
    }
}

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

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

    int t;
    cin>>t;
    while(t--){
        int n, k;
        cin>>n>>k;
        vector<int> v(n);
        set<int> s, s2;
        int mini = INT_MAX, cm = INT_MAX;
        int p = 0;
        for(int i = 0; i < n; i++){
            int a;
            cin>>a;
            v[i] = a;
            if(k == 0){
                s.insert(a);
            }
            else if(k == 1){
                mini = min(mini, a);
                s.insert(mini);
            }
        }
        if(k > 1){
            for(int i = 0; i < n; i+=k){
                cm = v[i];
                for(int j = 1; j < k; j++){
                    if(j+i >= n) break;
                    cm = min(cm, v[(j+i)]);
                }
                s.insert(cm);
            }
            for(int i = n-1; i >= 0; i-=k){
                cm = v[i];
                for(int j = k-1; j > 0; j--){
                    if(j+i > n || i-j < 0) break;
                    cm = min(cm, v[(i-j)]);
                }
                s2.insert(cm);
            }
        }
        cout<<(s2.size() > 0? min(s.size(), s2.size()): s.size())<<"\n";
    }
}
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)


Submission (verdict: Time limit exceeded on test 2):
#include<bits/stdc++.h>
#define ll long long
using namespace std;

int solve(int op,vector<ll>v){
    if(v.size()==1)
    return v[0];
    ll sum1=-1e9,sum2=-1e9,sum3=-1e9;
    sum1=accumulate(v.begin(),v.end(),0);
    vector<ll>a=v;
    reverse(a.begin(),a.end());
    vector<ll>t(v.size()-1);
    for(int i=1;i<v.size();i++){
        t[i-1]=v[i]-v[i-1];
    }
    if(op==-1|| op==2){
        sum2=solve(1,a);
        sum3= solve(2,t);
        return max(sum1,max(sum2,sum3));
    }
    sum3=solve(2,t);
    return max(sum1,sum3);
}
int main(){
    int t;
    cin>>t;
    while(t--){
        int n;
        cin>>n;
        vector<ll>v(n);
        for(int i=0;i<n;i++)
        cin>>v[i];
        cout<<solve(-1,v)<<"\n";
    }
}
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)

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

unordered_map<string,ll>dp;

string get_key(int op,vector<ll>&v){
    string key=to_string(op)+'|';
    for(int i=0;i<v.size();i++)
    key+=to_string(v[i]);
    return key;
}


int solve(int op,vector<ll>v){
    if(v.size()==1)
    return v[0];

    string s= get_key(op,v);
    if(dp.find(s)!=dp.end())
    return dp[s];
    ll sum1=-1e9,sum2=-1e9,sum3=-1e9;
    sum1=accumulate(v.begin(),v.end(),0);
    vector<ll>a=v;
    reverse(a.begin(),a.end());
    vector<ll>t(v.size()-1);
    for(int i=1;i<v.size();i++){
        t[i-1]=v[i]-v[i-1];
    }
    if(op==-1|| op==2){
        sum2=solve(1,a);
        sum3= solve(2,t);
        return dp[s]=max(sum1,max(sum2,sum3));
    }
    sum3=solve(2,t);
    return dp[s]=max(sum1,sum3);
}
int main(){
    int t;
    cin>>t;
    while(t--){
        int n;
        cin>>n;
        vector<ll>v(n);
        for(int i=0;i<n;i++)
        cin>>v[i];
        cout<<solve(-1,v)<<"\n";
    }
}

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

unordered_map<string,ll>dp;

string get_key(int op,vector<ll>&v){
    string key=to_string(op)+'|';
    for(int i=0;i<v.size();i++)
    key+=to_string(v[i]);
    return key;
}


ll solve(int op,vector<ll>v){
    if(v.size()==1)
    return v[0];

    string s= get_key(op,v);
    if(dp.find(s)!=dp.end())
    return dp[s];
    ll sum1=LLONG_MIN,sum2=LLONG_MIN,sum3=LLONG_MIN;
    sum1=accumulate(v.begin(),v.end(),0LL);
    vector<ll>a=v;
    reverse(a.begin(),a.end());
    vector<ll>t(v.size()-1);
    for(int i=1;i<v.size();i++){
        t[i-1]=v[i]-v[i-1];
    }
    if(op==-1|| op==2){
        sum2=solve(1,a);
        sum3= solve(2,t);
        return dp[s]=max(sum1,max(sum2,sum3));
    }
    sum3=solve(2,t);
    return dp[s]=max(sum1,sum3);
}
int main(){
    int t;
    cin>>t;
    while(t--){
        int n;
        cin>>n;
        vector<ll>v(n);
        for(int i=0;i<n;i++)
        cin>>v[i];
        cout<<solve(-1,v)<<"\n";
    }
}
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)

Previous submission (verdict: Time limit exceeded on test 2):
#include<bits/stdc++.h>
#define ll long long
using namespace std;

int solve(int op,vector<ll>v){
    if(v.size()==1)
    return v[0];
    ll sum1=-1e9,sum2=-1e9,sum3=-1e9;
    sum1=accumulate(v.begin(),v.end(),0);
    vector<ll>a=v;
    reverse(a.begin(),a.end());
    vector<ll>t(v.size()-1);
    for(int i=1;i<v.size();i++){
        t[i-1]=v[i]-v[i-1];
    }
    if(op==-1|| op==2){
        sum2=solve(1,a);
        sum3= solve(2,t);
        return max(sum1,max(sum2,sum3));
    }
    sum3=solve(2,t);
    return max(sum1,sum3);
}
int main(){
    int t;
    cin>>t;
    while(t--){
        int n;
        cin>>n;
        vector<ll>v(n);
        for(int i=0;i<n;i++)
        cin>>v[i];
        cout<<solve(-1,v)<<"\n";
    }
}

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

unordered_map<string,ll>dp;

string get_key(int op,vector<ll>&v){
    string key=to_string(op)+'|';
    for(int i=0;i<v.size();i++)
    key+=to_string(v[i]);
    return key;
}


int solve(int op,vector<ll>v){
    if(v.size()==1)
    return v[0];

    string s= get_key(op,v);
    if(dp.find(s)!=dp.end())
    return dp[s];
    ll sum1=-1e9,sum2=-1e9,sum3=-1e9;
    sum1=accumulate(v.begin(),v.end(),0);
    vector<ll>a=v;
    reverse(a.begin(),a.end());
    vector<ll>t(v.size()-1);
    for(int i=1;i<v.size();i++){
        t[i-1]=v[i]-v[i-1];
    }
    if(op==-1|| op==2){
        sum2=solve(1,a);
        sum3= solve(2,t);
        return dp[s]=max(sum1,max(sum2,sum3));
    }
    sum3=solve(2,t);
    return dp[s]=max(sum1,sum3);
}
int main(){
    int t;
    cin>>t;
    while(t--){
        int n;
        cin>>n;
        vector<ll>v(n);
        for(int i=0;i<n;i++)
        cin>>v[i];
        cout<<solve(-1,v)<<"\n";
    }
}