Code in java, python, c and ruby