This is my code My code has wrong answer on 11th test case, But I think my solution was right.
For every pair of soldiers one of them should get a badge with strictly higher factor than the second one. Exact values of their factors aren't important, they just need to have distinct factors.