using
System;
using
System.Collections.Generic;
class
GFG {
static
int
maxEqrows(List<List<
int
>> mat,
int
N,
int
M)
{
Dictionary<List<
int
>,
int
> mp =
new
Dictionary<List<
int
>,
int
>();
for
(
int
i = 0; i < N; i++) {
if
(mp.ContainsKey(mat[i]))
{
mp[(mat[i])]++;
}
else
{
mp[(mat[i])] = 1;
}
}
int
cntMaxRows = 0;
for
(
int
i = 0; i < N; i++) {
List<
int
> onesCompRow =
new
List<
int
>();
for
(
int
j = 0; j < M; j++)
{
onesCompRow.Add(0);
}
for
(
int
j = 0; j < M; j++) {
onesCompRow[j] = (mat[i][j] ^ 1);
}
if
(!mp.ContainsKey(mat[i]))
{
cntMaxRows = Math.Max(cntMaxRows, mp[onesCompRow] + 1);
}
else
if
(!mp.ContainsKey(onesCompRow))
{
cntMaxRows = Math.Max(cntMaxRows, mp[(mat[i])] + 1);
}
else
{
cntMaxRows = Math.Max(cntMaxRows, mp[(mat[i])] + mp[onesCompRow] + 1);
}
}
return
cntMaxRows;
}
static
void
Main() {
List<List<
int
>> mat =
new
List<List<
int
>>();
mat.Add(
new
List<
int
> { 0, 1, 0, 0, 1 });
mat.Add(
new
List<
int
> { 1, 1, 0, 1, 1 });
mat.Add(
new
List<
int
> { 1, 0, 1, 1, 0 });
int
N = mat.Count;
int
M = mat[0].Count;
Console.WriteLine(maxEqrows(mat, N, M));
}
}