ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2050C - Uninteresting Number
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 2):
 #include <bits/stdc++.h> 
using namespace std;
int main() { 
    ios_base::sync_with_stdio(0); 
    cin.tie(0);
    int t;
    cin>>t;
    while(t--) {
        string s;
        cin>>s;
        int sum = 0;
        for(int i = 0; i < s.size(); i++) {
            sum+=(s[i]-'0');
        }
        int d = 9-(sum%9), i = 0, t=18-(sum%9), p=27-(sum%9);
        while(d>=6) {
            if(s[i]=='3') {
                d-=6;
            }
            i++;
            if(i==s.size()) break;
        }
        i=0;
        while(d>=2) {
            if(s[i]=='2') {
                d-=2;
            }
            i++;
            if(i==s.size()) break;
        }
        i=0;
        while(d>=1) {
            if(s[i]=='0') {
                d--;
            }
            i++;
            if(i==s.size()) break;
        }
        i=0;
        while(t>=6) {
            if(s[i]=='3') {
                t-=6;
            }
            i++;
            if(i==s.size()) break;
        }
        i=0;
        while(t>=2) {
            if(s[i]=='2') {
                t-=2;
            }
            i++;
            if(i==s.size()) break;
        }
        i=0;
        while(t>=1) {
            if(s[i]=='0') {
                t--;
            }
            i++;
            if(i==s.size()) break;
        }
        i=0;
        while(p>=6) {
            if(s[i]=='3') {
                p-=6;
            }
            i++;
            if(i==s.size()) break;
        }
        i=0;
        while(p>=2) {
            if(s[i]=='2') {
                p-=2;
            }
            i++;
            if(i==s.size()) break;
        }
        i=0;
        while(p>=1) {
            if(s[i]=='0') {
                p--;
            }
            i++;
            if(i==s.size()) break;
        }
        if(p==0||t==0||d==0) {
            cout<<"YES\n";
        } else {
            cout<<"NO\n";
        }
    }
 }
Problem: 2052A - Adrenaline Rush
Language: C++23 (GCC 14-64, msys2)


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

//
void solve(){
    int n;
    cin>>n;
    vector<int> a(n+1);
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    vector<pair<int,int> > ans;
    for(int i=n;i>=1;i--){
        for(int j=i-1;j>=1;j--){
            if(a[i]>a[j]){
                ans.push_back({a[i],a[j]});
                ans.push_back({a[j],a[i]});
            }else{
                ans.push_back({a[j],a[i]});
            }
        }
    }
    cout<<ans.size()<<endl;
    for(auto &[x,y]:ans){
        cout<<x<<' '<<y<<endl;
    }
    cout<<endl;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int tt;
    //cin>>tt;
    tt=1;
    while(tt--){
        solve();
    }
    return 0;
}
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;
using ll =long long ;
const int MAX_INT = 2147483647;
const ll MAX_LL = 9223372036854775807;

//
void solve(){
    int n;
    cin>>n;
    vector<int> a(n+1);
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    vector<pair<int,int> > ans;
    for(int i=n;i>=1;i--){
        for(int j=1;j<=i-1;j++){
            if(a[i]>a[j]){
                ans.push_back({a[i],a[j]});
                ans.push_back({a[j],a[i]});
            }else{
                ans.push_back({a[j],a[i]});
            }
        }
    }
    cout<<ans.size()<<endl;
    for(auto &[x,y]:ans){
        cout<<x<<' '<<y<<endl;
    }
    cout<<endl;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int tt;
    //cin>>tt;
    tt=1;
    while(tt--){
        solve();
    }
    return 0;
}

Submission (verdict: Wrong answer on test 5):
#include<bits/stdc++.h>
using namespace std;
using ll =long long ;
const int MAX_INT = 2147483647;
const ll MAX_LL = 9223372036854775807;

