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

Previous submission (verdict: Wrong answer on test 2):
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

using namespace std;
typedef long long ll;
const int N = 309, M = 998244353;

void solve()
{
    int n;
    cin>>n;
    vector<vector<int>> g(n+1);
    vector<int> ind(n+1,0);

    for(int i=0,u,v;i<n-1;++i)
    {
        cin>>u>>v;
        g[u].push_back(v),g[v].push_back(u);
        ind[u]++,ind[v]++;
    }

    int tag=0,cnt=0;
    for(int i=1;i<=n;++i)
        if(ind[i]>ind[tag]) tag=i,cnt=0;
        else if(ind[i]==ind[tag]) cnt++;

    if(cnt>=3) cout<<ind[tag]*2-1<<'\n';
    else if(cnt==2)
    {
        bool is = false;
        for(int i=0;i<(int)g[tag][i];++i)
            if(ind[g[tag][i]]==ind[tag]) is = true;
        if(is) cout<< ind[tag]*2-2<< '\n';
        else cout<< ind[tag]*2-1<< '\n';
    }
    else
    {
        for(int i=0;i<(int)g[tag].size();++i) ind[g[tag][i]]--;
        int mx=0;
        for(int i=1;i<=n;++i)
            if(i!=tag) mx = max(mx,ind[i]);
        cout<< ind[tag]+mx-1<< '\n';
    }

}

int main()
{
    ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    //fflush(stdout);

    int t;
    cin>>t;
    while(t--) solve();

    return 0;
}


Submission (verdict: Runtime error on test 1):
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

using namespace std;
typedef long long ll;

void solve()
{
    int n;
    cin>>n;
    vector<vector<int>> g(n+1);
    vector<int> ind(n+1,0);

    for(int i=0,u,v;i<n-1;++i)
    {
        cin>>u>>v;
        g[u].push_back(v),g[v].push_back(u);
        ind[u]++,ind[v]++;
    }

    int tag=0,cnt=0;
    for(int i=1;i<=n;++i)
        if(ind[i]>ind[tag]) tag=i,cnt=1;
        else if(ind[i]==ind[tag]) cnt++;

    if(cnt>=3) cout<<ind[tag]*2-1<<'\n';
    else if(cnt==2)
    {
        bool is = false;
        for(int i=0;i<(int)g[tag][i];++i)
            if(ind[g[tag][i]]==ind[tag]) is = true;
        if(is) cout<< ind[tag]*2-2<< '\n';
        else cout<< ind[tag]*2-1<< '\n';
    }
    else
    {
        for(int i=0;i<(int)g[tag].size();++i) ind[g[tag][i]]--;
        int mx=0;
        for(int i=1;i<=n;++i)
            if(i!=tag) mx = max(mx,ind[i]);
        cout<< ind[tag]+mx-1<< '\n';
    }

}

int main()
{
    ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    //fflush(stdout);

    int t;
    cin>>t;
    while(t--) solve();

    return 0;
}
Problem: 2063C - Remove Exactly Two
Language: C++17 (GCC 7-32)

Previous submission (verdict: Runtime error on test 1):
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

using namespace std;
typedef long long ll;

void solve()
{
    int n;
    cin>>n;
    vector<vector<int>> g(n+1);
    vector<int> ind(n+1,0);

    for(int i=0,u,v;i<n-1;++i)
    {
        cin>>u>>v;
        g[u].push_back(v),g[v].push_back(u);
        ind[u]++,ind[v]++;
    }

    int tag=0,cnt=0;
    for(int i=1;i<=n;++i)
        if(ind[i]>ind[tag]) tag=i,cnt=1;
        else if(ind[i]==ind[tag]) cnt++;

    if(cnt>=3) cout<<ind[tag]*2-1<<'\n';
    else if(cnt==2)
    {
        bool is = false;
        for(int i=0;i<(int)g[tag][i];++i)
            if(ind[g[tag][i]]==ind[tag]) is = true;
        if(is) cout<< ind[tag]*2-2<< '\n';
        else cout<< ind[tag]*2-1<< '\n';
    }
    else
    {
        for(int i=0;i<(int)g[tag].size();++i) ind[g[tag][i]]--;
        int mx=0;
        for(int i=1;i<=n;++i)
            if(i!=tag) mx = max(mx,ind[i]);
        cout<< ind[tag]+mx-1<< '\n';
    }

}

