ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)

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

int main() {
    int t;
    cin >> t;
    while (t--) {
        int n;
        cin >> n;
        vector<int> a(n);
        for (int i = 0; i < n; i++) {
            cin >> a[i];
        }
        
        if (n == 1) {
            cout << a[0] << endl; 
            continue;
        }
        int sum =0;
        for(int i=0;i<n;i++){
            sum+=a[i];
        }
        while (a.size() > 1) {
            vector<int> b; 
            for (int i = 0; i < a.size() - 1; i++) {
                b.push_back(a[i + 1] - a[i]);
            }
            a = b; 
        }
        
        cout << max(sum,abs(a[0])) << endl;
    }
    return 0;
}


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

int main() {
    int t;
    cin >> t;
    while (t--) {
        int n;
        cin >> n;
        vector<int> a(n);
        for (int i = 0; i < n; i++) {
            cin >> a[i];
        }
        
        if (n == 1) {
            cout << a[0] << endl; 
            continue;
        }
        long long sum =0;
        for(int i=0;i<n;i++){
            sum+=a[i];
        }
        while (a.size() > 1) {
            vector<long long> b; 
            for (int i = 0; i < a.size() - 1; i++) {
                b.push_back(a[i + 1] - a[i]);
            }
            a = b; 
        }
        
        cout << max(sum,abs(a[0])) << endl;
    }
    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)

Previous submission (verdict: Compilation error):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
    int t;
    cin >> t;
    while (t--) {
        int n;
        cin >> n;
        vector<int> a(n);
        for (int i = 0; i < n; i++) {
            cin >> a[i];
        }
        
        if (n == 1) {
            cout << a[0] << endl; 
            continue;
        }
        long long sum =0;
        for(int i=0;i<n;i++){
            sum+=a[i];
        }
        while (a.size() > 1) {
            vector<long long> b; 
            for (int i = 0; i < a.size() - 1; i++) {
                b.push_back(a[i + 1] - a[i]);
            }
            a = b; 
        }
        
        cout << max(sum,abs(a[0])) << endl;
    }
    return 0;
}


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

int main() {
    int t;
    cin >> t;
    while (t--) {
        int n;
        cin >> n;
        vector<ll> a(n);  // Use long long to prevent type mismatch
        for (int i = 0; i < n; i++) {
            cin >> a[i];
        }
        
        if (n == 1) {
            cout << a[0] << endl; 
            continue;
        }

        ll sum = 0;
        for (int i = 0; i < n; i++) {
            sum += a[i];
        }

        while (a.size() > 1) {
            vector<ll> b; 
            for (size_t i = 0; i < a.size() - 1; i++) {
                b.push_back(a[i + 1] - a[i]);
            }
            a = b;  
        }
        
        cout << max(sum, abs(a[0])) << endl;
    }
    return 0;
}
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;
typedef long long ll;

int main() {
    int t;
    cin >> t;
    while(t--){
        int n,l,r;
        cin>>n>>l>>r;
        vector<int>a(n);
        for(int i =0;i<n;i++){
            cin>>a[i];
        }
        sort(a.begin(),a.end());
        int sum =0;
        for(int i =0;i<(r-l+1);i++){
            sum+=a[i];
        }
        cout<<sum<<endl;
    }
}

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

using namespace std;

typedef long long ll;



int main() {

    int t;

    cin >> t;

    while(t--){

        int n,l,r;

        cin>>n>>l>>r;

        int a[n+1],b[n+1];

        a[0

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

            cin>>a[i];

            b[i]=a[i];



        }

       sort(b+1,b+1+r);

		sort(a+l,a+n+1);

        for(auto it : a){

            cout<<it<<" ";

        }

        cout<<endl;

        for(auto it : b){

            cout<<it<<" ";

        }

        cout<<endl;

		long long s1=0,s2=0;

		for(int i=1;i<=r-l+1;i++) s1+=b[i];

		for(int i=l;i<=r;i++) s2+=a[i];

		printf("%lld\n",min(s1,s2));

    }

}
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)

