#!/usr/bin/env python3
"""Auto-generated by AGI Loop cycle #1240
Task: , given the initial query, the assistant's response is correct. The task is novel and fits the criteria of being self-contained and testable.

The assistant's response is accurate because it starts wi
Generated: 2026-02-13T01:28:20.175966
"""

def min_flips_to_checkerboard(matrix):
    rows = len(matrix)
    cols = len(matrix[0])
    pattern1 = 0  # Expected pattern starting with 0
    pattern2 = 1  # Expected pattern starting with 1

    flips1 = 0
    flips2 = 0

    for i in range(rows):
        for j in range(cols):
            expected = (i + j) % 2
            if matrix[i][j] != expected:
                flips1 += 1
            expected = (i + j + 1) % 2
            if matrix[i][j] != expected:
                flips2 += 1

    return min(flips1, flips2)


if __name__ == "__main__":
    matrix = [
        [1, 0, 1],
        [0, 1, 0],
        [1, 0, 1]
    ]
    result = min_flips_to_checkerboard(matrix)
    print(result)