ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2061D - Kevin and Numbers
Language: C++20 (GCC 13-64)


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

void solve(){
     int n , m; cin >> n >> m;
     
     multiset<int> a , b;
     
     for(int i = 0; i < n; ++i) {
         int x; cin >> x;
         a.insert(x);
     } 
     
     for(int i = 0; i < m; ++i) {
        int x; cin >> x;
        b.insert(x);
     }
     
     while(((int)b.size() > 0) and ((int)a.size() > 0)) {
        //     for(auto &it : a) {
        //     cout << it << " ";
        // } cout << " $\n";
        
        
         
        if(*a.begin() == *b.begin()) {
            a.erase(a.begin());
            b.erase(b.begin());
        } else {
            // cout << ((int)a.count(*a.begin() + 1)) << " " << ((*a.begin()) + 1) <<  "\n";
            // cout << ((int)a.count(*a.begin())) << " " << ((*a.begin())) <<  "\n";
            
            if(((int)a.size() > 1) and ((int)a.count(*a.begin()) > 1)) {
                int x = *a.begin();
                a.erase(a.begin());
                a.erase(a.find(x));
                // b.erase(b.begin());
                
                a.insert((int)2 * x);                
            } else if(((int)a.size() > 1) and (int)a.count(*a.begin() + 1)) {
                int x = *a.begin();
                a.erase(a.begin());
                a.erase(a.find(x + 1));
                // b.erase(b.begin());
                
                a.insert(((int)2 * x)  + (int)1);
            } else {
                cout << "No" << "\n"; return;
            }
        }
     }
     
    //  for(auto &it : a) {
    //       cout << it << " ";
    // } cout << " $\n";
     
     if(!(int)a.size()) {
         cout << "Yes" << "\n";
     } else {
         cout << "No" << "\n";
     }
}  
 
int32_t main(){
 
    int t = 1;
    cin >> t;
 
    while(t--){
        solve();
    } 
 
    return 0;
}

/*
Yes
No
Yes
Yes
No
Yes
No
No
No

*/
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;

int main() {
     int t;
     cin>>t;
     while(t--){
         int n,k;
         cin>>n>>k;
         int arr[n];
         for(int i=0;i<n;i++) cin>>arr[i];
         unordered_map<int,int>fq;
         for(int i=0;i<n;i++) fq[arr[i]]++;
         int un=fq.size();
         int ans=max(un-k,1);
         cout<<ans<<endl;
      
    }
    return 0;
}

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

