Problem:
Zero AND Subsets
非負整数の多重集合
a_1,a_2,..,a_N
が与えられます。
この集合の空でない部分集合であって、値のbitwiseANDが
0
になるものはいくつありますか。
答えを
10^9+7
で割った余りを求めてください。
入力
N
a_1 a_2...a_N
出力
答えを
10^9+7
で割った余りを出力せよ。
制約
1 \leq N \leq 10^5
0 \leq a_i \leq 2^{20}-1
入力例
6
8 6 9 1 2 1
出力例
51

Submitted solutions:

code_snippet: // AOJ #3119
// Zero AND Subsets 2025.2.3

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)

int Cin() {  // 整数の入力
	int n = 0, c = gc();
	if (c == '-') {	c = gc();
		do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
		return -n;
	}
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

void Cout(int n) { // 整数の表示（出力）
	char b[30];
	if (!n) pc('0');
	else {
		if (n < 0) pc('-'), n = -n;
		int i = 0; while (n) b[i++] = n % 10 + '0', n /= 10;
		while (i--) pc(b[i]);
	}
	pc('\n');
}

const int MOD = 1000000007;

// 素朴な方法で前計算。N の最大値は 1e5 なので十分。
int main() {
    int N = Cin();
    const int BITS = 20;
    const int SIZE = 1 << BITS;
    
    vector<int> freq(SIZE, 0);
    for (int i = 0; i < N; i++){
        int a = Cin();
        freq[a]++;
    }
    
    // F[mask] = 元の多重集合の中で、mask のビットすべてが1である数の個数
    vector<int> F(freq);
    for (int i = 0; i < BITS; i++){
        for (int mask = 0; mask < SIZE; mask++){
            if (!(mask & (1 << i))){
                F[mask] += F[mask | (1 << i)];
            }
        }
    }
    
    // 2^x の値を x=0...N まで前計算 (x は F[mask] の最大値は N)
    vector<ll> p2(N+1, 1);
    for (int i = 1; i <= N; i++){
        p2[i] = (p2[i-1] * 2LL) % MOD;
    }
    
    // 包除原理で答えを計算
    ll ans = 0;
    for (int mask = 0; mask < SIZE; mask++){
        int bits = __builtin_popcount(mask);
        ll term = (p2[F[mask]] - 1 + MOD) % MOD;
        if (bits % 2 == 1) ans = (ans - term + MOD) % MOD;
        else               ans = (ans + term) % MOD;
    }
    Cout((int)(ans % MOD));
    return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 12152
final_rank: 7

code_snippet: #include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
// find_by_order    ->return set[x]
// order_of_key     ->return index of first occ of x
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> omset;
#define int long long
#define endl '\n'
#define pi pair<int,int>
#define adjs(name, type, size) vector<vector<type>>name(size)
#define adjpass(name, type) vector<vector<type>>&name
#define rest(name, val) memset(name,val,sizeof(name))
#define all(x) x.begin(),x.end()
#define killua ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(0)
//changes in dir:
int dx[] = {0, 0, 1, -1, -1, 1, -1, 1};
int dy[] = {1, -1, 0, 0, 1, 1, -1, -1};
int cases = 0;
constexpr int mod = 1000000007;

/***إِلا أَنْ يَشَاءَ اللَّهُ وَاذْكُرْ رَبَّكَ إِذَا نَسِيتَ وَقُلْ عَسَى أَنْ يَهْدِيَنِي رَبِّي لأَقْرَبَ مِنْ هَذَا رَشَدًا ***/
long long modpow(long long a, long long b) {
    long long ans = 1;
    while (b) {
        if (b & 1) {
            (ans *= a) %= mod;
        }
        (a *= a) %= mod;
        b /= 2;
    }
    return ans;
}

mt19937 random_seed(time(0));

long long rnd(long long l, long long r) {
    if (l > r) throw invalid_argument("parameters is invalid");
    uniform_int_distribution<long long> dist(l, r);
    return dist(random_seed);
}

int countSubsetsWithBitwiseAndZero(int N, int A[]) {
    vector<int> b(1 << 20);
    for (int i = 0; i < N; i++) {
        b[A[i]]++;
    }
    for (int i = 0; i < 20; i++) {
        for (int j = 0; j < (1 << 20); j++) {
            if (1 & (j >> i)) {
                b[j ^ (1 << i)] += b[j];
            }
        }
    }
    for (int i = 0; i < (1 << 20); i++) {
        b[i] = modpow(2, b[i]) - 1;
    }
    for (int i = 0; i < 20; i++) {
        for (int j = 0; j < (1 << 20); j++) {
            if (1 & (j >> i)) {
                b[j ^ (1 << i)] += mod - b[j];
                if (b[j ^ (1 << i)] >= mod) b[j ^ (1 << i)] -= mod;
            }
        }
    }
    return b[0];
}

void gon() {
    int N;
    cin >> N;
    int arr[N];
    for (auto &i: arr) cin >> i;
    cout << countSubsetsWithBitwiseAndZero(N, arr) << endl;
}

int32_t main() {
    killua;
    int t = 1;
    if (cases) cin >> t;
    while (t--) {
        gon();
    }
}
accuracy: 1
time_ms: 50
memory_kb: 12068
final_rank: 11

code_snippet: #include <bits/stdc++.h>
using namespace std;

constexpr int mod = 1000000007;

long long modpow(long long a,long long b) {
    long long ans = 1;
    while(b) {
        if(b & 1) {
            (ans *= a) %= mod;
        }
        (a *= a) %= mod;
        b /= 2;
    }
    return ans;
}

int main() {
    int N;
    cin >> N;
    vector<int>a(N),b(1 << 20);
    for(int i = 0; i < N; i++) {
        cin >> a[i];
        b[a[i]]++;
    }
    for(int i = 0; i < 20; i++) {
        for(int j = 0; j < (1 << 20); j++) {
            if(1 & (j >> i)) {
                b[j^(1 << i)] += b[j];
            }
        }
    }
    for(int i = 0; i < (1 << 20); i++) {
        b[i] = modpow(2,b[i])-1;
    }
    for(int i = 0; i < 20; i++) {
        for(int j = 0; j < (1 << 20); j++) {
            if(1 & (j >> i)) {
                b[j^(1 << i)] += mod-b[j];
                if(b[j^(1 << i)] >= mod) b[j^(1 << i)] -= mod;
            }
        }
    }
    cout << b[0] << endl;
}
accuracy: 1
time_ms: 70
memory_kb: 7424
final_rank: 6

code_snippet: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(v) v.begin(), v.end()
#define pb push_back
template <class T, class U>
inline bool chmax(T &a, U b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T, class U>
inline bool chmin(T &a, U b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
constexpr int INF = 1000000000;
constexpr ll llINF = 1000000000000000000;
constexpr int mod = 1000000007;
constexpr double eps = 1e-10;
const double pi = acos(-1);
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
int Random(int mi, int ma) {
    random_device rnd;
    mt19937 mt(rnd());  // 32bit
    //[mi,ma]
    uniform_int_distribution<int> engine(mi, ma);
    return engine(mt);
}
/*
vector<vector<ll>>C,sC;
void init_comb(int n,int m){
    C.resize(n+1,vector<ll>(m+1,0));
    sC.resize(n+1,vector<ll>(m+1,0));
    C[0][0]=1;
    for(int i=1;i<=n;i++){
        C[i][0]=1;
        for(int j=1;j<=m;j++){
            C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod;
        }
    }
    rep(i,n+1){
        rep(j,m){
            sC[i][j+1]=(sC[i][j]+C[i][j])%mod;
        }
    }
}*/
bool prime(int a) {
    if (a == 1) return false;
    for (int i = 2; i * i <= a; i++) {
        if (a % i == 0) return false;
    }
    return true;
}
vector<int> primes;
void init_prime(int n) {
    primes.push_back(2);
    for (int i = 3; i <= n; i += 2) {
        bool f = true;
        for (int j : primes) {
            if (j * j > i) break;
            if (i % j == 0) {
                f = false;
                break;
            }
        }
        if (f) primes.push_back(i);
    }
}
ll modpow(ll a, ll b) {
    ll res = 1;
    while (b) {
        if (b & 1) {
            res *= a;
            res %= mod;
        }
        a *= a;
        a %= mod;
        b >>= 1;
    }
    return res;
}
vector<ll> inv, fact, factinv;
void init_fact(int n) {
    inv.resize(n + 1);
    fact.resize(n + 1);
    factinv.resize(n + 1);
    inv[0] = 0;
    inv[1] = 1;
    fact[0] = 1;
    factinv[0] = 1;
    for (ll i = 1; i <= n; i++) {
        if (i >= 2) inv[i] = mod - ((mod / i) * inv[mod % i] % mod);
        fact[i] = (fact[i - 1] * i) % mod;
        factinv[i] = factinv[i - 1] * inv[i] % mod;
    }
}
ll _inv(ll a, ll m = mod) {
    // gcd(a,m) must be 1
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll comb(int a, int b) {
    if (a < b) return 0;
    if (a < 0) return 0;
    return fact[a] * factinv[a - b] % mod * factinv[b] % mod;
}
int n, res[1 << 20], po[100010];
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    rep(i, n) {
        int a;
        cin >> a;
        res[a]++;
    }
    rep(i, 20) {
        for (int s = (1 << 20) - 1; s >= 0; s--) {
            if ((s >> i) & 1) {
                res[s - (1 << i)] += res[s];
            }
        }
    }
    po[0] = 1;
    rep(i, n) po[i + 1] = po[i] * 2 % mod;
    int ans = 0;
    rep(s, 1 << 20) {
        if (__builtin_popcount(s) % 2 == 0) {
            ans += po[res[s]];
            ans %= mod;
        } else {
            ans += (mod - po[res[s]]);
            ans %= mod;
        }
    }
    cout << ans << endl;
}
accuracy: 1
time_ms: 20
memory_kb: 7868
final_rank: 1

code_snippet: #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<P> vp;
typedef vector<bool> vb;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define REP(i,k,n) for(ll i=(ll)(k);i<(ll)(n);i++)
#define all(a) a.begin(),a.end()
#define rsort(a) {sort(all(a));reverse(all(a));}
#define dupli(a) {sort(all(a));a.erase(unique(all(a)),a.end());}
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pb emplace_back
const ll mod=1000000007;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){for(auto x:v)outv(x);}
template<class T> void outp(T p){cout<<'('<<p.fi<<','<<p.se<<')'<<endl;}
template<class T> void outvp(T v){for(auto p:v)cout<<'('<<p.fi<<','<<p.se<<')';cout<<endl;}
const ll inf=1001001001001001001;
ll modpow(ll a,ll b){
    a%=mod;
    ll res=1,cur=a;
    while(b){
        if(b&1)res=res*cur%mod;
        cur=cur*cur%mod;
        b>>=1;
    }
    return res;
}

int main(){
    ll n;cin>>n;
    vi dp(1<<20);
    rep(i,n){
        ll a;cin>>a;dp[a]++;
    }
    rep(j,20)for(int i=(1<<20)-1;i>=0;i--)if(!(i>>j&1))dp[i]+=dp[i|(1<<j)];
    ll ans=0;
    rep(i,1<<20){
        ll c=0;
        rep(j,20)if(i>>j&1)c++;
        if(c&1)ans-=modpow(2,dp[i])-1;
        else ans+=modpow(2,dp[i])-1;
    }
    ans%=mod;
    ans+=mod;
    out(ans%mod);
}
accuracy: 1
time_ms: 80
memory_kb: 10996
final_rank: 13

code_snippet: #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<P> vp;
typedef vector<bool> vb;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define REP(i,k,n) for(ll i=(ll)(k);i<(ll)(n);i++)
#define all(a) a.begin(),a.end()
#define rsort(a) {sort(all(a));reverse(all(a));}
#define dupli(a) {sort(all(a));a.erase(unique(all(a)),a.end());}
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pb emplace_back
const ll mod=1000000007;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){for(auto x:v)outv(x);}
template<class T> void outp(T p){cout<<'('<<p.fi<<','<<p.se<<')'<<endl;}
template<class T> void outvp(T v){for(auto p:v)cout<<'('<<p.fi<<','<<p.se<<')';cout<<endl;}
const ll inf=1001001001001001001;
ll modpow(ll a,ll b){
    a%=mod;
    ll res=1,cur=a;
    while(b){
        if(b&1)res*=cur;
        cur=cur*cur%mod;
        b>>=1;
    }
    return res;
}

int main(){
    ll n;cin>>n;
    vi dp(1<<20);
    rep(i,n){
        ll a;cin>>a;dp[a]++;
    }
    rep(j,20)for(int i=(1<<20)-1;i>=0;i--)if(!(i>>j&1))dp[i]+=dp[i|(1<<j)];
    ll ans=0;
    rep(i,1<<20){
        ll c=0;
        rep(j,20)if(i>>j&1)c++;
        if(c&1)ans-=modpow(2,dp[i])-1;
        else ans+=modpow(2,dp[i])-1;
    }
    ans%=mod;
    ans+=mod;
    out(ans%mod);
}
accuracy: 0.2
time_ms: 70
memory_kb: 10916
final_rank: 20

code_snippet: #ifdef ONLINE_JUDGE
#pragma GCC target("avx2,avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#endif
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using i128 = __int128_t;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define all(x) (x).begin(), (x).end()
constexpr char ln = '\n';
istream& operator>>(istream& is, __int128_t& x) {
    x = 0;
    string s;
    is >> s;
    int n = int(s.size()), it = 0;
    if (s[0] == '-') it++;
    for (; it < n; it++) x = (x * 10 + s[it] - '0');
    if (s[0] == '-') x = -x;
    return is;
}
ostream& operator<<(ostream& os, __int128_t x) {
    if (x == 0) return os << 0;
    if (x < 0) os << '-', x = -x;
    deque<int> deq;
    while (x) deq.emplace_front(x % 10), x /= 10;
    for (int e : deq) os << e;
    return os;
}
template<class T1, class T2>
ostream& operator<<(ostream& os, const pair<T1, T2>& p) {
    return os << "(" << p.first << ", " << p.second << ")";
}
template<class T> 
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "{";
    for (int i = 0; i < int(v.size()); i++) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "}";
}
template<class Container> inline int SZ(Container& v) { return int(v.size()); }
template<class T> inline void UNIQUE(vector<T>& v) { v.erase(unique(v.begin(), v.end()), v.end()); }
template<class T1, class T2> inline bool chmax(T1& a, T2 b) { if (a < b) {a = b; return true ;} return false ;}
template<class T1, class T2> inline bool chmin(T1& a, T2 b) { if (a > b) {a = b; return true ;} return false ;}
inline int topbit(ull x) { return x == 0 ? -1 : 63 - __builtin_clzll(x); }
inline int botbit(ull x) { return x == 0 ? 64 : __builtin_ctzll(x); }
inline int popcount(ull x) { return __builtin_popcountll(x); }
inline int kthbit(ull x, int k) { return (x>>k) & 1; }
inline constexpr long long TEN(int x) { return x == 0 ? 1 : TEN(x-1) * 10; }
inline void print() { cout << "\n"; }
template<class T>
inline void print(const vector<T>& v) {
    for (int i = 0; i < int(v.size()); i++) {
        if (i) cout << " ";
        cout << v[i];
    }
    print();
}
template<class T, class... Args>
inline void print(const T& x, const Args& ... args) {
    cout << x << " ";
    print(args...);
}
#ifdef MINATO_LOCAL
inline void debug_out() { cerr << endl; }
template <class T, class... Args>
inline void debug_out(const T& x, const Args& ... args) {
    cerr << " " << x;
    debug_out(args...);
}
#define debug(...) cerr << __LINE__ << " : [" << #__VA_ARGS__ << "] =", debug_out(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif
struct fast_ios { fast_ios() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

template<int m> 
struct ModInt {
  public:
    static constexpr int mod() { return m; }
    static ModInt raw(int v) {
        ModInt x;
        x._v = v;
        return x;
    }

    ModInt() : _v(0) {}
    ModInt(long long v) {
        long long x = (long long)(v % (long long)(umod()));
        if (x < 0) x += umod();
        _v = (unsigned int)(x);
    }

    unsigned int val() const { return _v; }

    ModInt& operator++() {
        _v++;
        if (_v == umod()) _v = 0;
        return *this;
    }
    ModInt& operator--() {
        if (_v == 0) _v = umod();
        _v--;
        return *this;
    }
    ModInt operator++(int) {
        ModInt result = *this;
        ++*this;
        return result;
    }
    ModInt operator--(int) {
        ModInt result = *this;
        --*this;
        return result;
    }

    ModInt& operator+=(const ModInt& rhs) {
        _v += rhs._v;
        if (_v >= umod()) _v -= umod();
        return *this;
    }
    ModInt& operator-=(const ModInt& rhs) {
        _v -= rhs._v;
        if (_v >= umod()) _v += umod();
        return *this;
    }
    ModInt& operator*=(const ModInt& rhs) {
        unsigned long long z = _v;
        z *= rhs._v;
        _v = (unsigned int)(z % umod());
        return *this;
    }
    ModInt& operator^=(long long n) {
        ModInt x = *this;
        *this = 1;
        if (n < 0) x = x.inv(), n = -n;
        while (n) {
            if (n & 1) *this *= x;
            x *= x;
            n >>= 1;
        }
        return *this;
    }
    ModInt& operator/=(const ModInt& rhs) { return *this = *this * rhs.inv(); }

    ModInt operator+() const { return *this; }
    ModInt operator-() const { return ModInt() - *this; }

    ModInt pow(long long n) const {
        ModInt r = *this;
        r ^= n;
        return r;
    }
    ModInt inv() const {
        int a = _v, b = umod(), y = 1, z = 0, t;
        for (; ; ) {
            t = a / b; a -= t * b;
            if (a == 0) {
                assert(b == 1 || b == -1);
                return ModInt(b * z);
            }
            y -= t * z;
            t = b / a; b -= t * a;
            if (b == 0) {
                assert(a == 1 || a == -1);
                return ModInt(a * y);
            }
            z -= t * y;
        }
    }

    friend ModInt operator+(const ModInt& lhs, const ModInt& rhs) { return ModInt(lhs) += rhs; }
    friend ModInt operator-(const ModInt& lhs, const ModInt& rhs) { return ModInt(lhs) -= rhs; }
    friend ModInt operator*(const ModInt& lhs, const ModInt& rhs) { return ModInt(lhs) *= rhs; }
    friend ModInt operator/(const ModInt& lhs, const ModInt& rhs) { return ModInt(lhs) /= rhs; }
    friend ModInt operator^(const ModInt& lhs, long long rhs) { return ModInt(lhs) ^= rhs; }
    friend bool operator==(const ModInt& lhs, const ModInt& rhs) { return lhs._v == rhs._v; }
    friend bool operator!=(const ModInt& lhs, const ModInt& rhs) { return lhs._v != rhs._v; }
    friend ModInt operator+(long long lhs, const ModInt& rhs) { return (ModInt(lhs) += rhs); }
    friend ModInt operator-(long long lhs, const ModInt& rhs) { return (ModInt(lhs) -= rhs); }
    friend ModInt operator*(long long lhs, const ModInt& rhs) { return (ModInt(lhs) *= rhs); }
    friend ostream &operator<<(ostream& os, const ModInt& rhs) { return os << rhs._v; }

  private:
    unsigned int _v;
    static constexpr unsigned int umod() { return m; }
};
 
constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;

using mint = ModInt<MOD>;

int A[1<<20];
mint dp[1<<20];
int main() {
    int N; cin >> N;
    rep(i,N) {
        int a; cin >> a;
        A[a]++;
    }
    vector<mint> beki(N+1,1);
    rep(i,N) beki[i+1] = beki[i]*2;

    rep(i,20) {
        rep(mask,1<<20) {
            if (!kthbit(mask,i)) {
                A[mask] += A[mask|(1<<i)];
            }
        }
    }

    rep(mask,1<<20) {
        dp[mask] = beki[A[mask]];
        dp[mask]--;
    }

    rep(i,20) {
        rep(mask,1<<20) {
            if (!kthbit(mask,i)) {
                dp[mask] -= dp[mask|(1<<i)];
            }
        }
    }

    cout << dp[0] << ln; 
}
accuracy: 1
time_ms: 30
memory_kb: 11580
final_rank: 8

code_snippet: #include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define SIZE 100005
#define MAX 20

int N;
ll dp[1 << MAX];
ll POW[SIZE];


int main(){

	POW[0] = 1;
	for(int i = 1; i < SIZE; i++){

		POW[i] = POW[i-1]*2;
		POW[i] %= MOD;
	}

	scanf("%d",&N);

	for(int i = 0; i < POW[MAX]; i++){

		dp[i] = 0;
	}

	int tmp;
	for(int loop = 0; loop < N; loop++){

		scanf("%d",&tmp);
		dp[tmp] += 1;
	}

	for(int loop = 0; loop < MAX; loop++){
		for(int state = POW[MAX]-1; state >= 0; state--){
			if((state & (1 << loop)) == 0){
				//自分を含む集合の個数を求める
				dp[state] += dp[state+POW[loop]];
			}
		}
	}

	ll ans = POW[N]-1;
	ll minus = 0;

	//全体から、少なくとも1つ以上の桁が1である集合を除く
	for(int i = 1; i < POW[MAX]; i++){
		int count = 0;
		for(int loop = 0; loop < MAX; loop++){
			if(i & (1 << loop))count++;
		}

		if(count%2 == 1){

			minus += (POW[dp[i]]-1);
			minus %= MOD;
		}else{

			minus -= (POW[dp[i]]-1);
			if(minus < 0){
				minus += MOD;
			}
		}
	}

	ans -= minus;
	if(ans < 0){

		ans += MOD;
	}

	printf("%lld\n",ans);

	return 0;
}
accuracy: 1
time_ms: 40
memory_kb: 12184
final_rank: 9

code_snippet: #pragma region
#include <bits/stdc++.h>
using namespace std;
/*
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
*/
#define int long long
#define REP(i,n) for(int i = 0;i < (int)(n);i++)
#define RREP(i,n) for(int i = (int)n-1;i >= 0;i--)
#define FOR(i,s,n) for(int i = s;i < (int)n;i++)
#define RFOR(i,s,n) for(int i = (int)n-1;i >= s;i--)
#define ALL(a) a.begin(),a.end()
#define IN(a, x, b) (a<=x && x<b)
template<class T>inline bool CHMAX(T&a,T b){if(a<b){a = b;return true;}return false;}
template<class T>inline bool CHMIN(T&a,T b){if(a>b){a = b;return true;}return false;}
template<class T>istream&operator >>(istream&is,vector<T>&vec){for(T&x:vec)is>>x;return is;}
template<class T>inline void in(T&t){cin>>t;}
template<class T,class... Ts>inline void in(T&t,Ts&...ts){cin>>t;in(ts...);}
template<class T>inline void out(T t){cout<<t<<endl;}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout<<t<<" ";out(ts...);}
template<typename T=int>vector<T>mv(size_t a){return vector<T>(a);}
template<typename T=int,typename... Ts>auto mv(size_t a,Ts... ts){return vector<decltype(mv<T>(ts...))>(a,mv<T>(ts...));}
template<typename T,typename V>typename enable_if<is_class<T>::value==0>::type fill(T&t,const V&v){t=v;}
template<typename T,typename V>typename enable_if<is_class<T>::value!=0>::type fill(T&t,const V&v){for(auto &e:t)fill(e,v);}
constexpr long long INF = 1e18;

template<int MOD> struct Fp {
	long long val;
	constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
		if (val < 0) val += MOD;
	}
	constexpr int getmod() { return MOD; }
	constexpr Fp operator - () const noexcept {
		return val ? MOD - val : 0;
	}
	constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
	constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
	constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
	constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
	constexpr Fp& operator += (const Fp& r) noexcept {
		val += r.val;
		if (val >= MOD) val -= MOD;
		return *this;
	}
	constexpr Fp& operator -= (const Fp& r) noexcept {
		val -= r.val;
		if (val < 0) val += MOD;
		return *this;
	}
	constexpr Fp& operator *= (const Fp& r) noexcept {
		val = val * r.val % MOD;
		return *this;
	}
	constexpr Fp& operator /= (const Fp& r) noexcept {
		long long a = r.val, b = MOD, u = 1, v = 0;
		while (b) {
			long long t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		val = val * u % MOD;
		if (val < 0) val += MOD;
		return *this;
	}
	constexpr bool operator == (const Fp& r) const noexcept {
		return this->val == r.val;
	}
	constexpr bool operator != (const Fp& r) const noexcept {
		return this->val != r.val;
	}
	friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
		return os << x.val;
	}
	friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
		if (n == 0) return 1;
		auto t = modpow(a, n / 2);
		t = t * t;
		if (n & 1) t = t * a;
		return t;
	}
};
 