int main()
{
    ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    //fflush(stdout);

    int t;
    cin>>t;
    while(t--) solve();

    return 0;
}


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

using namespace std;
typedef long long ll;

void solve()
{
    int n;
    cin>>n;
    vector<vector<int>> g(n+1);
    vector<int> ind(n+1,0);

    for(int i=0,u,v;i<n-1;++i)
    {
        cin>>u>>v;
        g[u].push_back(v),g[v].push_back(u);
        ind[u]++,ind[v]++;
    }

    int tag=0,cnt=0;
    for(int i=1;i<=n;++i)
        if(ind[i]>ind[tag]) tag=i,cnt=1;
        else if(ind[i]==ind[tag]) cnt++;

    if(cnt>=3) cout<<ind[tag]*2-1<<'\n';
    else if(cnt==2)
    {
        bool is = false;
        for(int i=0;i<(int)g[tag].size();++i)
            if(ind[g[tag][i]]==ind[tag]) is = true;
        if(is) cout<< ind[tag]*2-2<< '\n';
        else cout<< ind[tag]*2-1<< '\n';
    }
    else
    {
        for(int i=0;i<(int)g[tag].size();++i) ind[g[tag][i]]--;
        int mx=0;
        for(int i=1;i<=n;++i)
            if(i!=tag) mx = max(mx,ind[i]);
        cout<< ind[tag]+mx-1<< '\n';
    }

}

