#include <vector>
#include <bitset>
#include <iostream>
using namespace std;
const int N = 2048;
int GetRank(vector<bitset<N>> matrix) {
const int n = matrix.size();
int r = 0;
vector<bool> used(n);
for (int col = 0; col < n; ++col) {
int pivot = -1;
for (int row = 0; row < n; ++row) {
if (!used[row] && matrix[row][col]) {
pivot = row; break;
}
}
if (pivot == -1) { continue; }
used[pivot] = true;
++r;
for (int r = 0; r < n; ++r) {
if (r == pivot) { continue; }
if (matrix[r][col]) {
matrix[r] ^= matrix[pivot];
}
}
}
return r;
}
uint64_t xorshift64(uint64_t* state)
{
uint64_t x = *state;
x^= x << 13;
x^= x >> 7;
x^= x << 17;
*state = x;
return x;
}
#include <random>
int main() {
int n=1900;
mt19937 mt(time(NULL));
for (int i = 0; i < 10; ++i) {
int m = n + i;
vector<bitset<N>> matrix(m);
for (int i = 0; i < m; ++i) {
for (int j = 0; j < m; ++j) {
matrix[i][j] = mt() % 2;
}
}
cout << m << " "<< GetRank(matrix) << "\n";
}
}
I2luY2x1ZGUgPHZlY3Rvcj4KI2luY2x1ZGUgPGJpdHNldD4KI2luY2x1ZGUgPGlvc3RyZWFtPgoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmNvbnN0IGludCBOID0gMjA0ODsKCmludCBHZXRSYW5rKHZlY3RvcjxiaXRzZXQ8Tj4+IG1hdHJpeCkgewogICAgY29uc3QgaW50IG4gPSBtYXRyaXguc2l6ZSgpOwogICAgaW50IHIgPSAwOwogICAgdmVjdG9yPGJvb2w+IHVzZWQobik7CgogICAgZm9yIChpbnQgY29sID0gMDsgY29sIDwgbjsgKytjb2wpIHsKICAgICAgICBpbnQgcGl2b3QgPSAtMTsKICAgICAgICBmb3IgKGludCByb3cgPSAwOyByb3cgPCBuOyArK3JvdykgewogICAgICAgICAgICBpZiAoIXVzZWRbcm93XSAmJiBtYXRyaXhbcm93XVtjb2xdKSB7CiAgICAgICAgICAgICAgICBwaXZvdCA9IHJvdzsgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICB9CgogICAgICAgIGlmIChwaXZvdCA9PSAtMSkgeyBjb250aW51ZTsgfQogICAgICAgIHVzZWRbcGl2b3RdID0gdHJ1ZTsKICAgICAgICArK3I7CgogICAgICAgIGZvciAoaW50IHIgPSAwOyByIDwgbjsgKytyKSB7CiAgICAgICAgICAgIGlmIChyID09IHBpdm90KSB7IGNvbnRpbnVlOyB9CiAgICAgICAgICAgIGlmIChtYXRyaXhbcl1bY29sXSkgewogICAgICAgICAgICAgICAgbWF0cml4W3JdIF49IG1hdHJpeFtwaXZvdF07CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICB9CiAgICByZXR1cm4gcjsKfQoKdWludDY0X3QgeG9yc2hpZnQ2NCh1aW50NjRfdCogc3RhdGUpCnsKICAgIHVpbnQ2NF90IHggPSAqc3RhdGU7CiAgICB4Xj0geCA8PCAxMzsKICAgIHhePSB4ID4+IDc7CiAgICB4Xj0geCA8PCAxNzsKICAgICpzdGF0ZSA9IHg7CiAgICByZXR1cm4geDsKfQoKI2luY2x1ZGUgPHJhbmRvbT4KaW50IG1haW4oKSB7CiAgICBpbnQgbj0xOTAwOwoKICAgIG10MTk5MzcgbXQodGltZShOVUxMKSk7CiAgICBmb3IgKGludCBpID0gMDsgaSA8IDEwOyArK2kpIHsKICAgICAgICBpbnQgbSA9IG4gKyBpOwogICAgICAgIHZlY3RvcjxiaXRzZXQ8Tj4+IG1hdHJpeChtKTsKICAgICAgICBmb3IgKGludCBpID0gMDsgaSA8IG07ICsraSkgewogICAgICAgICAgICBmb3IgKGludCBqID0gMDsgaiA8IG07ICsraikgewogICAgICAgICAgICAgICAgbWF0cml4W2ldW2pdID0gbXQoKSAlIDI7CiAgICAgICAgICAgIH0KICAgICAgICB9CgogICAgICAgIGNvdXQgPDwgbSA8PCAiICI8PCBHZXRSYW5rKG1hdHJpeCkgPDwgIlxuIjsKICAgIH0KfQo=