Previous submission (verdict: Compilation error):
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;



int main() {

    int t;

    cin >> t;

    while(t--){

        int n,l,r;

        cin>>n>>l>>r;

        int a[n+1],b[n+1];

        a[0

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

            cin>>a[i];

            b[i]=a[i];



        }

       sort(b+1,b+1+r);

		sort(a+l,a+n+1);

        for(auto it : a){

            cout<<it<<" ";

        }

        cout<<endl;

        for(auto it : b){

            cout<<it<<" ";

        }

        cout<<endl;

		long long s1=0,s2=0;

		for(int i=1;i<=r-l+1;i++) s1+=b[i];

		for(int i=l;i<=r;i++) s2+=a[i];

		printf("%lld\n",min(s1,s2));

    }

}

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

int main() {
    int t;
    cin >> t;
    while(t--){
        int n,l,r;
        cin>>n>>l>>r;
        int a[n+1],b[n+1];
        a[0
        for(int i =1;i<=n;i++){
            cin>>a[i];
            b[i]=a[i];

        }
       sort(b+1,b+1+r);
		sort(a+l,a+n+1);
		long long s1=0,s2=0;
		for(int i=1;i<=r-l+1;i++) s1+=b[i];
		for(int i=l;i<=r;i++) s2+=a[i];
		printf("%lld\n",min(s1,s2));
    }
}
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)


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

int main() {
    int t;
    cin >> t;
    while(t--){
        int n,l,r;
        cin>>n>>l>>r;
        vector<int>a(n);
        for(int i =0;i<n;i++){
            cin>>a[i];
        }
        sort(a.begin(),a.end());
        int sum =0;
        for(int i =0;i<(r-l+1);i++){
            sum+=a[i];
        }
        cout<<sum<<endl;
    }
}
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)

Previous submission (verdict: Compilation error):
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
    int t;
    cin >> t;
    while(t--){
        int n,l,r;
        cin>>n>>l>>r;
        int a[n+1],b[n+1];
        a[0
        for(int i =1;i<=n;i++){
            cin>>a[i];
            b[i]=a[i];

        }
       sort(b+1,b+1+r);
		sort(a+l,a+n+1);
		long long s1=0,s2=0;
		for(int i=1;i<=r-l+1;i++) s1+=b[i];
		for(int i=l;i<=r;i++) s2+=a[i];
		printf("%lld\n",min(s1,s2));
    }
}

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

int main() {
    int t;
    cin >> t;
    while (t--) {
        int n, l, r;
        cin >> n >> l >> r;
        vector<int> a(n + 1), b(n + 1);

        for (int i = 1; i <= n; i++) {
            cin >> a[i];
            b[i] = a[i];
        }

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

        ll s1 = 0, s2 = 0;
        for (int i = 1; i <= r - l + 1; i++) 
            s1 += b[i];
        for (int i = l; i <= r; i++) 
            s2 += a[i];

        cout << min(s1, s2) << endl;
    }
    return 0;
}
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)

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

using namespace std;

#define ll long long 

#define pb push_back





int main()

{

  int t;

  cin>>t;

  while(t){

    int n, l, r;

    cin>>n>>l>>r;

    vector<int> arr(n);

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

      cin>>arr[i];

    }

   vector<int> left;

   vector<int> mid;

   vector<int> right;

   for(int i = 0; i<=l-2; i++){

    left.push_back(arr[i]);

   }

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

    mid.push_back(arr[i]);

   }

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

    right.push_back(arr[i]);

   }

    sort(left.begin(), left.end());

    sort(mid.begin(), mid.end());

    sort(right.begin(), right.end());

    int sum = 0;

    for(auto it: mid){

      sum+=it;

    }



    long long ans = sum, prefixLeft=0, prefixRight = 0, prefixMid = 0;

    for(int i=0, j=mid.size()-1;i<mid.size();i++, j--) {

      prefixMid += mid[j];

      prefixRight += right.size()>i ? right[i] : mid[j];

      prefixLeft += left.size()>i ? left[i] : mid[j];

      ans = min(ans, sum + prefixRight - prefixMid);

      ans = min(ans, sum + prefixLeft - prefixMid);

    }



    cout<<ans<<endl;

    t--;

  }

  return 0;

}

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