//
void solve(){
    int n;
    cin>>n;
    vector<int> a(n+1);
    vector<vector<int> > vis(n+1,vector<int>(n+1));
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    vector<pair<int,int> > ans;
    for(int i=n;i>=1;i--){
        for(int j=1;j<=i-1;j++){
            if(a[i]>a[j]){
                for(int k=a[i]-1;k>=a[j];k--) {
                    if(vis[a[i]][k]) continue;
                    ans.push_back({a[i],k});
                    vis[a[i]][k]=1;
                }
                ans.push_back({a[j],a[i]});
            }
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=n;j>=i+1;j--){
            if(a[i]>a[j]){
                if(vis[a[i]][a[j]]) continue;
                ans.push_back({a[i],a[j]});
                vis[a[i]][a[j]]=1;
            }
        }
    }
    cout<<ans.size()<<endl;
    for(auto &[x,y]:ans){
        cout<<x<<' '<<y<<endl;
    }
    cout<<endl;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int tt;
    //cin>>tt;
    tt=1;
    while(tt--){
        solve();
    }
    return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 5):
#include<bits/stdc++.h>
using namespace std;
using ll =long long ;
const int MAX_INT = 2147483647;
const ll MAX_LL = 9223372036854775807;

//
void solve(){
    int n;
    cin>>n;
    vector<int> a(n+1);
    vector<vector<int> > vis(n+1,vector<int>(n+1));
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    vector<pair<int,int> > ans;
    for(int i=n;i>=1;i--){
        for(int j=1;j<=i-1;j++){
            if(a[i]>a[j]){
                for(int k=a[i]-1;k>=a[j];k--) {
                    if(vis[a[i]][k]) continue;
                    ans.push_back({a[i],k});
                    vis[a[i]][k]=1;
                }
                ans.push_back({a[j],a[i]});
            }
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=n;j>=i+1;j--){
            if(a[i]>a[j]){
                if(vis[a[i]][a[j]]) continue;
                ans.push_back({a[i],a[j]});
                vis[a[i]][a[j]]=1;
            }
        }
    }
    cout<<ans.size()<<endl;
    for(auto &[x,y]:ans){
        cout<<x<<' '<<y<<endl;
    }
    cout<<endl;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int tt;
    //cin>>tt;
    tt=1;
    while(tt--){
        solve();
    }
    return 0;
}

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

