ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2057C - Trip to the Olympiad
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;
void solve(){
	ll l,r;
	scanf("%lld%lld",&l,&r);
	if (l==1&&r==3) {
		printf("1 2 3\n");
		return;
	}
	ll i=31,tmp=0;
	while (i>=0&&(l&(1ll<<i))==(r&(1ll<<i))) tmp=tmp|(r&(1ll<<i)),i--;
	ll a=tmp,b=tmp,c=tmp;
	a=a|(r&(1ll<<i));
	ll j=i;
	while (j>=0&&(l&(1ll<<j))==0) j--; 
	if (i-j==1) b=b|(1ll<<j); 
	for (i-=1;i>j;i--) b=b|(1ll<<i);
	while (j>=0) c=c|(1ll<<j),j--;
	printf("%lld %lld %lld\n",a,b,c);
}
int main(){
	int t;
	scanf("%d",&t);
	while (t--){
		solve();
	}
}


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
#define ll long long
using namespace std;
void solve(){
	ll l,r;
	scanf("%lld%lld",&l,&r);
	if (r-l==2) {
		printf("%d %d %d\n",l,l+1,r);
		return;
	}
	ll i=31,tmp=0;
	while (i>=0&&(l&(1ll<<i))==(r&(1ll<<i))) tmp=tmp|(r&(1ll<<i)),i--;
	ll a=tmp,b=tmp,c=tmp;
	a=a|(r&(1ll<<i));
	ll j=i;
	while (j>=0&&(l&(1ll<<j))==0) j--; 
	if (i-j==1) b=b|(1ll<<j); 
	for (i-=1;i>j;i--) b=b|(1ll<<i);
	while (j>=0) c=c|(1ll<<j),j--;
	printf("%lld %lld %lld\n",a,b,c);
}
int main(){
	int t;
	scanf("%d",&t);
	while (t--){
		solve();
	}
}
Problem: 2057C - Trip to the Olympiad
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;
void solve(){
	ll l,r;
	scanf("%lld%lld",&l,&r);
	if (r-l==2) {
		printf("%d %d %d\n",l,l+1,r);
		return;
	}
	ll i=31,tmp=0;
	while (i>=0&&(l&(1ll<<i))==(r&(1ll<<i))) tmp=tmp|(r&(1ll<<i)),i--;
	ll a=tmp,b=tmp,c=tmp;
	a=a|(r&(1ll<<i));
	ll j=i;
	while (j>=0&&(l&(1ll<<j))==0) j--; 
	if (i-j==1) b=r; 
	for (i-=1;i>j;i--) b=b|(1ll<<i);
	while (j>=0) c=c|(1ll<<j),j--;
	printf("%lld %lld %lld\n",a,b,c);
}
int main(){
	int t;
	scanf("%d",&t);
	while (t--){
		solve();
	}
}