// 二項係数ライブラリ
template<class T> struct BiCoef {
	vector<T> fact_, inv_, finv_;
	constexpr BiCoef() {}
	constexpr BiCoef(int n) noexcept : fact_(n, 1), inv_(n, 1), finv_(n, 1) {
		init(n);
	}
	constexpr void init(int n) noexcept {
		fact_.assign(n, 1), inv_.assign(n, 1), finv_.assign(n, 1);
		int MOD = fact_[0].getmod();
		for(int i = 2; i < n; i++){
			fact_[i] = fact_[i-1] * i;
			inv_[i] = -inv_[MOD%i] * (MOD/i);
			finv_[i] = finv_[i-1] * inv_[i];
		}
	}
	constexpr T com(int n, int k) const noexcept {
		if (n < k || n < 0 || k < 0) return 0;
		return fact_[n] * finv_[k] * finv_[n-k];
	}
	constexpr T fact(int n) const noexcept {
		if (n < 0) return 0;
		return fact_[n];
	}
	constexpr T inv(int n) const noexcept {
		if (n < 0) return 0;
		return inv_[n];
	}
	constexpr T finv(int n) const noexcept {
		if (n < 0) return 0;
		return finv_[n];
	}
};
 
const int MOD = 1000000007;
//const int MOD = 998244353;
using mint = Fp<MOD>;
BiCoef<mint> bc;
// bc.init(500050);
#pragma endregion