using namespace std;

#define ll long long 

#define pb push_back





int main()

{

  int t;

  cin>>t;

  while(t){

    int n, l, r;

    cin>>n>>l>>r;

    vector<int> arr(n);

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

      cin>>arr[i];

    }

   vector<int> left;

   vector<int> mid;

   vector<int> right;

   for(int i = 0; i<=l-2; i++){

    left.push_back(arr[i]);

   }

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

    mid.push_back(arr[i]);

   }

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

    right.push_back(arr[i]);

   }

    sort(left.begin(), left.end());

    sort(mid.begin(), mid.end());

    sort(right.begin(), right.end());

    long long  sum = 0;

    for(auto it: mid){

      sum+=it;

    }



    long long ans = sum, prefixLeft=0, prefixRight = 0, prefixMid = 0;

    for(int i=0, j=mid.size()-1;i<mid.size();i++, j--) {

      prefixMid += mid[j];

      prefixRight += right.size()>i ? right[i] : mid[j];

      prefixLeft += left.size()>i ? left[i] : mid[j];

      ans = min(ans, sum + prefixRight - prefixMid);

      ans = min(ans, sum + prefixLeft - prefixMid);

    }



    cout<<ans<<endl;

    t--;

  }

  return 0;

}
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)

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

using namespace std;

#define ll long long 

#define pb push_back





int main()

{

  int t;

  cin>>t;

  while(t){

    int n, l, r;

    cin>>n>>l>>r;

    vector<int> arr(n);

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

      cin>>arr[i];

    }

   vector<int> left;

   vector<int> mid;

   vector<int> right;

   for(int i = 0; i<=l-2; i++){

    left.push_back(arr[i]);

   }

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

    mid.push_back(arr[i]);

   }

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

    right.push_back(arr[i]);

   }

    sort(left.begin(), left.end());

    sort(mid.begin(), mid.end());

    sort(right.begin(), right.end());

    int sum = 0;

    for(auto it: mid){

      sum+=it;

    }



    int ans = sum, prefixLeft=0, prefixRight = 0, prefixMid = 0;

    for(int i=0, j=mid.size()-1;i<mid.size();i++, j--) {

      prefixMid += mid[j];

      prefixRight += right.size()>i ? right[i] : mid[j];

      prefixLeft += left.size()>i ? left[i] : mid[j];

      ans = min(ans, sum + prefixRight - prefixMid);

      ans = min(ans, sum + prefixLeft - prefixMid);

    }



    cout<<ans<<"\n";

    t--;

  }

  return 0;

}

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

using namespace std;

#define ll long long 

#define pb push_back





int main()

{

  int t;

  cin>>t;

  while(t){

    int n, l, r;

    cin>>n>>l>>r;

    vector<int> arr(n);

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

      cin>>arr[i];

    }

   vector<int> left;

   vector<int> mid;

   vector<int> right;

   for(int i = 0; i<=l-2; i++){

    left.push_back(arr[i]);

   }

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

    mid.push_back(arr[i]);

   }

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

    right.push_back(arr[i]);

   }

    sort(left.begin(), left.end());

    sort(mid.begin(), mid.end());

    sort(right.begin(), right.end());

    int sum = 0;

    for(auto it: mid){

      sum+=it;

    }



    long long ans = sum, prefixLeft=0, prefixRight = 0, prefixMid = 0;

    for(int i=0, j=mid.size()-1;i<mid.size();i++, j--) {

      prefixMid += mid[j];

      prefixRight += right.size()>i ? right[i] : mid[j];

      prefixLeft += left.size()>i ? left[i] : mid[j];

      ans = min(ans, sum + prefixRight - prefixMid);

      ans = min(ans, sum + prefixLeft - prefixMid);

    }



    cout<<ans<<endl;

    t--;

  }

  return 0;

}
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)


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

