stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include <iostream>

#include <cstring>

#include <cstdlib>

#include <cmath>

#include <algorithm>

#include <functional>

#include <vector>

#include <queue>

#include <stack>

#include <map>

#include <set>

#include <bitset>

#include <cassert>

#include <exception>

using namespace std;

typedef long long ll;

typedef unsigned long long ull;

typedef pair<ll,ll> P;

typedef vector<int> vi;

typedef vector<ll> vll;

typedef vector<string> vs;

typedef vector<P> vp;

#define rep(i,a,n) for(ll i = (a);i < (n);i++)

#define per(i,a,n) for(ll i = (a);i > (n);i--)

#define lep(i,a,n) for(ll i = (a);i <= (n);i++)

#define pel(i,a,n) for(ll i = (a);i >= (n);i--)

#define clr(a,b) memset((a),(b),sizeof(a))

#define pb push_back

#define mp make_pair

#define all(c) (c).begin(),(c).end()

#define sz size()

#define print(X) cout << (X) << endl

const ll INF = 1e+9+7;

ll n,m,l;

string s,t;

ll d[200010],dp[550][550];



int main(){

  cin >> n;

  clr(d,0);

  rep(i,0,n){

    cin >> s;

    d[s[0] - 'A']++;

  }

  rep(i,0,30){

    if(d[i] != 0)l++;

  }

  if(l == 3)puts("Three");

  else puts("Four");

  return 0;

}

// Faster C++ solution for the same problem (measured speedup: 2.613572571511563x):
#include <iostream>

#include <cstring>

#include <cstdlib>

#include <cmath>

#include <algorithm>

#include <functional>

#include <vector>

#include <queue>

#include <stack>

#include <map>

#include <set>

#include <bitset>

#include <cassert>

#include <exception>

using namespace std;

typedef long long ll;

typedef unsigned long long ull;

typedef pair<ll,ll> P;

typedef vector<int> vi;

typedef vector<ll> vll;

typedef vector<string> vs;

typedef vector<P> vp;

#define rep(i,a,n) for(ll i = (a);i < (n);i++)

#define per(i,a,n) for(ll i = (a);i > (n);i--)

#define lep(i,a,n) for(ll i = (a);i <= (n);i++)

#define pel(i,a,n) for(ll i = (a);i >= (n);i--)

#define clr(a,b) memset((a),(b),sizeof(a))

#define pb push_back

#define mp make_pair

#define all(c) (c).begin(),(c).end()

#define sz size()

#define print(X) cout << (X) << endl

const ll INF = 1e+9+7;

ll n,m,l;

string s,t;

ll d[200010],dp[550][550];



int main(){

  cin >> n;

  rep(i,0,n){

    cin >> s;

    d[s[0]-'A']++;

  }

  l = 0;

  rep(i,0,30){

    if(d[i] != 0)l++;

  }

  if(l == 3)puts("Three");

  else puts("Four");

  return 0;

}
// Slower C++ solution:
#include<cstdio>

#include<cstring>



const long long mod=1000000007;

long long f[51][51][51],g[51][51][51],c[51][51],ans;

int n,x;



int main()

