ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2063C - Remove Exactly Two
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
#define int long long
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
using namespace std;
const int N = 1e6 + 15, inf = 1e9 + 7, mod = 1e6;

const int I_LOVE_CCF = 1;

int n;
vector <int> g[N];
int du[N], vis[N], id; 

inline int read (int &n) {
	int x = 0, f = 1;
	char ch = getchar ();
	while (! isdigit (ch)) {
		if (ch == '-') f = -1;
		ch = getchar ();
	}
	while (isdigit (ch)) {
		x = (x << 1) + (x << 3) + (ch ^ 48);
		ch = getchar ();
	}
	n = x * f;
	return n;
}

void solve () {
	read (n);
	rep (i, 1, n) g[i].clear (), vis[i] = 0, du[i] = 0;
	rep (i, 1, n - 1) {
		int u, v;
		read (u), read (v);
		g[u].push_back (v);
		du[u] ++, du[v] ++;
	}
	vector <int> v;
	int maxx = 0, ans = 0;
	rep (i, 1, n) {
		maxx = max (maxx, du[i]);
	} 
	rep (i, 1, n) {
		if (du[i] == maxx) {
			v.push_back (i);
			vis[i] = 1;
		}
	}
	for (auto x : v) {
		int sum = 0;
		for (auto y : g[x]) {
			sum += vis[x];
		}
		if (sum <= 1) {
			id = x;
			break;
		}
	}
	ans += du[id];
	for (auto v : g[id]) du[v] --;
	du[id] = 0;
	maxx = 0;
	rep (i, 1, n) {
		if (du[i] > maxx) {
			maxx = du[i];
			id = i;
		}
	}
	ans += du[id];
	printf ("%lld\n", ans - 1);
}

signed main () {
	int t;
	read (t);
	while (t --) solve ();
	return 0;
}

Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
#define int long long
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
using namespace std;
const int N = 1e6 + 15, inf = 1e9 + 7, mod = 1e6;

const int I_LOVE_CCF = 1;

int n;
vector <int> g[N];
int du[N], vis[N], id; 

inline int read (int &n) {
	int x = 0, f = 1;
	char ch = getchar ();
	while (! isdigit (ch)) {
		if (ch == '-') f = -1;
		ch = getchar ();
	}
	while (isdigit (ch)) {
		x = (x << 1) + (x << 3) + (ch ^ 48);
		ch = getchar ();
	}
	n = x * f;
	return n;
}

void solve () {
	read (n);
	rep (i, 1, n) g[i].clear (), vis[i] = 0, du[i] = 0;
	rep (i, 1, n - 1) {
		int u, v;
		read (u), read (v);
		g[u].push_back (v);
		g[v].push_back (u);
		du[u] ++, du[v] ++;
	}
	vector <int> v;
	int maxx = 0, ans = 0;
	rep (i, 1, n) {
		maxx = max (maxx, du[i]);
	} 
	rep (i, 1, n) {
		if (du[i] == maxx) {
			v.push_back (i);
			vis[i] = 1;
		}
	}
	for (auto x : v) {
		int sum = 0;
		for (auto y : g[x]) {
			sum += vis[x];
		}
		if (sum <= 1) {
			id = x;
			break;
		}
	}
	ans += du[id];
	for (auto v : g[id]) du[v] --;
	du[id] = 0;
	maxx = 0;
	rep (i, 1, n) {
		if (du[i] > maxx) {
			maxx = du[i];
			id = i;
		}
	}
	ans += du[id];
	printf ("%lld\n", ans - 1);
}

signed main () {
	int t;
	read (t);
	while (t --) solve ();
	return 0;
}
Problem: 2063C - Remove Exactly Two
Language: C++23 (GCC 14-64, msys2)


Submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
#define int long long
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
using namespace std;
const int N = 1e6 + 15, inf = 1e9 + 7, mod = 1e6;

const int I_LOVE_CCF = 1;

int n;
vector <int> g[N];
int du[N], vis[N], id; 

inline int read (int &n) {
	int x = 0, f = 1;
	char ch = getchar ();
	while (! isdigit (ch)) {
		if (ch == '-') f = -1;
		ch = getchar ();
	}
	while (isdigit (ch)) {
		x = (x << 1) + (x << 3) + (ch ^ 48);
		ch = getchar ();
	}
	n = x * f;
	return n;
}

