Hey everyone, so initially I thought it may be an issue of int/ll boundaries so I changed all to ll just to be safe and see if that would solve the issue, but got stuck at the same point i.e. at around the 20/21st test. If you could please point out what I must be missing, I’d appreciate that.
Thanks in advance 
#include
#define ll long long
using namespace std;
int main()
{
ll N,K;
cin>>N>>K;
ll set [K]; //set of K elements
int i=0;
while(i<K){
cin>>set [i];i++;
}
/*
now we'll create a program to determine how many elements in a set of
integers from 1 to n inclusive are not divisible by any of the elements of
the set 'set'.
*/
ll subsets = (1<<K)-1; //number of subsets of the numbers we'll use as divisors
ll dem=1ll,ans=0; //defining the dem as just ll dem = 1 may cause issues, better use ll dem = 1ll
//i'm guessing even if declared as ll, 1 is still stored as int, so 1ll is necessary
for (ll i=1;i<=subsets;i++){
ll setBits = __builtin_popcount(i); //count number of 1s in the ith subset (this tells you what set is included in the subset)
for (ll k=0;k<K;k++)
if (i & (1<<k)) dem*=set[k];
if (setBits%2==0) ans-=N/dem;
else ans+=N/dem;
}
cout<<N-ans;
return 0;
}