using namespace std;

#define ll long long 

#define pb push_back





int main()

{

  int t;

  cin>>t;

  while(t){

    int n, l, r;

    cin>>n>>l>>r;

    vector<int> arr(n);

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

      cin>>arr[i];

    }

   vector<int> left;

   vector<int> mid;

   vector<int> right;

   for(int i = 0; i<=l-2; i++){

    left.push_back(arr[i]);

   }

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

    mid.push_back(arr[i]);

   }

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

    right.push_back(arr[i]);

   }

    sort(left.begin(), left.end());

    sort(mid.begin(), mid.end());

    sort(right.begin(), right.end());

    int sum = 0;

    for(auto it: mid){

      sum+=it;

    }



    int ans = sum, prefixLeft=0, prefixRight = 0, prefixMid = 0;

    for(int i=0, j=mid.size()-1;i<mid.size();i++, j--) {

      prefixMid += mid[j];

      prefixRight += right.size()>i ? right[i] : mid[j];

      prefixLeft += left.size()>i ? left[i] : mid[j];

      ans = min(ans, sum + prefixRight - prefixMid);

      ans = min(ans, sum + prefixLeft - prefixMid);

    }



    cout<<ans<<"\n";

    t--;

  }

  return 0;

}
Problem: 2063C - Remove Exactly Two
Language: C++17 (GCC 7-32)


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

bool checkOverlap(int node1, int node2, vector<vector<int>> &adj){
  for(auto it: adj[node1]){
    if(it == node2){
      return false;
    }
  }

  return true;
}

void getCardinality(vector<vector<int>> &adj, int n, vector<pair<int,int>> &cardinality){
  for(int i = 1; i<=n; i++){
    int size = adj[i].size();
    cardinality.pb({size, i});
  }
}

int findComponents(vector<vector<int>> &adj, vector<pair<int,int>> &c, int n){
  if(n <= 2) return 0;
  if(c[0].first == c[1].first == c[2].first){
    return (2 * c[0].first) - 1;
  }
  else if(c[0].first == c[1].first){
    if(checkOverlap(c[0].second, c[1].second, adj)){
      return (2 * c[0].first) - 1;
    }
    else{
      return (2 * c[0].first) - 2;
    }
  }
  else{
      if(checkOverlap(c[0].second, c[1].second, adj)){
          return (c[0].first + c[1].first) - 1;
      }
      else{
        int temp = (c[0].first + c[1].first) - 2;
        for(int i = 2; i<n; i++){
          if(c[i - 1].first == c[i].first){
            if(checkOverlap(c[0].second, c[i].second, adj)){
              temp = (c[0].first + c[i].first) - 1;
              break;
            }
          }
        }
        return temp;
      }
  }
  return -1;
}