void solve () {
	read (n);
	rep (i, 1, n) g[i].clear (), vis[i] = 0, du[i] = 0;
	rep (i, 1, n - 1) {
		int u, v;
		read (u), read (v);
		g[u].push_back (v);
		du[u] ++, du[v] ++;
	}
	vector <int> v;
	int maxx = 0, ans = 0;
	rep (i, 1, n) {
		maxx = max (maxx, du[i]);
	} 
	rep (i, 1, n) {
		if (du[i] == maxx) {
			v.push_back (i);
			vis[i] = 1;
		}
	}
	for (auto x : v) {
		int sum = 0;
		for (auto y : g[x]) {
			sum += vis[x];
		}
		if (sum <= 1) {
			id = x;
			break;
		}
	}
	ans += du[id];
	for (auto v : g[id]) du[v] --;
	du[id] = 0;
	maxx = 0;
	rep (i, 1, n) {
		if (du[i] > maxx) {
			maxx = du[i];
			id = i;
		}
	}
	ans += du[id];
	printf ("%lld\n", ans - 1);
}

signed main () {
	int t;
	read (t);
	while (t --) solve ();
	return 0;
}
Problem: 2063C - Remove Exactly Two
Language: C++23 (GCC 14-64, msys2)

Previous submission (verdict: Wrong answer on test 2):
#include<bits/stdc++.h>
#define int long long
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
using namespace std;
const int N = 1e6 + 15, inf = 1e9 + 7, mod = 1e6;

const int I_LOVE_CCF = 1;

int n;
vector <int> g[N];
int du[N], vis[N], id; 

inline int read (int &n) {
	int x = 0, f = 1;
	char ch = getchar ();
	while (! isdigit (ch)) {
		if (ch == '-') f = -1;
		ch = getchar ();
	}
	while (isdigit (ch)) {
		x = (x << 1) + (x << 3) + (ch ^ 48);
		ch = getchar ();
	}
	n = x * f;
	return n;
}

void solve () {
	read (n);
	rep (i, 1, n) g[i].clear (), vis[i] = 0, du[i] = 0;
	rep (i, 1, n - 1) {
		int u, v;
		read (u), read (v);
		g[u].push_back (v);
		g[v].push_back (u);
		du[u] ++, du[v] ++;
	}
	vector <int> v;
	int maxx = 0, ans = 0;
	rep (i, 1, n) {
		maxx = max (maxx, du[i]);
	} 
	rep (i, 1, n) {
		if (du[i] == maxx) {
			v.push_back (i);
			vis[i] = 1;
		}
	}
	for (auto x : v) {
		int sum = 0;
		for (auto y : g[x]) {
			sum += vis[x];
		}
		if (sum <= 1) {
			id = x;
			break;
		}
	}
	ans += du[id];
	for (auto v : g[id]) du[v] --;
	du[id] = 0;
	maxx = 0;
	rep (i, 1, n) {
		if (du[i] > maxx) {
			maxx = du[i];
			id = i;
		}
	}
	ans += du[id];
	printf ("%lld\n", ans - 1);
}

signed main () {
	int t;
	read (t);
	while (t --) solve ();
	return 0;
}

Submission (verdict: Accepted):
#include<bits/stdc++.h>
#define int long long
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
using namespace std;
const int N = 1e6 + 15, inf = 1e9 + 7, mod = 1e6;

const int I_LOVE_CCF = 1;

int n;
vector <int> g[N];
int du[N], vis[N], id; 

inline int read (int &n) {
	int x = 0, f = 1;
	char ch = getchar ();
	while (! isdigit (ch)) {
		if (ch == '-') f = -1;
		ch = getchar ();
	}
	while (isdigit (ch)) {
		x = (x << 1) + (x << 3) + (ch ^ 48);
		ch = getchar ();
	}
	n = x * f;
	return n;
}

