ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2063C - Remove Exactly Two
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 2):
#pragma GCC optimize("Ofast")
#pragma GCC optimize("O3,unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define f0r(i, n) for (int i = 0; i < (n); ++i)
#define fnr(i, n, k) for (int i = (n); i < (k); ++i)
#define ctn(x) cout << x << '\n'
#define ctl(lst)                          \
  for (auto &a : (lst)) cout << a << ' '; \
  cout << endl;
#define pb push_back
#define F first
#define S second
#define all(v) (v).begin(), (v).end()
#define ub(v, x) (upper_bound(all(v), x) - begin(v))
#define lb(v, x) (lower_bound(all(v), x) - begin(v))
#define sz(v) (v).size()

using namespace std;
template <class T>
using V = vector<T>;
using ll = long long;
using vi = V<int>;
using pi = pair<int, int>;
using Adj = V<vi>;


signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

	int T;
	cin >> T;
	while (T--) {
		int N, u, v;
		cin >> N;
		vi deg(N);
		Adj adj(N);
		f0r(i, N-1) {
			cin >> u >> v;
			adj[--u].pb(--v);
			adj[v].pb(u);
			deg[u]++, deg[v]++;
		}
		int comps = 1;
		auto mx1 = max_element(all(deg));
		comps += *mx1 - 1;
		for (auto &c: adj[mx1-begin(deg)]) deg[c]--;
		*mx1 = 0;
		mx1 = max_element(all(deg));
		comps += *mx1 - 1;
		ctn(comps);
	}
}
Problem: 2063C - Remove Exactly Two
Language: C++17 (GCC 7-32)

Previous submission (verdict: Compilation error):
#pragma GCC optimize("Ofast")
#pragma GCC optimize("O3,unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define f0r(i, n) for (int i = 0; i < (n); ++i)
#define fnr(i, n, k) for (int i = (n); i < (k); ++i)
#define ctn(x) cout << x << '\n'
#define ctl(lst)                          \
  for (auto &a : (lst)) cout << a << ' '; \
  cout << endl;
#define pb push_back
#define F first
#define S second
#define all(v) (v).begin(), (v).end()
#define ub(v, x) (upper_bound(all(v), x) - begin(v))
#define lb(v, x) (lower_bound(all(v), x) - begin(v))
#define sz(v) (v).size()

using namespace std;
template <class T>
using V = vector<T>;
using ll = long long;
using vi = V<int>;
using pi = pair<int, int>;
using Adj = V<vi>;


signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

	int T;
	cin >> T;
	while (T--) {
		int N, u, v;
		cin >> N;
		vi deg(N);
		Adj adj(N);
		f0r(i, N-1) {
			cin >> u >> v;
			adj[--u].pb(--v);
			adj[v].pb(u);
			deg[u]++, deg[v]++;
		}
		int comps = 1;
		auto mx1 = max_element(all(deg));
		comps += *mx1 - 1;
		for (auto &c: adj[mx1-begin(deg)]) deg[c]--;
		*mx1 = 0;
		mx1 = max_element(all(deg));
		ctn(comps += *mx1 - 1);
	}
}


Submission (verdict: Wrong answer on test 2):
#pragma GCC optimize("Ofast")
#pragma GCC optimize("O3,unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define f0r(i, n) for (int i = 0; i < (n); ++i)
#define fnr(i, n, k) for (int i = (n); i < (k); ++i)
#define ctn(x) cout << x << '\n'
#define ctl(lst)                          \
  for (auto &a : (lst)) cout << a << ' '; \
  cout << endl;
#define pb push_back
#define F first
#define S second
#define all(v) (v).begin(), (v).end()
#define ub(v, x) (upper_bound(all(v), x) - begin(v))
#define lb(v, x) (lower_bound(all(v), x) - begin(v))
#define sz(v) (v).size()

using namespace std;
template <class T>
using V = vector<T>;
using ll = long long;
using vi = V<int>;
using pi = pair<int, int>;
using Adj = V<vi>;


signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

	int T;
	cin >> T;
	while (T--) {
		int N, u, v;
		cin >> N;
		vi deg(N);
		Adj adj(N);
		f0r(i, N-1) {
			cin >> u >> v;
			adj[--u].pb(--v);
			adj[v].pb(u);
			deg[u]++, deg[v]++;
		}
		int comps = 1;
		auto mx1 = max_element(all(deg));
		comps += *mx1 - 1;
		for (auto &c: adj[mx1-begin(deg)]) deg[c]--;
		*mx1 = 0;
		mx1 = max_element(all(deg));
		ctn((comps += *mx1 - 1));
	}
}
Problem: 2061D - Kevin and Numbers
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 3):
// Problem: D. Kevin and Numbers
// Contest: Codeforces - IAEPC Preliminary Contest (Codeforces Round 999, Div. 1 + Div. 2)
// URL: https://codeforces.com/contest/2061/problem/D
// Memory Limit: 256 MB
// Time Limit: 2000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

//#pragma GCC optimize("O3")
//#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>
#define Begin ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define pii pair<int, int>
#define pdd pair<double, double>
#define lowbit(x) (x & -x)
#define all(x) x.begin(), x.end()

#define Rep(i, x) for(auto &i : x)
#define L(i, x, y) for(int i = x; i <= y; ++ i)
#define R(i, x, y) for(int i = x; i >= y; -- i)
#define rd(x) scanf("%lld", &(x))
#define p_b push_back
using namespace std;
template <class T> using vc = vector<T>;
template <class T> using _pq = priority_queue<T, vector<T>, greater<T>>;
using i64 = long long;
using u64 = unsigned long long;
using u32 = unsigned;
const int N = 2e5 + 10;


































void solve() {
	int n, m; cin >> n >> m;
	vc<int> a(n), b(m);
	map<int, int> mp1, mp2;
	L(i, 0, n - 1) {
		cin >> a[i];
		mp1[a[i]] ++;
	}
	L(i, 0, m - 1) {
		cin >> b[i];
		mp2[b[i]] ++;
		auto it = mp1.find(b[i]);
		if(it != mp1.end()) {
			mp1[b[i]] --;
			mp2[b[i]] --;
		}
	}
	sort(a.begin(), a.end()), sort(b.begin(), b.end());
	i64 s1 = reduce(a.begin(), a.end()), s2 = reduce(b.begin(), b.end());
	if(s1 != s2) {
		cout << "No\n";
		return;
	}
	vc<int> dkkk;
	for(auto &[x1, y1] : mp1) {
		if(y1 == 0) continue;
		else {
			L(i, 0, y1 - 1) dkkk.p_b(x1);
		}
	}
	if(dkkk.empty()) {
		cout << "Yes\n";
		return;
	}
	int sum = dkkk.front();
	L(i, 1, int(dkkk.size()) - 1) {
		if(sum == 0) sum += dkkk[i];
		if(abs(dkkk[i] - sum) <= 1 && sum != 0) sum += dkkk[i];
		auto it = mp2.find(sum);
		if(it != mp2.end() && it->second > 0) {

			sum = 0;
			it->second --;
		}
	}
	int ok = 1;
	for(auto [x2, y2] : mp2) {
		if(y2 > 0) ok = 0;
	}
	if(ok) cout << "Yes\n";
	else cout << "No\n";
}


int main() {
	Begin;
	int _; _ = 1;
	cin >> _;
	while(_--) solve();
	return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
#define int long long
using namespace std;
typedef pair<int,int> PII;
const int N=2e6+10,M=13010;
const int INF=1e18;
// const int mod=998244353;
const int mod=1e9+7;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); 
void solve(){   
    int l,r;
    cin>>l>>r;
    int x=0;
    while(1ll<<x<=r)x++;
    x--;
    int ans=0;
    for(int i=x;i>=0;i--){
        if((1ll<<i)-2<l){
            l-=1ll<<i;
            r-=1ll<<i;
            ans+=1ll<<i;
            continue;
        }
        if(1ll<<i>r)continue;
        int y=ans+(1ll<<i);
        // cout<<l<<" "<<r<<" "<<ans<<"\n";
        cout<<y<<" "<<y-1<<" "<<y-2<<"\n";
        return;
    }
}
signed main(){
    cin.tie(0)->sync_with_stdio(0);
    int T=1;
    cin>>T;
    while(T--)solve();
    return 0;
}


