This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define ll int
#define F first
#define S second
#define ull unsigned long long
#define db double
#define ldb long double
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
#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 int mod = 1e9 + 7;
const int N = 20001;
using namespace std;
using namespace __gnu_pbds;
ll n, m, k, p[N], f[N], a, b, ans, used[N];
vector <ll> v, q;
void rec (ll id, vector <ll> v){
	if (id == n + 1){
		cout << "YES";
		exit (0);
	}
	if (v.size() == 0){
		return;
	}
	a = 0;
	for (auto i: v){
		a += i;
	}
	if (a < p[id]){
		return;
	}
	for (int i = 1; i < (1 << v.size()); i++){
		a = 0;
//		cout << i << ' ';
		for (int y = 0; y < v.size(); y++){
			used[y] = 0;
			if ((i >> y) & 1){
				a += v[y];
				used[y] = 1;
			}
//			cout << (/(i << y) & 1) << ' ' << y << ' ' << a << '\n';
		}
//		cout << '\n';
		if (a == p[id]){
			q.clear();
			for (int y = 0; y < v.size(); y++){
				if (used[y] == 0){
					q.pb (v[y]);
				}
			}
			rec (id + 1, q);
		}
	}
}
signed main (){
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin >> n >> m;
	for (int i = 1; i <= n; i++){
		cin >> p[i];
	}
	for (int i = 1; i <= m; i++){
		cin >> f[i];
		v.pb (f[i]);
	}
//	for (int i = 1; i <= 20; i++){
//		for (int y = 5; y >= 0; y--){
//			if ((i))
//		}
//	}
	rec (1,v);
	cout << "NO";
}
Compilation message (stderr)
bank.cpp: In function 'void rec(int, std::vector<int>)':
bank.cpp:47:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |   for (int y = 0; y < v.size(); y++){
      |                   ~~^~~~~~~~~~
bank.cpp:58:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |    for (int y = 0; y < v.size(); y++){
      |                    ~~^~~~~~~~~~| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... |