void solve () {
	read (n);
	rep (i, 1, n) g[i].clear (), vis[i] = 0, du[i] = 0;
	rep (i, 1, n - 1) {
		int u, v;
		read (u), read (v);
		g[u].push_back (v);
		g[v].push_back (u);
		du[u] ++, du[v] ++;
	}
	vector <int> v;
	int maxx = 0, ans = 0;
	rep (i, 1, n) {
		maxx = max (maxx, du[i]);
	} 
	rep (i, 1, n) {
		if (du[i] == maxx) {
			v.push_back (i);
			vis[i] = 1;
		}
	}
	for (auto x : v) {
		int sum = 0;
		for (auto y : g[x]) {
			sum += vis[y];
		}
		if (sum <= 1) {
			id = x;
			break;
		}
	}
	ans += du[id];
	for (auto v : g[id]) du[v] --;
	du[id] = 0;
	maxx = 0;
	rep (i, 1, n) {
		if (du[i] > maxx) {
			maxx = du[i];
			id = i;
		}
	}
	ans += du[id];
	printf ("%lld\n", ans - 1);
}

signed main () {
	int t;
	read (t);
	while (t --) solve ();
	return 0;
}
Problem: 2057C - Trip to the Olympiad
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 1):
/*
lavanyagpt28
*/

#include <bits/stdc++.h>
 //#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("O3")

using namespace std;
//using namespace __gnu_pbds;

/*template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using MinPriorityQueue = priority_queue <T, vector <T>, greater <T>>;/*

/*#ifdef HOME
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
    cout << name << " : " << arg1 << std :: endl;
}
template < typename Arg1, typename... Args >
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    int len = comma - names;
    for (int i = 0; i < len; ++i) {
        cout << names[i];
    }
    cout <<  " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
#else
#define trace(...)
#endif*/

typedef double db;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef complex<double> com;

#define eb emplace_back
#define pb push_back
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define unique_sort(x) (sort(x.begin(), x.end()), x.resize(distance(x.begin(), unique(x.begin(), x.end()))))
#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)

const ll LINF = LLONG_MAX, SZ = 1e3, MOD = 1e9 + 7, N = 1e5 + 5, M = 1e3 + 5, LG = 21;
const int INF = INT_MAX;
const db PI = acos(-1), EPS = 1e-6;
//mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());

void test() {
    int l, r;
    cin >> l >> r;
    // find the first bit where l and r differ
    int k = -1;
    for(int i = 30; i >= 0; i--){
        int bit1 = (l >> i) & 1;
        int bit2 = (r >> i) & 1;
        if(bit1 != bit2){
            k = i;
            break;
        }
    }
    int first = (1 << k);
    int second = first - 1;
    int third;
    if(second - 1 >= l){
        third = second-1;
    }
    else{
        third = first + 1;
    }
    cout << first << " " << second << " " << third << endl;
}

int main() {
    fast_io();
   // #ifdef HOME
 //       freopen("input.txt", "r", stdin);
   //     freopen("output.txt", "w", stdout);
  //  #endif
//    cout << fixed << setprecision(15);
    int t = 1;
    cin >> t;
    for (int i = 0; i < t; ++i) {
        test();
    }
 //   #ifdef HOME
 //       cout << "Time: " << (int)(clock() * 1000. / CLOCKS_PER_SEC) << "ms";
//    #endif
    return 0;
}
Problem: 2050E - Three Strings
Language: C++17 (GCC 7-32)

Previous submission (verdict: Memory limit exceeded on test 14):
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

// Recursive function with memoization
int solve(int i, int j, int k, const string &a, const string &b, const string &c, vector<vector<vector<int>>> &dp) {
    if (k == c.size()) return 0; // Base case: all characters of c are processed

    if (dp[i][j][k] != -1) return dp[i][j][k]; // Return memoized value

    int changes = 1e9; // Large value to minimize

    // Option 1: Take from string a
    if (i < a.size()) {
        int ch = (a[i] != c[k]) ? 1 : 0; // Increment change if character doesn't match
        changes = solve(i + 1, j, k + 1, a, b, c, dp) + ch;
    }

    // Option 2: Take from string b
    if (j < b.size()) {
        int ch = (b[j] != c[k]) ? 1 : 0; // Increment change if character doesn't match
        changes = min(changes, solve(i, j + 1, k + 1, a, b, c, dp) + ch);
    }

    return dp[i][j][k] = changes; // Memoize the result
}

int main() {
    int t;
    cin >> t;
    while (t--) {
        string a, b, c;
        cin >> a >> b >> c;

        int n = a.size(), m = b.size();
        // Initialize a 3D memoization table
        vector<vector<vector<int>>> dp(n + 1, vector<vector<int>>(m + 1, vector<int>(c.size() + 1, -1)));

        // Start recursive calculation from the beginning of all strings
        cout << solve(0, 0, 0, a, b, c, dp) << endl;
    }
    return 0;
}


