
    Write a function that validates a student's composite risk score by ensuring that the frequency of each score level (0-9) in the combined metric does not exceed the actual score value itself, where the score is formed by concatenating attendance, academic, and engagement metrics. For example, in a score where 5 appears four times, the validation would fail since 4 (frequency) is not less than or equal to 5 (the digit itself).
    

    
def validate(n):
    """
    Write a function that validates a student's composite risk score by ensuring that the frequency of each score level (0-9) in the combined metric does not exceed the actual score value itself, where the score is formed by concatenating attendance, academic, and engagement metrics. For example, in a score where 5 appears four times, the validation would fail since 4 (frequency) is not less than or equal to 5 (the digit itself).
    

    """
def validate(n):
    """
    Write a function that validates a student's composite risk score by ensuring that the frequency of each score level (0-9) in the combined metric does not exceed the actual score value itself, where the score is formed by concatenating attendance, academic, and engagement metrics. For example, in a score where 5 appears four times, the validation would fail since 4 (frequency) is not less than or equal to 5 (the digit itself).
    

    """
    for i in range(10):
        temp = n
        count = 0
        while temp:
            if temp % 10 == i:
                count += 1
            if count > i:
                return False
            temp //= 10
    return True