int main() {
     int t;
     cin>>t;
     while(t--){
         int n,k;
         cin>>n>>k;
         int arr[n];
         for(long long int i=0;i<n;i++) cin>>arr[i];
         unordered_map<int,int>fq;
         for(int i=0;i<n;i++) fq[arr[i]]++;
         int un=fq.size();
         int ans=max(un-k,1);
         cout<<ans<<endl;
      
    }
    return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++17 (GCC 7-32)


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

int main() {
     int t;
     cin>>t;
     while(t--){
         int n,k;
         cin>>n>>k;
         int arr[n];
         for(int i=0;i<n;i++) cin>>arr[i];
         unordered_map<int,int>fq;
         for(int i=0;i<n;i++) fq[arr[i]]++;
         int un=fq.size();
         int ans=max(un-k,1);
         cout<<ans<<endl;
      
    }
    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;

int main() {
     int t;
     cin>>t;
     while(t--){
         int n,k;
         cin>>n>>k;
         int arr[n];
         for(long long int i=0;i<n;i++) cin>>arr[i];
         unordered_map<int,int>fq;
         for(int i=0;i<n;i++) fq[arr[i]]++;
         int un=fq.size();
         int ans=max(un-k,1);
         cout<<ans<<endl;
      
    }
    return 0;
}

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

int main()
{
    int t;
    cin>>t;
    while(t--) {
        int n,k; cin>>n>>k;
        map<int,int> fq;
        for(int i=0;i<n;i++) {
            int x;
            cin>>x;
            fq[x]++;
        }
        vector<int> v;
        for(auto& x : fq) {
            v.push_back(x.second);
        }
        sort(v.begin(),v.end(), greater<int> ());
        while(k > 0 && !v.empty()) {
            if(v.back() > k)
                break;
            k -= v.back();
            v.pop_back();
        }
        cout <<  max((int)v.size(), 1) << endl;
    }
    return 0;
}
Problem: 2061D - Kevin and Numbers
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 3):
#include<bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define x first
#define y second
using namespace std;
int a[300005],b[300005];
map<int,int>gs;
multiset<pii>s;
int dfs(){
	while(!s.empty()){
		pii o=*s.begin();
		while(s.size()>1){
			auto e=s.begin();
			o=*e;
			e++;
			pii t=*e;
			if(o.x==t.x)
				o.y+=t.y,s.erase(s.begin()),s.erase(s.begin()),s.insert(o);
			else
				break;
		}
		o=*s.begin();
		s.erase(s.begin());
		if(gs[o.x]>=o.y)
			gs[o.x]-=o.y;
		else{
			s.insert({o.x/2,o.y-gs[o.x]});
			s.insert({o.x-o.x/2,o.y-gs[o.x]});
			gs[o.x]=0;
			if(o.x==1)
				break;
			if(o.x==0)
				break;
		}
	}
	if(s.size()==0)
		return 1;
	else
		return 0;
}
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int T;
	cin>>T;
	while(T--){
		s.clear();
		int n,m,sum=0;
		cin>>n>>m;
		for(int i=1;i<=n;i++)
			cin>>a[i],gs[a[i]]++,sum+=a[i];
		for(int i=1;i<=m;i++){
			cin>>b[i];
			sum-=b[i];
			s.insert({b[i],1});
		}
		if(dfs()&&sum==0)
			cout<<"Yes\n";
		else
			cout<<"No\n";
	}
	return 0;
}