Submission (verdict: Accepted):
#include <bits/stdc++.h>
#define ll long long
using namespace std;
void solve(){
	ll l,r;
	scanf("%lld%lld",&l,&r);
	if (r-l==2) {
		printf("%d %d %d\n",l,l+1,r);
		return;
	}
	ll i=31,tmp=0;
	while (i>=0&&(l&(1ll<<i))==(r&(1ll<<i))) tmp=tmp|(r&(1ll<<i)),i--;
	ll a=tmp,b=tmp,c=tmp;
	a=a|(r&(1ll<<i));
	ll j=i;
	while (j>=0&&(l&(1ll<<j))==0) j--; 
	int k=j;
	while (k>=0) c=c|(1ll<<k),k--;
	if (i-j==1) {
		b=l;
		while ((b==c||b==a)) b++;
	} 
	else {
		for (i-=1;i>j;i--) b=b|(1ll<<i);
	}
	printf("%lld %lld %lld\n",a,b,c);
}
int main(){
	int t;
	scanf("%d",&t);
	while (t--){
		solve();
	}
}
Problem: 2057C - Trip to the Olympiad
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;
void solve(){
	ll l,r;
	scanf("%lld%lld",&l,&r);
	if (r-l==2) {
		printf("%d %d %d\n",l,l+1,r);
		return;
	}
	ll i=31,tmp=0;
	while (i>=0&&(l&(1ll<<i))==(r&(1ll<<i))) tmp=tmp|(r&(1ll<<i)),i--;
	ll a=tmp,b=tmp,c=tmp;
	a=a|(r&(1ll<<i));
	ll j=i;
	while (j>=0&&(l&(1ll<<j))==0) j--; 
	if (i-j==1) b=b|(1ll<<j); 
	for (i-=1;i>j;i--) b=b|(1ll<<i);
	while (j>=0) c=c|(1ll<<j),j--;
	printf("%lld %lld %lld\n",a,b,c);
}
int main(){
	int t;
	scanf("%d",&t);
	while (t--){
		solve();
	}
}


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
#define ll long long
using namespace std;
void solve(){
	ll l,r;
	scanf("%lld%lld",&l,&r);
	if (r-l==2) {
		printf("%d %d %d\n",l,l+1,r);
		return;
	}
	ll i=31,tmp=0;
	while (i>=0&&(l&(1ll<<i))==(r&(1ll<<i))) tmp=tmp|(r&(1ll<<i)),i--;
	ll a=tmp,b=tmp,c=tmp;
	a=a|(r&(1ll<<i));
	ll j=i;
	while (j>=0&&(l&(1ll<<j))==0) j--; 
	if (i-j==1) b=r; 
	for (i-=1;i>j;i--) b=b|(1ll<<i);
	while (j>=0) c=c|(1ll<<j),j--;
	printf("%lld %lld %lld\n",a,b,c);
}
int main(){
	int t;
	scanf("%d",&t);
	while (t--){
		solve();
	}
}
Problem: 2063C - Remove Exactly Two
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;
const int N=2e5+5;
int d[N];
vector<int> mp[N];
pair<int,int> a[N];
void solve(){
	int n;
	scanf("%d",&n);
	for (int i=1;i<n;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		d[x]++,d[y]++;
		mp[x].push_back(y);
		mp[y].push_back(x);
	}
	for (int i=1;i<=n;i++){
		a[i]={d[i],i};
	}
	sort(a+1,a+n+1);
	int ans=a[n].first,x=a[n].second;
	for (int i=0;i<mp[x].size();i++){
		int y=mp[x][i];
		d[y]--;
	}
	d[x]=-1;
	for (int i=1;i<=n;i++){
		a[i]={d[i],i};
		d[i]=0;
	}
	sort(a+1,a+n+1);
	printf("%d\n",ans+a[n].first-1);
}
int main()
{
	int t;
	scanf("%d",&t);
	while (t--){
		solve();
	}
}


Submission (verdict: Wrong answer on test 4):
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N=2e5+5;
int d[N];
vector<int> mp[N];
pair<int,int> a[N];
void solve(){
	int n;
	scanf("%d",&n);
	for (int i=1;i<n;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		d[x]++,d[y]++;
		mp[x].push_back(y);
		mp[y].push_back(x);
	}
	for (int i=1;i<=n;i++){
		a[i]={d[i],i};
	}
	sort(a+1,a+n+1);
	int ans=a[n].first,x=a[n].second;
	for (int i=0;i<mp[x].size();i++){
		int y=mp[x][i];
		d[y]--;
	}
	d[x]=-1;
	for (int i=1;i<=n;i++){
		a[i]={d[i],i};
		d[i]=0;
		mp[i].clear();
	}
	sort(a+1,a+n+1);
	printf("%d\n",ans+a[n].first-1);
}
int main()
{
	int t;
	scanf("%d",&t);
	while (t--){
		solve();
	}
}
Problem: 2063C - Remove Exactly Two
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 4):
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N=2e5+5;
int d[N];
vector<int> mp[N];
pair<int,int> a[N];
void solve(){
	int n;
	scanf("%d",&n);
	for (int i=1;i<n;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		d[x]++,d[y]++;
		mp[x].push_back(y);
		mp[y].push_back(x);
	}
	for (int i=1;i<=n;i++){
		a[i]={d[i],i};
	}
	sort(a+1,a+n+1);
	int ans=a[n].first,x=a[n].second;
	for (int i=0;i<mp[x].size();i++){
		int y=mp[x][i];
		d[y]--;
	}
	d[x]=-1;
	for (int i=1;i<=n;i++){
		a[i]={d[i],i};
		d[i]=0;
		mp[i].clear();
	}
	sort(a+1,a+n+1);
	printf("%d\n",ans+a[n].first-1);
}
int main()
{
	int t;
	scanf("%d",&t);
	while (t--){
		solve();
	}
}


