Not optimal this either, but doesn't check all cells in mesh. If C is quite small, this should do it.
from dolfin import *
from numpy import argwhere
mesh = UnitCubeMesh(4,4,4)
# Create meshfunction of cells
mf = CellFunction('size_t', mesh)
mf.set_all(0)
for i, c in enumerate(cells(mesh)):
if c.midpoint()[0] < 0.5:
mf[i] = 1
C = argwhere(mf.array()==1)
# Check adjacent cells for all cells in C
mesh.init(3,3)
for index in C:
index = index[0]
cell = Cell(mesh, index)
for adj_cell in cell.entities(3):
if mf[int(adj_cell)] == 0:
mf[int(adj_cell)] = 2
plot(mf, interactive=True)