def cnt(quantity, form1, form2, form5):
"""
Returns a string with the quantity and the correct form of a noun based on Russian pluralization rules.
This function selects the appropriate noun form depending on the given quantity:
- `form1` is used for singular (e.g., 1, 21, 31, ...)
- `form2` is used for a few (e.g., 2, 3, 4, 22, 23, 24, ...)
- `form5` is used for many or zero (e.g., 0, 5-20, 25-30, ...)
Args:
quantity (int): The number to determine the noun form for. Can be negative; the absolute value is used.
form1 (str): The noun form used with singular quantities.
form2 (str): The noun form used with a few quantities.
form5 (str): The noun form used with many quantities.
Returns:
str: A string combining the absolute quantity and the correct noun form, e.g. "5 яблок".
Example:
>>> cnt(23, "яблоко", "яблока", "яблок")
'23 яблока'
"""
quantity = abs(quantity)
last_two = quantity % 100
last_digit = quantity % 10
if 11 <= last_two <= 14:
form = form5
elif last_digit == 1:
form = form1
elif 2 <= last_digit <= 4:
form = form2
else:
form = form5
return f"{quantity} {form}"