Submission (verdict: Accepted):
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N=2e5+5;
int d[N];
map<pair<int,int>,int> mp;
pair<int,int> a[N];
void solve(){
	int n;
	scanf("%d",&n);
	for (int i=1;i<=n;i++) d[i]=0;
	for (int i=1;i<n;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		d[x]++,d[y]++;
		mp[{x,y}]=1;
		mp[{y,x}]=1;
	}
	for (int i=1;i<=n;i++){
		a[i]={d[i],i};
	}
	sort(a+1,a+n+1);
	int ans=0;
	for (int i=n;i>=n-1;i--){
		for (int j=i-1;j>=1;j--){
			ans=max(ans,a[i].first+a[j].first-mp[{a[i].second,a[j].second}]-1);
		}
	}
	mp.clear();
	printf("%d\n",ans);
}
int main()
{
	int t;
	scanf("%d",&t);
	while (t--){
		solve();
	}
}
Problem: 2063C - Remove Exactly Two
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N=2e5+5;
int d[N];
vector<int> mp[N];
pair<int,int> a[N];
void solve(){
	int n;
	scanf("%d",&n);
	for (int i=1;i<n;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		d[x]++,d[y]++;
		mp[x].push_back(y);
		mp[y].push_back(x);
	}
	for (int i=1;i<=n;i++){
		a[i]={d[i],i};
	}
	sort(a+1,a+n+1);
	int ans=a[n].first,x=a[n].second;
	for (int i=0;i<mp[x].size();i++){
		int y=mp[x][i];
		d[y]--;
	}
	d[x]=-1;
	for (int i=1;i<=n;i++){
		a[i]={d[i],i};
		d[i]=0;
	}
	sort(a+1,a+n+1);
	printf("%d\n",ans+a[n].first-1);
}
int main()
{
	int t;
	scanf("%d",&t);
	while (t--){
		solve();
	}
}
Problem: 2057B - Gorilla and the Exam
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Time limit exceeded on test 2):
#include<bits/stdc++.h>
using namespace std;
const int N=1e7;
using ll=long long;
using PII=pair<int,int>;

void so() {
	vector<int> a(N),ans;
	map<ll,ll> ma;
	int n,k;cin>>n>>k;
	for(int i=1;i<=n;i++) {
		cin>>a[i];
		ma[a[i]]++;
	}
	int res=ma.size();
	for(auto x:ma) {
		ans.push_back(x.second);
	}
	sort(ans.begin(),ans.end());
	auto ed=ans.end()-1;
	for(auto x:ans) {
		k-=x;(*ed)+=x;ed--;
		if(k>=0) {
			res--;
		} else break;
	}
	cout<<res<<endl;
	
}

int main() {
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	int t;cin>>t;
	while(t--) so();
	
	
	return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Time limit exceeded on test 2):
#include<bits/stdc++.h>
using namespace std;
const int N=1e7;
using ll=long long;
using PII=pair<int,int>;

void so() {
	vector<int> a(N),ans;
	map<ll,ll> ma;
	int n,k;cin>>n>>k;
	for(int i=1;i<=n;i++) {
		cin>>a[i];
		ma[a[i]]++;
	}
	int res=ma.size();
	for(auto x:ma) {
		ans.push_back(x.second);
	}
	sort(ans.begin(),ans.end());
	//别乱用auto
	for(int i=0;i<ans.size()-1;i++) {
		if(k>=ans[i]) {
			k-=ans[i];
			res--;
			if(res==1) break;
		} else break;
	}
	
	cout<<res<<endl;
	
}

