ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2052A - Adrenaline Rush
Language: C++20 (GCC 13-64)

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

ll T;
ll n;
ll a[200010];
ll b[200010];
multiset<ll> ans_more[1010];
multiset<ll> ans_still[1010];

bool cmp(ll a, ll b)
{
	return a < b;
}

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

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

	ll ans = 0;
	for (int i = 1; i <= n; i++)
		for (int j = 1; j < a[i]; j++)
			if (b[j] > i)
				ans++;
			else
				ans += 2;
	cout << ans << endl;

	for (int i = n; i >= 1; i--)
		for (int j = i - 1; j >= 1; j--)
		    cout << i << " " << j << endl;

	for (int i = 1; i <= n; i++)
		for (int j = n; j > a[i]; j--)
			if (b[j] > i) ans_more[i].insert(b[j]);
	
	for (int i = n; i >= 1; i--)
		for (auto it = ans_more[i].begin(); it!= ans_more[i].end(); it++)
            cout << i << " " << *it << endl;

    return 0;
}


/*
____        ____     ____  ___          ___  ____   ____
|  |        |  |     |  |  \  \        /  /  |  |  /  /
|  |        |  |     |  |   \  \      /  /   |  |_/  /
|  |        |  |     |  |    \  \    /  /    |      /
|  |        |  |     |  |     \  \  /  /     |  |\  \
|  |_____   |  |_____|  |      \  \/  /      |  | \  \
|________|  |___________|       \____/       |__|  \__\
*/


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

ll T;
ll n;
ll a[200010];
ll b[200010];
multiset<ll> ans_more[1010];
multiset<ll> ans_still[1010];

bool cmp(ll a, ll b)
{
	return a < b;
}

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

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

	ll ans = 0;
	for (int i = 1; i <= n; i++)
		for (int j = 1; j < a[i]; j++)
			if (b[j] > i)
				ans++;
			else
				ans += 2;
	cout << ans << endl;

	for (int i = n; i >= 1; i--)
		for (int j = i - 1; j >= 1; j--)
		    cout << i << " " << j << endl;

	for (int i = 1; i <= n; i++)
		for (int j = n; j > a[i]; j--)
			if (b[j] > i) ans_more[i].insert(b[j]);
	
	for (int i = n; i >= 1; i--)
		for (auto it = ans_more[i].rbegin(); it!= ans_more[i].rend(); it++)
            cout << i << " " << *it << endl;

    return 0;
}


/*
____        ____     ____  ___          ___  ____   ____
|  |        |  |     |  |  \  \        /  /  |  |  /  /
|  |        |  |     |  |   \  \      /  /   |  |_/  /
|  |        |  |     |  |    \  \    /  /    |      /
|  |        |  |     |  |     \  \  /  /     |  |\  \
|  |_____   |  |_____|  |      \  \/  /      |  | \  \
|________|  |___________|       \____/       |__|  \__\
*/
Problem: 2061D - Kevin and Numbers
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 3):
#include<bits/stdc++.h> 
#include<array>
#define ll long long
#define inf 1e9+7
using namespace std;
void solve()
{
	int n, m;
	cin >> n >> m;
	vector<int>a(n);
	vector<int>b(m);
	multiset<int>s;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		s.insert(a[i]);
	}
	for (int i = 0; i < m; i++) {
		cin >> b[i];
	}
	sort(b.begin(), b.end());
	auto it = s.begin();
	while(it!=s.end()) {
		int t = distance(s.begin(), it);
		if (t >= m) {
			cout << "NO" << endl;;
			return;
		}
		if (*it != b[t]) {
			if (b[t] < *it) {
				cout << "NO" << endl;
				return;
			}
			int temp1 = *it;
			if (it == prev(s.end())) {
				cout << "NO" << endl;
				return;
			}
			it=s.erase(it);
			int temp2 = *it;
			it = s.erase(it);
			if (temp2 - temp1 > 1) {
				cout << "NO" << endl;
				return;
			}
			s.insert(temp1 + temp2);
			if (it != s.begin()) {
				it--;
			}
		}
		else {
			it++;
		}
	}
	if (s.size() != m) {
		cout << "NO" << endl;
		return;
	}
	cout << "YES" << endl;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int T;
	cin >> T;
	while (T--) {
		solve();
	}
	return 0;
}


