Males will lock with other males if they are really horny. Females will try to get lazy males to lock , but from what I've seen it seems to mostly involve nudging them and shoving their head underneath the male's body.

Anyway, the snake with its tail on the bottom is definitely a male. The snake on top could be either gender.