// fzt {{{
//#include <vector>

// to upper : b[j] = sum(i: j in i, a[i])
// n is power of 2
template < class T >
vector< T > fzt(vector< T > a, bool toUpper) {
  int n = a.size();
  for(int i = 1; i < n; i <<= 1)
    for(int j = 0; j < n; j++)
      if((j & i) == 0) {
        if(toUpper) {
          a[j] += a[j | i];
        } else {
          a[j | i] += a[j];
        }
      }
  return a;
}
// }}}

signed main(){
	int N;
	in(N);
	auto cnt = mv(1ll << 20);
	REP(i,N){
		int t;
		in(t);
		cnt[t]++; //空の集合
	}
	auto dp = fzt(cnt,true);
	mint ans = 0;
	REP(i,1ll << 20){
		if(__builtin_popcountll(i)%2)ans-=modpow(mint(2),dp[i]);
		else ans+=modpow(mint(2),dp[i]);
	}
	out(ans);
}
accuracy: 1
time_ms: 140
memory_kb: 19212
final_rank: 17

code_snippet: #include <bits/stdc++.h>
using namespace std;

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

template<::std::uint_fast64_t mod>
class ModInt{
private:
  using value_type = ::std::uint_fast64_t;
  value_type n;
public:
  ModInt() : n(0) {}
  ModInt(value_type n_) : n(n_ % mod) {}
  ModInt(const ModInt& m) : n(m.n) {}