//
void solve(){
    int n;
    cin>>n;
    vector<int> a(n+1);
    vector<vector<int> > vis(n+1,vector<int>(n+1));
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    vector<pair<int,int> > ans;
    for(int i=n;i>1;i--){
        int z=a[i-1];
        for(int j=i-1;j>=1;j--){
            z=min(z,a[j]);
        }
        for(int j=a[i]-1;j>=max(z,1);j--){
            ans.push_back({a[i],j});
        }
    }
  //  cout<<ans.size()<<endl;
    for(int i=1;i<=n;i++){
        for(int j=n;j>=i+1;j--){
            ans.push_back({a[i],a[j]});
        }
    }
    cout<<ans.size()<<endl;
    for(auto &[x,y]:ans){
        cout<<x<<' '<<y<<endl;
    }
    cout<<endl;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int tt;
    //cin>>tt;
    tt=1;
    while(tt--){
        solve();
    }
    return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++23 (GCC 14-64, msys2)

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

//
void solve(){
    int n;
    cin>>n;
    vector<int> a(n+1);
    vector<vector<int> > vis(n+1,vector<int>(n+1));
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    vector<pair<int,int> > ans;
    for(int i=n;i>1;i--){
        int z=a[i-1];
        for(int j=i-1;j>=1;j--){
            z=min(z,a[j]);
        }
        for(int j=a[i]-1;j>=max(z,1);j--){
            ans.push_back({a[i],j});
        }
    }
  //  cout<<ans.size()<<endl;
    for(int i=1;i<=n;i++){
        for(int j=n;j>=i+1;j--){
            ans.push_back({a[i],a[j]});
        }
    }
    cout<<ans.size()<<endl;
    for(auto &[x,y]:ans){
        cout<<x<<' '<<y<<endl;
    }
    cout<<endl;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int tt;
    //cin>>tt;
    tt=1;
    while(tt--){
        solve();
    }
    return 0;
}

Submission (verdict: Accepted):
#include<bits/stdc++.h>
using namespace std;
using ll =long long ;
const int MAX_INT = 2147483647;
const ll MAX_LL = 9223372036854775807;

//倒着模拟,模拟成一辆辆车完成超车；
void solve(){
    int n;
    cin>>n;
    vector<int> a(n+1);
    vector<vector<int> > vis(n+1,vector<int>(n+1));
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    vector<pair<int,int> > ans;
    for(int i=1;i<=n;i++){
        for(int j=1;j<n;j++){
            if(a[j]<a[j+1]){
                ans.push_back({a[j],a[j+1]});
                swap(a[j],a[j+1]);
            }
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<n;j++){
            if(a[j]>a[j+1]){
                ans.push_back({a[j],a[j+1]});
                swap(a[j],a[j+1]);
            }
        }
    }
    reverse(begin(ans),end(ans));
    cout<<ans.size()<<endl;
    for(auto &[x,y]:ans){
        cout<<x<<' '<<y<<endl;
    }
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int tt;
    //cin>>tt;
    tt=1;
    while(tt--){
        solve();
    }
    return 0;
}
Problem: 2052A - Adrenaline Rush
Language: C++23 (GCC 14-64, msys2)

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

//
void solve(){
    int n;
    cin>>n;
    vector<int> a(n+1);
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    vector<pair<int,int> > ans;
    for(int i=n;i>=1;i--){
        for(int j=i-1;j>=1;j--){
            if(a[i]>a[j]){
                ans.push_back({a[i],a[j]});
                ans.push_back({a[j],a[i]});
            }else{
                ans.push_back({a[j],a[i]});
            }
        }
    }
    cout<<ans.size()<<endl;
    for(auto &[x,y]:ans){
        cout<<x<<' '<<y<<endl;
    }
    cout<<endl;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int tt;
    //cin>>tt;
    tt=1;
    while(tt--){
        solve();
    }
    return 0;
}

Submission (verdict: Wrong answer on test 4):
#include<bits/stdc++.h>
using namespace std;
using ll =long long ;
const int MAX_INT = 2147483647;
const ll MAX_LL = 9223372036854775807;

//
void solve(){
    int n;
    cin>>n;
    vector<int> a(n+1);
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    vector<pair<int,int> > ans;
    for(int i=n;i>=1;i--){
        for(int j=1;j<=i-1;j++){
            if(a[i]>a[j]){
                ans.push_back({a[i],a[j]});
                ans.push_back({a[j],a[i]});
            }else{
                ans.push_back({a[j],a[i]});
            }
        }
    }
    cout<<ans.size()<<endl;
    for(auto &[x,y]:ans){
        cout<<x<<' '<<y<<endl;
    }
    cout<<endl;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int tt;
    //cin>>tt;
    tt=1;
    while(tt--){
        solve();
    }
    return 0;
}
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int t;
int a[N];
int c;
int x,y;
int sum;
bool f=0;
int main(){
	cin>>t;
	while(t--){
		x=0,y=0;
		for(int i=1;i<=N;i++){
			a[i]=0;
		}
		string s;
		cin>>s;
		c=s.size();
		sum=0;
		f=0;
		for(int i=0;i<c;i++){
			a[i+1]=int(s[i]-'0');
			sum+=a[i+1];
			if(a[i+1]==2){
				x++;
			}
			if(a[i+1]==3){
				y++;
			}
		}
		for(int i=0;i<=x;i++){
			for(int j=0;j<=y;j++){
				if((sum+2*i+6*j)%9==0){
					f=1;
					break;
				}
			}
			if(f==1)break;
		}
		if(f==0){
			cout<<"No"<<endl;
		}else{
			cout<<"Yes"<<endl;
		}
	}
	return 0;
}

Submission (verdict: Accepted):
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int t;
int c;
int x,y;
int sum;
bool f=0;
int main(){
	cin>>t;
	while(t--){
		string s;
		cin>>s;
		c=s.size();
		sum=0;
		f=0;
		x=0,y=0;
		for(int i=0;i<c;i++){
			sum+=int(s[i]-'0');
			if(int(s[i]-'0')==2){
				x++;
			}
			if(int(s[i]-'0')==3){
				y++;
			}
		}
		sum%=9;
		if(sum==0){
			cout<<"Yes"<<endl;
			continue;
		}
		for(int i=0;i<=x;i++){
			for(int j=0;j<=y;j++){
				if((sum+2*i+6*j)%9==0){
					f=1;
					break;
				}
			}
			if(f==1)break;
		}
		if(f==0){
			cout<<"No"<<endl;
		}else{
			cout<<"Yes"<<endl;
		}
	}
	return 0;
}
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
int t;
int a[10];
bool f=0;
int c;
void dfs(int i,int sum){
	if(i>c){//出口
		if(sum%9==0){
			f=1;
		}
		return;
	}
	//不变
	dfs(i+1,sum+a[i]);
	//能否变
	if(2<=a[i]&&a[i]<=3){//可以变
		a[i]*=a[i];
		dfs(i+1,sum+a[i]);
	}
	return;
}
int main(){
	cin>>t;
	while(t--){
		for(int i=1;i<=7;i++){
			a[i]=0;
		}
		string s;
		cin>>s;
		c=s.size();
		for(int i=0;i<s.size();i++){
			a[i+1]=int(s[i]-'0');
			if(a[i+1]>=2&&a[i+1]<=3){
			}
		}
		f=0;
		dfs(1,0);
		if(f==0){
			cout<<"No"<<endl;
		}else{
			cout<<"Yes"<<endl;
		}
	}
	return 0;
}

Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
int t;
int a[10];
bool f=0;
int c;
void dfs(int i,int sum){
	if(i>c){//出口
		if(sum%9==0){
			f=1;
		}
		return;
	}
	//不变
	dfs(i+1,sum+a[i]);
	//能否变
	if(2<=a[i]&&a[i]<=3){//可以变
		a[i]*=a[i];
		dfs(i+1,sum+a[i]);
	}
	return;
}
int main(){
	cin>>t;
	while(t--){
		for(int i=1;i<=7;i++){
			a[i]=0;
		}
		string s;
		cin>>s;
		c=s.size();
		for(int i=0;i<c;i++){
			a[i+1]=int(s[i]-'0');
			if(a[i+1]>=2&&a[i+1]<=3){
			}
		}
		f=0;
		dfs(1,0);
		if(f==0){
			cout<<"No"<<endl;
		}else{
			cout<<"Yes"<<endl;
		}
	}
	return 0;
}
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
int t;
int a[10];
bool f=0;
int c;
void dfs(int i,int sum){
	if(i>c){//出口
		if(sum%9==0){
			f=1;
		}
		return;
	}
	//不变
	dfs(i+1,sum+a[i]);
	//能否变
	if(2<=a[i]&&a[i]<=3){//可以变
		a[i]*=a[i];
		dfs(i+1,sum+a[i]);
	}
	return;
}
int main(){
	cin>>t;
	while(t--){
		for(int i=1;i<=7;i++){
			a[i]=0;
		}
		string s;
		cin>>s;
		c=s.size();
		for(int i=0;i<s.size();i++){
			a[i+1]=int(s[i]-'0');
			if(a[i+1]>=2&&a[i+1]<=3){
			}
		}
		f=0;
		dfs(1,0);
		if(f==0){
			cout<<"No"<<endl;
		}else{
			cout<<"Yes"<<endl;
		}
	}
	return 0;
}
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
int t;
int a[10];
bool f=0;
int c;
void dfs(int i,int sum){
	if(i>c){//出口
		if(sum%9==0){
			f=1;
		}
		return;
	}
	//不变
	dfs(i+1,sum+a[i]);
	//能否变
	if(2<=a[i]&&a[i]<=3){//可以变
		a[i]*=a[i];
		dfs(i+1,sum+a[i]);
	}
	return;
}
int main(){
	cin>>t;
	while(t--){
		for(int i=1;i<=7;i++){
			a[i]=0;
		}
		string s;
		cin>>s;
		c=s.size();
		for(int i=0;i<c;i++){
			a[i+1]=int(s[i]-'0');
			if(a[i+1]>=2&&a[i+1]<=3){
			}
		}
		f=0;
		dfs(1,0);
		if(f==0){
			cout<<"No"<<endl;
		}else{
			cout<<"Yes"<<endl;
		}
	}
	return 0;
}

Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int t;
int a[N];
bool f=0;
int c;
void dfs(int i,int sum){
	if(i>c){//出口
		if(sum%9==0){
			f=1;
		}
		return;
	}
	//不变
	dfs(i+1,sum+a[i]);
	//能否变
	if(2<=a[i]&&a[i]<=3){//可以变
		a[i]*=a[i];
		dfs(i+1,sum+a[i]);
	}
	return;
}
int main(){
	cin>>t;
	while(t--){
		for(int i=1;i<=N;i++){
			a[i]=0;
		}
		string s;
		cin>>s;
		c=s.size();
		for(int i=0;i<c;i++){
			a[i+1]=int(s[i]-'0');
			if(a[i+1]>=2&&a[i+1]<=3){
			}
		}
		f=0;
		dfs(1,0);
		if(f==0){
			cout<<"No"<<endl;
		}else{
			cout<<"Yes"<<endl;
		}
	}
	return 0;
}
Problem: 2050C - Uninteresting Number
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int t;
int a[N];
bool f=0;
int c;
void dfs(int i,int sum){
	if(i>c){//出口
		if(sum%9==0){
			f=1;
		}
		return;
	}
	//不变
	dfs(i+1,sum+a[i]);
	//能否变
	if(2<=a[i]&&a[i]<=3){//可以变
		a[i]*=a[i];
		dfs(i+1,sum+a[i]);
	}
	return;
}
int main(){
	cin>>t;
	while(t--){
		for(int i=1;i<=N;i++){
			a[i]=0;
		}
		string s;
		cin>>s;
		c=s.size();
		for(int i=0;i<c;i++){
			a[i+1]=int(s[i]-'0');
			if(a[i+1]>=2&&a[i+1]<=3){
			}
		}
		f=0;
		dfs(1,0);
		if(f==0){
			cout<<"No"<<endl;
		}else{
			cout<<"Yes"<<endl;
		}
	}
	return 0;
}

Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int t;
int a[N];
int c;
int x,y;
int sum;
bool f=0;
int main(){
	cin>>t;
	while(t--){
		x=0,y=0;
		for(int i=1;i<=N;i++){
			a[i]=0;
		}
		string s;
		cin>>s;
		c=s.size();
		sum=0;
		f=0;
		for(int i=0;i<c;i++){
			a[i+1]=int(s[i]-'0');
			sum+=a[i+1];
			if(a[i+1]==2){
				x++;
			}
			if(a[i+1]==3){
				y++;
			}
		}
		for(int i=0;i<=x;i++){
			for(int j=0;j<=y;j++){
				if((sum+2*i+6*j)%9==0){
					f=1;
					break;
				}
			}
			if(f==1)break;
		}
		if(f==0){
			cout<<"No"<<endl;
		}else{
			cout<<"Yes"<<endl;
		}
	}
	return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)

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

#define ll long long

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int tc;
    cin >> tc;
    for(int itc = 0; itc < tc; itc++){
        int n;
        cin >> n;
        vector<int> a(n);
        ll tot = 0, ans = 0;
        for(int i = 0; i < n; i++){
            cin >> a[i];
            ans += a[i];
        }
        if(n == 1){
            cout << ans << '\n';
            continue;
        }
        while(n > 1){
            tot = 0;
            for(int i = 0; i < n - 1; i++){
                a[i] = a[i + 1] - a[i];
                tot += a[i];
            }
            ans = max(abs(tot), ans);
            n--;
        }
        cout << abs(ans) << '\n';
    }
    return 0;
} 

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