Submission (verdict: Accepted):
#include<bits/stdc++.h>
#define int long long
using namespace std;
typedef pair<int,int> PII;
const int N=2e6+10,M=13010;
const int INF=1e18;
// const int mod=998244353;
const int mod=1e9+7;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); 
void solve(){   
    int l,r;
    cin>>l>>r;
    int x=0;
    while(1ll<<x<=r)x++;
    x--;
    int ans=0;
    for(int i=x;i>=0;i--){
        if((1ll<<i)<=l){
            l-=1ll<<i;
            r-=1ll<<i;
            ans+=1ll<<i;
            continue;
        }
        if(1ll<<i>r)continue;
        int y=ans+(1ll<<i);
        if((1ll<<i)==r){
            cout<<y<<" "<<y-1<<" "<<y-2<<"\n";
        }
        else cout<<y+1<<" "<<y<<" "<<y-1<<"\n";
        return;
    }
}
signed main(){
    cin.tie(0)->sync_with_stdio(0);
    int T=1;
    cin>>T;
    while(T--)solve();
    return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
#define int long long
using namespace std;
typedef pair<int,int> PII;
const int N=2e6+10,M=13010;
const int INF=1e18;
// const int mod=998244353;
const int mod=1e9+7;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); 
void solve(){   
    int l,r;
    cin>>l>>r;
    int x=0;
    while(1ll<<x<=r)x++;
    x--;
    cout<<(1ll<<x)<<" "<<(1ll<<x)<<" "<<(1ll<<x)-1<<"\n";
}
signed main(){
    cin.tie(0)->sync_with_stdio(0);
    int T=1;
    cin>>T;
    while(T--)solve();
    return 0;
}


Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
#define int long long
using namespace std;
typedef pair<int,int> PII;
const int N=2e6+10,M=13010;
const int INF=1e18;
// const int mod=998244353;
const int mod=1e9+7;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); 
void solve(){   
    int l,r;
    cin>>l>>r;
    int x=0;
    while(1ll<<x<=r)x++;
    x--;
    int ans=0;
    for(int i=x;i>=0;i--){
        if((1ll<<i)-2<l){
            l-=1ll<<i;
            r-=1ll<<i;
            ans+=1ll<<i;
            continue;
        }
        if(1ll<<i>r)continue;
        int y=ans+(1ll<<i);
        // cout<<l<<" "<<r<<" "<<ans<<"\n";
        cout<<y<<" "<<y-1<<" "<<y-2<<"\n";
        return;
    }
}
signed main(){
    cin.tie(0)->sync_with_stdio(0);
    int T=1;
    cin>>T;
    while(T--)solve();
    return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 1):
#include<bits/stdc++.h>
#define int long long
using namespace std;
typedef pair<int,int> PII;
const int N=2e6+10,M=13010;
const int INF=1e18;
// const int mod=998244353;
const int mod=1e9+7;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); 
void solve(){   
    int l,r;
    cin>>l>>r;
    int x=0;
    while(1ll<<x<=r)x++;
    x--;
    cout<<(1ll<<x)<<" "<<(1ll<<x)<<" "<<(1ll<<x)-1<<"\n";
}
signed main(){
    cin.tie(0)->sync_with_stdio(0);
    int T=1;
    cin>>T;
    while(T--)solve();
    return 0;
}
Problem: 2049C - MEX Cycle
Language: C++20 (GCC 13-64)

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

using namespace std;

typedef long long ll;

#define endl "\n";

const int N = 2e5 + 5;



int main() {

	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	ll _; cin >> _;

	while (_--) {

		ll n, x, y; cin >> n >> x >> y;

		--x, --y;

		vector<ll> a(n);

		if (n & 1) {

			a[x] = 2;

			for (int i = 1; i < n; ++i) a[(x + i) % n] = i & 1;

		}

		else {

			if (x != y) for (int i = 0; i < n; ++i) a[i] = i & 1;

			else {

				a[x] = 2;

				for (int i = 1; i < n; ++i) a[(x + i) % n] = i & 1;

			}

		}

		for (int i = 0; i < n; ++i) cout << a[i] << " ";

		cout << endl;

	}

	return 0;

}





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

