F1 score model comparison

Write codeMedium15 minMeta and OpenAI style

Your task

Two spam-filter candidates were scored on the same eval set. Each model is summarized as [tp, fp, fn]. Its F1 score is 2tp / (2tp + fp + fn); if 2*tp + fp + fn is 0, treat that model's F1 as 0. Return 0 if model_a has the strictly higher F1, 1 if model_b does, and -1 on an exact tie. Compare the two fractions exactly with integer cross-multiplication, do not use floating point. Example: model_a = [8, 2, 2] (F1 = 16/20) beats model_b = [9, 4, 1] (F1 = 18/23), so return 0.

Examples

better_f1(model_a: list[int], model_b: list[int]) -> int
Example 1
Inputbetter_f1([8, 2, 2], [9, 4, 1])
Output0