http://vinhdinhcoder.net/Problem/Details/5005
#include <bits/stdc++.h>
using namespace std;
int n;
long long tw=0,cs[33],a[33],m;
void tim(int k)
{
if(tw==m){
cout<<"YES";
exit(0);
}
for(int i=1;i<=n;i++)if(tw+a[i]<=m&&i>cs[k-1])
{
tw=tw+a[i];
cs[k]=i;
tim(k+1);
tw=tw-a[i];
}
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
#ifndef ONLINE_JUDGE
freopen("a.inp","r",stdin);
freopen("a.out","w",stdout);
#endif
cin>>n>>m;
for(int i=1;i<=n;i++)cin>>a[i];
cs[0]=0;
tim(1);
if(tw!=m)cout<<"NO";
return 0;
}