#include <bits/stdc++.h>
using namespace std;

struct timeit {
    decltype(chrono::high_resolution_clock::now()) begin;
    const string label;
    timeit(string label = "???") : label(label) { begin = chrono::high_resolution_clock::now(); }
    ~timeit() {
        auto end = chrono::high_resolution_clock::now();
        auto duration = chrono::duration_cast<chrono::milliseconds>(end - begin).count();
        cerr << duration << "ms elapsed [" << label << "]" << endl;
    }
};
const int MAXN = 1<<8;
int i, j, a[MAXN][MAXN], rows[MAXN], cols[MAXN];
const int NUMITERS = 10000;
int main() {
    for (int i=0; i<MAXN; i++) {
        rows[i] = i;
        cols[i] = i;
    }
    {
        timeit timer("blocked");
        int n = MAXN;
        int B = 8;
        for (int t = 0; t < NUMITERS; t++) {
            for (int i = 0; i < n; i += B) {
                for (int j = 0; j < n; j += B) {
                    for (int x = i; x < i + B; x++) {
                        for (int y = j; y < j + B; y++) {
                            a[x][y] = rows[x] * cols[y];
                        }
                    }
                }
            }
        }
        cout<<a[20][20]<<endl;
    }
    {
        timeit x("normal");
        int n = MAXN;
        for (int t = 0; t < NUMITERS; t++) {
            for (i = 0; i < MAXN; i++) {
                for (j = 0; j < MAXN; j++) {
                    a[i][j] = rows[i]*cols[j];
                }
            }
        }
        cout<<a[20][20]<<endl;
    }
}