#define ll long long

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int tc;
    cin >> tc;
    for(int itc = 0; itc < tc; itc++){
        int n;
        cin >> n;
        vector<ll> a(n);
        ll tot = 0, ans = 0;
        for(int i = 0; i < n; i++){
            cin >> a[i];
            ans += a[i];
        }
        if(n == 1){
            cout << ans << '\n';
            continue;
        }
        while(n > 1){
            tot = 0;
            for(int i = 0; i < n - 1; i++){
                a[i] = a[i + 1] - a[i];
                tot += a[i];
            }
            ans = max(abs(tot), ans);
            n--;
        }
        cout << abs(ans) << '\n';
    }
    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)


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

#define ll long long

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int tc;
    cin >> tc;
    for(int itc = 0; itc < tc; itc++){
        int n;
        cin >> n;
        vector<int> a(n);
        ll tot = 0, ans = 0;
        for(int i = 0; i < n; i++){
            cin >> a[i];
            ans += a[i];
        }
        if(n == 1){
            cout << ans << '\n';
            continue;
        }
        while(n > 1){
            tot = 0;
            for(int i = 0; i < n -1; i++){
                a[i] = a[i + 1] - a[i];
                tot += a[i];
            }
            ans = max(tot, ans);
            n--;
        }
        ans = max(abs(tot), ans);
        cout << abs(ans) << '\n';
    }
    return 0;
}
Problem: 2062C - Cirno and Operations
Language: C++20 (GCC 13-64)

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

