/**
 * This function concatenates and subtracts arrays while repeating them n times.
 * It returns the resulting concatenated and subtracted array.
 *
 * @param arr1 First input array
 * @param arr2 Second input array
 * @param n Number of times to repeat the arrays
 * @return Concatenated and subtracted array
 */
fun concatenateAndSubtract(arr1: Array<IntArray>, arr2: Array<IntArray>, n: Int): Array<IntArray> {

    // Repeat the arrays n times
    val arr1Repeated = Array(n) { arr1 }.flatMap { it.toList() }.toTypedArray()
    val arr2Repeated = Array(n) { arr2 }.flatMap { it.toList() }.toTypedArray()

    // Concatenate and subtract the repeated arrays
    val result = arr1Repeated + arr2Repeated
    for (i in arr2Repeated.indices) {
        for (j in arr2Repeated[i].indices) {
            result[i][j] -= arr2Repeated[i][j]
        }
    }

    return result
}
/**
 * This function concatenates and subtracts arrays while repeating them n times.
 * It returns the resulting concatenated and subtracted array.
 *
 * @param arr1 First input array
 * @param arr2 Second input array
 * @param n Number of times to repeat the arrays
 * @return Concatenated and subtracted array
 */
fun concatenateAndSubtract(arr1: Array<IntArray>, arr2: Array<IntArray>, n: Int): Array<IntArray> {
/**
 * This function concatenates and subtracts arrays while repeating them n times.
 * It returns the resulting concatenated and subtracted array.
 *
 * @param arr1 First input array
 * @param arr2 Second input array
 * @param n Number of times to repeat the arrays
 * @return Concatenated and subtracted array
 */
fun concatenateAndSubtract(arr1: Array<IntArray>, arr2: Array<IntArray>, n: Int): Array<IntArray> {

    // Repeat the arrays n times
    val arr1Repeated = Array(n) { arr1 }.flatMap { it.toList() }.toTypedArray()
    val arr2Repeated = Array(n) { arr2 }.flatMap { it.toList() }.toTypedArray()

    // Concatenate and subtract the repeated arrays
    val result = arr1Repeated + arr2Repeated
    for (i in arr2Repeated.indices) {
        for (j in arr2Repeated[i].indices) {
            result[i][j] -= arr2Repeated[i][j]
        }
    }

    return result
}