int main()
{
    ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    //fflush(stdout);

    int t;
    cin>>t;
    while(t--) solve();

    return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 1):
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<cmath>
#include<stack>
#include<queue>
#include<set>
//#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define N 500010
const ll INF = 1e18 + 10;
#define mod 998244353
//map<ll, ll>v;
ll n, maxn, k, m, q, p, pos;
ll a[N], b[N], c[N];
ll vis[N];
ll dis[N];
vector<ll>v;
ll sum, cnt;
struct node { int id, x; }nod[N];
bool cmp(node x, node y) { return x.x < y.x; }
ll num[3005][3005],f[3005][3005];
ll s[N];
map<ll, ll>mp;
void solve() {
	ll l, r;
	cin >> l >> r;
	k = __lg(l ^ r);
	ll x = (r >> k) << k, y = x - 1,z;
	if (y == l)z = x + 1;
	else z = x - 2;
	cout << x << " " << y << " " << z << '\n';
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	//	freopen("input.txt","r",stdin);
	//  freopen("output.txt","w",stdout);
	int t = 1;
	cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<cmath>
#include<stack>
#include<queue>
#include<set>
//#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define N 500010
const ll INF = 1e18 + 10;
#define mod 998244353
//map<ll, ll>v;
ll n, maxn, k, m, q, p, pos;
ll a[N], b[N], c[N];
ll vis[N];
ll dis[N];
vector<ll>v;
ll sum, cnt;
struct node { int id, x; }nod[N];
bool cmp(node x, node y) { return x.x < y.x; }
ll num[3005][3005],f[3005][3005];
ll s[N];
map<ll, ll>mp;
void solve() {
	ll l, r;
	cin >> l >> r;
	k = __lg(l ^ r);
	ll x = (r >> k) << k, y = x - 1,z;
	if (y == l)z = x + 1;
	else z = x - 2;
	cout << x << " " << y << " " << z << '\n';
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	//	freopen("input.txt","r",stdin);
	//  freopen("output.txt","w",stdout);
	int t = 1;
	cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++20 (GCC 13-64)

Previous submission (verdict: Compilation error):
#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define N 500010
const ll INF = 1e18 + 10;
#define mod 998244353
//map<ll, ll>v;
ll n, maxn, k, m, q, p, pos;
ll a[N], b[N], c[N];
ll vis[N];
ll dis[N];
vector<ll>v;
ll sum, cnt;
struct node { int id, x; }nod[N];
bool cmp(node x, node y) { return x.x < y.x; }
ll num[3005][3005],f[3005][3005];
ll s[N];
map<ll, ll>mp;
void solve() {
	ll l, r;
	cin >> l >> r;
	k = __lg(l ^ r);
	ll x = (r >> k) << k, y = x - 1,z;
	if (y == l)z = x + 1;
	else z = x - 2;
	cout << x << " " << y << " " << z << '\n';
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	//	freopen("input.txt","r",stdin);
	//  freopen("output.txt","w",stdout);
	int t = 1;
	cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}


Submission (verdict: Accepted):
import java.util.*;
import java.lang.*;
import java.io.*;
public class Codechef
    {
	static FastScanner fs = null;
	public static void main(String[] args) {
		fs = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		int t = fs.nextInt();
        while(t-->0){
            int l = fs.nextInt();
            int r = fs.nextInt();
            int num = l^r;
            int x = 0;
            int y = 0;
            int z = 0;
            for(int i = 0;i<30;i++){
                if(((1<<i)&num) != 0){
                    x = 1<<i;
                }
            }
            y = x-1;
            for(int i = l;i<=r;i++){
                if(i==x || i==y){
                    
                }
                else{
                    z = i;
                    break;
                }
            }
            out.println(x+" "+y+" "+z);
        }
		out.close();
	}
	static void sort(int[] a) {
		ArrayList<Integer> l=new ArrayList<>();
		for (int i:a) l.add(i);
		Collections.sort(l);
		for (int i=0; i<a.length; i++) a[i]=l.get(i);
	}
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		long nextLong() {
			return Long.parseLong(next());
		}
		double nextDouble() {
			return Double.parseDouble(next());
		}
	}
}
Problem: 2057C - Trip to the Olympiad
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 1):
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<cmath>
#include<stack>
#include<queue>
#include<set>
//#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define N 500010
const ll INF = 1e18 + 10;
#define mod 998244353
//map<ll, ll>v;
ll n, maxn, k, m, q, p, pos;
ll a[N], b[N], c[N];
ll vis[N];
ll dis[N];
vector<ll>v;
ll sum, cnt;
struct node { int id, x; }nod[N];
bool cmp(node x, node y) { return x.x < y.x; }
ll num[3005][3005],f[3005][3005];
ll s[N];
map<ll, ll>mp;
void solve() {
	ll l, r;
	cin >> l >> r;
	k = __lg(l ^ r);
	ll x = (r >> k) << k, y = x - 1,z;
	if (y == l)z = x + 1;
	else z = x - 2;
	cout << x << " " << y << " " << z << '\n';
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	//	freopen("input.txt","r",stdin);
	//  freopen("output.txt","w",stdout);
	int t = 1;
	cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<cmath>
#include<stack>
#include<queue>
#include<set>
//#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define N 500010
const ll INF = 1e18 + 10;
#define mod 998244353
//map<ll, ll>v;
ll n, maxn, k, m, q, p, pos;
ll a[N], b[N], c[N];
ll vis[N];
ll dis[N];
vector<ll>v;
ll sum, cnt;
struct node { int id, x; }nod[N];
bool cmp(node x, node y) { return x.x < y.x; }
ll num[3005][3005],f[3005][3005];
ll s[N];
map<ll, ll>mp;
void solve() {
	ll l, r;
	cin >> l >> r;
	k = __lg(l ^ r);
	ll x = (r >> k) << k, y = x - 1,z;
	if (y == l)z = x + 1;
	else z = x - 2;
	cout << x << " " << y << " " << z << '\n';
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	//	freopen("input.txt","r",stdin);
	//  freopen("output.txt","w",stdout);
	int t = 1;
	cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}


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

#define ll long long
#define N 500010
const ll INF = 1e18 + 10;
#define mod 998244353
//map<ll, ll>v;
ll n, maxn, k, m, q, p, pos;
ll a[N], b[N], c[N];
ll vis[N];
ll dis[N];
vector<ll>v;
ll sum, cnt;
struct node { int id, x; }nod[N];
bool cmp(node x, node y) { return x.x < y.x; }
ll num[3005][3005],f[3005][3005];
ll s[N];
map<ll, ll>mp;
void solve() {
	ll l, r;
	cin >> l >> r;
	k = __lg(l ^ r);
	ll x = (r >> k) << k, y = x - 1,z;
	if (y == l)z = x + 1;
	else z = x - 2;
	cout << x << " " << y << " " << z << '\n';
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	//	freopen("input.txt","r",stdin);
	//  freopen("output.txt","w",stdout);
	int t = 1;
	cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}
Problem: 2063C - Remove Exactly Two
Language: C++17 (GCC 7-32)


Submission (verdict: Compilation error):
#include <iostream>


//#define endl '\n'
#define pi acos(-1)
#define euler_e 2.71828
#define pii pair<int,int>
#define pb push_back
#define all(a) a.begin(),a.end()
#define ll long long
#define ull unsigned long long
#define io freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define read freopen("input.txt","r",stdin);
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
void mycode();
const ll int infLL=(1LL<<62);
const ll mod=1e10;
ll int ceil(ll int a,ll int b){return (a+b-1)/b;}
ll int min(ll int a, ll int b){if(a>b)return b;else return a;}
bool bit_check(ll int a,int i){
  if((a & (1LL<<i)))return 1;
  return 0;
}
ll int bit_toggle(ll int a,int i){
  return (a^(1LL<<i));
}
ll int bit_sum(ll int a,int i){
  return a+(1LL<<i);
}
ll int bit_sub(ll int a,int i){
  return a-(1LL<<i);
}
ll mod_power(ll x,ll y, ll p=mod){//x^y%p
  ll res = 1;
  x = x % p;
  while (y > 0) { 
    if (y & 1)res = (res*x) % p;
    y = y>>1;x = (x*x) % p;
  }
  return res;
}
ll int power_of(ll int a,int b){
  if(a==0)return -1;
  return 1+power_of(a/b,b);
}
ll power(ll int a, ll int b) {
    if(a==1)return 1;
    ll int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
int main(){
    //io;
    boost;
    //read;
    //auto start = chrono::high_resolution_clock::now();
    mycode();
    //auto end = chrono::high_resolution_clock::now();cerr << "\nExecution time: "<< chrono::duration_cast<chrono::milliseconds>(end - start).count() << " ms" << endl;
    return 0;
}
#include <algorithm>
#include <set>
void mycode() {
    int t;
    cin>>t;
    while(t--){
        int n;
        cin>>n;
        pair<ll,int> arr[n+5];
        vector<int> vc[n+2];
        int x,y;
        for(int i=0;i<n-1;i++){
            cin>>x>>y;
            vc[x].push_back(y);
            vc[y].push_back(x);
        }
        for(int i=1;i<=n;i++){
            arr[i] = {vc[i].size(),i};
        }
        sort(arr,arr+n);
        ull ans = 0;
        for(int i=1;i<=n;i++){
            set<int> st;
            unsigned ll tmp = 0;
            st.insert(i);
            for(auto &x:vc[i]){
                st.insert(x);
                tmp = max(tmp,vc[i].size() + vc[x].size() - 2LL);
            }
            for(int j = n;j>0;j--){
                if(!st.count(arr[j].second)){
                    tmp = max(tmp,vc[i].size() + arr[j].first - 1LL);
                    break;
                }
            }
            ans = max(ans, tmp);
        }
        cout<<ans<<endl;
    }
}
Problem: 2050C - Uninteresting Number
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
void solve(){
	string s;
	cin>>s;
	int n = s.length();
	vector<vector<int>> dp(n+1,vector<int>(9,0));
	LL num = 0;
	if(s[0]-'0'==2){
		dp[0][2] = 1;
		dp[0][4] = 1;
	}
	else if(s[0]-'0'==3){
		dp[0][3] = 1;
		dp[0][0] = 1;
	}
	else{
		dp[0][s[0]-'0']=1;
	}
	for(int i=1;i<n;i++){
		if(s[i]=='2' || s[i]=='3'){
			for(int j=0;j<=8;j++){
				if(dp[i-1][j]){
					int num = j*10 + s[i] -'0';
					dp[i][num%9] = dp[i-1][j];
				}
			}
			for(int j=0;j<=8;j++){
				if(dp[i-1][j]){
					int num = j*10 + (s[i] -'0')* (s[i] -'0');
					dp[i][num%9] = dp[i-1][j];
				}
			}
		}
		else{
			for(int j=0;j<=8;j++){
			if(dp[i-1][j]){
				int num = j*10 + s[i] -'0';
				dp[i][num%9] = dp[i-1][j];
				}
			}
		}
	}
	// for(int i=0;i<n;i++){
	// 	for(int j=0;j<=9;j++){
	// 		cout<<dp[i][j]<<" ";
	// 	}
	// 	cout<<endl;
	// }
	if(dp[n-1][0]==1){
		cout<<"YES"<<endl;
	}
	else{
		cout<<"NO"<<endl;
	}
}
int main() { 
	int t;
	cin>>t;
	while(t--){
		solve();
	}
    return 0;
}


Submission (verdict: Accepted):
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
void solve(){
	string s;
	cin>>s;
	int n = s.length();
	vector<vector<int>> dp(n+1,vector<int>(9,0));
	LL num = 0;
	if(s[0]-'0'==2){
		dp[0][2] = 1;
		dp[0][4] = 1;
	}
	else if(s[0]-'0'==3){
		dp[0][3] = 1;
		dp[0][0] = 1;
	}
	else{
		dp[0][(s[0]-'0')%9]=1;
	}
	for(int i=1;i<n;i++){
		if(s[i]=='2' || s[i]=='3'){
			for(int j=0;j<=8;j++){
				if(dp[i-1][j]){
					int num = j*10 + s[i] -'0';
					dp[i][num%9] = dp[i-1][j];
				}
			}
			for(int j=0;j<=8;j++){
				if(dp[i-1][j]){
					int num = j*10 + (s[i] -'0')*(s[i] -'0');
					dp[i][num%9] = dp[i-1][j];
				}
			}
		}
		else{
			for(int j=0;j<=8;j++){
			if(dp[i-1][j]){
				int num = j*10 + s[i] -'0';
				dp[i][num%9] = dp[i-1][j];
				}
			}
		}
	}
	if(dp[n-1][0]==1){
		cout<<"YES"<<endl;
	}
	else{
		cout<<"NO"<<endl;
	}
}
int main() { 
	int t;
	cin>>t;
	while(t--){
		solve();
	}
    return 0;
}
Problem: 2050C - Uninteresting Number
Language: C++20 (GCC 13-64)


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
void solve(){
	string s;
	cin>>s;
	int n = s.length();
	vector<vector<int>> dp(n+1,vector<int>(11,0));
	LL num = 0;
	if(s[0]-'0'==2){
		dp[0][2] = 1;
		dp[0][4] = 1;
	}
	else if(s[0]-'0'==3){
		dp[0][3] = 1;
		dp[0][9] = 1;
	}
	else{
		dp[0][s[0]-'0']=1;
	}
	for(int i=1;i<s.length();i++){
		if(s[i]=='2' || s[i]=='3'){
			for(int j=0;j<=9;j++){
				if(dp[i-1][j]){
					int num = j*10 + s[i] -'0';
					dp[i][num%9] = dp[i-1][j];
				}
			}
			for(int j=0;j<=9;j++){
				if(dp[i-1][j]){
					int num = j*10 + (s[i] -'0')* (s[i] -'0');
					dp[i][num%9] = dp[i-1][j];
				}
			}
		}
		else{
			for(int j=0;j<=9;j++){
			if(dp[i-1][j]){
				int num = j*10 + s[i] -'0';
				dp[i][num%9] = dp[i-1][j];
				}
			}
		}
	}
	// for(int i=0;i<n;i++){
	// 	for(int j=0;j<=9;j++){
	// 		cout<<dp[i][j]<<" ";
	// 	}
	// 	cout<<endl;
	// }
	if(dp[n-1][0]==1){
		cout<<"YES"<<endl;
	}
	else{
		cout<<"NO"<<endl;
	}
}
int main() { 
	int t;
	cin>>t;
	while(t--){
		solve();
	}
    return 0;
}
Problem: 2050C - Uninteresting Number
Language: C++20 (GCC 13-64)

Previous submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
void solve(){
	string s;
	cin>>s;
	int n = s.length();
	vector<vector<int>> dp(n+1,vector<int>(11,0));
	LL num = 0;
	if(s[0]-'0'==2){
		dp[0][2] = 1;
		dp[0][4] = 1;
	}
	else if(s[0]-'0'==3){
		dp[0][3] = 1;
		dp[0][9] = 1;
	}
	else{
		dp[0][s[0]-'0']=1;
	}
	for(int i=1;i<s.length();i++){
		if(s[i]=='2' || s[i]=='3'){
			for(int j=0;j<=9;j++){
				if(dp[i-1][j]){
					int num = j*10 + s[i] -'0';
					dp[i][num%9] = dp[i-1][j];
				}
			}
			for(int j=0;j<=9;j++){
				if(dp[i-1][j]){
					int num = j*10 + (s[i] -'0')* (s[i] -'0');
					dp[i][num%9] = dp[i-1][j];
				}
			}
		}
		else{
			for(int j=0;j<=9;j++){
			if(dp[i-1][j]){
				int num = j*10 + s[i] -'0';
				dp[i][num%9] = dp[i-1][j];
				}
			}
		}
	}
	// for(int i=0;i<n;i++){
	// 	for(int j=0;j<=9;j++){
	// 		cout<<dp[i][j]<<" ";
	// 	}
	// 	cout<<endl;
	// }
	if(dp[n-1][0]==1){
		cout<<"YES"<<endl;
	}
	else{
		cout<<"NO"<<endl;
	}
}
int main() { 
	int t;
	cin>>t;
	while(t--){
		solve();
	}
    return 0;
}


Submission (verdict: Wrong answer on test 2):
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
void solve(){
	string s;
	cin>>s;
	int n = s.length();
	vector<vector<int>> dp(n+1,vector<int>(9,0));
	LL num = 0;
	if(s[0]-'0'==2){
		dp[0][2] = 1;
		dp[0][4] = 1;
	}
	else if(s[0]-'0'==3){
		dp[0][3] = 1;
		dp[0][0] = 1;
	}
	else{
		dp[0][s[0]-'0']=1;
	}
	for(int i=1;i<n;i++){
		if(s[i]=='2' || s[i]=='3'){
			for(int j=0;j<=8;j++){
				if(dp[i-1][j]){
					int num = j*10 + s[i] -'0';
					dp[i][num%9] = dp[i-1][j];
				}
			}
			for(int j=0;j<=8;j++){
				if(dp[i-1][j]){
					int num = j*10 + (s[i] -'0')* (s[i] -'0');
					dp[i][num%9] = dp[i-1][j];
				}
			}
		}
		else{
			for(int j=0;j<=8;j++){
			if(dp[i-1][j]){
				int num = j*10 + s[i] -'0';
				dp[i][num%9] = dp[i-1][j];
				}
			}
		}
	}
	// for(int i=0;i<n;i++){
	// 	for(int j=0;j<=9;j++){
	// 		cout<<dp[i][j]<<" ";
	// 	}
	// 	cout<<endl;
	// }
	if(dp[n-1][0]==1){
		cout<<"YES"<<endl;
	}
	else{
		cout<<"NO"<<endl;
	}
}
int 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 8):
#include <bits/stdc++.h>
using namespace std;
#define ll long long 

void input(vector<int>&a,int n){
  
  a.resize(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }

}
void printvec(vector<int>&a){
  for(auto num :a){
    cout<<num<<' ';
  }cout<<endl;
}

int main(){
   int test;
   cin>>test;
   while(test--){
    int n,l,r;
    cin>>n>>l>>r;
    vector<int>v(n);
    input(v,n);
    vector<int>b,c;
    r--;l--;
    for(int i=l;i<n;i++){
       b.push_back(v[i]);
    }
for(int i=0;i<=r;i++){
  c.push_back(v[i]);
}
sort(b.begin(),b.end());
sort(c.begin(),c.end());

ll sum1 = accumulate(b.begin(),b.begin()+(int)(r-l+1),0);
ll sum2 = accumulate(c.begin(),c.begin()+(int)(r-l+1),0);
cout<<min(sum1,sum2)<<endl;
    
    



}}


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

void input(vector<int>&a,int n){
  
  a.resize(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }

}
void printvec(vector<int>&a){
  for(auto num :a){
    cout<<num<<' ';
  }cout<<endl;
}

int main(){
   int test;
   cin>>test;
   while(test--){
    ll n,l,r;
    cin>>n>>l>>r;
    vector<ll>v(n);
    input(v,n);
    vector<ll>b,c;
    r--;l--;
    for(ll i=l;i<n;i++){
       b.push_back(v[i]);
    }
for(ll i=0;i<=r;i++){
  c.push_back(v[i]);
}
sort(b.begin(),b.end());
sort(c.begin(),c.end());

ll sum1 = accumulate(b.begin(),b.begin()+(int)(r-l+1),0);
ll sum2 = accumulate(c.begin(),c.begin()+(int)(r-l+1),0);
cout<<min(sum1,sum2) <<endl;
    
    



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

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

void input(vector<ll>&a,int n){
  
  a.resize(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }

}
void printvec(vector<int>&a){
  for(auto num :a){
    cout<<num<<' ';
  }cout<<endl;
}

int main(){
   int test;
   cin>>test;
   while(test--){
    ll n,l,r;
    cin>>n>>l>>r;
    vector<ll>v(n);
    input(v,n);
    vector<ll>b,c;
    r--;l--;
    for(ll i=l;i<n;i++){
       b.push_back(v[i]);
    }
for(ll i=0;i<=r;i++){
  c.push_back(v[i]);
}
sort(b.begin(),b.end());
sort(c.begin(),c.end());

ll sum1 = accumulate(b.begin(),b.begin()+(int)(r-l+1),0);
ll sum2 = accumulate(c.begin(),c.begin()+(int)(r-l+1),0);
cout<<min(sum1,sum2) <<endl;
    
    



}}


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

void input(vector<ll>&a,ll n){
  
  a.resize(n);
  for(ll i=0;i<n;i++){
    cin>>a[i];
  }

}
void printvec(vector<int>&a){
  for(auto num :a){
    cout<<num<<' ';
  }cout<<endl;
}

int main(){
   int test;
   cin>>test;
   while(test--){
    ll n,l,r;
    cin>>n>>l>>r;
    vector<ll>v(n);
    input(v,n);
    vector<ll>b,c;
    r--;l--;
    for(ll i=l;i<n;i++){
       b.push_back(v[i]);
    }
for(ll i=0;i<=r;i++){
  c.push_back(v[i]);
}
sort(b.begin(),b.end());
sort(c.begin(),c.end());

ll sum1 = accumulate(b.begin(),b.begin()+(int)(r-l+1),0LL);
ll sum2 = accumulate(c.begin(),c.begin()+(int)(r-l+1),0LL);
cout<<min(sum1,sum2) <<endl;
    
    



}}