  template<typename T>
  explicit operator T() const { return static_cast<T>(n); }
  value_type get() const { return n; }

  friend ::std::ostream& operator<<(::std::ostream &os, const ModInt<mod> &a) {
    return os << a.n;
  }

  friend ::std::istream& operator>>(::std::istream &is, ModInt<mod> &a) {
    value_type x;
    is >> x;
    a = ModInt<mod>(x);
    return is;
  }

  bool operator==(const ModInt& m) const { return n == m.n; }
  bool operator!=(const ModInt& m) const { return n != m.n; }
  ModInt& operator*=(const ModInt& m){ n = n * m.n % mod; return *this; }

  ModInt pow(value_type b) const{
    ModInt ans = 1, m = ModInt(*this);
    while(b){
      if(b & 1) ans *= m;
      m *= m;
      b >>= 1;
    }
    return ans;
  }

  ModInt inv() const { return (*this).pow(mod-2); }
  ModInt& operator+=(const ModInt& m){ n += m.n; n = (n < mod ? n : n - mod); return *this; }
  ModInt& operator-=(const ModInt& m){ n += mod - m.n; n = (n < mod ? n : n - mod); return *this; }
  ModInt& operator/=(const ModInt& m){ *this *= m.inv(); return *this; }
  ModInt operator+(const ModInt& m) const { return ModInt(*this) += m; }
  ModInt operator-(const ModInt& m) const { return ModInt(*this) -= m; }
  ModInt operator*(const ModInt& m) const { return ModInt(*this) *= m; }
  ModInt operator/(const ModInt& m) const { return ModInt(*this) /= m; }
  ModInt& operator++(){ n += 1; return *this; }
  ModInt& operator--(){ n -= 1; return *this; }
  ModInt operator++(int){
    ModInt old(n);
    n += 1;
    return old;
  }
  ModInt operator--(int){
    ModInt old(n);
    n -= 1;
    return old;
  }
  ModInt operator-() const { return ModInt(mod-n); }
};

