Problem: 2061D - Kevin and Numbers
Language: C++20 (GCC 13-64)

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

using namespace std;



namespace {

#define L(i, j, k) for(int i = (j), _e = (k); i <= _e; ++i)

#define R(i, j, k) for(int i = (j), _e = (k); i >= _e; --i)

#define gc cin.get

#define pc cout.put

#define inl static inline

#define pr(x) (cerr << (x))

#define db(...) fprintf(stderr, __VA_ARGS__)

#define _assume(x) { if (!(x)) __builtin_unreachable(); }

	typedef long long ll; typedef unsigned un; typedef unsigned long long ull; typedef pair<int, int> pii;

	template<typename T = int> inl T read() { char c; while ((c = gc()) <= ' '); int f = (c != '-' ? 1 : (c = gc(), -1)); T a = c - '0'; while ((c = gc()) >= '0') a = a * 10 + c - '0'; return a * f; } template<typename T> inl void read(T & a) { a = read<T>(); } inl void read(char & c) { while ((c = gc()) <= ' '); } inl int rstr(char * s) { char * t = s; while ((*t = gc()) <= ' '); while ((*++t = gc()) > ' '); *t = '\0'; return t - s; } template<typename T, typename ... A> inl void read(T & a, A & ... args) { read(a), read(args...); } template<typename T> inl void putz(T x) { _assume(x >= 0); static char b[40]; int p = 0; do b[p++] = x % 10 + '0'; while (x /= 10); do pc(b[--p]); while (p); } template<typename T> inl void put(T x) { putz(x < 0 ? (pc('-'), -x) : x); } template<typename T, typename ... A> inl void put(T x, A ... args) { put(x), pc(' '), put(args...); } inl void putln() { pc('\n'); } template<typename ... A> inl void putln(A ... args) { put(args...), pc('\n'); } template<typename T> inl void out(const T & x) { pr(x); } template<typename T> inl void out(T b, T e) { T i = b; pr(*i); while (++i != e) pr(' '), pr(*i); } template<typename T_, typename T> inl void out(const T_ & s, T b, T e) { out(s), out(b, e); } inl void outln() { pr('\n'); } template<typename ... A> inl void outln(A ... args) { out(args...), pr('\n'); } inl	void ps(const char * s) { while (*s != '\0') pc(*s++); } inl void ps(const string & s) { ps(s.c_str()); } inl void yes() { ps("yes\n"); } inl void Yes() { ps("Yes\n"); } inl void YES() { ps("YES\n"); } inl void no() { ps("no\n"); } inl void No() { ps("No\n"); } inl void NO() { ps("NO\n"); }

}



constexpr int N = 2e5 + 5;

int n, m;

int a[N], b[N];



void solve() {

	read(n, m); ll s1 = 0, s2 = 0;

	 L(i, 1, n) read(a[i]), s1 += a[i];

	a[n + 1] = 0; sort(a + 1, a + n + 1);

	L(i, 1, m) read(b[i]), s2 += b[i];

	if (s1 != s2) return No();

	b[m + 1] = 0; sort(b + 1, b + m + 1);



	L(i, 1, m) {

		int p = lower_bound(a + 1, a + n + 1, b[i]) - a;

		if (a[p] == b[i]) a[p] = b[i] = 0;

	}



	int k = 1;

	L(i, 1, m) {

		if (b[i] == 0) continue;

		if (a[k] > b[i]) return No();

		ll s = a[k];

		while (k < n && (a[k + 1] == 0 || abs(a[k + 1] - a[k]) < 2 || abs(a[k + 1] - s) < 2)) {

			s += a[++k];

			if (s >= b[i]) break;

		}

		if (s == b[i]) ++k;

		else return No();

	}

	Yes();

}



int main() {

	ios::sync_with_stdio(false); cin.tie(0);

	int t = read(); while (t--) solve();

}

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

using namespace std;



namespace {

#define L(i, j, k) for(int i = (j), _e = (k); i <= _e; ++i)

#define R(i, j, k) for(int i = (j), _e = (k); i >= _e; --i)

#define gc cin.get

#define pc cout.put

#define inl static inline

#define pr(x) (cerr << (x))

#define db(...) fprintf(stderr, __VA_ARGS__)

#define _assume(x) { if (!(x)) __builtin_unreachable(); }

	typedef long long ll; typedef unsigned un; typedef unsigned long long ull; typedef pair<int, int> pii;

	template<typename T = int> inl T read() { char c; while ((c = gc()) <= ' '); int f = (c != '-' ? 1 : (c = gc(), -1)); T a = c - '0'; while ((c = gc()) >= '0') a = a * 10 + c - '0'; return a * f; } template<typename T> inl void read(T & a) { a = read<T>(); } inl void read(char & c) { while ((c = gc()) <= ' '); } inl int rstr(char * s) { char * t = s; while ((*t = gc()) <= ' '); while ((*++t = gc()) > ' '); *t = '\0'; return t - s; } template<typename T, typename ... A> inl void read(T & a, A & ... args) { read(a), read(args...); } template<typename T> inl void putz(T x) { _assume(x >= 0); static char b[40]; int p = 0; do b[p++] = x % 10 + '0'; while (x /= 10); do pc(b[--p]); while (p); } template<typename T> inl void put(T x) { putz(x < 0 ? (pc('-'), -x) : x); } template<typename T, typename ... A> inl void put(T x, A ... args) { put(x), pc(' '), put(args...); } inl void putln() { pc('\n'); } template<typename ... A> inl void putln(A ... args) { put(args...), pc('\n'); } template<typename T> inl void out(const T & x) { pr(x); } template<typename T> inl void out(T b, T e) { T i = b; pr(*i); while (++i != e) pr(' '), pr(*i); } template<typename T_, typename T> inl void out(const T_ & s, T b, T e) { out(s), out(b, e); } inl void outln() { pr('\n'); } template<typename ... A> inl void outln(A ... args) { out(args...), pr('\n'); } inl	void ps(const char * s) { while (*s != '\0') pc(*s++); } inl void ps(const string & s) { ps(s.c_str()); } inl void yes() { ps("yes\n"); } inl void Yes() { ps("Yes\n"); } inl void YES() { ps("YES\n"); } inl void no() { ps("no\n"); } inl void No() { ps("No\n"); } inl void NO() { ps("NO\n"); }

}



constexpr int N = 2e5 + 5;

int n, m;

int a[N], b[N];

multiset<int> st;



bool pd(int x) {

	auto p = st.find(x);

	if (p != st.end()) return st.erase(p), true;

	return x != 1 && pd(x / 2) && pd(x - x / 2);

}



void solve() {

	read(n, m); ll s1 = 0, s2 = 0;

	L(i, 1, n) read(a[i]), s1 += a[i];

	L(i, 1, m) read(b[i]), s2 += b[i];

	if (s1 != s2) return No();

	st.clear(); L(i, 1, n) st.insert(a[i]);

	L(i, 1, m) if (!pd(b[i])) return No();

	Yes();

}



int main() {

	ios::sync_with_stdio(false); cin.tie(0);

	int t = read(); while (t--) solve();

}