int main() {
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	int t;cin>>t;
	while(t--) so();
	
	
	return 0;
}

Submission (verdict: Accepted):
#include<bits/stdc++.h>
using namespace std;
const int N=1e7;
using ll=long long;
using PII=pair<int,int>;

void so() {
	vector<int> ans;
	map<ll,ll> ma;
	int n,k;cin>>n>>k;
	for(int i=1;i<=n;i++) {
		int a;
		cin>>a;
		ma[a]++;
	}
	int res=ma.size();//这一步的问题？？？
	for(auto x:ma) {
		ans.push_back(x.second);
	}
	sort(ans.begin(),ans.end());
	//别乱用auto
	for(int i=0;i<(int)ans.size()-1;i++) {
		if(k>=ans[i]) {
			k-=ans[i];
			res--;
			if(res==1) break;
		} else break;
	}
	
	cout<<res<<endl;
	
}

int main() {
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	int t;cin>>t;
	while(t--) so();
	
	
	return 0;
}
Problem: 2057B - Gorilla and the Exam
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Time limit exceeded on test 2):
#include<bits/stdc++.h>
using namespace std;
const int N=1e7;
using ll=long long;
using PII=pair<int,int>;

void so() {
	vector<int> a(N),ans;
	map<ll,ll> ma;
	int n,k;cin>>n>>k;
	for(int i=1;i<=n;i++) {
		cin>>a[i];
		ma[a[i]]++;
	}
	int res=ma.size();
	for(auto x:ma) {
		ans.push_back(x.second);
	}
	sort(ans.begin(),ans.end());
	auto ed=ans.end()-1;
	for(auto x:ans) {
		k-=x;(*ed)+=x;ed--;
		if(k>=0) {
			res--;
		} else break;
	}
	cout<<res<<endl;
	
}

int main() {
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	int t;cin>>t;
	while(t--) so();
	
	
	return 0;
}

Submission (verdict: Time limit exceeded on test 2):
#include<bits/stdc++.h>
using namespace std;
const int N=1e7;
using ll=long long;
using PII=pair<int,int>;

void so() {
	vector<int> a(N),ans;
	map<ll,ll> ma;
	int n,k;cin>>n>>k;
	for(int i=1;i<=n;i++) {
		cin>>a[i];
		ma[a[i]]++;
	}
	int res=ma.size();
	for(auto x:ma) {
		ans.push_back(x.second);
	}
	sort(ans.begin(),ans.end());
	//别乱用auto
	for(int i=0;i<ans.size()-1;i++) {
		if(k>=ans[i]) {
			k-=ans[i];
			res--;
			if(res==1) break;
		} else break;
	}
	
	cout<<res<<endl;
	
}

int main() {
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	int t;cin>>t;
	while(t--) so();
	
	
	return 0;
}
Problem: 2061D - Kevin and Numbers
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
#define MAXN 200010
#define int long long 
#define INF 2147483647
#define MOD 998244353

using namespace std;