constexpr int64 mod = 1e9+7;
using Mint = ModInt<mod>;

int main(void) {
  int64 N;
  cin >> N;
  vector<int64> dp(1 << 20, 0);
  REP(i, N) {
    int64 a;
    cin >> a;
    dp[a]++;
  }
  Mint res = 0;
  REP(i, 20) {
    REP(j, 1 << 20) {
      if (!(j & (1 << i))) dp[j] += dp[j | (1 << i)];
    }
  }
  REP(i, dp.size()) {
    if (__builtin_popcount(i) % 2) {
      res -= Mint(2).pow(dp[i])-1;
    } else {
      res += Mint(2).pow(dp[i])-1;
    }
  }
  cout << res << endl;
}
accuracy: 1
time_ms: 70
memory_kb: 10944
final_rank: 12

code_snippet: #include <bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(long long i = 0; i < (long long)(N); i++)
#define repr(i,N) for(long long i = (long long)(N) - 1; i >= 0; i--)
#define rep1(i,N) for(long long i = 1; i <= (long long)(N) ; i++)
#define repr1(i,N) for(long long i = (N) ; (long long)(i) > 0 ; i--)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
using namespace std; void solve();
using ll = long long; template<class T = ll> using V = vector<T>;
using vi = V<int>; using vl = V<>; using vvi = V< V<int> >;
constexpr int inf = 1001001001; constexpr ll infLL = (1LL << 61) - 1;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(7);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cerr << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,N) do { cerr << #v << " = "; array_out(v , N);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
  int main(){solve();}
#endif

using P = pair<ll,ll>; using vp = V<P>;
constexpr int MOD = /**/ 1000000007; //*/ 998244353;
////////////////////////////////

template< int mod >
struct ModInt {
  int x;

  ModInt() : x(0) {}

  ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

  ModInt &operator+=(const ModInt &p) {
    if((x += p.x) >= mod) x -= mod;
    return *this;
  }

  ModInt &operator-=(const ModInt &p) {
    if((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }

  ModInt &operator*=(const ModInt &p) {
    x = (int) (1LL * x * p.x % mod);
    return *this;
  }

  ModInt &operator/=(const ModInt &p) {
    *this *= p.inverse();
    return *this;
  }

  ModInt operator-() const { return ModInt(-x); }

  ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }

  ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }

  ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }

  ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }

  bool operator==(const ModInt &p) const { return x == p.x; }

  bool operator!=(const ModInt &p) const { return x != p.x; }

  ModInt inverse() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }

  ModInt pow(int64_t n) const {
    ModInt ret(1), mul(x);
    while(n > 0) {
      if(n & 1) ret *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ret;
  }

  friend ostream &operator<<(ostream &os, const ModInt &p) {
    return os << p.x;
  }

  friend istream &operator>>(istream &is, ModInt &a) {
    int64_t t;
    is >> t;
    a = ModInt< mod >(t);
    return (is);
  }

  static int get_mod() { return mod; }
};