using namespace std;

typedef long long ll;

#define endl "\n";

const int N = 2e5 + 5;



int main() {

	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	ll _; cin >> _;

	while (_--) {

		ll n, x, y; cin >> n >> x >> y;

		--x, --y;

		vector<ll> a(n);

		if (n & 1) {

			a[x] = 2;

			for (int i = 1; i < n; ++i) a[(x + i) % n] = i & 1;

		}

		else {

			if ((x ^ y) & 1) for (int i = 0; i < n; ++i) a[i] = i & 1;

			else {

				a[x] = 2;

				for (int i = 1; i < n; ++i) a[(x + i) % n] = i & 1;

			}

		}

		for (int i = 0; i < n; ++i) cout << a[i] << " ";

		cout << endl;

	}

	return 0;

}
Problem: 2049C - MEX Cycle
Language: C++20 (GCC 13-64)


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

using namespace std;

typedef long long ll;

#define endl "\n";

const int N = 2e5 + 5;

ll a[N];



int main() {

	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	ll _; cin >> _;

	while (_--) {

		ll n, x, y; cin >> n >> x >> y;

		if (n & 1) {

			a[x] = 2;

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

				a[(x + i) % n] = i & 1;

			}

		}

		else {

			if (x != y) for (int i = 0; i < n; ++i) a[i] = i & 1;

			else {

				a[x] = 2;

				for (int i = 1; i < n; ++i) a[(x + i) % n] = i & 1;

			}

		}

		for (int i = 0; i < n; ++i) cout << a[i] << " ";

		cout << endl;

	}

	return 0;

}
Problem: 2049C - MEX Cycle
Language: C++20 (GCC 13-64)

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

using namespace std;

typedef long long ll;

#define endl "\n";

const int N = 2e5 + 5;

ll a[N];



int main() {

	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	ll _; cin >> _;

	while (_--) {

		ll n, x, y; cin >> n >> x >> y;

		if (n & 1) {

			a[x] = 2;

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

				a[(x + i) % n] = i & 1;

			}

		}

		else {

			if (x != y) for (int i = 0; i < n; ++i) a[i] = i & 1;

			else {

				a[x] = 2;

				for (int i = 1; i < n; ++i) a[(x + i) % n] = i & 1;

			}

		}

		for (int i = 0; i < n; ++i) cout << a[i] << " ";

		cout << endl;

	}

	return 0;

}





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

using namespace std;

typedef long long ll;

#define endl "\n";

const int N = 2e5 + 5;



int main() {

	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	ll _; cin >> _;

	while (_--) {

		ll n, x, y; cin >> n >> x >> y;

		--x, --y;

		vector<ll> a(n);

		if (n & 1) {

			a[x] = 2;

			for (int i = 1; i < n; ++i) a[(x + i) % n] = i & 1;

		}

		else {

			if (x != y) for (int i = 0; i < n; ++i) a[i] = i & 1;

			else {

				a[x] = 2;

				for (int i = 1; i < n; ++i) a[(x + i) % n] = i & 1;

			}

		}

		for (int i = 0; i < n; ++i) cout << a[i] << " ";

		cout << endl;

	}

	return 0;

}
Problem: 2063C - Remove Exactly Two
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 3):
#include<iostream>
#include<algorithm>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<set>
#include<cmath>
#include<queue>
using namespace std;
typedef long long LL;

const int N=2e5+10;
int d[N];
vector<int>g[N];
int cnt[N];
void solve()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        d[i]=0;
        cnt[i]=0;
        g[i].clear();
    }
    int mx1=0;
    int mx2=0;
    for(int i=1;i<=n-1;i++)
    {
        int u,v;
        cin>>u>>v;
        g[u].push_back(v);
        g[v].push_back(u);
        d[u]++;
        d[v]++;
    }
    for(int i=1;i<=n;i++)
    {
        cnt[d[i]]++;
        if(d[i]>mx1)
        {
            mx2=mx1;
            mx1=d[i];
        }
        else if(d[i]>mx2)
        {
            mx2=d[i];
        }
    }
   
    for(int i=1;i<=n;i++)
    {
        
        if(d[i]==mx1)
        {
            
            for(auto v:g[i])
            {
                if(d[v]==mx2)cnt[mx2]--;
            }
            
        }
    }
    int res=1;
    if(cnt[mx2])
    {
        res+=mx1-1;
        res+=mx2-1;
    }
    else
    {
        res+=mx1-1;
        res+=mx2-2;
    }
    cout<<res<<endl;
}


