Given an array of log lines logs, where each line is a string, write a function that extracts error codes and returns the 10 most frequent codes. An error code is any token that starts with ERROR_ and is followed by uppercase letters, digits, or underscores. Return a list of (code, count) pairs sorted by descending frequency, and break ties by lexicographically smaller code first.
ERROR_[A-Z0-9_]+def top_error_codes(logs):