Submission (verdict: Accepted):
#include<bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define x first
#define y second
using namespace std;
int a[300005],b[300005];
map<int,int>gs;
multiset<pii>s;
int dfs(){
	while(!s.empty()){
		pii o;
		while(s.size()>1){
			auto e=--s.end();
			o=*e;
			e--;
			pii t=*e;
			if(o.x==t.x)
				o.y+=t.y,s.erase(--s.end()),s.erase(--s.end()),s.insert(o);
			else
				break;
		}
		o=*--s.end();
		s.erase(--s.end());
		if(gs[o.x]>=o.y)
			gs[o.x]-=o.y;
		else{
			s.insert({o.x/2,o.y-gs[o.x]});
			s.insert({o.x-o.x/2,o.y-gs[o.x]});
			gs[o.x]=0;
			if(o.x==1)
				break;
		}
	}
	if(s.size()==0)
		return 1;
	else
		return 0;
}
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int T;
	cin>>T;
	while(T--){
		s.clear();
		int n,m,sum=0;
		cin>>n>>m;
		for(int i=1;i<=n;i++)
			cin>>a[i],gs[a[i]]++,sum+=a[i];
		for(int i=1;i<=m;i++){
			cin>>b[i];
			sum-=b[i];
			s.insert({b[i],1});
		}
		if(dfs()&&sum==0)
			cout<<"Yes\n";
		else
			cout<<"No\n";
		for(int i=1;i<=n;i++)
			gs[a[i]]=0;
	}
	return 0;
}
/*

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


Submission (verdict: Wrong answer on test 3):
#include<bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define x first
#define y second
using namespace std;
int a[300005],b[300005];
map<int,int>gs;
multiset<pii>s;
int dfs(){
	while(!s.empty()){
		pii o=*s.begin();
		while(s.size()>1){
			auto e=s.begin();
			o=*e;
			e++;
			pii t=*e;
			if(o.x==t.x)
				o.y+=t.y,s.erase(s.begin()),s.erase(s.begin()),s.insert(o);
			else
				break;
		}
		o=*s.begin();
		s.erase(s.begin());
		if(gs[o.x]>=o.y)
			gs[o.x]-=o.y;
		else{
			if(o.y>gs[o.x])
			s.insert({o.x/2,o.y-gs[o.x]});
			s.insert({o.x-o.x/2,o.y-max(0ll,gs[o.x]-o.y)});
			gs[o.x]=0;
			if(o.x==1)
				break;
			if(o.x==0)
				break;
		}
	}
	if(s.size()==0)
		return 1;
	else
		return 0;
}
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int T;
	cin>>T;
	while(T--){
		s.clear();
		int n,m,sum=0;
		cin>>n>>m;
		for(int i=1;i<=n;i++)
			cin>>a[i],gs[a[i]]++,sum+=a[i];
		for(int i=1;i<=m;i++){
			cin>>b[i];
			sum-=b[i];
			s.insert({b[i],1});
		}
		if(dfs()&&sum==0)
			cout<<"Yes\n";
		else
			cout<<"No\n";
	}
	return 0;
}
Problem: 2061D - Kevin and Numbers
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 3):
#include<bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define x first
#define y second
using namespace std;
int a[300005],b[300005];
map<int,int>gs;
multiset<pii>s;
int dfs(){
	while(!s.empty()){
		pii o=*s.begin();
		while(s.size()>1){
			auto e=s.begin();
			o=*e;
			e++;
			pii t=*e;
			if(o.x==t.x)
				o.y+=t.y,s.erase(s.begin()),s.erase(s.begin()),s.insert(o);
			else
				break;
		}
		o=*s.begin();
		s.erase(s.begin());
		if(gs[o.x]>=o.y)
			gs[o.x]-=o.y;
		else{
			if(o.y>gs[o.x])
			s.insert({o.x/2,o.y-gs[o.x]});
			s.insert({o.x-o.x/2,o.y-max(0ll,gs[o.x]-o.y)});
			gs[o.x]=0;
			if(o.x==1)
				break;
			if(o.x==0)
				break;
		}
	}
	if(s.size()==0)
		return 1;
	else
		return 0;
}
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int T;
	cin>>T;
	while(T--){
		s.clear();
		int n,m,sum=0;
		cin>>n>>m;
		for(int i=1;i<=n;i++)
			cin>>a[i],gs[a[i]]++,sum+=a[i];
		for(int i=1;i<=m;i++){
			cin>>b[i];
			sum-=b[i];
			s.insert({b[i],1});
		}
		if(dfs()&&sum==0)
			cout<<"Yes\n";
		else
			cout<<"No\n";
	}
	return 0;
}

Submission (verdict: Wrong answer on test 3):
#include<bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define x first
#define y second
using namespace std;
int a[300005],b[300005];
map<int,int>gs;
multiset<pii>s;
int dfs(){
	while(!s.empty()){
		pii o=*s.begin();
		while(s.size()>1){
			auto e=s.begin();
			o=*e;
			e++;
			pii t=*e;
			if(o.x==t.x)
				o.y+=t.y,s.erase(s.begin()),s.erase(s.begin()),s.insert(o);
			else
				break;
		}
		o=*s.begin();
		s.erase(s.begin());
		if(gs[o.x]>=o.y)
			gs[o.x]-=o.y;
		else{
			s.insert({o.x/2,o.y-gs[o.x]});
			s.insert({o.x-o.x/2,o.y-gs[o.x]});
			gs[o.x]=0;
			if(o.x==1)
				break;
			if(o.x==0)
				break;
		}
	}
	if(s.size()==0)
		return 1;
	else
		return 0;
}
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int T;
	cin>>T;
	while(T--){
		s.clear();
		int n,m,sum=0;
		cin>>n>>m;
		for(int i=1;i<=n;i++)
			cin>>a[i],gs[a[i]]++,sum+=a[i];
		for(int i=1;i<=m;i++){
			cin>>b[i];
			sum-=b[i];
			s.insert({b[i],1});
		}
		if(dfs()&&sum==0)
			cout<<"Yes\n";
		else
			cout<<"No\n";
	}
	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;

using ll = long long;
using str = string;
using vi = vector<int>;
using pi = pair<int, int>;
using vpi = vector<pi>;
using si = set<int>;

#define sz (int)(x).size()
#define pb push_back
#define all(x) begin(x), end(x)
#define sor(x) sort(all(x))
#define rev(x) reverse(all(x))
#define del(x, i) erase(begin(x) + i)
#define rem(x, i) erase(begin(x), begin(x) + i)

#define mp make_pair
#define sec second
#define fir first

#define ins insert
#define ez erase
#define cnt count

#define MOD 1e9 + 7
#define MAX_INT 1e18 * 9

#define possibilities(x) while(next_permutation(all(x)))

#define Trav(a, x) for (auto &a : x)
#define For(i, a, b) for (int i = (a); i < (b); ++i)

void solve() {
    int n;
    cin >> n;
    vector<vector<int>> adj(n);
    vector<int> degree(n);
    For(i, 0, n - 1) {
        int x, y;
        cin >> x >> y;
        x--, y--;
        degree[x]++, degree[y]++;
        adj[x].pb(y), adj[y].pb(x);
    }
    if(n <= 2) {
        cout << 0 << endl;
        return;
    }
    int res = 0;

    int rm = 0;
    for(int i = 0; i < n; i++) if(degree[i] > degree[rm]) rm = i;
    res += degree[rm];
    for(int x: adj[rm]) degree[x]--;
    degree[rm] = -1;

    rm = 0;
    For(i, 0, n) if(degree[i] > degree[rm]) rm = i;
    res += degree[rm];
        
    cout << res - 1 << endl;
}

int main() {
    int t;
    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>
using namespace std;
typedef long long ll;

void solve() {
    ll n, t;
    ll maxi = 0;
    cin >> n;
    vector<ll> a(n);
    for(ll i=0; i<n; i++){
      cin >> t;
      a[i] = t;
      maxi+= t;
    }
    bool istrue = false;
    ll sum;
    ll len = n;
    ll diff;
    vector<ll> b;
    while(len > 1){
      sum = 0;
      if(istrue){
        for(ll i=0; i < len - 1; i++){
          diff = a[i+1] - a[i];
          a[i] = diff;
          sum += diff;
        }
      }else{
        for(ll i=0; i < len - 1; i++){
          diff = -(a[i+1] - a[i]);
          a[i] = diff;
          sum += diff;
        }
      }
      istrue = !istrue;
      maxi = max(maxi, sum);
      len = len - 1;
    }
    cout << maxi << endl;
}

int main() {
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}


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

void solve() {
    ll n, t;
    cin >> n;
    vector<ll> a(n);
    for(int i=0; i<n; i++) cin >> a[i];
    ll len = n;
    ll sum = 0;
    if(n == 1){
      cout << a[0] << endl;
      return;
    }
    vector<ll> v;
    ll maxi = accumulate(a.begin(), a.end(), 0LL);
    while(len > 1){
      sum = 0;
      for(int i=0; i<len-1; i++){
        // sum += a[i];
        v.push_back(a[i+1] - a[i]);
      }
      
      for(ll i = 0; i < len - 1; i++){
        a[i] = v[i];
      }
      
      maxi = max(maxi, abs(accumulate(v.begin(), v.end(), 0LL)));
      v.clear();
      len--;
    }
    cout << maxi << endl;
}

int main() {
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)


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

void solve() {
    int n, t;
    ll maxi = 0;
    cin >> n;
    vector<int> a(n);
    for(int i=0; i<n; i++){
      cin >> t;
      a[i] = t;
      maxi+= t;
    }
    bool istrue = false;
    ll sum;
    int len = n;
    int diff;
    vector<int> b;
    while(len > 1){
      sum = 0;
      if(istrue){
        for(int i=0; i < len - 1; i++){
          diff = a[i+1] - a[i];
          a[i] = diff;
          sum += diff;
        }
      }else{
        for(int i=0; i < len - 1; i++){
          diff = -(a[i+1] - a[i]);
          a[i] = diff;
          sum += diff;
        }
      }
      istrue = !istrue;
      maxi = max(maxi, sum);
      len = len - 1;
    }
    cout << maxi << endl;
}

int main() {
    int t;
    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>
using namespace std;
typedef long long ll;

void solve() {
    int n, t;
    ll maxi = 0;
    cin >> n;
    vector<int> a(n);
    for(int i=0; i<n; i++){
      cin >> t;
      a[i] = t;
      maxi+= t;
    }
    bool istrue = false;
    ll sum;
    int len = n;
    int diff;
    vector<int> b;
    while(len > 1){
      sum = 0;
      if(istrue){
        for(int i=0; i < len - 1; i++){
          diff = a[i+1] - a[i];
          a[i] = diff;
          sum += diff;
        }
      }else{
        for(int i=0; i < len - 1; i++){
          diff = -(a[i+1] - a[i]);
          a[i] = diff;
          sum += diff;
        }
      }
      istrue = !istrue;
      maxi = max(maxi, sum);
      len = len - 1;
    }
    cout << maxi << endl;
}

int main() {
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}


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

void solve() {
    ll n, t;
    ll maxi = 0;
    cin >> n;
    vector<ll> a(n);
    for(ll i=0; i<n; i++){
      cin >> t;
      a[i] = t;
      maxi+= t;
    }
    bool istrue = false;
    ll sum;
    ll len = n;
    ll diff;
    vector<ll> b;
    while(len > 1){
      sum = 0;
      if(istrue){
        for(ll i=0; i < len - 1; i++){
          diff = a[i+1] - a[i];
          a[i] = diff;
          sum += diff;
        }
      }else{
        for(ll i=0; i < len - 1; i++){
          diff = -(a[i+1] - a[i]);
          a[i] = diff;
          sum += diff;
        }
      }
      istrue = !istrue;
      maxi = max(maxi, sum);
      len = len - 1;
    }
    cout << maxi << endl;
}

int main() {
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}
Problem: 2063B - Subsequence Update
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 1):
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    int t;
    cin >> t;
    while (t--) {
     int l,r;
     cin>>l>>r;
     int i=l;
     if(l==1){i=2;}
     
     int j=i+1;
     int count=0;
    //  cout<<i<<" "<<j<<endl;
     while( j<=r && i!=1){
        
        j++;
        count++;
     }
     if(l==1){count++;}
        cout<<count<<endl;
    }
    return 0;
}


Submission (verdict: Wrong answer on test 8):
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int solve(int i,int j,vector<int> &v,int l,int r){
   int maxi=*max_element(v.begin()+i,v.begin()+r+1);
   int size=r-l+1;
   
   vector<int> temp1(v.begin()+min(i,l),v.begin()+max(r,j)+1);
   sort(temp1.begin(),temp1.end());
   int sum=0;
   int k=0;
   while(k<size){
        sum+=temp1[k];
        k++;
   }
   return sum;
}

int main() {
    int t;
    cin >> t;
    while (t--) {
     int n,l,r;
     cin>>n>>l>>r;
     vector<int> v(n);
     int ans3=0;
     for(int i=0;i<n;i++){
        cin>>v[i];
        ans3+=v[i];
     }
     l--;
     r--;
     int ans1=solve(0,r,v,l,r);
     int ans2=solve(l,n-1,v,l,r);

     cout<<min(ans3,min(ans1,ans2))<<endl;
    }
    return 0;
}
Problem: 2063B - Subsequence Update
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 8):
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int solve(int i,int j,vector<int> &v,int l,int r){
   int maxi=*max_element(v.begin()+i,v.begin()+r+1);
   int size=r-l+1;
   
   vector<int> temp1(v.begin()+min(i,l),v.begin()+max(r,j)+1);
   sort(temp1.begin(),temp1.end());
   int sum=0;
   int k=0;
   while(k<size){
        sum+=temp1[k];
        k++;
   }
   return sum;
}

int main() {
    int t;
    cin >> t;
    while (t--) {
     int n,l,r;
     cin>>n>>l>>r;
     vector<int> v(n);
     int ans3=0;
     for(int i=0;i<n;i++){
        cin>>v[i];
        ans3+=v[i];
     }
     l--;
     r--;
     int ans1=solve(0,r,v,l,r);
     int ans2=solve(l,n-1,v,l,r);

     cout<<min(ans3,min(ans1,ans2))<<endl;
    }
    return 0;
}


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

#include <vector>

#include <algorithm>

using namespace std;



long long solve(int i, int j, vector<long long> &v, int l, int r) {

   long long maxi = *max_element(v.begin() + i, v.begin() + r + 1);

   long long size = r - l + 1;

   

   vector<long long> temp1(v.begin() + min(i, l), v.begin() + max(r, j) + 1);

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

   long long sum = 0;

   long long k = 0;

   while (k < size) {

        sum += temp1[k];

        k++;

   }

   return sum;

}



int main() {

    ios::sync_with_stdio(false);

    cin.tie(nullptr);

    

    int t;

    cin >> t;

    while (t--) {

        int n, l, r;

        cin >> n >> l >> r;

        vector<long long> v(n);

        long long ans3 = 0;

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

            cin >> v[i];

            ans3 += v[i];

        }

        l--;

        r--;

        long long ans1 = solve(0, r, v, l, r);

        long long ans2 = solve(l, n - 1, v, l, r);



        cout << min(ans3, min(ans1, ans2)) << endl;

    }

    return 0;

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


Submission (verdict: Wrong answer on test 1):
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    int t;
    cin >> t;
    while (t--) {
     int l,r;
     cin>>l>>r;
     int i=l;
     if(l==1){i=2;}
     
     int j=i+1;
     int count=0;
    //  cout<<i<<" "<<j<<endl;
     while( j<=r && i!=1){
        
        j++;
        count++;
     }
     if(l==1){count++;}
        cout<<count<<endl;
    }
    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++17 (GCC 7-32)


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

void solve(){
    int n;
    cin >> n;
    int a[n];
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    if(n == 1){
        cout << a[0] << endl;
        return;
    }
    int ans = 0;
    for(int i=0;i<n;i++){
        int sum = 0;
        for(int j=0;j<n-i;j++){
            if(i != 0){
                a[j] = a[j+1] - a[j];
            }
            sum += a[j];
        }
        ans = max(ans, abs(sum));
    }
    cout << ans << endl;
}

// ababa

// baba                  aaba
// bba aba              aba    
// ba   ba  aa         ba   aa
// a b  a b a  

// 9  

// abcde

// acde    bcde
// ade cde  bde 
// ae de  ce  be 

// a b c d e

int main(){
    int t = 1;
    cin >> t;
    while(t--){
        solve();
    }
}
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;

void solve(){
    int n;
    cin >> n;
    long long int a[n];
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    if(n == 1){
        cout << a[0] << endl;
        return;
    }
    long long int ans = 0;
    for(int i=0;i<n;i++){
        long long int sum = 0;
        for(int j=0;j<n-i;j++){
            if(i != 0){
                a[j] = a[j+1] - a[j];
            }
            sum += a[j];
        }
        ans = max(ans, abs(sum));
    }
    cout << ans << endl;
}

// ababa

// baba                  aaba
// bba aba              aba    
// ba   ba  aa         ba   aa
// a b  a b a  

// 9  

// abcde

// acde    bcde
// ade cde  bde 
// ae de  ce  be 

// a b c d e

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




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

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

// ababa

// baba                  aaba
// bba aba              aba    
// ba   ba  aa         ba   aa
// a b  a b a  

// 9  

// abcde

// acde    bcde
// ade cde  bde 
// ae de  ce  be 

// a b c d e

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