int main()
{
  int t;
  cin>>t;
  while(t){
    int n;
    cin>>n;
    int u, v;
    vector<vector<int>> adj(n+1);
    for(int i = 1; i<n; i++){
     cin>>u>>v;
     adj[u].push_back(v);
     adj[v].push_back(u);
   }
   vector<pair<int, int>> cardinality;
   getCardinality(adj, n, cardinality);
   sort(cardinality.begin(), cardinality.end(), greater<pair<int, int>>());
   cout<<findComponents(adj, cardinality, n)<<"\n";
   t--;
 }
 return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++17 (GCC 7-32)

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

int main(){
    ios::sync_with_stdio(false); cin.tie(0);
    int t; cin >> t;
    while(t--){
        int n, k;
        cin >> n >> k;
        vector<int> a(n);
        for(int i=0; i<n; i++) cin >> a[i];
        sort(a.begin(), a.end());
        vector<int> cnt = {1};
        for(int i=1; i<n; i++){
            if(a[i] == a[i-1]) cnt.back()++;
            else cnt.push_back(1);
        }
        sort(cnt.begin(), cnt.end());
        int m = cnt.size();
        for(int i=0; i<m; i++){
            if(cnt[i] > k){
                cout << m-i << "\n";
                return 0;
            }
            k-=cnt[i];
        }
        cout << 1 << "\n";
    }
}

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

int main(){
    ios::sync_with_stdio(false); cin.tie(0);
    int t; cin >> t;
    while(t--){
        int n, k;
        cin >> n >> k;
        vector<int> a(n);
        for(int i=0; i<n; i++) cin >> a[i];
        sort(a.begin(), a.end());
        vector<int> cnt = {1};
        for(int i=1; i<n; i++){
            if(a[i] == a[i-1]) cnt.back()++;
            else cnt.push_back(1);
        }
        sort(cnt.begin(), cnt.end());
        int m = cnt.size();
        bool flag = 0;
        for(int i=0; i<m; i++){
            if(cnt[i] > k){
                cout << m-i << "\n";
                flag=1;
                break;
            }
            k-=cnt[i];
        }
        if(!flag) cout << 1 << "\n";
    }
}
Problem: 2057B - Gorilla and the Exam
Language: C++17 (GCC 7-32)

Previous submission (verdict: Compilation error):
#include<bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
    ios::sync_with_stdio(false); cin.tie(0);
    int t; cin >> t;
    while(t--){
        int n, k;
        cin >> n >> k;
        vector<int> a(n);
        for(int i=0, i<n, i++) cin >> a[i];
        sort(a.begin(), a.end());
        vector<int> cnt = {1};
        for(int i=1, i<n, i++){
            if(a[i] == a[i-1]) cnt.back()++;
            else cnt.push_back(1);
        }
        sort(cnt.begin(), cnt.end());
        int m = cnt.size();
        for(int i=0, i<m, i++){
            if(cnt[i] > k){
                cout << m-i << "\n";
                return;
            }
            k-=cnt[i];
        }
        cout << 1 << "\n";
    }
}

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

int main(){
    ios::sync_with_stdio(false); cin.tie(0);
    int t; cin >> t;
    while(t--){
        int n, k;
        cin >> n >> k;
        vector<int> a(n);
        for(int i=0; i<n; i++) cin >> a[i];
        sort(a.begin(), a.end());
        vector<int> cnt = {1};
        for(int i=1; i<n; i++){
            if(a[i] == a[i-1]) cnt.back()++;
            else cnt.push_back(1);
        }
        sort(cnt.begin(), cnt.end());
        int m = cnt.size();
        for(int i=0; i<m; i++){
            if(cnt[i] > k){
                cout << m-i << "\n";
                return;
            }
            k-=cnt[i];
        }
        cout << 1 << "\n";
    }
}
Problem: 2057B - Gorilla and the Exam
Language: C++17 (GCC 7-32)


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

int main(){
    ios::sync_with_stdio(false); cin.tie(0);
    int t; cin >> t;
    while(t--){
        int n, k;
        cin >> n >> k;
        vector<int> a(n);
        for(int i=0, i<n, i++) cin >> a[i];
        sort(a.begin(), a.end());
        vector<int> cnt = {1};
        for(int i=1, i<n, i++){
            if(a[i] == a[i-1]) cnt.back()++;
            else cnt.push_back(1);
        }
        sort(cnt.begin(), cnt.end());
        int m = cnt.size();
        for(int i=0, i<m, i++){
            if(cnt[i] > k){
                cout << m-i << "\n";
                return;
            }
            k-=cnt[i];
        }
        cout << 1 << "\n";
    }
}
Problem: 2057B - Gorilla and the Exam
Language: C++17 (GCC 7-32)

