I am not able to come up with a logic for this problem.
Link to problem - https://codeforces.com/problemset/problem/1250/L
'Divide The Students' problem on codeforces
So we can approach this problem greedily.
Now since we know that c++ and assembly students can’t be in the same group, we have to divide them optimally and the greedy solution is optimal.
Lets say c++ students are more than assembly students, then we place assembly students in one group and divide the c++ students into two groups, half in each sub group. Similarly the case can be solved for when assembly students are more than c++students.
After this just greedily try to make the 3 subgroups as much equal as possible, by distributing all the basic students.
This is my code https://ide.codingblocks.com/s/236185, please see this if you fail to implement the above logic.