#define ll long long

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int tc;
    cin >> tc;
    for(int itc = 0; itc < tc; itc++){
        int n;
        cin >> n;
        vector<int> a(n);
        ll tot = 0, ans = 0;
        for(int i = 0; i < n; i++){
            cin >> a[i];
            ans += a[i];
        }
        if(n == 1){
            cout << ans << '\n';
            continue;
        }
        while(n > 1){
            tot = 0;
            for(int i = 0; i < n -1; i++){
                a[i] = a[i + 1] - a[i];
                tot += a[i];
            }
            ans = max(tot, ans);
            n--;
        }
        ans = max(abs(tot), ans);
        cout << abs(ans) << '\n';
    }
    return 0;
} 

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

#define ll long long

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int tc;
    cin >> tc;
    for(int itc = 0; itc < tc; itc++){
        int n;
        cin >> n;
        vector<int> a(n);
        ll tot = 0, ans = 0;
        for(int i = 0; i < n; i++){
            cin >> a[i];
            ans += a[i];
        }
        if(n == 1){
            cout << ans << '\n';
            continue;
        }
        while(n > 1){
            tot = 0;
            for(int i = 0; i < n - 1; i++){
                a[i] = a[i + 1] - a[i];
                tot += a[i];
            }
            ans = max(abs(tot), ans);
            n--;
        }
        cout << abs(ans) << '\n';
    }
    return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++17 (GCC 7-32)

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