signed main()
{
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    int tt=1;
    cin >> tt;
    while(tt--)
    {
        int n,m;
        int sum=0;
        multiset<int> a,b,c;
        
        cin >> n >> m;
        for(int i = 1;i <= n;i++)
        {
            int x;
            cin >> x;
            a.insert(x);
        }
        for(int i = 1;i <= m;i++)
        {
            int x;
            cin >> x;
            b.insert(x);
            sum+=x;
        }
        if(sum>MAXN)
        {
            cout << "No\n";
            continue;
        }


        bool end=false;
        while(!a.empty() && !end)
        {
            end=true;
            c.clear();
            for(auto x : b)
            {
                c.insert(x);
            }
            for(auto x : b)
            {
                if(x!=1)
                {
                    end=false;
                }
                if(a.find(x)!=a.end())
                {
                    c.erase(c.find(x));
                    a.erase(a.find(x));
                    //cout << x << " is dised.\n";
                }else
                {                    
                    if(x==1)
                    {
                        continue;
                    }
                    c.erase(c.find(x));
                    c.insert((x+1)>>1);
                    c.insert(x>>1);
                }
            }
            b.clear();
            for(auto x : c)
            {
                b.insert(x);
            }    
            /*for(auto x : b)
            {
                cout << x << ' ';
            }    
            cout << '\n';*/
        }

        if(!b.empty() ||!a.empty() )
        {
            cout << "No\n";
        }else
        {
            cout << "Yes\n";
        }
        
        
    }
	return 0;
}
/*
001 001 011 011
011 101

  
a<<1|1
a<<1

拆

3 5
->1 1 3 3

3 5
->3 2 3

gredy

3 5



*/
Problem: 2050E - Three Strings
Language: C++17 (GCC 7-32)


Submission (verdict: Time limit exceeded on test 6):
#include <iostream>
#include <cstring>
#include <algorithm>

using namespace std;
struct node {
	char ch;
	node* next;
};
const int maxsize = 1e3 + 7;
char a[maxsize], b[maxsize], c[maxsize * 2];
int lena, lenb, lenc;
node* s;
int ans;
int check() {
	node* cur = s->next;
	int pos = 0;
	int cnt = 0;
	while (cur != NULL) {
		if (cur->ch != c[pos++]) cnt++;
		cur = cur->next;
	}
	return cnt;
}
void init() {
	s = (node*)malloc(sizeof(node)); 
	s->next = NULL;
	node* pos;
	node* cur = s;
	for (int i = 0; i < lena; i++) {
		pos = (node*)malloc(sizeof(node));
		pos->ch = a[i];
		pos->next = NULL;
		cur->next = pos;
		cur = pos;
	}
}
void dfs(int pos,node* cur) {
	// only can we insert b[pos] into the position which after cur;
	// if all the string is inserted,teh string c has been finished
	if (pos == lenb) {
		int change_count = check();
		if (ans == -1 || ans > change_count) ans = change_count;
		return;
	}
	// only can insert node after point
	if (cur->next == NULL) {
		node* point = (node*)malloc(sizeof(node));
		point->ch = b[pos];
		point->next = NULL;
		cur->next = point;
		dfs(pos + 1, point);
		free(point);
		cur->next = NULL;
	}
	else {
		// do not insert
		dfs(pos, cur->next);
		// insert
		node* point = (node*)malloc(sizeof(node));
		point->ch = b[pos];
		point->next = cur->next;
		cur->next = point;
		dfs(pos + 1, point);
		cur->next = point->next;
		free(point);
	}
}
int main()
{
	int T;
	scanf("%d", &T);
	while (T--) {
		scanf("%s%s%s", a, b, c);
		lena = strlen(a); lenb = strlen(b); lenc = strlen(c);
		ans = -1;
		init();
		dfs(0,s);
		printf("%d\n", ans);
	}
	return 0;
}
Problem: 2050E - Three Strings
Language: C++17 (GCC 7-32)

Previous submission (verdict: Time limit exceeded on test 6):

#include <iostream>
#include <cstring>
#include <algorithm>

