python and c for problem 2