Submission (verdict: Wrong answer on test 3):
#include<bits/stdc++.h> 
#include<array>
#define ll long long
#define inf 1e9+7
using namespace std;
void solve()
{
	int n, m;
	cin >> n >> m;
	priority_queue<int,vector<int>,greater<>>a;
	priority_queue<int,vector<int>,greater<>>b;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		a.push(x);
	}
	for (int i = 0; i < m; i++) {
		int x;
		cin >> x;
		b.push(x);
	}
	while (!a.empty()) {
		int now = a.top();
		a.pop();
		if (b.empty()) {
			cout << "NO" << endl;
			return;
		}
		if (now == b.top()) {
			b.pop();
			continue;
		}
		if (now > b.top()) {
			cout << "NO" << endl;
			return;
		}
		if (a.empty()) {
			cout << "NO" << endl;
			return;
		}
		int next = a.top();
		a.pop();
		if (next - now > 1) {
			cout << "NO" << endl;
			return;
		}
		a.push(now + next);
	}
	if (!b.empty()) {
		cout << "NO" << endl;
	}
	else {
		cout << "YES" << endl;
	}
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int T;
	cin >> T;
	while (T--) {
		solve();
	}
	return 0;
}
Problem: 2061D - Kevin and Numbers
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 3):
#include<bits/stdc++.h> 
#include<array>
#define ll long long
#define inf 1e9+7
using namespace std;
void solve()
{
	int n, m;
	cin >> n >> m;
	vector<int>a(n);
	vector<int>b(m);
	multiset<int>s;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		s.insert(a[i]);
	}
	for (int i = 0; i < m; i++) {
		cin >> b[i];
	}
	sort(b.begin(), b.end());
	auto it = s.begin();
	while(it!=s.end()) {
		int t = distance(s.begin(), it);
		if (t >= m) {
			cout << "NO" << endl;;
			return;
		}
		if (*it != b[t]) {
			if (b[t] < *it) {
				cout << "NO" << endl;
				return;
			}
			int temp1 = *it;
			if (it == prev(s.end())) {
				cout << "NO" << endl;
				return;
			}
			it=s.erase(it);
			int temp2 = *it;
			it = s.erase(it);
			if (temp2 - temp1 > 1) {
				cout << "NO" << endl;
				return;
			}
			s.insert(temp1 + temp2);
			if (it != s.begin()) {
				it--;
			}
		}
		else {
			it++;
		}
	}
	if (s.size() != m) {
		cout << "NO" << endl;
		return;
	}
	cout << "YES" << endl;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int T;
	cin >> T;
	while (T--) {
		solve();
	}
	return 0;
}
Problem: 2061D - Kevin and Numbers
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 3):
#include<bits/stdc++.h> 
#include<array>
#define ll long long
#define inf 1e9+7
using namespace std;
void solve()
{
	int n, m;
	cin >> n >> m;
	priority_queue<int,vector<int>,greater<>>a;
	priority_queue<int,vector<int>,greater<>>b;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		a.push(x);
	}
	for (int i = 0; i < m; i++) {
		int x;
		cin >> x;
		b.push(x);
	}
	while (!a.empty()) {
		int now = a.top();
		a.pop();
		if (b.empty()) {
			cout << "NO" << endl;
			return;
		}
		if (now == b.top()) {
			b.pop();
			continue;
		}
		if (now > b.top()) {
			cout << "NO" << endl;
			return;
		}
		if (a.empty()) {
			cout << "NO" << endl;
			return;
		}
		int next = a.top();
		a.pop();
		if (next - now > 1) {
			cout << "NO" << endl;
			return;
		}
		a.push(now + next);
	}
	if (!b.empty()) {
		cout << "NO" << endl;
	}
	else {
		cout << "YES" << endl;
	}
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int T;
	cin >> T;
	while (T--) {
		solve();
	}
	return 0;
}


Submission (verdict: Accepted):
#include<bits/stdc++.h> 
#include<array>
#define ll long long
#define inf 1e9+7
using namespace std;
void solve()
{
	int n, m;
	cin >> n >> m;
	priority_queue<int, vector<int>>a;
	priority_queue<int, vector<int>>b;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		a.push(x);
	}
	for (int i = 0; i < m; i++) {
		int x;
		cin >> x;
		b.push(x);
	}
	while (!a.empty()) {
		if (b.empty() || b.size() > a.size()) {
			cout << "NO" << endl;
			return;
		}
		int x = b.top();
		b.pop();
		if (a.top() == x) {
			a.pop();
			continue;
		}
		b.push(x / 2);
		b.push((x + 1) / 2);
	}
	if (!b.empty()) {
		cout << "NO" << endl;
	}
	else {
		cout << "YES" << endl;
	}
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int T;
	cin >> T;
	while (T--) {
		solve();
	}
	return 0;
}
//3 3 4 4 
//7 7 
//4 4 6
//
Problem: 2057C - Trip to the Olympiad
Language: C++23 (GCC 14-64, msys2)


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