using modint = ModInt< MOD >;
using vm = vector<modint>;

vector<int> f(1048576 + 10 , 0);

void solve(){
  ini(N);
  rep(i , N){ ini(x); f[x]++;}
  rep(i,20) rep(j,1<<20) if (!(j&(1<<i))) f[j]+=f[j|(1<<i)];

  rep(i,1000) if(f[i]) trc(i , f[i]);
  modint ans = 0;
  rep(i , 1048576){
    if(f[i] == 0) continue;
    modint cur = modint(2).pow(f[i]) - 1;
    if( (__builtin_popcount(i) & 1) == 0) ans += cur;
    else ans -= cur;
  }
  out(ans);
}
accuracy: 1
time_ms: 50
memory_kb: 6912
final_rank: 4

code_snippet: #include <iostream>
#include <set>
#include <utility>
#include <vector>
#include <algorithm>
#define llint long long
#define inf 1e18
#define mod 1000000007

using namespace std;
typedef pair<llint, llint> P;

llint n;
llint a[100005];
llint cnt[1<<20];
llint pop[1<<20];

void zeta_transform(llint a[], int n)
{
	int S = 1<<n;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < S; j++){
			if(!(j&(1<<i))) a[j] += a[j^(1<<i)], a[j] %= mod;
		}
	}
}

llint modpow(llint a, llint n)
{
	if(n == 0) return 1;
	if(n % 2){
		return ((a%mod) * (modpow(a, n-1)%mod)) % mod;
	}
	else{
		return modpow((a*a)%mod, n/2) % mod;
	}
}

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> a[i], cnt[a[i]]++;
	zeta_transform(cnt, 20);
	for(int i = 0; i < (1<<20); i++) cnt[i] = modpow(2, cnt[i]) + mod - 1, cnt[i] %= mod;
	for(int i = 1; i < (1<<20); i++) pop[i] = pop[i&(i-1)] + 1;
	
	llint ans = 0;
	for(int i = 0; i < (1<<20); i++){
		if(pop[i]%2) ans += mod - cnt[i], ans %= mod;
		else ans += cnt[i], ans %= mod;
	}
	cout << ans << endl;

	return 0;
}
accuracy: 1
time_ms: 100
memory_kb: 20320
final_rank: 16

code_snippet: #include <iostream>
#include <vector>
#include <array>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
#include <cassert>
#include <random>

constexpr long long int MOD = 1000000007;
long long int power(long long int base, int exp) {
	switch (exp) {
	case 0: return 1;
	case 1: return base % MOD;
	default: return power(base * base % MOD, exp / 2) * power(base, exp % 2) % MOD;
	}
}
long long int power_set_size(int size) {
	static std::vector<long long int> memo(100001, -1);
	if (memo[size] >= 0) return memo[size];
	return memo[size] = power(2, size);
}
long long int calc(const std::vector<int>& values, int size = 20) {
	if (size == 0) return  (power_set_size(values.size()) + MOD - 1) % MOD;
	if (values.empty()) return 0;
	long long int sum{ 0 };
	std::vector<int> sub;
	for (auto i = 0; i < size; ++i) {
		sub.clear();
		for (const auto v : values) if ((v & (1 << i)) != 0) sub.push_back(v);
		sum += calc(sub, i);
	}
	return ((power_set_size(values.size()) + MOD - 1 - sum) % MOD + MOD) % MOD;
}
int count_bit(int n) {
	return (n == 0) ? 0 : (n & 1) + count_bit(n >> 1);
}
int main() {
	int n; std::cin >> n;
	std::vector<int> values(n); for (auto& a : values) std::cin >> a;
	std::vector<long long int> pattern(1 << 20, 0);
	for (const auto a : values) pattern[a]++;
	for (auto i = 0; i < 20; ++i) {
		for (auto j = 0; j < pattern.size(); ++j) 
			if ((j & (1 << i)) == 0) {
				pattern[j] += pattern[j | (1 << i)];
				pattern[j] %= MOD;
			}
	}
	long long int result = 0;
	for (auto i = 0; i < pattern.size(); ++i) {
		if (count_bit(i) % 2 == 0) {
			result += power(2, pattern[i]) - 1;
		}
		else {
			result -= power(2, pattern[i]) - 1;
		}
		result %= MOD;
	}
	std::cout << (result + MOD) % MOD << std::endl;
}
accuracy: 1
time_ms: 100
memory_kb: 11512
final_rank: 14

code_snippet: #include <bits/stdc++.h>
using namespace std;

const int64_t MOD = 1e9+7;
void add(int64_t& a, int64_t b){
    a = (a+b) % MOD;
}
void mul(int64_t& a, int64_t b){
    a = a*b % MOD;
}

vector<int64_t> fact, seq_inv, fact_inv;

