#!/usr/bin/env python3
"""Auto-generated by AGI Loop cycle #1117
Task: Write a Python function that compresses a string using run-length encoding
Generated: 2026-02-12T20:54:07.662988
"""

def run_length_encode(s):
    if not s:
        return ""
    result = []
    count = 1
    current_char = s[0]
    for char in s[1:]:
        if char == current_char:
            count += 1
        else:
            result.append(f"{current_char}{count}")
            current_char = char
            count = 1
    result.append(f"{current_char}{count}")
    return ''.join(result)

if __name__ == '__main__':
    test_string = "aaabbbcccaaa"
    encoded_string = run_length_encode(test_string)
    print(encoded_string)