class Solution {
public:
    vector<vector<int>> res;
    vector<vector<int> > subsets(vector<int> &S) {    
        vector<int> a;
        res.push_back(a);
        for(int i=1;i<=S.size();i++){
            dfs(S,a,0,i);
        }
        return res;
    }
    void dfs(vector<int> &S,vector<int> a,int begin,int cur){
        if(cur==a.size()){
            res.push_back(a);
            return;
        }
        for(int i=begin;i<S.size();i++){
            a.push_back(S[i]);
            dfs(S,a,i+1,cur);
            a.pop_back();
        }
    }
};