  The subalgebra membership problem is the problem of deciding if a given
element belongs to an algebra given by a set of generators. This is one of the
best established computational problems in algebra. We consider a variant of
this problem, which is motivated by recent progress in the Constraint
Satisfaction Problem, and is often referred to as the Subpower Membership
Problem (SMP). In the SMP we are given a set of tuples in a direct product of
algebras from a fixed finite set $\mathcal{K}$ of finite algebras, and are
asked whether or not a given tuple belongs to the subalgebra of the direct
product generated by a given set.
  Our main result is that the subpower membership problem SMP($\mathcal{K}$) is
in P if $\mathcal{K}$ is a finite set of finite algebras with a cube term,
provided $\mathcal{K}$ is contained in a residually small variety. We also
prove that for any finite set of finite algebras $\mathcal{K}$ in a variety
with a cube term, each one of the problems SMP($\mathcal{K}$), SMP($\mathbb{HS}
\mathcal{K}$), and finding compact representations for subpowers in
$\mathcal{K}$, is polynomial time reducible to any of the others, and the first
two lie in NP.