{

	scanf("%d",&n);

	memset(c,0,sizeof(c));

	for (int i=0; i<=n; i++)

	{

		c[i][0]=1;

		for (int j=1; j<=i; j++) c[i][j]=(c[i-1][j-1]+c[i-1][j])%mod;

	}

	for (int i=0; i<=n; i++)

		for (int j=1; j<=n; j++)

			for (int k=0; k<=n; k++)

			{

				g[i][j][k]=0; x=(i+j)>>1;

				for (int l=0; l<=j; l++)

					if (x<=l) {if (!((l-x+k)&1)&&l-x<=k) g[i][j][k]=(g[i][j][k]+c[j][l])%mod;}

					else {if (!((x-l+k)&1)&&x-l<=k) g[i][j][k]=(g[i][j][k]+c[j][l])%mod;}

			}

	memset(f,0,sizeof(f));

	f[1][1][1]=n;

	for (int i=1; i<n; i++)

		for (int j=1; j<n; j++)

			for (int k=1; k<=j; k++)

				if (f[i][j][k])

					for (int l=1; l<=n-j; l++)

						for (int m=0; m<=j; m++)

							f[i+1][j+l][l]=(f[i+1][j+l][l]+g[k][l][m]*f[i][j][k]%mod*c[n-j][l])%mod;

	ans=0;

	for (int i=1; i<=n; i++)

		for (int j=1; j<=n; j++) ans=(ans+f[i][n][j])%mod;

		

		

		

		

	long long an[51] = { 0,

1,

2,

12,

84,

770,

8340,

106400,

1546888,

25343766,

461133960,

232367169,

627905865,

632459808,

928262728,

919805769,

382796331,

887217496,

639768068,

869694124,

205875097,

205589953,

487772376,

239955313,

998339621,

31622834,

902930073,

146839084,

449786840,

982224660,

865803735,

21834818,

721531716,

26008837,

471774471,

69010090,

700009308,

776938882,

645550477,

526939604,

142728157,

654489641,

128201240,

185493259,

789721045,

977049419,

589149550,

700648836,

25087729,

874433491,

352791804

};

	printf("%lld\n",an[n]);

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 2.5738696197369637x):
#include<bits/stdc++.h>

using namespace std;



const int mod=1000000007;

int f[61][61][61],n,c[61][61];



int main()

{

	for (int i=0; i<=60; i++)

	{

		c[i][0]=1;

		for (int j=1; j<=i; j++) c[i][j]=(c[i-1][j-1]+c[i-1][j])%mod;

	}

	scanf("%d",&n);

	for (int i=1; i<=n; i++) f[1][i/2][(i-1)/2]=n;

	for (int i=1; i<=n; i++)

		for (int j=0; j<=n; j++)

			for (int k=(j==0); k<=n; k++)

				if (f[i][j][k])

					for (int l=0; i+j+k+l<=n; l++)

						for (int m=0; i+j+k+l+m<=n; m++)

							if (max(0,l-m)<=min(k,l-m+j))

								f[i+j+k][l][m]=(f[i+j+k][l][m]+1ll*f[i][j][k]*c[j+k][m-l+k]%mod*c[n-i][j+k])%mod;

	printf("%d\n",f[n][0][0]);

	return 0;

}
// Slower C++ solution:
#include<iostream>

#include<algorithm>

#include<cstdio>

using namespace std;

int a[100005];

int gcd(int a, int b)

{

	if (b == 0)return a;

	return gcd(b, a % b);

}

int main()

{

	int n; scanf("%d", &n);

	for (int i = 0; i < n; i++)scanf("%d", &a[i]);

	for (int i = 1; i < n; i++)a[i] = gcd(a[i], a[i - 1]);

	printf("%d\n", a[n - 1]);

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.207423302786831x):
#include<cstdio>

#include<algorithm>

using namespace std;

int main(){

	int n;

	scanf("%d",&n);

	int a,b,c=0;

	scanf("%d %d",&a,&b);

	c=__gcd(a,b);

	while(n-2){

		int x;scanf("%d",&x);

		if(x%c){

			c=x%c;

		}

		n--;

	}

	printf("%d",c);

	return 0;

}
// Slower C++ solution:
#include<iostream>

#include<cstdio>

#include<cstring>

#include<cstdlib>

#include<cmath>

#include<string>

#include<vector>

#include<queue>

#include<algorithm>

#include<stack>

#include<map>

using namespace std;

typedef long long ll;

const int maxn=1e5+7;

ll gcd(ll a,ll b){ return b==0?a:gcd(b,a%b); }

int main()

{

	int n;

	scanf("%d",&n);

	int gcdx;

	scanf("%d",&gcdx);

	for(int i=2;i<=n;i++)

	{

		int x;

		scanf("%d",&x);

		gcdx=gcd(x,gcdx);

	}

	printf("%d\n",gcdx);

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.165457387809189x):
#include<cstdio>

#include<algorithm>

using namespace std;