Previous submission (verdict: Compilation error):
#include<bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
    ios::sync_with_stdio(false); cin.tie(0);
    int t; cin >> t;
    while(t--){
        int n, k;
        cin >> n >> k;
        vector<int> a(n);
        for(int i=0; i<n; i++) cin >> a[i];
        sort(a.begin(), a.end());
        vector<int> cnt = {1};
        for(int i=1; i<n; i++){
            if(a[i] == a[i-1]) cnt.back()++;
            else cnt.push_back(1);
        }
        sort(cnt.begin(), cnt.end());
        int m = cnt.size();
        for(int i=0; i<m; i++){
            if(cnt[i] > k){
                cout << m-i << "\n";
                return;
            }
            k-=cnt[i];
        }
        cout << 1 << "\n";
    }
}

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

int main(){
    ios::sync_with_stdio(false); cin.tie(0);
    int t; cin >> t;
    while(t--){
        int n, k;
        cin >> n >> k;
        vector<int> a(n);
        for(int i=0; i<n; i++) cin >> a[i];
        sort(a.begin(), a.end());
        vector<int> cnt = {1};
        for(int i=1; i<n; i++){
            if(a[i] == a[i-1]) cnt.back()++;
            else cnt.push_back(1);
        }
        sort(cnt.begin(), cnt.end());
        int m = cnt.size();
        for(int i=0; i<m; i++){
            if(cnt[i] > k){
                cout << m-i << "\n";
                return 0;
            }
            k-=cnt[i];
        }
        cout << 1 << "\n";
    }
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector <ll>;
using ii = pair <ll, ll>;
using vii = vector <ii>;

int main(){
    ios::sync_with_stdio(false); cin.tie(0);
    int t; cin >> t;
    while(t--){
        int n; cin >> n;
        vector<int> a(n);
        int ans=0;
        for(int i=0; i<n; i++){
            cin >> a[i];
            ans+= a[i];
        }
        int s=a.size();
        while(s>1){
            ans = max(ans, abs(a[s-1] - a[0]));
            for(int i=0; i<s-1; i++){
                a[i] = a[i+1] - a[i];
            }
            a.pop_back();
            s-=1;
        }
        cout << ans << "\n";
    }
}


Submission (verdict: Compilation error):
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector <ll>;
using ii = pair <ll, ll>;
using vii = vector <ii>;

int main(){
    ios::sync_with_stdio(false); cin.tie(0);
    int t; cin >> t;
    while(t--){
        int n; cin >> n;
        vector<ll> a(n);
        int ans=0;
        for(int i=0; i<n; i++){
            cin >> a[i];
            ans+= a[i];
        }
        int s=a.size();
        while(s>1){
            ans = max(ans, abs(a[s-1] - a[0]));
            for(int i=0; i<s-1; i++){
                a[i] = a[i+1] - a[i];
            }
            a.pop_back();
            s-=1;
        }
        cout << ans << "\n";
    }
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)

Previous submission (verdict: Compilation error):
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector <ll>;
using ii = pair <ll, ll>;
using vii = vector <ii>;

int main(){
    ios::sync_with_stdio(false); cin.tie(0);
    int t; cin >> t;
    while(t--){
        int n; cin >> n;
        vector<ll> a(n);
        int ans=0;
        for(int i=0; i<n; i++){
            cin >> a[i];
            ans+= a[i];
        }
        int s=a.size();
        while(s>1){
            ans = max(ans, abs(a[s-1] - a[0]));
            for(int i=0; i<s-1; i++){
                a[i] = a[i+1] - a[i];
            }
            a.pop_back();
            s-=1;
        }
        cout << ans << "\n";
    }
}


Submission (verdict: Accepted):
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector <ll>;
using ii = pair <ll, ll>;
using vii = vector <ii>;

int main(){
    ios::sync_with_stdio(false); cin.tie(0);
    int t; cin >> t;
    while(t--){
        int n; cin >> n;
        vector<ll> a(n);
        ll ans=0;
        for(int i=0; i<n; i++){
            cin >> a[i];
            ans+= a[i];
        }
        int s=a.size();
        while(s>1){
            ans = max(ans, abs(a[s-1] - a[0]));
            for(int i=0; i<s-1; i++){
                a[i] = a[i+1] - a[i];
            }
            a.pop_back();
            s-=1;
        }
        cout << ans << "\n";
    }
}