let create : int -> int -> vec[int] =
    fun (l1 : int) (l2 : int) ->
        let x : vec[int] = vector (l1 * l2) 0 in
        for i = 0 to l1 do
            for j = 0 to l2 do
                vector_set x ((l2 * i) + j) (j + i)
            done
        done ;
        x
in

let mult : vec[int] -> int -> int -> vec[int] -> int -> int -> vec[int] =
    fun (x : vec[int])
    (x1 : int) (x2 : int)
    (y : vec[int])
    (y1 : int) (y2 : int) ->
    let r : vec[int] = vector (y2 * x1) 0 in
    for i = 0 to x1 do
        for j = 0 to y2 do
            for k = 0 to y1 do
                vector_set r ((i * y2) + j)
                    ((vector_get r ((i * y2) + j)) +
                        (vector_get x ((i * x2) + k)) *
                        (vector_get y ((k * y2) + j)))
            done
        done
    done ;
    r
in

let run_benchmark : int -> int = fun _ : int ->
    let size : int = read_int () in

    let ar : int = size in
    let ac : int = size in
    let br : int = size in
    let bc : int = size in

    let a : vec[int] = create ar ac in
    let b : vec[int] = create br bc in

    print_int (vector_get (mult a ar ac b br bc) ((ar * bc) - 1))
in
(time (run_benchmark))
