I have a solution to the puzzle at https://kattis.csc.kth.se/problem?id=codes.What can I do to make my algorithm much much faster? What the algorithm does is take an NK matrix and search for the minimum distance  that is, the least number of 1 for all the products of the matrix and a vector that ranges from 00001 to 11111 (where the top is 2K - 1). #include <iostream>using namespace std;void DataEntry(int &a, int &b, int** &matrix) {    cin >> a >> b;    matrix = new int*[a];    for (int i = 0; i < a; i++) {        matrix[i] = new int[b];    }    for (int i = 0; i < a; i++) {        for (int j = 0; j < b; j++) {            matrix[i][j] = -1;            cin >> matrix[i][j];        }    }}int* BinaryAdd(int* a, int* b, int tam) {    int* c;    int ac = 0;    c = new int[tam];    for (int i = tam - 1; i > -1; i--) {        c[i] = a[i] + b[i] + ac;        if (c[i] == 2) {            c[i] = 0;            ac = 1;        } else            ac = 0;    }    return c;}int* MultiplyMatrices(int** a, int* b, int tamF, int tamC) {    int * c;    c = new int[tamF];    for (int i = 0; i < tamF; i++) {        c[i] = 0;        for (int j = 0; j < tamC; j++) {            c[i] = c[i] + (a[i][j] * b[j]);            c[i] = c[i] % 2;        }    }    return c;}int MinimumDistance(int* a, int tam) {    int MD = 0;    for (int i = 0; i < tam; i++) {        if (a[i] == 1)            MD++;    }    return MD;}int pot(int a, int b) {    int c = 1;    for (int i = 1; i < b + 1; i++) {        c = a * c;    }    return c;}int main() {    int t = 0, n = 0, k = 0, d = -1, max = -1;    int ** lecc;    int * pro;    int * sal;    int * sol;    int * zero;    int * uno;    int * pro1;    cin >> t;    for (int p = 0; p < t; p++) {        DataEntry(n, k, lecc);        pro = new int[k];        uno = new int[k];        sal = new int[n];        zero = new int[n];        for (int i = 0; i < k; i++) {            pro[i] = 0;        }        for (int i = 0; i < k - 1; i++) {            uno[i] = 0;        }        uno[k - 1] = 1;        for (int i = 0; i < n; i++) {            zero[i] = 0;        }        pro1 = BinaryAdd(pro, uno, k);        pro = pro1;        max = pot(2, k);        sal = MultiplyMatrices(lecc, pro, n, k);        d = MinimumDistance(sal, n);        for (int i = 0; i < max - 1; i++) {            sal = MultiplyMatrices(lecc, pro, n, k);            pro1 = BinaryAdd(pro, uno, k);            pro = pro1;            int ad = MinimumDistance(sal, n);            if (ad < d)                d = ad;        }        cout << d << endl;    }}Edit: I give you a sample input and output Sample input     Sample output27 41 0 0 00 1 0 00 0 1 0           30 0 0 1           00 1 1 11 0 1 11 1 0 13 21 10 01 1 
Speed up a program to find the minimum Hamming distance
c++;optimization;bitwise;edit distance