void solver() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int input; cin >> input;
    while(input--) {
        int n, k; cin >> n >> k;
        unordered_map<int, int> map;
        int num;
        for(int i = 0; i < n; i++) {
            cin >> num;
            map[num]++;
        }

        vector<int> vec;
        for(auto ele: map) vec.push_back(ele.second);
        sort(vec.begin(), vec.end());

        int passes = vec.size();

        for(int i = 0; k > 0 && i < vec.size() - 1; i++) {
            int temp = min(vec[i], k);
            vec[i] -= temp;
            k -= temp;
            if(vec[i] == 0) passes--;
        }

        cout << passes << "\n";
    }
}


int main(){

    solver();

}


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


void solver() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int input; cin >> input;
    while(input--) {
        int n, k; cin >> n >> k;
        unordered_map<int, int> map;
        int num;
        for(int i = 0; i < n; i++) {
            cin >> num;
            map[num]++;
        }

        vector<int> vec;
        for(auto ele: map) vec.push_back(ele.second);
        sort(vec.begin(), vec.end());

        int passes = vec.size();

        for(int i = 0; k > 0 && i < vec.size() - 1; i++) {
            if(k >= vec[i]) {
                k -= vec[i];
                vec[i] = 0;
                passes--;
            }
            else break;
        }

        cout << passes << "\n";
    }
}


int main(){

    solver();
;
}