#include <iostream>
#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;
int help(int i,int money,int denomination[]){
    int sum=0;
    int j=0;
    while(i>0){
        if(i&1) sum+=denomination[j];
        i=i>>1;
        j+=1;
    }
    return sum==money?1:0;
}
int ans(int numOfNotes,int money,int denomination[]){
    for(int i=0;i<(1<<numOfNotes);i++){
        if(help(i,money,denomination)){
            return 1;
        }
    }
    return 0;
}  
int main() {
    int testCases,numOfNotes,money;
    cin>>testCases;
    while(testCases>0){
        cin>>numOfNotes>>money;
        int denomination[numOfNotes];
        int i=0;
        while(numOfNotes){
            cin>>denomination[i];
            i++;
            numOfNotes--;
        }
        testCases--;
        ans(numOfNotes,money,denomination)==1?cout<<"Yes"<<endl:cout<<"No"<<endl;
    }
    return 0;
}
If there exists a subset of array denomination such that it amounts to money, program should show "Yes", else "No". 
But for the following simple input
1
3 3
1
1
1
output is coming out to be
No
whereas it should be
Yes
According to me, the for and while loops are not working in the ans and help functions. Is there any other bug in the program?
 
    