Thanks for the puzzle.
Let the number of cows be x, buffalo y and goat z.
Cost of three combined -
2x + y + 0.25z = 20
solving we get
8x + 4y + z = 160 ..... eqn (i)
Again, we know the number of animals is 20
hence,
x + y + z = 20 ...... eqn (ii)
Solving eqn (i) and eqn (ii) we get,
4x - 3z = 0
or 4x = 3z
i.e. x/z = 3/4
or the number of cows and goats are in the ratio of 3:4
taking Cows as 3 and goats as 4 we get buffaloes as 13
Which satisfies the conditions.