using i64 = long long;
using i128 = __int128;
using ui64 = unsigned long long;

void solve(){
    int l, r;
    cin >> l >> r;
    int n = r;
    int cnt = 0;
    while(n) {
        n>>=1;
        cnt++;
    }
    int ans = 0;
    for(int i=0; i<cnt; i++) {
        if((r & (1<<i)) == 0) {
            ans |= (1<<i);
        }
    }
    cout << r << " " << ans << " " << (r ^ 1) << "\n";
}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(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>
using namespace std;

using i64 = long long;
using i128 = __int128;
using ui64 = unsigned long long;

void solve(){
    int l, r;
    cin >> l >> r;
    int n = r;
    int cnt = 0;
    while(n) {
        n>>=1;
        cnt++;
    }
    int ans = 0;
    for(int i=0; i<cnt; i++) {
        if((r & (1<<i)) == 0) {
            ans |= (1<<i);
        }
    }
    cout << r << " " << ans << " " << (r ^ 1) << "\n";
}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int t = 1;
    cin >> t;
    while(t--) {
        solve();
    }
    return 0;
}

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

void solve() {
    long long l, r;
    cin >> l >> r;
    long long a = r; 
    long long curr = a;

    for (int i = 32; i >= 0; i--) {
        if (curr & (1LL << i)) { 
            if ((curr & ~(1LL << i)) >= l) { 
                curr &= ~(1LL << i); 
            }
        } else { 
            if ((curr | (1LL << i)) <= r) { 
                curr |= (1LL << i); 
            }
        }
    }
    cout << a << " " << curr << " " << abs(curr) << "\n"; 
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
}
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>
using namespace std;

void solve() {
    long long l, r;
    cin >> l >> r;
    long long a = r; 
    long long curr = a;

    for (int i = 32; i >= 0; i--) {
        if (curr & (1LL << i)) { 
            if ((curr & ~(1LL << i)) >= l) { 
                curr &= ~(1LL << i); 
            }
        } else { 
            if ((curr | (1LL << i)) <= r) { 
                curr |= (1LL << i); 
            }
        }
    }
    cout << a << " " << curr << " " << abs(curr) << "\n"; 
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
}


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

void solve() {
    long long l, r;
    cin >> l >> r;
    long long a = r; 
    long long curr = a;
    int cng=-1;
    int f=-1;


    for (int i = 32; i >= 0; i--) {
        if (curr & (1LL << i)) { 
            if ((curr & ~(1LL << i)) >= l) { 
                curr &= ~(1LL << i); 
                f=1;
                cng=(1LL << i);


            }
        } else { 
            if ((curr | (1LL << i)) <= r) { 
                curr |= (1LL << i);
                cng = ~(1LL << i);
                f=0;


            }
        }
    }
    long long curr2=curr;
    if(f==1){
        curr2|=cng;

    }
    else{
        curr2&=cng;
    }
    cout << a << " " << curr << " " <<curr2  << "\n"; 
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
}
Problem: 2050E - Three Strings
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 17):
#pragma GCC optimize(2)
#include<unordered_map>
#include<unordered_set>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cctype>
#include<vector>
#include<cstdio>
#include<stack>
#include<queue>
#include<map>
#define se second
#define fi first
#define pb push_back
#define ins insert
#define all(x) x.begin(),x.end()
using namespace std;  
typedef long long ll; 
typedef unsigned long long ull;
inline bool cmp_v(ll a,ll b){return a>b;}
inline ll gcd(ll a ,ll b){return b?gcd(b,a%b):a;}
inline ll lcm(ll a ,ll b){return a*b/gcd(a,b);}
inline ll qk_pow(ll x,ll n){
    if(n==0)return 1;
    ll r=1;
    while(n--){
        if(n&1)r*=x;
        n>>=1;
        x*=x;
    }return r;
}
inline void swap_(ll &a,ll &b){
    a^=b^=a^=b;return ;
}
inline ll max_(ll a, ll b ){return a>b?a:b;}
inline ll min_(ll a, ll b ){return a>b?b:a;}
const int mod = 100000007;
const ll I = 10000007;
//================================================
//Please 键入 您的 code :
void solve(){
    string a,b,c;
    cin>>a>>b>>c;
    ll n=c.size();
    vector<vector<ll>>dp(n+1,vector<ll>(n+1,1e3));
    dp[0][0]=0;
    ll ans=1e3;
    for(ll f = 0;f<=a.size();f++)
        for(ll d =0;d<=b.size();d++){ 
            if(f<a.size())dp[f+1][d]=min_(dp[f+1][d],dp[f][d]+(a[f]!=c[f+d]));
            if(d<b.size())dp[f][d+1]=min_(dp[f][d+1],dp[f][d]+(b[d]!=c[f+d]));
           }
    for(ll f = 0;f<=a.size();f++){
        ll d =n-f;
        if(d>=0&&d<=b.size())ans=min_(dp[f][d],ans);
    }cout<<ans<<"\n";
}