Submission (verdict: Accepted):
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

// Recursive function with a 2D DP table
int solve(int i, int j, const string &a, const string &b, const string &c, vector<vector<int>> &dp) {
    int k = i + j; // Index in c
    if (k == c.size()) return 0; // Base case: all characters of c are processed

    if (dp[i][j] != -1) return dp[i][j]; // Return already computed value

    int changes = 1e9;

    // Option 1: Take from string a
    if (i < a.size()) {
        int ch = (a[i] != c[k]) ? 1 : 0; // Increment change if character doesn't match
        changes = solve(i + 1, j, a, b, c, dp) + ch;
    }

    // Option 2: Take from string b
    if (j < b.size()) {
        int ch = (b[j] != c[k]) ? 1 : 0; // Increment change if character doesn't match
        changes = min(changes, solve(i, j + 1, a, b, c, dp) + ch);
    }

    return dp[i][j] = changes; // Memoize the result
}

int main() {
    int t;
    cin >> t;
    while (t--) {
        string a, b, c;
        cin >> a >> b >> c;

        int n = a.size(), m = b.size();
        // Initialize a 2D memoization table
        vector<vector<int>> dp(n + 1, vector<int>(m + 1, -1));

        // Start recursive calculation from the beginning of all strings
        cout << solve(0, 0, a, b, c, dp) << endl;
    }
    return 0;
}
Problem: 2050E - Three Strings
Language: C++17 (GCC 7-32)

Previous submission (verdict: Wrong answer on test 1):
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

// Recursive function with memoization
int solve(int i, int j, int k, const string &a, const string &b, const string &c, vector<vector<vector<int>>> &dp) {
    if (k == c.size()) return 0; // Base case: no characters left in c
    if (dp[i][j][k] != -1) return dp[i][j][k]; // Return already computed value

    int changes = 1e9; // Initialize changes to a large number
    if (i < a.size() && a[i] == c[k]) {
        changes = solve(i + 1, j, k + 1, a, b, c, dp); // Take character from a
    }
    if (j < b.size() && b[j] == c[k]) {
        changes = min(changes, solve(i, j + 1, k + 1, a, b, c, dp)); // Take character from b
    }
    // Neither a[i] nor b[j] matches c[k]
    changes = min(changes, 1 + solve(i, j, k + 1, a, b, c, dp));

    return dp[i][j][k] = changes; // Store the result in the memoization table
}

int main() {
    int t;
    cin >> t;
    while (t--) {
        string a, b, c;
        cin >> a >> b >> c;
        int n = a.size(), m = b.size();
        // Memoization table: dp[i][j][k], where i and j are indices in a and b, k is index in c
        vector<vector<vector<int>>> dp(n + 1, vector<vector<int>>(m + 1, vector<int>(c.size() + 1, -1)));
        cout << solve(0, 0, 0, a, b, c, dp) << endl;
    }
    return 0;
}


Submission (verdict: Memory limit exceeded on test 14):
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

// Recursive function with memoization
int solve(int i, int j, int k, const string &a, const string &b, const string &c, vector<vector<vector<int>>> &dp) {
    if (k == c.size()) return 0; // Base case: all characters of c are processed

    if (dp[i][j][k] != -1) return dp[i][j][k]; // Return memoized value

    int changes = 1e9; // Large value to minimize

    // Option 1: Take from string a
    if (i < a.size()) {
        int ch = (a[i] != c[k]) ? 1 : 0; // Increment change if character doesn't match
        changes = solve(i + 1, j, k + 1, a, b, c, dp) + ch;
    }

    // Option 2: Take from string b
    if (j < b.size()) {
        int ch = (b[j] != c[k]) ? 1 : 0; // Increment change if character doesn't match
        changes = min(changes, solve(i, j + 1, k + 1, a, b, c, dp) + ch);
    }

    return dp[i][j][k] = changes; // Memoize the result
}

int main() {
    int t;
    cin >> t;
    while (t--) {
        string a, b, c;
        cin >> a >> b >> c;

        int n = a.size(), m = b.size();
        // Initialize a 3D memoization table
        vector<vector<vector<int>>> dp(n + 1, vector<vector<int>>(m + 1, vector<int>(c.size() + 1, -1)));

        // Start recursive calculation from the beginning of all strings
        cout << solve(0, 0, 0, a, b, c, dp) << endl;
    }
    return 0;
}
Problem: 2050E - Three Strings
Language: C++17 (GCC 7-32)


