I think that this (in the starting code):
weight, volume = [float(j) for j in input().split()]
should be changed to this:
weight, volume = [float(j) for j in raw_input().split()]
in Python (not Python 3).
I think that this (in the starting code):
weight, volume = [float(j) for j in input().split()]
should be changed to this:
weight, volume = [float(j) for j in raw_input().split()]
in Python (not Python 3).
And float replaced with double in C++ base code.