#include <cstdio>
#include <stdlib.h>

#include <iostream>
#include <chrono>


#define N 10000

#if _DEBUG
typedef long lli;
#else
typedef long long int  lli;
#endif

lli a[N*N];
lli b[N*N];
lli c[N*N];

int n,m,l;

void mult() {
    lli register t11, t12, t13, t21, t22, t23, t31, t32, t33;
    for(int i=0; i<n-2; i+=3)
        for(int j=0; j<l-2; j+=3) {
            t11 = c[i*N + j];
            t12 = c[i*N + (j+1)];
            t13 = c[i*N + (j+2)];
            t21 = c[(i+1)*N + j];
            t22 = c[(i+1)*N + (j+1)];
            t23 = c[(i+1)*N + (j+2)];
            t31 = c[(i+2)*N + j];
            t32 = c[(i+2)*N + (j+1)];
            t33 = c[(i+2)*N + (j+2)];
            for(int k=0; k<m; k++) {
                t11 += a[i*N + k] * b[k*N + j];
                t12 += a[i*N + k] * b[k*N + (j+1)];
                t13 += a[i*N + k] * b[k*N + (j+2)];
                t21 += a[(i+1)*N + k] * b[k*N + j];
                t22 += a[(i+1)*N + k] * b[k*N + (j+1)];
                t23 += a[(i+1)*N + k] * b[k*N + (j+2)];
                t31 += a[(i+2)*N + k] * b[k*N + j];
                t32 += a[(i+2)*N + k] * b[k*N + (j+1)];
                t33 += a[(i+2)*N + k] * b[k*N + (j+2)];
            }
            c[i*N + j] = t11;
            c[i*N + (j+1)] = t12;
            c[i*N + (j+2)] = t13;
            c[(i+1)*N + j] = t21;
            c[(i+1)*N + (j+1)] = t22;
            c[(i+1)*N + (j+2)] = t23;
            c[(i+2)*N + j] = t31;
            c[(i+2)*N + (j+1)] = t32;
            c[(i+2)*N + (j+2)] = t33;
        }
    for(int i=0; i<n-2; i+=3)
        for(int j=(l/3)*3; j<l; j++)
        {
            t11 = c[i*N + j];
            t21 = c[(i+1)*N + j];
            t31 = c[(i+2)*N + j];
            for(int k=0; k<m; k++) {
                t11 += a[i*N + k] * b[k*N + j];
                t21 += a[(i+1)*N + k] * b[k*N + j];
                t31 += a[(i+2)*N + k] * b[k*N + j];
            }
            c[i*N + j] = t11;
            c[(i+1)*N + j] = t21;
            c[(i+2)*N + j] = t31;
        }
    for(int i=(n/3)*3; i<n; i++)
        for(int j=0; j<l-2; j+=3)
        {
            t11 = c[i*N + j];
            t12 = c[i*N + (j+1)];
            t13 = c[i*N + (j+2)];
            for(int k=0; k<m; k++) {
                t11 += a[i*N + k] * b[k*N + j];
                t12 += a[i*N + k] * b[k*N + (j+1)];
                t13 += a[i*N + k] * b[k*N + (j+2)];
            }
            c[i*N + j] = t11;
            c[i*N + (j+1)] = t12;
            c[i*N + (j+2)] = t13;
        }
    for(int i=(n/3)*3; i<n; i++)
        for(int j=(l/3)*3; j<l; j++) {
            t11 = c[i*N + j];
            for(int k=0; k<m; k++)
                t11 += a[i*N + k] * b[k*N + j];
            c[i*N + j] = t11;
        }

}

int main(void) {
#if _DEBUG
    for(n=2; n<N; n*=2) {
        m=l=n;
#else
        scanf("%d%d%d", &n, &m, &l);
#endif


#if _DEBUG
        for(int i=0; i<n; i++)
            for(int j=0; j<m; j++)
                a[i*N + j] = rand();
        for(int i=0; i<m; i++)
            for(int j=0; j<l; j++)
                b[i*N + j] = rand();
#else
        for(int i=0; i<n; i++)
            for(int j=0; j<m; j++)
                scanf("%lld", &a[i*N + j]);
        for(int i=0; i<m; i++)
            for(int j=0; j<l; j++)
                scanf("%lld", &b[i*N + j]);
#endif
        for(int i=0; i<n; i++)
            for(int j=0; j<l; j++)
                c[i*N + j] = 0;

        auto start = std::chrono::system_clock::now();
        mult();
        auto end = std::chrono::system_clock::now();

#if _DEBUG
        auto dur = end-start;
        auto msec = std::chrono::duration_cast<std::chrono::milliseconds>(dur).count();
        std::cout << n << ":" << msec << " milli sec" << std::endl;
    }
#else
    for(int i=0; i<n; i++) {
        for(int j=0; j<l-1; j++)
            printf("%lld ", c[i*N + j]);
        printf("%lld", c[i*N + l-1]);
        printf("\n");
    }
#endif
    return 0;
}

Measured memory_bytes: 4592