Submission (verdict: Wrong answer on test 1):
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

// Recursive function with memoization
int solve(int i, int j, int k, const string &a, const string &b, const string &c, vector<vector<vector<int>>> &dp) {
    if (k == c.size()) return 0; // Base case: no characters left in c
    if (dp[i][j][k] != -1) return dp[i][j][k]; // Return already computed value

    int changes = 1e9; // Initialize changes to a large number
    if (i < a.size() && a[i] == c[k]) {
        changes = solve(i + 1, j, k + 1, a, b, c, dp); // Take character from a
    }
    if (j < b.size() && b[j] == c[k]) {
        changes = min(changes, solve(i, j + 1, k + 1, a, b, c, dp)); // Take character from b
    }
    // Neither a[i] nor b[j] matches c[k]
    changes = min(changes, 1 + solve(i, j, k + 1, a, b, c, dp));

    return dp[i][j][k] = changes; // Store the result in the memoization table
}

int main() {
    int t;
    cin >> t;
    while (t--) {
        string a, b, c;
        cin >> a >> b >> c;
        int n = a.size(), m = b.size();
        // Memoization table: dp[i][j][k], where i and j are indices in a and b, k is index in c
        vector<vector<vector<int>>> dp(n + 1, vector<vector<int>>(m + 1, vector<int>(c.size() + 1, -1)));
        cout << solve(0, 0, 0, a, b, c, dp) << endl;
    }
    return 0;
}
Problem: 2061D - Kevin and Numbers
Language: C++17 (GCC 7-32)


Submission (verdict: Time limit exceeded on test 28):
#include<iostream>

#include<unordered_map>

using namespace std;

#define INF 2147483647

int t,n,m,a,minv;

unordered_map<int,int>mp;

bool solve(int x)

{

    if(x<minv)return false;

    else if(mp[x])

    {

        mp[x]--;

        return true;

    }

    else if(x<=1)return false;

    else return solve(x/2)&&solve((x+1)/2);

}

int main()

{

    scanf("%d",&t);

    while(t--)

    {

        mp.clear();

        scanf("%d%d",&n,&m);

        minv=INF;

        long long cnt=0;

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

        {

            scanf("%d",&a);

            minv=min(minv,a);

            mp[a]++;

            cnt+=a;

        }

        bool flag=true;

        for(int i=0;i<m;i++)

        {

            scanf("%d",&a);

            cnt-=a;

            if(flag&&!solve(a))flag=false;

        }

        if(flag&&!cnt)printf("Yes\n");

        else printf("No\n");

    }

    return 0;

}
Problem: 2061D - Kevin and Numbers
Language: C++17 (GCC 7-32)

Previous submission (verdict: Time limit exceeded on test 28):
#include<iostream>

#include<unordered_map>

using namespace std;

#define INF 2147483647

int t,n,m,a;

unordered_map<int,int>mp;

bool solve(int x)

{

    if(mp[x])

    {

        mp[x]--;

        return true;

    }

    else if(!x)return false;

    else return solve(x/2)&&solve((x+1)/2);

}

int main()

{

    scanf("%d",&t);

    while(t--)

    {

        mp.clear();

        scanf("%d%d",&n,&m);

        long long cnt=0;

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

        {

            scanf("%d",&a);

            mp[a]++;

            cnt+=a;

        }

        bool flag=true;

        for(int i=0;i<m;i++)

        {

            scanf("%d",&a);

            cnt-=a;

            if(flag&&!solve(a))flag=false;

        }

        if(flag&&!cnt)printf("Yes\n");

        else printf("No\n");

    }

    return 0;

}

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

#include<map>

using namespace std;

int t,n,m,a;

map<int,int>mp;

bool solve(int x)

{

    if(mp[x])

    {

        mp[x]--;

        return true;

    }

    else if(!x)return false;

    else return solve(x/2)&&solve((x+1)/2);

}

int main()