using namespace std;
struct node {
	char ch;
	node* next;
};
const int maxsize = 1e3 + 7;
char a[maxsize], b[maxsize], c[maxsize * 2];
int lena, lenb, lenc;
node* s;
int ans;
int check() {
	node* cur = s->next;
	int pos = 0;
	int cnt = 0;
	while (cur != NULL) {
		if (cur->ch != c[pos++]) cnt++;
		cur = cur->next;
	}
	return cnt;
}
void init() {
	s = (node*)malloc(sizeof(node)); 
	s->next = NULL;
	node* pos;
	node* cur = s;
	for (int i = 0; i < lena; i++) {
		pos = (node*)malloc(sizeof(node));
		pos->ch = a[i];
		pos->next = NULL;
		cur->next = pos;
		cur = pos;
	}
}
void dfs(int pos, node* cur,int c_pos, int error_cnt) {
	// only can we insert b[pos] into the position which after cur;
	// if all the string is inserted,teh string c has been finished
	if (pos == lenb) {
		node* tmp = cur->next;
		while (tmp != NULL) {
			if (tmp->ch != c[c_pos]) error_cnt++;
			tmp = tmp->next; c_pos++;
		}
		if (ans > error_cnt) ans = error_cnt;
		return;
	}
	if (error_cnt >= ans) return;
	// only can insert node after point
	if (cur->next == NULL) {
		node* point = (node*)malloc(sizeof(node));
		point->ch = b[pos];
		point->next = NULL;
		cur->next = point;
		if (b[pos] != c[c_pos]) dfs(pos + 1, point, c_pos + 1, error_cnt + 1);
		else dfs(pos + 1, point, c_pos + 1, error_cnt);
		free(point);
		cur->next = NULL;
	}
	else {
		// do not insert
		if (cur->next->ch != c[c_pos]) dfs(pos, cur->next, c_pos + 1, error_cnt + 1);
		else dfs(pos, cur->next, c_pos + 1, error_cnt);
		// insert
		node* point = (node*)malloc(sizeof(node));
		point->ch = b[pos];
		point->next = cur->next;
		cur->next = point;
		if (b[pos] != c[c_pos]) dfs(pos + 1, point, c_pos + 1, error_cnt + 1);
		else dfs(pos + 1, point, c_pos + 1, error_cnt);
		cur->next = point->next;
		free(point);
	}
}
int main()
{
	int T;
	scanf("%d", &T);
	while (T--) {
		scanf("%s%s%s", a, b, c);
		lena = strlen(a); lenb = strlen(b); lenc = strlen(c);
		ans = maxsize * 2;
		if (lena < lenb) {
			swap(a, b);
			swap(lena, lenb);
		}
		init();
		dfs(0, s, 0, 0);
		printf("%d\n", ans);
	}
	return 0;
}


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

using namespace std;
const int maxsize = 1e3 + 7;
char a[maxsize], b[maxsize], c[maxsize * 2];
int lena, lenb, lenc;
int dp[maxsize * 2][maxsize];
int main()
{
	int T;
	scanf("%d", &T);
	while (T--) {
		scanf("%s%s%s", a, b, c);
		lena = strlen(a); lenb = strlen(b); lenc = strlen(c);
		fill(dp[0], dp[0] + maxsize * maxsize * 2, maxsize * 2);
		for (int i = 0; i < maxsize; i++) dp[0][i] = 0;
		for (int i = 1; i <= lenc; i++) {
			for (int j = 0; j <= lena; j++) {
				if ((i - j) < 0 || (i - j) > lenb) continue;
				if (i - j - 1 >= 0) dp[i][j] = min(dp[i][j], dp[i - 1][j] + (c[i - 1] == b[i - j - 1] ? 0 : 1));
				if (j - 1 >= 0) dp[i][j] = min(dp[i][j], dp[i - 1][j - 1] + (a[j - 1] == c[i - 1] ? 0 : 1));
			}
		}
		printf("%d\n", dp[lenc][lena]);
	}
	return 0;
}
Problem: 2063B - Subsequence Update
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 2):
#include <iostream>
#include <queue>
using namespace std;

// priority_queue<int, vector<int>, greater<int> > q;
priority_queue<int> q;

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

    int testcases;
    cin >> testcases;
    while (testcases--) {
      int n, l, r;
      cin >> n >> l >> r;

      for (int i = 0; i < n; i++) {
        int tmp;
        cin >> tmp;
        if (q.size() < r - l + 1) { q.push(tmp); }
        else if (q.top() > tmp) { q.pop(); q.push(tmp); }
      }

      int sum = 0;
      while (q.empty() == false) {
        sum += q.top();
        q.pop();
      }
      cout << sum << endl;
    }

    return 0;
}

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