void create_fact_mod(int num){
    fact[0] = fact[1] = 1;
    for(int i=2; i<=num; i++) fact[i] = fact[i-1] * i % MOD;
}

void create_seq_inv_mod(int num){
    seq_inv[0] = seq_inv[1] = 1;
    for(int i=2; i<=num; i++) seq_inv[i] = (MOD - MOD/i) * seq_inv[MOD%i] % MOD;
}

void create_fact_inv_mod(int num){
    fact_inv[0] = fact_inv[1] = 1;
    for(int i=2; i<=num; i++) fact_inv[i] = fact_inv[i-1] * seq_inv[i] % MOD;
}

void create_mod_tables(int num){
    fact.resize(num+1);
    seq_inv.resize(num+1);
    fact_inv.resize(num+1);
    create_fact_mod(num);
    create_seq_inv_mod(num);
    create_fact_inv_mod(num);
}

int64_t comb_mod(int n, int k){
    return fact[n] * fact_inv[n-k] % MOD * fact_inv[k] % MOD;
}

int64_t perm_mod(int n, int k){
    return fact[n] * fact_inv[n-k] % MOD;
}

int64_t power_mod(int64_t num, int64_t power){
    int64_t prod = 1;
    num %= MOD;
    while(power > 0){
        if(power&1) prod = prod * num % MOD;
        num = num * num % MOD;
        power >>= 1;
    }
    return prod;
}

int64_t extgcd(int64_t a, int64_t b, int64_t& x, int64_t& y){
    int64_t d = a;
    if(b != 0){
        d = extgcd(b, a%b, y, x);
        y -= (a/b) * x;
    }else{
        x = 1; y = 0;
    }
    return d;
}

int64_t inv_mod(int64_t a){
    int64_t x, y;
    extgcd(a, MOD, x, y);
    return (MOD + x%MOD) % MOD;
}

int nth_bit(int64_t num, int n){
    return (num >> n) & 1;
}