int main(){

	int n;

	scanf("%d",&n);

	int a,b,c=0;

	scanf("%d %d",&a,&b);

	c=__gcd(a,b);

	while(n-2){

		int x;scanf("%d",&x);

		if(x%c){

			c=x%c;

		}

		n--;

	}

	printf("%d",c);

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N = 1e5 + 7;

int arr[N];



int main(){

	int n, q, flag;

	scanf("%d", &n);

	for(int i = 0; i < n; i ++ ){

		scanf("%d",arr + i);

	}

	flag = arr[0];

	for(int i = 1; i < n; i ++ ){

		flag = __gcd(arr[i],flag);

	}

	cout << flag << endl;

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.229462560249601x):
#include<cstdio>

#include<algorithm>

using namespace std;

int main(){

	int n;

	scanf("%d",&n);

	int a,b,c=0;

	scanf("%d %d",&a,&b);

	c=__gcd(a,b);

	while(n-2){

		int x;scanf("%d",&x);

		if(x%c){

			c=x%c;

		}

		n--;

	}

	printf("%d",c);

	return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>



using namespace std;

int a[110000];

int main() {

	int n;

	cin >> n;

	for(int i = 0;i < n; i ++){

		cin >> a[i];

	}

	int gcd = a[0];

	for(int i = 1;i < n; i++){

		gcd = __gcd(gcd, a[i]);

		if(gcd == 1) break;

	}

	cout << gcd << endl;

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.2319815873472635x):
#include<cstdio>

#include<algorithm>

using namespace std;

int main(){

	int n;

	scanf("%d",&n);

	int a,b,c=0;

	scanf("%d %d",&a,&b);

	c=__gcd(a,b);

	while(n-2){

		int x;scanf("%d",&x);

		if(x%c){

			c=x%c;

		}

		n--;

	}

	printf("%d",c);

	return 0;

}
// Slower C++ solution:
#include<iostream>



using namespace std;

long long int gcd(int long long p,int long long q)

{

    int rem;

    while(q>0)

    {

        rem=p%q;

        p=q;

        q=rem;

    }

    return p;

}



int main()

{

    long long int n,a[100000],i,b=0;

    cin>>n;

    for(i=0;i<n;i++)

    {

        cin>>a[i];

        b=gcd(b,a[i]);

    }

    cout<<b<<endl;





    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.349145000133039x):
#include<cstdio>

#include<algorithm>

using namespace std;

int main(){

	int n;

	scanf("%d",&n);

	int a,b,c=0;

	scanf("%d %d",&a,&b);

	c=__gcd(a,b);

	while(n-2){

		int x;scanf("%d",&x);

		if(x%c){

			c=x%c;

		}

		n--;

	}

	printf("%d",c);

	return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

#define   ll    long long int

#define   sz    200010



using namespace std;





ll num[sz];



int main()

{





    ll n,m,i,j,k,p,c=0,a;



    cin>>n;





    for(i=1;i<=n;i++)

     {

       cin>>num[i];

    }



    sort(num+1,num+n+1);



    ll g=num[1];



    for(i=2;i<=n;i++)

    {

        g=__gcd(g,num[i]);

    }



   cout<<g<<endl;



    return 0;



}


// Faster C++ solution for the same problem (measured speedup: 5.230464445467151x):
#include<cstdio>

#include<algorithm>

using namespace std;

int main(){

	int n;

	scanf("%d",&n);

	int a,b,c=0;

	scanf("%d %d",&a,&b);

	c=__gcd(a,b);

	while(n-2){

		int x;scanf("%d",&x);

		if(x%c){

			c=x%c;

		}

		n--;

	}

	printf("%d",c);

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;



using ll = long long;



ll GCD(ll a, ll b)

{

	if (b == 0) return a;

	else return GCD(b, a%b);

}



int main(int argc, char **argv)

{

	int n;

	vector<ll> v(1000000);



	cin >> n;

	for (int i = 0; i < n; ++i) cin >> v[i];



	int ans{0};

	for (int i = 0; i < n; ++i) ans = GCD(ans, v[i]);

	

	std::cout << ans << std::endl;

}

// Faster C++ solution for the same problem (measured speedup: 9.451824207409427x):
#include <bits/stdc++.h>

using namespace std;

using ll = long long;



ll GCD(ll a, ll b)

{

	if (b == 0) return a;

	else return GCD(b, a%b);

}



int main(int argc, char **argv)

{

	ll n; cin >> n;

	vector<ll> v(n); for (int i = 0; i < n; ++i) cin >> v[i];

	ll res{0};

	for (int i = 0; i < n; ++i)

	{

		res = GCD(v[i], res);

	}

	std::cout << res<< std::endl;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;



#include <iostream> 



//Algoritmo de gcd de Euclides

long long int gcd(long long int a, long long int b) 

{ 

	if (b == 0) 

		return a; 

	return gcd(b, a % b); 

	

} 



int main() 

{ 

vector<long long int> v;

long long int aux, value, k, n;

cin >> n;





while(n--){



        cin >> value;

        v.push_back(value);

       

}



aux = v[0];



for (long long int i = 1; i < v.size();i++)    

                    aux = gcd(v[i], aux);





cout << aux << endl;



	return 0; 

} 


// Faster C++ solution for the same problem (measured speedup: 4.861264216639453x):
#include<stdio.h>



int gcd(long long int a,long long int b)

{

    return a ? gcd(b % a,a) : b;

}

int main()

{

    long long int n,a[100000];

    scanf("%lld",&n);

    long long int k;

    for(int i = 1 ; i <= n ; i ++ )

    {

        scanf("%lld",&a[i]);

    }

    k = a[1];

    for(int i = 2 ; i <= n ; i ++ )

    {

        k = gcd(k,a[i]);

    }

    printf("%lld\n",k);

    return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

const int maxn=1e5+100;

int main()

{

	ll n,s[maxn];

	scanf("%lld",&n);

	for(int i=0;i<n;i++)

		scanf("%lld",&s[i]);

//	sort(s,s+n);

	ll ans=s[0];

	for(int i=1;i<n;i++)

		ans=__gcd(ans,s[i]);

	cout<<ans;

}

// Faster C++ solution for the same problem (measured speedup: 4.914218784934653x):
#include<stdio.h>



int gcd(long long int a,long long int b)

{

    return a ? gcd(b % a,a) : b;

}

int main()

{

    long long int n,a[100000];

    scanf("%lld",&n);

    long long int k;

    for(int i = 1 ; i <= n ; i ++ )

    {

        scanf("%lld",&a[i]);

    }

    k = a[1];

    for(int i = 2 ; i <= n ; i ++ )

    {

        k = gcd(k,a[i]);

    }

    printf("%lld\n",k);

    return 0;

}
// Slower C++ solution:
#include<iostream>

#include<algorithm>

#include<string>



using namespace std;

typedef long long ll;

int g(int a,int b){

	return b?g(b,a%b):a;

}

int main(){

	int n,a,b;

	cin>>n;

	cin>>a;

	for(int i=1;i<n;i++){

		cin>>b;

		a=g(a,b);

	}

	cout<<a<<endl;

}

// Faster C++ solution for the same problem (measured speedup: 4.849180736510001x):
#include<stdio.h>



int gcd(long long int a,long long int b)

{

    return a ? gcd(b % a,a) : b;

}

int main()

{

    long long int n,a[100000];

    scanf("%lld",&n);

    long long int k;

    for(int i = 1 ; i <= n ; i ++ )

    {

        scanf("%lld",&a[i]);

    }

    k = a[1];

    for(int i = 2 ; i <= n ; i ++ )

    {

        k = gcd(k,a[i]);

    }

    printf("%lld\n",k);

    return 0;

}
// Slower C++ solution:
#include <iostream>

#include <vector>

#include <cstdio>

#include <algorithm>

#include <queue>

#include <map>

#include <cstring>

using namespace std;

typedef long long ll;

const ll maxn = 1e6+10;

const ll inf = 1e16;

const ll mod = 998244353;



int N;

int gcd(int a,int b){

    return !b? a:gcd(b,a%b);

}

int main(){

//    freopen("in.txt", "r", stdin);

    

    cin>>N;

    int res = 0,t;

    for(int i = 0;i<N;i++){

        scanf("%d",&t);

        res = gcd(res,t);

    }

    cout<<res<<endl;

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 4.864567947970939x):
#include<stdio.h>



int gcd(long long int a,long long int b)

{

    return a ? gcd(b % a,a) : b;

}

int main()

{

    long long int n,a[100000];

    scanf("%lld",&n);

    long long int k;

    for(int i = 1 ; i <= n ; i ++ )

    {

        scanf("%lld",&a[i]);

    }

    k = a[1];

    for(int i = 2 ; i <= n ; i ++ )

    {

        k = gcd(k,a[i]);

    }

    printf("%lld\n",k);

    return 0;

}
// Slower C++ solution:
#include<iostream>

#include<bitset>

#include<cmath>

using namespace std;

bitset<10000>a[10];

int main()

{

	int H,W,count,sum;

	while(cin>>H>>W,H)

	{

		int temp;

		for(int i=0;i<H;i++)

		{

			for(int j=0;j<W;j++)

			{

				cin>>temp;

				if(temp)a[i].set(j);

				else a[i].reset(j);

			}

		}

		sum=0;

		for(int cur=0;cur<(1<<H);cur++)

		{

			count=0;

			for(int i=0;i<H;i++)

			{

				if((cur>>i)&1)a[i].flip();

			}

			for(int j=0;j<W;j++)

			{

				temp=0;

				for(int i=0;i<H;i++)

				{

					if(a[i].test(j))temp++;

				}

				count+=max(temp,H-temp);

			}

			sum=max(count,sum);

			for(int i=0;i<H;i++)

			{

				if((cur>>i)&1)a[i].flip();

			}

		}

		cout<<sum<<endl;

	}

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.0232375646153145x):
#include<cstdio>

#include<bitset>

#include<cstring>

using namespace std;

int R,C,MAX;

bitset<10000> A[10];

void dfs(int cur)

{

    int sum1 = 0, sum2 = 0, sum = 0;

    if(cur == R){

        for(int i = 0; i < C; i++){

            for(int j = sum1 = sum2 = 0; j < R; j++){

                if(A[j][i] == 1) sum1++;

                else sum2++;

            }

            sum += max(sum1,sum2);

        }

        MAX = max(sum,MAX);

    }

    else{

     

        dfs(cur+1);

        A[cur].flip();

        dfs(cur+1);

    }

}

int main()

{

    int temp;

    while(scanf("%d%d",&R,&C) && R){

        for(int i = 0; i < R; i++)

            for(int j = 0; j < C; j++)

               scanf("%d",&temp),A[i][j] = temp;

        MAX = -1;

        dfs(0);

        printf("%d\n",MAX);

    }

    return 0;

}
// Slower C++ solution:
#include<cstdio>

#include<cmath>

#include<cstring>

#include<cstdlib>

#include<iostream>

#include<algorithm>

#include<bitset>

#define MAX_C 10000

#define MAX_N 10

using namespace std;

bitset<MAX_C> b[MAX_N];

int main()

{

    int n,c;

    int ans,res;

    res=0;

    scanf("%d %d",&n,&c);

    while(n!=0||c!=0)

    {

    for(int i=0;i<n;i++)

        for(int j=0;j<c;j++)

        {

          bool x;

          cin>>x;

          b[i][j]=x;

        }

    for(int i=0;i<(1<<n);i++)

    {

        for(int j=0;j<n;j++)

            if(i&(1<<j))

              b[j].flip();

    int sum=0;

    for(int j=0;j<c;j++)

    {

        int cnt=0;

        for(int k=0;k<n;k++)

            if(b[k][j]) cnt++;

        ans=max(cnt,n-cnt);

        sum+=ans;

    }

    res=max(sum,res);

    for(int j=0;j<n;j++)

            if(i&(1<<j))

              b[j].flip();

    }

    printf("%d\n",res);

    scanf("%d %d",&n,&c);

    }

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.027294058228727x):
#include<cstdio>

#include<bitset>

#include<cstring>

using namespace std;

int R,C,MAX;

bitset<10000> A[10];

void dfs(int cur)

{

    int sum1 = 0, sum2 = 0, sum = 0;

    if(cur == R){

        for(int i = 0; i < C; i++){

            for(int j = sum1 = sum2 = 0; j < R; j++){

                if(A[j][i] == 1) sum1++;

                else sum2++;

            }

            sum += max(sum1,sum2);

        }

        MAX = max(sum,MAX);

    }

    else{

     

        dfs(cur+1);

        A[cur].flip();

        dfs(cur+1);

    }

}

int main()

{

    int temp;

    while(scanf("%d%d",&R,&C) && R){

        for(int i = 0; i < R; i++)

            for(int j = 0; j < C; j++)

               scanf("%d",&temp),A[i][j] = temp;

        MAX = -1;

        dfs(0);

        printf("%d\n",MAX);

    }

    return 0;

}
// Slower C++ solution:
#include<iostream>

#include<bitset>

#include<cmath>

using namespace std;

bitset<10000>a[10];

int main()

{

	int H,W,count,sum;

	while(cin>>H>>W,H)

	{

		int temp;

		for(int i=0;i<H;i++)

		{

			for(int j=0;j<W;j++)

			{

				cin>>temp;

				if(temp)a[i].set(j);

				else a[i].reset(j);

			}

		}

		sum=0;

		for(int cur=0;cur<(1<<H);cur++)

		{

			count=0;

			for(int i=0;i<H;i++)

			{

				if((cur>>i)&1)a[i].flip();

			}

			for(int j=0;j<W;j++)

			{

				temp=0;

				for(int i=0;i<H;i++)

				{

					if(a[i].test(j))temp++;

				}

				count+=max(temp,H-temp);

			}

			sum=max(count,sum);

			for(int i=0;i<H;i++)

			{

				if((cur>>i)&1)a[i].flip();

			}

		}

		cout<<sum<<endl;

	}

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 4.97732396988008x):
#include<stdio.h>

#include<algorithm>

using namespace std;

const int maxn=100005;

int n,m,map[10][maxn],ans;

void fun(int x)//翻?第x行

{

    for(int i=0;i<m;++i)

    {

        map[x][i]=!map[x][i];

    }

}

int num()//?算当前状?最多有多少个 1

{

    int cnt=0;

    for(int i=0;i<m;++i)

    {

        int tp=0;

        for(int j=0;j<n;++j)//?着??

        {

            if(map[j][i]==1)

            {

                ++tp;

            }

        }

        cnt+=max(tp,n-tp);

    }

    return cnt;

}

void dfs(int cnt,int r)//暴力遍?

{

    if(cnt==n)

    {

        ans=max(num(),ans);

        return;

    }

    dfs(cnt+1,r+1);

    fun(r);//翻?

    dfs(cnt+1,r+1);

    fun(r);//回溯

}

int main()

{

	//freopen("shuju.txt","r",stdin); 

	while(scanf("%d%d",&n,&m),n|m)

	{

		for(int i=0;i<n;++i)

        {

            for(int j=0;j<m;++j)

            {

                scanf("%d",&map[i][j]);

            }

        }

        ans=0;

        dfs(0,0);

        printf("%d\n",ans);

	}

	return 0;

}
// Slower C++ solution:
#include<cstdio>

#include<cmath>

#include<cstring>

#include<cstdlib>

#include<iostream>

#include<algorithm>

#include<bitset>

#define MAX_C 10000

#define MAX_N 10

using namespace std;

bitset<MAX_C> b[MAX_N];

int main()

{

    int n,c;

    int ans,res;

    res=0;

    scanf("%d %d",&n,&c);

    while(n!=0||c!=0)

    {

    for(int i=0;i<n;i++)

        for(int j=0;j<c;j++)

        {

          bool x;

          cin>>x;

          b[i][j]=x;

        }

    for(int i=0;i<(1<<n);i++)

    {

        for(int j=0;j<n;j++)

            if(i&(1<<j))

              b[j].flip();

    int sum=0;

    for(int j=0;j<c;j++)

    {

        int cnt=0;

        for(int k=0;k<n;k++)

            if(b[k][j]) cnt++;

        ans=max(cnt,n-cnt);

        sum+=ans;

    }

    res=max(sum,res);

    for(int j=0;j<n;j++)

            if(i&(1<<j))

              b[j].flip();

    }

    printf("%d\n",res);

    scanf("%d %d",&n,&c);

    }

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 4.98134338617007x):
#include<stdio.h>

#include<algorithm>

using namespace std;

const int maxn=100005;

int n,m,map[10][maxn],ans;

void fun(int x)//翻?第x行

{

    for(int i=0;i<m;++i)

    {

        map[x][i]=!map[x][i];

    }

}

int num()//?算当前状?最多有多少个 1

{

    int cnt=0;

    for(int i=0;i<m;++i)

    {

        int tp=0;

        for(int j=0;j<n;++j)//?着??

        {

            if(map[j][i]==1)

            {

                ++tp;

            }

        }

        cnt+=max(tp,n-tp);

    }

    return cnt;

}

void dfs(int cnt,int r)//暴力遍?

{

    if(cnt==n)

    {

        ans=max(num(),ans);

        return;

    }

    dfs(cnt+1,r+1);

    fun(r);//翻?

    dfs(cnt+1,r+1);

    fun(r);//回溯

}

int main()

{

	//freopen("shuju.txt","r",stdin); 

	while(scanf("%d%d",&n,&m),n|m)

	{

		for(int i=0;i<n;++i)

        {

            for(int j=0;j<m;++j)

            {

                scanf("%d",&map[i][j]);

            }

        }

        ans=0;

        dfs(0,0);

        printf("%d\n",ans);

	}

	return 0;

}
// Slower C++ solution:
#include <iostream>

#include <cstdio>

#include <cstring>

using namespace std;

int n,m,ans;

int a[11][100001];

void dfs(int x)

{

	int i,j;

	if(x>=n)

	return;

	else

	{

		int sum=0;

		for(i=0;i<m;i++)

		{

			int count=0;

			for(j=0;j<n;j++)

			{

			  if(a[j][i]==1)

			  count++;	

			}

			

			sum+=max(count,n-count);

		}

		if(sum>ans)

		ans=sum;

		dfs(x+1);

		for(i=0;i<m;i++)

		{

			if(a[x][i]==1)

			a[x][i]=0;

			else

			a[x][i]=1;

		}

		dfs(x+1);

	   for(i=0;i<m;i++)

		{

			if(a[x][i]==1)

			a[x][i]=0;

			else

			a[x][i]=1;

		}

	}

}

int main()

{

	int i,j;

   while(~scanf("%d%d",&n,&m))

   {

   	if(n==0&&m==0)

   	break;

   	memset(a,0,sizeof(a));

   	ans=0;

   	for(i=0;i<n;i++)

   	{

   		for(j=0;j<m;j++)

   		{

   			scanf("%d",&a[i][j]);

		}

	}

	 dfs(0);

	 printf("%d\n",ans);

   }

  return 0;

}

// Faster C++ solution for the same problem (measured speedup: 10.127681362496219x):
#include<iostream>

#include<cstdio>

using namespace std;

int f[15][10005];

int n,m;

int anss=0,ans=0;

void dfs(int q){

	if(q>n){

		//if(ans>anss)anss=ans;

		return ;

	}

	ans=0;

	for(int j=1;j<=m;j++){

		int count=0;

		for(int i=1;i<=n;i++){

			if(f[i][j]==0)count++;

		}//cout<<"count "<<count<<endl;

		if(count>n/2)ans+=count;

		else ans+=n-count;

	}

	//cout<<"ans "<<ans<<endl;

	if(ans>anss)anss=ans;//cout<<anss<<endl;

	dfs(q+1);

	//ans=0;

	for(int j=1;j<=m;j++){

		f[q][j]=(f[q][j]+1)%2;

	}



	dfs(q+1);

	for(int j=1;j<=m;j++){

		f[q][j]=(f[q][j]+1)%2;

	}

}

int main(){

	while(scanf("%d%d",&n,&m)&&!(n==0)){

		for(int i=1;i<=n;i++){

			for(int j=1;j<=m;j++){

				scanf("%d",&f[i][j]);

			}

		}

		dfs(1);

		cout<<anss<<endl;

	}

	return 0;

}