//================================================
int main() {  
    ios::sync_with_stdio(false);  
    cin.tie(0);  
    cout.tie(0);  
    ll t;  
    t=1;
    cin >> t;
    while (t--) {  
        solve();  
    }  
    return 0;  
}
Problem: 2063C - Remove Exactly Two
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using ld = long double;
// using ull = unsigned long long;
#define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
#define all(x) x.begin(), x.end()
const ll mod = 998244353;
const ll c = 1e5;
// #pragma GCC optimize("O3,unroll-loops")
// #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
vector<vector<ll>> g;
vector<ll> dp;
ll ans = 0;

void dfs(ll v, ll p = -1) {
    for (ll u : g[v]) {
        if (u == p) {
            continue;
        }
        dfs(u, v);
        ans = max({ans, (ll)g[v].size() + dp[u] - 1, (ll)g[u].size() + (ll)g[v].size() - 2});
        dp[u] = max(dp[u], (ll)g[u].size());
        dp[v] = max(dp[v], dp[u]);
    }
}

void solve() {
    ll n; cin >> n;
    ans = 0;
    g.assign(n, vector<ll>());
    dp.assign(n, 0);
    for (ll i = 0; i < n - 1; i++) {
        ll a, b; cin >> a >> b;
        a--, b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    dfs(0);

    dp[0] = max(dp[0], (ll)g[0].size()); 
    cout << ans << '\n';
}

signed main() {
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(0);
    ll t; cin >> t;
    while (t--) solve();

}

Submission (verdict: Accepted):
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using ld = long double;
// using ull = unsigned long long;
#define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
#define all(x) x.begin(), x.end()
const ll mod = 998244353;
const ll c = 1e5;
// #pragma GCC optimize("O3,unroll-loops")
// #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
vector<vector<ll>> g;
vector<ll> dp;
ll ans = 0;

void dfs(ll v, ll p = -1) {
    for (ll u : g[v]) {
        if (u == p) {
            continue;
        }
        dfs(u, v);
        ans = max({ans, (ll)g[v].size() + dp[u] - 1, (ll)g[u].size() + (ll)g[v].size() - 2});
        dp[u] = max(dp[u], (ll)g[u].size());
        dp[v] = max(dp[v], dp[u]);
    }
    ll v1 = 0, v2 = 0;
    for (ll u : g[v]) {
        if (u == p) {
            continue;
        }        
        if (v1 < dp[u]) {
            swap(v1, v2);
            v1 = dp[u];
        } else if (v2 < dp[u]) {
            v2 = dp[u];
        }
    }
    ans = max(ans, v1 + v2 - 1);
}

void solve() {
    ll n; cin >> n;
    ans = 0;
    g.assign(n, vector<ll>());
    dp.assign(n, 0);
    for (ll i = 0; i < n - 1; i++) {
        ll a, b; cin >> a >> b;
        a--, b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    dfs(0);
    cout << ans << '\n';
}

signed main() {
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(0);
    ll t; cin >> 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>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using ld = long double;
// using ull = unsigned long long;
#define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
#define all(x) x.begin(), x.end()
const ll mod = 998244353;
const ll c = 1e5;
// #pragma GCC optimize("O3,unroll-loops")
// #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
vector<vector<int>> g;
vector<int> dp;
int ans = 0;

void dfs(int v, int p = -1) {
    auto& ans1 = ans;
    auto& dp1 = dp;
    for (int u : g[v]) {
        if (u == p) {
            continue;
        }
        dfs(u, v);
        if (dp[u] == 0) {
            ans = max(ans, (int)g[v].size() - 1);
        } else {
            ans = max(ans, (int)g[v].size() + dp[u] - 1);
        }
        ans = max(ans, (int)g[u].size() + (int)g[v].size() - 2);
        dp[u] = max(dp[u], (int)g[u].size());
        dp[v] = max(dp[v], dp[u]);
    }
    
}

void solve() {
    int n; cin >> n;
    ans = 0;
    g.assign(n, vector<int>());
    dp.assign(n, 0);
    for (int i = 0; i < n - 1; i++) {
        int a, b; cin >> a >> b;
        a--, b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    dfs(0);
    cout << ans << '\n';
}

signed main() {
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(0);
    ll t; cin >> 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>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using ld = long double;
// using ull = unsigned long long;
#define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
#define all(x) x.begin(), x.end()
const ll mod = 998244353;
const ll c = 1e5;
// #pragma GCC optimize("O3,unroll-loops")
// #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
vector<vector<int>> g;
vector<int> dp;
int ans = 0;

void dfs(int v, int p = -1) {
    auto& ans1 = ans;
    auto& dp1 = dp;
    for (int u : g[v]) {
        if (u == p) {
            continue;
        }
        dfs(u, v);
        if (dp[u] == 0) {
            ans = max(ans, (int)g[v].size() - 1);
        } else {
            ans = max(ans, (int)g[v].size() + dp[u] - 1);
        }
        ans = max(ans, (int)g[u].size() + (int)g[v].size() - 2);
        dp[u] = max(dp[u], (int)g[u].size());
        dp[v] = max(dp[v], dp[u]);
    }
    
}

void solve() {
    int n; cin >> n;
    ans = 0;
    g.assign(n, vector<int>());
    dp.assign(n, 0);
    for (int i = 0; i < n - 1; i++) {
        int a, b; cin >> a >> b;
        a--, b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    dfs(0);
    cout << ans << '\n';
}

signed main() {
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(0);
    ll t; cin >> t;
    while (t--) solve();

}

Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using ld = long double;
// using ull = unsigned long long;
#define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
#define all(x) x.begin(), x.end()
const ll mod = 998244353;
const ll c = 1e5;
// #pragma GCC optimize("O3,unroll-loops")
// #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
vector<vector<ll>> g;
vector<ll> dp;
ll ans = 0;

void dfs(ll v, ll p = -1) {
    for (ll u : g[v]) {
        if (u == p) {
            continue;
        }
        dfs(u, v);
        ans = max({ans, (ll)g[v].size() + dp[u] - 1, (ll)g[u].size() + (ll)g[v].size() - 2});
        dp[u] = max(dp[u], (ll)g[u].size());
        dp[v] = max(dp[v], dp[u]);
    }
}

void solve() {
    ll n; cin >> n;
    ans = 0;
    g.assign(n, vector<ll>());
    dp.assign(n, 0);
    for (ll i = 0; i < n - 1; i++) {
        ll a, b; cin >> a >> b;
        a--, b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    dfs(0);

    dp[0] = max(dp[0], (ll)g[0].size()); 
    cout << ans << '\n';
}

signed main() {
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(0);
    ll t; cin >> t;
    while (t--) solve();

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

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

#define fi first

#define se second

using pii = std::pair<int, int>;

using ll = long long;

using ul = unsigned long long;

using ld = long double;

constexpr int INF = 0x7FFFFFFF;

inline void solve() {

    std::string s;

    std::cin >> s;

    int n = s.size();

    std::vector<int> a(n + 1);

    for(int i = 1; i <= n; i++) a[i] = s[i - 1] - '0';

    int sum = 0, cnt3 = 0, cnt2 = 0;

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

        if(a[i] == 3) cnt3++;

        if(a[i] == 2) cnt2++;

        sum += a[i];

    }

    cnt3 %= 9, cnt2 %= 9;

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

        for(int j = 0; j <= cnt2; j++) {

            if((sum + i * 6 + j * 2) % 9 == 0) {

                std::cout << "YES\n";

                return;

            }

        }

    }

    std::cout << "NO\n";

}

signed main() {

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

	int t;

	std::cin >> t;

	while(t--) solve();

	return 0;

}



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

#define fi first

#define se second

using pii = std::pair<int, int>;

using ll = long long;

using ul = unsigned long long;

using ld = long double;

constexpr int INF = 0x7FFFFFFF;

inline void solve() {

    std::string s;

    std::cin >> s;

    int n = s.size();

    std::vector<int> a(n + 1);

    for(int i = 1; i <= n; i++) a[i] = s[i - 1] - '0';

    int sum = 0, cnt3 = 0, cnt2 = 0;

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

        if(a[i] == 3) cnt3++;

        if(a[i] == 2) cnt2++;

        sum += a[i];

    }

    cnt3 %= 20, cnt2 %= 20;

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

        for(int j = 0; j <= cnt2; j++) {

            if((sum + i * 6 + j * 2) % 9 == 0) {

                std::cout << "YES\n";

                return;

            }

        }

    }

    std::cout << "NO\n";

}

signed main() {

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

	int t;

	std::cin >> t;

	while(t--) solve();

	return 0;

}