{

    scanf("%d",&t);

    while(t--)

    {

        mp.clear();

        scanf("%d%d",&n,&m);

        long long cnt=0;

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

        {

            scanf("%d",&a);

            mp[a]++;

            cnt+=a;

        }

        bool flag=true;

        for(int i=0;i<m;i++)

        {

            scanf("%d",&a);

            cnt-=a;

            if(flag&&!solve(a))flag=false;

        }

        if(flag&&!cnt)printf("Yes\n");

        else printf("No\n");

    }

    return 0;

}
Problem: 2061D - Kevin and Numbers
Language: C++17 (GCC 7-32)

Previous submission (verdict: Time limit exceeded on test 28):
#include<iostream>

#include<unordered_map>

using namespace std;

#define INF 2147483647

int t,n,m,a,minv;

unordered_map<int,int>mp;

bool solve(int x)

{

    if(x<minv)return false;

    else if(mp[x])

    {

        mp[x]--;

        return true;

    }

    else if(x<=1)return false;

    else return solve(x/2)&&solve((x+1)/2);

}

int main()

{

    scanf("%d",&t);

    while(t--)

    {

        mp.clear();

        scanf("%d%d",&n,&m);

        minv=INF;

        long long cnt=0;

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

        {

            scanf("%d",&a);

            minv=min(minv,a);

            mp[a]++;

            cnt+=a;

        }

        bool flag=true;

        for(int i=0;i<m;i++)

        {

            scanf("%d",&a);

            cnt-=a;

            if(flag&&!solve(a))flag=false;

        }

        if(flag&&!cnt)printf("Yes\n");

        else printf("No\n");

    }

    return 0;

}

Submission (verdict: Time limit exceeded on test 28):
#include<iostream>

#include<unordered_map>

using namespace std;

#define INF 2147483647

int t,n,m,a;

unordered_map<int,int>mp;

bool solve(int x)

{

    if(mp[x])

    {

        mp[x]--;

        return true;

    }

    else if(!x)return false;

    else return solve(x/2)&&solve((x+1)/2);

}

int main()

{

    scanf("%d",&t);

    while(t--)

    {

        mp.clear();

        scanf("%d%d",&n,&m);

        long long cnt=0;

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

        {

            scanf("%d",&a);

            mp[a]++;

            cnt+=a;

        }

        bool flag=true;

        for(int i=0;i<m;i++)

        {

            scanf("%d",&a);

            cnt-=a;

            if(flag&&!solve(a))flag=false;

        }

        if(flag&&!cnt)printf("Yes\n");

        else printf("No\n");

    }

    return 0;

}
Problem: 2050C - Uninteresting Number
Language: PyPy 3-64

Previous submission (verdict: Runtime error on test 4):
t=int(input())
for z in range(t):
    n=int(input())
    a=[0,0]
    num=0
    while n!=0:
        if n%10!=2 and n%10!=3:
            num=(num+n%10)%9
            n=n//10
        else:
            if n%10!=3:
                a[0]+=1
                num=(num+n%10)%9
            else:
                a[1]+=1
                num=(num+n%10)%9
            n=n//10
    flag=False
    for i in range(min(10,a[0]+1)):
        if not flag:
            for j in range(min(10,a[1]+1)):
                if (num+2*i+6*j)%9==0:
                    print('YES')
                    flag=True
                    break
        else:
            break
    if not flag:
        print('NO')

Submission (verdict: Accepted):
t=int(input())
for z in range(t):
    n=[int(i) for i in list(input())]
    a=[0,0]
    num=sum(n)
    a[0]=n.count(2)
    a[1]=n.count(3)
    flag=False
    for i in range(min(10,a[0]+1)):
        if not flag:
            for j in range(min(10,a[1]+1)):
                if (num+2*i+6*j)%9==0:
                    print('YES')
                    flag=True
                    break
        else:
            break
    if not flag:
        print('NO')
Problem: 2050C - Uninteresting Number
Language: PyPy 3-64


Submission (verdict: Runtime error on test 4):
t=int(input())
for z in range(t):
    n=int(input())
    a=[0,0]
    num=0
    while n!=0:
        if n%10!=2 and n%10!=3:
            num=(num+n%10)%9
            n=n//10
        else:
            if n%10!=3:
                a[0]+=1
                num=(num+n%10)%9
            else:
                a[1]+=1
                num=(num+n%10)%9
            n=n//10
    flag=False
    for i in range(a[0]+1):
        if not flag:
            for j in range(a[1]+1):
                if (num+2*i+6*j)%9==0:
                    print('YES')
                    flag=True
                    break
        else:
            break
    if not flag:
        print('NO')