• + 1 comment
    #!/bin/python3
    
    import math
    import os
    import random
    import re
    import sys
    from collections import Counter
    
    
    if __name__ == '__main__':
    
        # Sample large text
        text = sys.stdin.read()
    
        pattern = r'[\r\n]'
        cleaned_text = re.sub(pattern, '', text)
    
        pattern = r'(?=(\b[a-z]+\s[a-z]+\s[a-z]+\b))'
        # Find all matches
        matches = re.findall(pattern, cleaned_text.lower())
    
        #print(matches)
        # Count the number of matches using Counter
        match_counts = Counter(matches)
    
        #get the first value with highest number
        result = ""
        max_num = 0
    
        for match, count in match_counts.items():
            #print(match, max_num, count)
            if max_num < count:
                result = match
                max_num = count
    
        print(result.strip())