A semiconductor device or a memory device with low power consumption and a small area is provided. The semiconductor device includes a sense amplifier and a memory cell. The memory cell is provided over the sense amplifier. The sense amplifier includes a first transistor and a second transistor. The memory cell includes a third transistor and a capacitor. The first transistor is a p-channel transistor. The second transistor and the third transistor each include an oxide semiconductor in a channel formation region. The third transistor is preferably provided over the capacitor.