// priority_queue<int, vector<int>, greater<int> > q;
priority_queue<int> q1;
priority_queue<int> q2;

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

    int testcases;
    cin >> testcases;
    while (testcases--) {
      int n, l, r;
      cin >> n >> l >> r;

      for (int i = 0; i < n; i++) {
        int tmp;
        cin >> tmp;
        if (i < r)
        {
          if (q1.size() < r - l + 1) { q1.push(tmp); }
          else if (q1.top() > tmp) { q1.pop(); q1.push(tmp); }
        }
        if (i >= l-1)
        {
          if (q2.size() < r - l + 1) { q2.push(tmp); }
          else if (q2.top() > tmp) { q2.pop(); q2.push(tmp); }
        }
      }

      int sum1 = 0;
      while (q1.empty() == false) {
        sum1 += q1.top();
        q1.pop();
      }
      int sum2 = 0;
      while (q2.empty() == false)
      {
        sum2 += q2.top();
        q2.pop();
      }
      int sum = (sum1 < sum2) ? sum1 : sum2;
      cout << sum << endl;
    }

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


Submission (verdict: Wrong answer on test 2):
#include <iostream>
#include <queue>
using namespace std;

// priority_queue<int, vector<int>, greater<int> > q;
priority_queue<int> q;

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

    int testcases;
    cin >> testcases;
    while (testcases--) {
      int n, l, r;
      cin >> n >> l >> r;

      for (int i = 0; i < n; i++) {
        int tmp;
        cin >> tmp;
        if (q.size() < r - l + 1) { q.push(tmp); }
        else if (q.top() > tmp) { q.pop(); q.push(tmp); }
      }

      int sum = 0;
      while (q.empty() == false) {
        sum += q.top();
        q.pop();
      }
      cout << sum << endl;
    }

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

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

// priority_queue<int, vector<int>, greater<int> > q;
priority_queue<int> q1;
priority_queue<int> q2;

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

    int testcases;
    cin >> testcases;
    while (testcases--) {
      int n, l, r;
      cin >> n >> l >> r;

      for (int i = 0; i < n; i++) {
        int tmp;
        cin >> tmp;
        if (i < r)
        {
          if (q1.size() < r - l + 1) { q1.push(tmp); }
          else if (q1.top() > tmp) { q1.pop(); q1.push(tmp); }
        }
        if (i >= l-1)
        {
          if (q2.size() < r - l + 1) { q2.push(tmp); }
          else if (q2.top() > tmp) { q2.pop(); q2.push(tmp); }
        }
      }

      int sum1 = 0;
      while (q1.empty() == false) {
        sum1 += q1.top();
        q1.pop();
      }
      int sum2 = 0;
      while (q2.empty() == false)
      {
        sum2 += q2.top();
        q2.pop();
      }
      int sum = (sum1 < sum2) ? sum1 : sum2;
      cout << sum << endl;
    }

    return 0;
}

Submission (verdict: Accepted):
#include <iostream>
#include <queue>
using namespace std;

typedef long long ll;

// priority_queue<int, vector<int>, greater<int> > q;
priority_queue<ll> q1;
priority_queue<ll> q2;

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

    int testcases;
    cin >> testcases;
    while (testcases--) {
      ll n, l, r;
      cin >> n >> l >> r;

      for (ll i = 0; i < n; i++) {
        ll tmp;
        cin >> tmp;
        if (i < r)
        {
          if (q1.size() < r - l + 1) { q1.push(tmp); }
          else if (q1.top() > tmp) { q1.pop(); q1.push(tmp); }
        }
        if (i >= l-1)
        {
          if (q2.size() < r - l + 1) { q2.push(tmp); }
          else if (q2.top() > tmp) { q2.pop(); q2.push(tmp); }
        }
      }

      ll sum1 = 0;
      while (q1.empty() == false) {
        sum1 += q1.top();
        q1.pop();
      }
      ll sum2 = 0;
      while (q2.empty() == false)
      {
        sum2 += q2.top();
        q2.pop();
      }
      ll sum = (sum1 < sum2) ? sum1 : sum2;
      cout << sum << endl;
    }

    return 0;
}