int pop_count(int bits){
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main(){
    int N;
    cin >> N;
    const int M = 1<<20;
    static int num[M];
    for(int i=0; i<N; i++){
        int a;
        cin >> a;
        num[a]++;
    }
    for(int k=0; k<20; k++) for(int i=M-1; i>=0; i--) if(!nth_bit(i, k)) num[i] += num[i+(1<<k)];

    vector<int64_t> pw2(N+1, 1);
    for(int i=1; i<=N; i++) pw2[i] = pw2[i-1] * 2 % MOD;


    int64_t ans = 0;
    for(int i=0; i<M; i++){
        int64_t res = pw2[num[i]] - 1;
        if(pop_count(i)%2) res *= -1;
        add(ans, MOD+res);
    }
    cout << ans << endl;
    return 0;
}
accuracy: 1
time_ms: 40
memory_kb: 7512
final_rank: 3

code_snippet: #include <cstdint>

namespace n91 {

template <std::uint_fast64_t Modulus> class modint {
  using u64 = std::uint_fast64_t;

public:
  using value_type = u64;

  static constexpr u64 mod = Modulus;

private:
  static_assert(mod < static_cast<u64>(1) << 32,
                "Modulus must be less than 2**32");

  u64 v;

  constexpr modint &negate() noexcept {
    if (v != 0)
      v = mod - v;
    return *this;
  }

public:
  constexpr modint(const u64 x = 0) noexcept : v(x % mod) {}
  constexpr u64 &value() noexcept { return v; }
  constexpr const u64 &value() const noexcept { return v; }
  constexpr modint operator+() const noexcept { return modint(*this); }
  constexpr modint operator-() const noexcept { return modint(*this).negate(); }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
    v += rhs.v;
    if (v >= mod)
      v -= mod;
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if (v < rhs.v)
      v += mod;
    v -= rhs.v;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
    v = v * rhs.v % mod;
    return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept {
    u64 exp = mod - 2;
    while (exp) {
      if (exp % 2 != 0)
        *this *= rhs;
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
  constexpr bool operator==(const modint rhs) const noexcept {
    return v == rhs.v;
  }
  constexpr bool operator!=(const modint rhs) const noexcept {
    return v != rhs.v;
  }
};
template <std::uint_fast64_t Modulus>
constexpr typename modint<Modulus>::u64 modint<Modulus>::mod;

} // namespace n91

#include <cstddef>
#include <vector>

template <class S>
void subset_zeta_transform(std::vector<typename S::value_type> &a) {
  using size_t = std::size_t;

  const size_t n = a.size();
  for (size_t i = 1; i < n; i *= 2) {
    for (size_t j = 0; j != n; j += 1) {
      if ((j & i) != 0)
        a[j] = S::operation(a[j & ~i], a[j]);
    }
  }
}

template <class S>
void superset_zeta_transform(std::vector<typename S::value_type> &a) {
  using size_t = std::size_t;

  const size_t n = a.size();
  for (size_t i = 1; i < n; i *= 2) {
    for (size_t j = 0; j != n; j += 1) {
      if ((j & i) != 0)
        a[j & ~i] = S::operation(a[j & ~i], a[j]);
    }
  }
}

template <class G>
void subset_mobius_transform(std::vector<typename G::value_type> &a) {
  using size_t = std::size_t;

  const size_t n = a.size();
  size_t i = 1;
  while (i < n)
    i *= 2;
  while (i != 1) {
    i /= 2;
    for (size_t j = 0; j != n; j += 1) {
      if ((j & i) != 0)
        a[j] = G::operation(G::inverse(a[j & ~i]), a[j]);
    }
  }
}

template <class G>
void superset_mobius_transform(std::vector<typename G::value_type> &a) {
  using size_t = std::size_t;

  const size_t n = a.size();
  size_t i = 1;
  while (i < n)
    i *= 2;
  while (i != 1) {
    i /= 2;
    for (size_t j = 0; j != n; j += 1) {
      if ((j & i) != 0)
        a[j & ~i] = G::operation(a[j & ~i], G::inverse(a[j]));
    }
  }
}

template <class T> class multiplies_monoid {
public:
  using value_type = T;

  static constexpr T operation(const T &x, const T &y) noexcept {
    return x * y;
  }
  static constexpr T identity = 1;
};
template <class T> constexpr T multiplies_monoid<T>::identity;

template <class T> class plus_abelian {
public:
  using value_type = T;
  static constexpr T operation(const T &x, const T &y) noexcept {
    return x + y;
  }
  static constexpr T identity = 0;
  static constexpr T inverse(const T &x) noexcept { return -x; }
};
template <class T> constexpr T plus_abelian<T>::identity;

#include <iostream>
#include <vector>

int main() {
  using mint = n91::modint<1000000007>;

  int n;
  std::cin >> n;
  std::vector<mint> b(1 << 20, 1);
  for (int i = 0; i != n; i += 1) {
    int a;
    std::cin >> a;
    b[a] += b[a];
  }
  superset_zeta_transform<multiplies_monoid<mint>>(b);
  superset_mobius_transform<plus_abelian<mint>>(b);
  std::cout << b[0].value() << std::endl;
  return 0;
}
accuracy: 1
time_ms: 60
memory_kb: 10944
final_rank: 10

code_snippet: #include <bits/stdc++.h>

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int cnt(int n) {
  int res = 0;
  while(n > 0) {
    res += n % 2;
    n /= 2;
  }
  return res;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int n; cin >> n;
  vi v(1<<20);
  for(int i=0;i<n;++i) {
    int a; cin >> a;
    v[a]++;
  }

  for(int i=0;i<20;++i) {
    for(int j=0;j<(1<<20);++j) {
      if((j>>i)&1) {
        v[j-(1<<i)] += v[j];
      }
    }
  }

  vll po(n);
  po[0] = 1;
  for(int i=0;i<n;++i) {
    po[i+1] = po[i] * 2 % MOD;
  }

  ll ans = 0;
  for(int i=0;i<(1<<20);++i) {
    if(cnt(i) % 2 == 0) {
      ans += po[v[i]];
      ans %= MOD;
    } else {
      ans += MOD - po[v[i]];
      ans %= MOD;
    }
  }
  cout << ans << endl;

}
accuracy: 1
time_ms: 30
memory_kb: 7728
final_rank: 2

code_snippet: #include <bits/stdc++.h>

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int cnt(int n) {
  int res = 0;
  while(n > 0) {
    res += n % 2;
    n /= 2;
  }
  return res;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int n; cin >> n;
  vi v(1<<20);
  for(int i=0;i<n;++i) {
    int a; cin >> a;
    v[a]++;
  }

  for(int i=0;i<20;++i) {
    for(int j=0;j<(1<<20);++j) {
      if((j>>i)&1) {
        v[j-(1<<i)] += v[j];
      }
    }
  }

  vll po(21);
  po[0] = 1;
  for(int i=0;i<20;++i) {
    po[i+1] = po[i] * 2 % MOD;
  }

  ll ans = 0;
  for(int i=0;i<(1<<20);++i) {
    if(cnt(i) % 2 == 0) {
      ans += po[v[i]];
      ans %= MOD;
    } else {
      ans += MOD - po[v[i]];
      ans %= MOD;
    }
  }
  cout << ans << endl;

}
accuracy: 0.2
time_ms: 20
memory_kb: 6884
final_rank: 18

code_snippet: #include <bits/stdc++.h>

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int count(int n) {
  int res = 0;
  while(n > 0) {
    res += n % 2;
    n /= 2;
  }
  return res;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int n; cin >> n;
  vi v(1<<20);
  for(int i=0;i<n;++i) {
    int a; cin >> a;
    v[a]++;
  }

  for(int i=0;i<20;++i) {
    for(int j=0;j<(1<<20);++j) {
      if((j>>i)&1) {
        v[j-(1<<i)] += v[j];
      }
    }
  }

  vll po(21);
  po[0] = 1;
  for(int i=0;i<20;++i) {
    po[i+1] = po[i] * 2 % MOD;
  }

  ll ans = 0;
  for(int i=0;i<(1<<20);++i) {
    if(count(i) % 2 == 0) {
      ans += po[v[i]];
      ans %= MOD;
    } else {
      ans += MOD - po[v[i]];
      ans %= MOD;
    }
  }
  cout << ans << endl;

}
accuracy: 0.2
time_ms: 20
memory_kb: 7052
final_rank: 19

code_snippet: //
// Created by yamunaku on 2019/12/29.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

using ll = long long;
using ld = long double;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
template<typename T>
using heap = priority_queue<T, vector<T>, function<bool(const T, const T)>>;

ll modpow(ll x, ll a){
    ll ans = 1;
    while(a){
        if(a & 1) ans = ans * x % MOD;
        a >>= 1;
        x = x * x % MOD;
    }
    return ans;
}

ll inv(ll x){
    return modpow(x, MOD - 2);
}


int main(){
    // CFS;
    int n;
    cin >> n;
    vi a(n);
    int b = 20;
    vi dp(1 << b, 0);
    rep(i, n){
        cin >> a[i];
        dp[a[i]]++;
    }
    rep(i, b){
        rep(j, 1 << b){
            if(j & (1 << i)) dp[j ^ (1 << i)] += dp[j];
        }
    }
    ll ans = modpow(2, n) - 1;
    vl mp(n + 1, 1);
    repl(i, 1, n + 1) mp[i] = mp[i - 1] * 2 % MOD;
    repl(i, 1, 1 << b){
        int c = 0;
        rep(j, b) if(i & (1 << j)) c++;
        ans = (ans + (mp[dp[i]] - 1 + MOD) % MOD * (1 - c % 2 * 2) + MOD) % MOD;
    }
    cout << ans << endl;
    return 0;
}
accuracy: 1
time_ms: 50
memory_kb: 8052
final_rank: 5

code_snippet: #include<iostream>
using namespace std;
long mod=1e9+7;
long power(long a,long b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}
int N;
int cnt[1<<20];
main()
{
	cin>>N;
	for(int i=0;i<N;i++)
	{
		int a;cin>>a;cnt[a]++;
	}
	for(int i=0;i<20;i++)for(int j=0;j<1<<20;j++)if(!(j>>i&1))cnt[j]+=cnt[j|1<<i];
	long ans=0;
	for(int i=0;i<1<<20;i++)
	{
		long now=power(2,cnt[i]);
		ans+=__builtin_popcount(i)%2?-now:now;
	}
	cout<<(ans%mod+mod)%mod<<endl;
}
accuracy: 1
time_ms: 180
memory_kb: 7172
final_rank: 15