Gap theorems for certain submanifolds of Euclidean spaces and hyperbolic space forms