What can we do after entire class failed/barely passed?
Talk to your student's union.

They should know whether or not there can be anything done and if yes, what. They should also know if a situation where everyone fails is common (in some universities there are some courses, mostly freshman-courses, where it's common that 90% of students fail) in your country/university.

But prepare yourself for the possibility that nothing happens. In my experience, the situation that two groups/individuals are graded obviously differently, is very common in the university level. In my university, for example, there is no quality control of the courses whatsoever - a course is taught well/ is fair if and only if the instructor wants to teach it well and wants to be fair (and is capable of teaching well and being fair). Fortunately, many academics are "good people" wanting to be a good teacher (without being rewarded) but some don't care at all (which can also makes sense, since they need to focus on publications to survive).

But what can you learn from this situation? You can take some steps to prepare.

1) It's always a good idea to find out what the exact rules are for taking courses in your university. Can you switch the order of the courses? Can you choose instructors? Can you do exams with instructors who held the course some years ago (but you took the course with someone else)?

2) If you can choose instructors, then try to find out something on them. Who teaches well? Who is motivated? Who treats students fair? Who helds female and male students to the same standards? (Unfortunately, not everyone.) What about foreign students? Who grades fairly? To find things like that out, ask your student's union, socialize with other students, read things in facebook groups, maybe become active yourself as a student's representative.. These things will help you a lot.
If lists are avaiable on who will teach courses in the future, try to adjust your courses (if possible) such that you get the good instructors. Remember that, of course, your goal should not be to just get the easy-grading instructors, but the ones where you learn much. (But nobody is helped if you learn much but fail the exam because the instructor belongs into the (unfortunately, non-empty) category of people who let everyone but women with very revailing clothes fail).

However, be advised, that unlike popular belief, there are many harsh graders where you don't learn much and their are many easy graders where you learn a lot.