int main()
{
   
    int t;
    cin>>t;
    while(t--)
    {
        solve();
    }
}
Problem: 2050C - Uninteresting Number
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Time limit exceeded on test 3):
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 20;
int  dp[N][10];
void solve() {
	memset(dp,0,sizeof(dp));
	string s;
	cin >> s;
	int len = s.length();
	s = " " + s;	dp[0][0]=1;
	for (int i = 1; i <= len; i++) {
		int val = s[i] - '0';
		for (int k = 0; k <= 8; k++) {
		
			if ( dp[i - 1][k]) {
				dp[i][(k + val) % 9] = 1;
				if (val < 4)dp[i][(val * val + k) % 9]=1;
			}
		}
	}
  if(dp[len][0])cout<<"YES"<<endl;else cout<<"NO"<<endl;
//  for(int i=1;i<=len;i++)
//  {
//  	for(int j=0;j<=8;j++)
//  	{
//	  	cout<<dp[i][j]<<' ';
//	  }cout<<endl;
//  }

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

	return 0;
}
Problem: 2050C - Uninteresting Number
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Time limit exceeded on test 2):
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 1e5+10;
int  dp[N][10];
void solve() {
	memset(dp,0,sizeof(dp));
	string s;
	cin >> s;
	int len = s.length();
	s = " " + s;	dp[0][0]=1;
	for (int i = 1; i <= len; i++) {
		int val = s[i] - '0';
		for (int k = 0; k <= 8; k++) {
		
			if ( dp[i - 1][k]) {
				dp[i][(k + val) % 9] = 1;
				if (val < 4)dp[i][(val * val + k) % 9]=1;
			}
		}
	}
  if(dp[len][0])cout<<"YES"<<endl;else cout<<"NO"<<endl;
//  for(int i=1;i<=len;i++)
//  {
//  	for(int j=0;j<=8;j++)
//  	{
//	  	cout<<dp[i][j]<<' ';
//	  }cout<<endl;
//  }

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

	return 0;
}

Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 1e5+10;
int  dp[N][10];
void solve() {
	//memset(dp,0,sizeof(dp));
	string s;
	cin >> s;
	int len = s.length();
	s = " " + s;	dp[0][0]=1;
	for (int i = 1; i <= len; i++) {
		int val = s[i] - '0';
		for (int k = 0; k <= 8; k++) {
		
			if ( dp[i - 1][k]) {
				dp[i][(k + val) % 9] = 1;
				if (val < 4)dp[i][(val * val + k) % 9]=1;
	if(i-1!=0)dp[i-1][k]=0;	
			}
		}
	}	
  if(dp[len][0])cout<<"YES"<<endl;else cout<<"NO"<<endl;
  for(int i=0;i<=8;i++)
  {
     dp[len][i]=0;
  }
  
//  for(int i=1;i<=len;i++)
//  {
//  	for(int j=0;j<=8;j++)
//  	{
//	  	cout<<dp[i][j]<<' ';
//	  }cout<<endl;
//  }

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

	return 0;
}
Problem: 2050C - Uninteresting Number
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Time limit exceeded on test 3):
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 20;
int  dp[N][10];
void solve() {
	memset(dp,0,sizeof(dp));
	string s;
	cin >> s;
	int len = s.length();
	s = " " + s;	dp[0][0]=1;
	for (int i = 1; i <= len; i++) {
		int val = s[i] - '0';
		for (int k = 0; k <= 8; k++) {
		
			if ( dp[i - 1][k]) {
				dp[i][(k + val) % 9] = 1;
				if (val < 4)dp[i][(val * val + k) % 9]=1;
			}
		}
	}
  if(dp[len][0])cout<<"YES"<<endl;else cout<<"NO"<<endl;
//  for(int i=1;i<=len;i++)
//  {
//  	for(int j=0;j<=8;j++)
//  	{
//	  	cout<<dp[i][j]<<' ';
//	  }cout<<endl;
//  }

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

	return 0;
}

Submission (verdict: Time limit exceeded on test 2):
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 1e5+10;
int  dp[N][10];
void solve() {
	memset(dp,0,sizeof(dp));
	string s;
	cin >> s;
	int len = s.length();
	s = " " + s;	dp[0][0]=1;
	for (int i = 1; i <= len; i++) {
		int val = s[i] - '0';
		for (int k = 0; k <= 8; k++) {
		
			if ( dp[i - 1][k]) {
				dp[i][(k + val) % 9] = 1;
				if (val < 4)dp[i][(val * val + k) % 9]=1;
			}
		}
	}
  if(dp[len][0])cout<<"YES"<<endl;else cout<<"NO"<<endl;
//  for(int i=1;i<=len;i++)
//  {
//  	for(int j=0;j<=8;j++)
//  	{
//	  	cout<<dp[i][j]<<' ';
//	  }cout<<endl;
//  }

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

	return 0;
}
Problem: 2063B - Subsequence Update
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
#include<iostream>

#include<vector>

#include<set>

#include<cstring>

#include<algorithm>

#include<cmath>

#include<map>

using namespace std;

using ll = long long; 



int main() {

    ll t;

    cin >> t;

    while (t--) {

        ll n,l,r;

        cin >> n >> l >> r;

        vector<int>a(n);

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

            cin >> a[i];

        }

        int sum = 0, sum_one = 0, sum_two=0;

        if (l == 1) {

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

            for (int i = 0; i < r ; i++)sum += a[i];

        }

        else if (r == n) {

            sort(a.begin(), a.end(), greater<int>());

            for (int i = 0; i < r - l; i++)sum += a[i];

        }

        else {

            vector<int>b = a;

            sort(a.begin(), a.begin()+r);

            for (int i = 0; i < r - l + 1; i++)sum_one += a[i];

            sort(b.begin() + l, b.end());

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

            sum = min(sum_one, sum_two);

        }

        cout << sum << endl;

    }

    return 0;

}

Submission (verdict: Wrong answer on test 2):
#include<iostream>

#include<vector>

#include<set>

#include<cstring>

#include<algorithm>

#include<cmath>

#include<map>

#include<stack>

#include<queue>

using namespace std;

using ll = long long; 

int main() {

    ll t;

    cin >> t;

    while (t--) {

        priority_queue<int> a;

        priority_queue<int> b;

        int n,l,r;

        cin >> n >> l >> r;

        vector<int>fa(n);

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

            cin >> fa[i];

            if (i >= l - 1 && i < r) {

                a.push(fa[i]);

                b.push(fa[i]);

            }

        }

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

            if (fa[i] < a.top()) {

                a.pop();

                a.push(fa[i]);

            }

        }

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

            if (fa[i] < b.top()) {

                a.pop();

                a.push(fa[i]);

            }

        }

        ll cm = 0, dm = 0;

        while (a.size()) {

            cm += a.top();

            a.pop();

        }

        while (b.size()) {

            dm += b.top();

            b.pop();

        }

        cout << min(cm, dm) << endl;

   }

    return 0;

}
Problem: 2063B - Subsequence Update
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 2):
#include<iostream>

#include<vector>

#include<set>

#include<cstring>

#include<algorithm>

#include<cmath>

#include<map>

using namespace std;

using ll = long long; 



int main() {

    ll t;

    cin >> t;

    while (t--) {

        ll n,l,r;

        cin >> n >> l >> r;

        vector<int>a(n);

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

            cin >> a[i];

        }

        int sum = 0, sum_one = 0, sum_two=0;

        if (l == 1) {

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

            for (int i = 0; i < r ; i++)sum += a[i];

        }

        else if (r == n) {

            sort(a.begin(), a.end(), greater<int>());

            for (int i = 0; i < r - l; i++)sum += a[i];

        }

        else {

            vector<int>b = a;

            sort(a.begin(), a.begin()+r);

            for (int i = 0; i < r - l + 1; i++)sum_one += a[i];

            sort(b.begin() + l, b.end());

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

            sum = min(sum_one, sum_two);

        }

        cout << sum << endl;

    }

    return 0;

}